From 68d2ef600109cb1d55533ede41298d01b18f26c7 Mon Sep 17 00:00:00 2001 From: sahani-deriv Date: Mon, 5 Feb 2024 14:09:51 +0800 Subject: [PATCH] refactor(deriv_web_view)!: remove hardcoded redirect urls --- packages/deriv_web_view/lib/deriv_web_view.dart | 2 ++ .../lib/widgets/in_app_browser/in_app_browser.dart | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/deriv_web_view/lib/deriv_web_view.dart b/packages/deriv_web_view/lib/deriv_web_view.dart index 740a148ed..0acefd179 100644 --- a/packages/deriv_web_view/lib/deriv_web_view.dart +++ b/packages/deriv_web_view/lib/deriv_web_view.dart @@ -66,6 +66,7 @@ Future openInAppWebViewWithUriHandler({ required Function(Uri) uriHandler, required Function(String) onError, required VoidCallback onClosed, + required List redirectURLs, }) async { try { _openInAppTabView(url, onClosed); @@ -73,6 +74,7 @@ Future openInAppWebViewWithUriHandler({ final AppInAppBrowser browser = AppInAppBrowser( onUrlChanged: (Uri uri) => uriHandler(uri), onError: (String message) => onError(message), + redirectURLs: redirectURLs, ); await browser.openUrlRequest( diff --git a/packages/deriv_web_view/lib/widgets/in_app_browser/in_app_browser.dart b/packages/deriv_web_view/lib/widgets/in_app_browser/in_app_browser.dart index 37494e72d..aea216ea3 100644 --- a/packages/deriv_web_view/lib/widgets/in_app_browser/in_app_browser.dart +++ b/packages/deriv_web_view/lib/widgets/in_app_browser/in_app_browser.dart @@ -4,9 +4,6 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart'; /// The browser that is used to launch deriv's login web page class AppInAppBrowser extends InAppBrowser { - /// AppInAppBrowser is called from *login_helper.dart* and launches deriv's - /// login page. - /// /// It takes the following requires parameters /// [onUrlChanged] function that is called when the url passed has changed, /// for a redirect link in this case. @@ -14,14 +11,17 @@ class AppInAppBrowser extends InAppBrowser { AppInAppBrowser({ required this.onUrlChanged, required this.onError, + required this.redirectURLs, }); /// A Function callback to url change. void Function(Uri) onUrlChanged; + /// A Function callback to error. void Function(String) onError; - final List _redirectURLs = ['deriv://multipliers']; + /// List of redirect urls. + List redirectURLs; @override void onBrowserCreated() => logger.log('\n\nBrowser Created!\n\n'); @@ -30,7 +30,7 @@ class AppInAppBrowser extends InAppBrowser { void onLoadStart(Uri? url) { logger.log('\n\nStarted\n\n'); - for (final String redirectURL in _redirectURLs) { + for (final String redirectURL in redirectURLs) { if (url.toString().startsWith(redirectURL)) { close(); onUrlChanged(url!);