159 lines
5.8 KiB
Dart
159 lines
5.8 KiB
Dart
import 'package:aitrainer_app/localization/app_localization.dart';
|
|
import 'package:aitrainer_app/viewmodel/customer_changing_view_model.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
// ignore: must_be_immutable
|
|
class CustomerGoalPage extends StatefulWidget{
|
|
_CustomerGoalPageState _state;
|
|
|
|
_CustomerGoalPageState createState() {
|
|
_state = _CustomerGoalPageState();
|
|
return _state;
|
|
}
|
|
}
|
|
|
|
class GoalsItem{
|
|
static String muscle = "gain_muscle";
|
|
static String weight = "weight_loss";
|
|
}
|
|
|
|
class _CustomerGoalPageState extends State<CustomerGoalPage> {
|
|
String selected;
|
|
|
|
initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final double cWidth = MediaQuery.of(context).size.width*0.75;
|
|
final CustomerChangingViewModel changingViewModel = ModalRoute.of(context).settings.arguments;
|
|
selected = changingViewModel.customer.goal;
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: <Widget>[
|
|
|
|
Image.asset(
|
|
'asset/image/WT_long_logo.png',
|
|
fit: BoxFit.cover,
|
|
height: 65.0,
|
|
),
|
|
],
|
|
),
|
|
backgroundColor: Colors.transparent,
|
|
),
|
|
body: Container(
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage('asset/image/WT_light_background.png'),
|
|
fit: BoxFit.cover,
|
|
|
|
alignment: Alignment.center,
|
|
),
|
|
),
|
|
height: double.infinity,
|
|
width: double.infinity,
|
|
child: SingleChildScrollView(
|
|
child: Center(
|
|
child: Column(
|
|
children: [
|
|
Divider(),
|
|
InkWell(
|
|
child: Text(AppLocalizations.of(context).translate("Set Your Goals"),
|
|
style: TextStyle(color: Colors.orange,
|
|
fontSize: 50, fontFamily: 'Arial',
|
|
fontWeight: FontWeight.w900 ),),
|
|
highlightColor: Colors.white,
|
|
),
|
|
|
|
Stack(
|
|
alignment: Alignment.bottomLeft,
|
|
overflow: Overflow.visible,
|
|
children: [
|
|
FlatButton(
|
|
child: Image.asset("asset/image/WT_gain_muscle.png", height: 180,),
|
|
padding: EdgeInsets.all(0.0),
|
|
shape: getShape(changingViewModel, GoalsItem.muscle ),
|
|
onPressed:() =>
|
|
{
|
|
print("gain muscle"),
|
|
setState((){
|
|
selected = GoalsItem.muscle;
|
|
changingViewModel.customer.setGoal(GoalsItem.muscle);
|
|
}),
|
|
|
|
}
|
|
),
|
|
InkWell(
|
|
child: Text(AppLocalizations.of(context).translate("Gain Muscle"),
|
|
style: TextStyle(color: Colors.white,
|
|
fontSize: 32, fontFamily: 'Arial',
|
|
fontWeight: FontWeight.w900 ),),
|
|
highlightColor: Colors.white,
|
|
)
|
|
]
|
|
),
|
|
Divider(),
|
|
Stack(
|
|
alignment: Alignment.bottomLeft,
|
|
overflow: Overflow.visible,
|
|
children: [
|
|
FlatButton(
|
|
child: Image.asset("asset/image/WT_weight_loss.png", height: 180,),
|
|
padding: EdgeInsets.all(0.0),
|
|
shape: getShape(changingViewModel, GoalsItem.weight ),
|
|
onPressed:() =>
|
|
{
|
|
print("weight_loss"),
|
|
setState((){
|
|
selected = GoalsItem.weight;
|
|
changingViewModel.customer.setGoal(GoalsItem.weight);
|
|
}),
|
|
|
|
}
|
|
),
|
|
InkWell(
|
|
child: Text(AppLocalizations.of(context).translate("Loose Weight"),
|
|
style: TextStyle(color: Colors.white,
|
|
fontSize: 32, fontFamily: 'Arial',
|
|
fontWeight: FontWeight.w900 ),),
|
|
highlightColor: Colors.white,
|
|
)
|
|
]
|
|
),
|
|
Divider(),
|
|
RaisedButton(
|
|
|
|
color: Colors.orange,
|
|
textColor: Colors.white,
|
|
child: InkWell(
|
|
child: Text(AppLocalizations.of(context).translate("Next"))),
|
|
onPressed: () => {
|
|
changingViewModel.saveCustomer(),
|
|
Navigator.of(context).pop(),
|
|
Navigator.of(context).pushNamed("customerFitnessPage", arguments: changingViewModel)
|
|
},
|
|
)
|
|
],
|
|
),
|
|
)
|
|
)
|
|
),
|
|
);
|
|
}
|
|
|
|
dynamic getShape( CustomerChangingViewModel changingViewModel, String goal ) {
|
|
String selectedGoal = changingViewModel.customer.goal;
|
|
dynamic returnCode = ( selectedGoal == goal ) ?
|
|
RoundedRectangleBorder(
|
|
side: BorderSide(width: 4, color: Colors.red),
|
|
)
|
|
: null;
|
|
//return
|
|
return returnCode;
|
|
}
|
|
|
|
} |