Merge branch 'fix/fd-826' into develop
This commit is contained in:
commit
ed4934ffdb
|
@ -98,7 +98,7 @@ class _CardItemTemplateComponentWidgetState
|
|||
}
|
||||
|
||||
Widget _generateImage() {
|
||||
CachedNetworkImage.evictFromCache(widget.imagePath ?? '');
|
||||
// CachedNetworkImage.evictFromCache(widget.imagePath ?? '');
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: CachedNetworkImage(
|
||||
|
|
|
@ -20,16 +20,14 @@ import 'package:responsive_framework/responsive_framework.dart';
|
|||
|
||||
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||
|
||||
|
||||
|
||||
void main() async {
|
||||
await _initializeApp();
|
||||
runApp(const App());
|
||||
}
|
||||
|
||||
|
||||
Future<void> _initializeApp() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
await _initializeStorageHelpers();
|
||||
await _initializeTracking();
|
||||
await _initializeFirebase();
|
||||
|
@ -39,15 +37,9 @@ Future<void> _initializeApp() async {
|
|||
await _initializeFlutterFlow();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Future<void> _initializeStorageHelpers() async {
|
||||
await StorageUtil().ensureInitialization();
|
||||
|
||||
|
||||
|
||||
// StorageUtil().isLogged = false;
|
||||
}
|
||||
|
||||
Future<void> _initializeTracking() async {
|
||||
|
@ -156,7 +148,8 @@ class _AppState extends State<App> {
|
|||
),
|
||||
);
|
||||
|
||||
final Iterable<LocalizationsDelegate<dynamic>>? localizationsDelegates = const [
|
||||
final Iterable<LocalizationsDelegate<dynamic>>? localizationsDelegates =
|
||||
const [
|
||||
FFLocalizationsDelegate(),
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
|
@ -181,7 +174,6 @@ class _AppState extends State<App> {
|
|||
);
|
||||
};
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
@ -201,7 +193,6 @@ class _AppState extends State<App> {
|
|||
_backgroundHandleMessage(message);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void setLocale(String language) {
|
||||
|
|
|
@ -344,6 +344,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
|||
enText: 'Pet registration limit reached',
|
||||
ptText: 'Limite de cadastro de pets atingido',
|
||||
);
|
||||
DialogUtil.error(buildContext!, errorMessage);
|
||||
} else {
|
||||
DialogUtil.errorDefault(buildContext!);
|
||||
}
|
||||
|
@ -367,22 +368,28 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
|||
clearFields();
|
||||
}
|
||||
|
||||
void clearFields() {
|
||||
Future<void> clearFields() async {
|
||||
uploadedLocalFile = null;
|
||||
|
||||
textControllerName?.clear();
|
||||
textControllerName?.clear();
|
||||
textControllerSpecies?.clear();
|
||||
textControllerRace?.clear();
|
||||
textControllerColor?.clear();
|
||||
textControllerData?.clear();
|
||||
textControllerObservation?.clear();
|
||||
textControllerName = TextEditingController(text: '');
|
||||
textControllerSpecies = TextEditingController(text: '');
|
||||
textControllerRace = TextEditingController(text: '');
|
||||
textControllerColor = TextEditingController(text: '');
|
||||
textControllerObservation = TextEditingController(text: '');
|
||||
|
||||
dropDownValue1 = null;
|
||||
dropDownValue2 = null;
|
||||
// textControllerData = TextEditingController(
|
||||
// text: dateTimeFormat(
|
||||
// 'dd/MM/yyyy',
|
||||
// DateTime.now(),
|
||||
// ));
|
||||
|
||||
dropDownValueController1 = FormFieldController<String>(null);
|
||||
dropDownValueController2 = FormFieldController<String>(null);
|
||||
// dropDownValue1 = '';
|
||||
// dropDownValue2 = '';
|
||||
|
||||
// dropDownValueController1 =
|
||||
// FormFieldController<String>('Selecione uma opção');
|
||||
// dropDownValueController2 =
|
||||
// FormFieldController<String>('Selecione uma opção');
|
||||
}
|
||||
|
||||
Widget buildPetDetails({
|
||||
|
|
|
@ -2,7 +2,6 @@ import 'dart:convert';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:http/http.dart';
|
||||
|
||||
|
@ -47,80 +46,22 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
|||
_model.updateOnChange = true;
|
||||
|
||||
_model.onUpdatePet = () {
|
||||
safeSetState(() {
|
||||
_model.clearFields();
|
||||
safeSetState(() async {
|
||||
await _model.clearFields();
|
||||
});
|
||||
};
|
||||
_model.onRegisterPet = () {
|
||||
safeSetState(() {
|
||||
_model.clearFields();
|
||||
safeSetState(() async {
|
||||
await _model.clearFields().then((_) => safeSetState(() {}));
|
||||
});
|
||||
};
|
||||
_model.safeSetState = () {
|
||||
safeSetState(() {});
|
||||
};
|
||||
|
||||
_model.updateImage = () => setState(() {
|
||||
_model.handleUploadComplete(_model.uploadedTempFile!);
|
||||
});
|
||||
|
||||
if (widget.pet != null) {
|
||||
int petId = widget.pet['id'];
|
||||
_model.petId = petId;
|
||||
|
||||
(() async {
|
||||
Response response = await get(Uri.parse(
|
||||
'https://freaccess.com.br/freaccess/getImage.php?devUUID=${_model.devUUID}&userUUID=${_model.userUUID}&cliID=${_model.cliUUID}&atividade=consultaFotoPet&petId=$petId'));
|
||||
String base64 = base64Encode(response.bodyBytes);
|
||||
FFUploadedFile uploadedFile =
|
||||
await ImageUtils.convertToUploadFile(base64);
|
||||
setState(() {
|
||||
_model.handleUploadComplete(uploadedFile);
|
||||
});
|
||||
})();
|
||||
}
|
||||
|
||||
_model.textControllerName ??= TextEditingController(
|
||||
text: widget.pet != null ? widget.pet['name'] ?? '' : '');
|
||||
_model.textFieldFocusName ??= FocusNode();
|
||||
|
||||
_model.textControllerSpecies ??= TextEditingController(
|
||||
text: widget.pet != null ? widget.pet['species'] ?? '' : '');
|
||||
_model.textFieldFocusSpecies ??= FocusNode();
|
||||
|
||||
_model.textControllerRace ??= TextEditingController(
|
||||
text: widget.pet != null ? widget.pet['breed'] ?? '' : '');
|
||||
_model.textFieldFocusRace ??= FocusNode();
|
||||
|
||||
_model.textControllerColor ??= TextEditingController(
|
||||
text: widget.pet != null ? widget.pet['color'] ?? '' : '');
|
||||
_model.textFieldFocusColor ??= FocusNode();
|
||||
|
||||
_model.textControllerData ??= TextEditingController(
|
||||
text: widget.pet != null
|
||||
? widget.pet['birthdayDate'] != null
|
||||
? ValidatorUtil.formatDateTimePicker(widget.pet['birthdayDate'])
|
||||
: ''
|
||||
: '');
|
||||
|
||||
_model.textFieldFocusData ??= FocusNode();
|
||||
|
||||
_model.textControllerObservation ??= TextEditingController(
|
||||
text: widget.pet != null ? widget.pet['notes'] ?? '' : '');
|
||||
_model.textFieldFocusObservation ??= FocusNode();
|
||||
|
||||
widget.pet != null
|
||||
? _model.dropDownValue1 ??= widget.pet['gender'] ?? ''
|
||||
: _model.dropDownValue1 ??= '';
|
||||
|
||||
widget.pet != null
|
||||
? _model.dropDownValue2 ??= widget.pet['size'] ?? ''
|
||||
: _model.dropDownValue2 ??= '';
|
||||
|
||||
_model.dropDownValueController1 ??=
|
||||
FormFieldController<String>(_model.dropDownValue1 ??= '');
|
||||
|
||||
_model.dropDownValueController2 ??=
|
||||
FormFieldController<String>(_model.dropDownValue2 ??= '');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -228,23 +169,20 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
|||
onChanged: (value) => setState(() {}),
|
||||
maxLength: 80,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
||||
child: CustomInputUtil(
|
||||
controller: _model.textControllerSpecies,
|
||||
validator: _model.textControllerSpeciesValidator
|
||||
.asValidator(context),
|
||||
focusNode: _model.textFieldFocusSpecies,
|
||||
labelText: FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Espécie', enText: 'Species'),
|
||||
hintText: FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Ex: Cachorro, Gato, Papagaio',
|
||||
enText: 'e.g. Dog, Cat, Parrot'),
|
||||
suffixIcon: Symbols.sound_detection_dog_barking,
|
||||
haveMaxLength: true,
|
||||
onChanged: (value) => setState(() {}),
|
||||
maxLength: 80,
|
||||
),
|
||||
CustomInputUtil(
|
||||
controller: _model.textControllerSpecies,
|
||||
validator: _model.textControllerSpeciesValidator
|
||||
.asValidator(context),
|
||||
focusNode: _model.textFieldFocusSpecies,
|
||||
labelText: FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Espécie', enText: 'Species'),
|
||||
hintText: FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Ex: Cachorro, Gato, Papagaio',
|
||||
enText: 'e.g. Dog, Cat, Parrot'),
|
||||
suffixIcon: Symbols.sound_detection_dog_barking,
|
||||
haveMaxLength: true,
|
||||
onChanged: (value) => setState(() {}),
|
||||
maxLength: 80,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15),
|
||||
|
@ -562,6 +500,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
|||
changed: (val) => safeSetState(() {
|
||||
_model.dropDownValue2 = val;
|
||||
}),
|
||||
dropDownValue: _model.dropDownValue2,
|
||||
optionsLabel: [
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Mini', enText: 'Mini'),
|
||||
|
@ -1029,6 +968,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
|||
changed: (val) => safeSetState(() {
|
||||
_model.dropDownValue2 = val;
|
||||
}),
|
||||
dropDownValue: _model.dropDownValue1,
|
||||
optionsLabel: [
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Mini', enText: 'Mini'),
|
||||
|
|
|
@ -14,24 +14,24 @@ class SecureStorageHelper extends ChangeNotifier implements Storage {
|
|||
|
||||
static SecureStorageHelper get instance => _instance;
|
||||
|
||||
|
||||
|
||||
|
||||
Future<void> setAndCacheString(String key, String value, Function(String) cacheSetter) async {
|
||||
Future<void> setAndCacheString(
|
||||
String key, String value, Function(String) cacheSetter) async {
|
||||
log('setAndCacheString value for key: $key to $value');
|
||||
await _secureStorage.write(key: key, value: value);
|
||||
CacheUtil.instance.set(key, value);
|
||||
cacheSetter(value);
|
||||
}
|
||||
|
||||
Future<void> setAndCacheBool(String key, bool value, Function(bool) cacheSetter) async {
|
||||
Future<void> setAndCacheBool(
|
||||
String key, bool value, Function(bool) cacheSetter) async {
|
||||
log('setAndCacheBool value for key: $key to $value');
|
||||
await _secureStorage.write(key: key, value: value.toString());
|
||||
CacheUtil.instance.set(key, value);
|
||||
cacheSetter(value);
|
||||
}
|
||||
|
||||
Future<void> setAndCacheObject(String key, String value, Function(String) cacheSetter) async {
|
||||
Future<void> setAndCacheObject(
|
||||
String key, String value, Function(String) cacheSetter) async {
|
||||
log('setAndCacheObject value for key: $key to $value');
|
||||
await _secureStorage.write(key: key, value: value);
|
||||
CacheUtil.instance.set(key, value);
|
||||
|
@ -69,7 +69,8 @@ class SecureStorageHelper extends ChangeNotifier implements Storage {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<void> set(String key, dynamic value, Function(dynamic) cacheSetter) async {
|
||||
Future<void> set(
|
||||
String key, dynamic value, Function(dynamic) cacheSetter) async {
|
||||
if (value is String) {
|
||||
await setAndCacheString(key, value, cacheSetter);
|
||||
} else if (value is bool) {
|
||||
|
@ -102,10 +103,8 @@ class SecureStorageHelper extends ChangeNotifier implements Storage {
|
|||
}
|
||||
|
||||
Future<void> purge() async {
|
||||
log('purge values');
|
||||
log('Purging secure storage');
|
||||
await _secureStorage.deleteAll();
|
||||
CacheUtil.instance.clear();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -50,8 +50,6 @@ class SQLiteStorageHelper implements Storage {
|
|||
|
||||
static SQLiteStorageHelper get instance => _instance;
|
||||
|
||||
|
||||
|
||||
Future<Database> get database async {
|
||||
log('Getting database instance');
|
||||
if (_database != null) return _database!;
|
||||
|
@ -141,7 +139,6 @@ class SQLiteStorageHelper implements Storage {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> setupLocalVariables() async {
|
||||
log('Setting up local variables');
|
||||
try {
|
||||
|
@ -190,8 +187,6 @@ class SQLiteStorageHelper implements Storage {
|
|||
return value == 'true';
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Future<dynamic> get(String key) async {
|
||||
log('Getting value for key: $key');
|
||||
|
@ -225,7 +220,8 @@ class SQLiteStorageHelper implements Storage {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<int> set(String key, dynamic value, Function(dynamic) cacheSetter) async {
|
||||
Future<int> set(
|
||||
String key, dynamic value, Function(dynamic) cacheSetter) async {
|
||||
log('Setting value for key: $key to $value');
|
||||
CacheUtil().set(key, value);
|
||||
final db = await database;
|
||||
|
@ -241,7 +237,7 @@ class SQLiteStorageHelper implements Storage {
|
|||
data,
|
||||
conflictAlgorithm: ConflictAlgorithm.replace,
|
||||
);
|
||||
log('Value $value set for key: $key');
|
||||
log('Value $value set for key: $key with result: $result');
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -262,7 +258,7 @@ class SQLiteStorageHelper implements Storage {
|
|||
|
||||
@override
|
||||
Future<void> purge() async {
|
||||
log('Purging database');
|
||||
log('Purging SQLite storage');
|
||||
await deleteDatabaseDB();
|
||||
await database;
|
||||
log('Database purged');
|
||||
|
@ -275,19 +271,6 @@ class SQLiteStorageHelper implements Storage {
|
|||
log('Database deleted');
|
||||
_database = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class SqliteStorageDelegate {}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -118,20 +118,17 @@ class StorageUtil {
|
|||
}
|
||||
|
||||
Future<void> ensureInitialization() async {
|
||||
await initSQLiteStorage();
|
||||
await initSharedPreferences();
|
||||
await initSecureStorage();
|
||||
await initSQLiteStorage();
|
||||
}
|
||||
|
||||
Future<void> initSharedPreferences() async {
|
||||
if (_sharedPreferences.prefs == null) {
|
||||
_sharedPreferences.prefs = await SharedPreferences.getInstance();
|
||||
_sharedPreferences.isFirstRun =
|
||||
_sharedPreferences.prefs?.getBool('first_run') ?? true;
|
||||
}
|
||||
if (_sharedPreferences.isFirstRun) {
|
||||
_sharedPreferences.prefs ??= await SharedPreferences.getInstance();
|
||||
_isFirstRun = _sharedPreferences.prefs?.getBool('first_run') ?? true;
|
||||
if (isFirstRun) {
|
||||
_sharedPreferences.isFirstRun = false;
|
||||
_sharedPreferences.purge();
|
||||
_secureStorage.purge();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,6 +155,26 @@ class StorageUtil {
|
|||
log('SQLiteStorageHelper: Starting initialization');
|
||||
try {
|
||||
await _sqliteStorage.database;
|
||||
_devUUID = await _sqliteStorage.get('devUUID') ?? '';
|
||||
_userUUID = await _sqliteStorage.get('userUUID') ?? '';
|
||||
_userDevUUID = await _sqliteStorage.get('userDevUUID') ?? '';
|
||||
_status = await _sqliteStorage.get('status') ?? '';
|
||||
_userName = await _sqliteStorage.get('userName') ?? '';
|
||||
_cliUUID = await _sqliteStorage.get('cliUUID') ?? '';
|
||||
_ownerUUID = await _sqliteStorage.get('ownerUUID') ?? '';
|
||||
_cliName = await _sqliteStorage.get('cliName') ?? '';
|
||||
_petAmountRegister = await _sqliteStorage.get('petAmountRegister') ?? '';
|
||||
_whatsapp = await _sqliteStorage.getBoolean('whatsapp');
|
||||
_provisional = await _sqliteStorage.getBoolean('provisional');
|
||||
_pets = await _sqliteStorage.getBoolean('pets');
|
||||
_local = await _sqliteStorage.getBoolean('local');
|
||||
_notify = await _sqliteStorage.getBoolean('notify');
|
||||
_fingerprint = await _sqliteStorage.getBoolean('fingerprint');
|
||||
_access = await _sqliteStorage.getBoolean('access');
|
||||
_panic = await _sqliteStorage.getBoolean('panic');
|
||||
_person = await _sqliteStorage.getBoolean('person');
|
||||
_requestOSnotification =
|
||||
await _sqliteStorage.getBoolean('requestOSnotification');
|
||||
} catch (e) {
|
||||
log('SQLiteStorageHelper: Error during initialization: $e');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue