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(
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'),
)

View File

@ -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;
}

View File

@ -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);
}
}