From 6a2bda3b38df9b4b9939961b690dcbfba76eb507 Mon Sep 17 00:00:00 2001 From: jantunesmesias Date: Tue, 6 Aug 2024 14:02:56 -0300 Subject: [PATCH] add AlertDialog in ToggleAccessNotification --- .../preferences_settings_model.dart | 350 ++++++++---------- 1 file changed, 162 insertions(+), 188 deletions(-) diff --git a/lib/pages/preferences_settings_page/preferences_settings_model.dart b/lib/pages/preferences_settings_page/preferences_settings_model.dart index 680d5781..62911c21 100644 --- a/lib/pages/preferences_settings_page/preferences_settings_model.dart +++ b/lib/pages/preferences_settings_page/preferences_settings_model.dart @@ -219,7 +219,7 @@ class PreferencesPageModel with ChangeNotifier { borderRadius: BorderRadius.circular(10), ), ), - ].divide(const SizedBox(width: 2)), + ], ), ], ); @@ -246,84 +246,90 @@ class PreferencesPageModel with ChangeNotifier { ), ), actions: [ - FFButtonWidget( - text: FFLocalizations.of(context).getVariableText( - enText: 'Cancel', - ptText: 'Cancelar', - ), - onPressed: () { - Navigator.pop(context); - }, - options: FFButtonOptions( - width: MediaQuery.of(context).size.width * 0.3, - height: MediaQuery.of(context).size.height * 0.05, - color: FlutterFlowTheme.of(context).primaryBackground, - textStyle: TextStyle( - color: FlutterFlowTheme.of(context).primaryText, + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisSize: MainAxisSize.max, + children: [ + FFButtonWidget( + text: FFLocalizations.of(context).getVariableText( + enText: 'Cancel', + ptText: 'Cancelar', ), - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).primaryBackground, - width: 1, - ), - borderRadius: BorderRadius.circular(10)), - ), - FFButtonWidget( - onPressed: () async { - PhpGroup.resopndeVinculo - .call( - userUUID: FFAppState().userUUID, - devUUID: FFAppState().devUUID, - cliID: FFAppState().cliUUID, - tarefa: 'I', - ) - // ignore: body_might_complete_normally_catch_error - .catchError((err, stack) { - log(err.toString()); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - FFLocalizations.of(context).getVariableText( - enText: 'Error unlinking device', - ptText: 'Erro ao desvincular dispositivo', - ), - style: TextStyle( - color: FlutterFlowTheme.of(context).info)), - backgroundColor: FlutterFlowTheme.of(context).error, - duration: const Duration(seconds: 3), - behavior: SnackBarBehavior.floating, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(30), - ), - ), - ); - }).then( - (value) { - FFAppState().deleteCliUUID(); - FFAppState().deleteLocal(); - FFAppState().deleteOwnerUUID(); - Navigator.pop(context); + onPressed: () { Navigator.pop(context); }, - ); - notifyListeners(); - }, - text: FFLocalizations.of(context).getVariableText( - enText: 'Unlink', - ptText: 'Desvincular', - ), - options: FFButtonOptions( - width: MediaQuery.of(context).size.width * 0.3, - height: MediaQuery.of(context).size.height * 0.05, - color: FlutterFlowTheme.of(context).primaryBackground, - textStyle: TextStyle( - color: FlutterFlowTheme.of(context).primaryText, + options: FFButtonOptions( + width: MediaQuery.of(context).size.width * 0.3, + height: MediaQuery.of(context).size.height * 0.05, + color: FlutterFlowTheme.of(context).primaryBackground, + textStyle: TextStyle( + color: FlutterFlowTheme.of(context).primaryText, + ), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context).primaryBackground, + width: 1, + ), + borderRadius: BorderRadius.circular(10)), ), - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).primaryBackground, - width: 1, + FFButtonWidget( + onPressed: () async { + PhpGroup.resopndeVinculo + .call( + userUUID: FFAppState().userUUID, + devUUID: FFAppState().devUUID, + cliID: FFAppState().cliUUID, + tarefa: 'I', + ) + // ignore: body_might_complete_normally_catch_error + .catchError((err, stack) { + log(err.toString()); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + FFLocalizations.of(context).getVariableText( + enText: 'Error unlinking device', + ptText: 'Erro ao desvincular dispositivo', + ), + style: TextStyle( + color: FlutterFlowTheme.of(context).info)), + backgroundColor: FlutterFlowTheme.of(context).error, + duration: const Duration(seconds: 3), + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30), + ), + ), + ); + }).then( + (value) { + FFAppState().deleteCliUUID(); + FFAppState().deleteLocal(); + FFAppState().deleteOwnerUUID(); + Navigator.pop(context); + Navigator.pop(context); + }, + ); + notifyListeners(); + }, + text: FFLocalizations.of(context).getVariableText( + enText: 'Unlink', + ptText: 'Desvincular', + ), + options: FFButtonOptions( + width: MediaQuery.of(context).size.width * 0.3, + height: MediaQuery.of(context).size.height * 0.05, + color: FlutterFlowTheme.of(context).primaryBackground, + textStyle: TextStyle( + color: FlutterFlowTheme.of(context).primaryText, + ), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context).primaryBackground, + width: 1, + ), + borderRadius: BorderRadius.circular(10), + ), ), - borderRadius: BorderRadius.circular(10), - ), + ], ), ], ); @@ -350,128 +356,96 @@ class PreferencesPageModel with ChangeNotifier { ), ), actions: [ - FFButtonWidget( - onPressed: () => Navigator.pop(context), - options: FFButtonOptions( - width: MediaQuery.of(context).size.width * 0.3, - height: MediaQuery.of(context).size.height * 0.05, - color: FlutterFlowTheme.of(context).primaryBackground, - textStyle: TextStyle( - color: FlutterFlowTheme.of(context).primaryText, - ), - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).primaryBackground, - width: 1, - ), - borderRadius: BorderRadius.circular(10), - ), - text: FFLocalizations.of(context).getVariableText( - enText: 'Cancel', - ptText: 'Cancelar', - ), - ), - FFButtonWidget( - onPressed: () { - PhpGroup.deleteAccount - .call( - devUUID: FFAppState().devUUID, - userUUID: FFAppState().userUUID, - ) - .then((value) { - FFAppState().deleteAll(); - FFAppState().isLogged = false; - context.goNamed( - 'welcomePage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - }).catchError((err) { - log(err.toString()); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - FFLocalizations.of(context).getVariableText( - enText: 'Error deleting account', - ptText: 'Erro ao deletar conta', - ), - style: TextStyle( - color: FlutterFlowTheme.of(context).info)), - backgroundColor: FlutterFlowTheme.of(context).error, - duration: const Duration(seconds: 3), - behavior: SnackBarBehavior.floating, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(30), - ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisSize: MainAxisSize.max, + children: [ + FFButtonWidget( + onPressed: () => Navigator.pop(context), + options: FFButtonOptions( + width: MediaQuery.of(context).size.width * 0.3, + height: MediaQuery.of(context).size.height * 0.05, + color: FlutterFlowTheme.of(context).primaryBackground, + textStyle: TextStyle( + color: FlutterFlowTheme.of(context).primaryText, ), - ); - }); - notifyListeners(); - }, - options: FFButtonOptions( - width: MediaQuery.of(context).size.width * 0.3, - height: MediaQuery.of(context).size.height * 0.05, - color: FlutterFlowTheme.of(context).primaryBackground, - textStyle: TextStyle( - color: FlutterFlowTheme.of(context).primaryText, + borderSide: BorderSide( + color: FlutterFlowTheme.of(context).primaryBackground, + width: 1, + ), + borderRadius: BorderRadius.circular(10), + ), + text: FFLocalizations.of(context).getVariableText( + enText: 'Cancel', + ptText: 'Cancelar', + ), ), - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).primaryBackground, - width: 1, + FFButtonWidget( + onPressed: () { + PhpGroup.deleteAccount + .call( + devUUID: FFAppState().devUUID, + userUUID: FFAppState().userUUID, + ) + .then((value) { + FFAppState().deleteAll(); + FFAppState().isLogged = false; + context.goNamed( + 'welcomePage', + extra: { + kTransitionInfoKey: const TransitionInfo( + hasTransition: true, + transitionType: PageTransitionType.scale, + alignment: Alignment.bottomCenter, + ), + }, + ); + }).catchError((err) { + log(err.toString()); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + FFLocalizations.of(context).getVariableText( + enText: 'Error deleting account', + ptText: 'Erro ao deletar conta', + ), + style: TextStyle( + color: FlutterFlowTheme.of(context).info)), + backgroundColor: FlutterFlowTheme.of(context).error, + duration: const Duration(seconds: 3), + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30), + ), + ), + ); + }); + notifyListeners(); + }, + options: FFButtonOptions( + width: MediaQuery.of(context).size.width * 0.3, + height: MediaQuery.of(context).size.height * 0.05, + color: FlutterFlowTheme.of(context).primaryBackground, + textStyle: TextStyle( + color: FlutterFlowTheme.of(context).primaryText, + ), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context).primaryBackground, + width: 1, + ), + borderRadius: BorderRadius.circular(10), + ), + text: FFLocalizations.of(context).getVariableText( + enText: 'Delete', + ptText: 'Deletar', + ), ), - borderRadius: BorderRadius.circular(10), - ), - text: FFLocalizations.of(context).getVariableText( - enText: 'Delete', - ptText: 'Deletar', - ), + ], ), ], ); }); notifyListeners(); - - // PhpGroup.deleteAccount - // .call( - // devUUID: FFAppState().devUUID, - // userUUID: FFAppState().userUUID, - // ) - // .then((value) { - // FFAppState().deleteAll(); - // FFAppState().isLogged = false; - // context.goNamed( - // 'welcomePage', - // extra: { - // kTransitionInfoKey: const TransitionInfo( - // hasTransition: true, - // transitionType: PageTransitionType.scale, - // alignment: Alignment.bottomCenter, - // ), - // }, - // ); - // }).catchError((err) { - // log(err.toString()); - // ScaffoldMessenger.of(context).showSnackBar( - // SnackBar( - // content: Text( - // FFLocalizations.of(context).getVariableText( - // ptText: 'Erro ao deletar dispositivo', - // enText: 'Error deleting device', - // ), - // style: TextStyle(color: FlutterFlowTheme.of(context).info)), - // backgroundColor: FlutterFlowTheme.of(context).error, - // duration: const Duration(seconds: 3), - // behavior: SnackBarBehavior.floating, - // shape: RoundedRectangleBorder( - // borderRadius: BorderRadius.circular(30), - // ), - // ), - // ); - // }); } Future togglePass(BuildContext context) async {