From d6b1fbec24c36916100e677f7ff5161ce867296e Mon Sep 17 00:00:00 2001 From: Yegor Vialov Date: Fri, 1 May 2020 15:48:54 +0000 Subject: [PATCH] Open local navigate actions in browser --- lib/cards/error_card.dart | 2 +- lib/entities/entity_wrapper.class.dart | 12 ++++++------ lib/utils/launcher.dart | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/cards/error_card.dart b/lib/cards/error_card.dart index 523f933..58d3a12 100644 --- a/lib/cards/error_card.dart +++ b/lib/cards/error_card.dart @@ -26,7 +26,7 @@ class ErrorCard extends StatelessWidget { ), RaisedButton( onPressed: () { - Launcher.launchURL("https://github.com/estevez-dev/ha_client/issues/new?assignees=&labels=&template=bug_report.md&title="); + Launcher.launchURLInBrowser("https://github.com/estevez-dev/ha_client/issues/new?assignees=&labels=&template=bug_report.md&title="); }, child: Text('Report issue'), ) diff --git a/lib/entities/entity_wrapper.class.dart b/lib/entities/entity_wrapper.class.dart index 2750082..3d57d83 100644 --- a/lib/entities/entity_wrapper.class.dart +++ b/lib/entities/entity_wrapper.class.dart @@ -61,9 +61,9 @@ class EntityWrapper { case EntityUIAction.navigate: { if (uiAction.tapService != null && uiAction.tapService.startsWith("/")) { //TODO handle local urls - Logger.w("Local urls is not supported yet"); + Launcher.launchURLInBrowser('${ConnectionManager().httpWebHost}${uiAction.tapService}'); } else { - Launcher.launchURL(uiAction.tapService); + Launcher.launchURLInBrowser(uiAction.tapService); } break; } @@ -101,9 +101,9 @@ class EntityWrapper { case EntityUIAction.navigate: { if (uiAction.holdService != null && uiAction.holdService.startsWith("/")) { //TODO handle local urls - Logger.w("Local urls is not supported yet"); + Launcher.launchURLInBrowser('${ConnectionManager().httpWebHost}${uiAction.holdService}'); } else { - Launcher.launchURL(uiAction.holdService); + Launcher.launchURLInBrowser(uiAction.holdService); } break; } @@ -141,9 +141,9 @@ class EntityWrapper { case EntityUIAction.navigate: { if (uiAction.doubleTapService != null && uiAction.doubleTapService.startsWith("/")) { //TODO handle local urls - Logger.w("Local urls is not supported yet"); + Launcher.launchURLInBrowser('${ConnectionManager().httpWebHost}${uiAction.doubleTapService}'); } else { - Launcher.launchURL(uiAction.doubleTapService); + Launcher.launchURLInBrowser(uiAction.doubleTapService); } break; } diff --git a/lib/utils/launcher.dart b/lib/utils/launcher.dart index 4f229cc..4930904 100644 --- a/lib/utils/launcher.dart +++ b/lib/utils/launcher.dart @@ -2,7 +2,7 @@ part of '../main.dart'; class Launcher { - static void launchURL(String url) async { + static void launchURLInBrowser(String url) async { if (await urlLauncher.canLaunch(url)) { await urlLauncher.launch(url); } else { @@ -30,7 +30,7 @@ class Launcher { } catch (e) { Logger.w("Can't open custom tab: ${e.toString()}"); Logger.w("Launching in default browser"); - Launcher.launchURL(url); + Launcher.launchURLInBrowser(url); } }