From 52454e36d696883c1533357506e851794e7f7568 Mon Sep 17 00:00:00 2001 From: Supermjork Date: Wed, 27 Dec 2023 00:46:06 +0200 Subject: [PATCH 1/6] Pub get, and const --- lib/home_screen.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/home_screen.dart b/lib/home_screen.dart index 72feed7..d01fa8c 100644 --- a/lib/home_screen.dart +++ b/lib/home_screen.dart @@ -24,7 +24,7 @@ class HomeScreen extends StatelessWidget { body: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Row( + const Row( mainAxisAlignment: MainAxisAlignment.center, children:[ Text("We may not be able to tell you why.\nBut surely are able to predict when."), From 828f97ce16307a0f8b80d0fab6ddc90e204b3138 Mon Sep 17 00:00:00 2001 From: Supermjork Date: Wed, 27 Dec 2023 13:18:27 +0200 Subject: [PATCH 2/6] Asking for Internet Perms --- android/app/src/main/AndroidManifest.xml | 1 + macos/Runner/Release.entitlements | 2 ++ 2 files changed, 3 insertions(+) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 5119000..cff34e9 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,4 +1,5 @@ + com.apple.security.app-sandbox + com.apple.security.network.client + From c4160118647a4d617ba819c385a2e9e1399356a7 Mon Sep 17 00:00:00 2001 From: Supermjork Date: Wed, 27 Dec 2023 16:45:42 +0200 Subject: [PATCH 3/6] Reversing fetched list (New to Old) --- lib/fetcher.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/fetcher.dart b/lib/fetcher.dart index 94a3d26..288367f 100644 --- a/lib/fetcher.dart +++ b/lib/fetcher.dart @@ -17,6 +17,15 @@ class _FetchAPIState extends State { return Scaffold( appBar: AppBar( title: const Text("Fetching API"), + actions: [ + IconButton( + onPressed: () { + setState(() { + fetchedArrivals = fetchArrivals(); + }); + }, + icon: const Icon(Icons.refresh_rounded)) + ], ), body: Column( mainAxisAlignment: MainAxisAlignment.start, From c9f990e7fdfdeba2edc8f8c965e0a4e2c412e1c9 Mon Sep 17 00:00:00 2001 From: Supermjork Date: Wed, 27 Dec 2023 16:46:03 +0200 Subject: [PATCH 4/6] REFRESH BUTTON --- lib/arrival_fetch.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/arrival_fetch.dart b/lib/arrival_fetch.dart index 6cccb8d..e7bd392 100644 --- a/lib/arrival_fetch.dart +++ b/lib/arrival_fetch.dart @@ -15,7 +15,7 @@ Future> fetchArrivals() async { // })); Iterable I = json.decode(response.body); List arrivals = List.from(I.map((model)=>Arrival.fromJson(model))); - return arrivals; + return arrivals.reversed.toList(); } else { throw Exception('Failed to load Arrival'); } From cecc3a93a83f3fbcd55cff6d7cab22a038a244d5 Mon Sep 17 00:00:00 2001 From: Supermjork Date: Wed, 27 Dec 2023 16:55:37 +0200 Subject: [PATCH 5/6] Pull down to refresh (yw lingy) --- lib/fetcher.dart | 89 +++++++++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 39 deletions(-) diff --git a/lib/fetcher.dart b/lib/fetcher.dart index 288367f..5d8d651 100644 --- a/lib/fetcher.dart +++ b/lib/fetcher.dart @@ -24,53 +24,64 @@ class _FetchAPIState extends State { fetchedArrivals = fetchArrivals(); }); }, - icon: const Icon(Icons.refresh_rounded)) + icon: const Icon(Icons.refresh_sharp), + ), + const SizedBox(width: 30,), ], ), - body: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - child: SizedBox( - child: FutureBuilder>( - future: fetchedArrivals, - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return const CircularProgressIndicator(); - } else if (snapshot.hasError) { - return Text('Failed to fetch data.\nError: ${snapshot.error}'); - } else { - return ListView.builder( - itemCount: snapshot.data!.length, - itemBuilder: (context, index) { - return ListTile( - title: Text("Arrival Time: ${snapshot.data![index].timeOfDay}"), - titleAlignment: ListTileTitleAlignment.center, - subtitle: Text("Week Day: ${weekNumToString(snapshot.data![index].weekDay)}"), - ); - }, - ); - } - }, + body: RefreshIndicator( + onRefresh: _refreshData, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: SizedBox( + child: FutureBuilder>( + future: fetchedArrivals, + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const CircularProgressIndicator(); + } else if (snapshot.hasError) { + return Text('Failed to fetch data.\nError: ${snapshot.error}'); + } else { + return ListView.builder( + itemCount: snapshot.data!.length, + itemBuilder: (context, index) { + return ListTile( + title: Text("Arrival Time: ${snapshot.data![index].timeOfDay}"), + titleAlignment: ListTileTitleAlignment.center, + subtitle: Text("Week Day: ${weekNumToString(snapshot.data![index].weekDay)}"), + ); + }, + ); + } + }, + ), ), ), - ), - const SizedBox(height: 30,), - InkWell( - onTap: () { - Navigator.pushNamedAndRemoveUntil(context, '/', (route) => false); - }, - child: Container( - padding: const EdgeInsets.all(20.0), - child: const Text("Homescreen"), + const SizedBox(height: 30,), + InkWell( + onTap: () { + Navigator.pushNamedAndRemoveUntil(context, '/', (route) => false); + }, + child: Container( + padding: const EdgeInsets.all(20.0), + child: const Text("Homescreen"), + ), ), - ), - const SizedBox(height: 35,), - ], + const SizedBox(height: 35,), + ], + ), ), ); } + Future _refreshData() async { + setState(() { + fetchedArrivals = fetchArrivals(); + }); + } + @override void initState() { super.initState(); @@ -97,4 +108,4 @@ String weekNumToString(int weekday) { } throw "AAAAAAAAA"; -} \ No newline at end of file +} From 7e876bc36d0a4fb205b7711eb061ee3917fbf261 Mon Sep 17 00:00:00 2001 From: Supermjork Date: Wed, 27 Dec 2023 17:08:50 +0200 Subject: [PATCH 6/6] README rework --- README.md | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 107d2e3..9a6f4ed 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,9 @@ -# witl +# WITL -A new Flutter project. +"We cannot tell you why the tram is late But surely can predict (sort of) its arrival" ## Getting Started -This project is a starting point for a Flutter application. +Flutter project aimed as a cross-platform extension of the [Native Android Version](https://github.com/LinlyBoi/WITL) of WITL. -A few resources to get you started if this is your first Flutter project: - -- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) - -For help getting started with Flutter development, view the -[online documentation](https://docs.flutter.dev/), which offers tutorials, -samples, guidance on mobile development, and a full API reference. +Also includes actual usage of our [From Scratch API](https://github.com/LinlyBoi/witl-api) written in Rust and Docker-deployed.