Resolves #227
This commit is contained in:
parent
215871ce9e
commit
73398378c4
@ -10,7 +10,19 @@ class DefaultEntityContainer extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Row(
|
final EntityModel entityModel = EntityModel.of(context);
|
||||||
|
return InkWell(
|
||||||
|
onLongPress: () {
|
||||||
|
if (entityModel.handleTap) {
|
||||||
|
entityModel.entityWrapper.handleHold();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onTap: () {
|
||||||
|
if (entityModel.handleTap) {
|
||||||
|
entityModel.entityWrapper.handleTap();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
EntityIcon(),
|
EntityIcon(),
|
||||||
@ -22,6 +34,7 @@ class DefaultEntityContainer extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
state
|
state
|
||||||
],
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,27 +10,14 @@ class EntityIcon extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final entityModel = EntityModel.of(context);
|
final EntityWrapper entityWrapper = EntityModel.of(context).entityWrapper;
|
||||||
return InkWell(
|
return Padding(
|
||||||
child: Padding(
|
|
||||||
padding: padding,
|
padding: padding,
|
||||||
child: MaterialDesignIcons.createIconWidgetFromEntityData(
|
child: MaterialDesignIcons.createIconWidgetFromEntityData(
|
||||||
entityModel.entityWrapper,
|
entityWrapper,
|
||||||
iconSize,
|
iconSize,
|
||||||
EntityColor.stateColor(entityModel.entityWrapper.entity.state)
|
EntityColor.stateColor(entityWrapper.entity.state)
|
||||||
),
|
),
|
||||||
),
|
|
||||||
onLongPress: () {
|
|
||||||
if (entityModel.handleTap) {
|
|
||||||
entityModel.entityWrapper.handleHold();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onTap: () {
|
|
||||||
if (entityModel.handleTap) {
|
|
||||||
entityModel.entityWrapper.handleTap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,28 +12,16 @@ class EntityName extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final entityModel = EntityModel.of(context);
|
final EntityWrapper entityWrapper = EntityModel.of(context).entityWrapper;
|
||||||
return InkWell(
|
return Padding(
|
||||||
child: Padding(
|
|
||||||
padding: padding,
|
padding: padding,
|
||||||
child: Text(
|
child: Text(
|
||||||
"${entityModel.entityWrapper.displayName}",
|
"${entityWrapper.displayName}",
|
||||||
overflow: textOverflow,
|
overflow: textOverflow,
|
||||||
softWrap: wordsWrap,
|
softWrap: wordsWrap,
|
||||||
style: TextStyle(fontSize: fontSize),
|
style: TextStyle(fontSize: fontSize),
|
||||||
textAlign: textAlign,
|
textAlign: textAlign,
|
||||||
),
|
),
|
||||||
),
|
|
||||||
onLongPress: () {
|
|
||||||
if (entityModel.handleTap) {
|
|
||||||
entityModel.entityWrapper.handleHold();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onTap: () {
|
|
||||||
if (entityModel.handleTap) {
|
|
||||||
entityModel.entityWrapper.handleTap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,6 +11,7 @@ class GlanceEntityContainer extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final EntityWrapper entityWrapper = EntityModel.of(context).entityWrapper;
|
||||||
List<Widget> result = [];
|
List<Widget> result = [];
|
||||||
if (showName) {
|
if (showName) {
|
||||||
result.add(EntityName(
|
result.add(EntityName(
|
||||||
@ -21,10 +22,12 @@ class GlanceEntityContainer extends StatelessWidget {
|
|||||||
fontSize: Sizes.smallFontSize,
|
fontSize: Sizes.smallFontSize,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
result.add(EntityIcon(
|
result.add(
|
||||||
|
EntityIcon(
|
||||||
padding: EdgeInsets.all(0.0),
|
padding: EdgeInsets.all(0.0),
|
||||||
iconSize: Sizes.iconSize,
|
iconSize: Sizes.iconSize,
|
||||||
));
|
)
|
||||||
|
);
|
||||||
if (showState) {
|
if (showState) {
|
||||||
result.add(SimpleEntityState(
|
result.add(SimpleEntityState(
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
@ -32,11 +35,20 @@ class GlanceEntityContainer extends StatelessWidget {
|
|||||||
padding: EdgeInsets.only(top: Sizes.rowPadding),
|
padding: EdgeInsets.only(top: Sizes.rowPadding),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return Column(
|
return Center(
|
||||||
|
child: InkWell(
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(minWidth: Sizes.iconSize*2),
|
||||||
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
//mainAxisAlignment: MainAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
//crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: result,
|
children: result,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () => entityWrapper.handleTap(),
|
||||||
|
onLongPress: () => entityWrapper.handleHold(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,7 +19,6 @@ class ClimateStateWidget extends StatelessWidget {
|
|||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.fromLTRB(
|
padding: EdgeInsets.fromLTRB(
|
||||||
0.0, 0.0, Sizes.rightWidgetPadding, 0.0),
|
0.0, 0.0, Sizes.rightWidgetPadding, 0.0),
|
||||||
child: GestureDetector(
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
@ -48,10 +47,6 @@ class ClimateStateWidget extends StatelessWidget {
|
|||||||
) :
|
) :
|
||||||
Container(height: 0.0,)
|
Container(height: 0.0,)
|
||||||
],
|
],
|
||||||
),
|
|
||||||
onTap: () => entityModel.handleTap
|
|
||||||
? eventBus.fire(new ShowEntityPageEvent(entity))
|
|
||||||
: null,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,7 +13,6 @@ class SimpleEntityState extends StatelessWidget {
|
|||||||
final entityModel = EntityModel.of(context);
|
final entityModel = EntityModel.of(context);
|
||||||
Widget result = Padding(
|
Widget result = Padding(
|
||||||
padding: padding,
|
padding: padding,
|
||||||
child: InkWell(
|
|
||||||
child: Text(
|
child: Text(
|
||||||
"${entityModel.entityWrapper.entity.state} ${entityModel.entityWrapper.entity.unitOfMeasurement}",
|
"${entityModel.entityWrapper.entity.state} ${entityModel.entityWrapper.entity.unitOfMeasurement}",
|
||||||
textAlign: textAlign,
|
textAlign: textAlign,
|
||||||
@ -22,17 +21,7 @@ class SimpleEntityState extends StatelessWidget {
|
|||||||
softWrap: true,
|
softWrap: true,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: Sizes.stateFontSize,
|
fontSize: Sizes.stateFontSize,
|
||||||
)),
|
)
|
||||||
onLongPress: () {
|
|
||||||
if (entityModel.handleTap) {
|
|
||||||
entityModel.entityWrapper.handleHold();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onTap: () {
|
|
||||||
if (entityModel.handleTap) {
|
|
||||||
entityModel.entityWrapper.handleTap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if (expanded) {
|
if (expanded) {
|
||||||
|
@ -24,14 +24,13 @@ class GlanceCardWidget extends StatelessWidget {
|
|||||||
|
|
||||||
Widget _buildRows(BuildContext context) {
|
Widget _buildRows(BuildContext context) {
|
||||||
List<Widget> result = [];
|
List<Widget> result = [];
|
||||||
double width = MediaQuery.of(context).size.width - Sizes.leftWidgetPadding - (2*Sizes.rightWidgetPadding);
|
|
||||||
List<EntityWrapper> toShow = card.entities.where((entity) {return !entity.entity.isHidden;}).toList();
|
List<EntityWrapper> toShow = card.entities.where((entity) {return !entity.entity.isHidden;}).toList();
|
||||||
int columnsCount = toShow.length >= card.columnsCount ? card.columnsCount : toShow.length;
|
int columnsCount = toShow.length >= card.columnsCount ? card.columnsCount : toShow.length;
|
||||||
card.entities.forEach((EntityWrapper entity) {
|
|
||||||
if (!entity.entity.isHidden) {
|
toShow.forEach((EntityWrapper entity) {
|
||||||
result.add(
|
result.add(
|
||||||
SizedBox(
|
FractionallySizedBox(
|
||||||
width: width / columnsCount,
|
widthFactor: 1/columnsCount,
|
||||||
child: EntityModel(
|
child: EntityModel(
|
||||||
entityWrapper: entity,
|
entityWrapper: entity,
|
||||||
child: entity.entity.buildGlanceWidget(context, card.showName, card.showState),
|
child: entity.entity.buildGlanceWidget(context, card.showName, card.showState),
|
||||||
@ -39,12 +38,11 @@ class GlanceCardWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.fromLTRB(0.0, Sizes.rowPadding, 0.0, 2*Sizes.rowPadding),
|
padding: EdgeInsets.fromLTRB(0.0, Sizes.rowPadding, 0.0, 2*Sizes.rowPadding),
|
||||||
child: Wrap(
|
child: Wrap(
|
||||||
alignment: WrapAlignment.spaceAround,
|
//alignment: WrapAlignment.spaceAround,
|
||||||
runSpacing: Sizes.rowPadding*2,
|
runSpacing: Sizes.rowPadding*2,
|
||||||
children: result,
|
children: result,
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user