From c112645b3cea8db3c5bfde9e168ed4f5b6302f29 Mon Sep 17 00:00:00 2001 From: Kyrel Jerome Date: Tue, 18 Jun 2019 22:31:02 -0400 Subject: [PATCH] [FILTER] --- lib/CreditsRoute.dart | 158 ++++++++++++++++++--------------- lib/FoodDisplayRoute.dart | 92 +++++++++---------- lib/SplashRoute.dart | 182 ++++++++++++++++++++++++++++++++++++-- lib/StoreViewRoute.dart | 35 ++------ pubspec.yaml | 1 + 5 files changed, 314 insertions(+), 154 deletions(-) diff --git a/lib/CreditsRoute.dart b/lib/CreditsRoute.dart index 824835e..1198007 100644 --- a/lib/CreditsRoute.dart +++ b/lib/CreditsRoute.dart @@ -1,5 +1,6 @@ import 'package:deer_food/presentation/t_foods_icons.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; import 'Objects/Store.dart'; import 'package:launch_review/launch_review.dart'; @@ -14,93 +15,106 @@ class CreditsRoute extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - backgroundColor: Colors.indigo[800], - centerTitle: true, - title: Text("About UofT Foods"), - ), body: Container( color: Colors.indigo, - padding: EdgeInsets.all(8), + padding: EdgeInsets.only( + bottom: 8, + top: 32, + left: 8, + right: 8, + ), height: double.infinity, width: double.infinity, child: InkWell( child: Center( child: Column( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.center, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Icon( - TFoods.tfoodstologotest, - size: 80.0, - color: Colors.indigo[100], - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text("Powered by ", style: TextStyle( - fontSize: 18, - color: Colors.white, - fontWeight: FontWeight.w600, - ), ), - Container( - margin: EdgeInsets.all(8), - child: FlutterLogo( - size: 80, - ), - ), - ], - ), - Container( + Expanded( child: Row( + mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - // Text("Suggestion?"), - RaisedButton( - child: Text("Leave a Review!"), - onPressed: () { - LaunchReview.launch(); - }, - ) - ], - ), - ), - Column( - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Center( - child: Text( - "Disclaimer", - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.w600, - color: Colors.white, - ), - textAlign: TextAlign.center, + Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Icon( + TFoods.tfoodstologotest, + size: 100.0, + color: Colors.indigo[100], + ), + Text( + "Powered by ", + style: TextStyle( + fontSize: 18, + color: Colors.white, + fontWeight: FontWeight.w600, + ), + ), + Container( + margin: EdgeInsets.all(8), + child: FlutterLogo( + size: 100, + ), + ), + ], ), - ), - Container( - margin: EdgeInsets.all(16), - child: Text( - " We are not affiliated, associated, authorized, endorsed by, or in any way officially connected with The University of Toronto, or any of its subsidiaries or its affiliates. The official The University of Toronto website can be found at https://www.utoronto.ca/ . The name “The University of Toronto” as well as related names, marks, emblems and images are registered trademarks of The University of Toronto. ", - style: TextStyle( - fontSize: 18, - color: Colors.white, - fontWeight: FontWeight.w600, + Expanded( + child: Container( + margin: EdgeInsets.symmetric(horizontal:32), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + mainAxisSize: MainAxisSize.max, + children: [ + Center( + child: Text( + "Disclaimer", + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w600, + color: Colors.indigo[100], + ), + textAlign: TextAlign.center, + ), + ), + Container( + margin: EdgeInsets.all(8), + child: Text( + " We are not affiliated, associated, authorized, endorsed by, or in any way officially connected with The University of Toronto, or any of its subsidiaries or its affiliates. The official The University of Toronto website can be found at https://www.utoronto.ca/ . The name “The University of Toronto” as well as related names, marks, emblems and images are registered trademarks of The University of Toronto. ", + softWrap: true, + overflow: TextOverflow.visible, + maxLines: 8, + style: TextStyle( + fontSize: 12, + color: Colors.indigo[100], + fontWeight: FontWeight.w600, + ), + ), + ), + Container( + //margin: EdgeInsets.all(16), + child: Text( + "All data presented is updated periodically from the Cobalt API, we are not liable for innaccuracies, but try to keep data accurate.", + style: TextStyle( + fontSize: 12, + color: Colors.indigo[100], + fontWeight: FontWeight.w600, + ), + textAlign: TextAlign.center, + ), + ), + ], + ), ), - textAlign: TextAlign.center, ), - ), - ], + ], + ), ), + RaisedButton( + child: Text("Got a Suggestion? Leave a Review!"), + onPressed: () { + LaunchReview.launch(); + }, + ) ], ), ), diff --git a/lib/FoodDisplayRoute.dart b/lib/FoodDisplayRoute.dart index 9354926..b6c5112 100644 --- a/lib/FoodDisplayRoute.dart +++ b/lib/FoodDisplayRoute.dart @@ -6,6 +6,7 @@ import 'Objects/Store.dart'; import 'API/cobaltFoodsWrapper.dart'; import 'Objects/StoreFilter.dart'; import 'presentation/t_foods_icons.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; class FoodDisplayRoute extends StatefulWidget { FoodDisplayRoute({Key key, this.title}) : super(key: key); @@ -26,6 +27,7 @@ class _FoodDisplayRouteState extends State { final TextEditingController _searchFilter = new TextEditingController(); Widget _appBarTitle; Widget _BottomDrawer; + int loadingInt = 0; Icon _searchIcon; String _searchText; @@ -44,6 +46,7 @@ class _FoodDisplayRouteState extends State { ); _BottomDrawer = BottomDrawerWidget( generalFilters: generalFilters, campusFilters: campusFilters); + int loadingInt = 0; } void initFilters() { @@ -97,13 +100,30 @@ class _FoodDisplayRouteState extends State { } void filterAction(bool value) { - setState(() { - updateFilteredStores(); - }); + updateFilteredStores(); } @override Widget build(BuildContext context) { + Widget storeLoader; + if (loadingInt == 0) { + storeLoader = Container(width: 0, height: 0); + } else { + storeLoader = Column( + children: [ + //loading stuff + SpinKitFadingCircle( + itemBuilder: (_, int index) { + return DecoratedBox( + decoration: BoxDecoration( + color: index.isEven ? Colors.indigo : Colors.blueGrey, + ), + ); + }, + ), + ], + ); + } Widget storeListWrapper; if (filteredStores != null && filteredStores.length > 0) { storeListWrapper = Expanded( @@ -135,16 +155,19 @@ class _FoodDisplayRouteState extends State { appBar: AppBar( title: _appBarTitle, leading: IconButton( - icon: Icon( - TFoods.tfoodstologotest, - size: 24.0, - color: Colors.white, - ), - onPressed: () => Navigator.push( - context, - MaterialPageRoute(builder: (context) => CreditsRoute()), - ), - ), + icon: Icon( + TFoods.tfoodstologotest, + size: 24.0, + color: Colors.white, + ), + onPressed: () { + setState( + () => Navigator.push( + context, + MaterialPageRoute(builder: (context) => CreditsRoute()), + ), + ); + }), actions: [ IconButton( icon: _searchIcon, @@ -189,6 +212,7 @@ class _FoodDisplayRouteState extends State { Divider( height: 0, ), + storeLoader, storeListWrapper, ], ), @@ -228,22 +252,6 @@ class _FoodDisplayRouteState extends State { return _BottomDrawer; } - // List getGeneralFilters() { - // List widgets = List(); - // for (StoreFilter filter in generalFilters) { - // widgets.add(filter.filterChip); - // } - // return widgets; - // } - - // List getCampusFilters() { - // List widgets = List(); - // for (StoreFilter filter in campusFilters) { - // widgets.add(filter.filterChip); - // } - // return widgets; - // } - void loadUnfilteredStores() async { print("Loading Unfiltered Stores"); List loadStream = await api.getFoodsJson(); @@ -261,13 +269,16 @@ class _FoodDisplayRouteState extends State { } setState(() { stores = loadStream; - updateFilteredStores(); }); + updateFilteredStores(); loadAllStoreImages(); - } else {} + } } void updateFilteredStores() { + setState(() { + loadingInt -= 1; + }); List tempStores = List(); print("Length: " + tempStores.length.toString()); for (Store store in stores) { @@ -287,7 +298,10 @@ class _FoodDisplayRouteState extends State { tempStores2.add(store); } } - filteredStores = tempStores2; + setState(() { + loadingInt += 1; + filteredStores = tempStores2; + }); } bool isSearchFiltered(Store store) { @@ -324,17 +338,6 @@ class _FoodDisplayRouteState extends State { } }); } - - // List buildFiltersList() { - // List widgets = List(); - // generalFilters.forEach((StoreFilter filter) { - // widgets.add(filter.filterChip); - // }); - // campusFilters.forEach((StoreFilter filter) { - // widgets.add(filter.filterChip); - // }); - // return widgets; - // } } class BottomDrawerWidget extends StatefulWidget { @@ -362,7 +365,7 @@ class _BottomDrawerWidgetState extends State { "REFINE RESULTS", style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600), ), - Icon(Icons.filter_list ,color: Colors.grey[500]), + Icon(Icons.filter_list, color: Colors.grey[500]), ], ), ), @@ -381,7 +384,6 @@ class _BottomDrawerWidgetState extends State { spacing: 8, children: getCampusFilters(), ), - Center( child: Container( child: Text( diff --git a/lib/SplashRoute.dart b/lib/SplashRoute.dart index 9df1306..f1ef386 100644 --- a/lib/SplashRoute.dart +++ b/lib/SplashRoute.dart @@ -1,5 +1,5 @@ +import 'dart:ui'; import 'package:flutter/material.dart'; - import 'FoodDisplayRoute.dart'; import 'presentation/t_foods_icons.dart'; @@ -8,24 +8,194 @@ class SplashRoute extends StatelessWidget { SplashRoute({this.title}); @override Widget build(BuildContext context) { + if (MediaQuery.of(context).orientation == Orientation.landscape) { + return Scaffold( + body: Container( + width: double.infinity, + height: double.infinity, + padding: EdgeInsets.only(bottom: 32, top: 48, left: 32, right: 32), + color: Colors.indigo, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Icon( + TFoods.tfoodstologotest, + size: 100.0, + color: Colors.indigo[100], + ), + Column( + children: [ + Center( + child: Text( + "Welcome To", + style: Theme.of(context).textTheme.display1.copyWith( + //fontStyle: FontStyle.italic, + color: Colors.white, + textBaseline: TextBaseline.ideographic), + ), + ), + Center( + child: Container( + child: Text( + "UofT Foods", + style: Theme.of(context) + .textTheme + .display3 + .copyWith( + color: Colors.white, + textBaseline: TextBaseline.ideographic), + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + Container( + margin: EdgeInsets.symmetric(horizontal: 16), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(right: 8), + child: Icon(Icons.fastfood, + color: Colors.white54), + ), + Text( + "Search Foods on Campus", + style: Theme.of(context) + .textTheme + .button + .copyWith( + fontSize: 20, + color: Colors.white70), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(right: 8), + child: Icon(Icons.store, + color: Colors.white54), + ), + Text( + "Filter By Campus", + style: Theme.of(context) + .textTheme + .button + .copyWith( + fontSize: 20, + color: Colors.white70), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(right: 8), + child: Icon(Icons.timer, + color: Colors.white54), + ), + Text( + "See Store Hours", + style: Theme.of(context) + .textTheme + .button + .copyWith( + fontSize: 20, + color: Colors.white70), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(right: 8), + child: Icon(Icons.location_on, + color: Colors.white54), + ), + Text( + "See Store Location", + style: Theme.of(context) + .textTheme + .button + .copyWith( + fontSize: 20, + color: Colors.white70), + ), + ], + ), + ], + ), + ), + ], + ), + ], + ), + ], + ), + RaisedButton( + color: Colors.white, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Center( + child: Text( + "Continue", + style: Theme.of(context) + .textTheme + .button + .copyWith(fontSize: 20), + ), + ), + Center( + child: Icon(Icons.arrow_forward), + ), + ], + ), + onPressed: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + FoodDisplayRoute(title: this.title)), + ), + ), + ], + ), + ), + ); + } return Scaffold( body: Container( width: double.infinity, height: double.infinity, - padding: EdgeInsets.symmetric(vertical: 48, horizontal: 32), + padding: EdgeInsets.only(bottom: 32, top: 48, left: 32, right: 32), color: Colors.indigo, child: Column( crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Center( child: Text( "Welcome To", style: Theme.of(context).textTheme.display1.copyWith( + //fontStyle: FontStyle.italic, color: Colors.white, textBaseline: TextBaseline.ideographic), ), ), - Spacer(), Icon( TFoods.tfoodstologotest, size: 64.0, @@ -33,7 +203,6 @@ class SplashRoute extends StatelessWidget { ), Center( child: Container( - margin: EdgeInsets.only(top: 16), child: Text( "UofT Foods", style: Theme.of(context).textTheme.display3.copyWith( @@ -42,7 +211,6 @@ class SplashRoute extends StatelessWidget { ), ), ), - Spacer(), Container( margin: EdgeInsets.symmetric(horizontal: 16), child: Column( @@ -114,7 +282,6 @@ class SplashRoute extends StatelessWidget { ], ), ), - Spacer(), RaisedButton( color: Colors.white, child: Row( @@ -137,7 +304,8 @@ class SplashRoute extends StatelessWidget { onPressed: () => Navigator.push( context, MaterialPageRoute( - builder: (context) => FoodDisplayRoute(title: this.title)), + builder: (context) => + FoodDisplayRoute(title: this.title)), ), ), ], diff --git a/lib/StoreViewRoute.dart b/lib/StoreViewRoute.dart index d8a1866..d0503df 100644 --- a/lib/StoreViewRoute.dart +++ b/lib/StoreViewRoute.dart @@ -80,36 +80,11 @@ class StoreViewRoute extends StatelessWidget { children: [ Container( width: double.infinity, - child: Stack( - children: [ - imageHolder, - Container( - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 8.0, vertical: 16.0), - child: IconButton( - iconSize: 32, - icon: Opacity( - child: Container( - decoration: new BoxDecoration( - shape: BoxShape.circle, - color: Colors.white70, - ), - child: Icon(Icons.arrow_back), - ), - opacity: 0.5, - ), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ), - ), - ], - ), + child: imageHolder, ), - Center( - child: new Text( + Container( + margin: EdgeInsets.symmetric(vertical: 16), + child: Text( store.name.toString().trim(), textAlign: TextAlign.center, style: Theme.of(context).textTheme.title, @@ -125,7 +100,7 @@ class StoreViewRoute extends StatelessWidget { children: [ Text(store.description.trim(), textAlign: TextAlign.center, - maxLines: 7, + maxLines: 9, style: Theme.of(context).textTheme.body1), // Divider(), // Text(store.website, diff --git a/pubspec.yaml b/pubspec.yaml index 9d0268d..628cfcd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,6 +14,7 @@ environment: dependencies: shared_preferences: ^0.5.3+1 launch_review: ^2.0.0 + flutter_spinkit: "^3.1.0" url_launcher: ^4.0.3 http: ^0.12.0 flutter: