diff --git a/assets/webpages/captcha.html b/assets/webpages/captcha.html new file mode 100644 index 000000000..69d1e8482 --- /dev/null +++ b/assets/webpages/captcha.html @@ -0,0 +1,23 @@ + + + + reCAPTCHA + + + +
+
+
+
+ + + diff --git a/lib/src/screens/loan/widgets/loan_login_section.dart b/lib/src/screens/loan/widgets/loan_login_section.dart index 17a8a031c..e13f8ed5b 100644 --- a/lib/src/screens/loan/widgets/loan_login_section.dart +++ b/lib/src/screens/loan/widgets/loan_login_section.dart @@ -1,5 +1,6 @@ import 'package:cake_wallet/src/widgets/base_text_form_field.dart'; import 'package:cake_wallet/src/widgets/primary_button.dart'; +import 'package:cake_wallet/view_model/loan/captcha_webview.dart'; import 'package:flutter/material.dart'; class LoanLoginSection extends StatelessWidget { @@ -74,6 +75,7 @@ class LoanLoginSection extends StatelessWidget { ], ), ), + SizedBox(height: 100, child: CaptchaWebview()), SizedBox(height: 100), ], ); diff --git a/lib/view_model/loan/captcha_webview.dart b/lib/view_model/loan/captcha_webview.dart new file mode 100644 index 000000000..18f1990ec --- /dev/null +++ b/lib/view_model/loan/captcha_webview.dart @@ -0,0 +1,41 @@ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:webview_flutter/webview_flutter.dart'; + +class CaptchaWebview extends StatefulWidget { + const CaptchaWebview({Key key}); + + @override + _CaptchaWebviewState createState() => _CaptchaWebviewState(); +} + +class _CaptchaWebviewState extends State { + WebViewController _controller; + + @override + Widget build(BuildContext context) { + return WebView( + javascriptMode: JavascriptMode.unrestricted, + onWebViewCreated: (controller) { + _controller = controller; + _loadHtmlFromAssets(); + }, + javascriptChannels: Set.from([ + JavascriptChannel( + name: 'Captcha', + onMessageReceived: (JavascriptMessage message) { + print(message.message); + }) + ].toList())); + } + + Future _loadHtmlFromAssets() async { + final fileText = + await rootBundle.loadString('assets/webpages/captcha.html'); + await _controller.loadUrl(Uri.dataFromString(fileText, + mimeType: 'text/html', encoding: Encoding.getByName('utf-8')) + .toString()); + } +} diff --git a/lib/view_model/loan/loan_account_view_model.dart b/lib/view_model/loan/loan_account_view_model.dart index 23fe380b2..7d28b1575 100644 --- a/lib/view_model/loan/loan_account_view_model.dart +++ b/lib/view_model/loan/loan_account_view_model.dart @@ -26,8 +26,6 @@ abstract class LoanAccountViewModelBase with Store { List items; Future _fetchLoanItems() async { - await Future.delayed(Duration(seconds: 5)); - isLoggedIn = true; items = [ LoanItem(id: '2133432', amount: 20000, status: 'Awaiting deposit'), LoanItem(id: '2133432', amount: 20000, status: 'Awaiting deposit'),