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

View File

@ -380,6 +380,13 @@ class AppState extends ChangeNotifier {
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() {
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 'sign_in_template_component_widget.dart'
show SignInTemplateComponentWidget;
@ -13,6 +15,8 @@ class SignInTemplateComponentModel
FocusNode? emailAddressFocusNode;
TextEditingController? emailAddressTextController;
String? Function(BuildContext, String?)? emailAddressTextControllerValidator;
SignInTemplateComponentModel();
String? _emailAddressTextControllerValidator(
BuildContext context, String? val) {
if (val == null || val.isEmpty) {

View File

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

View File

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

View File

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

View File

@ -72,87 +72,34 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
),
),
),
Row(
Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.fromLTRB(30, 0, 10, 0),
child: Tooltip(
message: FFLocalizations.of(context).getVariableText(
ptText:
'Seu identificador é utilizado para efetuar\no vinculo do seu APP com o condominio.',
enText: 'My Identifier'),
textStyle: FlutterFlowTheme.of(context)
.labelSmall
.override(
fontFamily: 'Nunito Sans',
color: FlutterFlowTheme.of(context)
.secondaryText,
fontSize: 10.0,
letterSpacing: 0.0,
fontWeight: FontWeight.w500,
useGoogleFonts: GoogleFonts.asMap()
.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),
Padding(
padding: const EdgeInsets.fromLTRB(60, 0, 60, 10),
child: Tooltip(
message: FFLocalizations.of(context).getVariableText(
ptText:
'Seu identificador é utilizado para efetuar\no vinculo do seu APP com o condominio.',
enText: 'My Identifier'),
textStyle: FlutterFlowTheme.of(context)
.labelSmall
.override(
fontFamily: 'Nunito Sans',
color:
FlutterFlowTheme.of(context).secondaryText,
fontSize: 10.0,
letterSpacing: 0.0,
fontWeight: FontWeight.w500,
useGoogleFonts: GoogleFonts.asMap()
.containsKey('Plus Jakarta Sans'),
),
showLoadingIndicator: false,
),
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.fromLTRB(10, 0, 30, 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,
),
},
);
},
onPressed: () => model.getIdenfifier(context),
text: FFLocalizations.of(context).getVariableText(
ptText: 'Sair da Conta', enText: 'Logout'),
ptText: 'Meu Identificador',
enText: 'My Identifier'),
options: FFButtonOptions(
width: double.infinity,
height: 44.0,
@ -160,7 +107,7 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
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,
color: FlutterFlowTheme.of(context).primary,
textStyle: FlutterFlowTheme.of(context)
.titleSmall
.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,
),
),
],
),
],