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?", "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": "The number of the exercise",
"The number of the exercise done with": "The number of the exercise done with", "The number of the exercise done with": "The number of the exercise done with",
"Please repeat with ": "Please repeat with ",
"repeat": "repeat", "repeat": "repeat",
@ -134,5 +135,19 @@
"5. Shoulders": "5. Shoulders", "5. Shoulders": "5. Shoulders",
"6. Core": "6. Core", "6. Core": "6. Core",
"7. Thigh": "7. Thigh", "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", "Delete": "Törlés",
"The number of the exercise": "Írd be a gyakorlat számát", "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", "The number of the exercise done with": "Írd be, mennyivel csináltad a gyakorlatot",
"Please repeat with ": "Kérlek ismételd",
"Name": "Név", "Name": "Név",
@ -134,5 +135,19 @@
"5. Shoulders": "5. Váll", "5. Shoulders": "5. Váll",
"6. Core": "6. Has", "6. Core": "6. Has",
"7. Thigh": "7. Comb", "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/model/workout_tree.dart';
import 'package:aitrainer_app/repository/exercise_plan_repository.dart'; import 'package:aitrainer_app/repository/exercise_plan_repository.dart';
import 'package:aitrainer_app/repository/exercise_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:bloc/bloc.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
@ -14,7 +14,7 @@ part 'exercise_by_plan_state.dart';
class ExerciseByPlanBloc extends Bloc<ExerciseByPlanEvent, ExerciseByPlanState> { class ExerciseByPlanBloc extends Bloc<ExerciseByPlanEvent, ExerciseByPlanState> {
final ExerciseRepository exerciseRepository; final ExerciseRepository exerciseRepository;
final MenuTreeRepository menuTreeRepository; final WorkoutTreeRepository menuTreeRepository;
final ExercisePlanRepository exercisePlanRepository = ExercisePlanRepository(); final ExercisePlanRepository exercisePlanRepository = ExercisePlanRepository();
int customerId; int customerId;
@override @override

View File

@ -7,6 +7,7 @@ class ExerciseControlFormBloc extends FormBloc<String, String> {
int step = 1; int step = 1;
final double percentToCalculate; final double percentToCalculate;
final bool readonly; final bool readonly;
String times;
final initialRMField = TextFieldBloc( final initialRMField = TextFieldBloc(
); );
@ -63,6 +64,8 @@ class ExerciseControlFormBloc extends FormBloc<String, String> {
exerciseRepository.setUnitQuantity(unitQuantity3Field.valueToDouble); exerciseRepository.setUnitQuantity(unitQuantity3Field.valueToDouble);
}); });
times = percentToCalculate == 0.5 ? "30-35" : "12";
} }
@override @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/model/workout_tree.dart';
import 'package:aitrainer_app/repository/exercise_plan_repository.dart'; import 'package:aitrainer_app/repository/exercise_plan_repository.dart';
import 'package:aitrainer_app/repository/exercise_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:bloc/bloc.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
@ -14,7 +14,7 @@ part 'exercise_plan_event.dart';
part 'exercise_plan_state.dart'; part 'exercise_plan_state.dart';
class ExercisePlanBloc extends Bloc<ExercisePlanEvent, ExercisePlanState> { class ExercisePlanBloc extends Bloc<ExercisePlanEvent, ExercisePlanState> {
final MenuTreeRepository menuTreeRepository; final WorkoutTreeRepository menuTreeRepository;
final ExerciseRepository exerciseRepository; final ExerciseRepository exerciseRepository;
final ExercisePlanRepository exercisePlanRepository = ExercisePlanRepository(); final ExercisePlanRepository exercisePlanRepository = ExercisePlanRepository();
int customerId; int customerId;

View File

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

View File

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

View File

@ -9,8 +9,10 @@ abstract class SessionEvent extends Equatable {
} }
class SessionStart extends SessionEvent { class SessionStart extends SessionEvent {
const SessionStart(); final SettingsBloc settingsBloc;
const SessionStart({this.settingsBloc});
@override @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{ Future<void> _changeLang( String lang ) async{
print("_change to $lang");
switch ( lang ) { switch ( lang ) {
case "English": case "English":
case "en":
case "Angol": case "Angol":
_locale = Locale('en'); _locale = Locale('en');
break; break;
case "Hungarian": case "Hungarian":
case "Magyar": case "Magyar":
case "hu":
_locale = Locale('hu'); _locale = Locale('hu');
break; break;
} }
this.language = lang; this.language = lang;
final AppLanguage appLanguage = AppLanguage(); AppLanguage().changeLanguage(_locale);
appLanguage.changeLanguage(_locale);
await loadLang(); await loadLang();
} }
Future<void> loadLang() async{ Future<void> loadLang() async{
if ( _locale != null ) {
print(" -- Loading lang $_locale"); print(" -- Loading lang $_locale");
if (context != null) { if (context != null) {
AppLocalizations.of(context).setLocale(_locale); AppLocalizations.of(context).setLocale(_locale);
await AppLocalizations.of(context).load(); 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 'dart:async';
import 'package:aitrainer_app/repository/customer_repository.dart'; import 'package:aitrainer_app/repository/customer_repository.dart';
import 'package:aitrainer_app/repository/exercise_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/util/session.dart';
import 'package:aitrainer_app/view/account.dart'; import 'package:aitrainer_app/view/account.dart';
import 'package:aitrainer_app/view/custom_exercise_page.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://api.dartlang.org/stable/1.24.2/dart-async/Zone-class.html
// - https://www.dartlang.org/articles/libraries/zones // - https://www.dartlang.org/articles/libraries/zones
runZonedGuarded<Future<Null>>(() async { runZonedGuarded<Future<Null>>(() async {
final MenuTreeRepository menuTreeRepository = MenuTreeRepository(); final WorkoutTreeRepository menuTreeRepository = WorkoutTreeRepository();
runApp( runApp(
MultiBlocProvider( MultiBlocProvider(
providers: [ providers: [

View File

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

View File

@ -28,7 +28,7 @@ class Antagonist {
static int calfNr = 8; static int calfNr = 8;
} }
class MenuTreeRepository { class WorkoutTreeRepository {
final LinkedHashMap tree = LinkedHashMap<String, WorkoutTree>(); final LinkedHashMap tree = LinkedHashMap<String, WorkoutTree>();
SplayTreeMap sortedTree = SplayTreeMap<String, List<WorkoutTree>>(); SplayTreeMap sortedTree = SplayTreeMap<String, List<WorkoutTree>>();
bool isEnglish; bool isEnglish;
@ -45,9 +45,9 @@ class MenuTreeRepository {
}; };
Future<void> createTree() async { Future<void> createTree() async {
final AppLanguage appLanguage = AppLanguage();
isEnglish = appLanguage.appLocal == Locale('en'); isEnglish = AppLanguage().appLocal == Locale('en');
print("** Start creating tree on lang: " + appLanguage.appLocal.toString()); print("** Start creating tree on lang: " + AppLanguage().appLocal.languageCode);
List<ExerciseTree> exerciseTree = Cache().getExerciseTree(); List<ExerciseTree> exerciseTree = Cache().getExerciseTree();
if ( exerciseTree == null || exerciseTree.length == 0) { if ( exerciseTree == null || exerciseTree.length == 0) {
@ -115,7 +115,7 @@ class MenuTreeRepository {
WorkoutTree treeItem = value as WorkoutTree; WorkoutTree treeItem = value as WorkoutTree;
if ( treeItem.id == treeId ) { if ( treeItem.id == treeId ) {
isTreeItem1RM = treeItem.is1RM; 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 ) { String getDateLocale( DateTime datetime, bool timeDisplay ) {
AppLanguage appLanguage = AppLanguage();
var date = datetime; 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 ) { 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; return dateName;
@ -74,5 +73,4 @@ mixin Common {
return _passwordRegExp.hasMatch(password); return _passwordRegExp.hasMatch(password);
} }
} }

View File

@ -17,7 +17,6 @@ class Session {
Future<SharedPreferences> _prefs = SharedPreferences.getInstance(); Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
SharedPreferences _sharedPreferences; SharedPreferences _sharedPreferences;
final AppLanguage appLanguage = AppLanguage();
fetchSessionAndNavigate( ) async { fetchSessionAndNavigate( ) async {
print (" -- Session: await prefs.."); print (" -- Session: await prefs..");
@ -27,11 +26,11 @@ class Session {
if ( Cache().firstLoad ) { if ( Cache().firstLoad ) {
print (" -- Session: fetch locale.."); print (" -- Session: fetch locale..");
await appLanguage.getLocale(_sharedPreferences); await AppLanguage().getLocale(_sharedPreferences);
await AppLocalizations.delegate.load(appLanguage.appLocal); await AppLocalizations.delegate.load(AppLanguage().appLocal);
print (" -- Session: fetch token.."); print (" -- Session: fetch token..");
await _fetchToken(_sharedPreferences); await _fetchToken(_sharedPreferences);
initDeviceLocale(); //initDeviceLocale();
// PushNotificationsManager().init(); // PushNotificationsManager().init();
} }
@ -69,7 +68,7 @@ class Session {
Cache.password Cache.password
); );
int customerId = 0; int customerId = 0;
print("--- Lang: " + appLanguage.appLocal.toString()); print("--- Lang: " + AppLanguage().appLocal.toString());
if(responseJson['error'] != null) { if(responseJson['error'] != null) {
print("************** Here big error - no authentication"); print("************** Here big error - no authentication");
} else if (responseJson['token'] != null) { } 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/bloc/account/account_bloc.dart';
import 'package:aitrainer_app/localization/app_language.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/model/customer.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:aitrainer_app/widgets/bottom_nav.dart'; import 'package:aitrainer_app/widgets/bottom_nav.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
// ignore: must_be_immutable // ignore: must_be_immutable
class AccountPage extends StatelessWidget { class AccountPage extends StatelessWidget with Trans {
// ignore: close_sinks // ignore: close_sinks
AccountBloc accountBloc; AccountBloc accountBloc;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
setContext(context);
accountBloc = BlocProvider.of<AccountBloc>(context); accountBloc = BlocProvider.of<AccountBloc>(context);
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(AppLocalizations.of(context).translate('Account')), title: Text(t('Account')),
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
), ),
body: Container( body: Container(
@ -76,7 +77,7 @@ class AccountPage extends StatelessWidget {
ListTile( ListTile(
leading: Icon(Icons.perm_identity), leading: Icon(Icons.perm_identity),
subtitle: subtitle:
Text(AppLocalizations.of(context).translate("Profile")), Text(t("Profile")),
title: FlatButton( title: FlatButton(
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -118,7 +119,7 @@ class AccountPage extends StatelessWidget {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text(AppLocalizations.of(context).translate(text), Text(t(text),
style: TextStyle( style: TextStyle(
color: buttonColor color: buttonColor
)), )),

View File

@ -1,6 +1,7 @@
import 'package:aitrainer_app/bloc/account/account_bloc.dart'; import 'package:aitrainer_app/bloc/account/account_bloc.dart';
import 'package:aitrainer_app/bloc/customer_change_form_bloc.dart'; import 'package:aitrainer_app/bloc/customer_change_form_bloc.dart';
import 'package:aitrainer_app/localization/app_localization.dart'; import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -9,15 +10,13 @@ import 'package:flutter_form_bloc/flutter_form_bloc.dart';
import '../library_keys.dart'; import '../library_keys.dart';
// ignore: must_be_immutable // ignore: must_be_immutable
class CustomerModifyPage extends StatelessWidget{ class CustomerModifyPage extends StatelessWidget with Trans {
final _formKey = GlobalKey<FormState>(); final _formKey = GlobalKey<FormState>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
setContext(context);
// ignore: close_sinks // ignore: close_sinks
final accountBloc = BlocProvider.of<AccountBloc>(context); final accountBloc = BlocProvider.of<AccountBloc>(context);
// we cannot initialize the translations in the initState // we cannot initialize the translations in the initState
@ -31,8 +30,7 @@ class CustomerModifyPage extends StatelessWidget{
}); });
*/ */
return BlocProvider( return BlocProvider(
create: (context) => create: (context) => CustomerChangeFormBloc(customerRepository: accountBloc.customerRepository),
CustomerChangeFormBloc(customerRepository: accountBloc.customerRepository),
child: Builder(builder: (context) { child: Builder(builder: (context) {
// ignore: close_sinks // ignore: close_sinks
final customerBloc = BlocProvider.of<CustomerChangeFormBloc>(context); final customerBloc = BlocProvider.of<CustomerChangeFormBloc>(context);
@ -66,29 +64,23 @@ class CustomerModifyPage extends StatelessWidget{
key: _formKey, key: _formKey,
child: SingleChildScrollView( child: SingleChildScrollView(
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
padding: EdgeInsets.only( padding: EdgeInsets.only(top: 40, left: 25, right: 45, bottom: 100),
top: 40, left: 25, right: 45, bottom: 100),
child: Container( child: Container(
alignment: Alignment.center, alignment: Alignment.center,
child: Column( child: Column(
children: [ children: [
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Expanded( Expanded(
child: child: TextFieldBlocBuilder(
TextFieldBlocBuilder(
key: LibraryKeys.loginEmailField, key: LibraryKeys.loginEmailField,
style: TextStyle(fontSize: 12), style: TextStyle(fontSize: 12),
textFieldBloc: customerBloc.emailField, textFieldBloc: customerBloc.emailField,
decoration: InputDecoration( decoration: InputDecoration(
fillColor: Colors.white24, fillColor: Colors.white24,
filled: true, filled: true,
labelText: AppLocalizations.of(context) labelText: t('Email'),
.translate('Email'),
), ),
), ),
@ -108,22 +100,18 @@ class CustomerModifyPage extends StatelessWidget{
) )
], ],
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Expanded( Expanded(
child: child: TextFieldBlocBuilder(
TextFieldBlocBuilder(
style: TextStyle(fontSize: 12), style: TextStyle(fontSize: 12),
textFieldBloc: customerBloc.passwordField, textFieldBloc: customerBloc.passwordField,
suffixButton: SuffixButton.obscureText, suffixButton: SuffixButton.obscureText,
decoration: InputDecoration( decoration: InputDecoration(
fillColor: Colors.white24, fillColor: Colors.white24,
filled: true, filled: true,
labelText: AppLocalizations.of(context) labelText: t('Password (Leave empty if no change)'),
.translate('Password (Leave empty if no change)'),
), ),
), ),
/*TextFormField( /*TextFormField(
@ -142,11 +130,9 @@ class CustomerModifyPage extends StatelessWidget{
) )
], ],
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Expanded( Expanded(
child: TextFieldBlocBuilder( child: TextFieldBlocBuilder(
style: TextStyle(fontSize: 12), style: TextStyle(fontSize: 12),
@ -154,18 +140,15 @@ class CustomerModifyPage extends StatelessWidget{
decoration: InputDecoration( decoration: InputDecoration(
fillColor: Colors.white24, fillColor: Colors.white24,
filled: true, filled: true,
labelText: AppLocalizations.of(context) labelText: t('Name'),
.translate('Name'),
), ),
), ),
) )
], ],
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Expanded( Expanded(
child: TextFieldBlocBuilder( child: TextFieldBlocBuilder(
style: TextStyle(fontSize: 12), style: TextStyle(fontSize: 12),
@ -173,30 +156,24 @@ class CustomerModifyPage extends StatelessWidget{
decoration: InputDecoration( decoration: InputDecoration(
fillColor: Colors.white24, fillColor: Colors.white24,
filled: true, filled: true,
labelText: AppLocalizations.of(context) labelText: t('First Name'),
.translate('First Name'),
), ),
), ),
) )
], ],
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Expanded( Expanded(
child: TextFieldBlocBuilder( child: TextFieldBlocBuilder(
style: TextStyle(fontSize: 12), style: TextStyle(fontSize: 12),
textFieldBloc: customerBloc.birthYearField, textFieldBloc: customerBloc.birthYearField,
inputFormatters: [ inputFormatters: [WhitelistingTextInputFormatter(RegExp(r"[\d]"))],
WhitelistingTextInputFormatter (RegExp(r"[\d]"))
],
decoration: InputDecoration( decoration: InputDecoration(
fillColor: Colors.white24, fillColor: Colors.white24,
filled: true, filled: true,
labelText: AppLocalizations.of(context) labelText: t('Birth Year'),
.translate('Birth Year'),
), ),
), ),
) )
@ -205,19 +182,15 @@ class CustomerModifyPage extends StatelessWidget{
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Expanded( Expanded(
child: TextFieldBlocBuilder( child: TextFieldBlocBuilder(
style: TextStyle(fontSize: 12), style: TextStyle(fontSize: 12),
textFieldBloc: customerBloc.weightField, textFieldBloc: customerBloc.weightField,
inputFormatters: [ inputFormatters: [WhitelistingTextInputFormatter(RegExp(r"[\d]"))],
WhitelistingTextInputFormatter (RegExp(r"[\d]"))
],
decoration: InputDecoration( decoration: InputDecoration(
fillColor: Colors.white24, fillColor: Colors.white24,
filled: true, filled: true,
labelText: AppLocalizations.of(context) labelText: t('Weight'),
.translate('Weight'),
), ),
), ),
) )
@ -227,76 +200,37 @@ class CustomerModifyPage extends StatelessWidget{
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Expanded( Expanded(
child: DropdownFieldBlocBuilder( child: DropdownFieldBlocBuilder(
selectFieldBloc: customerBloc.genderField, selectFieldBloc: customerBloc.genderField,
itemBuilder: (context, item) => item, itemBuilder: (context, item) => item,
decoration: InputDecoration( decoration: InputDecoration(
labelText: AppLocalizations.of(context).translate( labelText: t('Select a gender'),
'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( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
Expanded( Expanded(
child: RaisedButton( child: RaisedButton(
color: Colors.orange, color: Colors.orange,
textColor: Colors.white, textColor: Colors.white,
child: InkWell( child: InkWell(child: Text(t("Next"))),
child: Text( onPressed: () => {
AppLocalizations.of(context).translate(
"Next"))),
onPressed: () =>
{
customerBloc.add(SubmitFormBloc()), customerBloc.add(SubmitFormBloc()),
Navigator.of(context).pushNamed("customerGoalPage", arguments: customerBloc.customerRepository) 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_add_by_plan_bloc.dart';
import 'package:aitrainer_app/bloc/exercise_by_plan/exercise_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_language.dart';
import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:aitrainer_app/model/workout_tree.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/exercise_repository.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/splash.dart'; import 'package:aitrainer_app/widgets/splash.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
@ -18,7 +17,7 @@ class ExerciseAddByPlanPage extends StatefulWidget{
_ExerciseAddByPlanPage createState() => _ExerciseAddByPlanPage(); _ExerciseAddByPlanPage createState() => _ExerciseAddByPlanPage();
} }
class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> { class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> with Trans {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -28,6 +27,7 @@ class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> {
final int customerId = arguments['customerId']; final int customerId = arguments['customerId'];
final WorkoutTree workoutTree = arguments['workoutTree']; final WorkoutTree workoutTree = arguments['workoutTree'];
final ExerciseRepository exerciseRepository = ExerciseRepository(); final ExerciseRepository exerciseRepository = ExerciseRepository();
setContext(context);
return BlocProvider( return BlocProvider(
create: (context) => create: (context) =>
@ -155,10 +155,9 @@ class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> {
filled: false, filled: false,
hintStyle: TextStyle( hintStyle: TextStyle(
fontSize: 12, color: Colors.black54, fontWeight: FontWeight.w100), fontSize: 12, color: Colors.black54, fontWeight: FontWeight.w100),
hintText: AppLocalizations.of(context) hintText: t("The number of the exercise"),
.translate("The number of the exercise"),
labelStyle: TextStyle(fontSize: 12, color: Colors.deepOrange, fontWeight: FontWeight.normal), 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.exerciseRepository.exerciseType.unitQuantityUnit + " " +
exerciseBloc.exercisePlanRepository.actualPlanDetail.repeats.toString() + " times!", exerciseBloc.exercisePlanRepository.actualPlanDetail.repeats.toString() + " times!",
), ),
@ -201,7 +200,7 @@ class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> {
} }
}, },
child: Text( child: Text(
AppLocalizations.of(context).translate("Check"), t("Check"),
style: TextStyle(fontSize: 12),) style: TextStyle(fontSize: 12),)
), ),
Divider(color: Colors.transparent,), Divider(color: Colors.transparent,),
@ -213,8 +212,7 @@ class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> {
} }
String validateNumberInput(input) { String validateNumberInput(input) {
String error = AppLocalizations.of(context).translate( String error = t("Please type the right quantity 0-10000");
"Please type the right quantity 0-10000");
dynamic rc = (input != null && input.length > 0); dynamic rc = (input != null && input.length > 0);
if (!rc) { if (!rc) {
return null; return null;

View File

@ -16,7 +16,6 @@ class ExerciseControlPage extends StatefulWidget{
} }
class _ExerciseControlPage extends State<ExerciseControlPage> { class _ExerciseControlPage extends State<ExerciseControlPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
LinkedHashMap arguments = ModalRoute.of(context).settings.arguments; LinkedHashMap arguments = ModalRoute.of(context).settings.arguments;
@ -25,10 +24,9 @@ class _ExerciseControlPage extends State<ExerciseControlPage> {
final bool readonly = arguments['readonly']; final bool readonly = arguments['readonly'];
return BlocProvider( return BlocProvider(
create: (context) => create: (context) => ExerciseControlFormBloc(
ExerciseControlFormBloc(exerciseRepository: exerciseRepository, percentToCalculate: percent, readonly: readonly), exerciseRepository: exerciseRepository, percentToCalculate: percent, readonly: readonly),
child: BlocBuilder<ExerciseControlFormBloc, FormBlocState>( child: BlocBuilder<ExerciseControlFormBloc, FormBlocState>(builder: (context, state) {
builder: (context, state) {
// ignore: close_sinks // ignore: close_sinks
final exerciseBloc = BlocProvider.of<ExerciseControlFormBloc>(context); final exerciseBloc = BlocProvider.of<ExerciseControlFormBloc>(context);
if (state is FormBlocLoading) { if (state is FormBlocLoading) {
@ -38,14 +36,13 @@ class _ExerciseControlPage extends State<ExerciseControlPage> {
} else { } else {
return getControlForm(exerciseBloc); return getControlForm(exerciseBloc);
} }
} }));
));
} }
Form getControlForm(ExerciseControlFormBloc exerciseBloc) { Form getControlForm(ExerciseControlFormBloc exerciseBloc) {
String exerciseName = AppLanguage().appLocal == Locale("en") ? String exerciseName = AppLanguage().appLocal == Locale("en")
exerciseBloc.exerciseRepository.exerciseType.name : ? exerciseBloc.exerciseRepository.exerciseType.name
exerciseBloc.exerciseRepository.exerciseType.nameTranslation; : exerciseBloc.exerciseRepository.exerciseType.nameTranslation;
return Form( return Form(
autovalidate: true, autovalidate: true,
@ -70,14 +67,8 @@ class _ExerciseControlPage extends State<ExerciseControlPage> {
), ),
), ),
body: Container( body: Container(
width: MediaQuery width: MediaQuery.of(context).size.width,
.of(context) height: MediaQuery.of(context).size.height,
.size
.width,
height: MediaQuery
.of(context)
.size
.height,
decoration: BoxDecoration( decoration: BoxDecoration(
image: DecorationImage( image: DecorationImage(
image: AssetImage('asset/image/WT_light_background.png'), image: AssetImage('asset/image/WT_light_background.png'),
@ -89,46 +80,40 @@ class _ExerciseControlPage extends State<ExerciseControlPage> {
padding: const EdgeInsets.only(top: 25, left: 25, right: 25), padding: const EdgeInsets.only(top: 25, left: 25, right: 25),
child: SingleChildScrollView( child: SingleChildScrollView(
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
child: Column( child: Column(mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[
mainAxisAlignment: MainAxisAlignment.spaceAround, Text(
children: <Widget>[ exerciseName,
Text(exerciseName, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: Colors.deepOrange),
style: TextStyle(fontWeight: FontWeight.bold,
fontSize: 18,
color: Colors.deepOrange),
overflow: TextOverflow.fade, overflow: TextOverflow.fade,
maxLines: 1, maxLines: 1,
softWrap: true, softWrap: true,
), ),
FlatButton( FlatButton(
child: Row( child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Icon(Icons.question_answer), Icon(Icons.question_answer),
Text(AppLocalizations.of(context).translate( Text(AppLocalizations.of(context).translate("Why do you need Exercise Control?"),
"Why do you need Exercise Control?"), style: TextStyle(color: Colors.blueAccent, fontWeight: FontWeight.normal, fontSize: 14)),
style: TextStyle(
color: Colors.blueAccent,
fontWeight: FontWeight.normal,
fontSize: 14)),
Icon(Icons.arrow_forward_ios), Icon(Icons.arrow_forward_ios),
]), ]),
textColor: Colors.blueAccent, textColor: Colors.blueAccent,
color: Colors.transparent, color: Colors.transparent,
onPressed: () => onPressed: () => {
{
//Navigator.of(context).pushNamed('exerciseTypeDescription', arguments: exerciseBloc.exerciseRepository), //Navigator.of(context).pushNamed('exerciseTypeDescription', arguments: exerciseBloc.exerciseRepository),
}, },
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Text(AppLocalizations.of(context).translate("Your 1RM:"),), Text(
Text(" " + exerciseBloc.initialRMField.value + " " +exerciseBloc.exerciseRepository.exerciseType AppLocalizations.of(context).translate("Your 1RM:"),
.unitQuantityUnit, ),
style: TextStyle(fontWeight: FontWeight.bold),), Text(
" " +
exerciseBloc.initialRMField.value +
" " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit,
style: TextStyle(fontWeight: FontWeight.bold),
),
], ],
), ),
Divider(), Divider(),
@ -136,29 +121,30 @@ class _ExerciseControlPage extends State<ExerciseControlPage> {
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text(AppLocalizations.of(context).translate("1st Control Exercise:"), Text(
style: TextStyle(),), AppLocalizations.of(context).translate("1st Control Exercise:"),
style: TextStyle(),
),
TextFieldBlocBuilder( TextFieldBlocBuilder(
readOnly: exerciseBloc.step != 1, readOnly: exerciseBloc.step != 1,
textFieldBloc: exerciseBloc.quantity1Field, textFieldBloc: exerciseBloc.quantity1Field,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(fontSize: 14, color: Colors.deepOrange, fontWeight: FontWeight.bold),
fontSize: 14, inputFormatters: [WhitelistingTextInputFormatter(RegExp(r"[\d.]"))],
color: Colors.deepOrange,
fontWeight: FontWeight.bold),
inputFormatters: [
WhitelistingTextInputFormatter (RegExp(r"[\d.]"))
],
decoration: InputDecoration( decoration: InputDecoration(
fillColor: Colors.white, fillColor: Colors.white,
filled: false, filled: false,
hintStyle: TextStyle( hintStyle: TextStyle(fontSize: 12, color: Colors.black54, fontWeight: FontWeight.w100),
fontSize: 12, color: Colors.black54, fontWeight: FontWeight.w100), hintText: AppLocalizations.of(context).translate("The number of the exercise"),
hintText: AppLocalizations.of(context) labelStyle:
.translate("The number of the exercise"), TextStyle(fontSize: 12, color: Colors.deepOrange, fontWeight: FontWeight.normal),
labelStyle: TextStyle(fontSize: 12, color: Colors.deepOrange, fontWeight: FontWeight.normal), labelText: "Please repeat with " +
labelText: "Please repeat with " + exerciseBloc.unitQuantity1Field.value + " " + exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit + " 12 times!", exerciseBloc.unitQuantity1Field.value +
" " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit +
" " +
exerciseBloc.times +
" times!",
), ),
), ),
RaisedButton( RaisedButton(
@ -166,35 +152,28 @@ class _ExerciseControlPage extends State<ExerciseControlPage> {
textColor: Colors.white, textColor: Colors.white,
color: exerciseBloc.step == 1 ? Colors.blue : Colors.black26, color: exerciseBloc.step == 1 ? Colors.blue : Colors.black26,
focusColor: Colors.blueAccent, focusColor: Colors.blueAccent,
onPressed: () => onPressed: () => {exerciseBloc.submit()},
{
exerciseBloc.submit()
},
child: Text( child: Text(
AppLocalizations.of(context).translate("Check"), AppLocalizations.of(context).translate("Check"),
style: TextStyle(fontSize: 12),) style: TextStyle(fontSize: 12),
), )),
], ],
), ),
Divider(), Divider(),
Column( Column(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text(AppLocalizations.of(context).translate("2nd Control Exercise:"), Text(
style: TextStyle(),), AppLocalizations.of(context).translate("2nd Control Exercise:"),
style: TextStyle(),
),
TextFieldBlocBuilder( TextFieldBlocBuilder(
readOnly: exerciseBloc.step != 2, readOnly: exerciseBloc.step != 2,
textFieldBloc: exerciseBloc.quantity2Field, textFieldBloc: exerciseBloc.quantity2Field,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(fontSize: 14, color: Colors.deepOrange, fontWeight: FontWeight.bold),
fontSize: 14, inputFormatters: [WhitelistingTextInputFormatter(RegExp(r"[\d.]"))],
color: Colors.deepOrange,
fontWeight: FontWeight.bold),
inputFormatters: [
WhitelistingTextInputFormatter (RegExp(r"[\d.]"))
],
onChanged: (input) => { onChanged: (input) => {
print("Quantity 2 value $input"), print("Quantity 2 value $input"),
//exerciseBloc.exerciseRepository.setQuantity(double.parse(input)), //exerciseBloc.exerciseRepository.setQuantity(double.parse(input)),
@ -204,12 +183,15 @@ class _ExerciseControlPage extends State<ExerciseControlPage> {
decoration: InputDecoration( decoration: InputDecoration(
fillColor: Colors.white, fillColor: Colors.white,
filled: false, filled: false,
hintStyle: TextStyle( hintStyle: TextStyle(fontSize: 12, color: Colors.black54, fontWeight: FontWeight.w100),
fontSize: 12, color: Colors.black54, fontWeight: FontWeight.w100), hintText: AppLocalizations.of(context).translate("The number of the exercise"),
hintText: AppLocalizations.of(context) labelStyle:
.translate("The number of the exercise"), TextStyle(fontSize: 12, color: Colors.deepOrange, fontWeight: FontWeight.normal),
labelStyle: TextStyle(fontSize: 12, color: Colors.deepOrange, fontWeight: FontWeight.normal), labelText: "Please repeat with " +
labelText: "Please repeat with " + exerciseBloc.unitQuantity2Field.value + " " + exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit + " 12 times!", exerciseBloc.unitQuantity2Field.value +
" " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit +
" 12 times!",
), ),
), ),
RaisedButton( RaisedButton(
@ -217,35 +199,28 @@ class _ExerciseControlPage extends State<ExerciseControlPage> {
textColor: Colors.white, textColor: Colors.white,
color: exerciseBloc.step == 2 ? Colors.blue : Colors.black26, color: exerciseBloc.step == 2 ? Colors.blue : Colors.black26,
focusColor: Colors.blueAccent, focusColor: Colors.blueAccent,
onPressed: () => onPressed: () => {exerciseBloc.submit()},
{
exerciseBloc.submit()
},
child: Text( child: Text(
AppLocalizations.of(context).translate("Check"), AppLocalizations.of(context).translate("Check"),
style: TextStyle(fontSize: 12),) style: TextStyle(fontSize: 12),
), )),
], ],
), ),
Divider(), Divider(),
Column( Column(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text(AppLocalizations.of(context).translate("3rd Control Exercise:"), Text(
style: TextStyle(),), AppLocalizations.of(context).translate("3rd Control Exercise:"),
style: TextStyle(),
),
TextFieldBlocBuilder( TextFieldBlocBuilder(
readOnly: exerciseBloc.step != 3, readOnly: exerciseBloc.step != 3,
textFieldBloc: exerciseBloc.quantity3Field, textFieldBloc: exerciseBloc.quantity3Field,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(fontSize: 14, color: Colors.deepOrange, fontWeight: FontWeight.bold),
fontSize: 14, inputFormatters: [WhitelistingTextInputFormatter(RegExp(r"[\d.]"))],
color: Colors.deepOrange,
fontWeight: FontWeight.bold),
inputFormatters: [
WhitelistingTextInputFormatter (RegExp(r"[\d.]"))
],
onChanged: (input) => { onChanged: (input) => {
print("Quantity 3 value $input"), print("Quantity 3 value $input"),
//exerciseBloc.exerciseRepository.setQuantity(double.parse(input)), //exerciseBloc.exerciseRepository.setQuantity(double.parse(input)),
@ -255,12 +230,15 @@ class _ExerciseControlPage extends State<ExerciseControlPage> {
decoration: InputDecoration( decoration: InputDecoration(
fillColor: Colors.white, fillColor: Colors.white,
filled: false, filled: false,
hintStyle: TextStyle( hintStyle: TextStyle(fontSize: 12, color: Colors.black54, fontWeight: FontWeight.w100),
fontSize: 12, color: Colors.black54, fontWeight: FontWeight.w100), hintText: AppLocalizations.of(context).translate("The number of the exercise"),
hintText: AppLocalizations.of(context) labelStyle:
.translate("The number of the exercise"), TextStyle(fontSize: 12, color: Colors.deepOrange, fontWeight: FontWeight.normal),
labelStyle: TextStyle(fontSize: 12, color: Colors.deepOrange, fontWeight: FontWeight.normal), labelText: "Please repeat with " +
labelText: "Please repeat with " + exerciseBloc.unitQuantity3Field.value + " " + exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit + " 12 times!", exerciseBloc.unitQuantity3Field.value +
" " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit +
" 12 times!",
), ),
), ),
RaisedButton( RaisedButton(
@ -268,29 +246,21 @@ class _ExerciseControlPage extends State<ExerciseControlPage> {
textColor: Colors.white, textColor: Colors.white,
color: exerciseBloc.step == 3 ? Colors.blue : Colors.black26, color: exerciseBloc.step == 3 ? Colors.blue : Colors.black26,
focusColor: Colors.blueAccent, focusColor: Colors.blueAccent,
onPressed: () => onPressed: () => {exerciseBloc.submit()},
{
exerciseBloc.submit()
},
child: Text( child: Text(
AppLocalizations.of(context).translate("Check"), AppLocalizations.of(context).translate("Check"),
style: TextStyle(fontSize: 12),) style: TextStyle(fontSize: 12),
), )),
], ],
), ),
]), ]),
) ))),
)
),
), ),
); );
} }
String validateNumberInput(input) { String validateNumberInput(input) {
String error = AppLocalizations.of(context).translate( String error = AppLocalizations.of(context).translate("Please type the right quantity 0-10000");
"Please type the right quantity 0-10000");
dynamic rc = (input != null && input.length > 0); dynamic rc = (input != null && input.length > 0);
if (!rc) { if (!rc) {
return null; return null;
@ -307,7 +277,6 @@ class _ExerciseControlPage extends State<ExerciseControlPage> {
return error; return error;
} }
if (!(double.parse(input) < 10000 && double.parse(input) > 0)) { if (!(double.parse(input) < 10000 && double.parse(input) > 0)) {
return error; return error;
} }

View File

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

View File

@ -56,8 +56,6 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> {
), ),
child: BlocConsumer<ExercisePlanBloc, ExercisePlanState>(listener: (context, state) { child: BlocConsumer<ExercisePlanBloc, ExercisePlanState>(listener: (context, state) {
if (state is ExercisePlanError) { if (state is ExercisePlanError) {
//showInSnackBar(state.message);
//return exerciseWidget(bloc);
Scaffold.of(context).showSnackBar(SnackBar( Scaffold.of(context).showSnackBar(SnackBar(
content: Text( content: Text(
state.message, 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/exercise_plan_bloc.dart';
import 'package:aitrainer_app/bloc/exercise_plan_custom_form.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_language.dart';
import 'package:aitrainer_app/localization/app_localization.dart'; import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:aitrainer_app/repository/exercise_plan_repository.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:aitrainer_app/widgets/app_bar_common.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
@ -16,15 +16,17 @@ class ExercisePlanDetailAddPage extends StatefulWidget {
_ExercisePlanDetailAddPage createState() => _ExercisePlanDetailAddPage(); _ExercisePlanDetailAddPage createState() => _ExercisePlanDetailAddPage();
} }
class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> { class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> with Trans {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// ignore: close_sinks // ignore: close_sinks
final ExercisePlanBloc planBloc = ModalRoute.of(context).settings.arguments; final ExercisePlanBloc planBloc = ModalRoute.of(context).settings.arguments;
final ExercisePlanRepository exercisePlanRepository = planBloc.exercisePlanRepository; final ExercisePlanRepository exercisePlanRepository = planBloc.exercisePlanRepository;
setContext(context);
return BlocProvider( return BlocProvider(
create: (context) => ExercisePlanCustomerFormBloc(exercisePlanRepository: exercisePlanRepository, planBloc: planBloc), create: (context) =>
ExercisePlanCustomerFormBloc(exercisePlanRepository: exercisePlanRepository, planBloc: planBloc),
child: Builder(builder: (context) { child: Builder(builder: (context) {
// ignore: close_sinks // ignore: close_sinks
final bloc = BlocProvider.of<ExercisePlanCustomerFormBloc>(context); final bloc = BlocProvider.of<ExercisePlanCustomerFormBloc>(context);
@ -88,7 +90,8 @@ class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> {
fillColor: Colors.white, fillColor: Colors.white,
filled: false, filled: false,
hintStyle: TextStyle(fontSize: 16, color: Colors.black54, fontWeight: FontWeight.w100), 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), labelStyle: TextStyle(fontSize: 16, color: Colors.lightBlue),
labelText: AppLocalizations.of(context).translate("Repeats"), labelText: AppLocalizations.of(context).translate("Repeats"),
), ),
@ -116,10 +119,12 @@ class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> {
focusColor: Colors.white, focusColor: Colors.white,
onPressed: () => { onPressed: () => {
print("Remove " + bloc.exercisePlanRepository.actualPlanDetail.exerciseType.name), 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(), 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( RaisedButton(
textColor: Colors.white, textColor: Colors.white,
@ -129,9 +134,7 @@ class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> {
bloc.submit(), bloc.submit(),
Navigator.of(context).pop(), Navigator.of(context).pop(),
}, },
child: Text( child: Text(t("Save"), style: TextStyle(fontSize: 16),
AppLocalizations.of(context).translate("Save"),
style: TextStyle(fontSize: 16),
)), )),
], ],
), ),

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -35,7 +35,7 @@ packages:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.4.1" version: "2.4.2"
bloc: bloc:
dependency: transitive dependency: transitive
description: description:
@ -113,6 +113,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "7.1.0" version: "7.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
@ -134,6 +141,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.0" version: "0.2.0"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
code_builder: code_builder:
dependency: transitive dependency: transitive
description: description:
@ -147,7 +161,7 @@ packages:
name: collection name: collection
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.14.12" version: "1.14.13"
convert: convert:
dependency: transitive dependency: transitive
description: description:
@ -161,14 +175,14 @@ packages:
name: coverage name: coverage
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.13.11" version: "0.14.1"
crypto: crypto:
dependency: transitive dependency: transitive
description: description:
name: crypto name: crypto
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.4" version: "2.1.5"
csslib: csslib:
dependency: transitive dependency: transitive
description: description:
@ -204,13 +218,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.5" version: "1.2.5"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
file: file:
dependency: transitive dependency: transitive
description: description:
name: file name: file
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "5.1.0" version: "5.2.1"
fixnum: fixnum:
dependency: transitive dependency: transitive
description: description:
@ -380,7 +401,7 @@ packages:
name: image name: image
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.12" version: "2.1.14"
intl: intl:
dependency: "direct dev" dependency: "direct dev"
description: description:
@ -415,7 +436,7 @@ packages:
name: json_rpc_2 name: json_rpc_2
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.2.1"
logging: logging:
dependency: transitive dependency: transitive
description: description:
@ -429,7 +450,7 @@ packages:
name: matcher name: matcher
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.6" version: "0.12.8"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@ -451,13 +472,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.1.1" 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: nested:
dependency: transitive dependency: transitive
description: description:
@ -499,7 +513,7 @@ packages:
name: path name: path
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.6.4" version: "1.7.0"
path_provider_linux: path_provider_linux:
dependency: transitive dependency: transitive
description: description:
@ -534,7 +548,7 @@ packages:
name: petitparser name: petitparser
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.4.0" version: "3.0.4"
platform: platform:
dependency: transitive dependency: transitive
description: description:
@ -562,7 +576,7 @@ packages:
name: process name: process
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.12" version: "3.0.13"
provider: provider:
dependency: transitive dependency: transitive
description: description:
@ -728,7 +742,7 @@ packages:
name: stack_trace name: stack_trace
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.9.3" version: "1.9.5"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
@ -770,21 +784,21 @@ packages:
name: test name: test
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.14.4" version: "1.15.2"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.15" version: "0.2.17"
test_core: test_core:
dependency: transitive dependency: transitive
description: description:
name: test_core name: test_core
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.3.4" version: "0.3.10"
timing: timing:
dependency: transitive dependency: transitive
description: description:
@ -798,7 +812,7 @@ packages:
name: typed_data name: typed_data
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.6" version: "1.2.0"
usage: usage:
dependency: transitive dependency: transitive
description: description:
@ -875,7 +889,7 @@ packages:
name: xml name: xml
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.6.1" version: "4.2.0"
yaml: yaml:
dependency: transitive dependency: transitive
description: description:
@ -884,5 +898,5 @@ packages:
source: hosted source: hosted
version: "2.2.1" version: "2.2.1"
sdks: 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" 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. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at # Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.1.0+20 version: 1.1.0+21
environment: environment:
sdk: ">=2.7.0 <3.0.0" sdk: ">=2.7.0 <3.0.0"
@ -33,7 +33,7 @@ dependencies:
flutter_local_notifications: 1.1.1 flutter_local_notifications: 1.1.1
flutter_facebook_login: ^3.0.0 flutter_facebook_login: ^3.0.0
flutter_bloc: ^6.0.5 flutter_bloc: ^6.0.5
equatable: ^1.2.4 equatable: ^1.2.5
freezed: ^0.11.6 freezed: ^0.11.6
flutter_form_bloc: ^0.19.0 flutter_form_bloc: ^0.19.0
spider_chart: ^0.1.5 spider_chart: ^0.1.5
@ -51,7 +51,7 @@ dev_dependencies:
flutter_driver: flutter_driver:
sdk: flutter sdk: flutter
test: any test: any
bloc_test: ^7.0.3 bloc_test: ^7.0.4
build_runner: build_runner: