bug fix 1.0 (android logo, old device, firstname, exercise save)
This commit is contained in:
+16
-1
@@ -51,7 +51,7 @@ class AitrainerApp extends StatelessWidget {
|
||||
localizationsDelegates: [
|
||||
// ... app-specific localization delegate[s] here
|
||||
AppLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: [
|
||||
@@ -59,6 +59,21 @@ class AitrainerApp extends StatelessWidget {
|
||||
const Locale('hu', "HU"), // Hungarian
|
||||
// ... 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: {
|
||||
'home': (context) => AitrainerHome(),
|
||||
'loading': (context) => LoadingScreenMain(),
|
||||
|
||||
@@ -43,6 +43,7 @@ class Auth {
|
||||
Customer userLoggedIn;
|
||||
bool firstLoad = true;
|
||||
List<ExerciseType> _exerciseTypes;
|
||||
List deviceLanguages;
|
||||
|
||||
factory Auth() {
|
||||
return _singleton;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Customer {
|
||||
String name;
|
||||
String email;
|
||||
String firstName;
|
||||
String firstname;
|
||||
String sex;
|
||||
int age;
|
||||
String active;
|
||||
@@ -18,7 +18,7 @@ class Customer {
|
||||
|
||||
Customer({this.customerId,
|
||||
this.name,
|
||||
this.firstName,
|
||||
this.firstname,
|
||||
this.email,
|
||||
this.sex,
|
||||
this.age,
|
||||
@@ -36,7 +36,7 @@ class Customer {
|
||||
Customer.fromJson(Map json) {
|
||||
this.customerId = json['customerId'];
|
||||
this.name = json['name'];
|
||||
this.firstName = json['firstname'];
|
||||
this.firstname = json['firstname'];
|
||||
this.email = json['email'];
|
||||
this.sex = json['sex'];
|
||||
this.age = json['age'];
|
||||
@@ -52,7 +52,7 @@ class Customer {
|
||||
Map<String, dynamic> toJson() =>
|
||||
{
|
||||
"name": name,
|
||||
"firstName": firstName,
|
||||
"firstname": firstname,
|
||||
"email": email,
|
||||
"age": age,
|
||||
"sex": sex,
|
||||
|
||||
+24
-1
@@ -2,7 +2,8 @@ import 'package:aitrainer_app/localization/app_language.dart';
|
||||
import 'package:aitrainer_app/service/api.dart';
|
||||
import 'package:aitrainer_app/service/customer_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:aitrainer_app/model/auth.dart';
|
||||
|
||||
@@ -19,11 +20,33 @@ class Session {
|
||||
|
||||
if ( _auth.firstLoad ) {
|
||||
_fetchToken(_sharedPreferences, callback);
|
||||
initDeviceLocale();
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -77,7 +77,7 @@ class _AccountPagePageState extends State<AccountPage> {
|
||||
children: [
|
||||
Text(_loggedIn ? Auth().userLoggedIn.email + " " +
|
||||
Auth().userLoggedIn.name + " " +
|
||||
Auth().userLoggedIn.firstName : "",
|
||||
Auth().userLoggedIn.firstname : "",
|
||||
style: TextStyle(color: Colors.blue)),
|
||||
Icon(Icons.arrow_forward_ios),
|
||||
]),
|
||||
|
||||
@@ -163,7 +163,7 @@ class _CustomerModifyPageState extends State<CustomerModifyPage> {
|
||||
labelText: AppLocalizations.of(context).translate('First Name'),
|
||||
),
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
initialValue: customerChangeModel.customer.customer.firstName,
|
||||
initialValue: customerChangeModel.customer.customer.firstname,
|
||||
onFieldSubmitted: (input) => customerChangeModel.customer.setFirstName(input)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -30,7 +30,7 @@ class _ExerciseNewPageState extends State {
|
||||
model.exerciseViewModel.createNew();
|
||||
customerName = model != null && model.customer != null
|
||||
? model.customer.name + " " +
|
||||
model.customer.firstName
|
||||
model.customer.firstname
|
||||
: "Please select a customer";
|
||||
|
||||
exerciseName = model != null &&
|
||||
@@ -157,7 +157,7 @@ class _ExerciseNewPageState extends State {
|
||||
inputFormatters: [
|
||||
WhitelistingTextInputFormatter(RegExp(r"[\d.]"))
|
||||
],
|
||||
onFieldSubmitted: (input) => {
|
||||
onChanged: (input) => {
|
||||
print ("UnitQuantity value $input"),
|
||||
model.exerciseViewModel.setUnitQuantity(
|
||||
double.parse(input))
|
||||
@@ -193,7 +193,7 @@ class _ExerciseNewPageState extends State {
|
||||
inputFormatters: [
|
||||
WhitelistingTextInputFormatter(RegExp(r"[\d.]"))
|
||||
],
|
||||
onFieldSubmitted: (input) =>
|
||||
onChanged: (input) =>
|
||||
{
|
||||
print ("Quantity value $input"),
|
||||
model.exerciseViewModel.setQuantity(
|
||||
|
||||
@@ -11,7 +11,7 @@ class CustomerViewModel {
|
||||
}
|
||||
|
||||
String get firstName {
|
||||
return this.customer.firstName;
|
||||
return this.customer.firstname;
|
||||
}
|
||||
|
||||
String get sex {
|
||||
@@ -26,7 +26,7 @@ class CustomerViewModel {
|
||||
this.customer.name = name;
|
||||
}
|
||||
setFirstName(String firstName) {
|
||||
this.customer.firstName = firstName;
|
||||
this.customer.firstname = firstName;
|
||||
}
|
||||
|
||||
setPassword( String password ) {
|
||||
|
||||
Reference in New Issue
Block a user