Skip to content

Commit

Permalink
[FILTER]
Browse files Browse the repository at this point in the history
  • Loading branch information
KyrelJerome committed Jun 19, 2019
1 parent f29ee69 commit c112645
Show file tree
Hide file tree
Showing 5 changed files with 314 additions and 154 deletions.
158 changes: 86 additions & 72 deletions lib/CreditsRoute.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Icon(
TFoods.tfoodstologotest,
size: 80.0,
color: Colors.indigo[100],
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
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: <Widget>[
// Text("Suggestion?"),
RaisedButton(
child: Text("Leave a Review!"),
onPressed: () {
LaunchReview.launch();
},
)
],
),
),
Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Center(
child: Text(
"Disclaimer",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Colors.white,
),
textAlign: TextAlign.center,
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
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: <Widget>[
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();
},
)
],
),
),
Expand Down
92 changes: 47 additions & 45 deletions lib/FoodDisplayRoute.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -26,6 +27,7 @@ class _FoodDisplayRouteState extends State<FoodDisplayRoute> {
final TextEditingController _searchFilter = new TextEditingController();
Widget _appBarTitle;
Widget _BottomDrawer;
int loadingInt = 0;

Icon _searchIcon;
String _searchText;
Expand All @@ -44,6 +46,7 @@ class _FoodDisplayRouteState extends State<FoodDisplayRoute> {
);
_BottomDrawer = BottomDrawerWidget(
generalFilters: generalFilters, campusFilters: campusFilters);
int loadingInt = 0;
}

void initFilters() {
Expand Down Expand Up @@ -97,13 +100,30 @@ class _FoodDisplayRouteState extends State<FoodDisplayRoute> {
}

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: <Widget>[
//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(
Expand Down Expand Up @@ -135,16 +155,19 @@ class _FoodDisplayRouteState extends State<FoodDisplayRoute> {
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: <Widget>[
IconButton(
icon: _searchIcon,
Expand Down Expand Up @@ -189,6 +212,7 @@ class _FoodDisplayRouteState extends State<FoodDisplayRoute> {
Divider(
height: 0,
),
storeLoader,
storeListWrapper,
],
),
Expand Down Expand Up @@ -228,22 +252,6 @@ class _FoodDisplayRouteState extends State<FoodDisplayRoute> {
return _BottomDrawer;
}

// List<Widget> getGeneralFilters() {
// List<Widget> widgets = List();
// for (StoreFilter filter in generalFilters) {
// widgets.add(filter.filterChip);
// }
// return widgets;
// }

// List<Widget> getCampusFilters() {
// List<Widget> widgets = List();
// for (StoreFilter filter in campusFilters) {
// widgets.add(filter.filterChip);
// }
// return widgets;
// }

void loadUnfilteredStores() async {
print("Loading Unfiltered Stores");
List<Store> loadStream = await api.getFoodsJson();
Expand All @@ -261,13 +269,16 @@ class _FoodDisplayRouteState extends State<FoodDisplayRoute> {
}
setState(() {
stores = loadStream;
updateFilteredStores();
});
updateFilteredStores();
loadAllStoreImages();
} else {}
}
}

void updateFilteredStores() {
setState(() {
loadingInt -= 1;
});
List<Store> tempStores = List();
print("Length: " + tempStores.length.toString());
for (Store store in stores) {
Expand All @@ -287,7 +298,10 @@ class _FoodDisplayRouteState extends State<FoodDisplayRoute> {
tempStores2.add(store);
}
}
filteredStores = tempStores2;
setState(() {
loadingInt += 1;
filteredStores = tempStores2;
});
}

bool isSearchFiltered(Store store) {
Expand Down Expand Up @@ -324,17 +338,6 @@ class _FoodDisplayRouteState extends State<FoodDisplayRoute> {
}
});
}

// List<FilterChip> buildFiltersList() {
// List<FilterChip> widgets = List();
// generalFilters.forEach((StoreFilter filter) {
// widgets.add(filter.filterChip);
// });
// campusFilters.forEach((StoreFilter filter) {
// widgets.add(filter.filterChip);
// });
// return widgets;
// }
}

class BottomDrawerWidget extends StatefulWidget {
Expand Down Expand Up @@ -362,7 +365,7 @@ class _BottomDrawerWidgetState extends State<BottomDrawerWidget> {
"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]),
],
),
),
Expand All @@ -381,7 +384,6 @@ class _BottomDrawerWidgetState extends State<BottomDrawerWidget> {
spacing: 8,
children: getCampusFilters(),
),

Center(
child: Container(
child: Text(
Expand Down
Loading

0 comments on commit c112645

Please sign in to comment.