Resolve #382 VIew camera in chrome custom tab
This commit is contained in:
parent
caabf25260
commit
3c0ca5d16d
@ -17,10 +17,15 @@ class _CameraStreamViewState extends State<CameraStreamView> {
|
||||
|
||||
CameraEntity _entity;
|
||||
bool started = false;
|
||||
String streamUrl = "";
|
||||
|
||||
launchStream() {
|
||||
HAUtils.launchURLInCustomTab(context, '${Connection().httpWebHost}/api/camera_proxy_stream/${_entity
|
||||
.entityId}?token=${_entity.attributes['access_token']}');
|
||||
HAUtils.launchURLInCustomTab(
|
||||
context: context,
|
||||
url: streamUrl,
|
||||
enableDefaultShare: false,
|
||||
showPageTitle: false
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -32,13 +37,15 @@ class _CameraStreamViewState extends State<CameraStreamView> {
|
||||
.entity;
|
||||
started = true;
|
||||
}
|
||||
streamUrl = '${Connection().httpWebHost}/api/camera_proxy_stream/${_entity
|
||||
.entityId}?token=${_entity.attributes['access_token']}';
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: FlatButton(
|
||||
child: Text("View camera stream"),
|
||||
onPressed: () => launchStream(),
|
||||
child: IconButton(
|
||||
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:monitor-screenshot"), color: Colors.amber),
|
||||
iconSize: 50.0
|
||||
)
|
||||
)
|
||||
],
|
||||
|
@ -153,7 +153,7 @@ class HAClientApp extends StatelessWidget {
|
||||
appBar: new AppBar(
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.help),
|
||||
onPressed: () => HAUtils.launchURLInCustomTab(context, "http://ha-client.homemade.systems/docs#authentication")
|
||||
onPressed: () => HAUtils.launchURLInCustomTab(context: context, url: "http://ha-client.homemade.systems/docs#authentication")
|
||||
),
|
||||
title: new Text("Login to your Home Assistant"),
|
||||
),
|
||||
@ -548,7 +548,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
HAUtils.launchURLInCustomTab(context, "http://ha-client.homemade.systems/terms_and_conditions");
|
||||
HAUtils.launchURLInCustomTab(context: context, url: "http://ha-client.homemade.systems/terms_and_conditions");
|
||||
},
|
||||
child: Text(
|
||||
"Terms and Conditions",
|
||||
@ -564,7 +564,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
HAUtils.launchURLInCustomTab(context, "http://ha-client.homemade.systems/privacy_policy");
|
||||
HAUtils.launchURLInCustomTab(context: context, url: "http://ha-client.homemade.systems/privacy_policy");
|
||||
},
|
||||
child: Text(
|
||||
"Privacy Policy",
|
||||
@ -649,7 +649,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
||||
actions.add(FlatButton(
|
||||
child: Text("${action.title}", style: textStyle),
|
||||
onPressed: () {
|
||||
HAUtils.launchURLInCustomTab(context, "${action.url}");
|
||||
HAUtils.launchURLInCustomTab(context: context, url: "${action.url}");
|
||||
},
|
||||
));
|
||||
break;
|
||||
|
@ -28,7 +28,7 @@ class Panel {
|
||||
void handleOpen(BuildContext context) {
|
||||
if (type == "iframe") {
|
||||
Logger.d("Launching custom tab with ${config["url"]}");
|
||||
HAUtils.launchURLInCustomTab(context, config["url"]);
|
||||
HAUtils.launchURLInCustomTab(context: context, url: config["url"]);
|
||||
} else if (type == "config") {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
@ -38,7 +38,7 @@ class Panel {
|
||||
} else {
|
||||
String url = "${Connection().httpWebHost}/$urlPath";
|
||||
Logger.d("Launching custom tab with $url");
|
||||
HAUtils.launchURLInCustomTab(context, url);
|
||||
HAUtils.launchURLInCustomTab(context: context, url: url);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> {
|
||||
FlatButton(
|
||||
child: Text('Open web version', style: TextStyle(color: Colors.blue)),
|
||||
onPressed: () {
|
||||
HAUtils.launchURLInCustomTab(context, Connection().httpWebHost+"/config/cloud/account");
|
||||
HAUtils.launchURLInCustomTab(context: context, url: Connection().httpWebHost+"/config/cloud/account");
|
||||
},
|
||||
)
|
||||
],
|
||||
@ -52,7 +52,7 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> {
|
||||
FlatButton(
|
||||
child: Text('Open web version', style: TextStyle(color: Colors.blue)),
|
||||
onPressed: () {
|
||||
HAUtils.launchURLInCustomTab(context, Connection().httpWebHost+"/config/integrations/dashboard");
|
||||
HAUtils.launchURLInCustomTab(context: context, url: Connection().httpWebHost+"/config/integrations/dashboard");
|
||||
},
|
||||
)
|
||||
],
|
||||
@ -70,7 +70,7 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> {
|
||||
FlatButton(
|
||||
child: Text('Open web version', style: TextStyle(color: Colors.blue)),
|
||||
onPressed: () {
|
||||
HAUtils.launchURLInCustomTab(context, Connection().httpWebHost+"/config/users/picker");
|
||||
HAUtils.launchURLInCustomTab(context: context, url: Connection().httpWebHost+"/config/users/picker");
|
||||
},
|
||||
)
|
||||
],
|
||||
@ -88,7 +88,7 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> {
|
||||
FlatButton(
|
||||
child: Text('Open web version', style: TextStyle(color: Colors.blue)),
|
||||
onPressed: () {
|
||||
HAUtils.launchURLInCustomTab(context, Connection().httpWebHost+"/config/core");
|
||||
HAUtils.launchURLInCustomTab(context: context, url: Connection().httpWebHost+"/config/core");
|
||||
},
|
||||
),
|
||||
Container(height: Sizes.rowPadding,),
|
||||
@ -124,7 +124,7 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> {
|
||||
FlatButton(
|
||||
child: Text('Open web version', style: TextStyle(color: Colors.blue)),
|
||||
onPressed: () {
|
||||
HAUtils.launchURLInCustomTab(context, Connection().httpWebHost+"/config/person");
|
||||
HAUtils.launchURLInCustomTab(context: context, url: Connection().httpWebHost+"/config/person");
|
||||
},
|
||||
)
|
||||
],
|
||||
@ -142,7 +142,7 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> {
|
||||
FlatButton(
|
||||
child: Text('Open web version', style: TextStyle(color: Colors.blue)),
|
||||
onPressed: () {
|
||||
HAUtils.launchURLInCustomTab(context, Connection().httpWebHost+"/config/entity_registry");
|
||||
HAUtils.launchURLInCustomTab(context: context, url: Connection().httpWebHost+"/config/entity_registry");
|
||||
},
|
||||
)
|
||||
],
|
||||
@ -160,7 +160,7 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> {
|
||||
FlatButton(
|
||||
child: Text('Open web version', style: TextStyle(color: Colors.blue)),
|
||||
onPressed: () {
|
||||
HAUtils.launchURLInCustomTab(context, Connection().httpWebHost+"/config/area_registry");
|
||||
HAUtils.launchURLInCustomTab(context: context, url: Connection().httpWebHost+"/config/area_registry");
|
||||
},
|
||||
)
|
||||
],
|
||||
@ -178,7 +178,7 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> {
|
||||
FlatButton(
|
||||
child: Text('Open web version', style: TextStyle(color: Colors.blue)),
|
||||
onPressed: () {
|
||||
HAUtils.launchURLInCustomTab(context, Connection().httpWebHost+"/config/automation");
|
||||
HAUtils.launchURLInCustomTab(context: context, url: Connection().httpWebHost+"/config/automation");
|
||||
},
|
||||
)
|
||||
],
|
||||
@ -196,7 +196,7 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> {
|
||||
FlatButton(
|
||||
child: Text('Open web version', style: TextStyle(color: Colors.blue)),
|
||||
onPressed: () {
|
||||
HAUtils.launchURLInCustomTab(context, Connection().httpWebHost+"/config/script");
|
||||
HAUtils.launchURLInCustomTab(context: context, url: Connection().httpWebHost+"/config/script");
|
||||
},
|
||||
)
|
||||
],
|
||||
@ -214,7 +214,7 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> {
|
||||
FlatButton(
|
||||
child: Text('Open web version', style: TextStyle(color: Colors.blue)),
|
||||
onPressed: () {
|
||||
HAUtils.launchURLInCustomTab(context, Connection().httpWebHost+"/config/customize");
|
||||
HAUtils.launchURLInCustomTab(context: context, url: Connection().httpWebHost+"/config/customize");
|
||||
},
|
||||
)
|
||||
],
|
||||
|
@ -98,15 +98,15 @@ class HAUtils {
|
||||
}
|
||||
}
|
||||
|
||||
static void launchURLInCustomTab(BuildContext context, String url) async {
|
||||
static void launchURLInCustomTab({BuildContext context, String url, bool enableDefaultShare: true, bool showPageTitle: true}) async {
|
||||
try {
|
||||
await launch(
|
||||
"$url",
|
||||
option: new CustomTabsOption(
|
||||
toolbarColor: Theme.of(context).primaryColor,
|
||||
enableDefaultShare: true,
|
||||
enableDefaultShare: enableDefaultShare,
|
||||
enableUrlBarHiding: true,
|
||||
showPageTitle: true,
|
||||
showPageTitle: showPageTitle,
|
||||
animation: new CustomTabsAnimation.slideIn()
|
||||
// or user defined animation.
|
||||
/*animation: new CustomTabsAnimation(
|
||||
|
Reference in New Issue
Block a user