Minor gauge fixes

This commit is contained in:
estevez-dev 2019-09-07 17:04:40 +03:00
parent 37e63637a7
commit 6508f109f7
5 changed files with 28 additions and 15 deletions

View File

@ -291,13 +291,14 @@ class CardWidget extends StatelessWidget {
Widget _buildGaugeCard(BuildContext context) { Widget _buildGaugeCard(BuildContext context) {
card.linkedEntityWrapper.displayName = card.name ?? card.linkedEntityWrapper.displayName = card.name ??
card.linkedEntityWrapper.displayName; card.linkedEntityWrapper.displayName;
card.linkedEntityWrapper.unitOfMeasurement = card.unit ??
card.linkedEntityWrapper.unitOfMeasurement;
return Card( return Card(
child: EntityModel( child: EntityModel(
entityWrapper: card.linkedEntityWrapper, entityWrapper: card.linkedEntityWrapper,
child: GaugeCardBody( child: GaugeCardBody(
min: card.min, min: card.min,
max: card.max, max: card.max,
unit: card.unit ?? card.linkedEntityWrapper.entity.unitOfMeasurement,
severity: card.severity, severity: card.severity,
), ),
handleTap: true handleTap: true

View File

@ -4,10 +4,9 @@ class GaugeCardBody extends StatefulWidget {
final int min; final int min;
final int max; final int max;
final String unit;
final Map severity; final Map severity;
GaugeCardBody({Key key, this.min, this.max, this.unit, this.severity}) : super(key: key); GaugeCardBody({Key key, this.min, this.max, this.severity}) : super(key: key);
@override @override
_GaugeCardBodyState createState() => _GaugeCardBodyState(); _GaugeCardBodyState createState() => _GaugeCardBodyState();
@ -104,11 +103,15 @@ class _GaugeCardBodyState extends State<GaugeCardBody> {
double fontSize = constraints.maxHeight / 7; double fontSize = constraints.maxHeight / 7;
return Padding( return Padding(
padding: EdgeInsets.only(bottom: 2*fontSize), padding: EdgeInsets.only(bottom: 2*fontSize),
child: Text( child: SimpleEntityState(
'${entityWrapper.entity.doubleState}${widget.unit}', //textAlign: TextAlign.center,
expanded: false,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, bold: true,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: fontSize), textAlign: TextAlign.center,
padding: EdgeInsets.all(0.0),
fontSize: fontSize,
//padding: EdgeInsets.only(top: Sizes.rowPadding),
), ),
); );
} }
@ -121,11 +124,12 @@ class _GaugeCardBodyState extends State<GaugeCardBody> {
double fontSize = constraints.maxHeight / 7; double fontSize = constraints.maxHeight / 7;
return Padding( return Padding(
padding: EdgeInsets.only(bottom: fontSize), padding: EdgeInsets.only(bottom: fontSize),
child: Text( child: EntityName(
'${entityWrapper.displayName}', fontSize: fontSize,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, padding: EdgeInsets.all(0.0),
style: TextStyle(fontSize: fontSize), textAlign: TextAlign.center,
textOverflow: TextOverflow.ellipsis,
), ),
); );
} }

View File

@ -4,6 +4,7 @@ class EntityWrapper {
String displayName; String displayName;
String icon; String icon;
String unitOfMeasurement;
String entityPicture; String entityPicture;
EntityUIAction uiAction; EntityUIAction uiAction;
Entity entity; Entity entity;
@ -24,6 +25,7 @@ class EntityWrapper {
if (uiAction == null) { if (uiAction == null) {
uiAction = EntityUIAction(); uiAction = EntityUIAction();
} }
unitOfMeasurement = entity.unitOfMeasurement;
} }
} }

View File

@ -57,7 +57,7 @@ class BadgeWidget extends StatelessWidget {
} else if (entityModel.entityWrapper.entity.displayState.length <= 10) { } else if (entityModel.entityWrapper.entity.displayState.length <= 10) {
stateFontSize = 8.0; stateFontSize = 8.0;
} }
onBadgeTextValue = entityModel.entityWrapper.entity.unitOfMeasurement; onBadgeTextValue = entityModel.entityWrapper.unitOfMeasurement;
badgeIcon = Center( badgeIcon = Center(
child: Text( child: Text(
"${entityModel.entityWrapper.entity.displayState}", "${entityModel.entityWrapper.entity.displayState}",

View File

@ -7,8 +7,10 @@ class SimpleEntityState extends StatelessWidget {
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry padding;
final int maxLines; final int maxLines;
final String customValue; final String customValue;
final double fontSize;
final bool bold;
const SimpleEntityState({Key key, this.maxLines: 10, this.expanded: true, this.textAlign: TextAlign.right, this.padding: const EdgeInsets.fromLTRB(0.0, 0.0, Sizes.rightWidgetPadding, 0.0), this.customValue}) : super(key: key); const SimpleEntityState({Key key,this.bold: false, this.maxLines: 10, this.fontSize: Sizes.stateFontSize, this.expanded: true, this.textAlign: TextAlign.right, this.padding: const EdgeInsets.fromLTRB(0.0, 0.0, Sizes.rightWidgetPadding, 0.0), this.customValue}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -21,18 +23,22 @@ class SimpleEntityState extends StatelessWidget {
state = customValue; state = customValue;
} }
TextStyle textStyle = TextStyle( TextStyle textStyle = TextStyle(
fontSize: Sizes.stateFontSize, fontSize: this.fontSize,
fontWeight: FontWeight.normal
); );
if (entityModel.entityWrapper.entity.statelessType == StatelessEntityType.CALL_SERVICE) { if (entityModel.entityWrapper.entity.statelessType == StatelessEntityType.CALL_SERVICE) {
textStyle = textStyle.apply(color: Colors.blue); textStyle = textStyle.apply(color: Colors.blue);
} }
if (this.bold) {
textStyle = textStyle.apply(fontWeightDelta: 100);
}
while (state.contains(" ")){ while (state.contains(" ")){
state = state.replaceAll(" ", " "); state = state.replaceAll(" ", " ");
} }
Widget result = Padding( Widget result = Padding(
padding: padding, padding: padding,
child: Text( child: Text(
"$state ${entityModel.entityWrapper.entity.unitOfMeasurement}", "$state ${entityModel.entityWrapper.unitOfMeasurement}",
textAlign: textAlign, textAlign: textAlign,
maxLines: maxLines, maxLines: maxLines,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,