Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion UI #32

Merged
merged 5 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions src/lib/model/foodfeup_suggestion_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../view/Pages/foodfeup_suggestion_view.dart';
import '../view/Pages/secondary_page_view.dart';

class FoodFeupSuggestionPage extends StatefulWidget {
const FoodFeupSuggestionPage({Key key}) : super(key: key);

@override
_FoodFeupSuggestionPageState createState() => _FoodFeupSuggestionPageState();
}

class _FoodFeupSuggestionPageState extends SecondaryPageViewState {
final int weekDay = DateTime
.now()
.weekday;


final List<String> options = [
'indiferente',
'Carne',
'Peixe',
'Vegetariano',
'Dieta',
'Sopa',
];

@override
void initState() {
super.initState();

}

@override
void dispose() {
super.dispose();
}

Widget LoadingScreen() {

return Center(
child: SizedBox(
width: 60,
height: 60,
child: CircularProgressIndicator(),
)
);
}


@override
Widget getBody(BuildContext context) {
return FoodFeupSuggestionPageView(
options: options,

);
}
}
116 changes: 116 additions & 0 deletions src/lib/view/Pages/foodfeup_suggestion_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@


import 'package:flutter/material.dart';
import 'package:uni/view/Widgets/page_title.dart';

class FoodFeupSuggestionPageView extends StatelessWidget {
FoodFeupSuggestionPageView({
Key key,
@required this.options,
this.mealType,
this.mealRating,
this.mealRatingQuant,
this.mealName,
this.establishment
});

final List<String> options;
String dropdownValue;
String mealType;
int mealRating;
String mealRatingQuant;
String mealName;
String establishment;

@override
Widget build(BuildContext context){
dropdownValue = options[0];//TODO: read these from somewhere
establishment = "Cantina almoço";
mealType = "Vegetariano";
mealRating = 4;
mealRatingQuant = "23";
mealName = "Jardineira de soja (batata,ervilhas e cenoura)";



return (SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
children: [
Padding(padding: EdgeInsets.symmetric(horizontal: 0, vertical: 15)),
createDropdownButton(Theme.of(context).accentColor),
Padding(padding: EdgeInsets.symmetric(horizontal: 0, vertical: 15)),
Text(establishment,
style: TextStyle(fontWeight: FontWeight.w400,fontSize: 30),),
Padding(padding: EdgeInsets.symmetric(horizontal: 0, vertical: 15)),
Text(mealType,style: TextStyle(fontWeight: FontWeight.w500,fontSize: 30,
color:Theme.of(context).accentColor ),),
Padding(padding: EdgeInsets.symmetric(horizontal: 0, vertical: 3)),
Row( children: [
Text("Stars go here"),
Text("(" + mealRatingQuant + ")",style: TextStyle(fontWeight: FontWeight.w600,fontSize: 14,
color:Theme.of(context).accentColor ))
],
mainAxisAlignment: MainAxisAlignment.center,
),
Padding(padding: EdgeInsets.symmetric(horizontal: 0, vertical: 15)),
Divider(thickness: 3,indent: 20,endIndent: 20,color: Theme.of(context).accentColor),
Padding(padding: EdgeInsets.symmetric(horizontal: 0, vertical: 15)),
Text(mealName,style: TextStyle(fontWeight: FontWeight.w500,fontSize: 18,
color:Colors.black , ), textAlign: TextAlign.center,overflow: TextOverflow.fade),
Padding(padding: EdgeInsets.symmetric(horizontal: 0, vertical: 40)),
createReviewButton(Theme.of(context).accentColor)]
,)
));
}

Widget createDropdownButton(Color color){
return DropdownButton<String>(
value: dropdownValue,
icon: const Icon(Icons.arrow_downward),
style: const TextStyle(color: Colors.black),
borderRadius: BorderRadius.circular(1),
underline: Container(
height: 2,
color: color,
),
onChanged: (String newValue){//TODO:Make this update the page content
dropdownValue = newValue;
},
items: options.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
);
}

Widget createReviewButton(Color color){
return Padding(
padding: EdgeInsets.symmetric(horizontal: 0, vertical: 0),
child: SizedBox(
height: 55,
width: 55,
child: ElevatedButton(
child: Center(
child: Icon(Icons.star,color: Colors.white,size: 35,),
),
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(55),
),
primary: color,
),
onPressed: decoy,//TODO change to real function

)
),
);
}

bool decoy(){
return false;
}

}
11 changes: 10 additions & 1 deletion src/lib/view/Widgets/foodfeup_main_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:uni/view/Widgets/page_transition.dart';

import '../../main.dart';
import '../../model/entities/restaurant.dart';
import '../../model/foodfeup_suggestion_model.dart';

class FoodFeupMainMenu extends StatefulWidget{
@override
Expand Down Expand Up @@ -118,6 +119,14 @@ bool transitionToEstablishment(BuildContext context, String buttonName) {
return true;
}

bool transitionToSuggestion(BuildContext context, String buttonName) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const FoodFeupSuggestionPage()));

return true;
}

Future<List<Widget>> getWidgets(BuildContext context) async {
final List<Widget> widgets = [];
await RestaurantFetcherHtml().getRestaurants(state).then((restaurants) {
Expand All @@ -138,7 +147,7 @@ Future<List<Widget>> getWidgets(BuildContext context) async {
});

widgets.add(Padding(padding: EdgeInsets.symmetric(horizontal: 8, vertical: 0)));
widgets.add(createButton(context, 'Recomendação', 'Hoje', Colors.grey , transitionToEstablishment));
widgets.add(createButton(context, 'Recomendação', 'Hoje', Colors.grey , transitionToSuggestion));

return widgets;
}
Expand Down