From 4c0f1bfec7f4227e7596894a64eeaeff45a0734a Mon Sep 17 00:00:00 2001 From: phuoc Date: Thu, 12 Oct 2023 15:09:53 +0700 Subject: [PATCH] irl web view for merchandise Signed-off-by: phuoc --- lib/screen/app_router.dart | 4 ++-- lib/screen/irl_screen/webview_irl_screen.dart | 18 +++++++++++++----- lib/screen/settings/help_us/inapp_webview.dart | 16 +++++++++++----- lib/service/deeplink_service.dart | 3 ++- lib/view/external_link.dart | 5 +++-- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/lib/screen/app_router.dart b/lib/screen/app_router.dart index 5572670f9..536299e32 100644 --- a/lib/screen/app_router.dart +++ b/lib/screen/app_router.dart @@ -1098,11 +1098,11 @@ class AppRouter { }); case irlWebView: - final url = settings.arguments as String; + final payload = settings.arguments as IRLWebScreenPayload; return CupertinoPageRoute( settings: settings, builder: (context) { - return IRLWebScreen(url: url); + return IRLWebScreen(payload: payload); }); case irlSignMessage: diff --git a/lib/screen/irl_screen/webview_irl_screen.dart b/lib/screen/irl_screen/webview_irl_screen.dart index dcc3c5749..8ef84c881 100644 --- a/lib/screen/irl_screen/webview_irl_screen.dart +++ b/lib/screen/irl_screen/webview_irl_screen.dart @@ -26,9 +26,9 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:tezart/tezart.dart'; class IRLWebScreen extends StatefulWidget { - final String url; + final IRLWebScreenPayload payload; - const IRLWebScreen({Key? key, required this.url}) : super(key: key); + const IRLWebScreen({Key? key, required this.payload}) : super(key: key); @override State createState() => _IRLWebScreenState(); @@ -57,7 +57,7 @@ class _IRLWebScreenState extends State { 'function': func, 'error': result.errorMessage, 'result': result.result.toString(), - 'url': widget.url, + 'url': widget.payload.url, }); return result; } @@ -332,7 +332,7 @@ class _IRLWebScreenState extends State { injector.get().popUntilHomeOrSettings(); _metricClient.addEvent(MixpanelEvent.callIrlFunction, data: { 'function': IrlWebviewFunction.closeWebview, - 'url': widget.url, + 'url': widget.payload.url, }); }, ); @@ -358,7 +358,8 @@ class _IRLWebScreenState extends State { children: [ Expanded( child: InAppWebViewPage( - payload: InAppWebViewPayload(widget.url, + payload: InAppWebViewPayload(widget.payload.url, + isPlainUI: widget.payload.isPlainUI, onWebViewCreated: (controller) { _controller = controller; _addJavaScriptHandler(); @@ -420,3 +421,10 @@ class JSResult { ); } } + +class IRLWebScreenPayload { + final String url; + final bool isPlainUI; + + IRLWebScreenPayload(this.url, {this.isPlainUI = false}); +} diff --git a/lib/screen/settings/help_us/inapp_webview.dart b/lib/screen/settings/help_us/inapp_webview.dart index 9c201ef4d..85b043e10 100644 --- a/lib/screen/settings/help_us/inapp_webview.dart +++ b/lib/screen/settings/help_us/inapp_webview.dart @@ -47,8 +47,10 @@ class _InAppWebViewPageState extends State { backgroundColor: theme.primaryColor, body: Column( children: [ - _header(context), - addOnlyDivider(color: AppColor.auGrey), + if (!widget.payload.isPlainUI) ...[ + _header(context), + addOnlyDivider(color: AppColor.auGrey) + ], Expanded( child: Stack( children: [ @@ -89,8 +91,10 @@ class _InAppWebViewPageState extends State { ], ), ), - addOnlyDivider(color: AppColor.auGrey), - _bottomBar(context) + if (!widget.payload.isPlainUI) ...[ + addOnlyDivider(color: AppColor.auGrey), + _bottomBar(context) + ], ], ), ); @@ -215,9 +219,11 @@ class _InAppWebViewPageState extends State { class InAppWebViewPayload { final String url; + final bool isPlainUI; Function(InAppWebViewController controler)? onWebViewCreated; Function(InAppWebViewController controler, ConsoleMessage consoleMessage)? onConsoleMessage; - InAppWebViewPayload(this.url, {this.onWebViewCreated, this.onConsoleMessage}); + InAppWebViewPayload(this.url, + {this.isPlainUI = false, this.onWebViewCreated, this.onConsoleMessage}); } diff --git a/lib/service/deeplink_service.dart b/lib/service/deeplink_service.dart index 636b8a60b..e4c0e41f9 100644 --- a/lib/service/deeplink_service.dart +++ b/lib/service/deeplink_service.dart @@ -15,6 +15,7 @@ import 'package:autonomy_flutter/model/otp.dart'; import 'package:autonomy_flutter/model/postcard_claim.dart'; import 'package:autonomy_flutter/screen/claim/activation/claim_activation_page.dart'; import 'package:autonomy_flutter/screen/claim/airdrop/claim_airdrop_page.dart'; +import 'package:autonomy_flutter/screen/irl_screen/webview_irl_screen.dart'; import 'package:autonomy_flutter/service/account_service.dart'; import 'package:autonomy_flutter/service/activation_service.dart'; import 'package:autonomy_flutter/service/airdrop_service.dart'; @@ -295,7 +296,7 @@ class DeeplinkServiceImpl extends DeeplinkService { if (!validUrl) return false; } await _navigationService.navigateTo(AppRouter.irlWebView, - arguments: urlDecode); + arguments: IRLWebScreenPayload(urlDecode)); return true; } diff --git a/lib/view/external_link.dart b/lib/view/external_link.dart index 37c0da933..00ebb734f 100644 --- a/lib/view/external_link.dart +++ b/lib/view/external_link.dart @@ -1,6 +1,7 @@ import 'dart:ui' as ui; import 'package:autonomy_flutter/screen/app_router.dart'; +import 'package:autonomy_flutter/screen/irl_screen/webview_irl_screen.dart'; import 'package:autonomy_flutter/util/string_ext.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart' ''; @@ -24,8 +25,8 @@ class ExternalLink extends StatelessWidget { return GestureDetector( onTap: () { if (isValid) { - Navigator.of(context) - .pushNamed(AppRouter.irlWebView, arguments: link); + Navigator.of(context).pushNamed(AppRouter.irlWebView, + arguments: IRLWebScreenPayload(link!)); } }, child: Padding(