Feat: Configuração de Rotas e Ajuste na pagina de Reception
This commit is contained in:
parent
af95679fa1
commit
a2c76286e6
|
@ -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,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(
|
||||
'homePage',
|
||||
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,
|
||||
|
@ -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) {
|
||||
if (response.jsonBody['locais']
|
||||
.any((local) => local['CLU_STATUS'] == "A")) {
|
||||
return true;
|
||||
} else {
|
||||
// A chamada para showModalBottomSheet permanece, mas a atualização da UI é otimizada.
|
||||
}
|
||||
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(
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -71,7 +71,9 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter(
|
|||
name: '_initialize',
|
||||
path: '/',
|
||||
builder: (context, _) => AppState().isLogged
|
||||
? 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': '.*',
|
||||
|
|
|
@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -72,11 +72,12 @@ 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),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(60, 0, 60, 10),
|
||||
child: Tooltip(
|
||||
message: FFLocalizations.of(context).getVariableText(
|
||||
ptText:
|
||||
|
@ -86,8 +87,8 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
|
|||
.labelSmall
|
||||
.override(
|
||||
fontFamily: 'Nunito Sans',
|
||||
color: FlutterFlowTheme.of(context)
|
||||
.secondaryText,
|
||||
color:
|
||||
FlutterFlowTheme.of(context).secondaryText,
|
||||
fontSize: 10.0,
|
||||
letterSpacing: 0.0,
|
||||
fontWeight: FontWeight.w500,
|
||||
|
@ -104,8 +105,7 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
|
|||
height: 44.0,
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||
0.0, 0.0, 0.0, 0.0),
|
||||
iconPadding:
|
||||
const EdgeInsetsDirectional.fromSTEB(
|
||||
iconPadding: const EdgeInsetsDirectional.fromSTEB(
|
||||
0.0, 0.0, 0.0, 0.0),
|
||||
color: FlutterFlowTheme.of(context).primary,
|
||||
textStyle: FlutterFlowTheme.of(context)
|
||||
|
@ -131,10 +131,8 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
|
|||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(10, 0, 30, 0),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(60, 0, 60, 0),
|
||||
child: FFButtonWidget(
|
||||
onPressed: () async {
|
||||
AppState().deleteAll();
|
||||
|
@ -183,7 +181,6 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
|
|||
showLoadingIndicator: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue