Add Lovelase card widget
This commit is contained in:
parent
aee99e3925
commit
8dbfb91234
@ -167,7 +167,7 @@ class CardWidget extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
return Card(
|
return LovelaceCard(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.only(right: Sizes.rightWidgetPadding, left: Sizes.leftWidgetPadding),
|
padding: EdgeInsets.only(right: Sizes.rightWidgetPadding, left: Sizes.leftWidgetPadding),
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -186,7 +186,7 @@ class CardWidget extends StatelessWidget {
|
|||||||
List<Widget> body = [];
|
List<Widget> body = [];
|
||||||
body.add(CardHeader(name: card.name));
|
body.add(CardHeader(name: card.name));
|
||||||
body.add(MarkdownBody(data: card.content));
|
body.add(MarkdownBody(data: card.content));
|
||||||
return Card(
|
return LovelaceCard(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.fromLTRB(Sizes.leftWidgetPadding, Sizes.rowPadding, Sizes.rightWidgetPadding, Sizes.rowPadding),
|
padding: EdgeInsets.fromLTRB(Sizes.leftWidgetPadding, Sizes.rowPadding, Sizes.rightWidgetPadding, Sizes.rowPadding),
|
||||||
child: new Column(mainAxisSize: MainAxisSize.min, children: body),
|
child: new Column(mainAxisSize: MainAxisSize.min, children: body),
|
||||||
@ -226,7 +226,7 @@ class CardWidget extends StatelessWidget {
|
|||||||
states: card.states,
|
states: card.states,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return Card(
|
return LovelaceCard(
|
||||||
child: EntityModel(
|
child: EntityModel(
|
||||||
entityWrapper: card.linkedEntityWrapper,
|
entityWrapper: card.linkedEntityWrapper,
|
||||||
handleTap: null,
|
handleTap: null,
|
||||||
@ -278,7 +278,7 @@ class CardWidget extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Card(
|
return LovelaceCard(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@ -295,7 +295,7 @@ class CardWidget extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildMediaControlsCard(BuildContext context) {
|
Widget _buildMediaControlsCard(BuildContext context) {
|
||||||
return Card(
|
return LovelaceCard(
|
||||||
child: EntityModel(
|
child: EntityModel(
|
||||||
entityWrapper: card.linkedEntityWrapper,
|
entityWrapper: card.linkedEntityWrapper,
|
||||||
handleTap: null,
|
handleTap: null,
|
||||||
@ -307,7 +307,7 @@ class CardWidget extends StatelessWidget {
|
|||||||
Widget _buildEntityButtonCard(BuildContext context) {
|
Widget _buildEntityButtonCard(BuildContext context) {
|
||||||
card.linkedEntityWrapper.overrideName = card.name?.toUpperCase() ??
|
card.linkedEntityWrapper.overrideName = card.name?.toUpperCase() ??
|
||||||
card.linkedEntityWrapper.displayName.toUpperCase();
|
card.linkedEntityWrapper.displayName.toUpperCase();
|
||||||
return Card(
|
return LovelaceCard(
|
||||||
child: EntityModel(
|
child: EntityModel(
|
||||||
entityWrapper: card.linkedEntityWrapper,
|
entityWrapper: card.linkedEntityWrapper,
|
||||||
child: EntityButtonCardBody(
|
child: EntityButtonCardBody(
|
||||||
@ -324,7 +324,7 @@ class CardWidget extends StatelessWidget {
|
|||||||
card.linkedEntityWrapper.displayName;
|
card.linkedEntityWrapper.displayName;
|
||||||
card.linkedEntityWrapper.unitOfMeasurementOverride = card.unit ??
|
card.linkedEntityWrapper.unitOfMeasurementOverride = card.unit ??
|
||||||
card.linkedEntityWrapper.unitOfMeasurement;
|
card.linkedEntityWrapper.unitOfMeasurement;
|
||||||
return Card(
|
return LovelaceCard(
|
||||||
child: EntityModel(
|
child: EntityModel(
|
||||||
entityWrapper: card.linkedEntityWrapper,
|
entityWrapper: card.linkedEntityWrapper,
|
||||||
child: GaugeCardBody(
|
child: GaugeCardBody(
|
||||||
@ -341,7 +341,7 @@ class CardWidget extends StatelessWidget {
|
|||||||
Widget _buildLightCard(BuildContext context) {
|
Widget _buildLightCard(BuildContext context) {
|
||||||
card.linkedEntityWrapper.overrideName = card.name ??
|
card.linkedEntityWrapper.overrideName = card.name ??
|
||||||
card.linkedEntityWrapper.displayName;
|
card.linkedEntityWrapper.displayName;
|
||||||
return Card(
|
return LovelaceCard(
|
||||||
child: EntityModel(
|
child: EntityModel(
|
||||||
entityWrapper: card.linkedEntityWrapper,
|
entityWrapper: card.linkedEntityWrapper,
|
||||||
child: LightCardBody(
|
child: LightCardBody(
|
||||||
@ -382,7 +382,7 @@ class CardWidget extends StatelessWidget {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
body.addAll(result);
|
body.addAll(result);
|
||||||
return Card(
|
return LovelaceCard(
|
||||||
child: new Column(
|
child: new Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
17
lib/cards/widgets/lovelace_card.dart
Normal file
17
lib/cards/widgets/lovelace_card.dart
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
part of '../../main.dart';
|
||||||
|
|
||||||
|
class LovelaceCard extends StatelessWidget {
|
||||||
|
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
const LovelaceCard({Key key, this.child}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Card(
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -138,6 +138,7 @@ part 'types/ha_error.dart';
|
|||||||
part 'types/event_bus_events.dart';
|
part 'types/event_bus_events.dart';
|
||||||
part 'cards/widgets/gauge_card_body.dart';
|
part 'cards/widgets/gauge_card_body.dart';
|
||||||
part 'cards/widgets/light_card_body.dart';
|
part 'cards/widgets/light_card_body.dart';
|
||||||
|
part 'cards/widgets/lovelace_card.dart';
|
||||||
part 'pages/play_media.page.dart';
|
part 'pages/play_media.page.dart';
|
||||||
part 'entities/entity_page_layout.widget.dart';
|
part 'entities/entity_page_layout.widget.dart';
|
||||||
part 'entities/media_player/widgets/media_player_seek_bar.widget.dart';
|
part 'entities/media_player/widgets/media_player_seek_bar.widget.dart';
|
||||||
|
Reference in New Issue
Block a user