WT1.1.11 Null-Safe migration
This commit is contained in:
+68
-54
@@ -16,7 +16,7 @@ import 'package:flutter/cupertino.dart';
|
||||
// ignore: must_be_immutable
|
||||
class AccountPage extends StatelessWidget with Trans {
|
||||
// ignore: close_sinks
|
||||
AccountBloc accountBloc;
|
||||
late AccountBloc accountBloc;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -34,7 +34,7 @@ class AccountPage extends StatelessWidget with Trans {
|
||||
),
|
||||
child: BlocConsumer<AccountBloc, AccountState>(listener: (context, state) {
|
||||
if (state is AccountError) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
} else if (state is AccountLoading) {}
|
||||
}, builder: (context, state) {
|
||||
@@ -49,29 +49,31 @@ class AccountPage extends StatelessWidget with Trans {
|
||||
String goal = t("Set your goal");
|
||||
String fitnessLevel = t("Set your fitness level");
|
||||
String bodyType = "";
|
||||
if (accountBloc.customerRepository.customer != null) {
|
||||
customerName = accountBloc.customerRepository.firstName + " " + accountBloc.customerRepository.name;
|
||||
customerName = customerName.length < 3 ? t("Personal data") : customerName;
|
||||
goal = accountBloc.customerRepository.customer.goal != null ? t(accountBloc.customerRepository.customer.goal) : goal;
|
||||
fitnessLevel = accountBloc.customerRepository.customer.fitnessLevel != null
|
||||
? t(capitalize(accountBloc.customerRepository.customer.fitnessLevel))
|
||||
: fitnessLevel;
|
||||
bodyType = accountBloc.getAccurateBodyType();
|
||||
}
|
||||
|
||||
customerName = accountBloc.customerRepository.firstName! + " " + accountBloc.customerRepository.name!;
|
||||
customerName = customerName.length < 3 ? t("Personal data") : customerName;
|
||||
goal = accountBloc.customerRepository.customer.goal != null ? t(accountBloc.customerRepository.customer.goal!) : goal;
|
||||
fitnessLevel = accountBloc.customerRepository.customer.fitnessLevel != null
|
||||
? t(capitalize(accountBloc.customerRepository.customer.fitnessLevel!))
|
||||
: fitnessLevel;
|
||||
bodyType = accountBloc.getAccurateBodyType();
|
||||
|
||||
final HashMap<String, dynamic> args = HashMap();
|
||||
return ListView(padding: EdgeInsets.only(top: 35), children: <Widget>[
|
||||
ListTile(
|
||||
leading: Common.badgedIcon(Colors.grey, Icons.perm_identity, "personalData"), //Icon(Icons.perm_identity),
|
||||
subtitle: Text(t("Profile")),
|
||||
title: FlatButton(
|
||||
title: TextButton(
|
||||
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
Text(customerName, style: TextStyle(color: Colors.blue)),
|
||||
Icon(Icons.arrow_forward_ios),
|
||||
]),
|
||||
textColor: Colors.grey,
|
||||
color: Colors.white,
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
onSurface: Colors.grey,
|
||||
),
|
||||
onPressed: () => {
|
||||
if (accountBloc.customerRepository.customer != null && Cache().userLoggedIn != null)
|
||||
if (Cache().userLoggedIn != null)
|
||||
{
|
||||
args['personal_data'] = true,
|
||||
Navigator.of(context).pushNamed('customerModifyPage', arguments: args),
|
||||
@@ -82,15 +84,17 @@ class AccountPage extends StatelessWidget with Trans {
|
||||
ListTile(
|
||||
leading: Common.badgedIcon(Colors.grey, Icons.arrow_forward_sharp, "Goal"), //Icon(Icons.arrow_forward_sharp),
|
||||
subtitle: Text(t("Goal")),
|
||||
title: FlatButton(
|
||||
title: TextButton(
|
||||
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
Text(goal, style: TextStyle(color: Colors.blue)),
|
||||
Icon(Icons.arrow_forward_ios),
|
||||
]),
|
||||
textColor: Colors.grey,
|
||||
color: Colors.white,
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
onSurface: Colors.grey,
|
||||
),
|
||||
onPressed: () => {
|
||||
if (accountBloc.customerRepository.customer != null && Cache().userLoggedIn != null)
|
||||
if (Cache().userLoggedIn != null)
|
||||
{
|
||||
args['personal_data'] = true,
|
||||
args['bloc'] = accountBloc.customerRepository,
|
||||
@@ -102,15 +106,17 @@ class AccountPage extends StatelessWidget with Trans {
|
||||
ListTile(
|
||||
leading: Common.badgedIcon(Colors.grey, Icons.perm_contact_cal, "FitnessLevel"), //Icon(Icons.perm_contact_cal),
|
||||
subtitle: Text(t("Activity")),
|
||||
title: FlatButton(
|
||||
title: TextButton(
|
||||
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
Text(fitnessLevel, style: TextStyle(color: Colors.blue)),
|
||||
Icon(Icons.arrow_forward_ios),
|
||||
]),
|
||||
textColor: Colors.grey,
|
||||
color: Colors.white,
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
onSurface: Colors.grey,
|
||||
),
|
||||
onPressed: () => {
|
||||
if (accountBloc.customerRepository.customer != null && Cache().userLoggedIn != null)
|
||||
if (Cache().userLoggedIn != null)
|
||||
{
|
||||
args['personal_data'] = true,
|
||||
args['bloc'] = accountBloc.customerRepository,
|
||||
@@ -122,15 +128,17 @@ class AccountPage extends StatelessWidget with Trans {
|
||||
ListTile(
|
||||
leading: Common.badgedIcon(Colors.grey, CustomIcon.people_arrows, "bodyType"), //Icon(CustomIcon.people_arrows),
|
||||
subtitle: Text(t("Body Type")),
|
||||
title: FlatButton(
|
||||
title: TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
onSurface: Colors.grey,
|
||||
),
|
||||
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
Text(t(bodyType), style: TextStyle(color: Colors.blue)),
|
||||
Icon(Icons.arrow_forward_ios),
|
||||
]),
|
||||
textColor: Colors.grey,
|
||||
color: Colors.white,
|
||||
onPressed: () => {
|
||||
if (accountBloc.customerRepository.customer != null && Cache().userLoggedIn != null)
|
||||
if (Cache().userLoggedIn != null)
|
||||
{
|
||||
args['personal_data'] = true,
|
||||
args['bloc'] = accountBloc.customerRepository,
|
||||
@@ -150,14 +158,18 @@ class AccountPage extends StatelessWidget with Trans {
|
||||
element = ListTile(
|
||||
leading: Common.badgedIcon(Colors.grey, Icons.device_hub, "customerDevice"),
|
||||
subtitle: Text(t("These equipments and devices are available")),
|
||||
title: FlatButton(
|
||||
title: TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
onSurface: Colors.grey,
|
||||
),
|
||||
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,
|
||||
//textColor: Colors.orange,
|
||||
//color: Colors.white,
|
||||
onPressed: () => {
|
||||
if (accountBloc.customerRepository.customer != null && Cache().userLoggedIn != null)
|
||||
if (Cache().userLoggedIn != null)
|
||||
{
|
||||
Navigator.of(context).pushNamed('customerExerciseDevicePage'),
|
||||
}
|
||||
@@ -173,7 +185,7 @@ class AccountPage extends StatelessWidget with Trans {
|
||||
String text = "Logout";
|
||||
Color buttonColor = Colors.orange;
|
||||
|
||||
if (accountBloc.customerRepository.customer == null || accountBloc.customerRepository.customer.email == null) {
|
||||
if (accountBloc.customerRepository.customer.email == null) {
|
||||
text = "Login";
|
||||
buttonColor = Colors.blue;
|
||||
}
|
||||
@@ -181,13 +193,15 @@ class AccountPage extends StatelessWidget with Trans {
|
||||
element = ListTile(
|
||||
enabled: true,
|
||||
leading: Icon(Icons.input),
|
||||
title: FlatButton(
|
||||
title: TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
onSurface: Colors.grey,
|
||||
),
|
||||
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)
|
||||
{
|
||||
@@ -206,9 +220,6 @@ class AccountPage extends StatelessWidget with Trans {
|
||||
}
|
||||
|
||||
Widget getMyTrainees(BuildContext context, AccountBloc accountBloc) {
|
||||
if (accountBloc.customerRepository.customer == null) {
|
||||
return Container();
|
||||
}
|
||||
if (accountBloc.customerRepository.customer.trainer == 0) {
|
||||
return ListTile(
|
||||
title: Container(),
|
||||
@@ -218,31 +229,35 @@ class AccountPage extends StatelessWidget with Trans {
|
||||
if (accountBloc.customerRepository.getTraineesList() == null) {
|
||||
return ListTile(
|
||||
leading: Icon(Icons.people),
|
||||
title: RaisedButton(
|
||||
color: Colors.white70,
|
||||
title: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Colors.white70,
|
||||
),
|
||||
onPressed: () => accountBloc.add(AccountGetTrainees()),
|
||||
child: Text("See my trainees"),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> elements = List<Widget>();
|
||||
accountBloc.customerRepository.getTraineesList().forEach((element) {
|
||||
List<Widget> elements = [];
|
||||
accountBloc.customerRepository.getTraineesList()!.forEach((element) {
|
||||
Customer trainee = element;
|
||||
String name = trainee.name;
|
||||
String firstName = trainee.firstname;
|
||||
String name = trainee.name!;
|
||||
String firstName = trainee.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(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
side: BorderSide(width: 2, color: selected ? Colors.blue : Colors.black26),
|
||||
Widget widget = TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.all(10),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
side: BorderSide(width: 2, color: selected ? Colors.blue : Colors.black26),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
accountBloc.add(AccountSelectTrainee(traineeId: trainee.customerId));
|
||||
accountBloc.add(AccountSelectTrainee(traineeId: trainee.customerId!));
|
||||
//Navigator.of(context).pushNamed('login');
|
||||
},
|
||||
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
@@ -270,18 +285,17 @@ class AccountPage extends StatelessWidget with Trans {
|
||||
showCupertinoDialog(
|
||||
useRootNavigator: true,
|
||||
context: context,
|
||||
//barrierDismissible: false,
|
||||
builder: (_) => CupertinoAlertDialog(
|
||||
title: Text(t("Are you sure to logout?")),
|
||||
content: Column(children: [
|
||||
Divider(),
|
||||
]),
|
||||
actions: [
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text(t("No")),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text(t("Yes")),
|
||||
onPressed: () => {
|
||||
accountBloc.add(AccountLogout()),
|
||||
@@ -292,7 +306,7 @@ class AccountPage extends StatelessWidget with Trans {
|
||||
));
|
||||
}
|
||||
|
||||
String capitalize(String s) {
|
||||
String capitalize(String? s) {
|
||||
if (s == null || s.isEmpty) {
|
||||
return " ";
|
||||
}
|
||||
|
||||
@@ -1,355 +0,0 @@
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:aitrainer_app/bloc/custom_exercise_form_bloc.dart';
|
||||
import 'package:aitrainer_app/util/app_localization.dart';
|
||||
import 'package:aitrainer_app/model/exercise_type.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:aitrainer_app/service/logging.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
|
||||
class CustomExercisePage extends StatefulWidget {
|
||||
_CustomExerciseNewPageState createState() => _CustomExerciseNewPageState();
|
||||
}
|
||||
|
||||
class _CustomExerciseNewPageState extends State<CustomExercisePage> with Logging {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ExerciseType exerciseType = ModalRoute.of(context).settings.arguments;
|
||||
|
||||
return BlocProvider(
|
||||
create: (context) => CustomExerciseFormBloc(exerciseRepository: ExerciseRepository()),
|
||||
child: Builder(builder: (context) {
|
||||
final exerciseBloc = BlocProvider.of<CustomExerciseFormBloc>(context);
|
||||
exerciseBloc.exerciseRepository.setExerciseType(exerciseType);
|
||||
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
resizeToAvoidBottomInset: true,
|
||||
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(),
|
||||
),
|
||||
),
|
||||
body: FormBlocListener<CustomExerciseFormBloc, String, String>(
|
||||
/* onSubmitting: (context, state) {
|
||||
LoadingDialog.show(context);
|
||||
}, */
|
||||
onSuccess: (context, state) {},
|
||||
onFailure: (context, state) {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
backgroundColor: Colors.orange, content: Text(state.failureResponse, style: TextStyle(color: Colors.white))));
|
||||
},
|
||||
child: ModalProgressHUD(
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('asset/image/WT_light_background.jpg'),
|
||||
fit: BoxFit.fill,
|
||||
alignment: Alignment.center,
|
||||
),
|
||||
),
|
||||
child: CustomScrollView(scrollDirection: Axis.vertical, slivers: [
|
||||
SliverList(
|
||||
delegate: SliverChildListDelegate([
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 20, left: 25, right: 25),
|
||||
alignment: Alignment.center,
|
||||
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
Text("Custom Exercise",
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: Colors.deepOrange)),
|
||||
columnQuantityUnit(exerciseBloc),
|
||||
columnQuantity(exerciseBloc),
|
||||
])),
|
||||
]),
|
||||
),
|
||||
gridCalculation(exerciseBloc)
|
||||
])),
|
||||
inAsyncCall: exerciseBloc.loading == true,
|
||||
opacity: 0.5,
|
||||
color: Colors.black54,
|
||||
progressIndicator: CircularProgressIndicator(),
|
||||
),
|
||||
));
|
||||
}));
|
||||
}
|
||||
|
||||
Column columnQuantityUnit(CustomExerciseFormBloc bloc) {
|
||||
Column column = Column();
|
||||
if (bloc.exerciseRepository.exerciseType != null && bloc.exerciseRepository.exerciseType.unitQuantity == "1") {
|
||||
column = Column(children: [
|
||||
TextFieldBlocBuilder(
|
||||
textFieldBloc: bloc.unitQuantityField,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 16, color: Colors.lightBlue, fontWeight: FontWeight.bold),
|
||||
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r"[\d.]"))],
|
||||
onChanged: (input) => {log("UnitQuantity value $input"), bloc.exerciseRepository.setUnitQuantity(double.parse(input))},
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
hintStyle: TextStyle(fontSize: 12, color: Colors.black54, fontWeight: FontWeight.w100),
|
||||
hintText: AppLocalizations.of(context).translate("The number of the exercise done with"),
|
||||
labelStyle: TextStyle(fontSize: 12, color: Colors.lightBlue),
|
||||
labelText: AppLocalizations.of(context).translate(bloc.exerciseRepository.exerciseType.unitQuantityUnit),
|
||||
),
|
||||
),
|
||||
new InkWell(
|
||||
child: new Text(AppLocalizations.of(context).translate(bloc.exerciseRepository.exerciseType.unitQuantityUnit),
|
||||
style: TextStyle(fontSize: 12)),
|
||||
),
|
||||
]);
|
||||
}
|
||||
return column;
|
||||
}
|
||||
|
||||
Column columnQuantity(CustomExerciseFormBloc bloc) {
|
||||
Column column = Column(children: [
|
||||
TextFieldBlocBuilder(
|
||||
textFieldBloc: bloc.quantityField,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 20, color: Colors.deepOrange, fontWeight: FontWeight.bold),
|
||||
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r"[\d.]"))],
|
||||
onChanged: (input) => {
|
||||
log("Quantity value $input"),
|
||||
bloc.exerciseRepository.setQuantity(double.parse(input)),
|
||||
bloc.exerciseRepository.setUnit(bloc.exerciseRepository.exerciseType.unit)
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
hintStyle: TextStyle(fontSize: 12, color: Colors.black54, fontWeight: FontWeight.w100),
|
||||
hintText: AppLocalizations.of(context).translate("The number of the exercise"),
|
||||
labelStyle: TextStyle(fontSize: 12, color: Colors.deepOrange),
|
||||
labelText: AppLocalizations.of(context).translate(bloc.exerciseRepository.exerciseType.unit),
|
||||
),
|
||||
),
|
||||
]);
|
||||
|
||||
return column;
|
||||
}
|
||||
|
||||
SliverGrid gridCalculation(CustomExerciseFormBloc bloc) {
|
||||
LinkedHashMap args = LinkedHashMap();
|
||||
return SliverGrid(
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 3,
|
||||
mainAxisSpacing: 10.0,
|
||||
crossAxisSpacing: 10.0,
|
||||
childAspectRatio: 2.0,
|
||||
),
|
||||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
textFieldBloc: bloc.rmWendlerField,
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
labelText: "1RM by Wendler: ",
|
||||
)),
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
maxLines: 1,
|
||||
textFieldBloc: bloc.rmWathenField,
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
labelText: "1RM by Wahten: ",
|
||||
)),
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
maxLines: 1,
|
||||
textFieldBloc: bloc.rmOconnerField,
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
labelText: "1RM by O'Conner: ",
|
||||
)),
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
maxLines: 1,
|
||||
textFieldBloc: bloc.rmMayhewField,
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
labelText: "1RM by Mayhew: ",
|
||||
)),
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
maxLines: 1,
|
||||
textFieldBloc: bloc.rmAverageField,
|
||||
style: TextStyle(color: Colors.blueAccent, fontSize: 12),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
labelText: "1RM Average: ",
|
||||
)),
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
maxLines: 1,
|
||||
textFieldBloc: bloc.rm90Field,
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
labelText: "1RM 90%: ",
|
||||
)),
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
maxLines: 1,
|
||||
textFieldBloc: bloc.rm75Field,
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12, fontWeight: FontWeight.normal),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
labelText: "1RM 75%: ",
|
||||
)),
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
maxLines: 1,
|
||||
textFieldBloc: bloc.rm75OconnorField,
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12, fontWeight: FontWeight.normal),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
labelText: "1RM 75%: by O'Connor",
|
||||
)),
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
maxLines: 1,
|
||||
textFieldBloc: bloc.rm75WendlerField,
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12, fontWeight: FontWeight.normal),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
labelText: "1RM 75% by Wendler: ",
|
||||
)),
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
maxLines: 1,
|
||||
textFieldBloc: bloc.rm80Field,
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
labelText: "1RM 80%: ",
|
||||
)),
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
maxLines: 1,
|
||||
textFieldBloc: bloc.rm70Field,
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
labelText: "1RM 70%: ",
|
||||
)),
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
maxLines: 1,
|
||||
textFieldBloc: bloc.rm60Field,
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
labelText: "1RM 60%: ",
|
||||
)),
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
maxLines: 1,
|
||||
textFieldBloc: bloc.rm50Field,
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
labelText: "1RM 50%: ",
|
||||
)),
|
||||
RaisedButton(
|
||||
padding: EdgeInsets.all(0),
|
||||
textColor: Colors.white,
|
||||
color: Colors.blue,
|
||||
focusColor: Colors.blueAccent,
|
||||
onPressed: () => {
|
||||
args['exerciseRepository'] = bloc.exerciseRepository,
|
||||
args['percent'] = 0.75,
|
||||
args['readonly'] = true,
|
||||
Navigator.of(context).pushNamed('exerciseControlPage', arguments: args)
|
||||
},
|
||||
child: Text(
|
||||
"Control with 75%",
|
||||
style: TextStyle(fontSize: 12),
|
||||
)),
|
||||
RaisedButton(
|
||||
padding: EdgeInsets.all(0),
|
||||
textColor: Colors.white,
|
||||
color: Colors.green,
|
||||
focusColor: Colors.blueAccent,
|
||||
onPressed: () => {
|
||||
args['exerciseRepository'] = bloc.exerciseRepository,
|
||||
args['percent'] = 0.5,
|
||||
args['readonly'] = true,
|
||||
Navigator.of(context).pushNamed('exerciseControlPage', arguments: args)
|
||||
},
|
||||
child: Text(
|
||||
"Control with 50%",
|
||||
style: TextStyle(fontSize: 12),
|
||||
)),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,9 @@ import 'package:aitrainer_app/widgets/app_bar.dart';
|
||||
import 'package:aitrainer_app/widgets/dialog_html.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:liquid_progress_indicator/liquid_progress_indicator.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
import 'package:rainbow_color/rainbow_color.dart';
|
||||
|
||||
class CustomerBodyTypeAnimationPage extends StatefulWidget {
|
||||
@@ -22,17 +21,17 @@ class CustomerBodyTypeAnimationPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _CustomerBodyTypeAnimationPageState extends State<CustomerBodyTypeAnimationPage> with Trans {
|
||||
bool fulldata;
|
||||
late bool fulldata;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
CustomerRepository customerRepository;
|
||||
dynamic args = ModalRoute.of(context).settings.arguments;
|
||||
dynamic args = ModalRoute.of(context)!.settings.arguments;
|
||||
if (args is HashMap && args['personal_data'] != null) {
|
||||
fulldata = args['personal_data'];
|
||||
customerRepository = args['bloc'];
|
||||
} else {
|
||||
customerRepository = ModalRoute.of(context).settings.arguments;
|
||||
customerRepository = ModalRoute.of(context)!.settings.arguments as CustomerRepository;
|
||||
}
|
||||
|
||||
setContext(context);
|
||||
@@ -53,7 +52,7 @@ class _CustomerBodyTypeAnimationPageState extends State<CustomerBodyTypeAnimatio
|
||||
create: (context) => BodytypeBloc(repository: customerRepository),
|
||||
child: BlocConsumer<BodytypeBloc, BodytypeState>(listener: (context, state) {
|
||||
if (state is BodytypeError) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(state.error, style: TextStyle(color: Colors.white))));
|
||||
}
|
||||
}, builder: (context, state) {
|
||||
@@ -321,14 +320,14 @@ class _CustomerBodyTypeAnimationPageState extends State<CustomerBodyTypeAnimatio
|
||||
|
||||
class BodyTypeResult extends StatefulWidget {
|
||||
final BodytypeBloc bloc;
|
||||
const BodyTypeResult({this.bloc});
|
||||
const BodyTypeResult({required this.bloc});
|
||||
@override
|
||||
_BodyTypeResultState createState() => _BodyTypeResultState();
|
||||
}
|
||||
|
||||
class _BodyTypeResultState extends State<BodyTypeResult> with TickerProviderStateMixin {
|
||||
Animation<Color> colorAnim;
|
||||
AnimationController colorController;
|
||||
late Animation<Color> colorAnim;
|
||||
late AnimationController colorController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -339,14 +338,14 @@ class _BodyTypeResultState extends State<BodyTypeResult> with TickerProviderStat
|
||||
void buildAnimation() {
|
||||
colorController = AnimationController(duration: Duration(seconds: 2), vsync: this);
|
||||
colorAnim = RainbowColorTween([
|
||||
Colors.green[800],
|
||||
Colors.green[700],
|
||||
Colors.green[600],
|
||||
Colors.green[500],
|
||||
Colors.green[400],
|
||||
Colors.green[300],
|
||||
Colors.green[200],
|
||||
Colors.green[100],
|
||||
Colors.green[800]!,
|
||||
Colors.green[700]!,
|
||||
Colors.green[600]!,
|
||||
Colors.green[500]!,
|
||||
Colors.green[400]!,
|
||||
Colors.green[300]!,
|
||||
Colors.green[200]!,
|
||||
Colors.green[100]!,
|
||||
Color(0xffb4f500),
|
||||
]).animate(colorController)
|
||||
..addListener(() {
|
||||
@@ -384,14 +383,14 @@ class CurvePainter extends CustomPainter {
|
||||
final linePainter = Paint();
|
||||
final circlePainter = Paint();
|
||||
final Color color;
|
||||
|
||||
final int value;
|
||||
CurvePainter({this.value, this.color});
|
||||
|
||||
CurvePainter({required this.value, required this.color});
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
var paint = linePainter;
|
||||
paint.color = Colors.green[800];
|
||||
paint.color = Colors.green[800]!;
|
||||
paint.strokeWidth = 5;
|
||||
paint.style = PaintingStyle.fill;
|
||||
|
||||
@@ -421,15 +420,16 @@ class CurvePainter extends CustomPainter {
|
||||
class Question extends StatefulWidget {
|
||||
final String text;
|
||||
final BodytypeBloc bloc;
|
||||
const Question({this.text, this.bloc});
|
||||
const Question({required this.text, required this.bloc});
|
||||
|
||||
@override
|
||||
_QuestionState createState() => _QuestionState();
|
||||
}
|
||||
|
||||
class _QuestionState extends State<Question> with TickerProviderStateMixin {
|
||||
AnimationController _controller;
|
||||
Animation<double> _animation;
|
||||
late AnimationController _controller;
|
||||
late Animation<double> _animation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -464,7 +464,7 @@ class _QuestionState extends State<Question> with TickerProviderStateMixin {
|
||||
child: FadeTransition(
|
||||
key: ValueKey(widget.text),
|
||||
opacity: _animation,
|
||||
child: Text(AppLocalizations.of(context).translate(widget.bloc.getQuestion()),
|
||||
child: Text(AppLocalizations.of(context)!.translate(widget.bloc.getQuestion()),
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 3,
|
||||
style: GoogleFonts.archivoBlack(
|
||||
@@ -491,15 +491,15 @@ class CircleButton extends StatefulWidget {
|
||||
final BodytypeBloc bloc;
|
||||
final int value;
|
||||
|
||||
CircleButton({Key key, this.onTap, this.bloc, this.value}) : super(key: key);
|
||||
CircleButton({Key? key, required this.onTap, required this.bloc, required this.value}) : super(key: key);
|
||||
|
||||
@override
|
||||
_CircleButtonState createState() => _CircleButtonState();
|
||||
}
|
||||
|
||||
class _CircleButtonState extends State<CircleButton> with TickerProviderStateMixin {
|
||||
Animation<Color> colorAnim;
|
||||
AnimationController colorController;
|
||||
late Animation<Color> colorAnim;
|
||||
late AnimationController colorController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -530,14 +530,14 @@ class _CircleButtonState extends State<CircleButton> with TickerProviderStateMix
|
||||
Color(0xffb4f500),
|
||||
Color(0xffb4f500),
|
||||
Color(0xffb4f500),
|
||||
Colors.green[100],
|
||||
Colors.green[200],
|
||||
Colors.green[300],
|
||||
Colors.green[400],
|
||||
Colors.green[500],
|
||||
Colors.green[600],
|
||||
Colors.green[700],
|
||||
Colors.green[800],
|
||||
Colors.green[100]!,
|
||||
Colors.green[200]!,
|
||||
Colors.green[300]!,
|
||||
Colors.green[400]!,
|
||||
Colors.green[500]!,
|
||||
Colors.green[600]!,
|
||||
Colors.green[700]!,
|
||||
Colors.green[800]!,
|
||||
]).animate(colorController)
|
||||
..addListener(() {
|
||||
setState(() {});
|
||||
@@ -567,14 +567,14 @@ class _AnimatedLiquidCustomProgressIndicator extends StatefulWidget {
|
||||
final int percentTo;
|
||||
final int percentFrom;
|
||||
|
||||
const _AnimatedLiquidCustomProgressIndicator({this.percentTo, this.percentFrom});
|
||||
const _AnimatedLiquidCustomProgressIndicator({required this.percentTo, required this.percentFrom});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _AnimatedLiquidCustomProgressIndicatorState();
|
||||
}
|
||||
|
||||
class _AnimatedLiquidCustomProgressIndicatorState extends State<_AnimatedLiquidCustomProgressIndicator> with TickerProviderStateMixin {
|
||||
AnimationController _animationController;
|
||||
late AnimationController _animationController;
|
||||
bool switching = false;
|
||||
|
||||
@override
|
||||
@@ -625,7 +625,7 @@ class _AnimatedLiquidCustomProgressIndicatorState extends State<_AnimatedLiquidC
|
||||
value: _animationController.value,
|
||||
direction: Axis.vertical,
|
||||
backgroundColor: Colors.white,
|
||||
valueColor: AlwaysStoppedAnimation(Colors.blue[200]),
|
||||
valueColor: AlwaysStoppedAnimation(Colors.blue[200]!),
|
||||
shapePath: _buildHeartPath(),
|
||||
center: Text(
|
||||
"${percentage.toStringAsFixed(0)}%",
|
||||
@@ -650,26 +650,4 @@ class _AnimatedLiquidCustomProgressIndicatorState extends State<_AnimatedLiquidC
|
||||
..cubicTo(65, 0, 55, 12, 55, 15)
|
||||
..close();
|
||||
}
|
||||
|
||||
Path _buildManPath() {
|
||||
return Path()
|
||||
..moveTo(55, 15)
|
||||
..cubicTo(75, 20, 75, 32, 68, 38)
|
||||
..lineTo(68, 43)
|
||||
..lineTo(116, 43)
|
||||
..lineTo(116, 55)
|
||||
..lineTo(75, 55)
|
||||
..conicTo(68, 80, 80, 120, 20)
|
||||
..lineTo(68, 120)
|
||||
..lineTo(55, 90)
|
||||
..lineTo(42, 120)
|
||||
..lineTo(20, 120)
|
||||
..conicTo(42, 80, 40, 55, 40)
|
||||
..lineTo(0, 55)
|
||||
..lineTo(0, 43)
|
||||
..lineTo(48, 43)
|
||||
..lineTo(48, 38)
|
||||
..cubicTo(25, 20, 25, 32, 55, 15)
|
||||
..close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class CustomerExerciseDevicePage extends StatelessWidget with Trans {
|
||||
List<Widget> listDevice;
|
||||
late List<Widget> listDevice;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -34,12 +34,12 @@ class CustomerExerciseDevicePage extends StatelessWidget with Trans {
|
||||
),
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
CustomerExerciseDeviceBloc(repository: CustomerExerciseDeviceRepository(), devices: Cache().getDevices())
|
||||
CustomerExerciseDeviceBloc(repository: CustomerExerciseDeviceRepository(), devices: Cache().getDevices()!)
|
||||
..add(CustomerExerciseDeviceLoad()),
|
||||
child: BlocConsumer<CustomerExerciseDeviceBloc, CustomerExerciseDeviceState>(
|
||||
listener: (context, state) {
|
||||
if (state is CustomerExerciseDeviceError) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
}
|
||||
},
|
||||
@@ -183,7 +183,7 @@ class CustomerExerciseDevicePage extends StatelessWidget with Trans {
|
||||
|
||||
List<Widget> getDevices(CustomerExerciseDeviceBloc bloc, double cWidth, double cHeight) {
|
||||
final bool isEnglish = AppLanguage().appLocal.languageCode == "en";
|
||||
this.listDevice = List();
|
||||
this.listDevice = [];
|
||||
final devices = bloc.devices;
|
||||
if (devices != null) {
|
||||
devices.sort((a, b) => a.sort.compareTo(b.sort));
|
||||
@@ -213,7 +213,7 @@ class CustomerExerciseDevicePage extends StatelessWidget with Trans {
|
||||
|
||||
List<Widget> getDevicesPlace(CustomerExerciseDeviceBloc bloc, double cWidth, cHeight) {
|
||||
final bool isEnglish = AppLanguage().appLocal.languageCode == "en";
|
||||
this.listDevice = List();
|
||||
this.listDevice = [];
|
||||
final devices = bloc.devices;
|
||||
if (devices != null) {
|
||||
devices.sort((a, b) => a.sort.compareTo(b.sort));
|
||||
|
||||
@@ -14,7 +14,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class CustomerFitnessPage extends StatefulWidget {
|
||||
_CustomerFitnessPageState _state;
|
||||
late _CustomerFitnessPageState _state;
|
||||
|
||||
_CustomerFitnessPageState createState() {
|
||||
_state = _CustomerFitnessPageState();
|
||||
@@ -22,11 +22,10 @@ class CustomerFitnessPage extends StatefulWidget {
|
||||
}
|
||||
}
|
||||
|
||||
//TODO
|
||||
// dropbox for professional sport
|
||||
|
||||
class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
|
||||
String selected;
|
||||
late String selected;
|
||||
bool fulldata = false;
|
||||
|
||||
@override
|
||||
@@ -34,21 +33,24 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
|
||||
setContext(context);
|
||||
final double cWidth = MediaQuery.of(context).size.width * 0.75;
|
||||
CustomerRepository customerRepository;
|
||||
dynamic args = ModalRoute.of(context).settings.arguments;
|
||||
dynamic args = ModalRoute.of(context)!.settings.arguments;
|
||||
if (args is HashMap && args['personal_data'] != null) {
|
||||
fulldata = args['personal_data'];
|
||||
customerRepository = args['bloc'];
|
||||
} else {
|
||||
customerRepository = ModalRoute.of(context).settings.arguments;
|
||||
customerRepository = ModalRoute.of(context)!.settings.arguments as CustomerRepository;
|
||||
}
|
||||
|
||||
selected = customerRepository.customer.fitnessLevel;
|
||||
selected = customerRepository.customer.fitnessLevel!;
|
||||
|
||||
PreferredSizeWidget _bar = AppBarMin(
|
||||
back: true,
|
||||
);
|
||||
if (!fulldata) {
|
||||
_bar = AppBarProgress(max: 50, min: 26);
|
||||
}
|
||||
return Scaffold(
|
||||
appBar: fulldata
|
||||
? AppBarMin(
|
||||
back: true,
|
||||
)
|
||||
: AppBarProgress(max: 75, min: 51),
|
||||
appBar: _bar,
|
||||
body: BlocProvider(
|
||||
create: (context) => CustomerChangeBloc(customerRepository: customerRepository),
|
||||
child: Builder(builder: (context) {
|
||||
@@ -80,7 +82,11 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
|
||||
)
|
||||
]),
|
||||
Divider(),
|
||||
FlatButton(
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.all(10.0),
|
||||
shape: getShape(customerRepository, FitnessState.beginner),
|
||||
),
|
||||
child: Container(
|
||||
width: cWidth,
|
||||
child: Column(
|
||||
@@ -94,8 +100,6 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
|
||||
),
|
||||
],
|
||||
)),
|
||||
padding: EdgeInsets.all(10.0),
|
||||
shape: getShape(customerRepository, FitnessState.beginner),
|
||||
onPressed: () => {
|
||||
setState(() {
|
||||
selected = FitnessState.beginner;
|
||||
@@ -103,7 +107,11 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
|
||||
}),
|
||||
}),
|
||||
Divider(),
|
||||
FlatButton(
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.all(10.0),
|
||||
shape: getShape(customerRepository, FitnessState.intermediate),
|
||||
),
|
||||
child: Container(
|
||||
width: cWidth,
|
||||
child: Column(
|
||||
@@ -125,8 +133,6 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
|
||||
],
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.all(10.0),
|
||||
shape: getShape(customerRepository, FitnessState.intermediate),
|
||||
onPressed: () => {
|
||||
setState(() {
|
||||
selected = FitnessState.intermediate;
|
||||
@@ -135,7 +141,11 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
|
||||
}),
|
||||
}),
|
||||
Divider(),
|
||||
FlatButton(
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.all(10.0),
|
||||
shape: getShape(customerRepository, FitnessState.advanced),
|
||||
),
|
||||
child: Container(
|
||||
width: cWidth,
|
||||
child: Column(
|
||||
@@ -157,8 +167,6 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
|
||||
],
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.all(10.0),
|
||||
shape: getShape(customerRepository, FitnessState.advanced),
|
||||
onPressed: () => {
|
||||
setState(() {
|
||||
selected = FitnessState.advanced;
|
||||
@@ -167,21 +175,25 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
|
||||
}),
|
||||
}),
|
||||
Divider(),
|
||||
FlatButton(
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.all(10.0),
|
||||
shape: getShape(customerRepository, FitnessState.professional),
|
||||
),
|
||||
child: Container(
|
||||
width: cWidth,
|
||||
child: Column(
|
||||
children: [
|
||||
InkWell(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate("Professional"),
|
||||
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"),
|
||||
AppLocalizations.of(context)!.translate("I am professional"),
|
||||
style: TextStyle(color: Colors.black, fontSize: 20, fontFamily: 'Arial', fontWeight: FontWeight.w100),
|
||||
),
|
||||
highlightColor: Colors.white,
|
||||
@@ -189,8 +201,6 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
|
||||
],
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.all(10.0),
|
||||
shape: getShape(customerRepository, FitnessState.professional),
|
||||
onPressed: () => {
|
||||
setState(() {
|
||||
selected = FitnessState.professional;
|
||||
@@ -199,9 +209,11 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
|
||||
}),
|
||||
}),
|
||||
Divider(),
|
||||
RaisedButton(
|
||||
color: Colors.orange,
|
||||
textColor: Colors.white,
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
onPrimary: Colors.white,
|
||||
primary: Colors.orange,
|
||||
),
|
||||
child: Text(fulldata ? t("Save") : t("Next")),
|
||||
onPressed: () => {
|
||||
changeBloc.add(CustomerSave()),
|
||||
@@ -217,7 +229,7 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
|
||||
}
|
||||
|
||||
dynamic getShape(CustomerRepository customerRepository, String fitnessLevel) {
|
||||
String selected = customerRepository.fitnessLevel;
|
||||
String selected = customerRepository.fitnessLevel!;
|
||||
dynamic returnCode = (selected == fitnessLevel)
|
||||
? RoundedRectangleBorder(
|
||||
side: BorderSide(width: 4, color: Colors.orange),
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'package:aitrainer_app/widgets/app_bar_min.dart';
|
||||
import 'package:aitrainer_app/widgets/app_bar_progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class GoalsItem {
|
||||
static String muscle = "gain_muscle";
|
||||
@@ -22,7 +22,7 @@ class CustomerGoalPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _CustomerGoalPage extends State<CustomerGoalPage> with Trans {
|
||||
String selected;
|
||||
String? selected;
|
||||
bool fulldata = false;
|
||||
|
||||
@override
|
||||
@@ -30,20 +30,23 @@ class _CustomerGoalPage extends State<CustomerGoalPage> with Trans {
|
||||
setContext(context);
|
||||
|
||||
CustomerRepository customerRepository;
|
||||
dynamic args = ModalRoute.of(context).settings.arguments;
|
||||
dynamic args = ModalRoute.of(context)!.settings.arguments;
|
||||
if (args is HashMap && args['personal_data'] != null) {
|
||||
fulldata = args['personal_data'];
|
||||
customerRepository = args['bloc'];
|
||||
} else {
|
||||
customerRepository = ModalRoute.of(context).settings.arguments;
|
||||
customerRepository = ModalRoute.of(context)!.settings.arguments as CustomerRepository;
|
||||
}
|
||||
|
||||
PreferredSizeWidget _bar = AppBarMin(
|
||||
back: true,
|
||||
);
|
||||
if (!fulldata) {
|
||||
_bar = AppBarProgress(max: 50, min: 26);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: fulldata
|
||||
? AppBarMin(
|
||||
back: true,
|
||||
)
|
||||
: AppBarProgress(max: 50, min: 26),
|
||||
appBar: _bar,
|
||||
body: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
@@ -66,19 +69,21 @@ class _CustomerGoalPage extends State<CustomerGoalPage> with Trans {
|
||||
Divider(),
|
||||
InkWell(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate("Set Your Goals"),
|
||||
AppLocalizations.of(context)!.translate("Set Your Goals"),
|
||||
style: TextStyle(color: Colors.orange, fontSize: 50, fontFamily: 'Arial', fontWeight: FontWeight.w900),
|
||||
),
|
||||
highlightColor: Colors.white,
|
||||
),
|
||||
Stack(alignment: Alignment.bottomLeft, overflow: Overflow.visible, children: [
|
||||
FlatButton(
|
||||
Stack(alignment: Alignment.bottomLeft, children: [
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.all(0.0),
|
||||
shape: getShape(changeBloc, GoalsItem.muscle),
|
||||
),
|
||||
child: Image.asset(
|
||||
"asset/image/Gain_muscle.jpg",
|
||||
height: 180,
|
||||
),
|
||||
padding: EdgeInsets.all(0.0),
|
||||
shape: getShape(changeBloc, GoalsItem.muscle),
|
||||
onPressed: () => {
|
||||
setState(() {
|
||||
selected = GoalsItem.muscle;
|
||||
@@ -87,21 +92,23 @@ class _CustomerGoalPage extends State<CustomerGoalPage> with Trans {
|
||||
}),
|
||||
InkWell(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate("Gain Muscle"),
|
||||
AppLocalizations.of(context)!.translate("Gain Muscle"),
|
||||
style: TextStyle(color: Colors.white, fontSize: 32, fontFamily: 'Arial', fontWeight: FontWeight.w900),
|
||||
),
|
||||
highlightColor: Colors.white,
|
||||
)
|
||||
]),
|
||||
Divider(),
|
||||
Stack(alignment: Alignment.bottomLeft, overflow: Overflow.visible, children: [
|
||||
FlatButton(
|
||||
Stack(alignment: Alignment.bottomLeft, children: [
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.all(0.0),
|
||||
shape: getShape(changeBloc, GoalsItem.weight),
|
||||
),
|
||||
child: Image.asset(
|
||||
"asset/image/WT_weight_loss.jpg",
|
||||
height: 180,
|
||||
),
|
||||
padding: EdgeInsets.all(0.0),
|
||||
shape: getShape(changeBloc, GoalsItem.weight),
|
||||
onPressed: () => {
|
||||
setState(() {
|
||||
selected = GoalsItem.muscle;
|
||||
@@ -110,16 +117,18 @@ class _CustomerGoalPage extends State<CustomerGoalPage> with Trans {
|
||||
}),
|
||||
InkWell(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate("Loose Weight"),
|
||||
AppLocalizations.of(context)!.translate("Loose Weight"),
|
||||
style: TextStyle(color: Colors.white, fontSize: 32, fontFamily: 'Arial', fontWeight: FontWeight.w900),
|
||||
),
|
||||
highlightColor: Colors.white,
|
||||
)
|
||||
]),
|
||||
Divider(),
|
||||
RaisedButton(
|
||||
color: Colors.orange,
|
||||
textColor: Colors.white,
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
onPrimary: Colors.white,
|
||||
primary: Colors.orange,
|
||||
),
|
||||
child: Text(fulldata ? t("Save") : t("Next")),
|
||||
onPressed: () => {
|
||||
//changingViewModel.saveCustomer(),
|
||||
@@ -137,7 +146,7 @@ class _CustomerGoalPage extends State<CustomerGoalPage> with Trans {
|
||||
}
|
||||
|
||||
dynamic getShape(CustomerChangeBloc customerBloc, String goal) {
|
||||
String selectedGoal = customerBloc.customerRepository.goal;
|
||||
String selectedGoal = customerBloc.customerRepository.goal!;
|
||||
dynamic returnCode = (selectedGoal == goal)
|
||||
? RoundedRectangleBorder(
|
||||
side: BorderSide(width: 4, color: Colors.red),
|
||||
|
||||
@@ -13,7 +13,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
|
||||
import 'package:toggle_switch/toggle_switch.dart';
|
||||
|
||||
@@ -26,7 +26,7 @@ class CustomerModifyPage extends StatelessWidget with Trans {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
dynamic arguments = ModalRoute.of(context).settings.arguments;
|
||||
dynamic arguments = ModalRoute.of(context)!.settings.arguments;
|
||||
if (arguments is HashMap && arguments['personal_data'] != null) {
|
||||
fulldata = arguments['personal_data'];
|
||||
}
|
||||
@@ -36,18 +36,21 @@ class CustomerModifyPage extends StatelessWidget with Trans {
|
||||
final accountBloc = BlocProvider.of<AccountBloc>(context);
|
||||
|
||||
return BlocProvider(
|
||||
create: (context) => CustomerChangeBloc(customerRepository: accountBloc.customerRepository, context: context)..add(CustomerLoad()),
|
||||
create: (context) => CustomerChangeBloc(customerRepository: accountBloc.customerRepository)..add(CustomerLoad()),
|
||||
child: Builder(builder: (context) {
|
||||
// ignore: close_sinks
|
||||
final customerBloc = BlocProvider.of<CustomerChangeBloc>(context);
|
||||
|
||||
PreferredSizeWidget _bar = AppBarMin(
|
||||
back: true,
|
||||
);
|
||||
if (!fulldata) {
|
||||
_bar = AppBarProgress(max: 25, min: 0);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: true,
|
||||
appBar: fulldata
|
||||
? AppBarMin(
|
||||
back: true,
|
||||
)
|
||||
: AppBarProgress(max: 25, min: 0),
|
||||
appBar: _bar,
|
||||
body: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
@@ -59,13 +62,8 @@ class CustomerModifyPage extends StatelessWidget with Trans {
|
||||
child: BlocConsumer<CustomerChangeBloc, CustomerChangeState>(
|
||||
listener: (context, state) {
|
||||
if (state is CustomerSaveError) {
|
||||
String message = t(state.message);
|
||||
if (message == null) {
|
||||
message = "";
|
||||
} else {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(message, style: TextStyle(color: Colors.white))));
|
||||
}
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
backgroundColor: Colors.orange, content: Text(t(state.message), style: TextStyle(color: Colors.white))));
|
||||
} else if (state is CustomerSaveSuccess) {
|
||||
if (fulldata) {
|
||||
Navigator.of(context).pop();
|
||||
@@ -113,13 +111,14 @@ class CustomerModifyPage extends StatelessWidget with Trans {
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 4.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.green[50], width: 0.4),
|
||||
borderSide: BorderSide(color: Colors.green[50]!, width: 0.4),
|
||||
),
|
||||
),
|
||||
initialValue: customerBloc.customerRepository.customer.email,
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
validator: (val) {
|
||||
return customerBloc.emailValidation(val);
|
||||
String? validator = customerBloc.emailValidation(val!);
|
||||
return validator == null ? null : t(validator);
|
||||
},
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
style: new TextStyle(fontSize: 16, color: Colors.indigo),
|
||||
@@ -145,13 +144,14 @@ class CustomerModifyPage extends StatelessWidget with Trans {
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 1.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.green[50], width: 0.4),
|
||||
borderSide: BorderSide(color: Colors.green[50]!, width: 0.4),
|
||||
),
|
||||
),
|
||||
initialValue: customerBloc.customerRepository.customer.password,
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
validator: (val) {
|
||||
return customerBloc.passwordValidation(val);
|
||||
String? validator = customerBloc.passwordValidation(val!);
|
||||
return validator == null ? null : t(validator);
|
||||
},
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
style: new TextStyle(fontSize: 16, color: Colors.indigo),
|
||||
@@ -170,7 +170,7 @@ class CustomerModifyPage extends StatelessWidget with Trans {
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 1.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.green[50], width: 0.4),
|
||||
borderSide: BorderSide(color: Colors.green[50]!, width: 0.4),
|
||||
),
|
||||
),
|
||||
initialValue: customerBloc.customerRepository.customer.name,
|
||||
@@ -195,7 +195,7 @@ class CustomerModifyPage extends StatelessWidget with Trans {
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 2.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.green[50], width: 0.4),
|
||||
borderSide: BorderSide(color: Colors.green[50]!, width: 0.4),
|
||||
),
|
||||
),
|
||||
initialValue: customerBloc.customerRepository.customer.firstname,
|
||||
@@ -220,7 +220,7 @@ class CustomerModifyPage extends StatelessWidget with Trans {
|
||||
NumberPickerWidget(
|
||||
minValue: 1930,
|
||||
maxValue: 2100,
|
||||
initalValue: customerBloc.year.toInt(),
|
||||
initalValue: customerBloc.year!.toInt(),
|
||||
unit: " ",
|
||||
color: Colors.indigo,
|
||||
onChange: (value) => {customerBloc.add(CustomerBirthYearChange(year: value.toInt()))}),
|
||||
@@ -258,7 +258,7 @@ class CustomerModifyPage extends StatelessWidget with Trans {
|
||||
maxValue: 230,
|
||||
initalValue: customerBloc.height.toInt(),
|
||||
unit: " ",
|
||||
color: Colors.indigo[300],
|
||||
color: Colors.indigo[300]!,
|
||||
onChange: (value) => {customerBloc.add(CustomerHeightChange(height: value.toInt()))}),
|
||||
SizedBox(width: 80),
|
||||
],
|
||||
@@ -279,7 +279,7 @@ class CustomerModifyPage extends StatelessWidget with Trans {
|
||||
},
|
||||
),
|
||||
Divider(),
|
||||
FlatButton(
|
||||
TextButton(
|
||||
onPressed: () => {customerBloc.add(CustomerSave())},
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
@@ -298,9 +298,4 @@ class CustomerModifyPage extends StatelessWidget with Trans {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showInSnackBar(String error) {
|
||||
_scaffoldKey.currentState
|
||||
.showSnackBar(SnackBar(backgroundColor: Colors.orange, content: Text(error, style: TextStyle(color: Colors.white))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class CustomerWelcomePage extends StatefulWidget {
|
||||
_CustomerWelcomePageState _state;
|
||||
late _CustomerWelcomePageState _state;
|
||||
|
||||
_CustomerWelcomePageState createState() {
|
||||
_state = _CustomerWelcomePageState();
|
||||
@@ -17,21 +17,6 @@ class _CustomerWelcomePageState extends State<CustomerWelcomePage> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBarMin(),
|
||||
/*
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
|
||||
Image.asset(
|
||||
'asset/image/WT_long_logo.png',
|
||||
fit: BoxFit.cover,
|
||||
height: 65.0,
|
||||
),
|
||||
],
|
||||
),
|
||||
*/
|
||||
//backgroundColor: Colors.transparent,
|
||||
//),
|
||||
body: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
@@ -48,10 +33,12 @@ class _CustomerWelcomePageState extends State<CustomerWelcomePage> {
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
RaisedButton(
|
||||
color: Colors.orange,
|
||||
textColor: Colors.white,
|
||||
child: InkWell(child: Text(AppLocalizations.of(context).translate("Next"))),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Colors.orange,
|
||||
onSurface: Colors.white,
|
||||
),
|
||||
child: InkWell(child: Text(AppLocalizations.of(context)!.translate("Next"))),
|
||||
onPressed: () => {Navigator.of(context).pop(), Navigator.of(context).pushNamed("home")},
|
||||
)
|
||||
],
|
||||
|
||||
+32
-33
@@ -1,6 +1,6 @@
|
||||
import 'dart:collection';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:aitrainer_app/bloc/result/result_bloc.dart';
|
||||
import 'package:aitrainer_app/util/app_language.dart';
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
@@ -14,26 +14,25 @@ import 'package:aitrainer_app/widgets/app_bar_min.dart';
|
||||
import 'package:aitrainer_app/widgets/bottom_nav.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:aitrainer_app/model/result.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class EvaluationPage extends StatelessWidget with Trans {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
LinkedHashMap arguments = ModalRoute.of(context).settings.arguments;
|
||||
dynamic arguments = ModalRoute.of(context)!.settings.arguments;
|
||||
ExerciseRepository exerciseRepository;
|
||||
|
||||
if (arguments != null) {
|
||||
if (arguments is LinkedHashMap) {
|
||||
exerciseRepository = arguments['exerciseRepository'];
|
||||
} else {
|
||||
exerciseRepository = ExerciseRepository();
|
||||
}
|
||||
|
||||
ResultType resultType = ResultType.none;
|
||||
String imageUrl = "";
|
||||
if (Cache().userLoggedIn.sex == "m") {
|
||||
if (Cache().userLoggedIn!.sex == "m") {
|
||||
resultType = ResultType.man;
|
||||
imageUrl = 'asset/image/WT_Results_for_men.jpg';
|
||||
} else {
|
||||
@@ -42,16 +41,16 @@ class EvaluationPage extends StatelessWidget with Trans {
|
||||
}
|
||||
|
||||
if (arguments['past'] != null && arguments['past'] == true) {
|
||||
Exercise exercise = arguments['exercise'];
|
||||
Exercise? exercise = arguments['exercise'];
|
||||
if (exercise != null) {
|
||||
ExerciseType exerciseType = exerciseRepository.getExerciseTypeById(exercise.exerciseTypeId);
|
||||
ExerciseType exerciseType = exerciseRepository.getExerciseTypeById(exercise.exerciseTypeId!) as ExerciseType;
|
||||
exerciseRepository.exerciseType = exerciseType;
|
||||
exerciseRepository.exercise = exercise;
|
||||
String exerciseDate = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd);
|
||||
exerciseRepository.getSameExercise(exercise.exerciseTypeId, exerciseDate);
|
||||
String exerciseDate = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd!);
|
||||
exerciseRepository.getSameExercise(exercise.exerciseTypeId!, exerciseDate);
|
||||
}
|
||||
}
|
||||
if (exerciseRepository.exerciseType.getAbility().equalsTo(ExerciseAbility.running)) {
|
||||
if (exerciseRepository.exerciseType!.getAbility().equalsTo(ExerciseAbility.running)) {
|
||||
resultType = ResultType.running;
|
||||
imageUrl = 'asset/image/WT_Results_for_runners.jpg';
|
||||
}
|
||||
@@ -79,7 +78,7 @@ class EvaluationPage extends StatelessWidget with Trans {
|
||||
context: context),
|
||||
child: BlocConsumer<ResultBloc, ResultState>(listener: (context, state) {
|
||||
if (state is ResultError) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(state.error, style: TextStyle(color: Colors.white))));
|
||||
}
|
||||
}, builder: (context, state) {
|
||||
@@ -97,8 +96,8 @@ class EvaluationPage extends StatelessWidget with Trans {
|
||||
|
||||
Widget getEvaluationWidgets(ResultBloc resultBloc) {
|
||||
String exerciseName = AppLanguage().appLocal == Locale("en")
|
||||
? resultBloc.exerciseRepository.exerciseType.name
|
||||
: resultBloc.exerciseRepository.exerciseType.nameTranslation;
|
||||
? resultBloc.exerciseRepository.exerciseType!.name
|
||||
: resultBloc.exerciseRepository.exerciseType!.nameTranslation;
|
||||
return Container(
|
||||
padding: EdgeInsets.only(left: 10, right: 10),
|
||||
child: CustomScrollView(scrollDirection: Axis.vertical, slivers: [
|
||||
@@ -134,7 +133,7 @@ class EvaluationPage extends StatelessWidget with Trans {
|
||||
),
|
||||
SliverList(
|
||||
delegate: SliverChildListDelegate([
|
||||
Text(DateFormat('y-M-d HH:mm', AppLanguage().appLocal.toString()).format(resultBloc.exerciseRepository.start),
|
||||
Text(DateFormat('y-M-d HH:mm', AppLanguage().appLocal.toString()).format(resultBloc.exerciseRepository.start!),
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 2,
|
||||
softWrap: true,
|
||||
@@ -188,7 +187,7 @@ class EvaluationPage extends StatelessWidget with Trans {
|
||||
}
|
||||
|
||||
Widget getSuggestionTitle(ResultBloc resultBloc) {
|
||||
if (resultBloc.exerciseRepository.exerciseType.unitQuantityUnit != null) {
|
||||
if (resultBloc.exerciseRepository.exerciseType!.unitQuantityUnit != null) {
|
||||
return SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
@@ -254,7 +253,7 @@ class EvaluationPage extends StatelessWidget with Trans {
|
||||
}
|
||||
|
||||
Widget getSuggestion(ResultBloc resultBloc) {
|
||||
if (resultBloc.exerciseRepository.exerciseType.unitQuantityUnit != null) {
|
||||
if (resultBloc.exerciseRepository.exerciseType!.unitQuantityUnit != null) {
|
||||
return SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
@@ -282,9 +281,9 @@ class EvaluationPage extends StatelessWidget with Trans {
|
||||
}
|
||||
|
||||
Widget getSuggestionWidget(ResultBloc resultBloc, String title, String picture, String repeats, double percent, String restTime) {
|
||||
String unitQuantityUnit = resultBloc.exerciseRepository.exerciseType.unitQuantityUnit == null
|
||||
String unitQuantityUnit = resultBloc.exerciseRepository.exerciseType!.unitQuantityUnit == null
|
||||
? ""
|
||||
: resultBloc.exerciseRepository.exerciseType.unitQuantityUnit;
|
||||
: resultBloc.exerciseRepository.exerciseType!.unitQuantityUnit!;
|
||||
return Column(
|
||||
children: [
|
||||
Text(t(title),
|
||||
@@ -399,19 +398,19 @@ class EvaluationPage extends StatelessWidget with Trans {
|
||||
|
||||
Widget getSummary(ResultBloc bloc) {
|
||||
int index = 0;
|
||||
List<Text> resultList = List();
|
||||
List<Text> resultList = [];
|
||||
|
||||
bloc.exerciseRepository.actualExerciseList.forEach((actual) {
|
||||
bloc.exerciseRepository.actualExerciseList!.forEach((actual) {
|
||||
//final String unit = t(bloc.exerciseRepository.exerciseType.unit);
|
||||
final String unit = bloc.exerciseRepository.exerciseType.unitQuantityUnit != null
|
||||
? bloc.exerciseRepository.exerciseType.unitQuantityUnit
|
||||
: bloc.exerciseRepository.exerciseType.unit;
|
||||
final String unit = bloc.exerciseRepository.exerciseType!.unitQuantityUnit != null
|
||||
? bloc.exerciseRepository.exerciseType!.unitQuantityUnit!
|
||||
: bloc.exerciseRepository.exerciseType!.unit;
|
||||
String exerciseElement = "";
|
||||
String exerciseRepeats = actual.quantity.toStringAsFixed(0);
|
||||
if (bloc.exerciseRepository.exerciseType.unit == "second") {
|
||||
exerciseRepeats = bloc.printTime(actual.quantity);
|
||||
String exerciseRepeats = actual.quantity!.toStringAsFixed(0);
|
||||
if (bloc.exerciseRepository.exerciseType!.unit == "second") {
|
||||
exerciseRepeats = bloc.printTime(actual.quantity!);
|
||||
}
|
||||
final String exerciseUnitQuantity = actual.unitQuantity != null ? "x" + actual.unitQuantity.toStringAsFixed(0) : "";
|
||||
final String exerciseUnitQuantity = actual.unitQuantity != null ? "x" + actual.unitQuantity!.toStringAsFixed(0) : "";
|
||||
if (index == 0) {
|
||||
exerciseElement = t("Test") + ": ";
|
||||
} else if (index == 1) {
|
||||
@@ -471,7 +470,7 @@ class EvaluationPage extends StatelessWidget with Trans {
|
||||
}
|
||||
|
||||
List<Widget> getResultData(ResultBloc resultBloc) {
|
||||
List<Widget> data = List();
|
||||
List<Widget> data = [];
|
||||
|
||||
resultBloc.resultRepository.getResults().forEach((element) {
|
||||
data.add(getResultWidget(element));
|
||||
@@ -480,8 +479,8 @@ class EvaluationPage extends StatelessWidget with Trans {
|
||||
}
|
||||
|
||||
Widget getResultWidget(ResultExt element) {
|
||||
bool hasHardware = Cache().hasHardware;
|
||||
bool blur = (!hasHardware && element.isHardware());
|
||||
bool? hasHardware = Cache().hasHardware;
|
||||
bool blur = (hasHardware != null && !hasHardware && element.isHardware()!);
|
||||
/* print("Blur: " +
|
||||
element.getDescription() +
|
||||
": " +
|
||||
@@ -518,7 +517,7 @@ class EvaluationPage extends StatelessWidget with Trans {
|
||||
style: GoogleFonts.archivoBlack(fontSize: 28, color: blur ? Colors.white12 : Colors.white),
|
||||
),
|
||||
Text(
|
||||
t(element.getDescription()),
|
||||
t(element.getDescription()!),
|
||||
style: GoogleFonts.archivoBlack(fontSize: 14, color: blur ? Colors.white12 : Colors.white),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
|
||||
@@ -14,9 +14,8 @@ import 'package:aitrainer_app/widgets/timer_widget.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:google_fonts/google_fonts.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
|
||||
class ExerciseControlPage extends StatefulWidget {
|
||||
_ExerciseControlPage createState() => _ExerciseControlPage();
|
||||
@@ -34,7 +33,7 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
LinkedHashMap arguments = ModalRoute.of(context).settings.arguments;
|
||||
LinkedHashMap arguments = ModalRoute.of(context)!.settings.arguments as LinkedHashMap;
|
||||
final ExerciseRepository exerciseRepository = arguments['exerciseRepository'];
|
||||
final bool readonly = arguments['readonly'];
|
||||
setContext(context);
|
||||
@@ -46,7 +45,7 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
|
||||
..add(ExerciseControlLoad()),
|
||||
child: BlocConsumer<ExerciseControlBloc, ExerciseControlState>(listener: (context, state) {
|
||||
if (state is ExerciseControlError) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
}
|
||||
}, builder: (context, state) {
|
||||
@@ -67,8 +66,8 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
|
||||
Form getControlForm(ExerciseControlBloc exerciseBloc, TimerBloc timerBloc) {
|
||||
this.offset = exerciseBloc.scrollOffset;
|
||||
String exerciseName = AppLanguage().appLocal == Locale("en")
|
||||
? exerciseBloc.exerciseRepository.exerciseType.name
|
||||
: exerciseBloc.exerciseRepository.exerciseType.nameTranslation;
|
||||
? exerciseBloc.exerciseRepository.exerciseType!.name
|
||||
: exerciseBloc.exerciseRepository.exerciseType!.nameTranslation;
|
||||
return Form(
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: true,
|
||||
@@ -79,7 +78,7 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: Cache().userLoggedIn.sex == "m"
|
||||
image: Cache().userLoggedIn!.sex == "m"
|
||||
? AssetImage("asset/image/WT_Results_for_men.jpg")
|
||||
: AssetImage("asset/image/WT_Results_for_female.jpg"),
|
||||
fit: BoxFit.cover,
|
||||
@@ -156,7 +155,7 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
|
||||
" " +
|
||||
exerciseBloc.initialRM.toStringAsFixed(0) +
|
||||
" " +
|
||||
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit,
|
||||
exerciseBloc.exerciseRepository.exerciseType!.unitQuantityUnit!,
|
||||
style: GoogleFonts.inter(
|
||||
color: Colors.yellow[300],
|
||||
fontSize: 18,
|
||||
@@ -242,7 +241,7 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
|
||||
}
|
||||
|
||||
List<Widget> getButton(int step, ExerciseControlBloc exerciseBloc) {
|
||||
List<Widget> widgets = List();
|
||||
List<Widget> widgets = [];
|
||||
if (step < exerciseBloc.step) {
|
||||
widgets.add(Icon(
|
||||
CustomIcon.check_circle,
|
||||
@@ -289,8 +288,9 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
|
||||
children: [
|
||||
TextSpan(text: t("Please repeat with ")),
|
||||
TextSpan(
|
||||
text:
|
||||
exerciseBloc.unitQuantity.toStringAsFixed(0) + " " + exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit,
|
||||
text: exerciseBloc.unitQuantity.toStringAsFixed(0) +
|
||||
" " +
|
||||
exerciseBloc.exerciseRepository.exerciseType!.unitQuantityUnit!,
|
||||
style: GoogleFonts.inter(
|
||||
decoration: TextDecoration.underline,
|
||||
fontSize: 16,
|
||||
@@ -320,12 +320,14 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
|
||||
maxValue: 200,
|
||||
initalValue: exerciseBloc.quantity.round(),
|
||||
unit: t("reps"),
|
||||
color: Colors.yellow[50],
|
||||
color: Colors.yellow[50]!,
|
||||
onChange: (value) => {exerciseBloc.add(ExerciseControlQuantityChange(quantity: value.toDouble(), step: step))}),
|
||||
FlatButton(
|
||||
padding: EdgeInsets.all(0),
|
||||
textColor: Colors.white,
|
||||
focusColor: Colors.blueAccent,
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.all(0),
|
||||
primary: Colors.white,
|
||||
onSurface: Colors.blueAccent,
|
||||
),
|
||||
onPressed: () => {
|
||||
exerciseBloc.add(ExerciseControlSubmit(step: step)),
|
||||
if (step == 3)
|
||||
@@ -364,13 +366,13 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
|
||||
class UnitQuantityControl extends StatefulWidget {
|
||||
final ExerciseControlBloc exerciseBloc;
|
||||
final int step;
|
||||
const UnitQuantityControl({this.exerciseBloc, this.step});
|
||||
const UnitQuantityControl({required this.exerciseBloc, required this.step});
|
||||
@override
|
||||
_UnitQuantityControlState createState() => _UnitQuantityControlState();
|
||||
}
|
||||
|
||||
class _UnitQuantityControlState extends State<UnitQuantityControl> with Trans {
|
||||
double changedValue;
|
||||
late double changedValue;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
changedValue = widget.exerciseBloc.unitQuantity;
|
||||
@@ -428,7 +430,7 @@ class _UnitQuantityControlState extends State<UnitQuantityControl> with Trans {
|
||||
maxValue: (widget.exerciseBloc.unitQuantity + 10).round(),
|
||||
initalValue: widget.exerciseBloc.unitQuantity.round(),
|
||||
unit: t("kg"),
|
||||
color: Colors.yellow[50],
|
||||
color: Colors.yellow[50]!,
|
||||
onChange: (value) => {changedValue = value}),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
|
||||
@@ -21,21 +21,21 @@ class ExerciseExecutePage extends StatefulWidget {
|
||||
class _ExerciseExecutePage extends State<ExerciseExecutePage> with Trans {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
// ignore: close_sinks
|
||||
ExerciseExecutePlanBloc bloc;
|
||||
late ExerciseExecutePlanBloc bloc;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
/// We require the initializers to run after the loading screen is rendered
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
SchedulerBinding.instance!.addPostFrameCallback((_) {
|
||||
BlocProvider.of<ExerciseExecutePlanBloc>(context).add(ExerciseByPlanLoad());
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
LinkedHashMap arguments = ModalRoute.of(context).settings.arguments;
|
||||
LinkedHashMap arguments = ModalRoute.of(context)!.settings.arguments as LinkedHashMap;
|
||||
final int customerId = arguments['customerId'];
|
||||
bloc = BlocProvider.of<ExerciseExecutePlanBloc>(context);
|
||||
bloc.customerId = customerId;
|
||||
@@ -48,7 +48,7 @@ class _ExerciseExecutePage extends State<ExerciseExecutePage> with Trans {
|
||||
padding: EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: customerId == Cache().userLoggedIn.customerId
|
||||
image: customerId == Cache().userLoggedIn!.customerId
|
||||
? AssetImage('asset/image/WT_black_background.jpg')
|
||||
: AssetImage('asset/image/WT_light_background.jpg'),
|
||||
fit: BoxFit.cover,
|
||||
@@ -58,7 +58,7 @@ class _ExerciseExecutePage extends State<ExerciseExecutePage> with Trans {
|
||||
child: BlocConsumer<ExerciseExecutePlanBloc, ExerciseExecutePlanState>(listener: (context, state) {
|
||||
if (state is ExerciseByPlanError) {
|
||||
//LoadingDialog.hide(context);
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
state.message,
|
||||
),
|
||||
@@ -89,7 +89,7 @@ class _ExerciseExecutePage extends State<ExerciseExecutePage> with Trans {
|
||||
}
|
||||
|
||||
List<Widget> nodeExercisePlan(ExerciseExecutePlanBloc bloc) {
|
||||
List<Widget> exerciseTypes = List();
|
||||
List<Widget> exerciseTypes = [];
|
||||
Card explanation = Card(
|
||||
color: Colors.white38,
|
||||
child: Container(
|
||||
@@ -145,7 +145,7 @@ class _ExerciseExecutePage extends State<ExerciseExecutePage> with Trans {
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
final LinkedHashMap args = LinkedHashMap();
|
||||
args['customerId'] = Cache().userLoggedIn.customerId;
|
||||
args['customerId'] = Cache().userLoggedIn!.customerId;
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pushNamed('exercisePlanCustomPage', arguments: args);
|
||||
},
|
||||
@@ -169,7 +169,7 @@ class _ExerciseExecutePage extends State<ExerciseExecutePage> with Trans {
|
||||
}
|
||||
|
||||
List<Widget> _getChildList(List<WorkoutMenuTree> listWorkoutTree, ExerciseExecutePlanBloc bloc) {
|
||||
List<Widget> list = List();
|
||||
List<Widget> list = [];
|
||||
listWorkoutTree.forEach((element) {
|
||||
if (element.selected) {
|
||||
list.add(TreeViewChild(
|
||||
|
||||
@@ -12,9 +12,8 @@ import 'package:aitrainer_app/widgets/number_picker.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:google_fonts/google_fonts.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
|
||||
class ExerciseExecutePlanAddPage extends StatefulWidget {
|
||||
_ExerciseExecuteAddPage createState() => _ExerciseExecuteAddPage();
|
||||
@@ -32,7 +31,7 @@ class _ExerciseExecuteAddPage extends State<ExerciseExecutePlanAddPage> with Tra
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
LinkedHashMap arguments = ModalRoute.of(context).settings.arguments;
|
||||
LinkedHashMap arguments = ModalRoute.of(context)!.settings.arguments as LinkedHashMap;
|
||||
// ignore: close_sinks
|
||||
final ExerciseExecutePlanBloc planBloc = arguments['blocExerciseByPlan'];
|
||||
final int customerId = arguments['customerId'];
|
||||
@@ -49,7 +48,7 @@ class _ExerciseExecuteAddPage extends State<ExerciseExecutePlanAddPage> with Tra
|
||||
planBloc: planBloc),
|
||||
child: BlocConsumer<ExerciseExecutePlanAddBloc, ExerciseExecutePlanAddState>(listener: (context, state) {
|
||||
if (state is ExerciseExecutePlanAddError) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
}
|
||||
}, builder: (context, state) {
|
||||
@@ -70,8 +69,8 @@ class _ExerciseExecuteAddPage extends State<ExerciseExecutePlanAddPage> with Tra
|
||||
|
||||
Form getControlForm(ExerciseExecutePlanAddBloc exerciseBloc) {
|
||||
String exerciseName = AppLanguage().appLocal == Locale("en")
|
||||
? exerciseBloc.exerciseRepository.exerciseType.name
|
||||
: exerciseBloc.exerciseRepository.exerciseType.nameTranslation;
|
||||
? exerciseBloc.exerciseRepository.exerciseType!.name
|
||||
: exerciseBloc.exerciseRepository.exerciseType!.nameTranslation;
|
||||
|
||||
return Form(
|
||||
child: Scaffold(
|
||||
@@ -136,7 +135,7 @@ class _ExerciseExecuteAddPage extends State<ExerciseExecutePlanAddPage> with Tra
|
||||
}
|
||||
|
||||
List<Column> repeatExercises(ExerciseExecutePlanAddBloc exerciseBloc) {
|
||||
List<Column> listColumns = List<Column>();
|
||||
List<Column> listColumns = [];
|
||||
for (int i = 0; i < exerciseBloc.countSteps; i++) {
|
||||
Column col = Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
@@ -181,29 +180,31 @@ class _ExerciseExecuteAddPage extends State<ExerciseExecutePlanAddPage> with Tra
|
||||
color: Colors.transparent,
|
||||
),
|
||||
Row(mainAxisAlignment: MainAxisAlignment.start, children: [
|
||||
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit == null
|
||||
exerciseBloc.exerciseRepository.exerciseType!.unitQuantityUnit == null
|
||||
? Offstage()
|
||||
: NumberPickerWidget(
|
||||
minValue: 0,
|
||||
maxValue: 1000,
|
||||
fontSize: 16,
|
||||
initalValue: exerciseBloc.unitQuantity.toInt(),
|
||||
unit: t(exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit),
|
||||
color: Colors.yellow[50],
|
||||
unit: t(exerciseBloc.exerciseRepository.exerciseType!.unitQuantityUnit!),
|
||||
color: Colors.yellow[50]!,
|
||||
onChange: (value) => {exerciseBloc.add(ExerciseExecutePlanAddChangeUnitQuantity(quantity: value.toDouble()))}),
|
||||
NumberPickerWidget(
|
||||
minValue: 0,
|
||||
maxValue: 200,
|
||||
fontSize: 16,
|
||||
initalValue: exerciseBloc.quantity.toInt(),
|
||||
unit: t(exerciseBloc.exerciseRepository.exerciseType.unit), //t("repeat"),
|
||||
color: Colors.yellow[50],
|
||||
unit: t(exerciseBloc.exerciseRepository.exerciseType!.unit), //t("repeat"),
|
||||
color: Colors.yellow[50]!,
|
||||
onChange: (value) => {exerciseBloc.add(ExerciseExecutePlanAddChangeQuantity(quantity: value.toDouble()))}),
|
||||
]),
|
||||
FlatButton(
|
||||
padding: EdgeInsets.all(0),
|
||||
textColor: Colors.white,
|
||||
focusColor: Colors.blueAccent,
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.all(0),
|
||||
primary: Colors.white,
|
||||
onSurface: Colors.blueAccent,
|
||||
),
|
||||
onPressed: () => {
|
||||
if (exerciseBloc.step == i + 1) {exerciseBloc.add(ExerciseExecutePlanAddSubmit())},
|
||||
if (i + 1 == exerciseBloc.countSteps) {Navigator.of(context).pop()}
|
||||
@@ -260,7 +261,7 @@ class _ExerciseExecuteAddPage extends State<ExerciseExecutePlanAddPage> with Tra
|
||||
}
|
||||
|
||||
List<Widget> getButton(int step, ExerciseExecutePlanAddBloc exerciseBloc) {
|
||||
List<Widget> widgets = List();
|
||||
List<Widget> widgets = [];
|
||||
if (step < exerciseBloc.step) {
|
||||
widgets.add(Icon(
|
||||
CustomIcon.check_circle,
|
||||
|
||||
@@ -17,7 +17,7 @@ import 'package:aitrainer_app/util/common.dart';
|
||||
import 'package:aitrainer_app/util/trans.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:aitrainer_app/widgets/treeview_parent_widget.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
|
||||
class ExerciseLogPage extends StatefulWidget {
|
||||
@override
|
||||
@@ -27,7 +27,7 @@ class ExerciseLogPage extends StatefulWidget {
|
||||
class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
LinkedHashMap arguments = ModalRoute.of(context).settings.arguments;
|
||||
LinkedHashMap arguments = ModalRoute.of(context)!.settings.arguments as LinkedHashMap;
|
||||
final int customerId = arguments['customerId'];
|
||||
setContext(context);
|
||||
|
||||
@@ -35,7 +35,7 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
|
||||
create: (context) => ExerciseLogBloc(exerciseRepository: ExerciseRepository())..add(ExerciseLogLoad()),
|
||||
child: BlocConsumer<ExerciseLogBloc, ExerciseLogState>(listener: (context, state) {
|
||||
if (state is ExerciseLogError) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
}
|
||||
}, builder: (context, state) {
|
||||
@@ -57,7 +57,7 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
|
||||
padding: EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: customerId == Cache().userLoggedIn.customerId
|
||||
image: customerId == Cache().userLoggedIn!.customerId
|
||||
? AssetImage('asset/image/WT_black_background.jpg')
|
||||
: AssetImage('asset/image/WT_light_background.jpg'),
|
||||
fit: BoxFit.cover,
|
||||
@@ -80,15 +80,15 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
|
||||
List<Widget> _getTreeChildren(ExerciseLogBloc exerciseLogBloc, int customerId) {
|
||||
final ExerciseRepository exerciseRepository = exerciseLogBloc.exerciseRepository;
|
||||
|
||||
if (customerId == Cache().userLoggedIn.customerId) {
|
||||
if (customerId == Cache().userLoggedIn!.customerId) {
|
||||
exerciseRepository.exerciseList = exerciseRepository.getExerciseList();
|
||||
} else if (Cache().getTrainee() != null && customerId == Cache().getTrainee().customerId) {
|
||||
} else if (Cache().getTrainee() != null && customerId == Cache().getTrainee()!.customerId) {
|
||||
exerciseRepository.exerciseList = exerciseRepository.getExerciseListTrainee();
|
||||
}
|
||||
//print("ExerciseList ${exerciseRepository.exerciseList}");
|
||||
exerciseRepository.sortByDate();
|
||||
|
||||
List<Widget> listWidget = List();
|
||||
List<Widget> listWidget = [];
|
||||
|
||||
Card explanation = Card(
|
||||
color: Colors.white60,
|
||||
@@ -121,10 +121,10 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
|
||||
)));
|
||||
listWidget.add(explanation);
|
||||
|
||||
List<Exercise> listExercises = List();
|
||||
List<Exercise> listExercises = [];
|
||||
String origDate = "";
|
||||
exerciseRepository.exerciseLogList.forEach((exercise) {
|
||||
String exerciseDate = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd);
|
||||
exerciseRepository.exerciseLogList!.forEach((exercise) {
|
||||
String exerciseDate = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd!);
|
||||
|
||||
if (origDate != exerciseDate) {
|
||||
if (origDate.length == 0) {
|
||||
@@ -138,7 +138,7 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
|
||||
parent: TreeviewParentWidget(text: origDate),
|
||||
children: _getChildList(listExercises, exerciseRepository, exerciseLogBloc),
|
||||
)));
|
||||
listExercises = List();
|
||||
listExercises = [];
|
||||
listExercises.add(exercise);
|
||||
origDate = exerciseDate;
|
||||
}
|
||||
@@ -162,12 +162,12 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
|
||||
}
|
||||
|
||||
List<Widget> _getChildList(List<Exercise> listExercises, ExerciseRepository exerciseRepository, ExerciseLogBloc exerciseLogBloc) {
|
||||
List<Widget> list = List();
|
||||
List<Widget> list = [];
|
||||
bool isEnglish = AppLanguage().appLocal == Locale('en');
|
||||
|
||||
listExercises.forEach((exercise) {
|
||||
ExerciseType exerciseType = exerciseRepository.getExerciseTypeById(exercise.exerciseTypeId);
|
||||
String exerciseName = isEnglish ? exerciseType.name : exerciseType.nameTranslation;
|
||||
ExerciseType? exerciseType = exerciseRepository.getExerciseTypeById(exercise.exerciseTypeId!);
|
||||
String exerciseName = isEnglish ? exerciseType!.name : exerciseType!.nameTranslation;
|
||||
|
||||
list.add(
|
||||
Card(
|
||||
@@ -193,7 +193,7 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
|
||||
fit: FlexFit.tight,
|
||||
flex: 20,
|
||||
child: Text(
|
||||
exercise.summary == null ? "" : exercise.summary,
|
||||
exercise.summary == null ? "" : exercise.summary!,
|
||||
style: TextStyle(fontSize: 12, color: Colors.blue[800]),
|
||||
)),
|
||||
IconButton(
|
||||
@@ -241,14 +241,14 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
|
||||
}
|
||||
|
||||
void confirmationDialog(ExerciseLogBloc bloc, Exercise exercise) {
|
||||
ExerciseType exerciseType = bloc.exerciseRepository.getExerciseTypeById(exercise.exerciseTypeId);
|
||||
String exerciseName = AppLanguage().appLocal == Locale("en") ? exerciseType.name : exerciseType.nameTranslation;
|
||||
ExerciseType? exerciseType = bloc.exerciseRepository.getExerciseTypeById(exercise.exerciseTypeId!);
|
||||
String exerciseName = AppLanguage().appLocal == Locale("en") ? exerciseType!.name : exerciseType!.nameTranslation;
|
||||
|
||||
String strDate = AppLanguage().appLocal == Locale("en")
|
||||
? "on the " + DateFormat(DateFormat.YEAR_MONTH_DAY, AppLanguage().appLocal.toString()).format(exercise.dateAdd.toUtc())
|
||||
: DateFormat(DateFormat.YEAR_MONTH_DAY, AppLanguage().appLocal.toString()).format(exercise.dateAdd.toUtc()) + "-n";
|
||||
? "on the " + DateFormat(DateFormat.YEAR_MONTH_DAY, AppLanguage().appLocal.toString()).format(exercise.dateAdd!.toUtc())
|
||||
: DateFormat(DateFormat.YEAR_MONTH_DAY, AppLanguage().appLocal.toString()).format(exercise.dateAdd!.toUtc()) + "-n";
|
||||
|
||||
final String unitQuantity = exercise.unitQuantity == null ? "" : "x" + exercise.unitQuantity.toStringAsFixed(0);
|
||||
final String unitQuantity = exercise.unitQuantity == null ? "" : "x" + exercise.unitQuantity!.toStringAsFixed(0);
|
||||
|
||||
showCupertinoDialog(
|
||||
useRootNavigator: true,
|
||||
@@ -263,7 +263,7 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
|
||||
style: (TextStyle(color: Colors.blue)),
|
||||
),
|
||||
Text(
|
||||
exercise.quantity.toStringAsFixed(0) + unitQuantity + " ",
|
||||
exercise.quantity!.toStringAsFixed(0) + unitQuantity + " ",
|
||||
//+
|
||||
//exerciseType.unitQuantityUnit == null
|
||||
// ? ""
|
||||
@@ -276,11 +276,11 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
|
||||
),
|
||||
]),
|
||||
actions: [
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text(t("No")),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text(t("Yes")),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
|
||||
@@ -20,9 +20,8 @@ import 'package:aitrainer_app/widgets/size_widget.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:google_fonts/google_fonts.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
|
||||
class ExerciseNewPage extends StatefulWidget {
|
||||
_ExerciseNewPageState createState() => _ExerciseNewPageState();
|
||||
@@ -31,7 +30,7 @@ class ExerciseNewPage extends StatefulWidget {
|
||||
class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans, Logging {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ExerciseType exerciseType = ModalRoute.of(context).settings.arguments;
|
||||
final ExerciseType exerciseType = ModalRoute.of(context)!.settings.arguments as ExerciseType;
|
||||
// ignore: close_sinks
|
||||
final menuBloc = BlocProvider.of<MenuBloc>(context);
|
||||
setContext(context);
|
||||
@@ -46,23 +45,22 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans, Logging {
|
||||
child: BlocConsumer<ExerciseNewBloc, ExerciseNewState>(
|
||||
listener: (context, state) {
|
||||
if (state is ExerciseNewError) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
} else if (state is ExerciseNewSaved) {
|
||||
final LinkedHashMap args = LinkedHashMap();
|
||||
// ignore: close_sinks
|
||||
final TestSetExecuteBloc executeBloc = BlocProvider.of<TestSetExecuteBloc>(context);
|
||||
print("Execute paralell $exerciseType paralell: ${executeBloc.paralellTest}");
|
||||
final TestSetExecuteBloc? executeBloc = BlocProvider.of<TestSetExecuteBloc>(context);
|
||||
if (executeBloc != null && executeBloc.existsActivePlan() == true) {
|
||||
Navigator.of(context).pushNamed("testSetExecute");
|
||||
} else {
|
||||
// ignore: close_sinks
|
||||
final bloc = BlocProvider.of<ExerciseNewBloc>(context);
|
||||
|
||||
if (bloc.exerciseRepository.exerciseType.unitQuantityUnit == null) {
|
||||
if (bloc.exerciseRepository.exerciseType!.unitQuantityUnit == null) {
|
||||
args['exerciseRepository'] = bloc.exerciseRepository;
|
||||
Navigator.of(context).pushNamed('evaluationPage', arguments: args);
|
||||
} else if (menuBloc.ability.equalsTo(ExerciseAbility.oneRepMax)) {
|
||||
} else if (menuBloc.ability!.equalsTo(ExerciseAbility.oneRepMax)) {
|
||||
args['exerciseRepository'] = bloc.exerciseRepository;
|
||||
args['percent'] = 0.75;
|
||||
args['readonly'] = false;
|
||||
@@ -85,13 +83,13 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans, Logging {
|
||||
}
|
||||
|
||||
Widget getExerciseSaveWidget(ExerciseNewBloc exerciseBloc, ExerciseType exerciseType, MenuBloc menuBloc) {
|
||||
if (exerciseBloc.exerciseRepository.exerciseType.name == "BMR") {
|
||||
if (exerciseBloc.exerciseRepository.exerciseType!.name == "BMR") {
|
||||
return BMR(exerciseBloc: exerciseBloc);
|
||||
}
|
||||
if (exerciseBloc.exerciseRepository.exerciseType.name == "BMI") {
|
||||
if (exerciseBloc.exerciseRepository.exerciseType!.name == "BMI") {
|
||||
return BMI(exerciseBloc: exerciseBloc);
|
||||
}
|
||||
if (exerciseBloc.exerciseRepository.exerciseType.name == "Sizes") {
|
||||
if (exerciseBloc.exerciseRepository.exerciseType!.name == "Sizes") {
|
||||
return SizeWidget(exerciseBloc: exerciseBloc);
|
||||
}
|
||||
|
||||
@@ -107,12 +105,12 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans, Logging {
|
||||
),
|
||||
),
|
||||
child: ExerciseSave(
|
||||
exerciseName: exerciseBloc.exerciseRepository.exerciseType.nameTranslation,
|
||||
exerciseDescription: exerciseBloc.exerciseRepository.exerciseType.descriptionTranslation,
|
||||
exerciseName: exerciseBloc.exerciseRepository.exerciseType!.nameTranslation,
|
||||
exerciseDescription: exerciseBloc.exerciseRepository.exerciseType!.descriptionTranslation,
|
||||
exerciseTask: t("Please take a relative bigger weight and repeat 12-20 times"),
|
||||
unit: exerciseBloc.exerciseRepository.exerciseType.unit,
|
||||
unitQuantityUnit: exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit,
|
||||
hasUnitQuantity: exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit != null,
|
||||
unit: exerciseBloc.exerciseRepository.exerciseType!.unit,
|
||||
unitQuantityUnit: exerciseBloc.exerciseRepository.exerciseType!.unitQuantityUnit,
|
||||
hasUnitQuantity: exerciseBloc.exerciseRepository.exerciseType!.unitQuantityUnit != null,
|
||||
onQuantityChanged: (value) {
|
||||
exerciseBloc.add(ExerciseNewQuantityChange(quantity: double.parse(value)));
|
||||
},
|
||||
@@ -138,7 +136,7 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans, Logging {
|
||||
|
||||
void save(ExerciseNewBloc bloc, MenuBloc menuBloc) {
|
||||
// ignore: close_sinks
|
||||
final TestSetExecuteBloc executeBloc = BlocProvider.of<TestSetExecuteBloc>(context);
|
||||
final TestSetExecuteBloc? executeBloc = BlocProvider.of<TestSetExecuteBloc>(context);
|
||||
|
||||
if (executeBloc != null && executeBloc.existsActivePlan() == true) {
|
||||
confirmationOverride(bloc);
|
||||
@@ -148,19 +146,19 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans, Logging {
|
||||
}
|
||||
|
||||
void confirmationSave(ExerciseNewBloc bloc, MenuBloc menuBloc) {
|
||||
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();
|
||||
}
|
||||
|
||||
// ignore: close_sinks
|
||||
@@ -174,34 +172,34 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans, Logging {
|
||||
content: Column(children: [
|
||||
Divider(),
|
||||
Text(
|
||||
t("Exercise") + ": " + bloc.exerciseRepository.exerciseType.name,
|
||||
t("Exercise") + ": " + bloc.exerciseRepository.exerciseType!.name,
|
||||
style: (TextStyle(color: Colors.blue)),
|
||||
),
|
||||
Text(
|
||||
quantity + " " + t(bloc.exerciseRepository.exerciseType.unit),
|
||||
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)
|
||||
bloc.exerciseRepository.exerciseType!.unitQuantity == "1"
|
||||
? t("with") + " " + unitQuantity + " " + t(bloc.exerciseRepository.exerciseType!.unitQuantityUnit!)
|
||||
: "",
|
||||
style: (TextStyle(color: Colors.deepOrange)),
|
||||
),
|
||||
]),
|
||||
actions: [
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text(t("No")),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text(t("Yes")),
|
||||
onPressed: () {
|
||||
saveAll(bloc);
|
||||
if (executeBloc.existsActivePlan() == true) {
|
||||
executeBloc.add(TestSetExecuteExerciseFinished(
|
||||
exerciseTypeId: bloc.exerciseRepository.exerciseType.exerciseTypeId,
|
||||
quantity: bloc.exerciseRepository.exercise.quantity,
|
||||
unitQuantity: bloc.exerciseRepository.exercise.unitQuantity));
|
||||
exerciseTypeId: bloc.exerciseRepository.exerciseType!.exerciseTypeId,
|
||||
quantity: bloc.exerciseRepository.exercise!.quantity!,
|
||||
unitQuantity: bloc.exerciseRepository.exercise!.unitQuantity!));
|
||||
}
|
||||
Navigator.pop(context);
|
||||
},
|
||||
@@ -211,7 +209,7 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans, Logging {
|
||||
}
|
||||
|
||||
void saveAll(ExerciseNewBloc bloc) {
|
||||
bloc.exerciseRepository.setCustomer(Cache().userLoggedIn);
|
||||
bloc.exerciseRepository.setCustomer(Cache().userLoggedIn!);
|
||||
bloc.add(ExerciseNewSubmit());
|
||||
}
|
||||
|
||||
@@ -228,11 +226,11 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans, Logging {
|
||||
Text(t("Do you want to override it?"), style: GoogleFonts.archivoBlack(fontSize: 16, color: Colors.blue[800])),
|
||||
]),
|
||||
actions: [
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text(t("No"), style: GoogleFonts.archivoBlack(fontSize: 16, color: Colors.blue[800])),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text(t("Yes"), style: GoogleFonts.archivoBlack(fontSize: 16, color: Colors.red[800])),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
|
||||
@@ -10,12 +10,11 @@ import 'package:aitrainer_app/widgets/app_bar.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: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';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
|
||||
class ExercisePlanDetailAddPage extends StatefulWidget {
|
||||
@override
|
||||
@@ -92,7 +91,7 @@ class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> with T
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
LinkedHashMap args = ModalRoute.of(context).settings.arguments;
|
||||
LinkedHashMap args = ModalRoute.of(context)!.settings.arguments as LinkedHashMap;
|
||||
// ignore: close_sinks
|
||||
final ExercisePlanBloc planBloc = args['bloc'];
|
||||
final WorkoutMenuTree workoutMenuTree = args['workoutTreeItem'];
|
||||
@@ -106,7 +105,7 @@ class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> with T
|
||||
child: BlocConsumer<ExercisePlanCustomAddBloc, ExercisePlanCustomAddState>(
|
||||
listener: (context, state) {
|
||||
if (state is ExercisePlanCustomAddError) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
}
|
||||
},
|
||||
@@ -126,17 +125,20 @@ class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> with T
|
||||
|
||||
Widget getForm(ExercisePlanCustomAddBloc bloc, WorkoutMenuTree workoutMenuTree) {
|
||||
String exerciseName = "";
|
||||
if (bloc != null) {
|
||||
exerciseName = AppLanguage().appLocal == Locale("en")
|
||||
? bloc.exercisePlanRepository.getActualPlanDetail().exerciseType.name
|
||||
: bloc.exercisePlanRepository.getActualPlanDetail().exerciseType.nameTranslation;
|
||||
if (bloc.exercisePlanRepository.getActualPlanDetail() == null || bloc.serie == null) {
|
||||
return Offstage();
|
||||
}
|
||||
final bool weightVisible = bloc.exercisePlanRepository.getActualPlanDetail().exerciseType.unitQuantityUnit != null;
|
||||
String summary = bloc.serie.toStringAsFixed(0) + " x " + bloc.quantity.toStringAsFixed(0);
|
||||
|
||||
exerciseName = AppLanguage().appLocal == Locale("en")
|
||||
? bloc.exercisePlanRepository.getActualPlanDetail()!.exerciseType!.name
|
||||
: bloc.exercisePlanRepository.getActualPlanDetail()!.exerciseType!.nameTranslation;
|
||||
|
||||
final bool weightVisible = bloc.exercisePlanRepository.getActualPlanDetail()!.exerciseType!.unitQuantityUnit != null;
|
||||
String summary = bloc.serie!.toStringAsFixed(0) + " x " + bloc.quantity.toStringAsFixed(0);
|
||||
if (bloc.quantityUnit > 0) {
|
||||
summary += " x " + bloc.quantityUnit.toStringAsFixed(0) + " kg";
|
||||
}
|
||||
final String unit = bloc.exercisePlanRepository.getActualPlanDetail().exerciseType.unit;
|
||||
final String unit = bloc.exercisePlanRepository.getActualPlanDetail()!.exerciseType!.unit;
|
||||
return Form(
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: true,
|
||||
@@ -191,7 +193,7 @@ class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> with T
|
||||
borderSide: BorderSide(color: Colors.black26, width: 0.4),
|
||||
),
|
||||
),
|
||||
initialValue: bloc.serie.toStringAsFixed(0),
|
||||
initialValue: bloc.serie!.toStringAsFixed(0),
|
||||
focusNode: _nodeText1,
|
||||
keyboardType: TextInputType.number,
|
||||
style: GoogleFonts.archivoBlack(fontSize: 60, color: Colors.yellow[200]),
|
||||
@@ -209,7 +211,7 @@ class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> with T
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 4.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.green[50], width: 0.4),
|
||||
borderSide: BorderSide(color: Colors.green[50]!, width: 0.4),
|
||||
),
|
||||
),
|
||||
focusNode: _nodeText2,
|
||||
@@ -231,7 +233,7 @@ class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> with T
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 2.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.green[50], width: 0.4),
|
||||
borderSide: BorderSide(color: Colors.green[50]!, width: 0.4),
|
||||
),
|
||||
),
|
||||
focusNode: _nodeText3,
|
||||
@@ -251,7 +253,7 @@ class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> with T
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
FlatButton(
|
||||
TextButton(
|
||||
onPressed: () => {
|
||||
bloc.add(ExercisePlanCustomAddRemove()),
|
||||
Navigator.of(context).pop(),
|
||||
@@ -267,7 +269,7 @@ class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> with T
|
||||
],
|
||||
),
|
||||
),
|
||||
FlatButton(
|
||||
TextButton(
|
||||
onPressed: () => {
|
||||
bloc.add(ExercisePlanCustomAddSubmit()),
|
||||
Navigator.of(context).pop(),
|
||||
|
||||
@@ -14,7 +14,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
|
||||
class ExercisePlanCustomPage extends StatefulWidget {
|
||||
@override
|
||||
@@ -24,21 +24,21 @@ class ExercisePlanCustomPage extends StatefulWidget {
|
||||
class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> with Trans {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
// ignore: close_sinks
|
||||
ExercisePlanBloc bloc;
|
||||
late ExercisePlanBloc bloc;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
/// We require the initializers to run after the loading screen is rendered
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
SchedulerBinding.instance!.addPostFrameCallback((_) {
|
||||
BlocProvider.of<ExercisePlanBloc>(context).add(ExercisePlanLoad());
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
LinkedHashMap arguments = ModalRoute.of(context).settings.arguments;
|
||||
LinkedHashMap arguments = ModalRoute.of(context)!.settings.arguments as LinkedHashMap;
|
||||
final int customerId = arguments['customerId'];
|
||||
bloc = BlocProvider.of<ExercisePlanBloc>(context);
|
||||
bloc.customerId = customerId;
|
||||
@@ -51,7 +51,7 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> with Trans {
|
||||
padding: EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: customerId == Cache().userLoggedIn.customerId
|
||||
image: customerId == Cache().userLoggedIn!.customerId
|
||||
? AssetImage('asset/image/WT_black_background.jpg')
|
||||
: AssetImage('asset/image/WT_light_background.jpg'),
|
||||
fit: BoxFit.cover,
|
||||
@@ -60,7 +60,7 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> with Trans {
|
||||
),
|
||||
child: BlocConsumer<ExercisePlanBloc, ExercisePlanState>(listener: (context, state) {
|
||||
if (state is ExercisePlanError) {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
state.message,
|
||||
),
|
||||
@@ -88,7 +88,7 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> with Trans {
|
||||
}
|
||||
|
||||
List<Widget> _getTreeChildren(ExercisePlanBloc bloc) {
|
||||
List<Widget> exerciseTypes = List();
|
||||
List<Widget> exerciseTypes = [];
|
||||
|
||||
Card explanation = Card(
|
||||
color: Colors.white60,
|
||||
@@ -135,10 +135,10 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> with Trans {
|
||||
}
|
||||
|
||||
List<Widget> _getChildList(List<WorkoutMenuTree> listWorkoutTree, ExercisePlanBloc bloc) {
|
||||
List<Widget> list = List();
|
||||
List<Widget> list = [];
|
||||
listWorkoutTree.forEach((element) {
|
||||
final String unitQuantityUnit =
|
||||
element.exerciseType != null && element.exerciseType.unitQuantityUnit != null ? element.exerciseType.unitQuantityUnit : "";
|
||||
element.exerciseType != null && element.exerciseType!.unitQuantityUnit != null ? element.exerciseType!.unitQuantityUnit! : "";
|
||||
list.add(TreeViewChild(
|
||||
startExpanded: false,
|
||||
parent: Card(
|
||||
@@ -175,12 +175,12 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> with Trans {
|
||||
InkWell(
|
||||
child: !element.selected ||
|
||||
bloc.exercisePlanRepository.exercisePlanDetails[element.exerciseTypeId] == null ||
|
||||
bloc.exercisePlanRepository.exercisePlanDetails[element.exerciseTypeId].change == null
|
||||
bloc.exercisePlanRepository.exercisePlanDetails[element.exerciseTypeId]!.change == null
|
||||
? Text("")
|
||||
: Text(
|
||||
bloc.exercisePlanRepository.exercisePlanDetails[element.exerciseTypeId].repeats.toString() +
|
||||
bloc.exercisePlanRepository.exercisePlanDetails[element.exerciseTypeId]!.repeats.toString() +
|
||||
" x " +
|
||||
bloc.exercisePlanRepository.exercisePlanDetails[element.exerciseTypeId].weightEquation +
|
||||
bloc.exercisePlanRepository.exercisePlanDetails[element.exerciseTypeId]!.weightEquation! +
|
||||
unitQuantityUnit,
|
||||
style: TextStyle(fontSize: 9, color: Colors.green),
|
||||
),
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
import 'package:aitrainer_app/util/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';
|
||||
|
||||
class ExerciseTypeDescription extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ExerciseRepository exerciseRepository = ModalRoute.of(context).settings.arguments;
|
||||
String exerciseDescription = AppLanguage().appLocal == Locale("en")
|
||||
? exerciseRepository.exerciseType.description
|
||||
: exerciseRepository.exerciseType.descriptionTranslation;
|
||||
|
||||
String exerciseName =
|
||||
AppLanguage().appLocal == Locale("en") ? exerciseRepository.exerciseType.name : exerciseRepository.exerciseType.nameTranslation;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBarMin(
|
||||
back: true,
|
||||
),
|
||||
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.jpg'),
|
||||
fit: BoxFit.fill,
|
||||
alignment: Alignment.center,
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.only(left: 20, top: 20, right: 15),
|
||||
child: ListView(children: [
|
||||
Text(
|
||||
exerciseName,
|
||||
style: TextStyle(color: Colors.blueGrey, fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
InkWell(
|
||||
child: Text(
|
||||
exerciseDescription,
|
||||
style: TextStyle(color: Colors.blueGrey, fontSize: 18, fontWeight: FontWeight.normal),
|
||||
),
|
||||
),
|
||||
])));
|
||||
}
|
||||
}
|
||||
+13
-12
@@ -9,9 +9,8 @@ import 'package:aitrainer_app/widgets/dialog_long.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
|
||||
import '../library_keys.dart';
|
||||
|
||||
@@ -30,7 +29,7 @@ class LoginPage extends StatelessWidget with Trans {
|
||||
LoginBloc(userRepository: UserRepository(), accountBloc: accountBloc, context: context, isRegistration: false),
|
||||
child: BlocConsumer<LoginBloc, LoginState>(listener: (context, state) {
|
||||
if (state is LoginError) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(t(state.message), style: TextStyle(color: Colors.white))));
|
||||
} else if (state is LoginSuccess) {
|
||||
Navigator.of(context).pushNamed('home');
|
||||
@@ -71,11 +70,11 @@ class LoginPage extends StatelessWidget with Trans {
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(left: 20, right: 20),
|
||||
child: ListView(shrinkWrap: false, padding: EdgeInsets.only(top: 150.0), children: <Widget>[
|
||||
ListTile(title: Text(t("Login"), style: GoogleFonts.inter())),
|
||||
ListTile(title: Text(t("Login"), style: GoogleFonts.inter(fontSize: 24))),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Image.asset(
|
||||
'asset/image/button_fb.png',
|
||||
width: 60,
|
||||
@@ -83,7 +82,7 @@ class LoginPage extends StatelessWidget with Trans {
|
||||
onPressed: () => {loginBloc.add(LoginFB())},
|
||||
),
|
||||
Platform.isAndroid
|
||||
? FlatButton(
|
||||
? TextButton(
|
||||
child: Image.asset(
|
||||
'asset/image/button_google.png',
|
||||
width: 60,
|
||||
@@ -92,7 +91,7 @@ class LoginPage extends StatelessWidget with Trans {
|
||||
)
|
||||
: Offstage(),
|
||||
Platform.isIOS
|
||||
? FlatButton(
|
||||
? TextButton(
|
||||
child: Image.asset(
|
||||
'asset/image/button_apple.png',
|
||||
width: 60,
|
||||
@@ -115,13 +114,14 @@ class LoginPage extends StatelessWidget with Trans {
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 4.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.green[50], width: 0.4),
|
||||
borderSide: BorderSide(color: Colors.green[50]!, width: 0.4),
|
||||
),
|
||||
),
|
||||
initialValue: loginBloc.userRepository.user.email,
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
validator: (val) {
|
||||
return t(loginBloc.emailValidation(val));
|
||||
String? validationText = loginBloc.emailValidation(val!);
|
||||
return validationText == null ? null : t(validationText);
|
||||
},
|
||||
onChanged: (value) => loginBloc.add(LoginEmailChange(email: value)),
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
@@ -146,13 +146,14 @@ class LoginPage extends StatelessWidget with Trans {
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 1.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.green[50], width: 0.4),
|
||||
borderSide: BorderSide(color: Colors.green[50]!, width: 0.4),
|
||||
),
|
||||
),
|
||||
initialValue: loginBloc.userRepository.user.password,
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
validator: (val) {
|
||||
return t(loginBloc.passwordValidation(val));
|
||||
String? validationText = loginBloc.passwordValidation(val!);
|
||||
return validationText == null ? null : t(validationText);
|
||||
},
|
||||
onChanged: (value) => loginBloc.add(LoginPasswordChange(password: value)),
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
@@ -162,7 +163,7 @@ class LoginPage extends StatelessWidget with Trans {
|
||||
color: Colors.transparent,
|
||||
),
|
||||
Row(mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[
|
||||
FlatButton(
|
||||
TextButton(
|
||||
key: LibraryKeys.loginOKButton,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
|
||||
@@ -11,14 +11,14 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
class MenuPage extends StatefulWidget {
|
||||
int parent;
|
||||
|
||||
MenuPage({this.parent});
|
||||
MenuPage({required this.parent});
|
||||
|
||||
_MenuPage createState() => _MenuPage();
|
||||
}
|
||||
|
||||
class _MenuPage extends State<MenuPage> {
|
||||
// ignore: close_sinks
|
||||
MenuBloc menuBloc;
|
||||
late MenuBloc menuBloc;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -43,7 +43,7 @@ class _MenuPage extends State<MenuPage> {
|
||||
),
|
||||
child: BlocConsumer<MenuBloc, MenuState>(listener: (context, state) {
|
||||
if (state is MenuError) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
}
|
||||
}, builder: (context, state) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import 'package:aitrainer_app/util/trans.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:aitrainer_app/bloc/body_development/body_development_bloc.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
|
||||
class MyDevelopmentBodyPage extends StatefulWidget {
|
||||
@override
|
||||
@@ -21,7 +21,7 @@ class MyDevelopmentBodyPage extends StatefulWidget {
|
||||
class _MyDevelopmentBodyPage extends State<MyDevelopmentBodyPage> with Trans, Common {
|
||||
bool isStart = false;
|
||||
// ignore: close_sinks
|
||||
BodyDevelopmentBloc bloc;
|
||||
late BodyDevelopmentBloc bloc;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -48,7 +48,7 @@ class _MyDevelopmentBodyPage extends State<MyDevelopmentBodyPage> with Trans, Co
|
||||
}
|
||||
|
||||
/// We require the initializers to run after the loading screen is rendered
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
SchedulerBinding.instance!.addPostFrameCallback((_) {
|
||||
BlocProvider.of<BodyDevelopmentBloc>(context).add(BodyDevelopmentLoad());
|
||||
});
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class _MyDevelopmentBodyPage extends State<MyDevelopmentBodyPage> with Trans, Co
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bloc = BlocProvider.of<BodyDevelopmentBloc>(context);
|
||||
LinkedHashMap arguments = ModalRoute.of(context).settings.arguments;
|
||||
LinkedHashMap arguments = ModalRoute.of(context)!.settings.arguments as LinkedHashMap;
|
||||
final int customerId = arguments['customerId'];
|
||||
setContext(context);
|
||||
|
||||
@@ -66,7 +66,7 @@ class _MyDevelopmentBodyPage extends State<MyDevelopmentBodyPage> with Trans, Co
|
||||
padding: EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: customerId == Cache().userLoggedIn.customerId
|
||||
image: customerId == Cache().userLoggedIn!.customerId
|
||||
? AssetImage('asset/image/WT_light_background.jpg')
|
||||
: AssetImage('asset/image/WT_menu_dark.jpg'),
|
||||
fit: BoxFit.cover,
|
||||
|
||||
@@ -16,7 +16,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
|
||||
class MyDevelopmentMusclePage extends StatefulWidget {
|
||||
@override
|
||||
@@ -25,8 +24,8 @@ class MyDevelopmentMusclePage extends StatefulWidget {
|
||||
|
||||
class _MyDevelopmentMuscleState extends State<MyDevelopmentMusclePage> with Common, Trans {
|
||||
// ignore: close_sinks
|
||||
DevelopmentByMuscleBloc bloc;
|
||||
double cWidth;
|
||||
late DevelopmentByMuscleBloc bloc;
|
||||
late double cWidth;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -52,7 +51,7 @@ class _MyDevelopmentMuscleState extends State<MyDevelopmentMusclePage> with Comm
|
||||
}
|
||||
|
||||
/// We require the initializers to run after the loading screen is rendered
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
SchedulerBinding.instance!.addPostFrameCallback((_) {
|
||||
BlocProvider.of<DevelopmentByMuscleBloc>(context).add(DevelopmentByMuscleLoad());
|
||||
});
|
||||
}
|
||||
@@ -77,7 +76,7 @@ class _MyDevelopmentMuscleState extends State<MyDevelopmentMusclePage> with Comm
|
||||
child: BlocConsumer<DevelopmentByMuscleBloc, DevelopmentByMuscleState>(
|
||||
listener: (context, state) {
|
||||
if (state is DevelopmentByMuscleErrorState) {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
state.message,
|
||||
),
|
||||
@@ -102,7 +101,7 @@ class _MyDevelopmentMuscleState extends State<MyDevelopmentMusclePage> with Comm
|
||||
}
|
||||
|
||||
List<Widget> _getTreeChildren(SplayTreeMap tree, DevelopmentByMuscleBloc bloc) {
|
||||
List<Widget> exerciseTypes = List();
|
||||
List<Widget> exerciseTypes = [];
|
||||
|
||||
Card explanation = Card(
|
||||
color: Colors.white60,
|
||||
@@ -229,7 +228,7 @@ class _MyDevelopmentMuscleState extends State<MyDevelopmentMusclePage> with Comm
|
||||
return exerciseTypes;
|
||||
}
|
||||
|
||||
Widget _getExerciseWidget({@required String exerciseTypeName, bool noData = false}) {
|
||||
Widget _getExerciseWidget({required String exerciseTypeName, bool noData = false}) {
|
||||
return TreeviewParentWidget(
|
||||
text: exerciseTypeName,
|
||||
backgroundColor: !noData ? Colors.white38 : Colors.white12,
|
||||
@@ -238,7 +237,7 @@ class _MyDevelopmentMuscleState extends State<MyDevelopmentMusclePage> with Comm
|
||||
|
||||
LinkedHashMap<String, dynamic> _getChildList(List<WorkoutMenuTree> listWorkoutTree, DevelopmentByMuscleBloc bloc) {
|
||||
LinkedHashMap<String, dynamic> rc = LinkedHashMap();
|
||||
List<Widget> list = List();
|
||||
List<Widget> list = [];
|
||||
bool hasSummaryNoData = true;
|
||||
listWorkoutTree.forEach((element) {
|
||||
final bool hasNoData = (bloc.listChartData[element.exerciseTypeId] == null);
|
||||
@@ -257,7 +256,7 @@ class _MyDevelopmentMuscleState extends State<MyDevelopmentMusclePage> with Comm
|
||||
hasNoData
|
||||
? Container()
|
||||
: Text(
|
||||
element.exerciseType.nameTranslation,
|
||||
element.exerciseType!.nameTranslation,
|
||||
style: TextStyle(color: Colors.deepOrange),
|
||||
),
|
||||
hasNoData
|
||||
@@ -296,7 +295,7 @@ class _MyDevelopmentMuscleState extends State<MyDevelopmentMusclePage> with Comm
|
||||
getTextStyles: (_) => TextStyle(fontSize: 8, color: Colors.blueGrey),
|
||||
interval: bloc.listChartData[element.exerciseTypeId] == null
|
||||
? 100
|
||||
: bloc.listChartData[element.exerciseTypeId].interval,
|
||||
: bloc.listChartData[element.exerciseTypeId]!.interval,
|
||||
margin: 10,
|
||||
getTitles: (double value) {
|
||||
return value.toStringAsFixed(0) + unit;
|
||||
@@ -306,7 +305,7 @@ class _MyDevelopmentMuscleState extends State<MyDevelopmentMusclePage> with Comm
|
||||
),
|
||||
gridData: FlGridData(
|
||||
show: true,
|
||||
checkToShowHorizontalLine: (value) => value % bloc.listChartData[element.exerciseTypeId].gridInterval == 0,
|
||||
checkToShowHorizontalLine: (value) => value % bloc.listChartData[element.exerciseTypeId]!.gridInterval == 0,
|
||||
getDrawingHorizontalLine: (value) {
|
||||
return FlLine(
|
||||
color: Colors.black26,
|
||||
@@ -316,7 +315,7 @@ class _MyDevelopmentMuscleState extends State<MyDevelopmentMusclePage> with Comm
|
||||
),
|
||||
groupsSpace: 2,
|
||||
barGroups:
|
||||
bloc.listChartData[element.exerciseTypeId] == null ? [] : bloc.listChartData[element.exerciseTypeId].data,
|
||||
bloc.listChartData[element.exerciseTypeId] == null ? [] : bloc.listChartData[element.exerciseTypeId]!.data,
|
||||
),
|
||||
swapAnimationDuration: Duration(milliseconds: 1200),
|
||||
),
|
||||
|
||||
@@ -89,7 +89,7 @@ class _MyDevelopmentPage extends State<MyDevelopmentPage> with Trans {
|
||||
onTap: () => {
|
||||
if (Cache().userLoggedIn != null)
|
||||
{
|
||||
args['customerId'] = Cache().userLoggedIn.customerId,
|
||||
args['customerId'] = Cache().userLoggedIn!.customerId,
|
||||
Navigator.of(context).pushNamed('mydevelopmentBodyPage', arguments: args)
|
||||
}
|
||||
},
|
||||
@@ -185,17 +185,18 @@ class _MyDevelopmentPage extends State<MyDevelopmentPage> with Trans {
|
||||
Widget hiddenWidget(CustomerRepository customerRepository, ExerciseRepository exerciseRepository) {
|
||||
final LinkedHashMap args = LinkedHashMap();
|
||||
if (Cache().getTrainee() != null) {
|
||||
return FlatButton(
|
||||
padding: EdgeInsets.all(20),
|
||||
textColor: Colors.white,
|
||||
color: Colors.black12,
|
||||
focusColor: Colors.blueAccent,
|
||||
return TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.all(20),
|
||||
primary: Colors.white,
|
||||
onSurface: Colors.blueAccent,
|
||||
),
|
||||
onPressed: () => {
|
||||
if (Cache().getTrainee() != null)
|
||||
{
|
||||
args['exerciseRepository'] = exerciseRepository,
|
||||
args['customerRepository'] = customerRepository,
|
||||
args['customerId'] = Cache().getTrainee().customerId,
|
||||
args['customerId'] = Cache().getTrainee()!.customerId,
|
||||
Navigator.of(context).pushNamed('exerciseLogPage', arguments: args)
|
||||
},
|
||||
},
|
||||
@@ -213,7 +214,7 @@ class _MyDevelopmentPage extends State<MyDevelopmentPage> with Trans {
|
||||
final LinkedHashMap args = LinkedHashMap();
|
||||
args['exerciseRepository'] = exerciseRepository;
|
||||
args['customerRepository'] = customerRepository;
|
||||
args['customerId'] = Cache().userLoggedIn.customerId;
|
||||
args['customerId'] = Cache().userLoggedIn!.customerId;
|
||||
Navigator.of(context).pushNamed('exerciseLogPage', arguments: args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ import 'package:aitrainer_app/util/trans.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
import '../widgets/app_bar.dart';
|
||||
import '../widgets/input_dialog_widget.dart';
|
||||
|
||||
@@ -26,8 +26,8 @@ class _SizeState extends State<SizesDevelopmentPage> with Trans {
|
||||
create: (context) => DevelopmentSizesBloc(customerRepository: CustomerRepository())..add(DevelopmentSizesLoad()),
|
||||
child: BlocConsumer<DevelopmentSizesBloc, DevelopmentSizesState>(listener: (context, state) {
|
||||
if (state is DevelopmentSizesError) {
|
||||
Scaffold.of(context)
|
||||
.showSnackBar(SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
(SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white)))));
|
||||
}
|
||||
}, builder: (context, state) {
|
||||
final bloc = BlocProvider.of<DevelopmentSizesBloc>(context);
|
||||
@@ -74,7 +74,7 @@ class _SizeState extends State<SizesDevelopmentPage> with Trans {
|
||||
double mediaHeight = MediaQuery.of(context).size.height * .8;
|
||||
|
||||
bloc.customerRepository.setMediaDimensions(mediaWidth, mediaHeight);
|
||||
List<Widget> list = List();
|
||||
List<Widget> list = [];
|
||||
|
||||
list.add(
|
||||
bloc.isMan
|
||||
@@ -90,8 +90,8 @@ class _SizeState extends State<SizesDevelopmentPage> with Trans {
|
||||
),
|
||||
);
|
||||
list.add(Positioned(
|
||||
top: bloc.customerRepository.getWeightCoordinate(bloc.isMan, isTop: true).toDouble(),
|
||||
left: bloc.customerRepository.getWeightCoordinate(bloc.isMan, isTop: false, isLeft: true).toDouble() - 45,
|
||||
top: bloc.customerRepository.getWeightCoordinate(bloc.isMan, isTop: true)!.toDouble(),
|
||||
left: bloc.customerRepository.getWeightCoordinate(bloc.isMan, isTop: false, isLeft: true)!.toDouble() - 45,
|
||||
child: GestureDetector(
|
||||
//onTap: () => onPressed(bloc.customerRepository.getPropertyByName("Weight")),
|
||||
child: Image.asset(
|
||||
@@ -132,13 +132,13 @@ class _SizeState extends State<SizesDevelopmentPage> with Trans {
|
||||
}
|
||||
|
||||
List<Widget> getSizeElements(DevelopmentSizesBloc bloc) {
|
||||
List<Widget> list = List();
|
||||
List<Widget> list = [];
|
||||
|
||||
bloc.customerRepository.manSizes.forEach((element) {
|
||||
list.add(
|
||||
Positioned(
|
||||
top: element.top.toDouble(),
|
||||
left: element.left.toDouble(),
|
||||
top: element.top!.toDouble(),
|
||||
left: element.left!.toDouble(),
|
||||
child: element.value != 0
|
||||
? Container(
|
||||
width: 20,
|
||||
@@ -187,7 +187,7 @@ class _SizeState extends State<SizesDevelopmentPage> with Trans {
|
||||
builder: (context) => InputDialog(
|
||||
title: t("Size Of Your"),
|
||||
subtitle: element.propertyNameTranslation,
|
||||
initialValue: element.value,
|
||||
initialValue: element.value!,
|
||||
onChanged: (value) {
|
||||
//widget.exerciseBloc.add(ExerciseNewSizeChange(propertyName: element.propertyName, value: value));
|
||||
},
|
||||
|
||||
@@ -58,7 +58,7 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> with Trans, Logging
|
||||
if (Cache().userLoggedIn != null)
|
||||
{
|
||||
args['exerciseRepository'] = exerciseRepository,
|
||||
args['customerId'] = Cache().userLoggedIn.customerId,
|
||||
args['customerId'] = Cache().userLoggedIn!.customerId,
|
||||
Navigator.of(context).pushNamed('exercisePlanCustomPage', arguments: args)
|
||||
}
|
||||
},
|
||||
@@ -80,7 +80,7 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> with Trans, Logging
|
||||
onTap: () => {
|
||||
if (Cache().userLoggedIn != null)
|
||||
{
|
||||
args['customerId'] = Cache().userLoggedIn.customerId,
|
||||
args['customerId'] = Cache().userLoggedIn!.customerId,
|
||||
Navigator.of(context).pushNamed('exerciseExecutePlanPage', arguments: args)
|
||||
}
|
||||
},
|
||||
@@ -190,16 +190,17 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> with Trans, Logging
|
||||
Widget hiddenPlanWidget(ExerciseRepository exerciseRepository) {
|
||||
final LinkedHashMap args = LinkedHashMap();
|
||||
if (Cache().getTrainee() != null) {
|
||||
return FlatButton(
|
||||
padding: EdgeInsets.all(20),
|
||||
textColor: Colors.white,
|
||||
color: Colors.black12,
|
||||
focusColor: Colors.blueAccent,
|
||||
return TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.all(20),
|
||||
primary: Colors.white,
|
||||
onSurface: Colors.black12,
|
||||
),
|
||||
onPressed: () => {
|
||||
if (Cache().getTrainee() != null)
|
||||
{
|
||||
args['exerciseRepository'] = exerciseRepository,
|
||||
args['customerId'] = Cache().getTrainee().customerId,
|
||||
args['customerId'] = Cache().getTrainee()!.customerId,
|
||||
Navigator.of(context).pushNamed('exercisePlanCustomPage', arguments: args)
|
||||
}
|
||||
},
|
||||
@@ -215,16 +216,17 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> with Trans, Logging
|
||||
Widget hiddenTrainingWidget() {
|
||||
final LinkedHashMap args = LinkedHashMap();
|
||||
if (Cache().getTrainee() != null) {
|
||||
log("!!Trainee: " + Cache().getTrainee().firstname + " " + Cache().getTrainee().name);
|
||||
return FlatButton(
|
||||
padding: EdgeInsets.all(20),
|
||||
textColor: Colors.white,
|
||||
color: Colors.black12,
|
||||
focusColor: Colors.blueAccent,
|
||||
log("!!Trainee: " + Cache().getTrainee()!.firstname! + " " + Cache().getTrainee()!.name!);
|
||||
return TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.all(20),
|
||||
primary: Colors.white,
|
||||
onSurface: Colors.black12,
|
||||
),
|
||||
onPressed: () => {
|
||||
if (Cache().getTrainee() != null)
|
||||
{
|
||||
args['customerId'] = Cache().getTrainee().customerId,
|
||||
args['customerId'] = Cache().getTrainee()!.customerId,
|
||||
Navigator.of(context).pushNamed('exerciseExecutePlanPage', arguments: args)
|
||||
}
|
||||
},
|
||||
|
||||
+14
-18
@@ -10,9 +10,8 @@ import 'package:aitrainer_app/widgets/dialog_long.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
|
||||
import '../library_keys.dart';
|
||||
|
||||
@@ -31,13 +30,8 @@ class RegistrationPage extends StatelessWidget with Trans {
|
||||
LoginBloc(userRepository: UserRepository(), accountBloc: accountBloc, context: context, isRegistration: true),
|
||||
child: BlocConsumer<LoginBloc, LoginState>(listener: (context, state) {
|
||||
if (state is LoginError) {
|
||||
String message = t(state.message);
|
||||
if (message == null) {
|
||||
message = "";
|
||||
} else {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(message, style: TextStyle(color: Colors.white))));
|
||||
}
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(t(state.message), style: TextStyle(color: Colors.white))));
|
||||
} else if (state is LoginSuccess) {
|
||||
//Navigator.of(context).pushNamed('customerModifyPage');
|
||||
showDialog(
|
||||
@@ -95,7 +89,7 @@ class RegistrationPage extends StatelessWidget with Trans {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Image.asset(
|
||||
'asset/image/button_fb.png',
|
||||
width: 60,
|
||||
@@ -103,7 +97,7 @@ class RegistrationPage extends StatelessWidget with Trans {
|
||||
onPressed: () => {loginBloc.add(RegistrationFB())},
|
||||
),
|
||||
Platform.isAndroid
|
||||
? FlatButton(
|
||||
? TextButton(
|
||||
child: Image.asset(
|
||||
'asset/image/button_google.png',
|
||||
width: 60,
|
||||
@@ -112,7 +106,7 @@ class RegistrationPage extends StatelessWidget with Trans {
|
||||
)
|
||||
: Offstage(),
|
||||
Platform.isIOS
|
||||
? FlatButton(
|
||||
? TextButton(
|
||||
child: Image.asset(
|
||||
'asset/image/button_apple.png',
|
||||
width: 60,
|
||||
@@ -133,13 +127,14 @@ class RegistrationPage extends StatelessWidget with Trans {
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 4.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.green[50], width: 0.4),
|
||||
borderSide: BorderSide(color: Colors.green[50]!, width: 0.4),
|
||||
),
|
||||
),
|
||||
initialValue: loginBloc.userRepository.user.email,
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
validator: (val) {
|
||||
return t(loginBloc.emailValidation(val));
|
||||
final String? validator = loginBloc.emailValidation(val!);
|
||||
return validator == null ? null : t(validator);
|
||||
},
|
||||
onChanged: (value) => loginBloc.add(LoginEmailChange(email: value)),
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
@@ -164,13 +159,14 @@ class RegistrationPage extends StatelessWidget with Trans {
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 1.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.green[50], width: 0.4),
|
||||
borderSide: BorderSide(color: Colors.green[50]!, width: 0.4),
|
||||
),
|
||||
),
|
||||
initialValue: loginBloc.userRepository.user.password,
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
validator: (val) {
|
||||
return t(loginBloc.passwordValidation(val));
|
||||
final String? validator = loginBloc.passwordValidation(val!);
|
||||
return validator == null ? null : t(validator);
|
||||
},
|
||||
onChanged: (value) => loginBloc.add(LoginPasswordChange(password: value)),
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
@@ -184,7 +180,7 @@ class RegistrationPage extends StatelessWidget with Trans {
|
||||
color: Colors.transparent,
|
||||
),
|
||||
Row(mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[
|
||||
FlatButton(
|
||||
TextButton(
|
||||
key: LibraryKeys.loginOKButton,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
@@ -233,7 +229,7 @@ class RegistrationPage extends StatelessWidget with Trans {
|
||||
value: loginBloc.dataPolicyAllowed,
|
||||
activeColor: Colors.indigo,
|
||||
onChanged: (value) {
|
||||
loginBloc.add(DataProtectionClicked(marked: value));
|
||||
loginBloc.add(DataProtectionClicked(marked: value!));
|
||||
},
|
||||
controlAffinity: ListTileControlAffinity.leading, // <-- leading Checkbox
|
||||
);
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import 'package:aitrainer_app/bloc/reset_password_bloc.dart';
|
||||
import 'package:aitrainer_app/bloc/password_reset/password_reset_bloc.dart';
|
||||
import 'package:aitrainer_app/repository/user_repository.dart';
|
||||
import 'package:aitrainer_app/util/trans.dart';
|
||||
import 'package:aitrainer_app/widgets/app_bar_min.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
|
||||
import '../library_keys.dart';
|
||||
|
||||
@@ -20,49 +19,50 @@ class ResetPasswordPage extends StatelessWidget with Trans {
|
||||
Widget build(BuildContext context) {
|
||||
setContext(context);
|
||||
return BlocProvider(
|
||||
create: (context) => ResetPasswordFormBloc(
|
||||
create: (context) => PasswordResetBloc(
|
||||
userRepository: UserRepository(),
|
||||
),
|
||||
child: Builder(builder: (context) {
|
||||
final loginBloc = BlocProvider.of<ResetPasswordFormBloc>(context);
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: AppBarMin(),
|
||||
body: FormBlocListener<ResetPasswordFormBloc, String, String>(
|
||||
/* onSubmitting: (context, state) {
|
||||
LoadingDialog.show(context);
|
||||
}, */
|
||||
onSuccess: (context, state) {
|
||||
Navigator.of(context).pop();
|
||||
body: BlocConsumer<PasswordResetBloc, PasswordResetState>(
|
||||
listener: (context, state) {
|
||||
if (state is PasswordResetError) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(t(state.message), style: TextStyle(color: Colors.white))));
|
||||
} else if (state is PasswordResetReady) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
onFailure: (context, state) {
|
||||
showInSnackBar(state.failureResponse);
|
||||
},
|
||||
child: SafeArea(
|
||||
bottom: false,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('asset/image/WT_login.jpg'),
|
||||
fit: BoxFit.cover,
|
||||
alignment: Alignment.center,
|
||||
builder: (context, state) {
|
||||
final loginBloc = BlocProvider.of<PasswordResetBloc>(context);
|
||||
return SafeArea(
|
||||
bottom: false,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('asset/image/WT_login.jpg'),
|
||||
fit: BoxFit.cover,
|
||||
alignment: Alignment.center,
|
||||
),
|
||||
),
|
||||
child: ModalProgressHUD(
|
||||
child: buildResetPasswordForm(loginBloc),
|
||||
inAsyncCall: state is PasswordResetLoading,
|
||||
opacity: 0.5,
|
||||
color: Colors.black54,
|
||||
progressIndicator: CircularProgressIndicator(),
|
||||
),
|
||||
),
|
||||
child: ModalProgressHUD(
|
||||
child: buildResetPasswordForm(loginBloc),
|
||||
inAsyncCall: loginBloc.loading == true,
|
||||
opacity: 0.5,
|
||||
color: Colors.black54,
|
||||
progressIndicator: CircularProgressIndicator(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
Widget buildResetPasswordForm(ResetPasswordFormBloc formBloc) {
|
||||
Widget buildResetPasswordForm(PasswordResetBloc loginBloc) {
|
||||
return Form(
|
||||
key: _formKey,
|
||||
child: Container(
|
||||
@@ -81,14 +81,28 @@ class ResetPasswordPage extends StatelessWidget with Trans {
|
||||
],
|
||||
),
|
||||
Divider(),
|
||||
TextFieldBlocBuilder(
|
||||
TextFormField(
|
||||
key: LibraryKeys.loginEmailField,
|
||||
textFieldBloc: formBloc.emailField,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
contentPadding: EdgeInsets.only(left: 15, top: 15, bottom: 15),
|
||||
labelText: t('Email'),
|
||||
fillColor: Colors.white24,
|
||||
filled: true,
|
||||
labelText: 'Email',
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 4.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.green[50]!, width: 0.4),
|
||||
),
|
||||
),
|
||||
initialValue: loginBloc.userRepository.user.email,
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
validator: (val) {
|
||||
final String? validator = loginBloc.emailValidation(val!);
|
||||
return validator == null ? null : t(validator);
|
||||
},
|
||||
onChanged: (value) => loginBloc.add(PasswordResetEmailChange(email: value)),
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
style: new TextStyle(fontSize: 16, color: Colors.indigo),
|
||||
),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
@@ -97,7 +111,7 @@ class ResetPasswordPage extends StatelessWidget with Trans {
|
||||
color: Colors.transparent,
|
||||
),
|
||||
Row(mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[
|
||||
new FlatButton(
|
||||
TextButton(
|
||||
key: LibraryKeys.loginOKButton,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
@@ -109,8 +123,7 @@ class ResetPasswordPage extends StatelessWidget with Trans {
|
||||
),
|
||||
],
|
||||
),
|
||||
//Image.asset('asset/image/WT_OK.png', width: 100, height: 100),
|
||||
onPressed: () => {formBloc.add(SubmitFormBloc())}),
|
||||
onPressed: () => loginBloc.add(PasswordResetSubmit())),
|
||||
]),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
@@ -125,9 +138,4 @@ class ResetPasswordPage extends StatelessWidget with Trans {
|
||||
])),
|
||||
);
|
||||
}
|
||||
|
||||
void showInSnackBar(String error) {
|
||||
_scaffoldKey.currentState
|
||||
.showSnackBar(SnackBar(backgroundColor: Colors.orange, content: Text(error, style: TextStyle(color: Colors.white))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:aitrainer_app/widgets/sales_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class SalesPage extends StatelessWidget with Trans, Logging {
|
||||
@@ -23,7 +23,7 @@ class SalesPage extends StatelessWidget with Trans, Logging {
|
||||
child: BlocConsumer<SalesBloc, SalesState>(listener: (context, state) {
|
||||
if (state is SalesError) {
|
||||
log("Error: " + state.message);
|
||||
Scaffold.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(t(state.message), style: TextStyle(color: Colors.white))));
|
||||
} else if (state is SalesSuccessful) {
|
||||
showDialog(
|
||||
@@ -145,12 +145,12 @@ class SalesPage extends StatelessWidget with Trans, Logging {
|
||||
}
|
||||
|
||||
List<Widget> getButtons(SalesBloc bloc) {
|
||||
List<Widget> buttons = List();
|
||||
List<Widget> buttons = [];
|
||||
|
||||
bloc.product2Display.forEach((element) {
|
||||
final String title = element.sort == 3 ? t("Montly") : t("Annual");
|
||||
final String desc4 = element.sort == 1 ? "" : t("Predictions with Artificial Intelligence");
|
||||
String badge;
|
||||
late String badge;
|
||||
if (element.sort == 2) {
|
||||
badge = t("14% discount");
|
||||
} else if (element.sort == 1) {
|
||||
@@ -158,7 +158,7 @@ class SalesPage extends StatelessWidget with Trans, Logging {
|
||||
}
|
||||
Widget button = SalesButton(
|
||||
title: title,
|
||||
price: element.localizedPrice,
|
||||
price: element.localizedPrice!,
|
||||
desc1: t("Development programs"),
|
||||
desc2: t("Suggestions based on your actual status"),
|
||||
desc3: t("Special customized training plans"),
|
||||
|
||||
@@ -12,7 +12,7 @@ import 'package:aitrainer_app/widgets/bottom_nav.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
import 'package:toggle_switch/toggle_switch.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
@@ -39,7 +39,7 @@ class SettingsPage extends StatelessWidget with Trans {
|
||||
child: Form(
|
||||
child: BlocConsumer<SettingsBloc, SettingsState>(listener: (context, state) {
|
||||
if (state is SettingsError) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
} else if (state is SettingsReady) {
|
||||
menuBloc.add(MenuRecreateTree());
|
||||
@@ -71,8 +71,8 @@ class SettingsPage extends StatelessWidget with Trans {
|
||||
child: Text(value),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (String lang) => {
|
||||
settingsBloc.add(SettingsChangeLanguage(language: lang)),
|
||||
onChanged: (lang) => {
|
||||
settingsBloc.add(SettingsChangeLanguage(language: lang as String)),
|
||||
Track().track(TrackingEvent.settings_lang, eventValue: lang)
|
||||
})),
|
||||
getServer(settingsBloc),
|
||||
@@ -81,7 +81,7 @@ class SettingsPage extends StatelessWidget with Trans {
|
||||
}
|
||||
|
||||
ListTile getServer(SettingsBloc settingsBloc) {
|
||||
if (Cache().userLoggedIn == null || Cache().userLoggedIn.admin != 1) {
|
||||
if (Cache().userLoggedIn == null || Cache().userLoggedIn!.admin != 1) {
|
||||
return ListTile(
|
||||
title: Container(),
|
||||
);
|
||||
@@ -119,7 +119,7 @@ class SettingsPage extends StatelessWidget with Trans {
|
||||
minWidth: 120.0,
|
||||
minHeight: 30.0,
|
||||
fontSize: 14.0,
|
||||
initialLabelIndex: Cache().hasHardware ? 0 : 1,
|
||||
initialLabelIndex: Cache().hasHardware! ? 0 : 1,
|
||||
activeBgColor: Colors.indigo,
|
||||
activeFgColor: Colors.white,
|
||||
inactiveBgColor: Colors.white60,
|
||||
|
||||
@@ -14,13 +14,13 @@ import 'package:aitrainer_app/widgets/number_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class TestSetControl extends StatelessWidget with Trans {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final HashMap args = ModalRoute.of(context).settings.arguments;
|
||||
final HashMap args = ModalRoute.of(context)!.settings.arguments as HashMap;
|
||||
final ExerciseType exerciseType = args['exerciseType'];
|
||||
final ExercisePlanDetail exercisePlanDetail = args['exercisePlanDetail'];
|
||||
// ignore: close_sinks
|
||||
@@ -35,7 +35,7 @@ class TestSetControl extends StatelessWidget with Trans {
|
||||
padding: EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: Cache().userLoggedIn.sex == "m"
|
||||
image: Cache().userLoggedIn!.sex == "m"
|
||||
? AssetImage("asset/image/WT_Results_for_men.jpg")
|
||||
: AssetImage("asset/image/WT_Results_for_female.jpg"),
|
||||
fit: BoxFit.cover,
|
||||
@@ -47,7 +47,7 @@ class TestSetControl extends StatelessWidget with Trans {
|
||||
TestSetControlBloc(exercisePlanDetail: exercisePlanDetail, executeBloc: executeBloc, exerciseType: exerciseType),
|
||||
child: BlocConsumer<TestSetControlBloc, TestSetControlState>(listener: (context, state) {
|
||||
if (state is TestSetControlError) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
}
|
||||
}, builder: (context, state) {
|
||||
@@ -76,7 +76,7 @@ class TestSetControl extends StatelessWidget with Trans {
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
exercisePlanDetail.exerciseType.nameTranslation,
|
||||
exercisePlanDetail.exerciseType!.nameTranslation,
|
||||
style: GoogleFonts.archivoBlack(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 24,
|
||||
@@ -130,7 +130,7 @@ class TestSetControl extends StatelessWidget with Trans {
|
||||
children: [
|
||||
TextSpan(text: t("Please repeat with ")),
|
||||
TextSpan(
|
||||
text: bloc.initUnitQuantity.toStringAsFixed(0) + " " + bloc.exercisePlanDetail.exerciseType.unitQuantityUnit,
|
||||
text: bloc.initUnitQuantity.toStringAsFixed(0) + " " + bloc.exercisePlanDetail.exerciseType!.unitQuantityUnit!,
|
||||
style: GoogleFonts.inter(
|
||||
decoration: TextDecoration.underline,
|
||||
fontSize: 16,
|
||||
@@ -160,12 +160,14 @@ class TestSetControl extends StatelessWidget with Trans {
|
||||
maxValue: 200,
|
||||
initalValue: bloc.initQuantity.round(),
|
||||
unit: t("reps"),
|
||||
color: Colors.yellow[50],
|
||||
color: Colors.yellow[50]!,
|
||||
onChange: (value) => {bloc.add(TestSetControlQuantityChange(quantity: value.toDouble()))}),
|
||||
FlatButton(
|
||||
padding: EdgeInsets.all(0),
|
||||
textColor: Colors.white,
|
||||
focusColor: Colors.blueAccent,
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.all(0),
|
||||
primary: Colors.white,
|
||||
onSurface: Colors.blueAccent,
|
||||
),
|
||||
onPressed: () => {
|
||||
bloc.add(TestSetControlSubmit()),
|
||||
{
|
||||
|
||||
+11
-11
@@ -13,18 +13,18 @@ import 'package:carousel_slider/carousel_slider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class TestSetEdit extends StatelessWidget with Trans {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
HashMap args = ModalRoute.of(context).settings.arguments;
|
||||
HashMap args = ModalRoute.of(context)!.settings.arguments as HashMap;
|
||||
final String templateName = args['templateName'];
|
||||
final String templateNameTranslation = args['templateNameTranslation'];
|
||||
// ignore: close_sinks
|
||||
final MenuBloc menuBloc = BlocProvider.of<MenuBloc>(context);
|
||||
TestSetEditBloc bloc;
|
||||
late TestSetEditBloc? bloc;
|
||||
|
||||
setContext(context);
|
||||
return Scaffold(
|
||||
@@ -48,7 +48,7 @@ class TestSetEdit extends StatelessWidget with Trans {
|
||||
menuBloc: menuBloc),
|
||||
child: BlocConsumer<TestSetEditBloc, TestSetEditState>(listener: (context, state) {
|
||||
if (state is TestSetEditError) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
} else if (state is TestSetEditSaved) {
|
||||
Navigator.of(context).pop();
|
||||
@@ -57,7 +57,7 @@ class TestSetEdit extends StatelessWidget with Trans {
|
||||
}, builder: (context, state) {
|
||||
bloc = BlocProvider.of<TestSetEditBloc>(context);
|
||||
return ModalProgressHUD(
|
||||
child: getTestSetWidget(bloc, templateNameTranslation),
|
||||
child: getTestSetWidget(bloc!, templateNameTranslation),
|
||||
inAsyncCall: state is TestSetEditLoading,
|
||||
opacity: 0.5,
|
||||
color: Colors.black54,
|
||||
@@ -77,7 +77,7 @@ class TestSetEdit extends StatelessWidget with Trans {
|
||||
Navigator.of(context).pop(),
|
||||
if (bloc != null)
|
||||
{
|
||||
bloc.add(TestSetEditSubmit()),
|
||||
bloc!.add(TestSetEditSubmit()),
|
||||
}
|
||||
},
|
||||
onCancel: () => {Navigator.of(context).pop()},
|
||||
@@ -156,7 +156,7 @@ class TestSetEdit extends StatelessWidget with Trans {
|
||||
}
|
||||
|
||||
List<Widget> imageSliders(List<WorkoutMenuTree> alternatives, MenuBloc menuBloc, WorkoutMenuTree workoutTree, TestSetEditBloc bloc) {
|
||||
final List<Widget> list = List();
|
||||
final List<Widget> list = [];
|
||||
if (bloc.exercisePlanDetails[workoutTree.exerciseTypeId] == null) {
|
||||
list.add(Container(
|
||||
padding: EdgeInsets.only(top: 25, bottom: 25),
|
||||
@@ -177,7 +177,7 @@ class TestSetEdit extends StatelessWidget with Trans {
|
||||
} else {
|
||||
ExerciseType exerciseType = bloc.exercisePlanDetails[workoutTree.exerciseTypeId];
|
||||
|
||||
final WorkoutMenuTree actualWorkoutTree = bloc.menuBloc.menuTreeRepository.getMenuItemByExerciseTypeId(exerciseType.exerciseTypeId);
|
||||
final WorkoutMenuTree actualWorkoutTree = bloc.menuBloc.menuTreeRepository.getMenuItemByExerciseTypeId(exerciseType.exerciseTypeId)!;
|
||||
list.add(getImageStack(actualWorkoutTree, menuBloc, bloc));
|
||||
}
|
||||
|
||||
@@ -225,11 +225,11 @@ class TestSetEdit extends StatelessWidget with Trans {
|
||||
}
|
||||
|
||||
List<Widget> getExerciseTypeWidgets(TestSetEditBloc bloc) {
|
||||
final List<Widget> widgets = List();
|
||||
final List<Widget> widgets = [];
|
||||
bloc.exerciseTypes.forEach((element) {
|
||||
final WorkoutMenuTree workoutTree = bloc.menuBloc.menuTreeRepository.getMenuItemByExerciseTypeId(element.exerciseTypeId);
|
||||
final WorkoutMenuTree? workoutTree = bloc.menuBloc.menuTreeRepository.getMenuItemByExerciseTypeId(element.exerciseTypeId);
|
||||
|
||||
final List<WorkoutMenuTree> alternativeMenuItems = bloc.menuBloc.menuTreeRepository.getWorkoutTreeAlternatives(workoutTree);
|
||||
final List<WorkoutMenuTree>? alternativeMenuItems = bloc.menuBloc.menuTreeRepository.getWorkoutTreeAlternatives(workoutTree);
|
||||
if (workoutTree != null && alternativeMenuItems != null) {
|
||||
final Widget widget = CarouselSlider(
|
||||
options: CarouselOptions(
|
||||
|
||||
@@ -12,7 +12,7 @@ import 'package:aitrainer_app/widgets/victory_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
import 'package:timeline_tile/timeline_tile.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
@@ -40,7 +40,7 @@ class TestSetExecute extends StatelessWidget with Trans {
|
||||
),
|
||||
child: BlocConsumer<TestSetExecuteBloc, TestSetExecuteState>(listener: (context, state) {
|
||||
if (state is TestSetExecuteError) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
} else if (state is TestSetExecuteFinished) {
|
||||
showDialog(
|
||||
@@ -64,7 +64,7 @@ class TestSetExecute extends StatelessWidget with Trans {
|
||||
}),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
onPressed: () => executeExercise(executeBloc, executeBloc.getNext(), context),
|
||||
onPressed: () => executeExercise(executeBloc, executeBloc.getNext()!, context),
|
||||
backgroundColor: Colors.orange[800],
|
||||
icon: Icon(CustomIcon.weight_hanging),
|
||||
label: Text(
|
||||
@@ -82,7 +82,7 @@ class TestSetExecute extends StatelessWidget with Trans {
|
||||
}
|
||||
|
||||
List<Widget> getTiles(TestSetExecuteBloc bloc, BuildContext context) {
|
||||
List<Widget> tiles = List();
|
||||
List<Widget> tiles = [];
|
||||
tiles.add(getStartTile(bloc));
|
||||
tiles.addAll(getExerciseTiles(bloc, context));
|
||||
tiles.add(getEndTile());
|
||||
@@ -248,18 +248,18 @@ class TestSetExecute extends StatelessWidget with Trans {
|
||||
}
|
||||
|
||||
List<Widget> getExerciseTiles(TestSetExecuteBloc bloc, BuildContext context) {
|
||||
List<Widget> tiles = List();
|
||||
List<Widget> tiles = [];
|
||||
if (bloc.exercisePlanDetails != null) {
|
||||
bloc.exercisePlanDetails.forEach((element) {
|
||||
if (element != null && element.exerciseTypeId != null) {
|
||||
tiles.add(GestureDetector(
|
||||
onDoubleTap: () => print("Execute ${element.exerciseType.nameTranslation}"),
|
||||
onTap: () => executeExercise(bloc, element, context),
|
||||
child: ExerciseTile(
|
||||
bloc: bloc,
|
||||
exercisePlanDetail: element,
|
||||
)));
|
||||
}
|
||||
bloc.exercisePlanDetails!.forEach((element) {
|
||||
//if (element != null && element.exerciseTypeId != null) {
|
||||
tiles.add(GestureDetector(
|
||||
onDoubleTap: () => print("Execute ${element.exerciseType!.nameTranslation}"),
|
||||
onTap: () => executeExercise(bloc, element, context),
|
||||
child: ExerciseTile(
|
||||
bloc: bloc,
|
||||
exercisePlanDetail: element,
|
||||
)));
|
||||
//}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -267,8 +267,8 @@ class TestSetExecute extends StatelessWidget with Trans {
|
||||
}
|
||||
|
||||
void executeExercise(TestSetExecuteBloc bloc, ExercisePlanDetail exercisePlanDetail, BuildContext context) {
|
||||
ExercisePlanDetail next = bloc.getNext();
|
||||
print("Detail: $next");
|
||||
ExercisePlanDetail? next = bloc.getNext();
|
||||
|
||||
if (next != null) {
|
||||
final HashMap args = HashMap();
|
||||
args['exerciseType'] = exercisePlanDetail.exerciseType;
|
||||
@@ -279,7 +279,7 @@ class TestSetExecute extends StatelessWidget with Trans {
|
||||
String description2 = "";
|
||||
if (next.exerciseTypeId != exercisePlanDetail.exerciseTypeId) {
|
||||
title = t("Stop!");
|
||||
description = t("Please continue with the next exercise in the queue:") + next.exerciseType.nameTranslation;
|
||||
description = t("Please continue with the next exercise in the queue:") + next.exerciseType!.nameTranslation;
|
||||
description2 = t("Or, you can redifine this exercise queue in the Compact Test menu");
|
||||
} else {
|
||||
if (exercisePlanDetail.state.equalsTo(ExercisePlanDetailState.inProgress)) {
|
||||
@@ -318,10 +318,10 @@ class ExerciseTile extends StatelessWidget with Trans {
|
||||
final TestSetExecuteBloc bloc;
|
||||
final ExercisePlanDetail exercisePlanDetail;
|
||||
|
||||
ExerciseTile({this.bloc, this.exercisePlanDetail});
|
||||
ExerciseTile({required this.bloc, required this.exercisePlanDetail});
|
||||
|
||||
Widget getIndicator(ExercisePlanDetailState state) {
|
||||
ExercisePlanDetail next = bloc.getNext();
|
||||
ExercisePlanDetail? next = bloc.getNext();
|
||||
bool actual = false;
|
||||
if (next != null) {
|
||||
if (next.exerciseTypeId == exercisePlanDetail.exerciseTypeId) {
|
||||
@@ -359,8 +359,8 @@ class ExerciseTile extends StatelessWidget with Trans {
|
||||
Widget build(BuildContext context) {
|
||||
final ExercisePlanDetailState state = exercisePlanDetail.state;
|
||||
final bool done = state.equalsTo(ExercisePlanDetailState.finished);
|
||||
final String countSerie = exercisePlanDetail.exercises == null ? "1" : (exercisePlanDetail.exercises.length).toString();
|
||||
final String serie = exercisePlanDetail.exerciseType.unitQuantityUnit == null ? "/1" : "/4";
|
||||
final String countSerie = exercisePlanDetail.exercises == null ? "1" : (exercisePlanDetail.exercises!.length).toString();
|
||||
final String serie = exercisePlanDetail.exerciseType!.unitQuantityUnit == null ? "/1" : "/4";
|
||||
setContext(context);
|
||||
return Container(
|
||||
color: Colors.transparent,
|
||||
@@ -387,8 +387,8 @@ class ExerciseTile extends StatelessWidget with Trans {
|
||||
width: 120,
|
||||
height: 80,
|
||||
child: MenuImage(
|
||||
imageName: bloc.getActualImageName(exercisePlanDetail.exerciseType.exerciseTypeId),
|
||||
workoutTreeId: bloc.getActualWorkoutTreeId(exercisePlanDetail.exerciseType.exerciseTypeId),
|
||||
imageName: bloc.getActualImageName(exercisePlanDetail.exerciseType!.exerciseTypeId),
|
||||
workoutTreeId: bloc.getActualWorkoutTreeId(exercisePlanDetail.exerciseType!.exerciseTypeId)!,
|
||||
)),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
@@ -403,7 +403,7 @@ class ExerciseTile extends StatelessWidget with Trans {
|
||||
),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: exercisePlanDetail.exerciseType.nameTranslation,
|
||||
text: exercisePlanDetail.exerciseType!.nameTranslation,
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -421,18 +421,18 @@ class ExerciseTile extends StatelessWidget with Trans {
|
||||
),
|
||||
],
|
||||
)),
|
||||
exercisePlanDetail.exerciseType.unitQuantityUnit != null
|
||||
exercisePlanDetail.exerciseType!.unitQuantityUnit != null
|
||||
? TextSpan(
|
||||
text: "\n",
|
||||
)
|
||||
: TextSpan(),
|
||||
exercisePlanDetail.exerciseType.unitQuantityUnit != null
|
||||
exercisePlanDetail.exerciseType!.unitQuantityUnit != null
|
||||
? TextSpan(
|
||||
text: t(exercisePlanDetail.exerciseType.unitQuantityUnit) + ": ",
|
||||
text: t(exercisePlanDetail.exerciseType!.unitQuantityUnit!) + ": ",
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 12, color: done ? Colors.grey[100] : Colors.yellow[400], fontWeight: FontWeight.bold))
|
||||
: TextSpan(),
|
||||
exercisePlanDetail.exerciseType.unitQuantityUnit != null
|
||||
exercisePlanDetail.exerciseType!.unitQuantityUnit != null
|
||||
? TextSpan(
|
||||
text: t(bloc.getExerciseWeight(exercisePlanDetail)),
|
||||
style: GoogleFonts.inter(
|
||||
@@ -443,7 +443,7 @@ class ExerciseTile extends StatelessWidget with Trans {
|
||||
text: "\n",
|
||||
),
|
||||
TextSpan(
|
||||
text: t(exercisePlanDetail.exerciseType.unit) + ": ",
|
||||
text: t(exercisePlanDetail.exerciseType!.unit) + ": ",
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 12, color: done ? Colors.grey[100] : Colors.yellow[400], fontWeight: FontWeight.bold)),
|
||||
TextSpan(
|
||||
|
||||
@@ -13,18 +13,18 @@ import 'package:aitrainer_app/widgets/exercise_save.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:modal_progress_hud/modal_progress_hud.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class TestSetNew extends StatelessWidget with Trans {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final HashMap args = ModalRoute.of(context).settings.arguments;
|
||||
final HashMap args = ModalRoute.of(context)!.settings.arguments as HashMap;
|
||||
final ExerciseType exerciseType = args['exerciseType'];
|
||||
final int exercisePlanDetailId = args['exercisePlanDetailId'];
|
||||
// ignore: close_sinks
|
||||
final TestSetExecuteBloc executeBloc = args['testSetExecuteBloc'];
|
||||
TestSetNewBloc bloc;
|
||||
late TestSetNewBloc bloc;
|
||||
setContext(context);
|
||||
return Scaffold(
|
||||
appBar: AppBarNav(depth: 1),
|
||||
@@ -45,13 +45,13 @@ class TestSetNew extends StatelessWidget with Trans {
|
||||
executeBloc: executeBloc),
|
||||
child: BlocConsumer<TestSetNewBloc, TestSetNewState>(listener: (context, state) {
|
||||
if (state is TestSetNewError) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||
} else if (state is TestSetNewReady) {
|
||||
print("Actual state: ${executeBloc.actualState(exerciseType.exerciseTypeId).toString()}");
|
||||
if (executeBloc.actualState(exerciseType.exerciseTypeId).equalsTo(ExercisePlanDetailState.inProgress)) {
|
||||
HashMap args = HashMap();
|
||||
final ExercisePlanDetail actualExercisePlanDetail = executeBloc.actualExercisePlanDetail(exerciseType.exerciseTypeId);
|
||||
final ExercisePlanDetail actualExercisePlanDetail = executeBloc.actualExercisePlanDetail(exerciseType.exerciseTypeId)!;
|
||||
args['exerciseType'] = exerciseType;
|
||||
args['exercisePlanDetail'] = actualExercisePlanDetail;
|
||||
args['testSetExecuteBloc'] = executeBloc;
|
||||
@@ -94,7 +94,7 @@ class TestSetNew extends StatelessWidget with Trans {
|
||||
exerciseDescription: bloc.exerciseType.descriptionTranslation,
|
||||
exerciseTask: t("Please take a relative bigger weight and repeat 12-20 times"),
|
||||
unit: bloc.exerciseType.unit,
|
||||
unitQuantityUnit: bloc.exerciseType.unitQuantityUnit,
|
||||
unitQuantityUnit: bloc.exerciseType.unitQuantityUnit!,
|
||||
hasUnitQuantity: bloc.exerciseType.unitQuantityUnit != null,
|
||||
onQuantityChanged: (value) {
|
||||
bloc.add(TestSetNewChangeQuantity(quantity: double.parse(value)));
|
||||
|
||||
Reference in New Issue
Block a user