Merge ssh://git.aitrainer.app:6622/bossanyit/aitrainer_app

This commit is contained in:
bossanyit
2020-11-29 10:41:13 +01:00
71 changed files with 1458 additions and 845 deletions
+44 -1
View File
@@ -4,6 +4,7 @@ import 'package:aitrainer_app/model/cache.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:badges/badges.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:aitrainer_app/widgets/bottom_nav.dart';
import 'package:flutter/material.dart';
@@ -57,7 +58,7 @@ class AccountPage extends StatelessWidget with Trans {
ListView accountWidget(BuildContext context, String customerName, AccountBloc accountBloc) {
return ListView(padding: EdgeInsets.only(top: 35), children: <Widget>[
ListTile(
leading: Icon(Icons.perm_identity),
leading: badgedIcon(Colors.grey, Icons.perm_identity, "personalData"), //Icon(Icons.perm_identity),
subtitle: Text(t("Profile")),
title: FlatButton(
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
@@ -74,11 +75,33 @@ class AccountPage extends StatelessWidget with Trans {
},
),
),
devices(context, accountBloc),
loginOut(context, accountBloc),
getMyTrainees(context, accountBloc),
]);
}
ListTile devices(BuildContext context, AccountBloc accountBloc) {
ListTile element = ListTile();
element = ListTile(
leading: badgedIcon(Colors.grey, Icons.device_hub, "customerDevice"),
title: FlatButton(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [Text(t("Available Devices"), style: TextStyle(color: Colors.orange)), Icon(Icons.arrow_forward_ios)]),
textColor: Colors.orange,
color: Colors.white,
onPressed: () => {
if (accountBloc.customerRepository.customer != null && Cache().userLoggedIn != null)
{
Navigator.of(context).pushNamed('customerExerciseDevicePage'),
}
},
),
);
return element;
}
ListTile loginOut(BuildContext context, AccountBloc accountBloc) {
ListTile element = ListTile();
@@ -203,4 +226,24 @@ class AccountPage extends StatelessWidget with Trans {
],
));
}
Widget badgedIcon(Color color, IconData icon, String badgeKey) {
bool show = Cache().getBadges()[badgeKey] != null;
int counter = Cache().getBadges()[badgeKey] != null ? Cache().getBadges()[badgeKey] : 0;
return Badge(
position: BadgePosition.topEnd(top: -10, end: -10),
animationDuration: Duration(milliseconds: 500),
animationType: BadgeAnimationType.slide,
badgeColor: Colors.red,
showBadge: show,
badgeContent: Text(
counter.toString(),
style: TextStyle(color: Colors.white),
),
child: Icon(
icon,
color: color,
),
);
}
}
+246
View File
@@ -0,0 +1,246 @@
import 'package:aitrainer_app/bloc/customer_exercise_device/customer_exercise_device_bloc.dart';
import 'package:aitrainer_app/localization/app_language.dart';
import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/model/exercise_device.dart';
import 'package:aitrainer_app/repository/customer_exercise_device_repository.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/app_bar.dart';
import 'package:aitrainer_app/widgets/image_button.dart';
import 'package:aitrainer_app/widgets/splash.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:google_fonts/google_fonts.dart';
// ignore: must_be_immutable
class CustomerExerciseDevicePage extends StatelessWidget with Trans {
List<Widget> listDevice;
@override
Widget build(BuildContext context) {
setContext(context);
double cWidth = MediaQuery.of(context).size.width;
return Scaffold(
appBar: AppBarNav(depth: 0),
body: Container(
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('asset/image/WT_black_background.png'),
fit: BoxFit.cover,
alignment: Alignment.center,
),
),
child: BlocProvider(
create: (context) =>
CustomerExerciseDeviceBloc(repository: CustomerExerciseDeviceRepository(), devices: Cache().getDevices())
..add(CustomerExerciseDeviceLoad()),
child: BlocConsumer<CustomerExerciseDeviceBloc, CustomerExerciseDeviceState>(
listener: (context, state) {
if (state is CustomerExerciseDeviceLoading) {
return LoadingDialog();
} else if (state is CustomerExerciseDeviceError) {
Scaffold.of(context).showSnackBar(
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
}
},
builder: (context, state) {
final bloc = BlocProvider.of<CustomerExerciseDeviceBloc>(context);
return getPage(bloc, cWidth);
},
))));
}
Widget getPage(CustomerExerciseDeviceBloc bloc, double cWidth) {
print("width" + cWidth.toString());
return CustomScrollView(scrollDirection: Axis.vertical, slivers: [
SliverGrid(
delegate: SliverChildListDelegate([
Text(t("Available Training Places"),
textAlign: TextAlign.center,
maxLines: 2,
softWrap: true,
style: GoogleFonts.archivoBlack(
fontSize: 24,
color: Colors.white,
shadows: <Shadow>[
Shadow(
offset: Offset(5.0, 5.0),
blurRadius: 12.0,
color: Colors.black54,
),
Shadow(
offset: Offset(-3.0, 3.0),
blurRadius: 12.0,
color: Colors.black54,
),
],
)),
Text(t("select your places by tapping"),
textAlign: TextAlign.center,
softWrap: true,
maxLines: 2,
style: GoogleFonts.archivoBlack(
fontSize: 14,
color: Colors.white,
shadows: <Shadow>[
Shadow(
offset: Offset(5.0, 5.0),
blurRadius: 12.0,
color: Colors.black54,
),
Shadow(
offset: Offset(-3.0, 3.0),
blurRadius: 12.0,
color: Colors.black54,
),
],
)),
]),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1,
mainAxisSpacing: 0.0,
crossAxisSpacing: 0.0,
childAspectRatio: cWidth > 375 ? 9.1 : 4.1,
),
),
SliverGrid(
delegate: SliverChildListDelegate(getDevicesPlace(bloc, cWidth)),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1,
mainAxisSpacing: 15.0,
crossAxisSpacing: 10.0,
childAspectRatio: 3.0,
),
),
SliverGrid(
delegate: SliverChildListDelegate([
SizedBox(
height: 1,
),
Text(t("Available Equipments"),
textAlign: TextAlign.center,
maxLines: 2,
style: GoogleFonts.archivoBlack(
fontSize: 24,
color: Colors.white,
shadows: <Shadow>[
Shadow(
offset: Offset(5.0, 5.0),
blurRadius: 12.0,
color: Colors.black54,
),
Shadow(
offset: Offset(-3.0, 3.0),
blurRadius: 12.0,
color: Colors.black54,
),
],
)),
Text(t("select your equipments by tapping"),
textAlign: TextAlign.center,
maxLines: 2,
style: GoogleFonts.archivoBlack(
fontSize: 14,
color: Colors.white,
shadows: <Shadow>[
Shadow(
offset: Offset(5.0, 5.0),
blurRadius: 12.0,
color: Colors.black54,
),
Shadow(
offset: Offset(-3.0, 3.0),
blurRadius: 12.0,
color: Colors.black54,
),
],
)),
]),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1,
mainAxisSpacing: 2.0,
crossAxisSpacing: 5.0,
childAspectRatio: cWidth > 375 ? 9.1 : 6.1,
),
),
SliverGrid(
delegate: SliverChildListDelegate(getDevices(bloc)),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 15.0,
crossAxisSpacing: 15.0,
childAspectRatio: 1.0,
),
),
]);
}
List<Widget> getDevices(CustomerExerciseDeviceBloc bloc) {
final bool isEnglish = AppLanguage().appLocal.languageCode == "en";
this.listDevice = List();
final devices = bloc.devices;
devices.sort((a, b) => a.sort.compareTo(b.sort));
if (devices != null) {
devices.forEach((element) {
if (element.place == false) {
final String url = "asset/image/" + element.imageUrl.substring(7);
ImageButton button = ImageButton(
width: 178,
height: 175,
textAlignment: Alignment.topCenter,
text: isEnglish ? element.name : element.nameTranslation,
style: GoogleFonts.archivoBlack(fontSize: 14, color: Colors.white, backgroundColor: Colors.black54.withOpacity(0.4)),
image: url,
left: 5,
onTap: () => changeButtonShape(element, bloc),
isLocked: false,
isMarked: bloc.hasCustomerDevice(element.exerciseDeviceId),
buttonIndex: element.exerciseDeviceId,
isShape: false,
);
listDevice.add(button);
}
});
}
return listDevice;
}
List<Widget> getDevicesPlace(CustomerExerciseDeviceBloc bloc, double cWidth) {
final bool isEnglish = AppLanguage().appLocal.languageCode == "en";
this.listDevice = List();
final devices = bloc.devices;
if (devices != null) {
devices.sort((a, b) => a.sort.compareTo(b.sort));
devices.forEach((element) {
if (element.place) {
ImageButton button = ImageButton(
width: cWidth - 80,
height: 125,
top: 10,
textAlignment: Alignment.topCenter,
text: isEnglish ? element.name : element.nameTranslation,
style: GoogleFonts.archivoBlack(fontSize: 14, color: Colors.white, backgroundColor: Colors.black54.withOpacity(0.4)),
image: element.imageUrl,
left: 35,
onTap: () => changeButtonShape(element, bloc),
isLocked: false,
buttonIndex: element.exerciseDeviceId,
isShape: false,
isMarked: bloc.hasCustomerDevice(element.exerciseDeviceId),
);
listDevice.add(button);
}
});
}
return listDevice;
}
void changeButtonShape(ExerciseDevice device, CustomerExerciseDeviceBloc bloc) {
print("Device clicked: " + device.name);
if (bloc.hasCustomerDevice(device.exerciseDeviceId)) {
bloc.add(CustomerExerciseDeviceRemove(device: device));
} else {
bloc.add(CustomerExerciseDeviceAdd(device: device));
}
}
}
+64 -84
View File
@@ -27,43 +27,31 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
setContext(context);
return BlocProvider(
create: (context) => ExerciseControlBloc(
exerciseRepository: exerciseRepository, percentToCalculate: percent, readonly: readonly)..
add(ExerciseControlLoad()),
child:
BlocConsumer<ExerciseControlBloc, ExerciseControlState>(
listener: (context, state) {
create: (context) => ExerciseControlBloc(exerciseRepository: exerciseRepository, percentToCalculate: percent, readonly: readonly)
..add(ExerciseControlLoad()),
child: BlocConsumer<ExerciseControlBloc, ExerciseControlState>(listener: (context, state) {
if (state is ExerciseControlError) {
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))));
} else if (state is ExerciseControlLoading) {
return LoadingDialog();
}
},
builder: (context, state) {
}, builder: (context, state) {
final exerciseBloc = BlocProvider.of<ExerciseControlBloc>(context);
if (state is ExerciseControlReady) {
return getControlForm(exerciseBloc);
} else {
return getControlForm(exerciseBloc);
}
})
);
}));
}
Form getControlForm(ExerciseControlBloc exerciseBloc) {
String exerciseName = AppLanguage().appLocal == Locale("en")
? exerciseBloc.exerciseRepository.exerciseType.name
: exerciseBloc.exerciseRepository.exerciseType.nameTranslation;
return Form(
autovalidate: true,
child: Scaffold(
resizeToAvoidBottomInset: true,
appBar: AppBarNav(depth: 1),
@@ -97,8 +85,7 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
Icon(Icons.info),
Flexible(
child: Text(t("Why do you need Exercise Control?"),
style:
TextStyle(color: Colors.blueAccent, fontWeight: FontWeight.normal, fontSize: 14)),
style: TextStyle(color: Colors.blueAccent, fontWeight: FontWeight.normal, fontSize: 14)),
),
Icon(Icons.arrow_forward_ios),
]),
@@ -137,19 +124,20 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
}
Widget numberPickForm(ExerciseControlBloc exerciseBloc, int step) {
String strTimes = step == 2 ? exerciseBloc.origQuantity.toString() : "max.";
String textInstruction = "";
textInstruction = t("Please repeat with ") +
exerciseBloc.unitQuantity.toStringAsFixed(0) +
" " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit +
t("hu_with") + " " +
strTimes + " " + t("times!");
exerciseBloc.unitQuantity.toStringAsFixed(0) +
" " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit +
t("hu_with") +
" " +
strTimes +
" " +
t("times!");
String title = step.toString() + ". " + t("Control Exercise:");
List<Widget> listWidgets = [
Text(
title,
@@ -168,75 +156,67 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
minValue: 0,
maxValue: 200,
step: 1,
onChanged: (value) => {
exerciseBloc.add(ExerciseControlQuantityChange(quantity: value.toDouble(), step: step))
},
onChanged: (value) => {exerciseBloc.add(ExerciseControlQuantityChange(quantity: value.toDouble(), step: step))},
listViewHeight: 80,
//decoration: _decoration,
),
RaisedButton(
padding: EdgeInsets.all(0),
textColor: Colors.white,
color: step == exerciseBloc.step ? Colors.blue : Colors.black26,
focusColor: Colors.blueAccent,
onPressed: () => {
exerciseBloc.add(ExerciseControlSubmit(step: step)),
if ( step == 3 ) {
confirmationDialog(exerciseBloc)
}
},
child: Text(
t("Save"),
style: TextStyle(fontSize: 12),
)),
padding: EdgeInsets.all(0),
textColor: Colors.white,
color: step == exerciseBloc.step ? Colors.blue : Colors.black26,
focusColor: Colors.blueAccent,
onPressed: () => {
exerciseBloc.add(ExerciseControlSubmit(step: step)),
if (step == 3) {confirmationDialog(exerciseBloc)}
},
child: Text(
t("Save"),
style: TextStyle(fontSize: 12),
)),
],
),
];
return
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: listWidgets,
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: listWidgets,
);
}
void confirmationDialog( ExerciseControlBloc bloc ) {
void confirmationDialog(ExerciseControlBloc bloc) {
String unit = t(bloc.exerciseRepository.exerciseType.unit);
showCupertinoDialog(
useRootNavigator: true,
context: context,
//barrierDismissible: false,
builder:(_) => CupertinoAlertDialog(
title: Text(t("Summary of your test")),
content: Column(
children: [
Text(t("Test") + ": " + bloc.repeats[1].toStringAsFixed(0) + "x" + bloc.repeats[0].toStringAsFixed(0) + " " + unit ,
style: (TextStyle(color: Colors.blue)),),
Divider(),
Text(t("1st Control") + ": " + bloc.repeats[2].toStringAsFixed(0) + "x" + bloc.unitQuantity.toStringAsFixed(0) + " " + unit ,
style: (TextStyle(color: Colors.blue)),),
Text(t("2nd Control") + ": " + bloc.repeats[3].toStringAsFixed(0) + "x" + bloc.unitQuantity.toStringAsFixed(0) + " " + unit ,
style: (TextStyle(color: Colors.blue)),),
Text(t("3rd Control") + ": " + bloc.repeats [4].toStringAsFixed(0) + "x" + bloc.unitQuantity.toStringAsFixed(0) + " " + unit ,
style: (TextStyle(color: Colors.blue)),),
]),
actions: [
FlatButton(
child: Text(t("OK")),
onPressed: () => {
Navigator.of(context).pop(),
Navigator.of(context).pop()
},
)
],
)
);
useRootNavigator: true,
context: context,
//barrierDismissible: false,
builder: (_) => CupertinoAlertDialog(
title: Text(t("Summary of your test")),
content: Column(children: [
Text(
t("Test") + ": " + bloc.repeats[1].toStringAsFixed(0) + "x" + bloc.repeats[0].toStringAsFixed(0) + " " + unit,
style: (TextStyle(color: Colors.blue)),
),
Divider(),
Text(
t("1st Control") + ": " + bloc.repeats[2].toStringAsFixed(0) + "x" + bloc.unitQuantity.toStringAsFixed(0) + " " + unit,
style: (TextStyle(color: Colors.blue)),
),
Text(
t("2nd Control") + ": " + bloc.repeats[3].toStringAsFixed(0) + "x" + bloc.unitQuantity.toStringAsFixed(0) + " " + unit,
style: (TextStyle(color: Colors.blue)),
),
Text(
t("3rd Control") + ": " + bloc.repeats[4].toStringAsFixed(0) + "x" + bloc.unitQuantity.toStringAsFixed(0) + " " + unit,
style: (TextStyle(color: Colors.blue)),
),
]),
actions: [
FlatButton(
child: Text(t("OK")),
onPressed: () => {Navigator.of(context).pop(), Navigator.of(context).pop()},
)
],
));
}
}
+121 -144
View File
@@ -14,12 +14,11 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
class ExerciseExecutePlanAddPage extends StatefulWidget{
class ExerciseExecutePlanAddPage extends StatefulWidget {
_ExerciseExecuteAddPage createState() => _ExerciseExecuteAddPage();
}
class _ExerciseExecuteAddPage extends State<ExerciseExecutePlanAddPage> with Trans {
@override
Widget build(BuildContext context) {
LinkedHashMap arguments = ModalRoute.of(context).settings.arguments;
@@ -31,167 +30,151 @@ class _ExerciseExecuteAddPage extends State<ExerciseExecutePlanAddPage> with Tra
setContext(context);
return BlocProvider(
create: (context) =>
ExerciseExecutePlanAddBloc(
exerciseRepository: exerciseRepository,
exercisePlanRepository: planBloc.exercisePlanRepository,
customerId: customerId,
workoutTree: workoutTree,
planBloc: planBloc),
child: BlocConsumer<ExerciseExecutePlanAddBloc, ExerciseExecutePlanAddState>(
listener: (context, state) {
create: (context) => ExerciseExecutePlanAddBloc(
exerciseRepository: exerciseRepository,
exercisePlanRepository: planBloc.exercisePlanRepository,
customerId: customerId,
workoutTree: workoutTree,
planBloc: planBloc),
child: BlocConsumer<ExerciseExecutePlanAddBloc, ExerciseExecutePlanAddState>(listener: (context, state) {
if (state is ExerciseExecutePlanAddError) {
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))));
} else if (state is ExerciseExecutePlanAddLoading) {
return LoadingDialog();
}
},
builder: (context, state) {
}, builder: (context, state) {
// ignore: close_sinks
final exerciseBloc = BlocProvider.of<ExerciseExecutePlanAddBloc>(context);
if ( state is ExerciseExecutePlanAddLoading ) {
if (state is ExerciseExecutePlanAddLoading) {
return LoadingDialog();
} else if ( state is ExerciseExecutePlanAddReady) {
} else if (state is ExerciseExecutePlanAddReady) {
return getControlForm(exerciseBloc);
} else {
return getControlForm(exerciseBloc);
}
}
));
}));
}
Form getControlForm( ExerciseExecutePlanAddBloc exerciseBloc) {
String exerciseName = AppLanguage().appLocal == Locale("en") ?
exerciseBloc.exerciseRepository.exerciseType.name :
exerciseBloc.exerciseRepository.exerciseType.nameTranslation;
Form getControlForm(ExerciseExecutePlanAddBloc exerciseBloc) {
String exerciseName = AppLanguage().appLocal == Locale("en")
? exerciseBloc.exerciseRepository.exerciseType.name
: exerciseBloc.exerciseRepository.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: Container(
padding: const EdgeInsets.only (top: 25, left: 25, right: 25),
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
controller: ScrollController(
initialScrollOffset: exerciseBloc.scrollOffset,
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: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Text(t("Save Exercise")),
Text(exerciseName,
style: TextStyle(fontWeight: FontWeight.bold,
fontSize: 18,
color: Colors.deepOrange),
overflow: TextOverflow.fade,
maxLines: 1,
softWrap: true,
),
child: Container(
padding: const EdgeInsets.only(top: 25, left: 25, right: 25),
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
controller: ScrollController(
initialScrollOffset: exerciseBloc.scrollOffset,
),
Divider(color: Colors.transparent,),
Divider(),
Column(
children: repeatExercises(exerciseBloc),
),
Divider(),
]),
)
)
),
child: Column(mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[
Text(t("Save Exercise")),
Text(
exerciseName,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: Colors.deepOrange),
overflow: TextOverflow.fade,
maxLines: 1,
softWrap: true,
),
Divider(
color: Colors.transparent,
),
Divider(),
Column(
children: repeatExercises(exerciseBloc),
),
Divider(),
]),
))),
),
);
}
List<Column> repeatExercises(ExerciseExecutePlanAddBloc exerciseBloc) {
List<Column> listColumns = List<Column>();
for ( int i = 0; i < exerciseBloc.countSteps; i++) {
for (int i = 0; i < exerciseBloc.countSteps; i++) {
Column col = Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Divider(color: Colors.transparent,),
Divider(
color: Colors.transparent,
),
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),),
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 + " " +
exerciseBloc.exercisePlanRepository.getActualPlanDetail().repeats.toString() + " " + t("times!")),
Row(
children: [
NumberPicker.horizontal(
highlightSelectedValue: (i + 1) == exerciseBloc.step,
initialValue: exerciseBloc.unitQuantity.toInt(),
minValue: 0,
maxValue: 650,
step: 1,
textStyle: TextStyle(fontWeight: FontWeight.bold),
textStyleHighlighted: TextStyle(fontSize: 24, color: Colors.indigo, fontWeight: FontWeight.bold),
onChanged: (value) => {
exerciseBloc.add(ExerciseExecutePlanAddChangeUnitQuantity(quantity: value.toDouble()))
},
listViewHeight: 80,
//decoration: _decoration,
),
Text(exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit),
]
Divider(
color: Colors.transparent,
),
Row(
children: [
NumberPicker.horizontal(
highlightSelectedValue: (i+1) == exerciseBloc.step,
initialValue: exerciseBloc.quantity.toInt(),
minValue: 0,
maxValue: 200,
step: 1,
textStyle: TextStyle(fontWeight: FontWeight.bold),
textStyleHighlighted: TextStyle(fontSize: 24, color: Colors.deepOrange, fontWeight: FontWeight.bold),
onChanged: (value) => {
exerciseBloc.add(ExerciseExecutePlanAddChangeQuantity(quantity: value.toDouble()))
},
listViewHeight: 80,
//decoration: _decoration,
),
Text(t("repeat")),
]
),
Text(t("Please repeat with") +
" " +
exerciseBloc.unitQuantity.toStringAsFixed(0) +
" " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit +
" " +
exerciseBloc.exercisePlanRepository.getActualPlanDetail().repeats.toString() +
" " +
t("times!")),
Row(children: [
NumberPicker.horizontal(
highlightSelectedValue: (i + 1) == exerciseBloc.step,
initialValue: exerciseBloc.unitQuantity.toInt(),
minValue: 0,
maxValue: 650,
step: 1,
textStyle: TextStyle(fontWeight: FontWeight.bold),
textStyleHighlighted: TextStyle(fontSize: 24, color: Colors.indigo, fontWeight: FontWeight.bold),
onChanged: (value) => {exerciseBloc.add(ExerciseExecutePlanAddChangeUnitQuantity(quantity: value.toDouble()))},
listViewHeight: 80,
//decoration: _decoration,
),
Text(exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit),
]),
Row(children: [
NumberPicker.horizontal(
highlightSelectedValue: (i + 1) == exerciseBloc.step,
initialValue: exerciseBloc.quantity.toInt(),
minValue: 0,
maxValue: 200,
step: 1,
textStyle: TextStyle(fontWeight: FontWeight.bold),
textStyleHighlighted: TextStyle(fontSize: 24, color: Colors.deepOrange, fontWeight: FontWeight.bold),
onChanged: (value) => {exerciseBloc.add(ExerciseExecutePlanAddChangeQuantity(quantity: value.toDouble()))},
listViewHeight: 80,
//decoration: _decoration,
),
Text(t("repeat")),
]),
/*TextFieldBlocBuilder(
readOnly: exerciseBloc.step != i+1,
@@ -239,25 +222,19 @@ class _ExerciseExecuteAddPage extends State<ExerciseExecutePlanAddPage> with Tra
),
),*/
RaisedButton(
padding: EdgeInsets.all(0),
textColor: Colors.white,
color: exerciseBloc.step == i+1 ? Colors.blue : Colors.black26,
focusColor: Colors.blueAccent,
onPressed: () =>
{
print ("Submit step " + exerciseBloc.step.toString() + " (i) " + i.toString()),
if ( exerciseBloc.step == i+1 ) {
exerciseBloc.add(ExerciseExecutePlanAddSubmit())
},
if ( i+1 == exerciseBloc.countSteps) {
Navigator.of(context).pop()
}
},
child: Text(
t("Save"),
style: TextStyle(fontSize: 12),)
),
padding: EdgeInsets.all(0),
textColor: Colors.white,
color: exerciseBloc.step == i + 1 ? Colors.blue : Colors.black26,
focusColor: Colors.blueAccent,
onPressed: () => {
print("Submit step " + exerciseBloc.step.toString() + " (i) " + i.toString()),
if (exerciseBloc.step == i + 1) {exerciseBloc.add(ExerciseExecutePlanAddSubmit())},
if (i + 1 == exerciseBloc.countSteps) {Navigator.of(context).pop()}
},
child: Text(
t("Save"),
style: TextStyle(fontSize: 12),
)),
Divider(),
],
);
+45 -62
View File
@@ -1,10 +1,6 @@
import 'package:aitrainer_app/bloc/login_form_bloc.dart';
import 'package:aitrainer_app/bloc/account/account_bloc.dart';
import 'package:aitrainer_app/bloc/reset_password_bloc.dart';
import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:aitrainer_app/repository/user_repository.dart';
import 'package:aitrainer_app/service/firebase_api.dart';
import 'package:aitrainer_app/util/common.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/app_bar_min.dart';
import 'package:aitrainer_app/widgets/splash.dart';
@@ -69,68 +65,55 @@ class ResetPasswordPage extends StatelessWidget with Trans {
key: _formKey,
child: Container(
padding: const EdgeInsets.only(left: 25, right: 50),
child: ListView(
shrinkWrap: false,
padding: EdgeInsets.only(top: 150.0),
children: <Widget>[
Divider(),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
new InkWell(
child: new Text(
AppLocalizations.of(context)
.translate('I forgot the password'),
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 24)),
),
],
child: ListView(shrinkWrap: false, padding: EdgeInsets.only(top: 150.0), children: <Widget>[
Divider(),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
new InkWell(
child: new Text(AppLocalizations.of(context).translate('I forgot the password'),
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 24)),
),
Divider(),
TextFieldBlocBuilder(
key: LibraryKeys.loginEmailField,
textFieldBloc: formBloc.emailField,
decoration: InputDecoration(
fillColor: Colors.white,
filled: true,
labelText: 'Email',
),
),
Divider(
color: Colors.transparent,
),
Divider(
color: Colors.transparent,
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
new FlatButton(
key: LibraryKeys.loginOKButton,
child: Image.asset('asset/image/WT_OK.png',
width: 100, height: 100),
onPressed: () => {formBloc.add(SubmitFormBloc())}),
]),
Divider(
color: Colors.transparent,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
new InkWell(
child: new Text(
AppLocalizations.of(context).translate('Login')),
onTap: () => Navigator.of(context).pushNamed('login'),
),
Spacer(flex: 1),
]),
])),
],
),
Divider(),
TextFieldBlocBuilder(
key: LibraryKeys.loginEmailField,
textFieldBloc: formBloc.emailField,
decoration: InputDecoration(
fillColor: Colors.white,
filled: true,
labelText: 'Email',
),
),
Divider(
color: Colors.transparent,
),
Divider(
color: Colors.transparent,
),
Row(mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[
new FlatButton(
key: LibraryKeys.loginOKButton,
child: Image.asset('asset/image/WT_OK.png', width: 100, height: 100),
onPressed: () => {formBloc.add(SubmitFormBloc())}),
]),
Divider(
color: Colors.transparent,
),
Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[
new InkWell(
child: new Text(AppLocalizations.of(context).translate('Login')),
onTap: () => Navigator.of(context).pushNamed('login'),
),
Spacer(flex: 1),
]),
])),
);
}
void showInSnackBar(String error) {
_scaffoldKey.currentState.showSnackBar(SnackBar(
backgroundColor: Colors.orange,
content: Text(error, style: TextStyle(color: Colors.white))));
_scaffoldKey.currentState
.showSnackBar(SnackBar(backgroundColor: Colors.orange, content: Text(error, style: TextStyle(color: Colors.white))));
}
}