This commit is contained in:
J. A. Messias 2024-09-19 11:05:24 -03:00
parent 07059d9bad
commit b742777f74
5 changed files with 48 additions and 31 deletions

View File

@ -116,6 +116,29 @@ class AppState extends ChangeNotifier {
await loadFirstRun(); await loadFirstRun();
} }
bool _firstRun = true;
bool get firstRun => _firstRun;
Future<void> loadFirstRun() async {
final prefs = await SharedPreferences.getInstance();
_firstRun = prefs.getBool('first_run') ?? true;
notifyListeners();
}
Future<void> setFirstRun(bool value) async {
final prefs = await SharedPreferences.getInstance();
_firstRun = value;
await prefs.setBool('first_run', value);
notifyListeners();
}
Future<void> deleteFirstRun() async {
final prefs = await SharedPreferences.getInstance();
_firstRun = true;
await prefs.remove('first_run');
notifyListeners();
}
void update(VoidCallback callback) { void update(VoidCallback callback) {
callback(); callback();
notifyListeners(); notifyListeners();

View File

@ -204,13 +204,6 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
Future<void> signOut(BuildContext context) async { Future<void> signOut(BuildContext context) async {
final DatabaseHelper db = DatabaseHelper(); final DatabaseHelper db = DatabaseHelper();
final userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
final devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
showAlertDialog( showAlertDialog(
context, context,
'Logout', 'Logout',
@ -220,7 +213,6 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
), () async { ), () async {
PhpGroup.unregisterDevice.call(); PhpGroup.unregisterDevice.call();
AppState().deleteAll(); AppState().deleteAll();
await db.purge();
context.go( context.go(
'/welcomePage', '/welcomePage',
@ -232,6 +224,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
), ),
}, },
); );
await db.purge();
}); });
} }

View File

@ -23,7 +23,7 @@ final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
Future<void> initializeApp() async { Future<void> initializeApp() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
// DatabaseHelper().deleteDatabaseDB(); DatabaseHelper().deleteDatabaseDB();
await DatabaseHelper().database; await DatabaseHelper().database;
final status = await AppTrackingTransparency.requestTrackingAuthorization(); final status = await AppTrackingTransparency.requestTrackingAuthorization();

View File

@ -271,7 +271,9 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
Future<void> updatePet() async { Future<void> updatePet() async {
var img = await actions.convertImageFileToBase64(uploadedLocalFile!); var img = await actions.convertImageFileToBase64(uploadedLocalFile!);
img = "base64;jpeg,$img"; img = "base64;jpeg,$img";
await PhpGroup.updatePet.call( final url =
'https://freaccess.com.br/freaccess/getImage.php?devUUID=${devUUID}&userUUID=${userUUID}&cliID=${cliUUID}&atividade=consultaFotoPet&petId=$petId';
final response = await PhpGroup.updatePet.call(
petID: petId, petID: petId,
image: imgBase64, image: imgBase64,
birthdayDate: textControllerData!.text, birthdayDate: textControllerData!.text,
@ -314,7 +316,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
Future<void> registerPet() async { Future<void> registerPet() async {
var img = await actions.convertImageFileToBase64(uploadedLocalFile!); var img = await actions.convertImageFileToBase64(uploadedLocalFile!);
img = "base64;jpeg,$img"; img = "base64;jpeg,$img";
await PhpGroup.registerPet.call( final response = await PhpGroup.registerPet.call(
image: img, image: img,
birthdayDate: textControllerData!.text, birthdayDate: textControllerData!.text,
color: textControllerColor!.text, color: textControllerColor!.text,

View File

@ -65,27 +65,27 @@ class DatabaseHelper {
); );
'''); ''');
// ---------------------------------------------- // ----------------------------------------------
await insert('devUUID', '', 'user'); insert('devUUID', '', 'user');
await insert('userUUID', '', 'user'); insert('userUUID', '', 'user');
await insert('userDevUUID', '', 'user'); insert('userDevUUID', '', 'user');
await insert('status', '', 'user'); insert('status', '', 'user');
await insert('userName', '', 'user'); insert('userName', '', 'user');
// ---------------------------------------------- // ----------------------------------------------
await insert('cliUUID', '', 'local'); insert('cliUUID', '', 'local');
await insert('ownerUUID', '', 'local'); insert('ownerUUID', '', 'local');
await insert('cliName', '', 'local'); insert('cliName', '', 'local');
// ---------------------------------------------- // ----------------------------------------------
await insert('whatsapp', 'false', 'util'); insert('whatsapp', 'false', 'util');
await insert('provisional', 'false', 'util'); insert('provisional', 'false', 'util');
await insert('pets', 'false', 'util'); insert('pets', 'false', 'util');
await insert('local', 'false', 'util'); insert('local', 'false', 'util');
await insert('notify', 'false', 'util'); insert('notify', 'false', 'util');
await insert('fingerprint', 'false', 'util'); insert('fingerprint', 'false', 'util');
await insert('access', 'false', 'util'); insert('access', 'false', 'util');
await insert('panic', 'false', 'util'); insert('panic', 'false', 'util');
await insert('person', 'false', 'util'); insert('person', 'false', 'util');
await insert('requestOSnotification', 'false', 'util'); insert('requestOSnotification', 'false', 'util');
await insert('petAmountRegister', '', 'local'); insert('petAmountRegister', '', 'local');
// ---------------------------------------------- // ----------------------------------------------
log('Tables created'); log('Tables created');
} }
@ -226,7 +226,6 @@ class DatabaseHelper {
await helper.deleteDatabaseDB(); await helper.deleteDatabaseDB();
await helper.database; await helper.database;
await database;
log('Purge'); log('Purge');
} }