Fetch fetches, layout bettered
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
Future<Album> createAlbum(String title) async {
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:witl/album_fetch.dart';
|
||||
import 'package:witl/arrival_fetch.dart';
|
||||
|
||||
class FetchAPI extends StatefulWidget {
|
||||
const FetchAPI({super.key});
|
||||
@@ -17,8 +17,9 @@ class _FetchAPIState extends State<FetchAPI> {
|
||||
appBar: AppBar(
|
||||
title: const Text("Fetching API"),
|
||||
),
|
||||
body: Row(
|
||||
children: <Widget>[
|
||||
body: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
child: FutureBuilder<List<Arrival>>(
|
||||
@@ -33,7 +34,9 @@ class _FetchAPIState extends State<FetchAPI> {
|
||||
itemCount: snapshot.data!.length,
|
||||
itemBuilder: (context, index) {
|
||||
return ListTile(
|
||||
title: Text(snapshot.data![index].timeOfDay),
|
||||
title: Text("Arrival Time: ${snapshot.data![index].timeOfDay}"),
|
||||
titleAlignment: ListTileTitleAlignment.center,
|
||||
subtitle: Text("Week Day: ${weekNumToString(snapshot.data![index].weekDay)}"),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -42,6 +45,7 @@ class _FetchAPIState extends State<FetchAPI> {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30,),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.pushNamedAndRemoveUntil(context, '/', (route) => false);
|
||||
@@ -51,6 +55,7 @@ class _FetchAPIState extends State<FetchAPI> {
|
||||
child: const Text("Homescreen"),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 35,),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -62,3 +67,24 @@ class _FetchAPIState extends State<FetchAPI> {
|
||||
fetchedArrivals = fetchArrivals();
|
||||
}
|
||||
}
|
||||
|
||||
String weekNumToString(int weekday) {
|
||||
switch (weekday) {
|
||||
case 1:
|
||||
return "Monday";
|
||||
case 2:
|
||||
return "Tuesday";
|
||||
case 3:
|
||||
return "Wednesday";
|
||||
case 4:
|
||||
return "Thursday";
|
||||
case 5:
|
||||
return "Friday";
|
||||
case 6:
|
||||
return "Saturday";
|
||||
case 7:
|
||||
return "Sunday";
|
||||
}
|
||||
|
||||
throw "AAAAAAAAA";
|
||||
}
|
||||
@@ -5,7 +5,7 @@ class InputData extends StatefulWidget {
|
||||
const InputData({super.key});
|
||||
|
||||
@override
|
||||
_InputDataState createState() => _InputDataState();
|
||||
State<InputData> createState() => _InputDataState();
|
||||
}
|
||||
|
||||
class _InputDataState extends State<InputData> {
|
||||
|
||||
Reference in New Issue
Block a user