Open local navigate actions in browser

This commit is contained in:
Yegor Vialov 2020-05-01 15:48:54 +00:00
parent cacdd0d304
commit d6b1fbec24
3 changed files with 9 additions and 9 deletions

View File

@ -26,7 +26,7 @@ class ErrorCard extends StatelessWidget {
), ),
RaisedButton( RaisedButton(
onPressed: () { 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'), child: Text('Report issue'),
) )

View File

@ -61,9 +61,9 @@ class EntityWrapper {
case EntityUIAction.navigate: { case EntityUIAction.navigate: {
if (uiAction.tapService != null && uiAction.tapService.startsWith("/")) { if (uiAction.tapService != null && uiAction.tapService.startsWith("/")) {
//TODO handle local urls //TODO handle local urls
Logger.w("Local urls is not supported yet"); Launcher.launchURLInBrowser('${ConnectionManager().httpWebHost}${uiAction.tapService}');
} else { } else {
Launcher.launchURL(uiAction.tapService); Launcher.launchURLInBrowser(uiAction.tapService);
} }
break; break;
} }
@ -101,9 +101,9 @@ class EntityWrapper {
case EntityUIAction.navigate: { case EntityUIAction.navigate: {
if (uiAction.holdService != null && uiAction.holdService.startsWith("/")) { if (uiAction.holdService != null && uiAction.holdService.startsWith("/")) {
//TODO handle local urls //TODO handle local urls
Logger.w("Local urls is not supported yet"); Launcher.launchURLInBrowser('${ConnectionManager().httpWebHost}${uiAction.holdService}');
} else { } else {
Launcher.launchURL(uiAction.holdService); Launcher.launchURLInBrowser(uiAction.holdService);
} }
break; break;
} }
@ -141,9 +141,9 @@ class EntityWrapper {
case EntityUIAction.navigate: { case EntityUIAction.navigate: {
if (uiAction.doubleTapService != null && uiAction.doubleTapService.startsWith("/")) { if (uiAction.doubleTapService != null && uiAction.doubleTapService.startsWith("/")) {
//TODO handle local urls //TODO handle local urls
Logger.w("Local urls is not supported yet"); Launcher.launchURLInBrowser('${ConnectionManager().httpWebHost}${uiAction.doubleTapService}');
} else { } else {
Launcher.launchURL(uiAction.doubleTapService); Launcher.launchURLInBrowser(uiAction.doubleTapService);
} }
break; break;
} }

View File

@ -2,7 +2,7 @@ part of '../main.dart';
class Launcher { class Launcher {
static void launchURL(String url) async { static void launchURLInBrowser(String url) async {
if (await urlLauncher.canLaunch(url)) { if (await urlLauncher.canLaunch(url)) {
await urlLauncher.launch(url); await urlLauncher.launch(url);
} else { } else {
@ -30,7 +30,7 @@ class Launcher {
} catch (e) { } catch (e) {
Logger.w("Can't open custom tab: ${e.toString()}"); Logger.w("Can't open custom tab: ${e.toString()}");
Logger.w("Launching in default browser"); Logger.w("Launching in default browser");
Launcher.launchURL(url); Launcher.launchURLInBrowser(url);
} }
} }