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. 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 @@ + > 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'); } diff --git a/lib/fetcher.dart b/lib/fetcher.dart index 94a3d26..5d8d651 100644 --- a/lib/fetcher.dart +++ b/lib/fetcher.dart @@ -17,51 +17,71 @@ class _FetchAPIState extends State { return Scaffold( appBar: AppBar( title: const Text("Fetching API"), - ), - 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)}"), - ); - }, - ); - } - }, - ), - ), - ), - const SizedBox(height: 30,), - InkWell( - onTap: () { - Navigator.pushNamedAndRemoveUntil(context, '/', (route) => false); + actions: [ + IconButton( + onPressed: () { + setState(() { + fetchedArrivals = fetchArrivals(); + }); }, - child: Container( - padding: const EdgeInsets.all(20.0), - child: const Text("Homescreen"), - ), + icon: const Icon(Icons.refresh_sharp), ), - const SizedBox(height: 35,), + const SizedBox(width: 30,), ], ), + 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: 35,), + ], + ), + ), ); } + Future _refreshData() async { + setState(() { + fetchedArrivals = fetchArrivals(); + }); + } + @override void initState() { super.initState(); @@ -88,4 +108,4 @@ String weekNumToString(int weekday) { } throw "AAAAAAAAA"; -} \ No newline at end of file +} 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."), diff --git a/macos/Runner/Release.entitlements b/macos/Runner/Release.entitlements index 852fa1a..ee95ab7 100644 --- a/macos/Runner/Release.entitlements +++ b/macos/Runner/Release.entitlements @@ -4,5 +4,7 @@ com.apple.security.app-sandbox + com.apple.security.network.client +