add fastpass
This commit is contained in:
parent
b88405f202
commit
f6138d03c9
File diff suppressed because one or more lines are too long
|
@ -1,43 +1,96 @@
|
||||||
import '/flutter_flow/flutter_flow_theme.dart';
|
import 'package:f_r_e_hub/app_state.dart';
|
||||||
import '/flutter_flow/flutter_flow_util.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'fast_pass_page_model.dart';
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
export 'fast_pass_page_model.dart';
|
import 'package:webview_flutter/webview_flutter.dart';
|
||||||
|
|
||||||
|
import '/flutter_flow/flutter_flow_util.dart';
|
||||||
|
|
||||||
class FastPassPageWidget extends StatefulWidget {
|
class FastPassPageWidget extends StatefulWidget {
|
||||||
const FastPassPageWidget({super.key});
|
final String freToken = FFAppState().userUUID;
|
||||||
|
final String freUserData = "{\"name\": \"${FFAppState()}\", " +
|
||||||
|
"\"email\": \"${FFAppState().email}\"," +
|
||||||
|
"\"dev_id\": \"${FFAppState().devUUID}\"," +
|
||||||
|
"\"created_at\": \"${FFAppState().createdAt}\"," +
|
||||||
|
"\"updated_at\": \"0000-00-00 00:00:00\"," +
|
||||||
|
"\"status\": \"A\" }";
|
||||||
|
|
||||||
|
final String clientId = FFAppState().cliUUID;
|
||||||
|
|
||||||
|
// const FastPassPageWidget({ Key? key,}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<FastPassPageWidget> createState() => _FastPassPageWidgetState();
|
_FastPassPageWidgetState createState() => _FastPassPageWidgetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _FastPassPageWidgetState extends State<FastPassPageWidget> {
|
class _FastPassPageWidgetState extends State<FastPassPageWidget> {
|
||||||
late FastPassPageModel _model;
|
late WebViewController _controller;
|
||||||
|
late String url;
|
||||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
late String name;
|
||||||
|
late String email;
|
||||||
|
late String userUUID;
|
||||||
|
late String created_at;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_model = createModel(context, () => FastPassPageModel());
|
name = FFAppState().name;
|
||||||
}
|
email = FFAppState().email;
|
||||||
|
userUUID = FFAppState().userUUID;
|
||||||
|
created_at = FFAppState().createdAt;
|
||||||
|
|
||||||
@override
|
// url = 'https://hub.freaccess.com.br/hub/fast-pass/7';
|
||||||
void dispose() {
|
url = 'https://hub.freaccess.com.br/hub/fast-pass/${widget.clientId}';
|
||||||
_model.dispose();
|
|
||||||
|
|
||||||
super.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return SafeArea(
|
||||||
onTap: () => _model.unfocusNode.canRequestFocus
|
|
||||||
? FocusScope.of(context).requestFocus(_model.unfocusNode)
|
|
||||||
: FocusScope.of(context).unfocus(),
|
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
key: scaffoldKey,
|
body: WebViewWidget(
|
||||||
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
controller: _controller = WebViewController()
|
||||||
|
..clearCache()
|
||||||
|
..clearLocalStorage()
|
||||||
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||||
|
..setBackgroundColor(const Color(0x00000000))
|
||||||
|
..setOnConsoleMessage((message) {
|
||||||
|
debugPrint('Console: ${message.message}');
|
||||||
|
})
|
||||||
|
..setNavigationDelegate(
|
||||||
|
NavigationDelegate(
|
||||||
|
onProgress: (int progress) {},
|
||||||
|
onPageStarted: (String url) {
|
||||||
|
// log().info('Page started: $url');
|
||||||
|
final String token =
|
||||||
|
"localStorage.setItem('fre-token', '\"${widget.freToken}\"');";
|
||||||
|
// log().info(token);
|
||||||
|
_controller.runJavaScript(token);
|
||||||
|
final String data =
|
||||||
|
"localStorage.setItem('fre-user-data', '${widget.freUserData}');";
|
||||||
|
// log().info(data);
|
||||||
|
_controller.runJavaScript(data);
|
||||||
|
// final String command = 'Object.entries(localStorage).forEach(([ key, value ]) => console.log(key+" => "+value) );';
|
||||||
|
// _controller.runJavaScript(command);
|
||||||
|
},
|
||||||
|
onPageFinished: (String url) {
|
||||||
|
// log().info('Page finished: $url');
|
||||||
|
},
|
||||||
|
onWebResourceError: (WebResourceError error) {
|
||||||
|
// log().error('${error.description}');
|
||||||
|
},
|
||||||
|
onNavigationRequest: (NavigationRequest request) {
|
||||||
|
// log().info('Request: ${request.url}');
|
||||||
|
if (request.url.startsWith('http') ||
|
||||||
|
request.url.startsWith('https://api.whatsapp.com/send') ||
|
||||||
|
request.url.startsWith('https://wa.me')) {
|
||||||
|
launchUrlString(request.url);
|
||||||
|
return NavigationDecision.prevent;
|
||||||
|
}
|
||||||
|
return NavigationDecision.prevent;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
..loadRequest(Uri.parse(url)),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue