Remove webview plugin
This commit is contained in:
		| @@ -17,7 +17,6 @@ import 'package:progress_indicators/progress_indicators.dart'; | |||||||
| import 'package:flutter_markdown/flutter_markdown.dart'; | import 'package:flutter_markdown/flutter_markdown.dart'; | ||||||
| import 'package:flutter_custom_tabs/flutter_custom_tabs.dart'; | import 'package:flutter_custom_tabs/flutter_custom_tabs.dart'; | ||||||
| import 'package:firebase_messaging/firebase_messaging.dart'; | import 'package:firebase_messaging/firebase_messaging.dart'; | ||||||
| import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; |  | ||||||
| import 'package:flutter_secure_storage/flutter_secure_storage.dart'; | import 'package:flutter_secure_storage/flutter_secure_storage.dart'; | ||||||
| import 'package:device_info/device_info.dart'; | import 'package:device_info/device_info.dart'; | ||||||
| import 'package:flutter_local_notifications/flutter_local_notifications.dart'; | import 'package:flutter_local_notifications/flutter_local_notifications.dart'; | ||||||
| @@ -185,17 +184,7 @@ class HAClientApp extends StatelessWidget { | |||||||
|           mediaType: "${ModalRoute.of(context).settings.arguments != null ? (ModalRoute.of(context).settings.arguments as Map)['type'] ?? '' : ''}", |           mediaType: "${ModalRoute.of(context).settings.arguments != null ? (ModalRoute.of(context).settings.arguments as Map)['type'] ?? '' : ''}", | ||||||
|         ), |         ), | ||||||
|         "/log-view": (context) => LogViewPage(title: "Log"), |         "/log-view": (context) => LogViewPage(title: "Log"), | ||||||
|         "/whats-new": (context) => WhatsNewPage(), |         "/whats-new": (context) => WhatsNewPage() | ||||||
|         "/webview": (context) => WebviewScaffold( |  | ||||||
|           url: "${(ModalRoute.of(context).settings.arguments as Map)['url']}", |  | ||||||
|           appBar: new AppBar( |  | ||||||
|             leading: IconButton( |  | ||||||
|                 icon: Icon(Icons.arrow_back), |  | ||||||
|                 onPressed: () => Navigator.of(context).pop() |  | ||||||
|             ), |  | ||||||
|             title: new Text("${(ModalRoute.of(context).settings.arguments as Map)['title']}"), |  | ||||||
|           ), |  | ||||||
|         ) |  | ||||||
|       }, |       }, | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -369,21 +369,8 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse | |||||||
|           accountName: Text(HomeAssistant().userName), |           accountName: Text(HomeAssistant().userName), | ||||||
|           accountEmail: Text(ConnectionManager().displayHostname ?? "Not configured"), |           accountEmail: Text(ConnectionManager().displayHostname ?? "Not configured"), | ||||||
|           onDetailsPressed: () { |           onDetailsPressed: () { | ||||||
|             final flutterWebViewPlugin = new FlutterWebviewPlugin(); |             Launcher.launchURLInCustomTab( | ||||||
|             flutterWebViewPlugin.onStateChanged.listen((viewState) async { |               url: "${ConnectionManager().httpWebHost}/profile?external_auth=1" | ||||||
|               if (viewState.type == WebViewState.startLoad) { |  | ||||||
|                 Logger.d("[WebView] Injecting external auth JS"); |  | ||||||
|                 rootBundle.loadString('assets/js/externalAuth.js').then((js){ |  | ||||||
|                   flutterWebViewPlugin.evalJavascript(js.replaceFirst("[token]", ConnectionManager()._token)); |  | ||||||
|                 }); |  | ||||||
|               } |  | ||||||
|             }); |  | ||||||
|             Navigator.of(context).pushNamed( |  | ||||||
|                 "/webview", |  | ||||||
|                 arguments: { |  | ||||||
|                   "url": "${ConnectionManager().httpWebHost}/profile?external_auth=1", |  | ||||||
|                   "title": "Profile" |  | ||||||
|                 } |  | ||||||
|             ); |             ); | ||||||
|           }, |           }, | ||||||
|           currentAccountPicture: CircleAvatar( |           currentAccountPicture: CircleAvatar( | ||||||
| @@ -407,7 +394,7 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse | |||||||
|                     children: <Widget>[ |                     children: <Widget>[ | ||||||
|                       Text("${panel.title}"), |                       Text("${panel.title}"), | ||||||
|                       Container(width: 4.0,), |                       Container(width: 4.0,), | ||||||
|                       panel.isWebView ? Text("webview", style: TextStyle(fontSize: 8.0, color: Colors.black45),) : Container(width: 1.0,) |                       panel.isWebView ? Text("WEB", style: TextStyle(fontSize: 8.0, color: Colors.black45),) : Container(width: 1.0,) | ||||||
|                     ], |                     ], | ||||||
|                   ), |                   ), | ||||||
|                   onTap: () { |                   onTap: () { | ||||||
| @@ -888,15 +875,13 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse | |||||||
|         drawer: _buildAppDrawer(), |         drawer: _buildAppDrawer(), | ||||||
|         primary: false, |         primary: false, | ||||||
|         bottomNavigationBar: bottomBar, |         bottomNavigationBar: bottomBar, | ||||||
|         body: _buildScaffoldBody(false), |         body: _buildScaffoldBody(false) | ||||||
|       ); |       ); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @override |   @override | ||||||
|   void dispose() { |   void dispose() { | ||||||
|     final flutterWebviewPlugin = new FlutterWebviewPlugin(); |  | ||||||
|     flutterWebviewPlugin.dispose(); |  | ||||||
|     WidgetsBinding.instance.removeObserver(this); |     WidgetsBinding.instance.removeObserver(this); | ||||||
|     _viewsTabController?.dispose(); |     _viewsTabController?.dispose(); | ||||||
|     _stateSubscription?.cancel(); |     _stateSubscription?.cancel(); | ||||||
|   | |||||||
| @@ -28,7 +28,7 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> { | |||||||
|  |  | ||||||
|   stop() { |   stop() { | ||||||
|     eventBus.fire(ShowPopupDialogEvent( |     eventBus.fire(ShowPopupDialogEvent( | ||||||
|       title: "Are you sure you wanr to STOP Home Assistant?", |       title: "Are you sure you want to STOP Home Assistant?", | ||||||
|       body: "This will STOP your Home Assistant server. It means that your web interface as well as HA Client will not work untill you'll find a way to start your server using ssh or something.", |       body: "This will STOP your Home Assistant server. It means that your web interface as well as HA Client will not work untill you'll find a way to start your server using ssh or something.", | ||||||
|       positiveText: "Sure. Make it so", |       positiveText: "Sure. Make it so", | ||||||
|       negativeText: "What?? No!", |       negativeText: "What?? No!", | ||||||
| @@ -96,19 +96,7 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> { | |||||||
|             ), |             ), | ||||||
|           ), |           ), | ||||||
|         ), |         ), | ||||||
|         LinkToWebConfig(name: "Home Assistant Cloud", url: ConnectionManager().httpWebHost+"/config/cloud/account"), |         LinkToWebConfig(name: "Home AssistantConfiguration", url: ConnectionManager().httpWebHost+"/config"), | ||||||
|         Container(height: 8.0,), |  | ||||||
|         LinkToWebConfig(name: "Integrations", url: ConnectionManager().httpWebHost+"/config/integrations/dashboard"), |  | ||||||
|         LinkToWebConfig(name: "Users", url: ConnectionManager().httpWebHost+"/config/users/picker"), |  | ||||||
|         Container(height: 8.0,), |  | ||||||
|         LinkToWebConfig(name: "General", url: ConnectionManager().httpWebHost+"/config/core"), |  | ||||||
|         LinkToWebConfig(name: "Server Control", url: ConnectionManager().httpWebHost+"/config/server_control"), |  | ||||||
|         LinkToWebConfig(name: "Persons", url: ConnectionManager().httpWebHost+"/config/person"), |  | ||||||
|         LinkToWebConfig(name: "Entity Registry", url: ConnectionManager().httpWebHost+"/config/entity_registry"), |  | ||||||
|         LinkToWebConfig(name: "Area Registry", url: ConnectionManager().httpWebHost+"/config/area_registry"), |  | ||||||
|         LinkToWebConfig(name: "Automation", url: ConnectionManager().httpWebHost+"/config/automation"), |  | ||||||
|         LinkToWebConfig(name: "Script", url: ConnectionManager().httpWebHost+"/config/script"), |  | ||||||
|         LinkToWebConfig(name: "Customization", url: ConnectionManager().httpWebHost+"/config/customize"), |  | ||||||
|       ], |       ], | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -35,7 +35,7 @@ class Panel { | |||||||
|           ) |           ) | ||||||
|       ); |       ); | ||||||
|     } else { |     } else { | ||||||
|       Launcher.launchAuthenticatedWebView(context: context, url: "${ConnectionManager().httpWebHost}/$urlPath", title: "${this.title}"); |       Launcher.launchURLInCustomTab(url: "${ConnectionManager().httpWebHost}/$urlPath"); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ class LinkToWebConfig extends StatelessWidget { | |||||||
|                 style: new TextStyle(fontWeight: FontWeight.bold, fontSize: Sizes.largeFontSize)), |                 style: new TextStyle(fontWeight: FontWeight.bold, fontSize: Sizes.largeFontSize)), | ||||||
|             subtitle: Text("Tap to open web version"), |             subtitle: Text("Tap to open web version"), | ||||||
|             onTap: () { |             onTap: () { | ||||||
|               Launcher.launchAuthenticatedWebView(context: context, url: this.url, title: this.name); |               Launcher.launchURLInCustomTab(url: this.url); | ||||||
|             }, |             }, | ||||||
|           ) |           ) | ||||||
|         ], |         ], | ||||||
|   | |||||||
| @@ -10,47 +10,16 @@ class Launcher { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   static void launchAuthenticatedWebView({BuildContext context, String url, String title}) { |  | ||||||
|     if (url.contains("?")) { |  | ||||||
|       url += "&external_auth=1"; |  | ||||||
|     } else { |  | ||||||
|       url += "?external_auth=1"; |  | ||||||
|     } |  | ||||||
|     final flutterWebViewPlugin = new FlutterWebviewPlugin(); |  | ||||||
|     flutterWebViewPlugin.onStateChanged.listen((viewState) async { |  | ||||||
|       if (viewState.type == WebViewState.startLoad) { |  | ||||||
|         Logger.d("[WebView] Injecting external auth JS"); |  | ||||||
|         rootBundle.loadString('assets/js/externalAuth.js').then((js){ |  | ||||||
|           flutterWebViewPlugin.evalJavascript(js.replaceFirst("[token]", ConnectionManager()._token)); |  | ||||||
|         }); |  | ||||||
|       } |  | ||||||
|     }); |  | ||||||
|     Navigator.of(context).pushNamed( |  | ||||||
|         "/webview", |  | ||||||
|         arguments: { |  | ||||||
|           "url": "$url", |  | ||||||
|           "title": "${title ?? ''}" |  | ||||||
|         } |  | ||||||
|     ); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   static void launchURLInCustomTab({BuildContext context, String url, bool enableDefaultShare: true, bool showPageTitle: true}) async { |   static void launchURLInCustomTab({BuildContext context, String url, bool enableDefaultShare: true, bool showPageTitle: true}) async { | ||||||
|     try { |     try { | ||||||
|       await launch( |       await launch( | ||||||
|         "$url", |         "$url", | ||||||
|         option: new CustomTabsOption( |         option: new CustomTabsOption( | ||||||
|           toolbarColor: Theme.of(context).primaryColor, |           toolbarColor: context != null ? Theme.of(context).primaryColor : Colors.blue, | ||||||
|           enableDefaultShare: enableDefaultShare, |           enableDefaultShare: enableDefaultShare, | ||||||
|           enableUrlBarHiding: true, |           enableUrlBarHiding: true, | ||||||
|           showPageTitle: showPageTitle, |           showPageTitle: showPageTitle, | ||||||
|           animation: new CustomTabsAnimation.slideIn() |           animation: new CustomTabsAnimation.slideIn(), | ||||||
|           // or user defined animation. |  | ||||||
|           /*animation: new CustomTabsAnimation( |  | ||||||
|           startEnter: 'slide_up', |  | ||||||
|           startExit: 'android:anim/fade_out', |  | ||||||
|           endEnter: 'android:anim/fade_in', |  | ||||||
|           endExit: 'slide_down', |  | ||||||
|         )*/, |  | ||||||
|           extraCustomTabs: <String>[ |           extraCustomTabs: <String>[ | ||||||
|             // ref. https://play.google.com/store/apps/details?id=org.mozilla.firefox |             // ref. https://play.google.com/store/apps/details?id=org.mozilla.firefox | ||||||
|             'org.mozilla.firefox', |             'org.mozilla.firefox', | ||||||
|   | |||||||
| @@ -19,11 +19,9 @@ dependencies: | |||||||
|   charts_flutter: ^0.8.1 |   charts_flutter: ^0.8.1 | ||||||
|   flutter_markdown: any |   flutter_markdown: any | ||||||
|   in_app_purchase: ^0.2.1+4 |   in_app_purchase: ^0.2.1+4 | ||||||
| #  flutter_svg: ^0.10.3 |  | ||||||
|   flutter_custom_tabs: ^0.6.0 |   flutter_custom_tabs: ^0.6.0 | ||||||
|   firebase_messaging: ^5.1.6 |   firebase_messaging: ^5.1.6 | ||||||
|   uni_links: ^0.2.0 |   uni_links: ^0.2.0 | ||||||
|   flutter_webview_plugin: ^0.3.8 |  | ||||||
|   flutter_secure_storage: ^3.3.1+1 |   flutter_secure_storage: ^3.3.1+1 | ||||||
|   device_info: ^0.4.0+3 |   device_info: ^0.4.0+3 | ||||||
|   flutter_local_notifications: ^0.8.4 |   flutter_local_notifications: ^0.8.4 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user