Feat: Configuração de Rotas e Ajuste na pagina de Reception

This commit is contained in:
Lucas 2024-08-23 11:05:28 -03:00
parent af95679fa1
commit a2c76286e6
7 changed files with 136 additions and 115 deletions

View File

@ -1,3 +1,5 @@
import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// import 'package:hub/components/organisms/bottom_arrow_linked_locals/bottom_arrow_linked_locals_component_widget.dart'; // import 'package:hub/components/organisms/bottom_arrow_linked_locals/bottom_arrow_linked_locals_component_widget.dart';
import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/backend/api_requests/api_calls.dart';
@ -96,7 +98,8 @@ Future<Color> manageStatusColorAction(
} }
Future singInLoginAction( Future singInLoginAction(
BuildContext context, { BuildContext context,
FlutterFlowModel model, {
String? emailAdress, String? emailAdress,
String? password, String? password,
}) async { }) async {
@ -158,7 +161,11 @@ Future singInLoginAction(
AppState().isLogged = true; AppState().isLogged = true;
await toggleHomePage(context); bool _haveLocal = await checkLocals(context: context, model: model);
print(await checkLocals(context: context, model: model));
AppState().haveLocal = _haveLocal;
await toggleApp(context, AppState().haveLocal);
} else { } else {
if (PhpGroup.loginCall.msg((loginCall?.jsonBody ?? '')) == null) { if (PhpGroup.loginCall.msg((loginCall?.jsonBody ?? '')) == null) {
DialogUtil.errorDefault(context); DialogUtil.errorDefault(context);
@ -302,16 +309,27 @@ Future toggleSignUpPage(BuildContext context) async {
); );
} }
Future toggleHomePage(BuildContext context) async { Future toggleApp(BuildContext context, bool haveLocal) async {
context.goNamed( if (haveLocal == true)
'homePage', context.goNamed(
extra: <String, dynamic>{ 'homePage',
kTransitionInfoKey: const TransitionInfo( extra: <String, dynamic>{
hasTransition: true, kTransitionInfoKey: const TransitionInfo(
transitionType: PageTransitionType.fade, hasTransition: true,
), transitionType: PageTransitionType.fade,
}, ),
); },
);
else
context.goNamed(
'receptionPage',
extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
transitionType: PageTransitionType.fade,
)
},
);
} }
Future<bool> visitCancelAction(BuildContext context, Future<bool> visitCancelAction(BuildContext context,
@ -370,8 +388,7 @@ Future<void> snackbar(BuildContext context, {required bool opt}) async {
Future<bool> checkLocals({ Future<bool> checkLocals({
String? cliUUID, String? cliUUID,
required BuildContext context, required BuildContext context,
required HomePageModel model, required FlutterFlowModel model,
required void Function(void Function()) safeSetState,
}) async { }) async {
// A chamada para a API permanece a mesma, assumindo que é necessária sempre. // A chamada para a API permanece a mesma, assumindo que é necessária sempre.
final response = await PhpGroup.getLocalsCall.call( final response = await PhpGroup.getLocalsCall.call(
@ -386,32 +403,26 @@ Future<bool> checkLocals({
// Uso eficiente de coleções para verificar a condição desejada. // Uso eficiente de coleções para verificar a condição desejada.
final String uuid = cliUUID ?? AppState().cliUUID; final String uuid = cliUUID ?? AppState().cliUUID;
final bool itemFound = response.jsonBody['locais'].any( final bool itemFound =
(local) => local['CLI_ID'] == uuid && local['CLU_STATUS'] == "A", response.jsonBody['locais'].any((local) => local['CLI_ID'] == uuid);
);
// Log e retorno condicional baseado no resultado da busca.
if (itemFound) { if (itemFound) {
return true; if (response.jsonBody['locais']
} else { .any((local) => local['CLU_STATUS'] == "A")) {
// A chamada para showModalBottomSheet permanece, mas a atualização da UI é otimizada. return true;
}
await showModalBottomSheet( await showModalBottomSheet(
isScrollControlled: true, isScrollControlled: true,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
enableDrag: false, enableDrag: false,
isDismissible: false,
context: context, context: context,
builder: (context) => GestureDetector( builder: (context) => Padding(
onTap: () => model.unfocusNode.canRequestFocus padding: MediaQuery.viewInsetsOf(context),
? FocusScope.of(context).requestFocus(model.unfocusNode) child: const BottomArrowLinkedLocalsComponentWidget(),
: FocusScope.of(context).unfocus(),
child: Padding(
padding: MediaQuery.viewInsetsOf(context),
child: const BottomArrowLinkedLocalsComponentWidget(),
),
), ),
); ); // Chamada oti
safeSetState( return false;
() {}); // Chamada otimizada fora do then para evitar encadeamentos desnecessários. } else {
return false; return false;
} }
} }

View File

@ -380,6 +380,13 @@ class AppState extends ChangeNotifier {
secureStorage.setBool('ff_isLogged', value); secureStorage.setBool('ff_isLogged', value);
} }
bool _haveLocal = false;
bool get haveLocal => _haveLocal;
set haveLocal(bool value) {
_haveLocal = value;
secureStorage.setBool('ff_local', value);
}
void deleteIsLogged() { void deleteIsLogged() {
secureStorage.delete(key: 'ff_isLogged'); secureStorage.delete(key: 'ff_isLogged');
} }

View File

@ -1,3 +1,5 @@
import 'package:hub/pages/home_page/home_page_model.dart';
import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_util.dart';
import 'sign_in_template_component_widget.dart' import 'sign_in_template_component_widget.dart'
show SignInTemplateComponentWidget; show SignInTemplateComponentWidget;
@ -13,6 +15,8 @@ class SignInTemplateComponentModel
FocusNode? emailAddressFocusNode; FocusNode? emailAddressFocusNode;
TextEditingController? emailAddressTextController; TextEditingController? emailAddressTextController;
String? Function(BuildContext, String?)? emailAddressTextControllerValidator; String? Function(BuildContext, String?)? emailAddressTextControllerValidator;
SignInTemplateComponentModel();
String? _emailAddressTextControllerValidator( String? _emailAddressTextControllerValidator(
BuildContext context, String? val) { BuildContext context, String? val) {
if (val == null || val.isEmpty) { if (val == null || val.isEmpty) {

View File

@ -548,6 +548,7 @@ class _SignInTemplateComponentWidgetState
await action_blocks await action_blocks
.singInLoginAction( .singInLoginAction(
context, context,
_model,
emailAdress: _model emailAdress: _model
.emailAddressTextController .emailAddressTextController
.text, .text,
@ -707,6 +708,7 @@ class _SignInTemplateComponentWidgetState
await action_blocks await action_blocks
.singInLoginAction( .singInLoginAction(
context, context,
_model,
emailAdress: _model emailAdress: _model
.emailAddressTextController .emailAddressTextController
.text, .text,

View File

@ -71,7 +71,9 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter(
name: '_initialize', name: '_initialize',
path: '/', path: '/',
builder: (context, _) => AppState().isLogged builder: (context, _) => AppState().isLogged
? const HomePageWidget() ? AppState().haveLocal
? const HomePageWidget()
: const ReceptionPageWidget()
: const WelcomePageWidget(), : const WelcomePageWidget(),
), ),
FFRoute( FFRoute(
@ -133,7 +135,7 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter(
FFRoute( FFRoute(
name: 'acessHistoryPage', name: 'acessHistoryPage',
path: '/acessHistoryPage', path: '/acessHistoryPage',
builder: (context, params) => AcessHistoryPageWidget(opt: { builder: (context, params) => AcessHistoryPageWidget(opt: const {
'personType': '.*', 'personType': '.*',
'accessType': '.*', 'accessType': '.*',
'search': '.*', 'search': '.*',

View File

@ -29,12 +29,10 @@ class _HomePageWidgetState extends State<HomePageWidget> {
bool localStatus = false; bool localStatus = false;
final scaffoldKey = GlobalKey<ScaffoldState>(); final scaffoldKey = GlobalKey<ScaffoldState>();
Future<void> checkLocalStatus() async { Future<void> checkLocalStatus() async {
localStatus = await checkLocals( localStatus = await checkLocals(
context: context, context: context,
model: _model, model: _model,
safeSetState: safeSetState,
); );
} }

View File

@ -72,87 +72,34 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
), ),
), ),
), ),
Row( Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: [ children: [
Expanded( Padding(
child: Padding( padding: const EdgeInsets.fromLTRB(60, 0, 60, 10),
padding: const EdgeInsets.fromLTRB(30, 0, 10, 0), child: Tooltip(
child: Tooltip( message: FFLocalizations.of(context).getVariableText(
message: FFLocalizations.of(context).getVariableText( ptText:
ptText: 'Seu identificador é utilizado para efetuar\no vinculo do seu APP com o condominio.',
'Seu identificador é utilizado para efetuar\no vinculo do seu APP com o condominio.', enText: 'My Identifier'),
enText: 'My Identifier'), textStyle: FlutterFlowTheme.of(context)
textStyle: FlutterFlowTheme.of(context) .labelSmall
.labelSmall .override(
.override( fontFamily: 'Nunito Sans',
fontFamily: 'Nunito Sans', color:
color: FlutterFlowTheme.of(context) FlutterFlowTheme.of(context).secondaryText,
.secondaryText, fontSize: 10.0,
fontSize: 10.0, letterSpacing: 0.0,
letterSpacing: 0.0, fontWeight: FontWeight.w500,
fontWeight: FontWeight.w500, useGoogleFonts: GoogleFonts.asMap()
useGoogleFonts: GoogleFonts.asMap() .containsKey('Plus Jakarta Sans'),
.containsKey('Plus Jakarta Sans'),
),
child: FFButtonWidget(
onPressed: () => model.getIdenfifier(context),
text: FFLocalizations.of(context).getVariableText(
ptText: 'Meu Identificador',
enText: 'My Identifier'),
options: FFButtonOptions(
width: double.infinity,
height: 44.0,
padding: const EdgeInsetsDirectional.fromSTEB(
0.0, 0.0, 0.0, 0.0),
iconPadding:
const EdgeInsetsDirectional.fromSTEB(
0.0, 0.0, 0.0, 0.0),
color: FlutterFlowTheme.of(context).primary,
textStyle: FlutterFlowTheme.of(context)
.titleSmall
.override(
fontFamily: 'Nunito Sans',
color: FlutterFlowTheme.of(context)
.primaryBackground,
fontSize: 14.0,
letterSpacing: 0.0,
fontWeight: FontWeight.w500,
useGoogleFonts: GoogleFonts.asMap()
.containsKey('Plus Jakarta Sans'),
),
elevation: 3.0,
borderSide: const BorderSide(
color: Colors.transparent,
width: 1.0,
),
borderRadius: BorderRadius.circular(12.0),
), ),
showLoadingIndicator: false,
),
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.fromLTRB(10, 0, 30, 0),
child: FFButtonWidget( child: FFButtonWidget(
onPressed: () async { onPressed: () => model.getIdenfifier(context),
AppState().deleteAll();
setState(() {});
context.goNamed(
'welcomePage',
extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
transitionType: PageTransitionType.scale,
alignment: Alignment.bottomCenter,
),
},
);
},
text: FFLocalizations.of(context).getVariableText( text: FFLocalizations.of(context).getVariableText(
ptText: 'Sair da Conta', enText: 'Logout'), ptText: 'Meu Identificador',
enText: 'My Identifier'),
options: FFButtonOptions( options: FFButtonOptions(
width: double.infinity, width: double.infinity,
height: 44.0, height: 44.0,
@ -160,7 +107,7 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
0.0, 0.0, 0.0, 0.0), 0.0, 0.0, 0.0, 0.0),
iconPadding: const EdgeInsetsDirectional.fromSTEB( iconPadding: const EdgeInsetsDirectional.fromSTEB(
0.0, 0.0, 0.0, 0.0), 0.0, 0.0, 0.0, 0.0),
color: FlutterFlowTheme.of(context).customColor1, color: FlutterFlowTheme.of(context).primary,
textStyle: FlutterFlowTheme.of(context) textStyle: FlutterFlowTheme.of(context)
.titleSmall .titleSmall
.override( .override(
@ -184,6 +131,56 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
), ),
), ),
), ),
Padding(
padding: const EdgeInsets.fromLTRB(60, 0, 60, 0),
child: FFButtonWidget(
onPressed: () async {
AppState().deleteAll();
setState(() {});
context.goNamed(
'welcomePage',
extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
transitionType: PageTransitionType.scale,
alignment: Alignment.bottomCenter,
),
},
);
},
text: FFLocalizations.of(context).getVariableText(
ptText: 'Sair da Conta', enText: 'Logout'),
options: FFButtonOptions(
width: double.infinity,
height: 44.0,
padding: const EdgeInsetsDirectional.fromSTEB(
0.0, 0.0, 0.0, 0.0),
iconPadding: const EdgeInsetsDirectional.fromSTEB(
0.0, 0.0, 0.0, 0.0),
color: FlutterFlowTheme.of(context).customColor1,
textStyle: FlutterFlowTheme.of(context)
.titleSmall
.override(
fontFamily: 'Nunito Sans',
color: FlutterFlowTheme.of(context)
.primaryBackground,
fontSize: 14.0,
letterSpacing: 0.0,
fontWeight: FontWeight.w500,
useGoogleFonts: GoogleFonts.asMap()
.containsKey('Plus Jakarta Sans'),
),
elevation: 3.0,
borderSide: const BorderSide(
color: Colors.transparent,
width: 1.0,
),
borderRadius: BorderRadius.circular(12.0),
),
showLoadingIndicator: false,
),
),
], ],
), ),
], ],