WIP
This commit is contained in:
parent
31e20ab37c
commit
b29cb152b9
|
@ -4,7 +4,6 @@ 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';
|
||||||
import 'package:hub/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart';
|
import 'package:hub/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart';
|
||||||
import 'package:hub/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart';
|
|
||||||
import 'package:hub/custom_code/actions/get_dev_u_u_i_d.dart';
|
import 'package:hub/custom_code/actions/get_dev_u_u_i_d.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||||
|
@ -138,28 +137,24 @@ Future singInLoginAction(
|
||||||
AppState().userUUID = PhpGroup.loginCall.userUUID(
|
AppState().userUUID = PhpGroup.loginCall.userUUID(
|
||||||
(loginCall.jsonBody ?? ''),
|
(loginCall.jsonBody ?? ''),
|
||||||
)!;
|
)!;
|
||||||
|
|
||||||
AppState().createdAt = dateTimeFormat(
|
AppState().createdAt = dateTimeFormat(
|
||||||
'd/M/y H:mm:ss',
|
'd/M/y H:mm:ss',
|
||||||
getCurrentTimestamp,
|
getCurrentTimestamp,
|
||||||
locale: FFLocalizations.of(context).languageCode,
|
locale: FFLocalizations.of(context).languageCode,
|
||||||
);
|
);
|
||||||
|
|
||||||
AppState().updatedAt = '00/00/0000 00:00:00';
|
AppState().updatedAt = '00/00/0000 00:00:00';
|
||||||
|
|
||||||
AppState().status =
|
AppState().status =
|
||||||
PhpGroup.loginCall.userStatus((loginCall.jsonBody ?? ''))!;
|
PhpGroup.loginCall.userStatus((loginCall.jsonBody ?? ''))!;
|
||||||
|
|
||||||
AppState().userDevUUID =
|
AppState().userDevUUID =
|
||||||
PhpGroup.loginCall.userDeviceId((loginCall.jsonBody ?? ''))!;
|
PhpGroup.loginCall.userDeviceId((loginCall.jsonBody ?? ''))!;
|
||||||
|
|
||||||
PhpGroup.loginCall.userName((loginCall.jsonBody ?? ''))!;
|
PhpGroup.loginCall.userName((loginCall.jsonBody ?? ''))!;
|
||||||
|
|
||||||
AppState().serialNumber = await getSerialNumber() ?? '';
|
AppState().serialNumber = await getSerialNumber() ?? '';
|
||||||
|
|
||||||
AppState().isLogged = true;
|
AppState().isLogged = true;
|
||||||
AppState().haveLocal = await checkLocals(context: context, model: model)
|
|
||||||
.then((value) async => await toggleApp(context, value));
|
AppState().haveLocal =
|
||||||
|
await checkLocals(context: context, model: model);
|
||||||
|
log('haveLocal in login: ${AppState().haveLocal}');
|
||||||
|
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);
|
||||||
|
@ -304,6 +299,7 @@ Future toggleSignUpPage(BuildContext context) async {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future toggleApp(BuildContext context, bool haveLocal) async {
|
Future toggleApp(BuildContext context, bool haveLocal) async {
|
||||||
|
log('haveLocal in toggleApp: $haveLocal');
|
||||||
if (haveLocal == true)
|
if (haveLocal == true)
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'homePage',
|
'homePage',
|
||||||
|
@ -400,19 +396,6 @@ Future<bool> checkLocals({
|
||||||
if (locals.isEmpty) {
|
if (locals.isEmpty) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (locals.where((local) => local['CLU_STATUS'] != 'A').isNotEmpty) {
|
|
||||||
await showModalBottomSheet(
|
|
||||||
isScrollControlled: true,
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
enableDrag: false,
|
|
||||||
isDismissible: false,
|
|
||||||
context: context,
|
|
||||||
builder: (context) => Padding(
|
|
||||||
padding: MediaQuery.viewInsetsOf(context),
|
|
||||||
child: const BottomArrowLinkedLocalsComponentWidget(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,6 +216,17 @@ class AppState extends ChangeNotifier {
|
||||||
secureStorage.delete(key: 'panic');
|
secureStorage.delete(key: 'panic');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool? _haveLocal = null;
|
||||||
|
bool? get haveLocal => _haveLocal;
|
||||||
|
set haveLocal(bool? value) {
|
||||||
|
_haveLocal = value;
|
||||||
|
secureStorage.setBool('ff_have_local', value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void deleteHaveLocal() {
|
||||||
|
secureStorage.delete(key: 'ff_have_local');
|
||||||
|
}
|
||||||
|
|
||||||
String _fingerprintPass = '';
|
String _fingerprintPass = '';
|
||||||
String get fingerprintPass => _fingerprintPass;
|
String get fingerprintPass => _fingerprintPass;
|
||||||
set fingerprintPass(String value) {
|
set fingerprintPass(String value) {
|
||||||
|
@ -412,13 +423,6 @@ 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_have_local', value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void deleteIsLogged() {
|
void deleteIsLogged() {
|
||||||
secureStorage.delete(key: 'ff_isLogged');
|
secureStorage.delete(key: 'ff_isLogged');
|
||||||
}
|
}
|
||||||
|
@ -549,7 +553,7 @@ extension FlutterSecureStorageExtensions on FlutterSecureStorage {
|
||||||
await writeSync(key: key, value: value);
|
await writeSync(key: key, value: value);
|
||||||
|
|
||||||
Future<bool?> getBool(String key) async => (await read(key: key)) == 'true';
|
Future<bool?> getBool(String key) async => (await read(key: key)) == 'true';
|
||||||
Future<void> setBool(String key, bool value) async =>
|
Future<void> setBool(String key, bool? value) async =>
|
||||||
await writeSync(key: key, value: value.toString());
|
await writeSync(key: key, value: value.toString());
|
||||||
|
|
||||||
Future<int?> getInt(String key) async =>
|
Future<int?> getInt(String key) async =>
|
||||||
|
|
|
@ -183,7 +183,6 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
ptText: 'Tem certeza',
|
ptText: 'Tem certeza',
|
||||||
), () async {
|
), () async {
|
||||||
AppState().deleteAll();
|
AppState().deleteAll();
|
||||||
// setState(() {});
|
|
||||||
|
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'welcomePage',
|
'welcomePage',
|
||||||
|
|
|
@ -72,7 +72,7 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter(
|
||||||
name: '_initialize',
|
name: '_initialize',
|
||||||
path: '/',
|
path: '/',
|
||||||
builder: (context, _) => AppState().isLogged
|
builder: (context, _) => AppState().isLogged
|
||||||
? AppState().haveLocal
|
? AppState().haveLocal == true
|
||||||
? const HomePageWidget()
|
? const HomePageWidget()
|
||||||
: const ReceptionPageWidget()
|
: const ReceptionPageWidget()
|
||||||
: const WelcomePageWidget(),
|
: const WelcomePageWidget(),
|
||||||
|
|
|
@ -90,6 +90,7 @@ class _AppState extends State<App> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
log("haveLocals: ${AppState().haveLocal}");
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
ChangeNotifierProvider(create: (_) => AppState()),
|
ChangeNotifierProvider(create: (_) => AppState()),
|
||||||
|
|
|
@ -3,10 +3,10 @@ import 'dart:developer';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:hub/actions/actions.dart';
|
|
||||||
import 'package:hub/backend/api_requests/api_calls.dart';
|
import 'package:hub/backend/api_requests/api_calls.dart';
|
||||||
import 'package:hub/backend/notifications/firebase_messaging_service.dart';
|
import 'package:hub/backend/notifications/firebase_messaging_service.dart';
|
||||||
import 'package:hub/backend/schema/enums/enums.dart';
|
import 'package:hub/backend/schema/enums/enums.dart';
|
||||||
|
import 'package:hub/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart';
|
||||||
import 'package:hub/components/organism_components/local_profile_component/local_profile_component_widget.dart';
|
import 'package:hub/components/organism_components/local_profile_component/local_profile_component_widget.dart';
|
||||||
import 'package:hub/components/organism_components/menu_component/menu_component_widget.dart';
|
import 'package:hub/components/organism_components/menu_component/menu_component_widget.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_icon_button.dart';
|
import 'package:hub/flutter_flow/flutter_flow_icon_button.dart';
|
||||||
|
@ -28,7 +28,7 @@ class _HomePageWidgetState extends State<HomePageWidget> {
|
||||||
late HomePageModel _model;
|
late HomePageModel _model;
|
||||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
void checkData() async {
|
Future checkData() async {
|
||||||
final response = await PhpGroup.getDadosCall.call(
|
final response = await PhpGroup.getDadosCall.call(
|
||||||
devUUID: AppState().devUUID,
|
devUUID: AppState().devUUID,
|
||||||
userUUID: AppState().userUUID,
|
userUUID: AppState().userUUID,
|
||||||
|
@ -60,6 +60,46 @@ class _HomePageWidgetState extends State<HomePageWidget> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future checkLocal() async {
|
||||||
|
final response = await PhpGroup.getLocalsCall.call(
|
||||||
|
devUUID: AppState().devUUID,
|
||||||
|
userUUID: AppState().userUUID,
|
||||||
|
);
|
||||||
|
log(response.jsonBody.toString());
|
||||||
|
List<dynamic> locals = response.jsonBody['locais'] ?? [];
|
||||||
|
|
||||||
|
final activeLocals =
|
||||||
|
locals.where((local) => local['CLU_STATUS'] == 'A').toList();
|
||||||
|
log("activeLocals $activeLocals");
|
||||||
|
if (activeLocals.isEmpty) {
|
||||||
|
await showModalBottomSheet(
|
||||||
|
isScrollControlled: true,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
enableDrag: false,
|
||||||
|
isDismissible: false,
|
||||||
|
context: context,
|
||||||
|
builder: (context) => Padding(
|
||||||
|
padding: MediaQuery.viewInsetsOf(context),
|
||||||
|
child: const BottomArrowLinkedLocalsComponentWidget(),
|
||||||
|
),
|
||||||
|
).then((_) => checkData());
|
||||||
|
} else if (AppState().cliUUID.isEmpty) {
|
||||||
|
showModalBottomSheet(
|
||||||
|
isScrollControlled: true,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
enableDrag: false,
|
||||||
|
isDismissible: false,
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return Padding(
|
||||||
|
padding: MediaQuery.viewInsetsOf(context),
|
||||||
|
child: const BottomArrowLinkedLocalsComponentWidget(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
).then((_) => checkData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
@ -67,14 +107,17 @@ class _HomePageWidgetState extends State<HomePageWidget> {
|
||||||
|
|
||||||
AppState().context = context;
|
AppState().context = context;
|
||||||
|
|
||||||
|
checkLocal();
|
||||||
|
|
||||||
() async {
|
() async {
|
||||||
await FirebaseMessagingService().updateDeviceToken();
|
await FirebaseMessagingService().updateDeviceToken();
|
||||||
}();
|
}();
|
||||||
|
|
||||||
checkLocals(
|
() async {
|
||||||
context: context,
|
await FirebaseMessagingService().updateDeviceToken();
|
||||||
model: _model,
|
}();
|
||||||
).then((_) => checkData());
|
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) async {});
|
||||||
|
|
||||||
_model.textController ??= TextEditingController();
|
_model.textController ??= TextEditingController();
|
||||||
_model.textFieldFocusNode ??= FocusNode();
|
_model.textFieldFocusNode ??= FocusNode();
|
||||||
|
|
|
@ -310,9 +310,9 @@ class PreferencesPageModel with ChangeNotifier {
|
||||||
)
|
)
|
||||||
.then((value) {
|
.then((value) {
|
||||||
if (value.jsonBody['error'] == false) {
|
if (value.jsonBody['error'] == false) {
|
||||||
AppState().deleteCliUUID();
|
// AppState().deleteCliUUID();
|
||||||
AppState().deleteLocal();
|
// AppState().deleteLocal();
|
||||||
AppState().deleteOwnerUUID();
|
// AppState().deleteOwnerUUID();
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'homePage',
|
'homePage',
|
||||||
extra: <String, dynamic>{
|
extra: <String, dynamic>{
|
||||||
|
|
Loading…
Reference in New Issue