Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #61 from MXCzkEVM/pre_main_qa
Browse files Browse the repository at this point in the history
Feat;Pre main qa
  • Loading branch information
sheenhx authored Sep 19, 2023
2 parents 3e2d1ce + 43799bb commit f592ede
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
12 changes: 6 additions & 6 deletions lib/features/dapps/subfeatures/open_dapp/open_dapp_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class OpenAppPage extends HookConsumerWidget {
initialUrlRequest: URLRequest(
url: Uri.parse(url),
),
onLoadStop: (controller, url) {
presenter.injectCopyHandling();
},
onLoadError: (controller, url, code, message) =>
collectLog('onLoadError: $code: $message'),
onLoadHttpError: (controller, url, statusCode, description) =>
Expand Down Expand Up @@ -101,12 +104,10 @@ class OpenAppPage extends HookConsumerWidget {
break;
}
},

initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
useShouldOverrideUrlLoading: true,
mediaPlaybackRequiresUserGesture: false
),
useShouldOverrideUrlLoading: true,
mediaPlaybackRequiresUserGesture: false),
android: AndroidInAppWebViewOptions(
useWideViewPort: true,
geolocationEnabled: true,
Expand All @@ -128,8 +129,7 @@ class OpenAppPage extends HookConsumerWidget {
action: PermissionRequestResponseAction.GRANT,
);
},
androidOnGeolocationPermissionsHidePrompt: (controller) {
},
androidOnGeolocationPermissionsHidePrompt: (controller) {},
androidOnGeolocationPermissionsShowPrompt:
(InAppWebViewController controller, String origin) async {
return GeolocationPermissionShowPromptResponse(
Expand Down
25 changes: 23 additions & 2 deletions lib/features/dapps/subfeatures/open_dapp/open_dapp_presenter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ class OpenDAppPresenter extends CompletePresenter<OpenDAppState> {
return super.dispose();
}

void onWebViewCreated(InAppWebViewController controller) =>
notify(() => state.webviewController = controller);
void onWebViewCreated(InAppWebViewController controller) {
notify(() => state.webviewController = controller);
}

Future<EstimatedGasFee?> _estimatedFee(
String from,
Expand Down Expand Up @@ -219,4 +220,24 @@ class OpenDAppPresenter extends CompletePresenter<OpenDAppState> {
}
}""";
}

void copy(List<dynamic> params) {
Clipboard.setData(ClipboardData(text: params[0]));
}

Future<String> paste(List<dynamic> params) async {
return (await Clipboard.getData('text/plain'))?.text.toString() ?? '';
}

void injectCopyHandling() {
state.webviewController!.evaluateJavascript(
source:
'javascript:navigator.clipboard.writeText = (msg) => { return window.flutter_inappwebview?.callHandler("axs-wallet-copy-clipboard", msg); }');
state.webviewController!.addJavaScriptHandler(
handlerName: 'axs-wallet-copy-clipboard',
callback: (args) {
copy(args);
},
);
}
}

0 comments on commit f592ede

Please sign in to comment.