wt1.1.1 translation fixes

This commit is contained in:
Bossanyi Tibor 2020-09-19 08:09:43 +02:00
parent eb2e8e7171
commit 4a193e085f
31 changed files with 585 additions and 599 deletions

View File

@ -66,6 +66,7 @@
"Do you save this exercise with these parameters?":"Do you save this exercise with these parameters?",
"The number of the exercise": "The number of the exercise",
"The number of the exercise done with": "The number of the exercise done with",
"Please repeat with ": "Please repeat with ",
"repeat": "repeat",
@ -134,5 +135,19 @@
"5. Shoulders": "5. Shoulders",
"6. Core": "6. Core",
"7. Thigh": "7. Thigh",
"8. Calf": "8. Calf"
"8. Calf": "8. Calf",
"Execute My Selected Training Plan": "Execute My Selected Training Plan",
"Edit My Custom Plan": "Edit My Custom Plan",
"Suggested Training Plan": "Suggested Training Plan",
"My Special Plan": "My Special Plan",
"My Arnold's Plan":"My Arnold's Plan",
"My Trainee's Plan": "My Trainee's Plan",
"Execute My Trainee's Training Plan": "Execute My Trainee's Training Plan",
"My Exercise Logs": "My Exercise Logs",
"My Whole Body Development": "My Whole Body Development",
"Development Of Muscles": "Development Of Muscles",
"Predictions": "Predictions",
"My Trainee's Exercise Logs": "My Trainee's Exercise Logs"
}

View File

@ -55,6 +55,7 @@
"Delete": "Törlés",
"The number of the exercise": "Írd be a gyakorlat számát",
"The number of the exercise done with": "Írd be, mennyivel csináltad a gyakorlatot",
"Please repeat with ": "Kérlek ismételd",
"Name": "Név",
@ -134,5 +135,19 @@
"5. Shoulders": "5. Váll",
"6. Core": "6. Has",
"7. Thigh": "7. Comb",
"8. Calf": "8. Vádli"
"8. Calf": "8. Vádli",
"Execute My Selected Training Plan": "Edzésterv végrehajtása",
"Edit My Custom Plan": "Egyéni edzésterv",
"Suggested Training Plan": "Javasolt edzésterv",
"My Special Plan": "Speciális edzésterv",
"My Arnold's Plan": "Arnold edzésterve rám szabva",
"My Trainee's Plan" : "Kliensem edzésterve",
"Execute My Trainee's Training Plan": "Kliensem edzéstervének végrehajtása",
"My Exercise Logs": "Edzésnaplóm",
"My Whole Body Development": "Testem fejlődése",
"Development Of Muscles": "Izomcsoportok fejlődése",
"Predictions": "Előrejelzések",
"My Trainee's Exercise Logs": "Kliensem edzésnaplőja"
}

View File

@ -3,7 +3,7 @@ import 'package:aitrainer_app/model/exercise_type.dart';
import 'package:aitrainer_app/model/workout_tree.dart';
import 'package:aitrainer_app/repository/exercise_plan_repository.dart';
import 'package:aitrainer_app/repository/exercise_repository.dart';
import 'package:aitrainer_app/repository/menu_tree_repository.dart';
import 'package:aitrainer_app/repository/workout_tree_repository.dart';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart';
@ -14,7 +14,7 @@ part 'exercise_by_plan_state.dart';
class ExerciseByPlanBloc extends Bloc<ExerciseByPlanEvent, ExerciseByPlanState> {
final ExerciseRepository exerciseRepository;
final MenuTreeRepository menuTreeRepository;
final WorkoutTreeRepository menuTreeRepository;
final ExercisePlanRepository exercisePlanRepository = ExercisePlanRepository();
int customerId;
@override

View File

@ -7,6 +7,7 @@ class ExerciseControlFormBloc extends FormBloc<String, String> {
int step = 1;
final double percentToCalculate;
final bool readonly;
String times;
final initialRMField = TextFieldBloc(
);
@ -63,6 +64,8 @@ class ExerciseControlFormBloc extends FormBloc<String, String> {
exerciseRepository.setUnitQuantity(unitQuantity3Field.valueToDouble);
});
times = percentToCalculate == 0.5 ? "30-35" : "12";
}
@override

View File

@ -4,7 +4,7 @@ import 'package:aitrainer_app/model/exercise_type.dart';
import 'package:aitrainer_app/model/workout_tree.dart';
import 'package:aitrainer_app/repository/exercise_plan_repository.dart';
import 'package:aitrainer_app/repository/exercise_repository.dart';
import 'package:aitrainer_app/repository/menu_tree_repository.dart';
import 'package:aitrainer_app/repository/workout_tree_repository.dart';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart';
@ -14,7 +14,7 @@ part 'exercise_plan_event.dart';
part 'exercise_plan_state.dart';
class ExercisePlanBloc extends Bloc<ExercisePlanEvent, ExercisePlanState> {
final MenuTreeRepository menuTreeRepository;
final WorkoutTreeRepository menuTreeRepository;
final ExerciseRepository exerciseRepository;
final ExercisePlanRepository exercisePlanRepository = ExercisePlanRepository();
int customerId;

View File

@ -1,7 +1,7 @@
import 'dart:async';
import 'package:aitrainer_app/model/workout_tree.dart';
import 'package:aitrainer_app/repository/menu_tree_repository.dart';
import 'package:aitrainer_app/repository/workout_tree_repository.dart';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart';
@ -10,7 +10,7 @@ part 'menu_event.dart';
part 'menu_state.dart';
class MenuBloc extends Bloc<MenuEvent, MenuState> {
final MenuTreeRepository menuTreeRepository;
final WorkoutTreeRepository menuTreeRepository;
int parent;
MenuBloc({this.menuTreeRepository}) : super(MenuInitial()) {

View File

@ -1,5 +1,7 @@
import 'dart:async';
import 'package:aitrainer_app/bloc/settings/settings_bloc.dart';
import 'package:aitrainer_app/localization/app_language.dart';
import 'package:aitrainer_app/util/session.dart';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
@ -19,7 +21,12 @@ class SessionBloc extends Bloc<SessionEvent, SessionState> {
try {
if (event is SessionStart) {
yield SessionLoading();
// ignore: close_sinks
SettingsBloc settingsBloc = event.settingsBloc;
await session.fetchSessionAndNavigate();
String lang = AppLanguage().appLocal.languageCode;
print("Change lang to $lang");
settingsBloc.add(SettingsChangeLanguage(language: lang));
yield SessionReady();
}
} on Exception catch(ex) {

View File

@ -9,8 +9,10 @@ abstract class SessionEvent extends Equatable {
}
class SessionStart extends SessionEvent {
const SessionStart();
final SettingsBloc settingsBloc;
const SessionStart({this.settingsBloc});
@override
List<Object> get props => [];
List<Object> get props => [settingsBloc];
}

View File

@ -42,28 +42,35 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
}
Future<void> _changeLang( String lang ) async{
print("_change to $lang");
switch ( lang ) {
case "English":
case "en":
case "Angol":
_locale = Locale('en');
break;
case "Hungarian":
case "Magyar":
case "hu":
_locale = Locale('hu');
break;
}
this.language = lang;
final AppLanguage appLanguage = AppLanguage();
appLanguage.changeLanguage(_locale);
AppLanguage().changeLanguage(_locale);
await loadLang();
}
Future<void> loadLang() async{
print (" -- Loading lang $_locale");
if ( context != null ) {
AppLocalizations.of(context).setLocale(_locale);
await AppLocalizations.of(context).load();
if ( _locale != null ) {
print(" -- Loading lang $_locale");
if (context != null) {
AppLocalizations.of(context).setLocale(_locale);
await AppLocalizations.of(context).load();
} else {
print("no context, does not load");
}
} else {
print("no locale, does not load");
}
}
}

View File

@ -1,7 +1,7 @@
import 'dart:async';
import 'package:aitrainer_app/repository/customer_repository.dart';
import 'package:aitrainer_app/repository/exercise_repository.dart';
import 'package:aitrainer_app/repository/menu_tree_repository.dart';
import 'package:aitrainer_app/repository/workout_tree_repository.dart';
import 'package:aitrainer_app/util/session.dart';
import 'package:aitrainer_app/view/account.dart';
import 'package:aitrainer_app/view/custom_exercise_page.dart';
@ -105,7 +105,7 @@ Future<Null> main() async {
// - https://api.dartlang.org/stable/1.24.2/dart-async/Zone-class.html
// - https://www.dartlang.org/articles/libraries/zones
runZonedGuarded<Future<Null>>(() async {
final MenuTreeRepository menuTreeRepository = MenuTreeRepository();
final WorkoutTreeRepository menuTreeRepository = WorkoutTreeRepository();
runApp(
MultiBlocProvider(
providers: [

View File

@ -161,9 +161,9 @@ class ExerciseRepository {
}
});
print ("checkedExerciseTypeid: " + checkedExerciseTypeId.toString());
print ("baseTreeItem: " + baseTreeItem.toString());
print ("count1RMExercises: " + count1RMExercises.toString());
//print ("checkedExerciseTypeid: " + checkedExerciseTypeId.toString());
//print ("baseTreeItem: " + baseTreeItem.toString());
//print ("count1RMExercises: " + count1RMExercises.toString());
final double percent = count1RMExercises / baseTreeItem.length;
Cache().setPercentExercises(percent);
}

View File

@ -28,7 +28,7 @@ class Antagonist {
static int calfNr = 8;
}
class MenuTreeRepository {
class WorkoutTreeRepository {
final LinkedHashMap tree = LinkedHashMap<String, WorkoutTree>();
SplayTreeMap sortedTree = SplayTreeMap<String, List<WorkoutTree>>();
bool isEnglish;
@ -45,9 +45,9 @@ class MenuTreeRepository {
};
Future<void> createTree() async {
final AppLanguage appLanguage = AppLanguage();
isEnglish = appLanguage.appLocal == Locale('en');
print("** Start creating tree on lang: " + appLanguage.appLocal.toString());
isEnglish = AppLanguage().appLocal == Locale('en');
print("** Start creating tree on lang: " + AppLanguage().appLocal.languageCode);
List<ExerciseTree> exerciseTree = Cache().getExerciseTree();
if ( exerciseTree == null || exerciseTree.length == 0) {
@ -115,7 +115,7 @@ class MenuTreeRepository {
WorkoutTree treeItem = value as WorkoutTree;
if ( treeItem.id == treeId ) {
isTreeItem1RM = treeItem.is1RM;
print (treeItem.name + " 1RM " + treeItem.is1RM.toString() );
//print (treeItem.name + " 1RM " + treeItem.is1RM.toString() );
}
});

View File

@ -38,12 +38,11 @@ mixin Common {
}
String getDateLocale( DateTime datetime, bool timeDisplay ) {
AppLanguage appLanguage = AppLanguage();
var date = datetime;
String dateName = DateFormat(DateFormat.YEAR_MONTH_DAY, appLanguage.appLocal.toString()).format(date.toUtc());
String dateName = DateFormat(DateFormat.YEAR_MONTH_DAY, AppLanguage().appLocal.toString()).format(date.toUtc());
if ( timeDisplay ) {
dateName += " " +DateFormat(DateFormat.HOUR_MINUTE, appLanguage.appLocal.toString()).format(date.toUtc());
dateName += " " +DateFormat(DateFormat.HOUR_MINUTE, AppLanguage().appLocal.toString()).format(date.toUtc());
}
return dateName;
@ -74,5 +73,4 @@ mixin Common {
return _passwordRegExp.hasMatch(password);
}
}

View File

@ -17,7 +17,6 @@ class Session {
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
SharedPreferences _sharedPreferences;
final AppLanguage appLanguage = AppLanguage();
fetchSessionAndNavigate( ) async {
print (" -- Session: await prefs..");
@ -27,11 +26,11 @@ class Session {
if ( Cache().firstLoad ) {
print (" -- Session: fetch locale..");
await appLanguage.getLocale(_sharedPreferences);
await AppLocalizations.delegate.load(appLanguage.appLocal);
await AppLanguage().getLocale(_sharedPreferences);
await AppLocalizations.delegate.load(AppLanguage().appLocal);
print (" -- Session: fetch token..");
await _fetchToken(_sharedPreferences);
initDeviceLocale();
//initDeviceLocale();
// PushNotificationsManager().init();
}
@ -69,7 +68,7 @@ class Session {
Cache.password
);
int customerId = 0;
print("--- Lang: " + appLanguage.appLocal.toString());
print("--- Lang: " + AppLanguage().appLocal.toString());
if(responseJson['error'] != null) {
print("************** Here big error - no authentication");
} else if (responseJson['token'] != null) {

13
lib/util/trans.dart Normal file
View File

@ -0,0 +1,13 @@
import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:flutter/cupertino.dart';
mixin Trans {
BuildContext context;
void setContext(BuildContext context) {
this.context = context;
}
String t(String text) {
return AppLocalizations.of(context).translate(text);
}
}

View File

@ -1,23 +1,24 @@
import 'package:aitrainer_app/bloc/account/account_bloc.dart';
import 'package:aitrainer_app/localization/app_language.dart';
import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:aitrainer_app/model/customer.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:aitrainer_app/widgets/bottom_nav.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
// ignore: must_be_immutable
class AccountPage extends StatelessWidget {
class AccountPage extends StatelessWidget with Trans {
// ignore: close_sinks
AccountBloc accountBloc;
@override
Widget build(BuildContext context) {
setContext(context);
accountBloc = BlocProvider.of<AccountBloc>(context);
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context).translate('Account')),
title: Text(t('Account')),
backgroundColor: Colors.transparent,
),
body: Container(
@ -76,7 +77,7 @@ class AccountPage extends StatelessWidget {
ListTile(
leading: Icon(Icons.perm_identity),
subtitle:
Text(AppLocalizations.of(context).translate("Profile")),
Text(t("Profile")),
title: FlatButton(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -118,7 +119,7 @@ class AccountPage extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(AppLocalizations.of(context).translate(text),
Text(t(text),
style: TextStyle(
color: buttonColor
)),

View File

@ -1,6 +1,7 @@
import 'package:aitrainer_app/bloc/account/account_bloc.dart';
import 'package:aitrainer_app/bloc/customer_change_form_bloc.dart';
import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
@ -9,15 +10,13 @@ import 'package:flutter_form_bloc/flutter_form_bloc.dart';
import '../library_keys.dart';
// ignore: must_be_immutable
class CustomerModifyPage extends StatelessWidget{
class CustomerModifyPage extends StatelessWidget with Trans {
final _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
setContext(context);
// ignore: close_sinks
final accountBloc = BlocProvider.of<AccountBloc>(context);
// we cannot initialize the translations in the initState
@ -31,68 +30,61 @@ class CustomerModifyPage extends StatelessWidget{
});
*/
return BlocProvider(
create: (context) =>
CustomerChangeFormBloc(customerRepository: accountBloc.customerRepository),
child: Builder(builder: (context) {
// ignore: close_sinks
final customerBloc = BlocProvider.of<CustomerChangeFormBloc>(context);
create: (context) => CustomerChangeFormBloc(customerRepository: accountBloc.customerRepository),
child: Builder(builder: (context) {
// ignore: close_sinks
final customerBloc = BlocProvider.of<CustomerChangeFormBloc>(context);
return Scaffold(
resizeToAvoidBottomInset: true,
appBar: AppBar(
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("Profil"),
Image.asset(
'asset/image/WT_long_logo.png',
fit: BoxFit.cover,
height: 65.0,
return Scaffold(
resizeToAvoidBottomInset: true,
appBar: AppBar(
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("Profil"),
Image.asset(
'asset/image/WT_long_logo.png',
fit: BoxFit.cover,
height: 65.0,
),
],
),
],
),
//title: Text(AppLocalizations.of(context).translate('Settings')),
backgroundColor: Colors.transparent,
),
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('asset/image/WT_light_background.png'),
fit: BoxFit.cover,
alignment: Alignment.center,
//title: Text(AppLocalizations.of(context).translate('Settings')),
backgroundColor: Colors.transparent,
),
),
child: Form(
key: _formKey,
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
padding: EdgeInsets.only(
top: 40, left: 25, right: 45, bottom: 100),
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('asset/image/WT_light_background.png'),
fit: BoxFit.cover,
alignment: Alignment.center,
),
),
child: Form(
key: _formKey,
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
padding: EdgeInsets.only(top: 40, left: 25, right: 45, bottom: 100),
child: Container(
alignment: Alignment.center,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextFieldBlocBuilder(
key: LibraryKeys.loginEmailField,
style: TextStyle(fontSize: 12),
textFieldBloc: customerBloc.emailField,
decoration: InputDecoration(
fillColor: Colors.white24,
filled: true,
labelText: t('Email'),
),
),
child: Container(
alignment: Alignment.center,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child:
TextFieldBlocBuilder(
key: LibraryKeys.loginEmailField,
style: TextStyle(fontSize: 12),
textFieldBloc: customerBloc.emailField,
decoration: InputDecoration(
fillColor: Colors.white24,
filled: true,
labelText: AppLocalizations.of(context)
.translate('Email'),
),
),
/* TextFormField(
/* TextFormField(
style: TextStyle(fontSize: 12),
decoration: InputDecoration(
fillColor: Colors.white24,
@ -100,33 +92,29 @@ class CustomerModifyPage extends StatelessWidget{
labelText: AppLocalizations.of(context)
.translate('Email'),
), */
// initialValue: customerChangingViewModel.customer
// .customer.email,
// onFieldSubmitted: (input) =>
// customerChangingViewModel.customer.setEmail(
// input)
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child:
TextFieldBlocBuilder(
style: TextStyle(fontSize: 12),
textFieldBloc: customerBloc.passwordField,
suffixButton: SuffixButton.obscureText,
decoration: InputDecoration(
fillColor: Colors.white24,
filled: true,
labelText: AppLocalizations.of(context)
.translate('Password (Leave empty if no change)'),
),
// initialValue: customerChangingViewModel.customer
// .customer.email,
// onFieldSubmitted: (input) =>
// customerChangingViewModel.customer.setEmail(
// input)
)
],
),
/*TextFormField(
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextFieldBlocBuilder(
style: TextStyle(fontSize: 12),
textFieldBloc: customerBloc.passwordField,
suffixButton: SuffixButton.obscureText,
decoration: InputDecoration(
fillColor: Colors.white24,
filled: true,
labelText: t('Password (Leave empty if no change)'),
),
),
/*TextFormField(
style: TextStyle(fontSize: 12),
obscureText: true,
decoration: InputDecoration(
@ -139,164 +127,110 @@ class CustomerModifyPage extends StatelessWidget{
//initialValue: customerChangingViewModel.customer.customer.password,
// onFieldSubmitted: (input) => customerChangingViewModel.customer.setPassword(input)
)*/
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextFieldBlocBuilder(
style: TextStyle(fontSize: 12),
textFieldBloc: customerBloc.nameField,
decoration: InputDecoration(
fillColor: Colors.white24,
filled: true,
labelText: AppLocalizations.of(context)
.translate('Name'),
),
),
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextFieldBlocBuilder(
style: TextStyle(fontSize: 12),
textFieldBloc: customerBloc.firstNameField,
decoration: InputDecoration(
fillColor: Colors.white24,
filled: true,
labelText: AppLocalizations.of(context)
.translate('First Name'),
),
),
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextFieldBlocBuilder(
style: TextStyle(fontSize: 12),
textFieldBloc: customerBloc.birthYearField,
inputFormatters: [
WhitelistingTextInputFormatter (RegExp(r"[\d]"))
],
decoration: InputDecoration(
fillColor: Colors.white24,
filled: true,
labelText: AppLocalizations.of(context)
.translate('Birth Year'),
),
),
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextFieldBlocBuilder(
style: TextStyle(fontSize: 12),
textFieldBloc: customerBloc.weightField,
inputFormatters: [
WhitelistingTextInputFormatter (RegExp(r"[\d]"))
],
decoration: InputDecoration(
fillColor: Colors.white24,
filled: true,
labelText: AppLocalizations.of(context)
.translate('Weight'),
),
),
)
],
),
Divider(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: DropdownFieldBlocBuilder(
selectFieldBloc: customerBloc.genderField,
itemBuilder: (context, item) => item,
decoration: InputDecoration(
labelText: AppLocalizations.of(context).translate(
'Select a gender'),
)
),
)
/* child: DropdownButtonHideUnderline(
child: DropdownButton<GenderItem>(
hint: Text(
AppLocalizations.of(context).translate(
'Select a gender')),
style: TextStyle(
fontSize: 12, color: Colors.black),
focusColor: Colors.white24,
// value: selectedGender,
items: genders.map((GenderItem gender) {
return DropdownMenuItem<GenderItem>(
value: gender,
child: Text(gender.name)
);
}).toList(),
onChanged: (GenderItem gender) => {
// setState(() {
// selectedGender = gender;
// customerChangingViewModel.customer.setSex(gender.dbValue);
print ("Gender " + gender.name);
//})
//model.customer.sex =
},
)
) */
],
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextFieldBlocBuilder(
style: TextStyle(fontSize: 12),
textFieldBloc: customerBloc.nameField,
decoration: InputDecoration(
fillColor: Colors.white24,
filled: true,
labelText: t('Name'),
),
),
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextFieldBlocBuilder(
style: TextStyle(fontSize: 12),
textFieldBloc: customerBloc.firstNameField,
decoration: InputDecoration(
fillColor: Colors.white24,
filled: true,
labelText: t('First Name'),
),
),
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextFieldBlocBuilder(
style: TextStyle(fontSize: 12),
textFieldBloc: customerBloc.birthYearField,
inputFormatters: [WhitelistingTextInputFormatter(RegExp(r"[\d]"))],
decoration: InputDecoration(
fillColor: Colors.white24,
filled: true,
labelText: t('Birth Year'),
),
),
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextFieldBlocBuilder(
style: TextStyle(fontSize: 12),
textFieldBloc: customerBloc.weightField,
inputFormatters: [WhitelistingTextInputFormatter(RegExp(r"[\d]"))],
decoration: InputDecoration(
fillColor: Colors.white24,
filled: true,
labelText: t('Weight'),
),
),
)
],
),
Divider(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: DropdownFieldBlocBuilder(
selectFieldBloc: customerBloc.genderField,
itemBuilder: (context, item) => item,
decoration: InputDecoration(
labelText: t('Select a gender'),
)),
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Expanded(
child: RaisedButton(
color: Colors.orange,
textColor: Colors.white,
child: InkWell(child: Text(t("Next"))),
onPressed: () => {
customerBloc.add(SubmitFormBloc()),
Navigator.of(context)
.pushNamed("customerGoalPage", arguments: customerBloc.customerRepository)
},
))
],
),
],
),
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Expanded(
child: RaisedButton(
color: Colors.orange,
textColor: Colors.white,
child: InkWell(
child: Text(
AppLocalizations.of(context).translate(
"Next"))),
onPressed: () =>
{
customerBloc.add(SubmitFormBloc()),
Navigator.of(context).pushNamed("customerGoalPage", arguments: customerBloc.customerRepository)
},
)
)
],
),
],
),
),
),
)
)
);
})
);
),
)));
}));
}
}

View File

@ -3,10 +3,9 @@ import 'dart:collection';
import 'package:aitrainer_app/bloc/exercise_add_by_plan_bloc.dart';
import 'package:aitrainer_app/bloc/exercise_by_plan/exercise_by_plan_bloc.dart';
import 'package:aitrainer_app/localization/app_language.dart';
import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:aitrainer_app/model/workout_tree.dart';
import 'package:aitrainer_app/repository/exercise_plan_repository.dart';
import 'package:aitrainer_app/repository/exercise_repository.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/splash.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@ -18,7 +17,7 @@ class ExerciseAddByPlanPage extends StatefulWidget{
_ExerciseAddByPlanPage createState() => _ExerciseAddByPlanPage();
}
class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> {
class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> with Trans {
@override
Widget build(BuildContext context) {
@ -28,6 +27,7 @@ class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> {
final int customerId = arguments['customerId'];
final WorkoutTree workoutTree = arguments['workoutTree'];
final ExerciseRepository exerciseRepository = ExerciseRepository();
setContext(context);
return BlocProvider(
create: (context) =>
@ -155,10 +155,9 @@ class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> {
filled: false,
hintStyle: TextStyle(
fontSize: 12, color: Colors.black54, fontWeight: FontWeight.w100),
hintText: AppLocalizations.of(context)
.translate("The number of the exercise"),
hintText: t("The number of the exercise"),
labelStyle: TextStyle(fontSize: 12, color: Colors.deepOrange, fontWeight: FontWeight.normal),
labelText: "Please repeat with " + exerciseBloc.unitQuantity1Field.value + " " +
labelText: t("Please repeat with ") + exerciseBloc.unitQuantity1Field.value + " " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit + " " +
exerciseBloc.exercisePlanRepository.actualPlanDetail.repeats.toString() + " times!",
),
@ -201,7 +200,7 @@ class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> {
}
},
child: Text(
AppLocalizations.of(context).translate("Check"),
t("Check"),
style: TextStyle(fontSize: 12),)
),
Divider(color: Colors.transparent,),
@ -213,8 +212,7 @@ class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> {
}
String validateNumberInput(input) {
String error = AppLocalizations.of(context).translate(
"Please type the right quantity 0-10000");
String error = t("Please type the right quantity 0-10000");
dynamic rc = (input != null && input.length > 0);
if (!rc) {
return null;

View File

@ -11,12 +11,11 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
class ExerciseControlPage extends StatefulWidget{
class ExerciseControlPage extends StatefulWidget {
_ExerciseControlPage createState() => _ExerciseControlPage();
}
class _ExerciseControlPage extends State<ExerciseControlPage> {
@override
Widget build(BuildContext context) {
LinkedHashMap arguments = ModalRoute.of(context).settings.arguments;
@ -25,27 +24,25 @@ class _ExerciseControlPage extends State<ExerciseControlPage> {
final bool readonly = arguments['readonly'];
return BlocProvider(
create: (context) =>
ExerciseControlFormBloc(exerciseRepository: exerciseRepository, percentToCalculate: percent, readonly: readonly),
child: BlocBuilder<ExerciseControlFormBloc, FormBlocState>(
builder: (context, state) {
create: (context) => ExerciseControlFormBloc(
exerciseRepository: exerciseRepository, percentToCalculate: percent, readonly: readonly),
child: BlocBuilder<ExerciseControlFormBloc, FormBlocState>(builder: (context, state) {
// ignore: close_sinks
final exerciseBloc = BlocProvider.of<ExerciseControlFormBloc>(context);
if ( state is FormBlocLoading ) {
if (state is FormBlocLoading) {
return LoadingDialog();
} else if ( state is FormBlocSuccess) {
} else if (state is FormBlocSuccess) {
return getControlForm(exerciseBloc);
} else {
return getControlForm(exerciseBloc);
}
}
));
}));
}
Form getControlForm( ExerciseControlFormBloc exerciseBloc) {
String exerciseName = AppLanguage().appLocal == Locale("en") ?
exerciseBloc.exerciseRepository.exerciseType.name :
exerciseBloc.exerciseRepository.exerciseType.nameTranslation;
Form getControlForm(ExerciseControlFormBloc exerciseBloc) {
String exerciseName = AppLanguage().appLocal == Locale("en")
? exerciseBloc.exerciseRepository.exerciseType.name
: exerciseBloc.exerciseRepository.exerciseType.nameTranslation;
return Form(
autovalidate: true,
@ -70,227 +67,200 @@ class _ExerciseControlPage extends State<ExerciseControlPage> {
),
),
body: Container(
width: MediaQuery
.of(context)
.size
.width,
height: MediaQuery
.of(context)
.size
.height,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('asset/image/WT_light_background.png'),
fit: BoxFit.fill,
alignment: Alignment.center,
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('asset/image/WT_light_background.png'),
fit: BoxFit.fill,
alignment: Alignment.center,
),
),
),
child: Container(
padding: const EdgeInsets.only (top: 25, left: 25, right: 25),
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Text(exerciseName,
style: TextStyle(fontWeight: FontWeight.bold,
fontSize: 18,
color: Colors.deepOrange),
overflow: TextOverflow.fade,
maxLines: 1,
softWrap: true,
),
FlatButton(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
child: Container(
padding: const EdgeInsets.only(top: 25, left: 25, right: 25),
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[
Text(
exerciseName,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: Colors.deepOrange),
overflow: TextOverflow.fade,
maxLines: 1,
softWrap: true,
),
FlatButton(
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Icon(Icons.question_answer),
Text(AppLocalizations.of(context).translate(
"Why do you need Exercise Control?"),
style: TextStyle(
color: Colors.blueAccent,
fontWeight: FontWeight.normal,
fontSize: 14)),
Text(AppLocalizations.of(context).translate("Why do you need Exercise Control?"),
style: TextStyle(color: Colors.blueAccent, fontWeight: FontWeight.normal, fontSize: 14)),
Icon(Icons.arrow_forward_ios),
]),
textColor: Colors.blueAccent,
color: Colors.transparent,
onPressed: () =>
{
//Navigator.of(context).pushNamed('exerciseTypeDescription', arguments: exerciseBloc.exerciseRepository),
},
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(AppLocalizations.of(context).translate("Your 1RM:"),),
Text(" " + exerciseBloc.initialRMField.value + " " +exerciseBloc.exerciseRepository.exerciseType
.unitQuantityUnit,
style: TextStyle(fontWeight: FontWeight.bold),),
],
),
Divider(),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(AppLocalizations.of(context).translate("1st Control Exercise:"),
style: TextStyle(),),
TextFieldBlocBuilder(
readOnly: exerciseBloc.step != 1,
textFieldBloc: exerciseBloc.quantity1Field,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14,
color: Colors.deepOrange,
fontWeight: FontWeight.bold),
inputFormatters: [
WhitelistingTextInputFormatter (RegExp(r"[\d.]"))
],
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, fontWeight: FontWeight.normal),
labelText: "Please repeat with " + exerciseBloc.unitQuantity1Field.value + " " + exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit + " 12 times!",
textColor: Colors.blueAccent,
color: Colors.transparent,
onPressed: () => {
//Navigator.of(context).pushNamed('exerciseTypeDescription', arguments: exerciseBloc.exerciseRepository),
},
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
AppLocalizations.of(context).translate("Your 1RM:"),
),
),
RaisedButton(
padding: EdgeInsets.all(0),
textColor: Colors.white,
color: exerciseBloc.step == 1 ? Colors.blue : Colors.black26,
focusColor: Colors.blueAccent,
onPressed: () =>
{
exerciseBloc.submit()
},
child: Text(
AppLocalizations.of(context).translate("Check"),
style: TextStyle(fontSize: 12),)
),
],
),
Divider(),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(AppLocalizations.of(context).translate("2nd Control Exercise:"),
style: TextStyle(),),
TextFieldBlocBuilder(
readOnly: exerciseBloc.step != 2,
textFieldBloc: exerciseBloc.quantity2Field,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14,
color: Colors.deepOrange,
fontWeight: FontWeight.bold),
inputFormatters: [
WhitelistingTextInputFormatter (RegExp(r"[\d.]"))
],
onChanged: (input) => {
print("Quantity 2 value $input"),
//exerciseBloc.exerciseRepository.setQuantity(double.parse(input)),
//exerciseBloc.exerciseRepository
// .setUnit(exerciseBloc.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, fontWeight: FontWeight.normal),
labelText: "Please repeat with " + exerciseBloc.unitQuantity2Field.value + " " + exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit + " 12 times!",
Text(
" " +
exerciseBloc.initialRMField.value +
" " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit,
style: TextStyle(fontWeight: FontWeight.bold),
),
),
RaisedButton(
padding: EdgeInsets.all(0),
textColor: Colors.white,
color: exerciseBloc.step == 2 ? Colors.blue : Colors.black26,
focusColor: Colors.blueAccent,
onPressed: () =>
{
exerciseBloc.submit()
},
child: Text(
AppLocalizations.of(context).translate("Check"),
style: TextStyle(fontSize: 12),)
),
],
),
Divider(),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(AppLocalizations.of(context).translate("3rd Control Exercise:"),
style: TextStyle(),),
TextFieldBlocBuilder(
readOnly: exerciseBloc.step != 3,
textFieldBloc: exerciseBloc.quantity3Field,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14,
color: Colors.deepOrange,
fontWeight: FontWeight.bold),
inputFormatters: [
WhitelistingTextInputFormatter (RegExp(r"[\d.]"))
],
onChanged: (input) => {
print("Quantity 3 value $input"),
//exerciseBloc.exerciseRepository.setQuantity(double.parse(input)),
//exerciseBloc.exerciseRepository
// .setUnit(exerciseBloc.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, fontWeight: FontWeight.normal),
labelText: "Please repeat with " + exerciseBloc.unitQuantity3Field.value + " " + exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit + " 12 times!",
],
),
Divider(),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
AppLocalizations.of(context).translate("1st Control Exercise:"),
style: TextStyle(),
),
),
RaisedButton(
padding: EdgeInsets.all(0),
textColor: Colors.white,
color: exerciseBloc.step == 3 ? Colors.blue : Colors.black26,
focusColor: Colors.blueAccent,
onPressed: () =>
{
exerciseBloc.submit()
},
child: Text(
AppLocalizations.of(context).translate("Check"),
style: TextStyle(fontSize: 12),)
),
],
),
]),
)
)
),
TextFieldBlocBuilder(
readOnly: exerciseBloc.step != 1,
textFieldBloc: exerciseBloc.quantity1Field,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14, color: Colors.deepOrange, fontWeight: FontWeight.bold),
inputFormatters: [WhitelistingTextInputFormatter(RegExp(r"[\d.]"))],
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, fontWeight: FontWeight.normal),
labelText: "Please repeat with " +
exerciseBloc.unitQuantity1Field.value +
" " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit +
" " +
exerciseBloc.times +
" times!",
),
),
RaisedButton(
padding: EdgeInsets.all(0),
textColor: Colors.white,
color: exerciseBloc.step == 1 ? Colors.blue : Colors.black26,
focusColor: Colors.blueAccent,
onPressed: () => {exerciseBloc.submit()},
child: Text(
AppLocalizations.of(context).translate("Check"),
style: TextStyle(fontSize: 12),
)),
],
),
Divider(),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
AppLocalizations.of(context).translate("2nd Control Exercise:"),
style: TextStyle(),
),
TextFieldBlocBuilder(
readOnly: exerciseBloc.step != 2,
textFieldBloc: exerciseBloc.quantity2Field,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14, color: Colors.deepOrange, fontWeight: FontWeight.bold),
inputFormatters: [WhitelistingTextInputFormatter(RegExp(r"[\d.]"))],
onChanged: (input) => {
print("Quantity 2 value $input"),
//exerciseBloc.exerciseRepository.setQuantity(double.parse(input)),
//exerciseBloc.exerciseRepository
// .setUnit(exerciseBloc.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, fontWeight: FontWeight.normal),
labelText: "Please repeat with " +
exerciseBloc.unitQuantity2Field.value +
" " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit +
" 12 times!",
),
),
RaisedButton(
padding: EdgeInsets.all(0),
textColor: Colors.white,
color: exerciseBloc.step == 2 ? Colors.blue : Colors.black26,
focusColor: Colors.blueAccent,
onPressed: () => {exerciseBloc.submit()},
child: Text(
AppLocalizations.of(context).translate("Check"),
style: TextStyle(fontSize: 12),
)),
],
),
Divider(),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
AppLocalizations.of(context).translate("3rd Control Exercise:"),
style: TextStyle(),
),
TextFieldBlocBuilder(
readOnly: exerciseBloc.step != 3,
textFieldBloc: exerciseBloc.quantity3Field,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14, color: Colors.deepOrange, fontWeight: FontWeight.bold),
inputFormatters: [WhitelistingTextInputFormatter(RegExp(r"[\d.]"))],
onChanged: (input) => {
print("Quantity 3 value $input"),
//exerciseBloc.exerciseRepository.setQuantity(double.parse(input)),
//exerciseBloc.exerciseRepository
// .setUnit(exerciseBloc.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, fontWeight: FontWeight.normal),
labelText: "Please repeat with " +
exerciseBloc.unitQuantity3Field.value +
" " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit +
" 12 times!",
),
),
RaisedButton(
padding: EdgeInsets.all(0),
textColor: Colors.white,
color: exerciseBloc.step == 3 ? Colors.blue : Colors.black26,
focusColor: Colors.blueAccent,
onPressed: () => {exerciseBloc.submit()},
child: Text(
AppLocalizations.of(context).translate("Check"),
style: TextStyle(fontSize: 12),
)),
],
),
]),
))),
),
);
}
String validateNumberInput(input) {
String error = AppLocalizations.of(context).translate(
"Please type the right quantity 0-10000");
String error = AppLocalizations.of(context).translate("Please type the right quantity 0-10000");
dynamic rc = (input != null && input.length > 0);
if (!rc) {
return null;
@ -307,7 +277,6 @@ class _ExerciseControlPage extends State<ExerciseControlPage> {
return error;
}
if (!(double.parse(input) < 10000 && double.parse(input) > 0)) {
return error;
}

View File

@ -1,12 +1,12 @@
import 'dart:collection';
import 'package:aitrainer_app/localization/app_language.dart';
import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/model/exercise.dart';
import 'package:aitrainer_app/model/exercise_type.dart';
import 'package:aitrainer_app/repository/customer_repository.dart';
import 'package:aitrainer_app/repository/exercise_repository.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/app_bar_common.dart';
import 'package:flutter/material.dart';
import 'package:flutter_treeview/tree_view.dart';
@ -16,13 +16,14 @@ class ExerciseLogPage extends StatefulWidget {
_ExerciseLogPage createState() => _ExerciseLogPage();
}
class _ExerciseLogPage extends State<ExerciseLogPage> {
class _ExerciseLogPage extends State<ExerciseLogPage> with Trans {
@override
Widget build(BuildContext context) {
LinkedHashMap arguments = ModalRoute.of(context).settings.arguments;
final ExerciseRepository exerciseRepository = arguments['exerciseRepository'];
final CustomerRepository customerRepository = arguments['customerRepository'];
final int customerId = arguments['customerId'];
setContext(context);
return Scaffold(
appBar: AppBarCommonNav(),
@ -126,8 +127,7 @@ class _ExerciseLogPage extends State<ExerciseLogPage> {
String unitQuantity = exerciseType.unitQuantity == "1"
? exercise.unitQuantity.toStringAsFixed(0) +
" " +
AppLocalizations.of(context)
.translate(exerciseType.unitQuantityUnit) +
t(exerciseType.unitQuantityUnit) +
" "
: "";
@ -136,7 +136,7 @@ class _ExerciseLogPage extends State<ExerciseLogPage> {
unitQuantity +
exercise.quantity.toStringAsFixed(0) +
" " +
AppLocalizations.of(context).translate(exercise.unit);
t(exercise.unit);
listExercisesPerDay.add(Node(
label: labelExercise,
key: exercise.exerciseId.toString(),

View File

@ -56,8 +56,6 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> {
),
child: BlocConsumer<ExercisePlanBloc, ExercisePlanState>(listener: (context, state) {
if (state is ExercisePlanError) {
//showInSnackBar(state.message);
//return exerciseWidget(bloc);
Scaffold.of(context).showSnackBar(SnackBar(
content: Text(
state.message,

View File

@ -1,9 +1,9 @@
import 'package:aitrainer_app/bloc/exercise_plan/exercise_plan_bloc.dart';
import 'package:aitrainer_app/bloc/exercise_plan_custom_form.dart';
import 'package:aitrainer_app/localization/app_language.dart';
import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:aitrainer_app/repository/exercise_plan_repository.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/app_bar_common.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@ -16,15 +16,17 @@ class ExercisePlanDetailAddPage extends StatefulWidget {
_ExercisePlanDetailAddPage createState() => _ExercisePlanDetailAddPage();
}
class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> {
class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> with Trans {
@override
Widget build(BuildContext context) {
// ignore: close_sinks
final ExercisePlanBloc planBloc = ModalRoute.of(context).settings.arguments;
final ExercisePlanRepository exercisePlanRepository = planBloc.exercisePlanRepository;
setContext(context);
return BlocProvider(
create: (context) => ExercisePlanCustomerFormBloc(exercisePlanRepository: exercisePlanRepository, planBloc: planBloc),
create: (context) =>
ExercisePlanCustomerFormBloc(exercisePlanRepository: exercisePlanRepository, planBloc: planBloc),
child: Builder(builder: (context) {
// ignore: close_sinks
final bloc = BlocProvider.of<ExercisePlanCustomerFormBloc>(context);
@ -88,7 +90,8 @@ class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> {
fillColor: Colors.white,
filled: false,
hintStyle: TextStyle(fontSize: 16, color: Colors.black54, fontWeight: FontWeight.w100),
hintText: AppLocalizations.of(context).translate("The number of the repeats of one serie"),
hintText:
AppLocalizations.of(context).translate("The number of the repeats of one serie"),
labelStyle: TextStyle(fontSize: 16, color: Colors.lightBlue),
labelText: AppLocalizations.of(context).translate("Repeats"),
),
@ -116,10 +119,12 @@ class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> {
focusColor: Colors.white,
onPressed: () => {
print("Remove " + bloc.exercisePlanRepository.actualPlanDetail.exerciseType.name),
planBloc.add(ExercisePlanRemoveExercise(exercisePlanDetail: bloc.exercisePlanRepository.actualPlanDetail)),
planBloc.add(ExercisePlanRemoveExercise(
exercisePlanDetail: bloc.exercisePlanRepository.actualPlanDetail)),
Navigator.of(context).pop(),
},
child: Text("Delete"), //Text(AppLocalizations.of(context).translate("Delete"), style: TextStyle(fontSize: 16),)
child: Text(t(
"Delete")), //Text(AppLocalizations.of(context).translate("Delete"), style: TextStyle(fontSize: 16),)
),
RaisedButton(
textColor: Colors.white,
@ -129,9 +134,7 @@ class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> {
bloc.submit(),
Navigator.of(context).pop(),
},
child: Text(
AppLocalizations.of(context).translate("Save"),
style: TextStyle(fontSize: 16),
child: Text(t("Save"), style: TextStyle(fontSize: 16),
)),
],
),

View File

@ -24,12 +24,6 @@ class _MenuPage extends State<MenuPage> {
// ignore: close_sinks
MenuBloc menuBloc;
void checkTest() {
}
@override
Widget build(BuildContext context) {
menuBloc = BlocProvider.of<MenuBloc>(context);
@ -48,7 +42,7 @@ class _MenuPage extends State<MenuPage> {
if (state is MenuError) {
Scaffold.of(context).showSnackBar(SnackBar(
backgroundColor: Colors.orange,
content: Text("error", style: TextStyle(color: Colors.white))));
content: Text(state.message, style: TextStyle(color: Colors.white))));
} else if ( state is MenuLoading ) {
return MenuPageWidget();
}
@ -88,6 +82,7 @@ class _LoadingMenuDialog extends State<LoadingMenuDialog> {
BlocProvider.of<MenuBloc>(context).add(MenuCreate());
});
}
@override
Widget build(BuildContext context) {
return WillPopScope(

View File

@ -3,6 +3,7 @@ import 'dart:collection';
import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/repository/customer_repository.dart';
import 'package:aitrainer_app/repository/exercise_repository.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/app_bar_common.dart';
import 'package:aitrainer_app/widgets/bottom_nav.dart';
import 'package:flutter/cupertino.dart';
@ -13,12 +14,13 @@ class MyDevelopmentPage extends StatefulWidget {
_MyDevelopmentPage createState() => _MyDevelopmentPage();
}
class _MyDevelopmentPage extends State<MyDevelopmentPage> {
class _MyDevelopmentPage extends State<MyDevelopmentPage> with Trans {
@override
Widget build(BuildContext context) {
final ExerciseRepository exerciseRepository = ExerciseRepository();
final CustomerRepository customerRepository = CustomerRepository();
final LinkedHashMap args = LinkedHashMap();
setContext(context);
return Scaffold(
appBar: AppBarCommonNav(),
@ -51,7 +53,7 @@ class _MyDevelopmentPage extends State<MyDevelopmentPage> {
Navigator.of(context).pushNamed('exerciseLogPage',
arguments: args)
},
child: Text("My Exercise Logs",
child: Text(t("My Exercise Logs"),
style: TextStyle(fontSize: 18),)
),
Stack(
@ -71,7 +73,7 @@ class _MyDevelopmentPage extends State<MyDevelopmentPage> {
onPressed: () =>
{
},
child: Text("My Whole Body Development",
child: Text(t("My Whole Body Development"),
style: TextStyle(fontSize: 18),)
),
@ -94,7 +96,7 @@ class _MyDevelopmentPage extends State<MyDevelopmentPage> {
onPressed: () =>
{
},
child: Text("Development Of Muscles",
child: Text(t("Development Of Muscles"),
style: TextStyle(fontSize: 18),)
),
@ -117,7 +119,7 @@ class _MyDevelopmentPage extends State<MyDevelopmentPage> {
onPressed: () =>
{
},
child: Text("Predictions",
child: Text(t("Predictions"),
style: TextStyle(fontSize: 18),)
),
]
@ -154,7 +156,7 @@ class _MyDevelopmentPage extends State<MyDevelopmentPage> {
Navigator.of(context).pushNamed('exerciseLogPage',
arguments: args)
},
child: Text("My Trainee's Exercise Logs",
child: Text(t("My Trainee's Exercise Logs"),
style: TextStyle(fontSize: 18),)
);
} else {

View File

@ -1,6 +1,7 @@
import 'dart:collection';
import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/repository/exercise_repository.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/app_bar_common.dart';
import 'package:aitrainer_app/widgets/bottom_nav.dart';
import 'package:flutter/cupertino.dart';
@ -11,11 +12,12 @@ class MyExercisePlanPage extends StatefulWidget {
_MyExercisePlanPage createState() => _MyExercisePlanPage();
}
class _MyExercisePlanPage extends State<MyExercisePlanPage> {
class _MyExercisePlanPage extends State<MyExercisePlanPage> with Trans {
@override
Widget build(BuildContext context) {
final ExerciseRepository exerciseRepository = ExerciseRepository();
final LinkedHashMap args = LinkedHashMap();
setContext(context);
return Scaffold(
appBar: AppBarCommonNav(),
@ -46,7 +48,7 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> {
Navigator.of(context).pushNamed('exerciseByPlanPage',
arguments: args)
},
child: Text("Execute My Selected Training Plan",
child: Text(t("Execute My Selected Training Plan"),
style: TextStyle(fontSize: 18),)
),
@ -62,7 +64,7 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> {
Navigator.of(context).pushNamed('exercisePlanCustomPage',
arguments: args)
},
child: Text("Edit My Custom Plan",
child: Text(t("Edit My Custom Plan"),
style: TextStyle(fontSize: 18),)
),
FlatButton(
@ -74,7 +76,7 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> {
{
},
child: Text("Suggested Plan",
child: Text(t("Suggested Training Plan"),
style: TextStyle(fontSize: 18),)
),
Stack(
@ -95,7 +97,7 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> {
{
},
child: Text("My Special Plan",
child: Text(t("My Special Plan"),
style: TextStyle(fontSize: 18),)
),
@ -119,7 +121,7 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> {
{
},
child: Text("My Arnold's Plan",
child: Text(t("My Arnold's Plan"),
style: TextStyle(fontSize: 18),)
),
@ -160,7 +162,7 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> {
Navigator.of(context).pushNamed('exercisePlanCustomPage',
arguments: args)
},
child: Text("My Trainee's Plan",
child: Text(t("My Trainee's Plan"),
style: TextStyle(fontSize: 18),)
);
} else {
@ -183,7 +185,7 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> {
Navigator.of(context).pushNamed('exerciseByPlanPage',
arguments: args)
},
child: Text("Execute My Trainee's Training Plan",
child: Text(t("Execute My Trainee's Training Plan"),
style: TextStyle(fontSize: 18),)
);
} else {

View File

@ -1,6 +1,5 @@
import 'dart:async';
import 'package:aitrainer_app/animations/test_progress_animation.dart';
import 'package:aitrainer_app/bloc/menu/menu_bloc.dart';
import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:aitrainer_app/model/cache.dart';
@ -12,7 +11,7 @@ import 'package:percent_indicator/linear_percent_indicator.dart';
import 'package:rainbow_color/rainbow_color.dart';
class AppBarNav extends StatefulWidget implements PreferredSizeWidget {
class AppBarNav extends StatefulWidget implements PreferredSizeWidget {
final MenuBloc menuBloc;
const AppBarNav({this.menuBloc});
@ -86,6 +85,8 @@ class _AppBarNav extends State<AppBarNav> with SingleTickerProviderStateMixin {
@override
Widget build(BuildContext context) {
menuBloc = BlocProvider.of<MenuBloc>(context);
//setContext(context);
return AppBar(
backgroundColor: Colors.black,
title: Row(
@ -128,11 +129,13 @@ class _AppBarNav extends State<AppBarNav> with SingleTickerProviderStateMixin {
}
int sizeExerciseList = Cache().getExercises() == null? 0 : Cache().getExercises().length;
if ( sizeExerciseList == 0 ) {
String text = AppLocalizations.of(context).translate("Make your first test");
double fontSize = text.length > 15 ? 10 : 16;
return Stack(
alignment: Alignment.topLeft,
children: [
Text(AppLocalizations.of(context).translate("Make your first test"),
style: TextStyle(fontSize: 16, color: colorAnim.value, shadows: [Shadow(color: Colors.purple , blurRadius: 15)]),
Text(text,
style: TextStyle(fontSize: fontSize, color: colorAnim.value, shadows: [Shadow(color: Colors.purple , blurRadius: 15)]),
),
//TestProgress(animation: sizeAnim),

View File

@ -97,11 +97,13 @@ class _AppBarCommonNav extends State<AppBarCommonNav> with SingleTickerProvider
}
int sizeExerciseList = Cache().getExercises() == null? 0 : Cache().getExercises().length;
if ( sizeExerciseList == 0 ) {
String text = AppLocalizations.of(context).translate("Make your first test");
double fontSize = text.length > 17 ? 10 : 16;
return Stack(
alignment: Alignment.topLeft,
children: [
Text(AppLocalizations.of(context).translate("Make your first test"),
style: TextStyle(fontSize: 16, color: colorAnim.value, shadows: [Shadow(color: Colors.purple , blurRadius: 15)]),
Text(text,
style: TextStyle(fontSize: fontSize, color: colorAnim.value, shadows: [Shadow(color: Colors.purple , blurRadius: 15)]),
),
//TestProgress(animation: sizeAnim),

View File

@ -36,17 +36,18 @@ class _HomePageState extends State<AitrainerHome> {
}
Future runDelayedEvent() async {
await Future.delayed(Duration(seconds: 3), () async {
await Future.delayed(Duration(seconds: 2), () async {
if ( context != null) {
// ignore: close_sinks
SessionBloc sessionBloc = BlocProvider.of<SessionBloc>(context);
if (sessionBloc.state != SessionReady()) {
sessionBloc.add(SessionStart());
// ignore: close_sinks
SettingsBloc settingsBloc = BlocProvider.of<SettingsBloc>(context);
String lang = AppLanguage().appLocal.languageCode;
print (" -- Loading delayed lang $lang");
settingsBloc.add(SettingsChangeLanguage(language: lang));
settingsBloc.context = context;
sessionBloc.add(SessionStart(settingsBloc: settingsBloc));
//String lang = AppLanguage().appLocal.languageCode;
//print (" -- Loading delayed lang $lang");
//settingsBloc.add(SettingsChangeLanguage(language: lang));
}
}
});
@ -59,7 +60,12 @@ class _HomePageState extends State<AitrainerHome> {
child: BlocConsumer<SessionBloc, SessionState>(
listener: (context, state) {
if ( state is SessionFailure) {
Scaffold.of(context).showSnackBar(SnackBar(
content: Text(
state.message,
),
backgroundColor: Colors.orange,
));
}
},
builder: (context, state) {
@ -69,7 +75,7 @@ class _HomePageState extends State<AitrainerHome> {
print("loading");
return LoadingScreenMain();
} else if (state is SessionReady) {
print("ready");
print("ready menu with " + Cache().startPage);
if (Cache().startPage == 'login') {
return LoginPage();
} else if (Cache().startPage == 'registration') {

View File

@ -37,7 +37,7 @@ class MenuPageWidget extends StatelessWidget {
child: Center(
child: Stack(
alignment: Alignment.bottomLeft,
clipBehavior: Clip.antiAliasWithSaveLayer,
//clipBehavior: Clip.antiAliasWithSaveLayer,
children: [
FlatButton(
child: _getButtonImage(workoutTree),
@ -46,7 +46,7 @@ class MenuPageWidget extends StatelessWidget {
onPressed: () => menuClick(workoutTree, menuBloc, context),
),
Positioned(
top: workoutTree.name.length > 30 ? 140 : 150,
top: workoutTree.name.length > 15 ? 140 : 150,
left: 5,
child: Container(
height: 300,

View File

@ -35,7 +35,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.1"
version: "2.4.2"
bloc:
dependency: transitive
description:
@ -113,6 +113,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "7.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
charcode:
dependency: transitive
description:
@ -134,6 +141,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
code_builder:
dependency: transitive
description:
@ -147,7 +161,7 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.12"
version: "1.14.13"
convert:
dependency: transitive
description:
@ -161,14 +175,14 @@ packages:
name: coverage
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.11"
version: "0.14.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
version: "2.1.5"
csslib:
dependency: transitive
description:
@ -204,13 +218,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.5"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "5.1.0"
version: "5.2.1"
fixnum:
dependency: transitive
description:
@ -380,7 +401,7 @@ packages:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.12"
version: "2.1.14"
intl:
dependency: "direct dev"
description:
@ -415,7 +436,7 @@ packages:
name: json_rpc_2
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.2.1"
logging:
dependency: transitive
description:
@ -429,7 +450,7 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.6"
version: "0.12.8"
meta:
dependency: transitive
description:
@ -451,13 +472,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.1"
multi_server_socket:
dependency: transitive
description:
name: multi_server_socket
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
nested:
dependency: transitive
description:
@ -499,7 +513,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
version: "1.7.0"
path_provider_linux:
dependency: transitive
description:
@ -534,7 +548,7 @@ packages:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
version: "3.0.4"
platform:
dependency: transitive
description:
@ -562,7 +576,7 @@ packages:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.12"
version: "3.0.13"
provider:
dependency: transitive
description:
@ -728,7 +742,7 @@ packages:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.3"
version: "1.9.5"
stream_channel:
dependency: transitive
description:
@ -770,21 +784,21 @@ packages:
name: test
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.4"
version: "1.15.2"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.15"
version: "0.2.17"
test_core:
dependency: transitive
description:
name: test_core
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.4"
version: "0.3.10"
timing:
dependency: transitive
description:
@ -798,7 +812,7 @@ packages:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
version: "1.2.0"
usage:
dependency: transitive
description:
@ -875,7 +889,7 @@ packages:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.1"
version: "4.2.0"
yaml:
dependency: transitive
description:
@ -884,5 +898,5 @@ packages:
source: hosted
version: "2.2.1"
sdks:
dart: ">=2.7.0 <3.0.0"
dart: ">=2.9.0-14.0.dev <3.0.0"
flutter: ">=1.16.0 <2.0.0"

View File

@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.1.0+20
version: 1.1.0+21
environment:
sdk: ">=2.7.0 <3.0.0"
@ -33,7 +33,7 @@ dependencies:
flutter_local_notifications: 1.1.1
flutter_facebook_login: ^3.0.0
flutter_bloc: ^6.0.5
equatable: ^1.2.4
equatable: ^1.2.5
freezed: ^0.11.6
flutter_form_bloc: ^0.19.0
spider_chart: ^0.1.5
@ -51,7 +51,7 @@ dev_dependencies:
flutter_driver:
sdk: flutter
test: any
bloc_test: ^7.0.3
bloc_test: ^7.0.4
build_runner: