Fix camera stream view navigation issue

This commit is contained in:
Yegor Vialov 2020-05-01 18:50:50 +00:00
parent 915e8045a3
commit 1c461d2449
10 changed files with 15 additions and 44 deletions

View File

@ -17,6 +17,7 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="HA Client"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"

View File

@ -33,7 +33,7 @@ class AlarmPanelCard extends StatelessWidget {
alignment: Alignment.centerRight,
icon: Icon(MaterialDesignIcons.getIconDataFromIconName(
"mdi:dots-vertical")),
onPressed: () => eventBus.fire(new ShowEntityPageEvent(entity: card.entity.entity))
onPressed: () => eventBus.fire(new ShowEntityPageEvent(entityId: card.entity.entity.entityId))
)
)
]

View File

@ -143,6 +143,6 @@ class BadgeWidget extends StatelessWidget {
],
),
onTap: () =>
eventBus.fire(new ShowEntityPageEvent(entity: entityModel.entityWrapper.entity)));
eventBus.fire(new ShowEntityPageEvent(entityId: entityModel.entityWrapper.entity.entityId)));
}
}

View File

@ -138,8 +138,7 @@ class _CameraStreamViewState extends State<CameraStreamView> {
iconSize: 40,
color: Theme.of(context).accentColor,
onPressed: _isLoaded ? () {
eventBus.fire(ShowEntityPageEvent());
Navigator.of(context).push(
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (conext) => FullScreenPage(
child: EntityModel(
@ -155,7 +154,7 @@ class _CameraStreamViewState extends State<CameraStreamView> {
fullscreenDialog: true
)
).then((_){
eventBus.fire(ShowEntityPageEvent(entity: _entity));
eventBus.fire(ShowEntityPageEvent(entityId: _entity.entityId));
});
} : null,
)

View File

@ -2,10 +2,9 @@ part of '../main.dart';
class EntityPageLayout extends StatelessWidget {
final bool showClose;
final Entity entity;
EntityPageLayout({Key key, this.showClose: false, this.entity}) : super(key: key);
EntityPageLayout({Key key, this.entity}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -14,34 +13,6 @@ class EntityPageLayout extends StatelessWidget {
child: ListView(
padding: EdgeInsets.all(0),
children: <Widget>[
showClose ?
Container(
color: Theme.of(context).primaryColor,
height: 40,
child: Row(
children: <Widget>[
Expanded(
child: Padding(
padding: EdgeInsets.only(left: 8),
child: Text(
entity.displayName,
style: Theme.of(context).primaryTextTheme.headline
),
),
),
IconButton(
padding: EdgeInsets.all(0),
icon: Icon(Icons.close),
color: Theme.of(context).primaryTextTheme.headline.color,
iconSize: 36.0,
onPressed: () {
eventBus.fire(ShowEntityPageEvent());
},
)
],
),
) :
Container(height: 0, width: 0,),
Padding(
padding: EdgeInsets.only(top: Sizes.rowPadding, left: Sizes.leftWidgetPadding),
child: DefaultEntityContainer(state: entity._buildStatePartForPage(context)),

View File

@ -54,7 +54,7 @@ class EntityWrapper {
case EntityUIAction.moreInfo: {
eventBus.fire(
new ShowEntityPageEvent(entity: entity));
new ShowEntityPageEvent(entityId: entity.entityId));
break;
}
@ -94,7 +94,7 @@ class EntityWrapper {
case EntityUIAction.moreInfo: {
eventBus.fire(
new ShowEntityPageEvent(entity: entity));
new ShowEntityPageEvent(entityId: entity.entityId));
break;
}
@ -134,7 +134,7 @@ class EntityWrapper {
case EntityUIAction.moreInfo: {
eventBus.fire(
new ShowEntityPageEvent(entity: entity));
new ShowEntityPageEvent(entityId: entity.entityId));
break;
}

View File

@ -228,7 +228,7 @@ class MediaPlayerPlaybackControls extends StatelessWidget {
IconButton(
icon: Icon(MaterialDesignIcons.getIconDataFromIconName(
"mdi:dots-vertical")),
onPressed: () => eventBus.fire(new ShowEntityPageEvent(entity: entity))
onPressed: () => eventBus.fire(new ShowEntityPageEvent(entityId: entity.entityId))
)
);
} else if (entity.supportStop && entity.state != EntityState.off && entity.state != EntityState.unavailable) {

View File

@ -211,7 +211,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
if (_showEntityPageSubscription == null) {
_showEntityPageSubscription =
eventBus.on<ShowEntityPageEvent>().listen((event) {
_showEntityPage(event.entity?.entityId);
_showEntityPage(event.entityId);
});
}

View File

@ -105,7 +105,7 @@ class _PlayMediaPageState extends State<PlayMediaPage> {
);
HomeAssistant().sendFromPlayerId = null;
}
eventBus.fire(ShowEntityPageEvent(entity: entity));
eventBus.fire(ShowEntityPageEvent(entityId: entity.entityId));
}
}

View File

@ -77,9 +77,9 @@ class ShowPopupMessageEvent {
}
class ShowEntityPageEvent {
final Entity entity;
final String entityId;
ShowEntityPageEvent({this.entity});
ShowEntityPageEvent({@required this.entityId});
}
class ShowPageEvent {