WT1.1.2f Purchase, Product, Property, BMR, BMI, Sizes
This commit is contained in:
+92
-129
@@ -2,6 +2,7 @@ import 'package:aitrainer_app/bloc/account/account_bloc.dart';
|
||||
import 'package:aitrainer_app/localization/app_language.dart';
|
||||
import 'package:aitrainer_app/model/customer.dart';
|
||||
import 'package:aitrainer_app/util/trans.dart';
|
||||
import 'package:aitrainer_app/widgets/app_bar_min.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:aitrainer_app/widgets/bottom_nav.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -17,17 +18,8 @@ class AccountPage extends StatelessWidget with Trans {
|
||||
setContext(context);
|
||||
accountBloc = BlocProvider.of<AccountBloc>(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(t('Account')),
|
||||
backgroundColor: Colors.transparent,
|
||||
),
|
||||
appBar: AppBarMin(),
|
||||
body: Container(
|
||||
foregroundDecoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('asset/image/WT_long_logo.png'),
|
||||
alignment: Alignment.topRight,
|
||||
),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('asset/image/WT_light_background.png'),
|
||||
@@ -35,79 +27,64 @@ class AccountPage extends StatelessWidget with Trans {
|
||||
alignment: Alignment.center,
|
||||
),
|
||||
),
|
||||
child: BlocConsumer<AccountBloc, AccountState>(
|
||||
listener: (context, state) {
|
||||
if (state is AccountError) {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
backgroundColor: Colors.orange,
|
||||
content:
|
||||
Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
} else if (state is AccountLoading) {
|
||||
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
if ( state is AccountInitial ) {
|
||||
String customerName = accountBloc.customerRepository.firstName +
|
||||
" " + accountBloc.customerRepository.name;
|
||||
return accountWidget(context, customerName, accountBloc);
|
||||
} else if ( state is AccountLoggedIn ) {
|
||||
String customerName = accountBloc.customerRepository.firstName +
|
||||
" " + accountBloc.customerRepository.name;
|
||||
return accountWidget(context, customerName, accountBloc);
|
||||
} else if ( state is AccountLoggedOut ) {
|
||||
String customerName = "";
|
||||
return accountWidget(context, customerName, accountBloc);
|
||||
} else if ( state is AccountReady ) {
|
||||
String customerName = accountBloc.customerRepository.firstName +
|
||||
" " + accountBloc.customerRepository.name;
|
||||
return accountWidget(context, customerName, accountBloc);
|
||||
} else {
|
||||
return accountWidget(context, "", accountBloc);
|
||||
}
|
||||
|
||||
child: BlocConsumer<AccountBloc, AccountState>(listener: (context, state) {
|
||||
if (state is AccountError) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
} else if (state is AccountLoading) {}
|
||||
}, builder: (context, state) {
|
||||
if (state is AccountInitial) {
|
||||
String customerName = accountBloc.customerRepository.firstName + " " + accountBloc.customerRepository.name;
|
||||
return accountWidget(context, customerName, accountBloc);
|
||||
} else if (state is AccountLoggedIn) {
|
||||
String customerName = accountBloc.customerRepository.firstName + " " + accountBloc.customerRepository.name;
|
||||
return accountWidget(context, customerName, accountBloc);
|
||||
} else if (state is AccountLoggedOut) {
|
||||
String customerName = "";
|
||||
return accountWidget(context, customerName, accountBloc);
|
||||
} else if (state is AccountReady) {
|
||||
String customerName = accountBloc.customerRepository.firstName + " " + accountBloc.customerRepository.name;
|
||||
return accountWidget(context, customerName, accountBloc);
|
||||
} else {
|
||||
return accountWidget(context, "", accountBloc);
|
||||
}
|
||||
),
|
||||
}),
|
||||
),
|
||||
bottomNavigationBar: BottomNavigator(bottomNavIndex: 3));
|
||||
}
|
||||
|
||||
ListView accountWidget(BuildContext context, String customerName, AccountBloc accountBloc) {
|
||||
return ListView(padding: EdgeInsets.only(top: 135), children: <Widget>[
|
||||
return ListView(padding: EdgeInsets.only(top: 35), children: <Widget>[
|
||||
ListTile(
|
||||
leading: Icon(Icons.perm_identity),
|
||||
subtitle:
|
||||
Text(t("Profile")),
|
||||
subtitle: Text(t("Profile")),
|
||||
title: FlatButton(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(customerName,
|
||||
style: TextStyle(color: Colors.blue)),
|
||||
Icon(Icons.arrow_forward_ios),
|
||||
]),
|
||||
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
Text(customerName, style: TextStyle(color: Colors.blue)),
|
||||
Icon(Icons.arrow_forward_ios),
|
||||
]),
|
||||
textColor: Colors.grey,
|
||||
color: Colors.white,
|
||||
onPressed: () => {
|
||||
if (accountBloc.customerRepository.customer != null) {
|
||||
Navigator.of(context).pushNamed('customerModifyPage'),
|
||||
print("Profile"),
|
||||
}
|
||||
if (accountBloc.customerRepository.customer != null)
|
||||
{
|
||||
Navigator.of(context).pushNamed('customerModifyPage'),
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
loginOut( context, accountBloc ),
|
||||
loginOut(context, accountBloc),
|
||||
getMyTrainees(context, accountBloc),
|
||||
]);
|
||||
}
|
||||
|
||||
ListTile loginOut( BuildContext context, AccountBloc accountBloc ) {
|
||||
ListTile loginOut(BuildContext context, AccountBloc accountBloc) {
|
||||
ListTile element = ListTile();
|
||||
|
||||
String text = "Logout";
|
||||
Color buttonColor = Colors.orange;
|
||||
|
||||
if ( accountBloc.customerRepository.customer == null || accountBloc.customerRepository.customer.email == null) {
|
||||
if (accountBloc.customerRepository.customer == null || accountBloc.customerRepository.customer.email == null) {
|
||||
text = "Login";
|
||||
buttonColor = Colors.blue;
|
||||
}
|
||||
@@ -116,25 +93,22 @@ class AccountPage extends StatelessWidget with Trans {
|
||||
enabled: true,
|
||||
leading: Icon(Icons.input),
|
||||
title: FlatButton(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(t(text),
|
||||
style: TextStyle(
|
||||
color: buttonColor
|
||||
)),
|
||||
Icon(Icons.arrow_forward_ios),
|
||||
]),
|
||||
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
Text(t(text), style: TextStyle(color: buttonColor)),
|
||||
Icon(Icons.arrow_forward_ios),
|
||||
]),
|
||||
textColor: buttonColor,
|
||||
color: Colors.white,
|
||||
onPressed: () => {
|
||||
if ( accountBloc.loggedIn ) {
|
||||
confirmationDialog( accountBloc ),
|
||||
} else {
|
||||
accountBloc.add(AccountLogin()),
|
||||
Navigator.of(context).pushNamed('login'),
|
||||
}
|
||||
|
||||
if (accountBloc.loggedIn)
|
||||
{
|
||||
confirmationDialog(accountBloc),
|
||||
}
|
||||
else
|
||||
{
|
||||
accountBloc.add(AccountLogin()),
|
||||
Navigator.of(context).pushNamed('login'),
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -142,17 +116,17 @@ class AccountPage extends StatelessWidget with Trans {
|
||||
return element;
|
||||
}
|
||||
|
||||
Widget getMyTrainees( BuildContext context, AccountBloc accountBloc ) {
|
||||
if ( accountBloc.customerRepository.customer == null ) {
|
||||
Widget getMyTrainees(BuildContext context, AccountBloc accountBloc) {
|
||||
if (accountBloc.customerRepository.customer == null) {
|
||||
return Container();
|
||||
}
|
||||
if ( accountBloc.customerRepository.customer.trainer == 0 ) {
|
||||
if (accountBloc.customerRepository.customer.trainer == 0) {
|
||||
return ListTile(
|
||||
title: Container(),
|
||||
);
|
||||
}
|
||||
|
||||
if (accountBloc.customerRepository.getTraineesList() == null ) {
|
||||
if (accountBloc.customerRepository.getTraineesList() == null) {
|
||||
return ListTile(
|
||||
leading: Icon(Icons.people),
|
||||
title: RaisedButton(
|
||||
@@ -161,7 +135,6 @@ class AccountPage extends StatelessWidget with Trans {
|
||||
child: Text("See my trainees"),
|
||||
),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
List<Widget> elements = List<Widget>();
|
||||
@@ -169,74 +142,64 @@ class AccountPage extends StatelessWidget with Trans {
|
||||
Customer trainee = element;
|
||||
String name = trainee.name;
|
||||
String firstName = trainee.firstname;
|
||||
String nodeName = AppLanguage().appLocal == Locale("en") ?
|
||||
firstName + " " + name : name + " " + firstName;
|
||||
String nodeName = AppLanguage().appLocal == Locale("en") ? firstName + " " + name : name + " " + firstName;
|
||||
|
||||
bool selected = accountBloc.traineeId == trainee.customerId;
|
||||
|
||||
Widget widget = FlatButton(
|
||||
padding: EdgeInsets.all(10),
|
||||
shape:RoundedRectangleBorder(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
side: BorderSide(width: 2, color: selected ? Colors.blue : Colors.black26 ),
|
||||
side: BorderSide(width: 2, color: selected ? Colors.blue : Colors.black26),
|
||||
),
|
||||
onPressed: () {
|
||||
accountBloc.add(AccountSelectTrainee(traineeId: trainee.customerId));
|
||||
//Navigator.of(context).pushNamed('login');
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(nodeName, style:
|
||||
TextStyle(
|
||||
color: selected ? Colors.blue : Colors.black54,
|
||||
fontWeight: selected ? FontWeight.bold : FontWeight.normal
|
||||
),
|
||||
),
|
||||
Icon(Icons.arrow_forward_ios),
|
||||
]),
|
||||
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
Text(
|
||||
nodeName,
|
||||
style: TextStyle(color: selected ? Colors.blue : Colors.black54, fontWeight: selected ? FontWeight.bold : FontWeight.normal),
|
||||
),
|
||||
Icon(Icons.arrow_forward_ios),
|
||||
]),
|
||||
);
|
||||
elements.add(widget);
|
||||
});
|
||||
|
||||
return ListTile(
|
||||
leading: Icon(Icons.people),
|
||||
subtitle: Text("My Trainees"),
|
||||
title: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: elements,
|
||||
)
|
||||
);
|
||||
leading: Icon(Icons.people),
|
||||
subtitle: Text("My Trainees"),
|
||||
title: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: elements,
|
||||
));
|
||||
}
|
||||
|
||||
void confirmationDialog(AccountBloc accountBloc) {
|
||||
showCupertinoDialog(
|
||||
useRootNavigator: true,
|
||||
context: context,
|
||||
//barrierDismissible: false,
|
||||
builder:(_) => CupertinoAlertDialog(
|
||||
title: Text(t("Are you sure to logout?")),
|
||||
content: Column(
|
||||
|
||||
children: [
|
||||
Divider(),
|
||||
]),
|
||||
actions: [
|
||||
FlatButton(
|
||||
child: Text(t("No")),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
FlatButton(
|
||||
child: Text(t("Yes")),
|
||||
onPressed: () => {
|
||||
accountBloc.add(AccountLogout()),
|
||||
Navigator.pop(context),
|
||||
},
|
||||
)
|
||||
],
|
||||
)
|
||||
);
|
||||
useRootNavigator: true,
|
||||
context: context,
|
||||
//barrierDismissible: false,
|
||||
builder: (_) => CupertinoAlertDialog(
|
||||
title: Text(t("Are you sure to logout?")),
|
||||
content: Column(children: [
|
||||
Divider(),
|
||||
]),
|
||||
actions: [
|
||||
FlatButton(
|
||||
child: Text(t("No")),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
FlatButton(
|
||||
child: Text(t("Yes")),
|
||||
onPressed: () => {
|
||||
accountBloc.add(AccountLogout()),
|
||||
Navigator.pop(context),
|
||||
},
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:aitrainer_app/bloc/customer_change/customer_change_bloc.dart';
|
||||
import 'package:aitrainer_app/localization/app_localization.dart';
|
||||
import 'package:aitrainer_app/repository/customer_repository.dart';
|
||||
import 'package:aitrainer_app/model/fitness_state.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
@@ -16,13 +17,13 @@ class CustomerFitnessPage extends StatefulWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class FitnessItem {
|
||||
/* class FitnessItem {
|
||||
static String beginner = "beginner";
|
||||
static String intermediate = "intermediate";
|
||||
static String advanced = "advanced";
|
||||
static String professional = "professional";
|
||||
}
|
||||
|
||||
*/
|
||||
//TODO
|
||||
// dropbox for professional sport
|
||||
|
||||
@@ -32,8 +33,7 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double cWidth = MediaQuery.of(context).size.width * 0.75;
|
||||
final CustomerRepository customerRepository =
|
||||
ModalRoute.of(context).settings.arguments;
|
||||
final CustomerRepository customerRepository = ModalRoute.of(context).settings.arguments;
|
||||
selected = customerRepository.customer.fitnessLevel;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
@@ -50,12 +50,10 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> {
|
||||
backgroundColor: Colors.transparent,
|
||||
),
|
||||
body: BlocProvider(
|
||||
create: (context) =>
|
||||
CustomerChangeBloc(customerRepository: customerRepository),
|
||||
create: (context) => CustomerChangeBloc(customerRepository: customerRepository),
|
||||
child: Builder(builder: (context) {
|
||||
// ignore: close_sinks
|
||||
CustomerChangeBloc changeBloc =
|
||||
BlocProvider.of<CustomerChangeBloc>(context);
|
||||
CustomerChangeBloc changeBloc = BlocProvider.of<CustomerChangeBloc>(context);
|
||||
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
@@ -77,14 +75,9 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> {
|
||||
alignment: WrapAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)
|
||||
.translate("Your Fitness State"),
|
||||
AppLocalizations.of(context).translate("Your Fitness State"),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.orange,
|
||||
fontSize: 42,
|
||||
fontFamily: 'Arial',
|
||||
fontWeight: FontWeight.w900),
|
||||
style: TextStyle(color: Colors.orange, fontSize: 42, fontFamily: 'Arial', fontWeight: FontWeight.w900),
|
||||
)
|
||||
]),
|
||||
Divider(),
|
||||
@@ -93,33 +86,20 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> {
|
||||
width: cWidth,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(AppLocalizations.of(context).translate("Beginner"),
|
||||
textWidthBasis: TextWidthBasis.longestLine,
|
||||
style: TextStyle(color: Colors.blue, fontSize: 32, fontFamily: 'Arial', fontWeight: FontWeight.w900)),
|
||||
Text(
|
||||
AppLocalizations.of(context)
|
||||
.translate("Beginner"),
|
||||
textWidthBasis:
|
||||
TextWidthBasis.longestLine,
|
||||
style: TextStyle(
|
||||
color: Colors.blue,
|
||||
fontSize: 32,
|
||||
fontFamily: 'Arial',
|
||||
fontWeight: FontWeight.w900)),
|
||||
Text(
|
||||
AppLocalizations.of(context)
|
||||
.translate("I am beginner"),
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 20,
|
||||
fontFamily: 'Arial',
|
||||
fontWeight: FontWeight.w100),
|
||||
AppLocalizations.of(context).translate("I am beginner"),
|
||||
style: TextStyle(color: Colors.black, fontSize: 20, fontFamily: 'Arial', fontWeight: FontWeight.w100),
|
||||
),
|
||||
],
|
||||
)),
|
||||
padding: EdgeInsets.all(10.0),
|
||||
shape: getShape(
|
||||
customerRepository, FitnessItem.beginner),
|
||||
shape: getShape(customerRepository, FitnessState.beginner),
|
||||
onPressed: () => {
|
||||
setState(() {
|
||||
selected = FitnessItem.beginner;
|
||||
selected = FitnessState.beginner;
|
||||
changeBloc.add(CustomerFitnessChange(fitness: selected));
|
||||
print(selected);
|
||||
}),
|
||||
@@ -132,25 +112,15 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> {
|
||||
children: [
|
||||
InkWell(
|
||||
child: Text(
|
||||
AppLocalizations.of(context)
|
||||
.translate("Intermediate"),
|
||||
style: TextStyle(
|
||||
color: Colors.blue,
|
||||
fontSize: 32,
|
||||
fontFamily: 'Arial',
|
||||
fontWeight: FontWeight.w900),
|
||||
AppLocalizations.of(context).translate("Intermediate"),
|
||||
style: TextStyle(color: Colors.blue, fontSize: 32, fontFamily: 'Arial', fontWeight: FontWeight.w900),
|
||||
),
|
||||
highlightColor: Colors.white,
|
||||
),
|
||||
InkWell(
|
||||
child: Text(
|
||||
AppLocalizations.of(context)
|
||||
.translate("I am intermediate"),
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 20,
|
||||
fontFamily: 'Arial',
|
||||
fontWeight: FontWeight.w100),
|
||||
AppLocalizations.of(context).translate("I am intermediate"),
|
||||
style: TextStyle(color: Colors.black, fontSize: 20, fontFamily: 'Arial', fontWeight: FontWeight.w100),
|
||||
),
|
||||
highlightColor: Colors.white,
|
||||
),
|
||||
@@ -158,11 +128,10 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> {
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.all(10.0),
|
||||
shape: getShape(
|
||||
customerRepository, FitnessItem.intermediate),
|
||||
shape: getShape(customerRepository, FitnessState.intermediate),
|
||||
onPressed: () => {
|
||||
setState(() {
|
||||
selected = FitnessItem.intermediate;
|
||||
selected = FitnessState.intermediate;
|
||||
changeBloc.add(CustomerFitnessChange(fitness: selected));
|
||||
print(selected);
|
||||
}),
|
||||
@@ -175,25 +144,15 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> {
|
||||
children: [
|
||||
InkWell(
|
||||
child: Text(
|
||||
AppLocalizations.of(context)
|
||||
.translate("Advanced"),
|
||||
style: TextStyle(
|
||||
color: Colors.blue,
|
||||
fontSize: 32,
|
||||
fontFamily: 'Arial',
|
||||
fontWeight: FontWeight.w900),
|
||||
AppLocalizations.of(context).translate("Advanced"),
|
||||
style: TextStyle(color: Colors.blue, fontSize: 32, fontFamily: 'Arial', fontWeight: FontWeight.w900),
|
||||
),
|
||||
highlightColor: Colors.white,
|
||||
),
|
||||
InkWell(
|
||||
child: Text(
|
||||
AppLocalizations.of(context)
|
||||
.translate("I am advanced"),
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 20,
|
||||
fontFamily: 'Arial',
|
||||
fontWeight: FontWeight.w100),
|
||||
AppLocalizations.of(context).translate("I am advanced"),
|
||||
style: TextStyle(color: Colors.black, fontSize: 20, fontFamily: 'Arial', fontWeight: FontWeight.w100),
|
||||
),
|
||||
highlightColor: Colors.white,
|
||||
),
|
||||
@@ -201,11 +160,10 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> {
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.all(10.0),
|
||||
shape: getShape(
|
||||
customerRepository, FitnessItem.advanced),
|
||||
shape: getShape(customerRepository, FitnessState.advanced),
|
||||
onPressed: () => {
|
||||
setState(() {
|
||||
selected = FitnessItem.advanced;
|
||||
selected = FitnessState.advanced;
|
||||
changeBloc.add(CustomerFitnessChange(fitness: selected));
|
||||
print(selected);
|
||||
}),
|
||||
@@ -218,25 +176,15 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> {
|
||||
children: [
|
||||
InkWell(
|
||||
child: Text(
|
||||
AppLocalizations.of(context)
|
||||
.translate("Professional"),
|
||||
style: TextStyle(
|
||||
color: Colors.blue,
|
||||
fontSize: 32,
|
||||
fontFamily: 'Arial',
|
||||
fontWeight: FontWeight.w900),
|
||||
AppLocalizations.of(context).translate("Professional"),
|
||||
style: TextStyle(color: Colors.blue, fontSize: 32, fontFamily: 'Arial', fontWeight: FontWeight.w900),
|
||||
),
|
||||
highlightColor: Colors.white,
|
||||
),
|
||||
InkWell(
|
||||
child: Text(
|
||||
AppLocalizations.of(context)
|
||||
.translate("I am professional"),
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 20,
|
||||
fontFamily: 'Arial',
|
||||
fontWeight: FontWeight.w100),
|
||||
AppLocalizations.of(context).translate("I am professional"),
|
||||
style: TextStyle(color: Colors.black, fontSize: 20, fontFamily: 'Arial', fontWeight: FontWeight.w100),
|
||||
),
|
||||
highlightColor: Colors.white,
|
||||
),
|
||||
@@ -244,11 +192,10 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> {
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.all(10.0),
|
||||
shape: getShape(
|
||||
customerRepository, FitnessItem.professional),
|
||||
shape: getShape(customerRepository, FitnessState.professional),
|
||||
onPressed: () => {
|
||||
setState(() {
|
||||
selected = FitnessItem.professional;
|
||||
selected = FitnessState.professional;
|
||||
changeBloc.add(CustomerFitnessChange(fitness: selected));
|
||||
print(selected);
|
||||
}),
|
||||
@@ -257,15 +204,11 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> {
|
||||
RaisedButton(
|
||||
color: Colors.orange,
|
||||
textColor: Colors.white,
|
||||
child: InkWell(
|
||||
child: Text(AppLocalizations.of(context)
|
||||
.translate("Next"))),
|
||||
child: InkWell(child: Text(AppLocalizations.of(context).translate("Next"))),
|
||||
onPressed: () => {
|
||||
changeBloc.add(CustomerSave()),
|
||||
Navigator.of(context).pop(),
|
||||
Navigator.of(context).pushNamed(
|
||||
"customerBodyTypePage",
|
||||
arguments: customerRepository)
|
||||
Navigator.of(context).pushNamed("customerBodyTypePage", arguments: customerRepository)
|
||||
},
|
||||
)
|
||||
],
|
||||
|
||||
+256
-164
@@ -1,17 +1,21 @@
|
||||
import 'package:aitrainer_app/bloc/account/account_bloc.dart';
|
||||
import 'package:aitrainer_app/bloc/customer_change_form_bloc.dart';
|
||||
import 'package:aitrainer_app/bloc/customer_change/customer_change_bloc.dart';
|
||||
import 'package:aitrainer_app/library/numberpicker.dart';
|
||||
import 'package:aitrainer_app/util/trans.dart';
|
||||
import 'package:aitrainer_app/widgets/app_bar_min.dart';
|
||||
import 'package:aitrainer_app/widgets/splash.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
|
||||
import 'package:toggle_switch/toggle_switch.dart';
|
||||
|
||||
import '../library_keys.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class CustomerModifyPage extends StatelessWidget with Trans {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -20,180 +24,268 @@ class CustomerModifyPage extends StatelessWidget with Trans {
|
||||
final accountBloc = BlocProvider.of<AccountBloc>(context);
|
||||
|
||||
return BlocProvider(
|
||||
create: (context) => CustomerChangeFormBloc(customerRepository: accountBloc.customerRepository),
|
||||
create: (context) => CustomerChangeBloc(customerRepository: accountBloc.customerRepository)..add(CustomerLoad()),
|
||||
child: Builder(builder: (context) {
|
||||
// ignore: close_sinks
|
||||
final customerBloc = BlocProvider.of<CustomerChangeFormBloc>(context);
|
||||
final customerBloc = BlocProvider.of<CustomerChangeBloc>(context);
|
||||
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: true,
|
||||
appBar: AppBar(
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Text("Profil"),
|
||||
Image.asset(
|
||||
'asset/image/WT_long_logo.png',
|
||||
fit: BoxFit.cover,
|
||||
height: 65.0,
|
||||
),
|
||||
],
|
||||
),
|
||||
//title: Text(AppLocalizations.of(context).translate('Settings')),
|
||||
backgroundColor: Colors.transparent,
|
||||
appBar: AppBarMin(
|
||||
back: true,
|
||||
),
|
||||
body: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('asset/image/WT_light_background.png'),
|
||||
fit: BoxFit.cover,
|
||||
fit: BoxFit.fill,
|
||||
alignment: Alignment.center,
|
||||
),
|
||||
),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
padding: EdgeInsets.only(top: 40, left: 25, right: 45, bottom: 100),
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFieldBlocBuilder(
|
||||
key: LibraryKeys.loginEmailField,
|
||||
style: TextStyle(fontSize: 12),
|
||||
textFieldBloc: customerBloc.emailField,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white24,
|
||||
filled: true,
|
||||
labelText: t('Email'),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFieldBlocBuilder(
|
||||
style: TextStyle(fontSize: 12),
|
||||
textFieldBloc: customerBloc.passwordField,
|
||||
suffixButton: SuffixButton.obscureText,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white24,
|
||||
filled: true,
|
||||
labelText: t('Password (Leave empty if no change)'),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFieldBlocBuilder(
|
||||
style: TextStyle(fontSize: 12),
|
||||
textFieldBloc: customerBloc.nameField,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white24,
|
||||
filled: true,
|
||||
labelText: t('Name'),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFieldBlocBuilder(
|
||||
style: TextStyle(fontSize: 12),
|
||||
textFieldBloc: customerBloc.firstNameField,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white24,
|
||||
filled: true,
|
||||
labelText: t('First Name'),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFieldBlocBuilder(
|
||||
style: TextStyle(fontSize: 12),
|
||||
textFieldBloc: customerBloc.birthYearField,
|
||||
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r"[\d]"))],
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white24,
|
||||
filled: true,
|
||||
labelText: t('Birth Year'),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFieldBlocBuilder(
|
||||
style: TextStyle(fontSize: 12),
|
||||
textFieldBloc: customerBloc.weightField,
|
||||
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r"[\d]"))],
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white24,
|
||||
filled: true,
|
||||
labelText: t('Weight'),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
Divider(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: DropdownFieldBlocBuilder(
|
||||
selectFieldBloc: customerBloc.genderField,
|
||||
itemBuilder: (context, item) => item,
|
||||
decoration: InputDecoration(
|
||||
labelText: t('Select a gender'),
|
||||
)),
|
||||
)
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Expanded(
|
||||
child: RaisedButton(
|
||||
color: Colors.orange,
|
||||
textColor: Colors.white,
|
||||
child: InkWell(child: Text(t("Next"))),
|
||||
onPressed: () => {
|
||||
customerBloc.add(SubmitFormBloc()),
|
||||
Navigator.of(context)
|
||||
.pushNamed("customerGoalPage", arguments: customerBloc.customerRepository)
|
||||
},
|
||||
))
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
child: BlocConsumer<CustomerChangeBloc, CustomerChangeState>(
|
||||
listener: (context, state) {
|
||||
if (state is CustomerChangeLoading) {
|
||||
LoadingDialog();
|
||||
} else if (state is CustomerSaveError) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
} else if (state is CustomerSaveSuccess) {
|
||||
Navigator.of(context).pushNamed("customerGoalPage", arguments: customerBloc.customerRepository);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return loadForm(customerBloc);
|
||||
},
|
||||
)));
|
||||
}));
|
||||
}
|
||||
|
||||
Widget loadForm(CustomerChangeBloc customerBloc) {
|
||||
return Form(
|
||||
key: _scaffoldKey,
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
padding: EdgeInsets.only(top: 40, left: 25, right: 25, bottom: 250),
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
child: Column(
|
||||
children: [
|
||||
TextFormField(
|
||||
key: LibraryKeys.loginEmailField,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.only(left: 15, top: 15, bottom: 15),
|
||||
labelText: t('Email'),
|
||||
fillColor: Colors.white24,
|
||||
filled: true,
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 4.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.green[50], width: 0.4),
|
||||
),
|
||||
),
|
||||
initialValue: customerBloc.customerRepository.customer.email,
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
validator: (val) {
|
||||
return customerBloc.emailValidation(val);
|
||||
},
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
style: new TextStyle(fontSize: 16, color: Colors.indigo),
|
||||
),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
TextFormField(
|
||||
key: LibraryKeys.loginPasswordField,
|
||||
obscureText: true,
|
||||
decoration: InputDecoration(
|
||||
labelStyle: TextStyle(fontSize: 14),
|
||||
contentPadding: EdgeInsets.only(left: 15, top: 15, bottom: 15),
|
||||
suffixIcon: IconButton(
|
||||
onPressed: () => {customerBloc.add(CustomerChangePasswordObscure())},
|
||||
icon: Icon(Icons.remove_red_eye),
|
||||
),
|
||||
labelText: t('Password (Leave empty if no change)'),
|
||||
fillColor: Colors.white24,
|
||||
filled: true,
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 1.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.green[50], width: 0.4),
|
||||
),
|
||||
),
|
||||
initialValue: customerBloc.customerRepository.customer.password,
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
validator: (val) {
|
||||
return customerBloc.passwordValidation(val);
|
||||
},
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
style: new TextStyle(fontSize: 16, color: Colors.indigo),
|
||||
),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.only(left: 15, top: 15, bottom: 15),
|
||||
labelText: t('Name'),
|
||||
fillColor: Colors.white24,
|
||||
filled: true,
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 1.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.green[50], width: 0.4),
|
||||
),
|
||||
),
|
||||
initialValue: customerBloc.customerRepository.customer.name,
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
validator: (val) {
|
||||
return customerBloc.nameValidation(val);
|
||||
},
|
||||
keyboardType: TextInputType.name,
|
||||
style: new TextStyle(fontSize: 16, color: Colors.indigo),
|
||||
onChanged: (value) => {customerBloc.add(CustomerNameChange(name: value))}),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.only(left: 15, top: 15, bottom: 15),
|
||||
labelText: t('First Name'),
|
||||
fillColor: Colors.white24,
|
||||
filled: true,
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 2.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.green[50], width: 0.4),
|
||||
),
|
||||
),
|
||||
initialValue: customerBloc.customerRepository.customer.firstname,
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
validator: (val) {
|
||||
return customerBloc.nameValidation(val);
|
||||
},
|
||||
keyboardType: TextInputType.name,
|
||||
style: new TextStyle(fontSize: 16, color: Colors.indigo),
|
||||
onChanged: (value) => {customerBloc.add(CustomerFirstNameChange(firstName: value))}),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: Text(t("Birth Year"), style: TextStyle(fontWeight: FontWeight.normal, fontSize: 14)),
|
||||
),
|
||||
Flexible(
|
||||
fit: FlexFit.tight,
|
||||
flex: 8,
|
||||
child: NumberPicker.horizontal(
|
||||
highlightSelectedValue: true,
|
||||
initialValue: customerBloc.year,
|
||||
minValue: 1930,
|
||||
maxValue: 2100,
|
||||
|
||||
step: 1,
|
||||
textStyle: TextStyle(fontWeight: FontWeight.bold),
|
||||
textStyleHighlighted: TextStyle(fontSize: 16, color: Colors.indigo, fontWeight: FontWeight.bold),
|
||||
onChanged: (value) => {customerBloc.add(CustomerBirthYearChange(year: value))},
|
||||
listViewHeight: 60,
|
||||
//decoration: _decoration,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 80),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: Text(t("Weight"), style: TextStyle(fontWeight: FontWeight.normal, fontSize: 14)),
|
||||
),
|
||||
Flexible(
|
||||
fit: FlexFit.tight,
|
||||
flex: 8,
|
||||
child: NumberPicker.horizontal(
|
||||
highlightSelectedValue: true,
|
||||
initialValue: customerBloc.weight.toInt(),
|
||||
minValue: 0,
|
||||
maxValue: 200,
|
||||
step: 1,
|
||||
textStyle: TextStyle(fontWeight: FontWeight.bold),
|
||||
textStyleHighlighted: TextStyle(fontSize: 18, color: Colors.indigo, fontWeight: FontWeight.bold),
|
||||
onChanged: (value) => {customerBloc.add(CustomerWeightChange(weight: value))},
|
||||
listViewHeight: 60,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 80),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: Text(t("Height"), style: TextStyle(fontWeight: FontWeight.normal, fontSize: 14)),
|
||||
),
|
||||
Flexible(
|
||||
fit: FlexFit.tight,
|
||||
flex: 8,
|
||||
child: NumberPicker.horizontal(
|
||||
highlightSelectedValue: true,
|
||||
initialValue: customerBloc.height.toInt(),
|
||||
minValue: 0,
|
||||
maxValue: 230,
|
||||
step: 1,
|
||||
textStyle: TextStyle(fontWeight: FontWeight.bold),
|
||||
textStyleHighlighted: TextStyle(fontSize: 18, color: Colors.indigo, fontWeight: FontWeight.bold),
|
||||
onChanged: (value) => {customerBloc.add(CustomerHeightChange(height: value))},
|
||||
listViewHeight: 60,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 80),
|
||||
],
|
||||
),
|
||||
Divider(),
|
||||
ToggleSwitch(
|
||||
minWidth: 50.0,
|
||||
minHeight: 50.0,
|
||||
fontSize: 14.0,
|
||||
initialLabelIndex: customerBloc.customerRepository.customer.sex == "m" ? 0 : 1,
|
||||
activeBgColor: Colors.indigo,
|
||||
activeFgColor: Colors.white,
|
||||
inactiveBgColor: Colors.white30,
|
||||
inactiveFgColor: Colors.grey[900],
|
||||
labels: [t('Man'), t('Woman')],
|
||||
onToggle: (index) {
|
||||
customerBloc.add(CustomerGenderChange(gender: index));
|
||||
},
|
||||
),
|
||||
Divider(),
|
||||
FlatButton(
|
||||
onPressed: () => {customerBloc.add(CustomerSave())},
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Image.asset('asset/icon/gomb_orange_a.png', width: 140, height: 60),
|
||||
Text(
|
||||
t("Next"),
|
||||
style: TextStyle(fontSize: 16, color: Colors.white),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showInSnackBar(String error) {
|
||||
_scaffoldKey.currentState
|
||||
.showSnackBar(SnackBar(backgroundColor: Colors.orange, content: Text(error, style: TextStyle(color: Colors.white))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import 'package:aitrainer_app/localization/app_localization.dart';
|
||||
import 'package:aitrainer_app/widgets/app_bar_min.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class CustomerWelcomePage extends StatefulWidget{
|
||||
class CustomerWelcomePage extends StatefulWidget {
|
||||
_CustomerWelcomePageState _state;
|
||||
|
||||
_CustomerWelcomePageState createState() {
|
||||
@@ -14,9 +15,9 @@ class CustomerWelcomePage extends StatefulWidget{
|
||||
class _CustomerWelcomePageState extends State<CustomerWelcomePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
appBar: AppBarMin(),
|
||||
/*
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
@@ -28,40 +29,34 @@ class _CustomerWelcomePageState extends State<CustomerWelcomePage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
backgroundColor: Colors.transparent,
|
||||
),
|
||||
body: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('asset/image/WT_welcome.png'),
|
||||
fit: BoxFit.cover,
|
||||
alignment: Alignment.center,
|
||||
),
|
||||
*/
|
||||
//backgroundColor: Colors.transparent,
|
||||
//),
|
||||
body: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('asset/image/WT_welcome.png'),
|
||||
fit: BoxFit.fill,
|
||||
alignment: Alignment.center,
|
||||
),
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Divider(color: Colors.transparent,),
|
||||
Divider(color: Colors.transparent,),
|
||||
Divider(color: Colors.transparent,),
|
||||
Divider(color: Colors.transparent,),
|
||||
RaisedButton(
|
||||
|
||||
color: Colors.orange,
|
||||
textColor: Colors.white,
|
||||
child: InkWell(
|
||||
child: Text(AppLocalizations.of(context).translate("Next"))),
|
||||
onPressed: () => {
|
||||
|
||||
Navigator.of(context).pop(),
|
||||
Navigator.of(context).pushNamed("home")
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
child: SafeArea(
|
||||
bottom: false,
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
RaisedButton(
|
||||
color: Colors.orange,
|
||||
textColor: Colors.white,
|
||||
child: InkWell(child: Text(AppLocalizations.of(context).translate("Next"))),
|
||||
onPressed: () => {Navigator.of(context).pop(), Navigator.of(context).pushNamed("home")},
|
||||
)
|
||||
],
|
||||
),
|
||||
))),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
|
||||
class ExerciseExecutePage extends StatefulWidget {
|
||||
@override
|
||||
@@ -109,7 +110,8 @@ class _ExerciseExecutePage extends State<ExerciseExecutePage> with Trans {
|
||||
child:
|
||||
Text(
|
||||
t("Execute your active Exercise Plan!"),
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
style: GoogleFonts.archivoBlack(fontSize: 20,),
|
||||
maxLines: 2,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -167,13 +169,17 @@ class _ExerciseExecutePage extends State<ExerciseExecutePage> with Trans {
|
||||
),
|
||||
SizedBox(width: 20),
|
||||
Flexible(
|
||||
fit:FlexFit.tight,
|
||||
child:
|
||||
InkWell(
|
||||
child:
|
||||
Text(
|
||||
element.name,
|
||||
textAlign: TextAlign.start,
|
||||
style: TextStyle(fontSize: 12, color: Colors.black),
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 17,
|
||||
color: Colors.black),
|
||||
|
||||
),
|
||||
onTap: () => {
|
||||
addExerciseByPlanEvent(bloc, element)
|
||||
|
||||
@@ -135,8 +135,17 @@ class _ExerciseExecuteAddPage extends State<ExerciseExecutePlanAddPage> with Tra
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Divider(color: Colors.transparent,),
|
||||
Text(t("Execute the") + " " + (i+1).toString() + t(". set!"),
|
||||
style: TextStyle(),),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||
children: [
|
||||
Text(t("Execute the") + " ",style: TextStyle(fontWeight: FontWeight.bold),),
|
||||
Text((i+1).toString() + ". ",style: TextStyle(fontSize:24, fontWeight: FontWeight.bold),),
|
||||
Text(t("set!"),style: TextStyle(fontWeight: FontWeight.bold),),
|
||||
],
|
||||
),
|
||||
|
||||
|
||||
Divider(color: Colors.transparent,),
|
||||
Text(t("Please repeat with") + " "+ exerciseBloc.unitQuantity.toStringAsFixed(0) + " " +
|
||||
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit + " " +
|
||||
|
||||
+287
-219
@@ -5,21 +5,73 @@ import 'package:aitrainer_app/bloc/menu/menu_bloc.dart';
|
||||
import 'package:aitrainer_app/localization/app_language.dart';
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/model/exercise_type.dart';
|
||||
import 'package:aitrainer_app/repository/customer_repository.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:aitrainer_app/util/trans.dart';
|
||||
import 'package:aitrainer_app/widgets/app_bar.dart';
|
||||
import 'package:aitrainer_app/widgets/bmi_widget.dart';
|
||||
import 'package:aitrainer_app/widgets/bmr_widget.dart';
|
||||
import 'package:aitrainer_app/widgets/size_widget.dart';
|
||||
import 'package:aitrainer_app/widgets/splash.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
import 'package:aitrainer_app/library/numberpicker.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:keyboard_actions/keyboard_actions.dart';
|
||||
|
||||
class ExerciseNewPage extends StatefulWidget{
|
||||
class ExerciseNewPage extends StatefulWidget {
|
||||
_ExerciseNewPageState createState() => _ExerciseNewPageState();
|
||||
}
|
||||
|
||||
class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans{
|
||||
class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans {
|
||||
final FocusNode _nodeText1 = FocusNode();
|
||||
final FocusNode _nodeText2 = FocusNode();
|
||||
|
||||
KeyboardActionsConfig _buildConfig(BuildContext context) {
|
||||
return KeyboardActionsConfig(
|
||||
keyboardActionsPlatform: KeyboardActionsPlatform.ALL,
|
||||
keyboardBarColor: Colors.grey[200],
|
||||
keyboardSeparatorColor: Colors.black26,
|
||||
nextFocus: true,
|
||||
actions: [
|
||||
KeyboardActionsItem(focusNode: _nodeText2, toolbarButtons: [
|
||||
(node) {
|
||||
return GestureDetector(
|
||||
onTap: () => node.unfocus(),
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
color: Colors.orange[500],
|
||||
child: Text(
|
||||
t("Done"),
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
]),
|
||||
KeyboardActionsItem(
|
||||
focusNode: _nodeText1,
|
||||
toolbarButtons: [
|
||||
//button 2
|
||||
(node) {
|
||||
return GestureDetector(
|
||||
onTap: () => node.unfocus(),
|
||||
child: Container(
|
||||
color: Colors.orange,
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
t("Done"),
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -29,251 +81,267 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans{
|
||||
setContext(context);
|
||||
|
||||
return BlocProvider(
|
||||
create: (context) => ExerciseNewBloc(exerciseRepository: ExerciseRepository(), menuBloc: menuBloc, exerciseType: exerciseType)..
|
||||
add(ExerciseNewLoad()),
|
||||
child: BlocConsumer<ExerciseNewBloc, ExerciseNewState>(
|
||||
listener: (context, state) {
|
||||
if ( state is ExerciseNewLoading ) {
|
||||
return LoadingDialog();
|
||||
} else if ( state is ExerciseNewError ) {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
backgroundColor: Colors.orange,
|
||||
content:
|
||||
Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
final exerciseBloc = BlocProvider.of<ExerciseNewBloc>(context);
|
||||
if ( state is ExerciseNewReady ) {
|
||||
create: (context) => ExerciseNewBloc(
|
||||
exerciseRepository: ExerciseRepository(),
|
||||
menuBloc: menuBloc,
|
||||
customerRepository: CustomerRepository(),
|
||||
exerciseType: exerciseType)
|
||||
..add(ExerciseNewLoad()),
|
||||
child: BlocConsumer<ExerciseNewBloc, ExerciseNewState>(
|
||||
listener: (context, state) {
|
||||
if (state is ExerciseNewLoading) {
|
||||
return LoadingDialog();
|
||||
} else if (state is ExerciseNewError) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
final exerciseBloc = BlocProvider.of<ExerciseNewBloc>(context);
|
||||
double width = MediaQuery.of(context).size.width;
|
||||
double height = MediaQuery.of(context).size.height;
|
||||
exerciseBloc.setMediaDimensions(width, height);
|
||||
return getExerciseWidget(exerciseBloc, exerciseType);
|
||||
} else {
|
||||
return getExerciseWidget(exerciseBloc, exerciseType);
|
||||
}
|
||||
},
|
||||
)
|
||||
);
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
Widget getExerciseWidget(ExerciseNewBloc exerciseBloc, ExerciseType exerciseType) {
|
||||
|
||||
exerciseBloc.exerciseRepository.setExerciseType(exerciseType);
|
||||
String exerciseName = AppLanguage().appLocal == Locale("en") ?
|
||||
exerciseBloc.exerciseRepository.exerciseType.name :
|
||||
exerciseBloc.exerciseRepository.exerciseType.nameTranslation;
|
||||
final String exerciseName = AppLanguage().appLocal == Locale("en")
|
||||
? exerciseBloc.exerciseRepository.exerciseType.name
|
||||
: exerciseBloc.exerciseRepository.exerciseType.nameTranslation;
|
||||
|
||||
String exerciseDescription = AppLanguage().appLocal == Locale("en")
|
||||
? exerciseBloc.exerciseRepository.exerciseType.description
|
||||
: exerciseBloc.exerciseRepository.exerciseType.descriptionTranslation;
|
||||
if (exerciseDescription == null) {
|
||||
exerciseDescription = "";
|
||||
}
|
||||
|
||||
print(exerciseBloc.exerciseRepository.exerciseType.name);
|
||||
|
||||
if (exerciseBloc.exerciseRepository.exerciseType.name == "BMR") {
|
||||
return BMR(exerciseBloc: exerciseBloc);
|
||||
}
|
||||
if (exerciseBloc.exerciseRepository.exerciseType.name == "BMI") {
|
||||
return BMI(exerciseBloc: exerciseBloc);
|
||||
}
|
||||
if (exerciseBloc.exerciseRepository.exerciseType.name == "Sizes") {
|
||||
return SizeWidget(exerciseBloc: exerciseBloc);
|
||||
}
|
||||
|
||||
return Form(
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: true,
|
||||
appBar: AppBarNav(depth: 1),
|
||||
body: Container(
|
||||
width: MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.width,
|
||||
height: MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.height,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('asset/image/WT_light_background.png'),
|
||||
fit: BoxFit.fill,
|
||||
alignment: Alignment.center,
|
||||
),
|
||||
//autovalidateMode: AutovalidateMode.disabled,
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: true,
|
||||
appBar: AppBarNav(depth: 1),
|
||||
body: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('asset/image/WT_black_background.png'),
|
||||
fit: BoxFit.fill,
|
||||
alignment: Alignment.center,
|
||||
),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only (top: 25, left: 25, right: 25),
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
/*Divider(color: Colors.transparent,),
|
||||
Divider(color: Colors.transparent,),*/
|
||||
Text(t('Save Exercise'),
|
||||
style: TextStyle(fontSize: 14, color: Colors.blueAccent)),
|
||||
Text(exerciseName,
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: Colors.deepOrange),
|
||||
overflow: TextOverflow.fade,
|
||||
maxLines: 1,
|
||||
softWrap: true,
|
||||
),
|
||||
|
||||
|
||||
//Divider(color: Colors.transparent,),
|
||||
FlatButton(
|
||||
child: Row(
|
||||
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Icon(Icons.description),
|
||||
Text(t("Description"),
|
||||
style: TextStyle(
|
||||
color: Colors.blueAccent, fontWeight: FontWeight.normal, fontSize: 14)),
|
||||
Icon(Icons.arrow_forward_ios),
|
||||
]),
|
||||
textColor: Colors.blueAccent,
|
||||
color: Colors.transparent,
|
||||
onPressed: () =>
|
||||
{
|
||||
Navigator.of(context).pushNamed(
|
||||
'exerciseTypeDescription', arguments: exerciseBloc.exerciseRepository),
|
||||
},
|
||||
),
|
||||
//Divider(color: Colors.transparent,),
|
||||
columnQuantityUnit(exerciseBloc),
|
||||
Divider(color: Colors.transparent,),
|
||||
|
||||
|
||||
columnQuantity(exerciseBloc),
|
||||
Divider(),
|
||||
Divider(color: Colors.transparent,),
|
||||
Divider(color: Colors.transparent,),
|
||||
Divider(color: Colors.transparent,),
|
||||
RaisedButton(
|
||||
textColor: Colors.white,
|
||||
color: Colors.deepOrange,
|
||||
focusColor: Colors.white,
|
||||
onPressed: () =>
|
||||
{
|
||||
confirmationDialog(exerciseBloc),
|
||||
},
|
||||
child: Text(t("Save"), style: TextStyle(fontSize: 16),)
|
||||
),
|
||||
]),
|
||||
)
|
||||
)
|
||||
),
|
||||
child: KeyboardActions(
|
||||
config: _buildConfig(context),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(top: 5, left: 75, right: 75),
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(t('Save Exercise'), style: TextStyle(fontSize: 14, color: Colors.blue[200])),
|
||||
Divider(),
|
||||
Text(
|
||||
exerciseName,
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: Colors.orange),
|
||||
overflow: TextOverflow.fade,
|
||||
maxLines: 2,
|
||||
softWrap: true,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Text(
|
||||
exerciseDescription,
|
||||
style: GoogleFonts.inter(fontSize: 12, color: Colors.yellow[300]),
|
||||
maxLines: 8,
|
||||
overflow: TextOverflow.fade,
|
||||
softWrap: true,
|
||||
),
|
||||
InkWell(
|
||||
child: Text(
|
||||
t("More »"),
|
||||
style: GoogleFonts.inter(fontSize: 12, color: Colors.blue[200]),
|
||||
),
|
||||
onTap: () => {
|
||||
Navigator.of(context).pushNamed('exerciseTypeDescription', arguments: exerciseBloc.exerciseRepository),
|
||||
},
|
||||
),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
columnQuantityUnit(exerciseBloc),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
columnQuantity(exerciseBloc),
|
||||
Divider(),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
FlatButton(
|
||||
onPressed: () => {
|
||||
confirmationDialog(exerciseBloc),
|
||||
},
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Image.asset('asset/icon/gomb_orange_a.png', width: 140, height: 60),
|
||||
Text(
|
||||
t("Save"),
|
||||
style: TextStyle(fontSize: 16, color: Colors.white),
|
||||
),
|
||||
],
|
||||
)),
|
||||
]),
|
||||
))),
|
||||
),
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
Row columnQuantityUnit( ExerciseNewBloc bloc ) {
|
||||
Row row = Row();
|
||||
if ( bloc.exerciseRepository.exerciseType != null &&
|
||||
bloc.exerciseRepository.exerciseType.unitQuantity == "1") {
|
||||
row = Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
NumberPicker.horizontal(
|
||||
highlightSelectedValue: true,
|
||||
initialValue: bloc.unitQuantity.toInt(),
|
||||
minValue: 0,
|
||||
maxValue: 200,
|
||||
step: 1,
|
||||
onChanged: (value) => {
|
||||
bloc.add(ExerciseNewQuantityUnitChange(quantity: value.toDouble()))
|
||||
},
|
||||
listViewHeight: 80,
|
||||
textStyle: TextStyle(fontSize: 24),
|
||||
textStyleHighlighted: TextStyle(fontSize: 38, color: Colors.orange, fontWeight: FontWeight.bold),
|
||||
//decoration: _decoration,
|
||||
),
|
||||
|
||||
new InkWell(
|
||||
child: new Text(t(bloc.exerciseRepository.exerciseType.unitQuantityUnit),
|
||||
style: TextStyle(fontSize: 16)),
|
||||
),
|
||||
|
||||
]);
|
||||
Column columnQuantityUnit(ExerciseNewBloc bloc) {
|
||||
Column row = Column();
|
||||
if (bloc.exerciseRepository.exerciseType != null && bloc.exerciseRepository.exerciseType.unitQuantity == "1") {
|
||||
row = Column(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
|
||||
TextFormField(
|
||||
focusNode: _nodeText1,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.only(left: 25, top: 5, bottom: 5),
|
||||
labelText: t(bloc.exerciseRepository.exerciseType.unitQuantityUnit),
|
||||
labelStyle: GoogleFonts.inter(fontSize: 20, color: Colors.yellow[50]),
|
||||
fillColor: Colors.black38,
|
||||
filled: true,
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 8.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.white12, width: 0.4),
|
||||
),
|
||||
),
|
||||
initialValue: "30",
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
textInputAction: TextInputAction.done,
|
||||
style: GoogleFonts.archivoBlack(fontSize: 80, color: Colors.yellow[300]),
|
||||
onChanged: (value) => {bloc.add(ExerciseNewQuantityUnitChange(quantity: double.parse(value)))}),
|
||||
//] ),
|
||||
]);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
Row columnQuantity( ExerciseNewBloc bloc ) {
|
||||
Row row = Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
NumberPicker.horizontal(
|
||||
highlightSelectedValue: true,
|
||||
initialValue: bloc.quantity.toInt(),
|
||||
minValue: 0,
|
||||
maxValue: 200,
|
||||
step: 1,
|
||||
onChanged: (value) => {
|
||||
bloc.add(ExerciseNewQuantityChange(quantity: value.toDouble()))
|
||||
},
|
||||
listViewHeight: 80,
|
||||
textStyle: TextStyle(fontSize: 24),
|
||||
textStyleHighlighted: TextStyle(fontSize: 38, color: Colors.orange, fontWeight: FontWeight.bold),
|
||||
//decoration: _decoration,
|
||||
),
|
||||
|
||||
Text(t(bloc.exerciseRepository.exerciseType.unit),
|
||||
style: TextStyle(fontSize: 16)),
|
||||
]);
|
||||
Column columnQuantity(ExerciseNewBloc bloc) {
|
||||
Column row = Column(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
|
||||
TextFormField(
|
||||
focusNode: _nodeText2,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.only(left: 25, top: 5, bottom: 5),
|
||||
labelText: t(bloc.exerciseRepository.exerciseType.unit),
|
||||
labelStyle: GoogleFonts.inter(fontSize: 20, color: Colors.orange[50], decorationColor: Colors.black12),
|
||||
fillColor: Colors.black38,
|
||||
filled: true,
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 8.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.black26, width: 0.4),
|
||||
),
|
||||
),
|
||||
initialValue: "12",
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
style: GoogleFonts.archivoBlack(fontSize: 80, color: Colors.orange[200]),
|
||||
onChanged: (value) => {bloc.add(ExerciseNewQuantityChange(quantity: double.parse(value)))},
|
||||
),
|
||||
]);
|
||||
|
||||
return row;
|
||||
}
|
||||
|
||||
void confirmationDialog( ExerciseNewBloc bloc ) {
|
||||
void confirmationDialog(ExerciseNewBloc bloc) {
|
||||
LinkedHashMap args = LinkedHashMap();
|
||||
print("exercise validated " + bloc.exerciseRepository.exercise.quantity.toString());
|
||||
if ( bloc.exerciseRepository.exercise.quantity == null) {
|
||||
if (bloc.exerciseRepository.exercise.quantity == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String quantity = bloc.exerciseRepository.exercise.quantity % 1 == 0?
|
||||
bloc.exerciseRepository.exercise.quantity.round().toString() :
|
||||
bloc.exerciseRepository.exercise.quantity.toString();
|
||||
String quantity = bloc.exerciseRepository.exercise.quantity % 1 == 0
|
||||
? bloc.exerciseRepository.exercise.quantity.round().toString()
|
||||
: bloc.exerciseRepository.exercise.quantity.toString();
|
||||
|
||||
String unitQuantity = "";
|
||||
if ( bloc.exerciseRepository.exercise.unitQuantity != null ) {
|
||||
unitQuantity = bloc.exerciseRepository.exercise.unitQuantity % 1 == 0 ?
|
||||
bloc.exerciseRepository.exercise.unitQuantity.round().toString() :
|
||||
bloc.exerciseRepository.exercise.unitQuantity.toString();
|
||||
if (bloc.exerciseRepository.exercise.unitQuantity != null) {
|
||||
unitQuantity = bloc.exerciseRepository.exercise.unitQuantity % 1 == 0
|
||||
? bloc.exerciseRepository.exercise.unitQuantity.round().toString()
|
||||
: bloc.exerciseRepository.exercise.unitQuantity.toString();
|
||||
}
|
||||
|
||||
|
||||
showCupertinoDialog(
|
||||
useRootNavigator: true,
|
||||
context: context,
|
||||
//barrierDismissible: false,
|
||||
builder:(_) => CupertinoAlertDialog(
|
||||
title: Text(t("Do you save this exercise with these parameters?")),
|
||||
content: Column(
|
||||
|
||||
children: [
|
||||
Divider(),
|
||||
Text(t("Exercise") + ": " +
|
||||
bloc.exerciseRepository.exerciseType.name,
|
||||
style: (TextStyle(color: Colors.blue)),),
|
||||
Text(quantity + " " +
|
||||
t(bloc.exerciseRepository.exerciseType.unit),
|
||||
style: (TextStyle(color: Colors.deepOrange)),),
|
||||
Text(bloc.exerciseRepository.exerciseType.unitQuantity == "1" ?
|
||||
t("with") + " "
|
||||
+ unitQuantity + " "
|
||||
+ t(bloc.exerciseRepository.exerciseType.unitQuantityUnit) :
|
||||
"",
|
||||
style: (TextStyle(color: Colors.deepOrange)),
|
||||
),
|
||||
|
||||
]),
|
||||
actions: [
|
||||
FlatButton(
|
||||
child: Text(t("No")),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
FlatButton(
|
||||
child: Text(t("Yes")),
|
||||
onPressed: () => {
|
||||
bloc.exerciseRepository.setCustomer(Cache().userLoggedIn),
|
||||
bloc.exerciseRepository.addExercise(),
|
||||
Navigator.pop(context),
|
||||
Navigator.pop(context),
|
||||
if ( bloc.exerciseRepository.exerciseType.is1RM ) {
|
||||
args['exerciseRepository'] = bloc.exerciseRepository,
|
||||
args['percent'] = 0.75,
|
||||
args['readonly'] = false,
|
||||
Navigator.of(context).pushNamed('exerciseControlPage',
|
||||
arguments: args )
|
||||
}
|
||||
},
|
||||
)
|
||||
],
|
||||
)
|
||||
);
|
||||
useRootNavigator: true,
|
||||
context: context,
|
||||
//barrierDismissible: false,
|
||||
builder: (_) => CupertinoAlertDialog(
|
||||
title: Text(t("Do you save this exercise with these parameters?")),
|
||||
content: Column(children: [
|
||||
Divider(),
|
||||
Text(
|
||||
t("Exercise") + ": " + bloc.exerciseRepository.exerciseType.name,
|
||||
style: (TextStyle(color: Colors.blue)),
|
||||
),
|
||||
Text(
|
||||
quantity + " " + t(bloc.exerciseRepository.exerciseType.unit),
|
||||
style: (TextStyle(color: Colors.deepOrange)),
|
||||
),
|
||||
Text(
|
||||
bloc.exerciseRepository.exerciseType.unitQuantity == "1"
|
||||
? t("with") + " " + unitQuantity + " " + t(bloc.exerciseRepository.exerciseType.unitQuantityUnit)
|
||||
: "",
|
||||
style: (TextStyle(color: Colors.deepOrange)),
|
||||
),
|
||||
]),
|
||||
actions: [
|
||||
FlatButton(
|
||||
child: Text(t("No")),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
FlatButton(
|
||||
child: Text(t("Yes")),
|
||||
onPressed: () => {
|
||||
bloc.exerciseRepository.setCustomer(Cache().userLoggedIn),
|
||||
bloc.exerciseRepository.addExercise(),
|
||||
Navigator.pop(context),
|
||||
Navigator.pop(context),
|
||||
if (bloc.exerciseRepository.exerciseType.is1RM)
|
||||
{
|
||||
args['exerciseRepository'] = bloc.exerciseRepository,
|
||||
args['percent'] = 0.75,
|
||||
args['readonly'] = false,
|
||||
Navigator.of(context).pushNamed('exerciseControlPage', arguments: args)
|
||||
}
|
||||
},
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'dart:collection';
|
||||
|
||||
import 'package:aitrainer_app/bloc/exercise_plan/exercise_plan_bloc.dart';
|
||||
import 'package:aitrainer_app/bloc/exercise_plan_custom_add/exercise_plan_custom_add_bloc.dart';
|
||||
import 'package:aitrainer_app/library/numberpicker.dart';
|
||||
import 'package:aitrainer_app/localization/app_language.dart';
|
||||
import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_plan_repository.dart';
|
||||
@@ -13,6 +12,10 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:keyboard_actions/keyboard_actions.dart';
|
||||
import 'package:keyboard_actions/keyboard_actions_config.dart';
|
||||
import 'package:keyboard_actions/keyboard_actions_item.dart';
|
||||
|
||||
class ExercisePlanDetailAddPage extends StatefulWidget {
|
||||
@override
|
||||
@@ -20,6 +23,73 @@ class ExercisePlanDetailAddPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> with Trans {
|
||||
final FocusNode _nodeText1 = FocusNode();
|
||||
final FocusNode _nodeText2 = FocusNode();
|
||||
final FocusNode _nodeText3 = FocusNode();
|
||||
|
||||
KeyboardActionsConfig _buildConfig(BuildContext context) {
|
||||
return KeyboardActionsConfig(
|
||||
keyboardActionsPlatform: KeyboardActionsPlatform.ALL,
|
||||
keyboardBarColor: Colors.grey[200],
|
||||
nextFocus: true,
|
||||
actions: [
|
||||
KeyboardActionsItem(focusNode: _nodeText2, toolbarButtons: [
|
||||
(node) {
|
||||
return GestureDetector(
|
||||
onTap: () => node.unfocus(),
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
color: Colors.orange[500],
|
||||
child: Text(
|
||||
t("Done"),
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
]),
|
||||
KeyboardActionsItem(
|
||||
focusNode: _nodeText1,
|
||||
toolbarButtons: [
|
||||
//button 2
|
||||
(node) {
|
||||
return GestureDetector(
|
||||
onTap: () => node.unfocus(),
|
||||
child: Container(
|
||||
color: Colors.orange,
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
t("Done"),
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
],
|
||||
),
|
||||
KeyboardActionsItem(
|
||||
focusNode: _nodeText3,
|
||||
toolbarButtons: [
|
||||
//button 2
|
||||
(node) {
|
||||
return GestureDetector(
|
||||
onTap: () => node.unfocus(),
|
||||
child: Container(
|
||||
color: Colors.orange,
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
t("Done"),
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
LinkedHashMap args = ModalRoute.of(context).settings.arguments;
|
||||
@@ -38,8 +108,8 @@ class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> with T
|
||||
if (state is ExercisePlanCustomAddLoading) {
|
||||
return LoadingDialog();
|
||||
} else if (state is ExercisePlanCustomAddError) {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
@@ -50,8 +120,6 @@ class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> with T
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Widget getForm(ExercisePlanCustomAddBloc bloc, WorkoutMenuTree workoutMenuTree) {
|
||||
String exerciseName = "";
|
||||
if (bloc != null) {
|
||||
@@ -60,162 +128,158 @@ class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> with T
|
||||
: bloc.exercisePlanRepository.getActualPlanDetail().exerciseType.nameTranslation;
|
||||
}
|
||||
return Form(
|
||||
autovalidate: true,
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: true,
|
||||
appBar: AppBarNav(depth: 1),
|
||||
body: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('asset/image/WT_light_background.png'),
|
||||
fit: BoxFit.fill,
|
||||
alignment: Alignment.center,
|
||||
),
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: true,
|
||||
appBar: AppBarNav(depth: 1),
|
||||
body: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('asset/image/WT_black_background.png'),
|
||||
fit: BoxFit.fill,
|
||||
alignment: Alignment.center,
|
||||
),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(top: 25, left: 25, right: 25),
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
child: Column(mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[
|
||||
Text(t('Save The Exercise To The Exercise Plan'),
|
||||
style: TextStyle(fontSize: 14, color: Colors.blueAccent)),
|
||||
Text(
|
||||
exerciseName,
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: Colors.deepOrange),
|
||||
overflow: TextOverflow.fade,
|
||||
maxLines: 1,
|
||||
softWrap: true,
|
||||
),
|
||||
Divider(color: Colors.transparent,height: 30,),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Flexible(
|
||||
fit: FlexFit.tight,
|
||||
flex: 8,
|
||||
child:
|
||||
),
|
||||
child: KeyboardActions(
|
||||
config: _buildConfig(context),
|
||||
child: Container(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.only(top: 25, left: 95, right: 95),
|
||||
scrollDirection: Axis.vertical,
|
||||
child: Column(mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[
|
||||
Text(t('Save The Exercise To The Exercise Plan'),
|
||||
textAlign: TextAlign.center,
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 14,
|
||||
color: Colors.white,
|
||||
)),
|
||||
Text(
|
||||
exerciseName,
|
||||
textAlign: TextAlign.center,
|
||||
style: GoogleFonts.archivoBlack(fontSize: 18, color: Colors.deepOrange),
|
||||
overflow: TextOverflow.fade,
|
||||
maxLines: 3,
|
||||
softWrap: true,
|
||||
),
|
||||
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
height: 30,
|
||||
),
|
||||
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.only(left: 25, top: 5, bottom: 5),
|
||||
labelText: t('Serie'),
|
||||
labelStyle: GoogleFonts.inter(fontSize: 20, color: Colors.yellow[50], decorationColor: Colors.black12),
|
||||
fillColor: Colors.white24,
|
||||
filled: true,
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 8.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.black26, width: 0.4),
|
||||
),
|
||||
),
|
||||
initialValue: bloc.serie.toStringAsFixed(0),
|
||||
focusNode: _nodeText1,
|
||||
keyboardType: TextInputType.number,
|
||||
style: GoogleFonts.archivoBlack(fontSize: 60, color: Colors.yellow[200]),
|
||||
onChanged: (value) => {bloc.add(ExercisePlanCustomAddChangeSerie(quantity: double.parse(value)))}),
|
||||
//] ),
|
||||
Divider(),
|
||||
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.only(left: 25, top: 5, bottom: 5),
|
||||
labelText: t('Repeats'),
|
||||
fillColor: Colors.white24,
|
||||
labelStyle: GoogleFonts.inter(fontSize: 20, color: Colors.yellow[50]),
|
||||
filled: true,
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 4.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.green[50], width: 0.4),
|
||||
),
|
||||
),
|
||||
focusNode: _nodeText2,
|
||||
initialValue: bloc.quantity.toStringAsFixed(0),
|
||||
keyboardType: TextInputType.number,
|
||||
style: GoogleFonts.archivoBlack(fontSize: 60, color: Colors.yellow[200]),
|
||||
onChanged: (value) => {bloc.add(ExercisePlanCustomAddChangeQuantity(quantity: double.parse(value)))}),
|
||||
//]),
|
||||
Divider(),
|
||||
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.only(left: 25, top: 5, bottom: 5),
|
||||
labelText: t('Weight'),
|
||||
fillColor: Colors.white24,
|
||||
labelStyle: GoogleFonts.inter(fontSize: 20, color: Colors.yellow[50]),
|
||||
filled: true,
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 2.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.green[50], width: 0.4),
|
||||
),
|
||||
),
|
||||
focusNode: _nodeText3,
|
||||
initialValue: bloc.quantityUnit.toStringAsFixed(0),
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
style: GoogleFonts.archivoBlack(fontSize: 60, color: Colors.yellow[200]),
|
||||
onChanged: (value) => {bloc.add(ExercisePlanCustomAddChangeQuantityUnit(quantity: double.parse(value)))}),
|
||||
//]),
|
||||
|
||||
Divider(),
|
||||
Text(
|
||||
bloc.serie.toStringAsFixed(0) +
|
||||
" x " +
|
||||
bloc.quantity.toStringAsFixed(0) +
|
||||
" x " +
|
||||
bloc.quantityUnit.toStringAsFixed(0) +
|
||||
" kg",
|
||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.normal, color: Colors.yellow[50]),
|
||||
),
|
||||
Divider(),
|
||||
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
FlatButton(
|
||||
onPressed: () => {
|
||||
bloc.add(ExercisePlanCustomAddRemove()),
|
||||
Navigator.of(context).pop(),
|
||||
},
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Image.asset('asset/icon/gomb_pink_b.png', width: 140, height: 60),
|
||||
Text(
|
||||
t("Serie"),
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
|
||||
t("Delete"),
|
||||
style: TextStyle(fontSize: 16, color: Colors.white),
|
||||
),
|
||||
],
|
||||
),
|
||||
NumberPicker.horizontal(
|
||||
highlightSelectedValue: true,
|
||||
initialValue: bloc.serie.toInt(),
|
||||
itemExtent: 85,
|
||||
minValue: 1,
|
||||
maxValue: 20,
|
||||
//decoration: _decoration,
|
||||
step: 1,
|
||||
onChanged: (value) => {
|
||||
bloc.add(ExercisePlanCustomAddChangeSerie(quantity: value.toDouble()))
|
||||
},
|
||||
listViewHeight: 80,
|
||||
textStyle: TextStyle(fontSize: 24),
|
||||
textStyleHighlighted: TextStyle(fontSize: 36, color: Colors.orange, fontWeight: FontWeight.bold),
|
||||
//decoration: _decoration,
|
||||
),
|
||||
|
||||
]
|
||||
),
|
||||
Divider(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Flexible(
|
||||
fit: FlexFit.tight,
|
||||
flex: 8,
|
||||
child:
|
||||
Text(t("Repeats"),
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),),
|
||||
),
|
||||
NumberPicker.horizontal(
|
||||
highlightSelectedValue: true,
|
||||
initialValue: bloc.quantity.toInt(),
|
||||
itemExtent: 85,
|
||||
minValue: 0,
|
||||
maxValue: 200,
|
||||
step: 1,
|
||||
onChanged: (value) => {
|
||||
bloc.add(ExercisePlanCustomAddChangeQuantity(quantity: value.toDouble()))
|
||||
},
|
||||
listViewHeight: 80,
|
||||
textStyle: TextStyle(fontSize: 24),
|
||||
textStyleHighlighted: TextStyle(fontSize: 36, color: Colors.orange, fontWeight: FontWeight.bold),
|
||||
//decoration: _decoration,
|
||||
),
|
||||
]),
|
||||
Divider(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Flexible(
|
||||
fit: FlexFit.tight,
|
||||
flex: 8,
|
||||
child:
|
||||
Text(t("Weight") + " (" + bloc.exercisePlanRepository.getActualPlanDetail().exerciseType.unitQuantityUnit + ")",
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),),
|
||||
),
|
||||
NumberPicker.horizontal(
|
||||
highlightSelectedValue: true,
|
||||
initialValue: bloc.quantityUnit.toInt(),
|
||||
//decoration: _decoration,
|
||||
itemExtent: 85,
|
||||
minValue: 0,
|
||||
maxValue: 650,
|
||||
step: 1,
|
||||
onChanged: (value) => {
|
||||
bloc.add(ExercisePlanCustomAddChangeQuantityUnit(quantity: value.toDouble()))
|
||||
},
|
||||
listViewHeight: 80,
|
||||
textStyle: TextStyle(fontSize: 24),
|
||||
textStyleHighlighted: TextStyle(fontSize: 36, color: Colors.orange, fontWeight: FontWeight.bold),
|
||||
//decoration: _decoration,
|
||||
),
|
||||
]),
|
||||
|
||||
|
||||
Divider(),
|
||||
Text(
|
||||
bloc.serie.toStringAsFixed(0) + " x " + bloc.quantity.toStringAsFixed(0) + " x " + bloc.quantityUnit.toStringAsFixed(0) + " kg" ,
|
||||
style: TextStyle(fontSize: 28, fontWeight: FontWeight.normal),
|
||||
),
|
||||
Divider(),
|
||||
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
RaisedButton(
|
||||
textColor: Colors.white,
|
||||
color: Colors.red.shade300,
|
||||
focusColor: Colors.white,
|
||||
),
|
||||
FlatButton(
|
||||
onPressed: () => {
|
||||
bloc.add(ExercisePlanCustomAddRemove()),
|
||||
Navigator.of(context).pop(),
|
||||
},
|
||||
child: Text(t(
|
||||
"Delete")), //Text(AppLocalizations.of(context).translate("Delete"), style: TextStyle(fontSize: 16),)
|
||||
),
|
||||
RaisedButton(
|
||||
textColor: Colors.white,
|
||||
color: Colors.blueAccent,
|
||||
focusColor: Colors.white,
|
||||
onPressed: () => {
|
||||
bloc.add(ExercisePlanCustomAddSubmit()),
|
||||
Navigator.of(context).pop(),
|
||||
},
|
||||
child: Text(
|
||||
t("Save"),
|
||||
style: TextStyle(fontSize: 16),
|
||||
)),
|
||||
],
|
||||
),
|
||||
]),
|
||||
))),
|
||||
),
|
||||
);
|
||||
bloc.add(ExercisePlanCustomAddSubmit()),
|
||||
Navigator.of(context).pop(),
|
||||
},
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Image.asset('asset/icon/gomb_zold_b-1.png', width: 140, height: 60),
|
||||
Text(
|
||||
t("Save"),
|
||||
style: TextStyle(fontSize: 16, color: Colors.white),
|
||||
),
|
||||
],
|
||||
)),
|
||||
],
|
||||
),
|
||||
]),
|
||||
)))),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
|
||||
class ExercisePlanCustomPage extends StatefulWidget {
|
||||
@override
|
||||
@@ -109,7 +110,7 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> with Trans {
|
||||
Text(" "),
|
||||
Text(
|
||||
t("Custom Exercise Plan"),
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
style: GoogleFonts.archivoBlack(fontSize: 20),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -118,7 +119,7 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> with Trans {
|
||||
),
|
||||
Text(
|
||||
t("Select manually the exercises what you would like to have in your plan. At the end don't forget to save."),
|
||||
style: TextStyle(fontSize: 12, fontWeight: FontWeight.normal),
|
||||
style: GoogleFonts.inter(fontSize: 12, fontWeight: FontWeight.normal),
|
||||
),
|
||||
|
||||
],
|
||||
@@ -131,7 +132,7 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> with Trans {
|
||||
exerciseTypes.add(Container(
|
||||
margin: const EdgeInsets.only(left: 4.0),
|
||||
child: TreeViewChild(
|
||||
startExpanded: true,
|
||||
startExpanded: false,
|
||||
parent: TreeviewParentWidget(text: name),
|
||||
children: _getChildList(list, bloc),
|
||||
)));
|
||||
@@ -157,8 +158,8 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> with Trans {
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: element.selected ? Icon(Icons.check, color: Colors.greenAccent.shade700,)
|
||||
: Icon(Icons.add, color: Colors.blue.shade400,),
|
||||
icon: element.selected ? Icon(Icons.check, color: Colors.green[600],)
|
||||
: Icon(Icons.add, color: Colors.indigo,),
|
||||
onPressed: () => clickAddDetail(bloc, element),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
@@ -171,7 +172,7 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> with Trans {
|
||||
Text(
|
||||
element.name,
|
||||
textAlign: TextAlign.start,
|
||||
style: TextStyle(fontSize: 12, color: Colors.black),
|
||||
style: GoogleFonts.inter(fontSize: 16, color: Colors.black),
|
||||
),
|
||||
onTap: () => clickAddDetail(bloc, element),
|
||||
),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:aitrainer_app/localization/app_language.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:aitrainer_app/widgets/app_bar_min.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -18,23 +19,7 @@ class ExerciseTypeDescription extends StatelessWidget {
|
||||
exerciseRepository.exerciseType.nameTranslation;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
'asset/image/WT_long_logo.png',
|
||||
fit: BoxFit.cover,
|
||||
height: 65.0,
|
||||
),
|
||||
],
|
||||
),
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: Colors.white),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
appBar: AppBarMin(back: true,),
|
||||
body: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
|
||||
+13
-29
@@ -6,34 +6,18 @@ class Gdpr extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
padding: const EdgeInsets.only (left:15, right: 15),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
new InkWell(
|
||||
child: new Text(
|
||||
AppLocalizations.of(context).translate('gdpr_text'),
|
||||
|
||||
),
|
||||
|
||||
customBorder: Border.all(color:Colors.teal, width:1),
|
||||
),
|
||||
Spacer(flex:2),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
FlatButton(
|
||||
textColor: Colors.black,
|
||||
|
||||
onPressed: () { },
|
||||
|
||||
)
|
||||
body: Container(
|
||||
padding: const EdgeInsets.only(left: 15, right: 15),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
new InkWell(
|
||||
child: new Text(
|
||||
AppLocalizations.of(context).translate('gdpr_text'),
|
||||
),
|
||||
customBorder: Border.all(color: Colors.teal, width: 1),
|
||||
),
|
||||
Spacer(flex: 2),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
)
|
||||
);
|
||||
)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+22
-16
@@ -29,7 +29,6 @@ class LoginWidget extends StatefulWidget {
|
||||
|
||||
class _LoginWidget extends State<LoginWidget> with Common, Trans {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -57,29 +56,36 @@ class _LoginWidget extends State<LoginWidget> with Common, Trans {
|
||||
LoadingDialog.hide(context);
|
||||
showInSnackBar(t(state.failureResponse));
|
||||
},
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('asset/image/WT_login.png'),
|
||||
fit: BoxFit.cover,
|
||||
alignment: Alignment.center,
|
||||
),
|
||||
),
|
||||
child: buildLoginForm(loginBloc, accountBloc),
|
||||
),
|
||||
)
|
||||
onLoaded: (context, state ) {
|
||||
|
||||
},
|
||||
child: loadForm(loginBloc, accountBloc)
|
||||
),
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
Widget loadForm(LoginFormBloc loginBloc, AccountBloc accountBloc) {
|
||||
return SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('asset/image/WT_login.png'),
|
||||
fit: BoxFit.cover,
|
||||
alignment: Alignment.center,
|
||||
),
|
||||
),
|
||||
child: buildLoginForm(loginBloc, accountBloc),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildLoginForm(LoginFormBloc formBloc, AccountBloc accountBloc) {
|
||||
|
||||
return Form(
|
||||
key: _formKey,
|
||||
key: _scaffoldKey,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(left: 15, right: 50),
|
||||
child:
|
||||
|
||||
Reference in New Issue
Block a user