2018-10-27 14:27:41 +03:00
|
|
|
part of '../../main.dart';
|
|
|
|
|
|
|
|
class SimpleEntityState extends StatelessWidget {
|
2018-11-05 20:21:44 +02:00
|
|
|
|
|
|
|
final bool expanded;
|
2018-11-14 19:52:17 +02:00
|
|
|
final TextAlign textAlign;
|
|
|
|
final EdgeInsetsGeometry padding;
|
2018-11-05 20:21:44 +02:00
|
|
|
|
2018-11-14 19:52:17 +02:00
|
|
|
const SimpleEntityState({Key key, this.expanded: true, this.textAlign: TextAlign.right, this.padding: const EdgeInsets.fromLTRB(0.0, 0.0, Sizes.rightWidgetPadding, 0.0)}) : super(key: key);
|
2018-11-05 20:21:44 +02:00
|
|
|
|
2018-10-27 14:27:41 +03:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final entityModel = EntityModel.of(context);
|
2018-11-05 20:21:44 +02:00
|
|
|
Widget result = Padding(
|
2018-11-14 19:52:17 +02:00
|
|
|
padding: padding,
|
2018-11-05 20:21:44 +02:00
|
|
|
child: GestureDetector(
|
|
|
|
child: Text(
|
2018-11-15 19:08:47 +02:00
|
|
|
"${entityModel.entity.entity.state}${entityModel.entity.entity.unitOfMeasurement}",
|
2018-11-14 19:52:17 +02:00
|
|
|
textAlign: textAlign,
|
2018-11-14 12:35:08 +02:00
|
|
|
maxLines: 4,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
softWrap: true,
|
2018-11-05 20:21:44 +02:00
|
|
|
style: new TextStyle(
|
2018-11-12 20:28:10 +02:00
|
|
|
fontSize: Sizes.stateFontSize,
|
2018-11-05 20:21:44 +02:00
|
|
|
)),
|
|
|
|
onTap: () => entityModel.handleTap
|
2018-11-15 19:08:47 +02:00
|
|
|
? eventBus.fire(new ShowEntityPageEvent(entityModel.entity.entity))
|
2018-11-05 20:21:44 +02:00
|
|
|
: null,
|
|
|
|
)
|
2018-11-04 22:55:09 +02:00
|
|
|
);
|
2018-11-05 20:21:44 +02:00
|
|
|
if (expanded) {
|
2018-11-14 12:35:08 +02:00
|
|
|
return SizedBox(
|
|
|
|
width: MediaQuery.of(context).size.width * 0.3,
|
|
|
|
child: result,
|
2018-11-05 20:21:44 +02:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return result;
|
|
|
|
}
|
2018-10-27 14:27:41 +03:00
|
|
|
}
|
2018-11-04 22:55:09 +02:00
|
|
|
}
|