Merge pull request #5 from FRE-Informatica/bugfix/webview
BUGFIX: FeastPass Web View in iOS
This commit is contained in:
commit
05bd6b41b7
|
@ -130,10 +130,8 @@ 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) => local['CLU_STATUS'] == "A")
|
|
||||||
) {
|
|
||||||
FFAppState().cliUUID = localItem['CLI_ID'];
|
FFAppState().cliUUID = localItem['CLI_ID'];
|
||||||
setState(() {});
|
setState(() {});
|
||||||
FFAppState().local = localItem['CLI_NOME'];
|
FFAppState().local = localItem['CLI_NOME'];
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
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 {
|
||||||
|
@ -18,14 +20,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;
|
||||||
|
@ -39,54 +40,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) {
|
|
||||||
log('Console: ${message.message}');
|
|
||||||
})
|
|
||||||
..setNavigationDelegate(
|
..setNavigationDelegate(
|
||||||
NavigationDelegate(
|
NavigationDelegate(
|
||||||
onProgress: (int progress) {},
|
onProgress: (int progress) {},
|
||||||
onPageStarted: (String url) {
|
onPageStarted: (String url) {
|
||||||
log('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) {
|
|
||||||
log('Page finished: $url');
|
|
||||||
},
|
|
||||||
onWebResourceError: (WebResourceError error) {
|
|
||||||
log('Error: ${error.description}');
|
|
||||||
},
|
},
|
||||||
onNavigationRequest: (NavigationRequest request) {
|
onNavigationRequest: (NavigationRequest request) {
|
||||||
log('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')) {
|
||||||
|
@ -101,5 +93,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