bug: FastPass WebView iOS
This commit is contained in:
parent
ae33972b26
commit
c740a75d10
|
@ -128,29 +128,19 @@ class _BottomArrowLinkedLocalsComponentWidgetState
|
||||||
hoverColor: Colors.transparent,
|
hoverColor: Colors.transparent,
|
||||||
highlightColor: Colors.transparent,
|
highlightColor: Colors.transparent,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
|
if (localItem['CLU_STATUS'] == 'A') {
|
||||||
|
|
||||||
if (linkedLocals.any((local) =>
|
FFAppState().cliUUID = localItem['CLI_ID'];
|
||||||
local['CLI_ID'] == FFAppState().cliUUID &&
|
|
||||||
local['CLU_STATUS'] == "A")) {
|
|
||||||
FFAppState().cliUUID = getJsonField(
|
|
||||||
localItem,
|
|
||||||
r'''$.CLI_ID''',
|
|
||||||
).toString();
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
FFAppState().local = getJsonField(
|
FFAppState().local = localItem['CLI_NOME'];
|
||||||
localItem,
|
|
||||||
r'''$.CLI_NOME''',
|
|
||||||
).toString();
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
FFAppState().ownerUUID = getJsonField(
|
FFAppState().ownerUUID = localItem['CLU_OWNER_ID'];
|
||||||
localItem,
|
|
||||||
r'''$.CLU_OWNER_ID''',
|
|
||||||
).toString();
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
debugPrint('Local: ${FFAppState().local}');
|
debugPrint('Local: ${FFAppState().local}');
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} else {
|
} else {
|
||||||
debugPrint('Local não disponível');
|
debugPrint('Local não disponível');
|
||||||
|
debugPrint(localItem.toString());
|
||||||
// ScaffoldMessenger.of(context).showSnackBar(
|
// ScaffoldMessenger.of(context).showSnackBar(
|
||||||
// SnackBar(
|
// SnackBar(
|
||||||
// content: Text(
|
// content: Text(
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import 'package:f_r_e_hub/app_state.dart';
|
import 'package:f_r_e_hub/app_state.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||||
import 'package:url_launcher/url_launcher_string.dart';
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
import 'package:webview_flutter/webview_flutter.dart';
|
import 'package:webview_flutter/webview_flutter.dart';
|
||||||
|
import 'dart:io' show Platform;
|
||||||
import '/flutter_flow/flutter_flow_util.dart';
|
import '/flutter_flow/flutter_flow_util.dart';
|
||||||
|
|
||||||
class FastPassPageWidget extends StatefulWidget {
|
class FastPassPageWidget extends StatefulWidget {
|
||||||
|
@ -16,14 +18,13 @@ class FastPassPageWidget extends StatefulWidget {
|
||||||
|
|
||||||
final String clientId = FFAppState().cliUUID;
|
final String clientId = FFAppState().cliUUID;
|
||||||
|
|
||||||
// const FastPassPageWidget({ Key? key,}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_FastPassPageWidgetState createState() => _FastPassPageWidgetState();
|
_FastPassPageWidgetState createState() => _FastPassPageWidgetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _FastPassPageWidgetState extends State<FastPassPageWidget> {
|
class _FastPassPageWidgetState extends State<FastPassPageWidget> {
|
||||||
late WebViewController _controller;
|
late InAppWebViewController _controllerIOS;
|
||||||
|
late WebViewController _controllerAll;
|
||||||
late String url;
|
late String url;
|
||||||
late String name;
|
late String name;
|
||||||
late String email;
|
late String email;
|
||||||
|
@ -37,54 +38,45 @@ class _FastPassPageWidgetState extends State<FastPassPageWidget> {
|
||||||
email = FFAppState().email;
|
email = FFAppState().email;
|
||||||
userUUID = FFAppState().userUUID;
|
userUUID = FFAppState().userUUID;
|
||||||
created_at = FFAppState().createdAt;
|
created_at = FFAppState().createdAt;
|
||||||
|
|
||||||
// url = 'https://hub.freaccess.com.br/hub/fast-pass/7';
|
|
||||||
url = 'https://hub.freaccess.com.br/hub/fast-pass/${widget.clientId}';
|
url = 'https://hub.freaccess.com.br/hub/fast-pass/${widget.clientId}';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
|
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
body: WebViewWidget(
|
body: Platform.isIOS ? InAppWebView(
|
||||||
controller: _controller = WebViewController()
|
initialUrlRequest: URLRequest(url: WebUri(url)),
|
||||||
|
initialSettings: InAppWebViewSettings(
|
||||||
|
allowsBackForwardNavigationGestures: true,
|
||||||
|
javaScriptEnabled: true,
|
||||||
|
),
|
||||||
|
onWebViewCreated: (controller) async {
|
||||||
|
_controllerIOS = controller;
|
||||||
|
},
|
||||||
|
onLoadStop: (controller, url) async {
|
||||||
|
await controller.evaluateJavascript(source: "window.localStorage.setItem('fre-token', '\"${widget.freToken}\"')");
|
||||||
|
await controller.evaluateJavascript(source: "window.localStorage.setItem('fre-user-data', '${widget.freUserData}')");
|
||||||
|
},
|
||||||
|
) : WebViewWidget(
|
||||||
|
controller: _controllerAll = WebViewController()
|
||||||
..clearCache()
|
..clearCache()
|
||||||
..clearLocalStorage()
|
..clearLocalStorage()
|
||||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||||
..setBackgroundColor(const Color(0x00000000))
|
..setBackgroundColor(const Color(0x00000000))
|
||||||
..setOnConsoleMessage((message) {
|
|
||||||
debugPrint('Console: ${message.message}');
|
|
||||||
})
|
|
||||||
..setNavigationDelegate(
|
..setNavigationDelegate(
|
||||||
NavigationDelegate(
|
NavigationDelegate(
|
||||||
onProgress: (int progress) {},
|
onProgress: (int progress) {},
|
||||||
onPageStarted: (String url) {
|
onPageStarted: (String url) {
|
||||||
debugPrint('Page started: $url');
|
final String token = "localStorage.setItem('fre-token', '\"${widget.freToken}\"');";
|
||||||
final String token =
|
final String data = "localStorage.setItem('fre-user-data', '${widget.freUserData}');";
|
||||||
"localStorage.setItem('fre-token', '\"${widget.freToken}\"');";
|
|
||||||
|
|
||||||
_controller.runJavaScript(token);
|
_controllerAll.runJavaScript(token);
|
||||||
_controller
|
_controllerAll.runJavaScript(data);
|
||||||
.runJavaScript('console.log("fre-token: $token");');
|
|
||||||
|
|
||||||
final String data =
|
|
||||||
"localStorage.setItem('fre-user-data', '${widget.freUserData}');";
|
|
||||||
|
|
||||||
_controller.runJavaScript(data);
|
|
||||||
_controller
|
|
||||||
.runJavaScript('console.log("fre-user-data: $data");');
|
|
||||||
final String command =
|
|
||||||
'Object.entries(localStorage).forEach(([ key, value ]) => console.log(key+" => "+value) );';
|
|
||||||
_controller.runJavaScript(command);
|
|
||||||
},
|
|
||||||
onPageFinished: (String url) {
|
|
||||||
debugPrint('Page finished: $url');
|
|
||||||
},
|
|
||||||
onWebResourceError: (WebResourceError error) {
|
|
||||||
debugPrint('Error: ${error.description}');
|
|
||||||
},
|
},
|
||||||
onNavigationRequest: (NavigationRequest request) {
|
onNavigationRequest: (NavigationRequest request) {
|
||||||
debugPrint('Request: ${request.url}');
|
|
||||||
if (request.url.startsWith('http') ||
|
if (request.url.startsWith('http') ||
|
||||||
request.url.startsWith('https://api.whatsapp.com/send') ||
|
request.url.startsWith('https://api.whatsapp.com/send') ||
|
||||||
request.url.startsWith('https://wa.me')) {
|
request.url.startsWith('https://wa.me')) {
|
||||||
|
@ -99,5 +91,6 @@ class _FastPassPageWidgetState extends State<FastPassPageWidget> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ dependencies:
|
||||||
barcode_widget: 2.0.3
|
barcode_widget: 2.0.3
|
||||||
cached_network_image: 3.3.1
|
cached_network_image: 3.3.1
|
||||||
firebase_core: 3.1.0
|
firebase_core: 3.1.0
|
||||||
flutter_inappwebview: 6.0.0
|
flutter_inappwebview: ^6.0.0
|
||||||
webview_flutter: ^4.8.0
|
webview_flutter: ^4.8.0
|
||||||
rxdart: ^0.27.7
|
rxdart: ^0.27.7
|
||||||
collection: 1.18.0
|
collection: 1.18.0
|
||||||
|
|
Loading…
Reference in New Issue