commit
867cabd890
|
@ -9,6 +9,7 @@
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||||
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
|
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:label="FRE ACCESS HUB"
|
android:label="FRE ACCESS HUB"
|
||||||
|
@ -46,26 +47,41 @@
|
||||||
android:name="io.flutter.embedding.android.SplashScreenDrawable"
|
android:name="io.flutter.embedding.android.SplashScreenDrawable"
|
||||||
android:resource="@drawable/launch_background"
|
android:resource="@drawable/launch_background"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <meta-data android:name="flutter_deeplinking_enabled" android:value="true" /> -->
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<!-- Deep linking -->
|
|
||||||
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
|
|
||||||
|
|
||||||
<intent-filter android:autoVerify="true">
|
<intent-filter android:autoVerify="true">
|
||||||
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
|
<action android:name="mensagem" />
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
<data android:scheme="frehub" android:host="frehub.com" />
|
<data android:scheme="frehub" android:host="frehub.com" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="visit_request" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="access" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="mensagem" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<!-- <meta-data
|
<meta-data
|
||||||
android:name="com.google.firebase.messaging.default_notification_icon"
|
android:name="com.google.firebase.messaging.default_notification_icon"
|
||||||
android:resource="@drawable/notification_icon" /> -->
|
android:resource="@drawable/notification_icon" />
|
||||||
|
|
||||||
<!-- Don't delete the meta-data below.
|
<!-- Don't delete the meta-data below.
|
||||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||||
|
@ -87,4 +103,10 @@
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
<queries>
|
||||||
|
<intent>
|
||||||
|
<action android:name="android.intent.action.PROCESS_TEXT"/>
|
||||||
|
<data android:mimeType="text/plain"/>
|
||||||
|
</intent>
|
||||||
|
</queries>
|
||||||
</manifest>
|
</manifest>
|
|
@ -1,5 +1,6 @@
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:firebase_core/firebase_core.dart';
|
||||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||||
import 'package:hub/app_state.dart';
|
import 'package:hub/app_state.dart';
|
||||||
import 'package:hub/backend/api_requests/api_calls.dart';
|
import 'package:hub/backend/api_requests/api_calls.dart';
|
||||||
|
@ -30,16 +31,28 @@ class FirebaseMessagingService {
|
||||||
Future<void> initNotifications() async {
|
Future<void> initNotifications() async {
|
||||||
await _firebaseMessaging.requestPermission();
|
await _firebaseMessaging.requestPermission();
|
||||||
|
|
||||||
_refreshToken();
|
_firebaseMessaging.onTokenRefresh.listen((token) => updateDeviceToken);
|
||||||
|
|
||||||
_firebaseMessaging.setAutoInitEnabled(false);
|
_firebaseMessaging.setAutoInitEnabled(false);
|
||||||
_firebaseMessaging.pluginConstants;
|
_firebaseMessaging.pluginConstants;
|
||||||
|
|
||||||
FirebaseMessaging.onBackgroundMessage(handleMessage);
|
// FirebaseMessaging.onBackgroundMessage(handleMessage);
|
||||||
|
|
||||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
// FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||||
handleMessage(message);
|
// handleMessage(message);
|
||||||
});
|
// });
|
||||||
|
|
||||||
|
// FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
|
||||||
|
// log('A Message was opened: $message');
|
||||||
|
// });
|
||||||
|
|
||||||
|
// FirebaseMessaging.instance
|
||||||
|
// .getInitialMessage()
|
||||||
|
// .then((RemoteMessage? message) {
|
||||||
|
// if (message != null) {
|
||||||
|
// log('A Message was opened: $message');
|
||||||
|
// }
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateDeviceToken() async {
|
Future<void> updateDeviceToken() async {
|
||||||
|
@ -66,8 +79,4 @@ class FirebaseMessagingService {
|
||||||
LogUtil.requestAPIFailed("updToken.php", "", "Atualizar Token", e, s);
|
LogUtil.requestAPIFailed("updToken.php", "", "Atualizar Token", e, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _refreshToken() {
|
|
||||||
_firebaseMessaging.onTokenRefresh.listen((token) => updateDeviceToken);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,59 +14,10 @@ import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
|
||||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||||
import 'package:hub/shared/utils/dialog_util.dart';
|
import 'package:hub/shared/utils/dialog_util.dart';
|
||||||
|
|
||||||
class NotificationService {
|
Future<void> onMessageReceived(
|
||||||
static Future<void> initialize() async {
|
Map<String, dynamic> payload, String? extra, String? handleClick) async {
|
||||||
await AwesomeNotifications().initialize(
|
|
||||||
'resource://drawable/notification_icon',
|
|
||||||
[
|
|
||||||
NotificationChannel(
|
|
||||||
channelKey: 'basic_channel',
|
|
||||||
channelGroupKey: 'basic_channel',
|
|
||||||
channelName: 'Notificações do App',
|
|
||||||
channelDescription: 'Canal de notificação do Aplicativo',
|
|
||||||
importance: NotificationImportance.Max,
|
|
||||||
channelShowBadge: false,
|
|
||||||
playSound: true,
|
|
||||||
criticalAlerts: true,
|
|
||||||
onlyAlertOnce: true,
|
|
||||||
defaultColor: Colors.green,
|
|
||||||
ledColor: Colors.white,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
channelGroups: [
|
|
||||||
NotificationChannelGroup(
|
|
||||||
channelGroupKey: 'basic_channel_group',
|
|
||||||
channelGroupName: 'group_1')
|
|
||||||
],
|
|
||||||
debug: kDebugMode);
|
|
||||||
|
|
||||||
await AwesomeNotifications().isNotificationAllowed().then((isAllowed) async {
|
|
||||||
if (!AppState().isRequestOSNotification) {
|
|
||||||
if (!isAllowed) {
|
|
||||||
AppState().isRequestOSNotification = true;
|
|
||||||
await AwesomeNotifications().requestPermissionToSendNotifications();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
});
|
|
||||||
|
|
||||||
await AwesomeNotifications().setListeners(
|
|
||||||
onActionReceivedMethod: onActionReceivedMethod,
|
|
||||||
onNotificationCreatedMethod: onNotificationCreatedMethod,
|
|
||||||
onNotificationDisplayedMethod: onNotificationDisplayedMethod,
|
|
||||||
onDismissActionReceivedMethod: onDismissActionReceivedMethod);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Future<void> onActionReceivedMethod(
|
|
||||||
ReceivedAction receivedAction) async {
|
|
||||||
final payload = receivedAction.payload ?? {};
|
|
||||||
final extra = receivedAction.body;
|
|
||||||
final handleClick = payload['click_action'];
|
|
||||||
|
|
||||||
final localId = jsonDecode(payload['local']!)['CLI_ID'];
|
final localId = jsonDecode(payload['local']!)['CLI_ID'];
|
||||||
|
|
||||||
log('payload: $payload');
|
|
||||||
log('extra: $extra');
|
|
||||||
switch (handleClick) {
|
switch (handleClick) {
|
||||||
case 'visit_request':
|
case 'visit_request':
|
||||||
showDialog(
|
showDialog(
|
||||||
|
@ -83,70 +34,26 @@ class NotificationService {
|
||||||
FlutterFlowIconButton(
|
FlutterFlowIconButton(
|
||||||
icon: const Icon(Icons.done),
|
icon: const Icon(Icons.done),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
showDialog(
|
showAlertDialog(
|
||||||
context: context,
|
context,
|
||||||
builder: (context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: Text(
|
|
||||||
FFLocalizations.of(context).getVariableText(
|
FFLocalizations.of(context).getVariableText(
|
||||||
ptText: 'Aprovar Visita',
|
ptText: 'Aprovar Visita',
|
||||||
enText: 'Approve Visit',
|
enText: 'Approve Visit',
|
||||||
),
|
),
|
||||||
),
|
|
||||||
content: Text(
|
|
||||||
FFLocalizations.of(context).getVariableText(
|
FFLocalizations.of(context).getVariableText(
|
||||||
ptText:
|
ptText:
|
||||||
'Você tem certeza que deseja aprovar essa visita?',
|
'Você tem certeza que deseja aprovar essa visita?',
|
||||||
enText:
|
enText:
|
||||||
'Are you sure you want to approve this visit?',
|
'Are you sure you want to approve this visit?',
|
||||||
),
|
),
|
||||||
),
|
() async {
|
||||||
backgroundColor: FlutterFlowTheme.of(context)
|
await answersRequest(
|
||||||
.primaryBackground,
|
|
||||||
actions: [
|
|
||||||
FFButtonWidget(
|
|
||||||
text: FFLocalizations.of(context)
|
|
||||||
.getVariableText(
|
|
||||||
enText: 'No',
|
|
||||||
ptText: 'Não',
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
context.pop();
|
|
||||||
},
|
|
||||||
options: FFButtonOptions(
|
|
||||||
width: 100,
|
|
||||||
height: 40,
|
|
||||||
color: FlutterFlowTheme.of(context)
|
|
||||||
.primaryBackground,
|
|
||||||
textStyle: TextStyle(
|
|
||||||
color: FlutterFlowTheme.of(context)
|
|
||||||
.primaryText,
|
|
||||||
),
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: FlutterFlowTheme.of(context)
|
|
||||||
.primaryBackground,
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
borderRadius:
|
|
||||||
BorderRadius.circular(10)),
|
|
||||||
),
|
|
||||||
FFButtonWidget(
|
|
||||||
text: FFLocalizations.of(context)
|
|
||||||
.getVariableText(
|
|
||||||
enText: 'Yes',
|
|
||||||
ptText: 'Sim',
|
|
||||||
),
|
|
||||||
onPressed: () async {
|
|
||||||
log("payload: $payload");
|
|
||||||
await answersRequest
|
|
||||||
.call(
|
|
||||||
context,
|
context,
|
||||||
payload['referencia'].toString(),
|
payload['referencia'].toString(),
|
||||||
'L',
|
'L',
|
||||||
'Mensagem',
|
'Mensagem',
|
||||||
payload['idVisitante'].toString(),
|
payload['idVisitante'].toString(),
|
||||||
)
|
).then((value) {
|
||||||
.then((value) {
|
|
||||||
if (value) {
|
if (value) {
|
||||||
context.pop();
|
context.pop();
|
||||||
context.pop();
|
context.pop();
|
||||||
|
@ -161,26 +68,7 @@ class NotificationService {
|
||||||
DialogUtil.errorDefault(context);
|
DialogUtil.errorDefault(context);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
options: FFButtonOptions(
|
|
||||||
width: 100,
|
|
||||||
height: 40,
|
|
||||||
color: FlutterFlowTheme.of(context)
|
|
||||||
.primaryBackground,
|
|
||||||
textStyle: TextStyle(
|
|
||||||
color: FlutterFlowTheme.of(context)
|
|
||||||
.primaryText,
|
|
||||||
),
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: FlutterFlowTheme.of(context)
|
|
||||||
.primaryBackground,
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
});
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
FlutterFlowIconButton(
|
FlutterFlowIconButton(
|
||||||
|
@ -309,6 +197,59 @@ class NotificationService {
|
||||||
// showAlertDialog(AppState().context!, 'Test', 'Test', () async {});
|
// showAlertDialog(AppState().context!, 'Test', 'Test', () async {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class NotificationService {
|
||||||
|
static Future<void> initialize() async {
|
||||||
|
await AwesomeNotifications().initialize(
|
||||||
|
'resource://drawable/notification_icon',
|
||||||
|
[
|
||||||
|
NotificationChannel(
|
||||||
|
channelKey: 'basic_channel',
|
||||||
|
channelGroupKey: 'basic_channel',
|
||||||
|
channelName: 'Notificações do App',
|
||||||
|
channelDescription: 'Canal de notificação do Aplicativo',
|
||||||
|
importance: NotificationImportance.Max,
|
||||||
|
channelShowBadge: false,
|
||||||
|
playSound: true,
|
||||||
|
criticalAlerts: true,
|
||||||
|
onlyAlertOnce: true,
|
||||||
|
defaultColor: Colors.green,
|
||||||
|
ledColor: Colors.white,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
channelGroups: [
|
||||||
|
NotificationChannelGroup(
|
||||||
|
channelGroupKey: 'basic_channel_group',
|
||||||
|
channelGroupName: 'group_1')
|
||||||
|
],
|
||||||
|
debug: kDebugMode);
|
||||||
|
|
||||||
|
await AwesomeNotifications()
|
||||||
|
.isNotificationAllowed()
|
||||||
|
.then((isAllowed) async {
|
||||||
|
if (!AppState().isRequestOSNotification) {
|
||||||
|
if (!isAllowed) {
|
||||||
|
AppState().isRequestOSNotification = true;
|
||||||
|
await AwesomeNotifications().requestPermissionToSendNotifications();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
|
||||||
|
await AwesomeNotifications().setListeners(
|
||||||
|
onActionReceivedMethod: onActionReceivedMethod,
|
||||||
|
onNotificationCreatedMethod: onNotificationCreatedMethod,
|
||||||
|
onNotificationDisplayedMethod: onNotificationDisplayedMethod,
|
||||||
|
onDismissActionReceivedMethod: onDismissActionReceivedMethod);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<void> onActionReceivedMethod(
|
||||||
|
ReceivedAction receivedAction) async {
|
||||||
|
final payload = receivedAction.payload ?? {};
|
||||||
|
final extra = receivedAction.body;
|
||||||
|
final handleClick = payload['click_action'];
|
||||||
|
onMessageReceived(payload, extra, handleClick);
|
||||||
|
}
|
||||||
|
|
||||||
static Future<void> onNotificationCreatedMethod(
|
static Future<void> onNotificationCreatedMethod(
|
||||||
ReceivedNotification receivedNotification) async {}
|
ReceivedNotification receivedNotification) async {}
|
||||||
|
|
||||||
|
|
|
@ -73,9 +73,10 @@ class DefaultFirebaseOptions {
|
||||||
projectId: 'accessmoblie-da839',
|
projectId: 'accessmoblie-da839',
|
||||||
databaseURL: 'https://accessmoblie-da839.firebaseio.com',
|
databaseURL: 'https://accessmoblie-da839.firebaseio.com',
|
||||||
storageBucket: 'accessmoblie-da839.appspot.com',
|
storageBucket: 'accessmoblie-da839.appspot.com',
|
||||||
androidClientId: '187064172787-7et0qu5p2qtmisvqgndn3kfi1b7u9ifl.apps.googleusercontent.com',
|
androidClientId:
|
||||||
iosClientId: '187064172787-c5gs7fvp78om9r7dofkjn2qmpumkuvig.apps.googleusercontent.com',
|
'187064172787-7et0qu5p2qtmisvqgndn3kfi1b7u9ifl.apps.googleusercontent.com',
|
||||||
|
iosClientId:
|
||||||
|
'187064172787-c5gs7fvp78om9r7dofkjn2qmpumkuvig.apps.googleusercontent.com',
|
||||||
iosBundleId: 'br.com.freaccess.hub',
|
iosBundleId: 'br.com.freaccess.hub',
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
|
@ -3,12 +3,12 @@ import 'dart:developer';
|
||||||
import 'package:app_tracking_transparency/app_tracking_transparency.dart';
|
import 'package:app_tracking_transparency/app_tracking_transparency.dart';
|
||||||
import 'package:firebase_core/firebase_core.dart';
|
import 'package:firebase_core/firebase_core.dart';
|
||||||
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
|
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
|
||||||
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:flutter_web_plugins/url_strategy.dart';
|
import 'package:flutter_web_plugins/url_strategy.dart';
|
||||||
import 'package:hub/backend/notifications/firebase_messaging_service.dart';
|
|
||||||
import 'package:hub/backend/notifications/notification_service.dart';
|
import 'package:hub/backend/notifications/notification_service.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';
|
||||||
|
@ -28,7 +28,6 @@ Future<void> initializeApp() async {
|
||||||
await appState.initializePersistedState();
|
await appState.initializePersistedState();
|
||||||
|
|
||||||
await Firebase.initializeApp();
|
await Firebase.initializeApp();
|
||||||
await FirebaseMessagingService().initNotifications();
|
|
||||||
await NotificationService.initialize();
|
await NotificationService.initialize();
|
||||||
|
|
||||||
setUrlStrategy(const PathUrlStrategy());
|
setUrlStrategy(const PathUrlStrategy());
|
||||||
|
@ -48,6 +47,15 @@ Future<void> initializeApp() async {
|
||||||
usePathUrlStrategy();
|
usePathUrlStrategy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> foregroundHandleMessage(RemoteMessage message) async {
|
||||||
|
NotificationService.show(
|
||||||
|
title: message.notification!.title!,
|
||||||
|
body: message.notification!.body!,
|
||||||
|
payload: Map<String, String>.from(message.data));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _backgroundHandleMessage(RemoteMessage message) async {}
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
await initializeApp();
|
await initializeApp();
|
||||||
runApp(const App());
|
runApp(const App());
|
||||||
|
@ -79,6 +87,19 @@ class _AppState extends State<App> {
|
||||||
_router = createRouter(_appStateNotifier);
|
_router = createRouter(_appStateNotifier);
|
||||||
Future.delayed(const Duration(milliseconds: 1000),
|
Future.delayed(const Duration(milliseconds: 1000),
|
||||||
() => setState(() => _appStateNotifier.stopShowingSplashImage()));
|
() => setState(() => _appStateNotifier.stopShowingSplashImage()));
|
||||||
|
|
||||||
|
FirebaseMessaging.onMessage.listen(foregroundHandleMessage);
|
||||||
|
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
|
||||||
|
onMessageReceived(message.data, message.notification!.body,
|
||||||
|
message.data['click_action']);
|
||||||
|
});
|
||||||
|
FirebaseMessaging.onBackgroundMessage(_backgroundHandleMessage);
|
||||||
|
|
||||||
|
FirebaseMessaging.instance.getInitialMessage().then((message) {
|
||||||
|
if (message != null) {
|
||||||
|
_backgroundHandleMessage(message);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -120,9 +120,9 @@ class _HomePageWidgetState extends State<HomePageWidget> {
|
||||||
_model = createModel(context, () => HomePageModel());
|
_model = createModel(context, () => HomePageModel());
|
||||||
_model.updateOnChange = true;
|
_model.updateOnChange = true;
|
||||||
|
|
||||||
() async {
|
FirebaseMessagingService().updateDeviceToken();
|
||||||
await FirebaseMessagingService().updateDeviceToken();
|
|
||||||
|
|
||||||
|
() async {
|
||||||
if (AppState().cliUUID.isEmpty) {
|
if (AppState().cliUUID.isEmpty) {
|
||||||
await processLocals();
|
await processLocals();
|
||||||
}
|
}
|
||||||
|
@ -252,4 +252,75 @@ class _HomePageWidgetState extends State<HomePageWidget> {
|
||||||
child: _localProfileComponentWidget,
|
child: _localProfileComponentWidget,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> processData() async {
|
||||||
|
try {
|
||||||
|
var response = await PhpGroup.getDadosCall.call(
|
||||||
|
devUUID: AppState().devUUID,
|
||||||
|
userUUID: AppState().userUUID,
|
||||||
|
cliUUID: AppState().cliUUID,
|
||||||
|
atividade: 'getDados',
|
||||||
|
);
|
||||||
|
|
||||||
|
final error = response.jsonBody['error'];
|
||||||
|
final errorMsg = response.jsonBody['error_msg'];
|
||||||
|
|
||||||
|
if (error == false) {
|
||||||
|
AppState().whatsapp = response.jsonBody['whatsapp'] ?? false;
|
||||||
|
AppState().provisional = response.jsonBody['provisional'] ?? false;
|
||||||
|
AppState().name = response.jsonBody['visitado']['VDO_NOME'];
|
||||||
|
safeSetState(() {});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DialogUtil.warningDefault(context).whenComplete(() => processLocals());
|
||||||
|
safeSetState(() {});
|
||||||
|
return;
|
||||||
|
} catch (e, s) {
|
||||||
|
DialogUtil.warningDefault(context).whenComplete(() => processLocals());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> processLocals() async {
|
||||||
|
try {
|
||||||
|
var response = await PhpGroup.getLocalsCall.call(
|
||||||
|
devUUID: AppState().devUUID,
|
||||||
|
userUUID: AppState().userUUID,
|
||||||
|
);
|
||||||
|
|
||||||
|
List<dynamic> locals = response.jsonBody['locais'] ?? [];
|
||||||
|
|
||||||
|
final activeLocals =
|
||||||
|
locals.where((local) => local['CLU_STATUS'] == 'A').toList();
|
||||||
|
|
||||||
|
if (activeLocals.isEmpty || AppState().cliUUID.isEmpty) {
|
||||||
|
await showModalSelectLocal();
|
||||||
|
} else {
|
||||||
|
await processData();
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
await showModalSelectLocal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> showModalSelectLocal() async {
|
||||||
|
await showModalBottomSheet(
|
||||||
|
isScrollControlled: true,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
enableDrag: false,
|
||||||
|
isDismissible: false,
|
||||||
|
context: context,
|
||||||
|
builder: (context) => Padding(
|
||||||
|
padding: MediaQuery.viewInsetsOf(context),
|
||||||
|
child: const BottomArrowLinkedLocalsComponentWidget(),
|
||||||
|
),
|
||||||
|
).then((_) async {
|
||||||
|
_model.updatePage(() => safeSetState(() {
|
||||||
|
_localProfileComponentWidget = LocalProfileComponentWidget(
|
||||||
|
showBottomSheet: showModalSelectLocal);
|
||||||
|
}));
|
||||||
|
|
||||||
|
await processData();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue