Skip to content

Commit

Permalink
Merge pull request #1318 from bitmark-inc/irl_webview
Browse files Browse the repository at this point in the history
irl web view for merchandise
  • Loading branch information
phuocbitmark authored Oct 13, 2023
2 parents a0f2a33 + 4c0f1bf commit bd42b34
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 15 deletions.
4 changes: 2 additions & 2 deletions lib/screen/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 13 additions & 5 deletions lib/screen/irl_screen/webview_irl_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<IRLWebScreen> createState() => _IRLWebScreenState();
Expand Down Expand Up @@ -57,7 +57,7 @@ class _IRLWebScreenState extends State<IRLWebScreen> {
'function': func,
'error': result.errorMessage,
'result': result.result.toString(),
'url': widget.url,
'url': widget.payload.url,
});
return result;
}
Expand Down Expand Up @@ -332,7 +332,7 @@ class _IRLWebScreenState extends State<IRLWebScreen> {
injector.get<NavigationService>().popUntilHomeOrSettings();
_metricClient.addEvent(MixpanelEvent.callIrlFunction, data: {
'function': IrlWebviewFunction.closeWebview,
'url': widget.url,
'url': widget.payload.url,
});
},
);
Expand All @@ -358,7 +358,8 @@ class _IRLWebScreenState extends State<IRLWebScreen> {
children: [
Expanded(
child: InAppWebViewPage(
payload: InAppWebViewPayload(widget.url,
payload: InAppWebViewPayload(widget.payload.url,
isPlainUI: widget.payload.isPlainUI,
onWebViewCreated: (controller) {
_controller = controller;
_addJavaScriptHandler();
Expand Down Expand Up @@ -420,3 +421,10 @@ class JSResult {
);
}
}

class IRLWebScreenPayload {
final String url;
final bool isPlainUI;

IRLWebScreenPayload(this.url, {this.isPlainUI = false});
}
16 changes: 11 additions & 5 deletions lib/screen/settings/help_us/inapp_webview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ class _InAppWebViewPageState extends State<InAppWebViewPage> {
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: [
Expand Down Expand Up @@ -89,8 +91,10 @@ class _InAppWebViewPageState extends State<InAppWebViewPage> {
],
),
),
addOnlyDivider(color: AppColor.auGrey),
_bottomBar(context)
if (!widget.payload.isPlainUI) ...[
addOnlyDivider(color: AppColor.auGrey),
_bottomBar(context)
],
],
),
);
Expand Down Expand Up @@ -215,9 +219,11 @@ class _InAppWebViewPageState extends State<InAppWebViewPage> {

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});
}
3 changes: 2 additions & 1 deletion lib/service/deeplink_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -295,7 +296,7 @@ class DeeplinkServiceImpl extends DeeplinkService {
if (!validUrl) return false;
}
await _navigationService.navigateTo(AppRouter.irlWebView,
arguments: urlDecode);
arguments: IRLWebScreenPayload(urlDecode));
return true;
}

Expand Down
5 changes: 3 additions & 2 deletions lib/view/external_link.dart
Original file line number Diff line number Diff line change
@@ -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' '';
Expand All @@ -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(
Expand Down

0 comments on commit bd42b34

Please sign in to comment.