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