Commit f36787cc7d5ca651c067e73083159734deb958a1
1 parent
3a0b9b5d
webview更换&&注释帮助与反馈&&去掉flutter_downloader的初始化
Showing
14 changed files
with
585 additions
and
388 deletions
| @@ -550,7 +550,7 @@ | @@ -550,7 +550,7 @@ | ||
| 550 | CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements; | 550 | CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements; |
| 551 | CODE_SIGN_IDENTITY = "Apple Development"; | 551 | CODE_SIGN_IDENTITY = "Apple Development"; |
| 552 | CODE_SIGN_STYLE = Automatic; | 552 | CODE_SIGN_STYLE = Automatic; |
| 553 | - CURRENT_PROJECT_VERSION = 5204; | 553 | + CURRENT_PROJECT_VERSION = 520; |
| 554 | DEVELOPMENT_TEAM = 8J59HM8B82; | 554 | DEVELOPMENT_TEAM = 8J59HM8B82; |
| 555 | ENABLE_BITCODE = NO; | 555 | ENABLE_BITCODE = NO; |
| 556 | FLUTTER_BUILD_MODE = release; | 556 | FLUTTER_BUILD_MODE = release; |
| @@ -698,10 +698,10 @@ | @@ -698,10 +698,10 @@ | ||
| 698 | CODE_SIGN_ENTITLEMENTS = "Runner/一键订Debug.entitlements"; | 698 | CODE_SIGN_ENTITLEMENTS = "Runner/一键订Debug.entitlements"; |
| 699 | CODE_SIGN_IDENTITY = "Apple Development"; | 699 | CODE_SIGN_IDENTITY = "Apple Development"; |
| 700 | CODE_SIGN_STYLE = Automatic; | 700 | CODE_SIGN_STYLE = Automatic; |
| 701 | - CURRENT_PROJECT_VERSION = 5204; | 701 | + CURRENT_PROJECT_VERSION = 520; |
| 702 | DEVELOPMENT_TEAM = 8J59HM8B82; | 702 | DEVELOPMENT_TEAM = 8J59HM8B82; |
| 703 | ENABLE_BITCODE = NO; | 703 | ENABLE_BITCODE = NO; |
| 704 | - FLUTTER_BUILD_MODE = debug; | 704 | + FLUTTER_BUILD_MODE = release; |
| 705 | FRAMEWORK_SEARCH_PATHS = ( | 705 | FRAMEWORK_SEARCH_PATHS = ( |
| 706 | "$(inherited)", | 706 | "$(inherited)", |
| 707 | "$(PROJECT_DIR)/Flutter", | 707 | "$(PROJECT_DIR)/Flutter", |
| @@ -734,7 +734,7 @@ | @@ -734,7 +734,7 @@ | ||
| 734 | CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; | 734 | CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; |
| 735 | CODE_SIGN_IDENTITY = "Apple Development"; | 735 | CODE_SIGN_IDENTITY = "Apple Development"; |
| 736 | CODE_SIGN_STYLE = Automatic; | 736 | CODE_SIGN_STYLE = Automatic; |
| 737 | - CURRENT_PROJECT_VERSION = 5204; | 737 | + CURRENT_PROJECT_VERSION = 520; |
| 738 | DEVELOPMENT_TEAM = 8J59HM8B82; | 738 | DEVELOPMENT_TEAM = 8J59HM8B82; |
| 739 | ENABLE_BITCODE = NO; | 739 | ENABLE_BITCODE = NO; |
| 740 | FLUTTER_BUILD_MODE = release; | 740 | FLUTTER_BUILD_MODE = release; |
| @@ -6,7 +6,7 @@ import 'package:dio/dio.dart'; | @@ -6,7 +6,7 @@ import 'package:dio/dio.dart'; | ||
| 6 | import 'package:fluro/fluro.dart'; | 6 | import 'package:fluro/fluro.dart'; |
| 7 | import 'package:flutter/material.dart' hide Router; | 7 | import 'package:flutter/material.dart' hide Router; |
| 8 | import 'package:flutter_bugly/flutter_bugly.dart'; | 8 | import 'package:flutter_bugly/flutter_bugly.dart'; |
| 9 | -import 'package:flutter_downloader/flutter_downloader.dart'; | 9 | +// import 'package:flutter_downloader/flutter_downloader.dart'; |
| 10 | import 'package:flutter_easyrefresh/ball_pulse_footer.dart'; | 10 | import 'package:flutter_easyrefresh/ball_pulse_footer.dart'; |
| 11 | import 'package:flutter_easyrefresh/easy_refresh.dart'; | 11 | import 'package:flutter_easyrefresh/easy_refresh.dart'; |
| 12 | import 'package:flutter_easyrefresh/material_header.dart'; | 12 | import 'package:flutter_easyrefresh/material_header.dart'; |
| @@ -81,7 +81,7 @@ Future<void> main() async { | @@ -81,7 +81,7 @@ Future<void> main() async { | ||
| 81 | // // _requestPermissions(); | 81 | // // _requestPermissions(); |
| 82 | // Utils.changeStatusColor(); | 82 | // Utils.changeStatusColor(); |
| 83 | 83 | ||
| 84 | - await FlutterDownloader.initialize(debug: true, ignoreSsl: true); | 84 | + // await FlutterDownloader.initialize(debug: true, ignoreSsl: true); |
| 85 | 85 | ||
| 86 | await App.initSp(); | 86 | await App.initSp(); |
| 87 | SystemChrome.setPreferredOrientations( | 87 | SystemChrome.setPreferredOrientations( |
| 1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
| 2 | -import 'package:flutter_inappwebview/flutter_inappwebview.dart'; | ||
| 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 4 | import 'package:one_key/res/colors.dart'; | 3 | import 'package:one_key/res/colors.dart'; |
| 5 | import 'package:one_key/route/navigator_util.dart'; | 4 | import 'package:one_key/route/navigator_util.dart'; |
| @@ -38,7 +38,7 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> { | @@ -38,7 +38,7 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> { | ||
| 38 | super.initState(); | 38 | super.initState(); |
| 39 | 39 | ||
| 40 | WidgetsBinding.instance.addPostFrameCallback((_) async { | 40 | WidgetsBinding.instance.addPostFrameCallback((_) async { |
| 41 | - _getLocationPermission(); | 41 | + _requestLocationPermission(); |
| 42 | }); | 42 | }); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| @@ -52,17 +52,17 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> { | @@ -52,17 +52,17 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> { | ||
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | /// 检查权限并定 | 54 | /// 检查权限并定 |
| 55 | - _getLocationPermission() async { | ||
| 56 | - if (!(await checkPermission(Permission.location))) { | ||
| 57 | - //没有定位权限 | ||
| 58 | - | ||
| 59 | - //申请定位权限 | ||
| 60 | - _requestLocationPermission(); | ||
| 61 | - } else { | ||
| 62 | - //去定位 | ||
| 63 | - _requestLocationPermission(); | ||
| 64 | - } | ||
| 65 | - } | 55 | + // _getLocationPermission() async { |
| 56 | + // if (!(await checkPermission(Permission.location))) { | ||
| 57 | + // //没有定位权限 | ||
| 58 | + | ||
| 59 | + // //申请定位权限 | ||
| 60 | + // _requestLocationPermission(); | ||
| 61 | + // } else { | ||
| 62 | + // //去定位 | ||
| 63 | + // _requestLocationPermission(); | ||
| 64 | + // } | ||
| 65 | + // } | ||
| 66 | 66 | ||
| 67 | /// 获取定位权限 | 67 | /// 获取定位权限 |
| 68 | _requestLocationPermission() async { | 68 | _requestLocationPermission() async { |
| @@ -268,12 +268,13 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> { | @@ -268,12 +268,13 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> { | ||
| 268 | ? Colors.green | 268 | ? Colors.green |
| 269 | : Colors.grey, | 269 | : Colors.grey, |
| 270 | ), | 270 | ), |
| 271 | - Text(item.title, | ||
| 272 | - style: TextStyle( | ||
| 273 | - fontSize: 16, | ||
| 274 | - color: position == 0 | ||
| 275 | - ? Colors.green | ||
| 276 | - : Color(0xFF787878))) | 271 | + Expanded( |
| 272 | + child: Text(item.title, | ||
| 273 | + style: TextStyle( | ||
| 274 | + fontSize: 16, | ||
| 275 | + color: position == 0 | ||
| 276 | + ? Colors.green | ||
| 277 | + : Color(0xFF787878)))) | ||
| 277 | ], | 278 | ], |
| 278 | ), | 279 | ), |
| 279 | ), | 280 | ), |
| @@ -3,7 +3,7 @@ import 'dart:async'; | @@ -3,7 +3,7 @@ import 'dart:async'; | ||
| 3 | import 'package:device_info/device_info.dart'; | 3 | import 'package:device_info/device_info.dart'; |
| 4 | import 'package:dio/dio.dart'; | 4 | import 'package:dio/dio.dart'; |
| 5 | import 'package:flutter/material.dart'; | 5 | import 'package:flutter/material.dart'; |
| 6 | -import 'package:flutter_inappwebview/flutter_inappwebview.dart'; | 6 | +// import 'package:flutter_inappwebview/flutter_inappwebview.dart'; |
| 7 | import 'package:one_key/net/dio_util.dart'; | 7 | import 'package:one_key/net/dio_util.dart'; |
| 8 | import 'package:one_key/res/colors.dart'; | 8 | import 'package:one_key/res/colors.dart'; |
| 9 | import 'package:one_key/utils/event_bus.dart'; | 9 | import 'package:one_key/utils/event_bus.dart'; |
| @@ -26,9 +26,16 @@ import 'package:webview_flutter/webview_flutter.dart'; | @@ -26,9 +26,16 @@ import 'package:webview_flutter/webview_flutter.dart'; | ||
| 26 | // import 'package:flutter_inappwebview/flutter_inappwebview.dart'; | 26 | // import 'package:flutter_inappwebview/flutter_inappwebview.dart'; |
| 27 | import 'package:url_launcher/url_launcher.dart'; | 27 | import 'package:url_launcher/url_launcher.dart'; |
| 28 | import 'dart:collection'; | 28 | import 'dart:collection'; |
| 29 | + | ||
| 30 | +// Import for Android features. | ||
| 31 | +import 'package:webview_flutter_android/webview_flutter_android.dart'; | ||
| 32 | +// Import for iOS features. | ||
| 33 | +import 'package:webview_flutter_wkwebview/webview_flutter_wkwebview.dart'; | ||
| 29 | // import 'package:open_file/open_file.dart'; | 34 | // import 'package:open_file/open_file.dart'; |
| 30 | // import 'package:flutter_downloader/flutter_downloader.dart'; | 35 | // import 'package:flutter_downloader/flutter_downloader.dart'; |
| 31 | 36 | ||
| 37 | + | ||
| 38 | + | ||
| 32 | class WebPage extends StatefulWidget { | 39 | class WebPage extends StatefulWidget { |
| 33 | final String title; | 40 | final String title; |
| 34 | final String url; | 41 | final String url; |
| @@ -41,42 +48,34 @@ class WebPage extends StatefulWidget { | @@ -41,42 +48,34 @@ class WebPage extends StatefulWidget { | ||
| 41 | } | 48 | } |
| 42 | 49 | ||
| 43 | class _WebPageState extends State<WebPage> { | 50 | class _WebPageState extends State<WebPage> { |
| 44 | - final GlobalKey webViewKey = GlobalKey(); | ||
| 45 | - | ||
| 46 | - InAppWebViewController webViewController; | ||
| 47 | - InAppWebViewGroupOptions options = InAppWebViewGroupOptions( | ||
| 48 | - crossPlatform: InAppWebViewOptions( | ||
| 49 | - useShouldOverrideUrlLoading: true, | ||
| 50 | - useOnDownloadStart: true, | ||
| 51 | - mediaPlaybackRequiresUserGesture: false, | ||
| 52 | - ), | ||
| 53 | - android: AndroidInAppWebViewOptions( | ||
| 54 | - useHybridComposition: true, | ||
| 55 | - ), | ||
| 56 | - ios: IOSInAppWebViewOptions( | ||
| 57 | - allowsInlineMediaPlayback: true, | ||
| 58 | - )); | ||
| 59 | - | ||
| 60 | - PullToRefreshController pullToRefreshController; | ||
| 61 | - ContextMenu contextMenu; | ||
| 62 | - String url = ""; | ||
| 63 | - double progress = 0; | ||
| 64 | - final urlController = TextEditingController(); | ||
| 65 | - // Future<void> openFile(filePath) async { | ||
| 66 | - // final _result = await OpenFile.open(filePath); | ||
| 67 | - // print(_result.message); | ||
| 68 | - | ||
| 69 | - // // setState(() { | ||
| 70 | - // // _openResult = "type=${_result.type} message=${_result.message}"; | ||
| 71 | - // // }); | ||
| 72 | - // } | 51 | + WebViewController controller; |
| 73 | 52 | ||
| 74 | @override | 53 | @override |
| 75 | void initState() { | 54 | void initState() { |
| 76 | super.initState(); | 55 | super.initState(); |
| 77 | 56 | ||
| 78 | - // Enable hybrid composition. | ||
| 79 | - _init(); | 57 | + // #docregion webview_controller |
| 58 | + controller = WebViewController() | ||
| 59 | + ..setJavaScriptMode(JavaScriptMode.unrestricted) | ||
| 60 | + ..setBackgroundColor(const Color(0x00000000)) | ||
| 61 | + ..setNavigationDelegate( | ||
| 62 | + NavigationDelegate( | ||
| 63 | + onProgress: (int progress) { | ||
| 64 | + // Update loading bar. | ||
| 65 | + }, | ||
| 66 | + onPageStarted: (String url) {}, | ||
| 67 | + onPageFinished: (String url) {}, | ||
| 68 | + onWebResourceError: (WebResourceError error) {}, | ||
| 69 | + onNavigationRequest: (NavigationRequest request) { | ||
| 70 | + if (request.url.startsWith('https://www.youtube.com/')) { | ||
| 71 | + return NavigationDecision.prevent; | ||
| 72 | + } | ||
| 73 | + return NavigationDecision.navigate; | ||
| 74 | + }, | ||
| 75 | + ), | ||
| 76 | + ) | ||
| 77 | + ..loadRequest(Uri.parse('http://colorcun.com/privacy2.html')); | ||
| 78 | + // #enddocregion webview_controller | ||
| 80 | } | 79 | } |
| 81 | 80 | ||
| 82 | @override | 81 | @override |
| @@ -88,269 +87,18 @@ class _WebPageState extends State<WebPage> { | @@ -88,269 +87,18 @@ class _WebPageState extends State<WebPage> { | ||
| 88 | super.dispose(); | 87 | super.dispose(); |
| 89 | } | 88 | } |
| 90 | 89 | ||
| 91 | - Future<bool> _checkPermission() async { | ||
| 92 | - DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); | ||
| 93 | - AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; | ||
| 94 | - if (Platform.isAndroid && androidInfo.version.sdkInt <= 28) { | ||
| 95 | - final status = await Permission.storage.status; | ||
| 96 | - if (status != PermissionStatus.granted) { | ||
| 97 | - final result = await Permission.storage.request(); | ||
| 98 | - if (result == PermissionStatus.granted) { | ||
| 99 | - return true; | ||
| 100 | - } | ||
| 101 | - } else { | ||
| 102 | - return true; | ||
| 103 | - } | ||
| 104 | - } else { | ||
| 105 | - return true; | ||
| 106 | - } | ||
| 107 | - return false; | ||
| 108 | - } | ||
| 109 | - | ||
| 110 | - Future<bool> checkPermissionStorage() async { | ||
| 111 | - var status = await Permission.storage.status; | ||
| 112 | - if (!status.isGranted) { | ||
| 113 | - status = await Permission.storage.request(); | ||
| 114 | - if (status.isGranted) { | ||
| 115 | - return true; | ||
| 116 | - } | ||
| 117 | - } else { | ||
| 118 | - return true; | ||
| 119 | - } | ||
| 120 | - return false; | ||
| 121 | - } | ||
| 122 | - | ||
| 123 | - _init() async { | ||
| 124 | - // WidgetsFlutterBinding.ensureInitialized(); | ||
| 125 | - // await FlutterDownloader.initialize(debug: true); | ||
| 126 | - if (Platform.isAndroid) { | ||
| 127 | - await AndroidInAppWebViewController.setWebContentsDebuggingEnabled(true); | ||
| 128 | - | ||
| 129 | - var swAvailable = await AndroidWebViewFeature.isFeatureSupported( | ||
| 130 | - AndroidWebViewFeature.SERVICE_WORKER_BASIC_USAGE); | ||
| 131 | - var swInterceptAvailable = await AndroidWebViewFeature.isFeatureSupported( | ||
| 132 | - AndroidWebViewFeature.SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST); | ||
| 133 | - | ||
| 134 | - if (swAvailable && swInterceptAvailable) { | ||
| 135 | - AndroidServiceWorkerController serviceWorkerController = | ||
| 136 | - AndroidServiceWorkerController.instance(); | ||
| 137 | - | ||
| 138 | - serviceWorkerController.serviceWorkerClient = | ||
| 139 | - AndroidServiceWorkerClient( | ||
| 140 | - shouldInterceptRequest: (request) async { | ||
| 141 | - print(request); | ||
| 142 | - return null; | ||
| 143 | - }, | ||
| 144 | - ); | ||
| 145 | - } | ||
| 146 | - } | ||
| 147 | - // await FlutterDownloader.initialize( | ||
| 148 | - // debug: true // optional: set false to disable printing logs to console | ||
| 149 | - // ); | ||
| 150 | - // await Permission.storage.request(); | ||
| 151 | - } | ||
| 152 | - | ||
| 153 | @override | 90 | @override |
| 154 | Widget build(BuildContext context) { | 91 | Widget build(BuildContext context) { |
| 155 | return Scaffold( | 92 | return Scaffold( |
| 156 | - // We're using a Builder here so we have a context that is below the Scaffold | ||
| 157 | - // to allow calling Scaffold.of(context) so we can show a snackbar. | ||
| 158 | - appBar: SystemAppBar( | ||
| 159 | - widget.title, | ||
| 160 | - ), | ||
| 161 | - body: Column( | ||
| 162 | - children: [ | ||
| 163 | - Expanded( | ||
| 164 | - child: InAppWebView( | ||
| 165 | - key: webViewKey, | ||
| 166 | - // contextMenu: contextMenu, | ||
| 167 | - initialUrlRequest: URLRequest( | ||
| 168 | - // url: Uri.parse("http://colorcun.com/privacy1.html")), | ||
| 169 | - url: Uri.parse("http://colorcun.com/privacy2.html")), | ||
| 170 | - //华为下载功能闪退,去掉下载功能*********http://colorcun.com/privacy2.html | ||
| 171 | - // initialFile: "assets/index.html", | ||
| 172 | - initialUserScripts: UnmodifiableListView<UserScript>([]), | ||
| 173 | - initialOptions: options, | ||
| 174 | - pullToRefreshController: pullToRefreshController, | ||
| 175 | - onWebViewCreated: (controller) { | ||
| 176 | - webViewController = controller; | ||
| 177 | - }, | ||
| 178 | - onLoadStart: (controller, url) { | ||
| 179 | - setState(() { | ||
| 180 | - this.url = url.toString(); | ||
| 181 | - urlController.text = this.url; | ||
| 182 | - }); | ||
| 183 | - }, | ||
| 184 | - androidOnPermissionRequest: | ||
| 185 | - (controller, origin, resources) async { | ||
| 186 | - return PermissionRequestResponse( | ||
| 187 | - resources: resources, | ||
| 188 | - action: PermissionRequestResponseAction.GRANT); | ||
| 189 | - }, | ||
| 190 | - shouldOverrideUrlLoading: (controller, navigationAction) async { | ||
| 191 | - var uri = navigationAction.request.url; | ||
| 192 | - | ||
| 193 | - if (![ | ||
| 194 | - "http", | ||
| 195 | - "https", | ||
| 196 | - "file", | ||
| 197 | - "chrome", | ||
| 198 | - "data", | ||
| 199 | - "javascript", | ||
| 200 | - "about" | ||
| 201 | - ].contains(uri.scheme)) { | ||
| 202 | - if (await canLaunch(url)) { | ||
| 203 | - // Launch the App | ||
| 204 | - await launch( | ||
| 205 | - url, | ||
| 206 | - ); | ||
| 207 | - // and cancel the request | ||
| 208 | - return NavigationActionPolicy.CANCEL; | ||
| 209 | - } | ||
| 210 | - } | ||
| 211 | - | ||
| 212 | - return NavigationActionPolicy.ALLOW; | ||
| 213 | - }, | ||
| 214 | - onLoadStop: (controller, url) async { | ||
| 215 | - pullToRefreshController.endRefreshing(); | ||
| 216 | - setState(() { | ||
| 217 | - this.url = url.toString(); | ||
| 218 | - urlController.text = this.url; | ||
| 219 | - }); | ||
| 220 | - }, | ||
| 221 | - onLoadError: (controller, url, code, message) { | ||
| 222 | - pullToRefreshController.endRefreshing(); | ||
| 223 | - }, | ||
| 224 | - onProgressChanged: (controller, progress) { | ||
| 225 | - if (progress == 100) { | ||
| 226 | - pullToRefreshController.endRefreshing(); | ||
| 227 | - } | ||
| 228 | - setState(() { | ||
| 229 | - this.progress = progress / 100; | ||
| 230 | - urlController.text = this.url; | ||
| 231 | - }); | ||
| 232 | - }, | ||
| 233 | - onUpdateVisitedHistory: (controller, url, androidIsReload) { | ||
| 234 | - setState(() { | ||
| 235 | - this.url = url.toString(); | ||
| 236 | - urlController.text = this.url; | ||
| 237 | - }); | ||
| 238 | - }, | ||
| 239 | - onConsoleMessage: (controller, consoleMessage) { | ||
| 240 | - print(consoleMessage); | ||
| 241 | - }, | ||
| 242 | - onDownloadStart: (controller, url) async { | ||
| 243 | - print("onDownloadStart $url"); | ||
| 244 | - Utils.showToast('开始下载...'); | ||
| 245 | - // final taskId = await FlutterDownloader.enqueue( | ||
| 246 | - // url: url.toString(), | ||
| 247 | - // savedDir: (await getExternalStorageDirectory()).path, | ||
| 248 | - // showNotification: | ||
| 249 | - // true, // show download progress in status bar (for Android) | ||
| 250 | - // openFileFromNotification: | ||
| 251 | - // true, // click on notification to open downloaded file (for Android) | ||
| 252 | - // ); | ||
| 253 | - final dir = await getExternalStorageDirectory(); | ||
| 254 | - String savePath = dir.path + "/one_key"; | ||
| 255 | - | ||
| 256 | - Directory directory = new Directory(savePath); | ||
| 257 | - if (directory.existsSync()) { | ||
| 258 | - //删除历史apk | ||
| 259 | - final List<FileSystemEntity> files = directory.listSync(); | ||
| 260 | - for (FileSystemEntity file in files) { | ||
| 261 | - file.deleteSync(); | ||
| 262 | - } | ||
| 263 | - } | ||
| 264 | - DioUtil().download(url.toString(), savePath, | ||
| 265 | - onProgress: (received, total) { | ||
| 266 | - // if (_progress != 100) { | ||
| 267 | - // int progress = ((received / total) * 100).round(); | ||
| 268 | - // _progress = progress; | ||
| 269 | - // _setState(() {}); | ||
| 270 | - // } | ||
| 271 | - if (received == total) { | ||
| 272 | - print('object'); | ||
| 273 | - Utils.showToast('文件已保存在${savePath}'); | ||
| 274 | - // openFile(savePath); | ||
| 275 | - //下载完成 | ||
| 276 | - // InstallPlugin.installApk(savePath, "com.naji.one_key"); | ||
| 277 | - } | ||
| 278 | - }); | ||
| 279 | - // }, | ||
| 280 | - // DioUtil().download(url.toString(), | ||
| 281 | - // (await getExternalStorageDirectory()).path, | ||
| 282 | - // onProgress: (received, total) { | ||
| 283 | - // // if (_progress != 100) { | ||
| 284 | - // // int progress = ((received / total) * 100).round(); | ||
| 285 | - // // _progress = progress; | ||
| 286 | - // // _setState(() {}); | ||
| 287 | - // // } | ||
| 288 | - // if (received == total) { | ||
| 289 | - // //下载完成 | ||
| 290 | - // // InstallPlugin.installApk(savePath, "com.naji.one_key"); | ||
| 291 | - // } | ||
| 292 | - // }); | ||
| 293 | - }, | ||
| 294 | - )) | ||
| 295 | - ], | ||
| 296 | - ) | ||
| 297 | - // Builder(builder: (BuildContext context) { | ||
| 298 | - // return WebView( | ||
| 299 | - // initialUrl: "http://colorcun.com/privacy1.html", | ||
| 300 | - // javascriptMode: JavascriptMode.unrestricted, | ||
| 301 | - // onWebViewCreated: (WebViewController webViewController) { | ||
| 302 | - // _controller.complete(webViewController); | ||
| 303 | - // }, | ||
| 304 | - // // TODO(iskakaushik): Remove this when collection literals makes it to stable. | ||
| 305 | - // // ignore: prefer_collection_literals | ||
| 306 | - // javascriptChannels: <JavascriptChannel>[ | ||
| 307 | - // _toasterJavascriptChannel(context), | ||
| 308 | - // ].toSet(), | ||
| 309 | - // navigationDelegate: (NavigationRequest request) { | ||
| 310 | - // if (request.url.startsWith('https://www.youtube.com/')) { | ||
| 311 | - // print('blocking navigation to $request}'); | ||
| 312 | - // return NavigationDecision.prevent; | ||
| 313 | - // } | ||
| 314 | - // print('allowing navigation to $request'); | ||
| 315 | - // return NavigationDecision.navigate; | ||
| 316 | - // }, | ||
| 317 | - // onPageStarted: (String url) { | ||
| 318 | - // print('Page started loading: $url'); | ||
| 319 | - // }, | ||
| 320 | - // onPageFinished: (String url) async { | ||
| 321 | - // print('Page finished loading: $url'); | ||
| 322 | - // // showDownloadProgress(context); | ||
| 323 | - // final dir = await getExternalStorageDirectory(); | ||
| 324 | - // String savePath = dir.path + "/one_key"; | ||
| 325 | - // DioUtil().download(url, savePath, | ||
| 326 | - // onProgress: (received, total) { | ||
| 327 | - // // if (_progress != 100) { | ||
| 328 | - // // int progress = ((received / total) * 100).round(); | ||
| 329 | - // // _progress = progress; | ||
| 330 | - // // _setState(() {}); | ||
| 331 | - // // } | ||
| 332 | - // if (received == total) { | ||
| 333 | - // print('object'); | ||
| 334 | - // //下载完成 | ||
| 335 | - // // InstallPlugin.installApk(savePath, "com.naji.one_key"); | ||
| 336 | - // } | ||
| 337 | - // }); | ||
| 338 | - // }, | ||
| 339 | - // gestureNavigationEnabled: true, | ||
| 340 | - // ); | ||
| 341 | - // }), | ||
| 342 | - ); | 93 | + appBar: SystemAppBar(widget.title, onTap: () { |
| 94 | + if (widget.need) { | ||
| 95 | + Utils.changeStatusColor(color: MyColours.color_199095); | ||
| 96 | + } | ||
| 97 | + Navigator.of(context).pop(); | ||
| 98 | + }), | ||
| 99 | + body: WebViewWidget(controller: controller), | ||
| 100 | + ); | ||
| 343 | } | 101 | } |
| 344 | - | ||
| 345 | - // JavascriptChannel _toasterJavascriptChannel(BuildContext context) { | ||
| 346 | - // return JavascriptChannel( | ||
| 347 | - // name: 'Toaster', | ||
| 348 | - // onMessageReceived: (JavascriptMessage message) { | ||
| 349 | - // Scaffold.of(context).showSnackBar( | ||
| 350 | - // SnackBar(content: Text(message.message)), | ||
| 351 | - // ); | ||
| 352 | - // }); | ||
| 353 | - // } | ||
| 354 | } | 102 | } |
| 355 | 103 | ||
| 356 | // class WebPage extends StatelessWidget { | 104 | // class WebPage extends StatelessWidget { |
lib/pages/login/web_page_old.dart
0 → 100644
| 1 | +// import 'dart:async'; | ||
| 2 | + | ||
| 3 | +// import 'package:device_info/device_info.dart'; | ||
| 4 | +// import 'package:dio/dio.dart'; | ||
| 5 | +// import 'package:flutter/material.dart'; | ||
| 6 | +// import 'package:flutter_inappwebview/flutter_inappwebview.dart'; | ||
| 7 | +// import 'package:one_key/net/dio_util.dart'; | ||
| 8 | +// import 'package:one_key/res/colors.dart'; | ||
| 9 | +// import 'package:one_key/utils/event_bus.dart'; | ||
| 10 | +// import 'package:one_key/utils/utils.dart'; | ||
| 11 | +// import 'package:one_key/widgets/system_app_bar.dart'; | ||
| 12 | +// import 'package:path_provider/path_provider.dart'; | ||
| 13 | +// import 'package:permission_handler/permission_handler.dart'; | ||
| 14 | +// import 'package:webview_flutter/webview_flutter.dart'; | ||
| 15 | + | ||
| 16 | +// import 'dart:async'; | ||
| 17 | +// import 'dart:convert'; | ||
| 18 | +// import 'dart:io'; | ||
| 19 | + | ||
| 20 | +// import 'package:flutter/material.dart'; | ||
| 21 | +// import 'package:one_key/utils/event_bus.dart'; | ||
| 22 | +// import 'package:one_key/widgets/app_bar.dart'; | ||
| 23 | +// import 'package:one_key/widgets/system_app_bar.dart'; | ||
| 24 | +// import 'package:webview_flutter/webview_flutter.dart'; | ||
| 25 | + | ||
| 26 | +// // import 'package:flutter_inappwebview/flutter_inappwebview.dart'; | ||
| 27 | +// import 'package:url_launcher/url_launcher.dart'; | ||
| 28 | +// import 'dart:collection'; | ||
| 29 | +// // import 'package:open_file/open_file.dart'; | ||
| 30 | +// // import 'package:flutter_downloader/flutter_downloader.dart'; | ||
| 31 | + | ||
| 32 | +// class WebPage extends StatefulWidget { | ||
| 33 | +// final String title; | ||
| 34 | +// final String url; | ||
| 35 | +// final bool need; | ||
| 36 | + | ||
| 37 | +// const WebPage({Key key, this.title, this.url, this.need = false}) | ||
| 38 | +// : super(key: key); | ||
| 39 | +// @override | ||
| 40 | +// _WebPageState createState() => _WebPageState(); | ||
| 41 | +// } | ||
| 42 | + | ||
| 43 | +// class _WebPageState extends State<WebPage> { | ||
| 44 | +// final GlobalKey webViewKey = GlobalKey(); | ||
| 45 | + | ||
| 46 | +// InAppWebViewController webViewController; | ||
| 47 | +// InAppWebViewGroupOptions options = InAppWebViewGroupOptions( | ||
| 48 | +// crossPlatform: InAppWebViewOptions( | ||
| 49 | +// useShouldOverrideUrlLoading: true, | ||
| 50 | +// useOnDownloadStart: true, | ||
| 51 | +// mediaPlaybackRequiresUserGesture: false, | ||
| 52 | +// ), | ||
| 53 | +// android: AndroidInAppWebViewOptions( | ||
| 54 | +// useHybridComposition: true, | ||
| 55 | +// ), | ||
| 56 | +// ios: IOSInAppWebViewOptions( | ||
| 57 | +// allowsInlineMediaPlayback: true, | ||
| 58 | +// )); | ||
| 59 | + | ||
| 60 | +// PullToRefreshController pullToRefreshController; | ||
| 61 | +// ContextMenu contextMenu; | ||
| 62 | +// String url = ""; | ||
| 63 | +// double progress = 0; | ||
| 64 | +// final urlController = TextEditingController(); | ||
| 65 | +// // Future<void> openFile(filePath) async { | ||
| 66 | +// // final _result = await OpenFile.open(filePath); | ||
| 67 | +// // print(_result.message); | ||
| 68 | + | ||
| 69 | +// // // setState(() { | ||
| 70 | +// // // _openResult = "type=${_result.type} message=${_result.message}"; | ||
| 71 | +// // // }); | ||
| 72 | +// // } | ||
| 73 | + | ||
| 74 | +// @override | ||
| 75 | +// void initState() { | ||
| 76 | +// super.initState(); | ||
| 77 | + | ||
| 78 | +// // Enable hybrid composition. | ||
| 79 | +// _init(); | ||
| 80 | +// } | ||
| 81 | + | ||
| 82 | +// @override | ||
| 83 | +// void dispose() { | ||
| 84 | +// if (widget.need) { | ||
| 85 | +// Utils.changeStatusColor(color: MyColours.color_199095); | ||
| 86 | +// } | ||
| 87 | + | ||
| 88 | +// super.dispose(); | ||
| 89 | +// } | ||
| 90 | + | ||
| 91 | +// Future<bool> _checkPermission() async { | ||
| 92 | +// DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); | ||
| 93 | +// AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; | ||
| 94 | +// if (Platform.isAndroid && androidInfo.version.sdkInt <= 28) { | ||
| 95 | +// final status = await Permission.storage.status; | ||
| 96 | +// if (status != PermissionStatus.granted) { | ||
| 97 | +// final result = await Permission.storage.request(); | ||
| 98 | +// if (result == PermissionStatus.granted) { | ||
| 99 | +// return true; | ||
| 100 | +// } | ||
| 101 | +// } else { | ||
| 102 | +// return true; | ||
| 103 | +// } | ||
| 104 | +// } else { | ||
| 105 | +// return true; | ||
| 106 | +// } | ||
| 107 | +// return false; | ||
| 108 | +// } | ||
| 109 | + | ||
| 110 | +// Future<bool> checkPermissionStorage() async { | ||
| 111 | +// var status = await Permission.storage.status; | ||
| 112 | +// if (!status.isGranted) { | ||
| 113 | +// status = await Permission.storage.request(); | ||
| 114 | +// if (status.isGranted) { | ||
| 115 | +// return true; | ||
| 116 | +// } | ||
| 117 | +// } else { | ||
| 118 | +// return true; | ||
| 119 | +// } | ||
| 120 | +// return false; | ||
| 121 | +// } | ||
| 122 | + | ||
| 123 | +// _init() async { | ||
| 124 | +// // WidgetsFlutterBinding.ensureInitialized(); | ||
| 125 | +// // await FlutterDownloader.initialize(debug: true); | ||
| 126 | +// if (Platform.isAndroid) { | ||
| 127 | +// await AndroidInAppWebViewController.setWebContentsDebuggingEnabled(true); | ||
| 128 | + | ||
| 129 | +// var swAvailable = await AndroidWebViewFeature.isFeatureSupported( | ||
| 130 | +// AndroidWebViewFeature.SERVICE_WORKER_BASIC_USAGE); | ||
| 131 | +// var swInterceptAvailable = await AndroidWebViewFeature.isFeatureSupported( | ||
| 132 | +// AndroidWebViewFeature.SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST); | ||
| 133 | + | ||
| 134 | +// if (swAvailable && swInterceptAvailable) { | ||
| 135 | +// AndroidServiceWorkerController serviceWorkerController = | ||
| 136 | +// AndroidServiceWorkerController.instance(); | ||
| 137 | + | ||
| 138 | +// serviceWorkerController.serviceWorkerClient = | ||
| 139 | +// AndroidServiceWorkerClient( | ||
| 140 | +// shouldInterceptRequest: (request) async { | ||
| 141 | +// print(request); | ||
| 142 | +// return null; | ||
| 143 | +// }, | ||
| 144 | +// ); | ||
| 145 | +// } | ||
| 146 | +// } | ||
| 147 | +// // await FlutterDownloader.initialize( | ||
| 148 | +// // debug: true // optional: set false to disable printing logs to console | ||
| 149 | +// // ); | ||
| 150 | +// // await Permission.storage.request(); | ||
| 151 | +// } | ||
| 152 | + | ||
| 153 | +// @override | ||
| 154 | +// Widget build(BuildContext context) { | ||
| 155 | +// return Scaffold( | ||
| 156 | +// // We're using a Builder here so we have a context that is below the Scaffold | ||
| 157 | +// // to allow calling Scaffold.of(context) so we can show a snackbar. | ||
| 158 | +// appBar: SystemAppBar( | ||
| 159 | +// widget.title, | ||
| 160 | +// ), | ||
| 161 | +// body: Column( | ||
| 162 | +// children: [ | ||
| 163 | +// Expanded( | ||
| 164 | +// child: InAppWebView( | ||
| 165 | +// key: webViewKey, | ||
| 166 | +// // contextMenu: contextMenu, | ||
| 167 | +// initialUrlRequest: URLRequest( | ||
| 168 | +// // url: Uri.parse("http://colorcun.com/privacy1.html")), | ||
| 169 | +// url: Uri.parse("http://colorcun.com/privacy2.html")), | ||
| 170 | +// //华为下载功能闪退,去掉下载功能*********http://colorcun.com/privacy2.html | ||
| 171 | +// // initialFile: "assets/index.html", | ||
| 172 | +// initialUserScripts: UnmodifiableListView<UserScript>([]), | ||
| 173 | +// initialOptions: options, | ||
| 174 | +// pullToRefreshController: pullToRefreshController, | ||
| 175 | +// onWebViewCreated: (controller) { | ||
| 176 | +// webViewController = controller; | ||
| 177 | +// }, | ||
| 178 | +// onLoadStart: (controller, url) { | ||
| 179 | +// setState(() { | ||
| 180 | +// this.url = url.toString(); | ||
| 181 | +// urlController.text = this.url; | ||
| 182 | +// }); | ||
| 183 | +// }, | ||
| 184 | +// androidOnPermissionRequest: | ||
| 185 | +// (controller, origin, resources) async { | ||
| 186 | +// return PermissionRequestResponse( | ||
| 187 | +// resources: resources, | ||
| 188 | +// action: PermissionRequestResponseAction.GRANT); | ||
| 189 | +// }, | ||
| 190 | +// shouldOverrideUrlLoading: (controller, navigationAction) async { | ||
| 191 | +// var uri = navigationAction.request.url; | ||
| 192 | + | ||
| 193 | +// if (![ | ||
| 194 | +// "http", | ||
| 195 | +// "https", | ||
| 196 | +// "file", | ||
| 197 | +// "chrome", | ||
| 198 | +// "data", | ||
| 199 | +// "javascript", | ||
| 200 | +// "about" | ||
| 201 | +// ].contains(uri.scheme)) { | ||
| 202 | +// if (await canLaunch(url)) { | ||
| 203 | +// // Launch the App | ||
| 204 | +// await launch( | ||
| 205 | +// url, | ||
| 206 | +// ); | ||
| 207 | +// // and cancel the request | ||
| 208 | +// return NavigationActionPolicy.CANCEL; | ||
| 209 | +// } | ||
| 210 | +// } | ||
| 211 | + | ||
| 212 | +// return NavigationActionPolicy.ALLOW; | ||
| 213 | +// }, | ||
| 214 | +// onLoadStop: (controller, url) async { | ||
| 215 | +// pullToRefreshController.endRefreshing(); | ||
| 216 | +// setState(() { | ||
| 217 | +// this.url = url.toString(); | ||
| 218 | +// urlController.text = this.url; | ||
| 219 | +// }); | ||
| 220 | +// }, | ||
| 221 | +// onLoadError: (controller, url, code, message) { | ||
| 222 | +// pullToRefreshController.endRefreshing(); | ||
| 223 | +// }, | ||
| 224 | +// onProgressChanged: (controller, progress) { | ||
| 225 | +// if (progress == 100) { | ||
| 226 | +// pullToRefreshController.endRefreshing(); | ||
| 227 | +// } | ||
| 228 | +// setState(() { | ||
| 229 | +// this.progress = progress / 100; | ||
| 230 | +// urlController.text = this.url; | ||
| 231 | +// }); | ||
| 232 | +// }, | ||
| 233 | +// onUpdateVisitedHistory: (controller, url, androidIsReload) { | ||
| 234 | +// setState(() { | ||
| 235 | +// this.url = url.toString(); | ||
| 236 | +// urlController.text = this.url; | ||
| 237 | +// }); | ||
| 238 | +// }, | ||
| 239 | +// onConsoleMessage: (controller, consoleMessage) { | ||
| 240 | +// print(consoleMessage); | ||
| 241 | +// }, | ||
| 242 | +// onDownloadStart: (controller, url) async { | ||
| 243 | +// print("onDownloadStart $url"); | ||
| 244 | +// Utils.showToast('开始下载...'); | ||
| 245 | +// // final taskId = await FlutterDownloader.enqueue( | ||
| 246 | +// // url: url.toString(), | ||
| 247 | +// // savedDir: (await getExternalStorageDirectory()).path, | ||
| 248 | +// // showNotification: | ||
| 249 | +// // true, // show download progress in status bar (for Android) | ||
| 250 | +// // openFileFromNotification: | ||
| 251 | +// // true, // click on notification to open downloaded file (for Android) | ||
| 252 | +// // ); | ||
| 253 | +// final dir = await getExternalStorageDirectory(); | ||
| 254 | +// String savePath = dir.path + "/one_key"; | ||
| 255 | + | ||
| 256 | +// Directory directory = new Directory(savePath); | ||
| 257 | +// if (directory.existsSync()) { | ||
| 258 | +// //删除历史apk | ||
| 259 | +// final List<FileSystemEntity> files = directory.listSync(); | ||
| 260 | +// for (FileSystemEntity file in files) { | ||
| 261 | +// file.deleteSync(); | ||
| 262 | +// } | ||
| 263 | +// } | ||
| 264 | +// DioUtil().download(url.toString(), savePath, | ||
| 265 | +// onProgress: (received, total) { | ||
| 266 | +// // if (_progress != 100) { | ||
| 267 | +// // int progress = ((received / total) * 100).round(); | ||
| 268 | +// // _progress = progress; | ||
| 269 | +// // _setState(() {}); | ||
| 270 | +// // } | ||
| 271 | +// if (received == total) { | ||
| 272 | +// print('object'); | ||
| 273 | +// Utils.showToast('文件已保存在${savePath}'); | ||
| 274 | +// // openFile(savePath); | ||
| 275 | +// //下载完成 | ||
| 276 | +// // InstallPlugin.installApk(savePath, "com.naji.one_key"); | ||
| 277 | +// } | ||
| 278 | +// }); | ||
| 279 | +// // }, | ||
| 280 | +// // DioUtil().download(url.toString(), | ||
| 281 | +// // (await getExternalStorageDirectory()).path, | ||
| 282 | +// // onProgress: (received, total) { | ||
| 283 | +// // // if (_progress != 100) { | ||
| 284 | +// // // int progress = ((received / total) * 100).round(); | ||
| 285 | +// // // _progress = progress; | ||
| 286 | +// // // _setState(() {}); | ||
| 287 | +// // // } | ||
| 288 | +// // if (received == total) { | ||
| 289 | +// // //下载完成 | ||
| 290 | +// // // InstallPlugin.installApk(savePath, "com.naji.one_key"); | ||
| 291 | +// // } | ||
| 292 | +// // }); | ||
| 293 | +// }, | ||
| 294 | +// )) | ||
| 295 | +// ], | ||
| 296 | +// ) | ||
| 297 | +// // Builder(builder: (BuildContext context) { | ||
| 298 | +// // return WebView( | ||
| 299 | +// // initialUrl: "http://colorcun.com/privacy1.html", | ||
| 300 | +// // javascriptMode: JavascriptMode.unrestricted, | ||
| 301 | +// // onWebViewCreated: (WebViewController webViewController) { | ||
| 302 | +// // _controller.complete(webViewController); | ||
| 303 | +// // }, | ||
| 304 | +// // // TODO(iskakaushik): Remove this when collection literals makes it to stable. | ||
| 305 | +// // // ignore: prefer_collection_literals | ||
| 306 | +// // javascriptChannels: <JavascriptChannel>[ | ||
| 307 | +// // _toasterJavascriptChannel(context), | ||
| 308 | +// // ].toSet(), | ||
| 309 | +// // navigationDelegate: (NavigationRequest request) { | ||
| 310 | +// // if (request.url.startsWith('https://www.youtube.com/')) { | ||
| 311 | +// // print('blocking navigation to $request}'); | ||
| 312 | +// // return NavigationDecision.prevent; | ||
| 313 | +// // } | ||
| 314 | +// // print('allowing navigation to $request'); | ||
| 315 | +// // return NavigationDecision.navigate; | ||
| 316 | +// // }, | ||
| 317 | +// // onPageStarted: (String url) { | ||
| 318 | +// // print('Page started loading: $url'); | ||
| 319 | +// // }, | ||
| 320 | +// // onPageFinished: (String url) async { | ||
| 321 | +// // print('Page finished loading: $url'); | ||
| 322 | +// // // showDownloadProgress(context); | ||
| 323 | +// // final dir = await getExternalStorageDirectory(); | ||
| 324 | +// // String savePath = dir.path + "/one_key"; | ||
| 325 | +// // DioUtil().download(url, savePath, | ||
| 326 | +// // onProgress: (received, total) { | ||
| 327 | +// // // if (_progress != 100) { | ||
| 328 | +// // // int progress = ((received / total) * 100).round(); | ||
| 329 | +// // // _progress = progress; | ||
| 330 | +// // // _setState(() {}); | ||
| 331 | +// // // } | ||
| 332 | +// // if (received == total) { | ||
| 333 | +// // print('object'); | ||
| 334 | +// // //下载完成 | ||
| 335 | +// // // InstallPlugin.installApk(savePath, "com.naji.one_key"); | ||
| 336 | +// // } | ||
| 337 | +// // }); | ||
| 338 | +// // }, | ||
| 339 | +// // gestureNavigationEnabled: true, | ||
| 340 | +// // ); | ||
| 341 | +// // }), | ||
| 342 | +// ); | ||
| 343 | +// } | ||
| 344 | + | ||
| 345 | +// // JavascriptChannel _toasterJavascriptChannel(BuildContext context) { | ||
| 346 | +// // return JavascriptChannel( | ||
| 347 | +// // name: 'Toaster', | ||
| 348 | +// // onMessageReceived: (JavascriptMessage message) { | ||
| 349 | +// // Scaffold.of(context).showSnackBar( | ||
| 350 | +// // SnackBar(content: Text(message.message)), | ||
| 351 | +// // ); | ||
| 352 | +// // }); | ||
| 353 | +// // } | ||
| 354 | +// } | ||
| 355 | + | ||
| 356 | +// // class WebPage extends StatelessWidget { | ||
| 357 | +// // final String title; | ||
| 358 | +// // final String url; | ||
| 359 | +// // final bool need; | ||
| 360 | + | ||
| 361 | +// // const WebPage({Key key, this.title, this.url, this.need = false}) | ||
| 362 | +// // : super(key: key); | ||
| 363 | +// // @override | ||
| 364 | +// // Widget build(BuildContext context) { | ||
| 365 | +// // final Completer<WebViewController> _controller = | ||
| 366 | +// // Completer<WebViewController>(); | ||
| 367 | +// // return Scaffold( | ||
| 368 | +// // appBar: SystemAppBar(title, onTap: () { | ||
| 369 | +// // if (need) { | ||
| 370 | +// // Utils.changeStatusColor(color: MyColours.color_199095); | ||
| 371 | +// // } | ||
| 372 | +// // Navigator.of(context).pop(); | ||
| 373 | +// // }), | ||
| 374 | +// // body: WillPopScope( | ||
| 375 | +// // onWillPop: () async { | ||
| 376 | +// // if (need) { | ||
| 377 | +// // Utils.changeStatusColor(color: MyColours.color_199095); | ||
| 378 | +// // } | ||
| 379 | +// // return true; | ||
| 380 | +// // }, | ||
| 381 | +// // child: WebView( | ||
| 382 | +// // initialUrl: "http://colorcun.com/privacy1.html", | ||
| 383 | +// // javascriptMode: JavascriptMode.unrestricted, | ||
| 384 | +// // onWebViewCreated: (WebViewController webViewController) { | ||
| 385 | +// // // Loading.showLoading(context); | ||
| 386 | +// // _controller.complete(webViewController); | ||
| 387 | +// // }, | ||
| 388 | +// // javascriptChannels: <JavascriptChannel>[ | ||
| 389 | +// // _toasterJavascriptChannel(context), | ||
| 390 | +// // ].toSet(), | ||
| 391 | +// // navigationDelegate: (NavigationRequest request) { | ||
| 392 | +// // if (request.url.startsWith('https://www.youtube.com/')) { | ||
| 393 | +// // return NavigationDecision.prevent; | ||
| 394 | +// // } | ||
| 395 | +// // return NavigationDecision.navigate; | ||
| 396 | +// // }, | ||
| 397 | +// // onPageStarted: (String url) {}, | ||
| 398 | +// // onPageFinished: (String url) { | ||
| 399 | +// // // Loading.hideLoading(context); | ||
| 400 | +// // }, | ||
| 401 | +// // gestureNavigationEnabled: true, | ||
| 402 | +// // )), | ||
| 403 | +// // ); | ||
| 404 | +// // } | ||
| 405 | + | ||
| 406 | +// // JavascriptChannel _toasterJavascriptChannel(BuildContext context) { | ||
| 407 | +// // return JavascriptChannel( | ||
| 408 | +// // name: 'Toaster', | ||
| 409 | +// // onMessageReceived: (JavascriptMessage message) { | ||
| 410 | +// // Scaffold.of(context).showSnackBar( | ||
| 411 | +// // SnackBar(content: Text(message.message)), | ||
| 412 | +// // ); | ||
| 413 | +// // }); | ||
| 414 | +// // } | ||
| 415 | +// // } |
| 1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
| 2 | -import 'package:flutter_inappwebview/flutter_inappwebview.dart'; | 2 | +// import 'package:flutter_inappwebview/flutter_inappwebview.dart'; |
| 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 4 | import 'package:one_key/res/colors.dart'; | 4 | import 'package:one_key/res/colors.dart'; |
| 5 | import 'package:one_key/route/navigator_util.dart'; | 5 | import 'package:one_key/route/navigator_util.dart'; |
| @@ -184,7 +184,8 @@ class _PlanDishCreateSelectTypePageState | @@ -184,7 +184,8 @@ class _PlanDishCreateSelectTypePageState | ||
| 184 | onPressed: () async { | 184 | onPressed: () async { |
| 185 | bool needRefresh = await NavigatorUtil.goPlanDishEditPage( | 185 | bool needRefresh = await NavigatorUtil.goPlanDishEditPage( |
| 186 | context, | 186 | context, |
| 187 | - isMine: selectF,isEdit:true); | 187 | + isMine: selectF, |
| 188 | + isEdit: true); | ||
| 188 | print(needRefresh); | 189 | print(needRefresh); |
| 189 | if (needRefresh != null && needRefresh) { | 190 | if (needRefresh != null && needRefresh) { |
| 190 | Navigator.pop(context); | 191 | Navigator.pop(context); |
| @@ -772,8 +772,9 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> { | @@ -772,8 +772,9 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> { | ||
| 772 | return InkWell( | 772 | return InkWell( |
| 773 | onTap: () { | 773 | onTap: () { |
| 774 | Utils.getPickPermission(context, () async { | 774 | Utils.getPickPermission(context, () async { |
| 775 | - mapAddress = await NavigatorUtil.goMapChoicePointPage(context); | ||
| 776 | - if (mapAddress != null) { | 775 | + Map temp = await NavigatorUtil.goMapChoicePointPage(context); |
| 776 | + if (temp != null) { | ||
| 777 | + mapAddress = temp; | ||
| 777 | setState(() { | 778 | setState(() { |
| 778 | // storeMapAddress = address['address']; | 779 | // storeMapAddress = address['address']; |
| 779 | // // createStoreModel.storeInfo?.address = storeAddress; | 780 | // // createStoreModel.storeInfo?.address = storeAddress; |
| @@ -1765,16 +1766,18 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> { | @@ -1765,16 +1766,18 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> { | ||
| 1765 | padding: EdgeInsets.symmetric( | 1766 | padding: EdgeInsets.symmetric( |
| 1766 | horizontal: ScreenUtil().setWidth(24), | 1767 | horizontal: ScreenUtil().setWidth(24), |
| 1767 | ), | 1768 | ), |
| 1768 | - child: mapAddress['address'] == '' || | 1769 | + child: mapAddress == null || |
| 1770 | + mapAddress['address'] == '' || | ||
| 1769 | mapAddress['address'] == null || | 1771 | mapAddress['address'] == null || |
| 1770 | mapAddress['address'] == 'null' | 1772 | mapAddress['address'] == 'null' |
| 1771 | ? InkWell( | 1773 | ? InkWell( |
| 1772 | onTap: () { | 1774 | onTap: () { |
| 1773 | Utils.getPickPermission(context, | 1775 | Utils.getPickPermission(context, |
| 1774 | () async { | 1776 | () async { |
| 1775 | - mapAddress = await NavigatorUtil | 1777 | + Map temp = await NavigatorUtil |
| 1776 | .goMapChoicePointPage(context); | 1778 | .goMapChoicePointPage(context); |
| 1777 | - if (mapAddress != null) { | 1779 | + if (temp != null) { |
| 1780 | + mapAddress = temp; | ||
| 1778 | setState(() { | 1781 | setState(() { |
| 1779 | // storeMapAddress = address['address']; | 1782 | // storeMapAddress = address['address']; |
| 1780 | // // createStoreModel.storeInfo?.address = storeAddress; | 1783 | // // createStoreModel.storeInfo?.address = storeAddress; |
| @@ -1872,11 +1875,12 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> { | @@ -1872,11 +1875,12 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> { | ||
| 1872 | onPressed: () { | 1875 | onPressed: () { |
| 1873 | Utils.getPickPermission( | 1876 | Utils.getPickPermission( |
| 1874 | context, () async { | 1877 | context, () async { |
| 1875 | - mapAddress = | ||
| 1876 | - await NavigatorUtil | ||
| 1877 | - .goMapChoicePointPage( | ||
| 1878 | - context); | ||
| 1879 | - if (mapAddress != null) { | 1878 | + Map temp = await NavigatorUtil |
| 1879 | + .goMapChoicePointPage( | ||
| 1880 | + context); | ||
| 1881 | + if (temp != null) { | ||
| 1882 | + mapAddress = temp; | ||
| 1883 | + | ||
| 1880 | setState(() { | 1884 | setState(() { |
| 1881 | // storeMapAddress = address['address']; | 1885 | // storeMapAddress = address['address']; |
| 1882 | // // createStoreModel.storeInfo?.address = storeAddress; | 1886 | // // createStoreModel.storeInfo?.address = storeAddress; |
| @@ -21,7 +21,7 @@ class _WebViewPageState extends State<WebViewPage> { | @@ -21,7 +21,7 @@ class _WebViewPageState extends State<WebViewPage> { | ||
| 21 | void initState() { | 21 | void initState() { |
| 22 | super.initState(); | 22 | super.initState(); |
| 23 | // Enable hybrid composition. | 23 | // Enable hybrid composition. |
| 24 | - if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); | 24 | + // if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | @override | 27 | @override |
| @@ -33,51 +33,52 @@ class _WebViewPageState extends State<WebViewPage> { | @@ -33,51 +33,52 @@ class _WebViewPageState extends State<WebViewPage> { | ||
| 33 | 33 | ||
| 34 | @override | 34 | @override |
| 35 | Widget build(BuildContext context) { | 35 | Widget build(BuildContext context) { |
| 36 | - return Scaffold( | ||
| 37 | - // We're using a Builder here so we have a context that is below the Scaffold | ||
| 38 | - // to allow calling Scaffold.of(context) so we can show a snackbar. | ||
| 39 | - appBar: SystemAppBar( | ||
| 40 | - '周到安排商家', | ||
| 41 | - ), | ||
| 42 | - body: Builder(builder: (BuildContext context) { | ||
| 43 | - return WebView( | ||
| 44 | - initialUrl: "https://support.qq.com/product/152856", | ||
| 45 | - javascriptMode: JavascriptMode.unrestricted, | ||
| 46 | - onWebViewCreated: (WebViewController webViewController) { | ||
| 47 | - _controller.complete(webViewController); | ||
| 48 | - }, | ||
| 49 | - // TODO(iskakaushik): Remove this when collection literals makes it to stable. | ||
| 50 | - // ignore: prefer_collection_literals | ||
| 51 | - javascriptChannels: <JavascriptChannel>[ | ||
| 52 | - _toasterJavascriptChannel(context), | ||
| 53 | - ].toSet(), | ||
| 54 | - navigationDelegate: (NavigationRequest request) { | ||
| 55 | - if (request.url.startsWith('https://www.youtube.com/')) { | ||
| 56 | - print('blocking navigation to $request}'); | ||
| 57 | - return NavigationDecision.prevent; | ||
| 58 | - } | ||
| 59 | - print('allowing navigation to $request'); | ||
| 60 | - return NavigationDecision.navigate; | ||
| 61 | - }, | ||
| 62 | - onPageStarted: (String url) { | ||
| 63 | - print('Page started loading: $url'); | ||
| 64 | - }, | ||
| 65 | - onPageFinished: (String url) { | ||
| 66 | - print('Page finished loading: $url'); | ||
| 67 | - }, | ||
| 68 | - gestureNavigationEnabled: true, | ||
| 69 | - ); | ||
| 70 | - }), | ||
| 71 | - ); | 36 | + return Container(); |
| 37 | + // return Scaffold( | ||
| 38 | + // // We're using a Builder here so we have a context that is below the Scaffold | ||
| 39 | + // // to allow calling Scaffold.of(context) so we can show a snackbar. | ||
| 40 | + // appBar: SystemAppBar( | ||
| 41 | + // '周到安排商家', | ||
| 42 | + // ), | ||
| 43 | + // body: Builder(builder: (BuildContext context) { | ||
| 44 | + // return WebView( | ||
| 45 | + // initialUrl: "https://support.qq.com/product/152856", | ||
| 46 | + // javascriptMode: JavascriptMode.unrestricted, | ||
| 47 | + // onWebViewCreated: (WebViewController webViewController) { | ||
| 48 | + // _controller.complete(webViewController); | ||
| 49 | + // }, | ||
| 50 | + // // TODO(iskakaushik): Remove this when collection literals makes it to stable. | ||
| 51 | + // // ignore: prefer_collection_literals | ||
| 52 | + // javascriptChannels: <JavascriptChannel>[ | ||
| 53 | + // _toasterJavascriptChannel(context), | ||
| 54 | + // ].toSet(), | ||
| 55 | + // navigationDelegate: (NavigationRequest request) { | ||
| 56 | + // if (request.url.startsWith('https://www.youtube.com/')) { | ||
| 57 | + // print('blocking navigation to $request}'); | ||
| 58 | + // return NavigationDecision.prevent; | ||
| 59 | + // } | ||
| 60 | + // print('allowing navigation to $request'); | ||
| 61 | + // return NavigationDecision.navigate; | ||
| 62 | + // }, | ||
| 63 | + // onPageStarted: (String url) { | ||
| 64 | + // print('Page started loading: $url'); | ||
| 65 | + // }, | ||
| 66 | + // onPageFinished: (String url) { | ||
| 67 | + // print('Page finished loading: $url'); | ||
| 68 | + // }, | ||
| 69 | + // gestureNavigationEnabled: true, | ||
| 70 | + // ); | ||
| 71 | + // }), | ||
| 72 | + // ); | ||
| 72 | } | 73 | } |
| 73 | 74 | ||
| 74 | - JavascriptChannel _toasterJavascriptChannel(BuildContext context) { | ||
| 75 | - return JavascriptChannel( | ||
| 76 | - name: 'Toaster', | ||
| 77 | - onMessageReceived: (JavascriptMessage message) { | ||
| 78 | - ScaffoldMessenger.of(context).showSnackBar( | ||
| 79 | - SnackBar(content: Text(message.message)), | ||
| 80 | - ); | ||
| 81 | - }); | ||
| 82 | - } | 75 | + // JavascriptChannel _toasterJavascriptChannel(BuildContext context) { |
| 76 | + // return JavascriptChannel( | ||
| 77 | + // name: 'Toaster', | ||
| 78 | + // onMessageReceived: (JavascriptMessage message) { | ||
| 79 | + // ScaffoldMessenger.of(context).showSnackBar( | ||
| 80 | + // SnackBar(content: Text(message.message)), | ||
| 81 | + // ); | ||
| 82 | + // }); | ||
| 83 | + // } | ||
| 83 | } | 84 | } |
| @@ -609,7 +609,11 @@ class MyTableManageHomeModel with ChangeNotifier { | @@ -609,7 +609,11 @@ class MyTableManageHomeModel with ChangeNotifier { | ||
| 609 | Utils.showToast(baseResp.msg ?? '修改桌位失败!'); | 609 | Utils.showToast(baseResp.msg ?? '修改桌位失败!'); |
| 610 | } | 610 | } |
| 611 | } else { | 611 | } else { |
| 612 | - Utils.showToast(baseResp.msg ?? '修改桌位失败!'); | 612 | + if (baseResp.code == 397) { |
| 613 | + Utils.showToast('桌台已存在'); | ||
| 614 | + } else { | ||
| 615 | + Utils.showToast(baseResp.msg ?? '修改桌位失败!'); | ||
| 616 | + } | ||
| 613 | } | 617 | } |
| 614 | return false; | 618 | return false; |
| 615 | } | 619 | } |
| @@ -55,7 +55,7 @@ import 'package:one_key/pages/login/login_page.dart'; | @@ -55,7 +55,7 @@ import 'package:one_key/pages/login/login_page.dart'; | ||
| 55 | import 'package:one_key/pages/detail/handle_online_page.dart'; | 55 | import 'package:one_key/pages/detail/handle_online_page.dart'; |
| 56 | import 'package:one_key/pages/detail/notebook_detail_page.dart'; | 56 | import 'package:one_key/pages/detail/notebook_detail_page.dart'; |
| 57 | import 'package:one_key/pages/login/login_page_f.dart'; | 57 | import 'package:one_key/pages/login/login_page_f.dart'; |
| 58 | -import 'package:one_key/pages/login/web_page.dart'; | 58 | +import 'package:one_key/pages/login/web_page_old.dart'; |
| 59 | import 'package:one_key/pages/message/message_order_menu.dart'; | 59 | import 'package:one_key/pages/message/message_order_menu.dart'; |
| 60 | 60 | ||
| 61 | import 'package:one_key/pages/my/customer_type/my_customer/my_customer_detail_edit_page.dart'; | 61 | import 'package:one_key/pages/my/customer_type/my_customer/my_customer_detail_edit_page.dart'; |
| @@ -189,6 +189,7 @@ import '../pages/feast/feast_setmeal_page.dart'; | @@ -189,6 +189,7 @@ import '../pages/feast/feast_setmeal_page.dart'; | ||
| 189 | import '../pages/feast/feast_wine_page.dart'; | 189 | import '../pages/feast/feast_wine_page.dart'; |
| 190 | import '../pages/login/collect_store_info_page.dart'; | 190 | import '../pages/login/collect_store_info_page.dart'; |
| 191 | import '../pages/login/complete_create_store.dart'; | 191 | import '../pages/login/complete_create_store.dart'; |
| 192 | +import '../pages/login/web_page.dart'; | ||
| 192 | import '../pages/message/message_recharge_info_page.dart'; | 193 | import '../pages/message/message_recharge_info_page.dart'; |
| 193 | import '../pages/my/comment_manage/comment_manage_home_page.dart'; | 194 | import '../pages/my/comment_manage/comment_manage_home_page.dart'; |
| 194 | import '../pages/my/customer_type/my_customer/my_customer_home_page.dart'; | 195 | import '../pages/my/customer_type/my_customer/my_customer_home_page.dart'; |
| @@ -17,7 +17,7 @@ import 'package:flutter_statusbarcolor_ns/flutter_statusbarcolor_ns.dart'; | @@ -17,7 +17,7 @@ import 'package:flutter_statusbarcolor_ns/flutter_statusbarcolor_ns.dart'; | ||
| 17 | import 'package:fluttertoast/fluttertoast.dart'; | 17 | import 'package:fluttertoast/fluttertoast.dart'; |
| 18 | import 'package:flutter/services.dart'; | 18 | import 'package:flutter/services.dart'; |
| 19 | import 'package:fluwx/fluwx.dart'; | 19 | import 'package:fluwx/fluwx.dart'; |
| 20 | -import 'package:one_key/pages/login/web_page.dart'; | 20 | +import 'package:one_key/pages/login/web_page_old.dart'; |
| 21 | import 'package:one_key/provider/my_model.dart'; | 21 | import 'package:one_key/provider/my_model.dart'; |
| 22 | import 'package:one_key/provider/user_model.dart'; | 22 | import 'package:one_key/provider/user_model.dart'; |
| 23 | import 'package:one_key/res/colors.dart'; | 23 | import 'package:one_key/res/colors.dart'; |
| @@ -1516,8 +1516,9 @@ class Utils { | @@ -1516,8 +1516,9 @@ class Utils { | ||
| 1516 | // miniProgramType: WXMiniProgramType.RELEASE); | 1516 | // miniProgramType: WXMiniProgramType.RELEASE); |
| 1517 | // } | 1517 | // } |
| 1518 | 1518 | ||
| 1519 | - //跳转拨打电话页面 | 1519 | + //跳转帮助与反馈页面 |
| 1520 | static goHelp(BuildContext context) async { | 1520 | static goHelp(BuildContext context) async { |
| 1521 | + //此页面已经注释,不能使用 | ||
| 1521 | NavigatorUtil.goWebviewPage(context); | 1522 | NavigatorUtil.goWebviewPage(context); |
| 1522 | } | 1523 | } |
| 1523 | 1524 |
| @@ -607,7 +607,7 @@ packages: | @@ -607,7 +607,7 @@ packages: | ||
| 607 | name: flutter_inappwebview | 607 | name: flutter_inappwebview |
| 608 | url: "https://pub.flutter-io.cn" | 608 | url: "https://pub.flutter-io.cn" |
| 609 | source: hosted | 609 | source: hosted |
| 610 | - version: "5.7.2+3" | 610 | + version: "5.8.0" |
| 611 | flutter_keyboard_visibility: | 611 | flutter_keyboard_visibility: |
| 612 | dependency: "direct main" | 612 | dependency: "direct main" |
| 613 | description: | 613 | description: |
| @@ -1620,10 +1620,31 @@ packages: | @@ -1620,10 +1620,31 @@ packages: | ||
| 1620 | webview_flutter: | 1620 | webview_flutter: |
| 1621 | dependency: "direct main" | 1621 | dependency: "direct main" |
| 1622 | description: | 1622 | description: |
| 1623 | - path: "library/webview_flutter-2.0.13-copy_inappwebview_select_file_20210930" | ||
| 1624 | - relative: true | ||
| 1625 | - source: path | ||
| 1626 | - version: "2.0.13" | 1623 | + name: webview_flutter |
| 1624 | + url: "https://pub.flutter-io.cn" | ||
| 1625 | + source: hosted | ||
| 1626 | + version: "4.2.2" | ||
| 1627 | + webview_flutter_android: | ||
| 1628 | + dependency: transitive | ||
| 1629 | + description: | ||
| 1630 | + name: webview_flutter_android | ||
| 1631 | + url: "https://pub.flutter-io.cn" | ||
| 1632 | + source: hosted | ||
| 1633 | + version: "3.9.3" | ||
| 1634 | + webview_flutter_platform_interface: | ||
| 1635 | + dependency: transitive | ||
| 1636 | + description: | ||
| 1637 | + name: webview_flutter_platform_interface | ||
| 1638 | + url: "https://pub.flutter-io.cn" | ||
| 1639 | + source: hosted | ||
| 1640 | + version: "2.5.0" | ||
| 1641 | + webview_flutter_wkwebview: | ||
| 1642 | + dependency: transitive | ||
| 1643 | + description: | ||
| 1644 | + name: webview_flutter_wkwebview | ||
| 1645 | + url: "https://pub.flutter-io.cn" | ||
| 1646 | + source: hosted | ||
| 1647 | + version: "3.7.3" | ||
| 1627 | wechat_assets_picker: | 1648 | wechat_assets_picker: |
| 1628 | dependency: "direct main" | 1649 | dependency: "direct main" |
| 1629 | description: | 1650 | description: |
| @@ -185,9 +185,10 @@ dependencies: | @@ -185,9 +185,10 @@ dependencies: | ||
| 185 | # flutter_app_update: ^1.0.0 | 185 | # flutter_app_update: ^1.0.0 |
| 186 | flutter_staggered_grid_view: ^0.4.1 | 186 | flutter_staggered_grid_view: ^0.4.1 |
| 187 | # webview | 187 | # webview |
| 188 | - # webview_flutter: ^2.0.13 | ||
| 189 | - # flutter_inappwebview: ^5.3.2 | ||
| 190 | - flutter_inappwebview: ^5.7.2+3 | 188 | + |
| 189 | + webview_flutter: ^4.2.2 | ||
| 190 | + flutter_inappwebview: ^5.3.2 | ||
| 191 | + # flutter_inappwebview: ^6.0.0 | ||
| 191 | flutter_downloader: ^1.10.5 | 192 | flutter_downloader: ^1.10.5 |
| 192 | android_path_provider: ^0.3.0 | 193 | android_path_provider: ^0.3.0 |
| 193 | # open_file: ^3.2.1 | 194 | # open_file: ^3.2.1 |
| @@ -198,8 +199,8 @@ dependencies: | @@ -198,8 +199,8 @@ dependencies: | ||
| 198 | flutter_draggable_gridview: ^0.0.8 | 199 | flutter_draggable_gridview: ^0.0.8 |
| 199 | 200 | ||
| 200 | 201 | ||
| 201 | - webview_flutter: | ||
| 202 | - path: library/webview_flutter-2.0.13-copy_inappwebview_select_file_20210930 | 202 | + # webview_flutter: |
| 203 | + # path: library/webview_flutter-2.0.13-copy_inappwebview_select_file_20210930 | ||
| 203 | sendsms: | 204 | sendsms: |
| 204 | path: library/sendsms-1.0.3 | 205 | path: library/sendsms-1.0.3 |
| 205 | device_utils_my: | 206 | device_utils_my: |
-
Please register or login to post a comment