From d25327602a3ad5459acb2c099a724ed87df14c3b Mon Sep 17 00:00:00 2001 From: Supermjork Date: Tue, 26 Dec 2023 21:49:27 +0200 Subject: [PATCH] Fetch fetches, layout bettered --- lib/{album_fetch.dart => arrival_fetch.dart} | 0 lib/{album_post.dart => arrival_post.dart} | 1 + lib/fetcher.dart | 34 +++++++++++++++++--- lib/input_data.dart | 2 +- 4 files changed, 32 insertions(+), 5 deletions(-) rename lib/{album_fetch.dart => arrival_fetch.dart} (100%) rename lib/{album_post.dart => arrival_post.dart} (99%) diff --git a/lib/album_fetch.dart b/lib/arrival_fetch.dart similarity index 100% rename from lib/album_fetch.dart rename to lib/arrival_fetch.dart diff --git a/lib/album_post.dart b/lib/arrival_post.dart similarity index 99% rename from lib/album_post.dart rename to lib/arrival_post.dart index f5f1d04..f6ad2bb 100644 --- a/lib/album_post.dart +++ b/lib/arrival_post.dart @@ -1,4 +1,5 @@ import 'dart:convert'; + import 'package:http/http.dart' as http; Future createAlbum(String title) async { diff --git a/lib/fetcher.dart b/lib/fetcher.dart index de30f0e..4837f43 100644 --- a/lib/fetcher.dart +++ b/lib/fetcher.dart @@ -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 { appBar: AppBar( title: const Text("Fetching API"), ), - body: Row( - children: [ + body: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ Expanded( child: SizedBox( child: FutureBuilder>( @@ -33,7 +34,9 @@ class _FetchAPIState extends State { 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 { ), ), ), + const SizedBox(height: 30,), InkWell( onTap: () { Navigator.pushNamedAndRemoveUntil(context, '/', (route) => false); @@ -51,6 +55,7 @@ class _FetchAPIState extends State { child: const Text("Homescreen"), ), ), + const SizedBox(height: 35,), ], ), ); @@ -62,3 +67,24 @@ class _FetchAPIState extends State { 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"; +} \ No newline at end of file diff --git a/lib/input_data.dart b/lib/input_data.dart index 539adb6..e611882 100644 --- a/lib/input_data.dart +++ b/lib/input_data.dart @@ -5,7 +5,7 @@ class InputData extends StatefulWidget { const InputData({super.key}); @override - _InputDataState createState() => _InputDataState(); + State createState() => _InputDataState(); } class _InputDataState extends State {