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,7 +309,8 @@ Future toggleSignUpPage(BuildContext context) async {
); );
} }
Future toggleHomePage(BuildContext context) async { Future toggleApp(BuildContext context, bool haveLocal) async {
if (haveLocal == true)
context.goNamed( context.goNamed(
'homePage', 'homePage',
extra: <String, dynamic>{ extra: <String, dynamic>{
@ -312,6 +320,16 @@ Future toggleHomePage(BuildContext context) async {
), ),
}, },
); );
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) {
if (response.jsonBody['locais']
.any((local) => local['CLU_STATUS'] == "A")) {
return true; return true;
} else { }
// A chamada para showModalBottomSheet permanece, mas a atualização da UI é otimizada.
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
? FocusScope.of(context).requestFocus(model.unfocusNode)
: FocusScope.of(context).unfocus(),
child: Padding(
padding: MediaQuery.viewInsetsOf(context), padding: MediaQuery.viewInsetsOf(context),
child: const BottomArrowLinkedLocalsComponentWidget(), child: const BottomArrowLinkedLocalsComponentWidget(),
), ),
), ); // Chamada oti
); return false;
safeSetState( } else {
() {}); // Chamada otimizada fora do then para evitar encadeamentos desnecessários.
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
? AppState().haveLocal
? const HomePageWidget() ? 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,11 +72,12 @@ 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:
@ -86,8 +87,8 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
.labelSmall .labelSmall
.override( .override(
fontFamily: 'Nunito Sans', fontFamily: 'Nunito Sans',
color: FlutterFlowTheme.of(context) color:
.secondaryText, FlutterFlowTheme.of(context).secondaryText,
fontSize: 10.0, fontSize: 10.0,
letterSpacing: 0.0, letterSpacing: 0.0,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
@ -104,8 +105,7 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
height: 44.0, height: 44.0,
padding: const EdgeInsetsDirectional.fromSTEB( padding: const EdgeInsetsDirectional.fromSTEB(
0.0, 0.0, 0.0, 0.0), 0.0, 0.0, 0.0, 0.0),
iconPadding: iconPadding: const EdgeInsetsDirectional.fromSTEB(
const EdgeInsetsDirectional.fromSTEB(
0.0, 0.0, 0.0, 0.0), 0.0, 0.0, 0.0, 0.0),
color: FlutterFlowTheme.of(context).primary, color: FlutterFlowTheme.of(context).primary,
textStyle: FlutterFlowTheme.of(context) textStyle: FlutterFlowTheme.of(context)
@ -131,10 +131,8 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
), ),
), ),
), ),
), Padding(
Expanded( padding: const EdgeInsets.fromLTRB(60, 0, 60, 0),
child: Padding(
padding: const EdgeInsets.fromLTRB(10, 0, 30, 0),
child: FFButtonWidget( child: FFButtonWidget(
onPressed: () async { onPressed: () async {
AppState().deleteAll(); AppState().deleteAll();
@ -183,7 +181,6 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
showLoadingIndicator: false, showLoadingIndicator: false,
), ),
), ),
),
], ],
), ),
], ],