bug fix 1.0 (android logo, old device, firstname, exercise save)

This commit is contained in:
Bossanyi Tibor 2020-07-09 14:08:14 +02:00
parent dfe20685d7
commit 9b1d867826
11 changed files with 132 additions and 17 deletions

View File

@ -7,8 +7,8 @@
FlutterApplication and put your custom class here. --> FlutterApplication and put your custom class here. -->
<application <application
android:name="io.flutter.app.FlutterApplication" android:name="io.flutter.app.FlutterApplication"
android:label="aitrainer_app" android:label="WorkoutTest"
android:icon="@mipmap/ic_launcher"> android:icon="@mipmap/launcher_icon">
<activity <activity
android:name="com.aitrainer.aitrainer_app.MainActivity" android:name="com.aitrainer.aitrainer_app.MainActivity"
android:launchMode="singleTop" android:launchMode="singleTop"

View File

@ -51,7 +51,7 @@ class AitrainerApp extends StatelessWidget {
localizationsDelegates: [ localizationsDelegates: [
// ... app-specific localization delegate[s] here // ... app-specific localization delegate[s] here
AppLocalizations.delegate, AppLocalizations.delegate,
GlobalWidgetsLocalizations.delegate, GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
], ],
supportedLocales: [ supportedLocales: [
@ -59,6 +59,21 @@ class AitrainerApp extends StatelessWidget {
const Locale('hu', "HU"), // Hungarian const Locale('hu', "HU"), // Hungarian
// ... other locales the app supports // ... other locales the app supports
], ],
localeResolutionCallback: (Locale locale, Iterable<Locale> supportedLocales) {
//myLocale = deviceLocale ;
// here you make your app language similar to device language ,
// but you should check whether the localization is supported by your app
Locale realSupportedLocale = Locale('en', "US");
supportedLocales.forEach((supportedLocale) {
if ( supportedLocale.countryCode == locale.countryCode ) {
realSupportedLocale = supportedLocale;
}
});
if ( realSupportedLocale.countryCode != locale.countryCode ) {
print ("Locale " + locale.countryCode + " not supported on this device :(");
}
return realSupportedLocale;
},
routes: { routes: {
'home': (context) => AitrainerHome(), 'home': (context) => AitrainerHome(),
'loading': (context) => LoadingScreenMain(), 'loading': (context) => LoadingScreenMain(),

View File

@ -43,6 +43,7 @@ class Auth {
Customer userLoggedIn; Customer userLoggedIn;
bool firstLoad = true; bool firstLoad = true;
List<ExerciseType> _exerciseTypes; List<ExerciseType> _exerciseTypes;
List deviceLanguages;
factory Auth() { factory Auth() {
return _singleton; return _singleton;

View File

@ -1,7 +1,7 @@
class Customer { class Customer {
String name; String name;
String email; String email;
String firstName; String firstname;
String sex; String sex;
int age; int age;
String active; String active;
@ -18,7 +18,7 @@ class Customer {
Customer({this.customerId, Customer({this.customerId,
this.name, this.name,
this.firstName, this.firstname,
this.email, this.email,
this.sex, this.sex,
this.age, this.age,
@ -36,7 +36,7 @@ class Customer {
Customer.fromJson(Map json) { Customer.fromJson(Map json) {
this.customerId = json['customerId']; this.customerId = json['customerId'];
this.name = json['name']; this.name = json['name'];
this.firstName = json['firstname']; this.firstname = json['firstname'];
this.email = json['email']; this.email = json['email'];
this.sex = json['sex']; this.sex = json['sex'];
this.age = json['age']; this.age = json['age'];
@ -52,7 +52,7 @@ class Customer {
Map<String, dynamic> toJson() => Map<String, dynamic> toJson() =>
{ {
"name": name, "name": name,
"firstName": firstName, "firstname": firstname,
"email": email, "email": email,
"age": age, "age": age,
"sex": sex, "sex": sex,

View File

@ -2,7 +2,8 @@ import 'package:aitrainer_app/localization/app_language.dart';
import 'package:aitrainer_app/service/api.dart'; import 'package:aitrainer_app/service/api.dart';
import 'package:aitrainer_app/service/customer_service.dart'; import 'package:aitrainer_app/service/customer_service.dart';
import 'package:aitrainer_app/service/exercisetype_service.dart'; import 'package:aitrainer_app/service/exercisetype_service.dart';
import 'package:aitrainer_app/viewmodel/exercise_type_changing_view_model.dart'; import 'package:devicelocale/devicelocale.dart';
import 'package:flutter/services.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:aitrainer_app/model/auth.dart'; import 'package:aitrainer_app/model/auth.dart';
@ -19,11 +20,33 @@ class Session {
if ( _auth.firstLoad ) { if ( _auth.firstLoad ) {
_fetchToken(_sharedPreferences, callback); _fetchToken(_sharedPreferences, callback);
initDeviceLocale();
appLanguage.fetchLocale(); appLanguage.fetchLocale();
} }
} }
Future<void> initDeviceLocale() async {
List languages;
String currentLocale;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
languages = await Devicelocale.preferredLanguages;
Auth().deviceLanguages = languages;
print("device langs " + languages.toString());
} on PlatformException {
print("Error obtaining preferred languages");
}
try {
currentLocale = await Devicelocale.currentLocale;
print("Device currentlocale " + currentLocale);
} on PlatformException {
print("Error obtaining current locale");
}
}
/* /*
Auth flow of the user, see auth.dart Auth flow of the user, see auth.dart
*/ */

View File

@ -77,7 +77,7 @@ class _AccountPagePageState extends State<AccountPage> {
children: [ children: [
Text(_loggedIn ? Auth().userLoggedIn.email + " " + Text(_loggedIn ? Auth().userLoggedIn.email + " " +
Auth().userLoggedIn.name + " " + Auth().userLoggedIn.name + " " +
Auth().userLoggedIn.firstName : "", Auth().userLoggedIn.firstname : "",
style: TextStyle(color: Colors.blue)), style: TextStyle(color: Colors.blue)),
Icon(Icons.arrow_forward_ios), Icon(Icons.arrow_forward_ios),
]), ]),

View File

@ -163,7 +163,7 @@ class _CustomerModifyPageState extends State<CustomerModifyPage> {
labelText: AppLocalizations.of(context).translate('First Name'), labelText: AppLocalizations.of(context).translate('First Name'),
), ),
keyboardType: TextInputType.emailAddress, keyboardType: TextInputType.emailAddress,
initialValue: customerChangeModel.customer.customer.firstName, initialValue: customerChangeModel.customer.customer.firstname,
onFieldSubmitted: (input) => customerChangeModel.customer.setFirstName(input) onFieldSubmitted: (input) => customerChangeModel.customer.setFirstName(input)
) )
) )

View File

@ -30,7 +30,7 @@ class _ExerciseNewPageState extends State {
model.exerciseViewModel.createNew(); model.exerciseViewModel.createNew();
customerName = model != null && model.customer != null customerName = model != null && model.customer != null
? model.customer.name + " " + ? model.customer.name + " " +
model.customer.firstName model.customer.firstname
: "Please select a customer"; : "Please select a customer";
exerciseName = model != null && exerciseName = model != null &&
@ -157,7 +157,7 @@ class _ExerciseNewPageState extends State {
inputFormatters: [ inputFormatters: [
WhitelistingTextInputFormatter(RegExp(r"[\d.]")) WhitelistingTextInputFormatter(RegExp(r"[\d.]"))
], ],
onFieldSubmitted: (input) => { onChanged: (input) => {
print ("UnitQuantity value $input"), print ("UnitQuantity value $input"),
model.exerciseViewModel.setUnitQuantity( model.exerciseViewModel.setUnitQuantity(
double.parse(input)) double.parse(input))
@ -193,7 +193,7 @@ class _ExerciseNewPageState extends State {
inputFormatters: [ inputFormatters: [
WhitelistingTextInputFormatter(RegExp(r"[\d.]")) WhitelistingTextInputFormatter(RegExp(r"[\d.]"))
], ],
onFieldSubmitted: (input) => onChanged: (input) =>
{ {
print ("Quantity value $input"), print ("Quantity value $input"),
model.exerciseViewModel.setQuantity( model.exerciseViewModel.setQuantity(

View File

@ -11,7 +11,7 @@ class CustomerViewModel {
} }
String get firstName { String get firstName {
return this.customer.firstName; return this.customer.firstname;
} }
String get sex { String get sex {
@ -26,7 +26,7 @@ class CustomerViewModel {
this.customer.name = name; this.customer.name = name;
} }
setFirstName(String firstName) { setFirstName(String firstName) {
this.customer.firstName = firstName; this.customer.firstname = firstName;
} }
setPassword( String password ) { setPassword( String password ) {

View File

@ -1,6 +1,20 @@
# Generated by pub # Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile # See https://dart.dev/tools/pub/glossary#lockfile
packages: packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.0"
async: async:
dependency: transitive dependency: transitive
description: description:
@ -36,6 +50,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.14.12" version: "1.14.12"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.5"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
@ -50,6 +78,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.0" version: "1.0.0"
devicelocale:
dependency: "direct main"
description:
name: devicelocale
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.1"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
@ -69,6 +104,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.8" version: "1.3.8"
flutter_launcher_icons:
dependency: "direct dev"
description:
name: flutter_launcher_icons
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.5"
flutter_localizations: flutter_localizations:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -93,6 +135,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.1.4" version: "3.1.4"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.14"
intl: intl:
dependency: "direct dev" dependency: "direct dev"
description: description:
@ -128,6 +177,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.9.0" version: "1.9.0"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.4"
provider: provider:
dependency: "direct dev" dependency: "direct dev"
description: description:
@ -203,6 +259,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.8" version: "2.0.8"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.0"
yaml:
dependency: transitive
description:
name: yaml
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
sdks: sdks:
dart: ">=2.7.0 <3.0.0" dart: ">=2.7.0 <3.0.0"
flutter: ">=1.0.0 <2.0.0" flutter: ">=1.12.13+hotfix.6 <2.0.0"

View File

@ -27,6 +27,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3 cupertino_icons: ^0.1.3
devicelocale: ^0.3.1
flutter_localizations: flutter_localizations:
sdk: flutter sdk: flutter
@ -42,6 +43,11 @@ dev_dependencies:
datetime_picker_formfield: ^1.0.0 datetime_picker_formfield: ^1.0.0
shared_preferences: ^0.4.1 shared_preferences: ^0.4.1
flutter_launcher_icons: "^0.7.3"
flutter_icons:
android: "launcher_icon"
image_path: "asset/icon/icon.png"
# For information on the generic Dart part of this file, see the # For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec # following page: https://dart.dev/tools/pub/pubspec