WIP Themes: climate controls and entity name
This commit is contained in:
@ -204,20 +204,20 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
//_buildOnOffControl(entity),
|
||||
_buildTemperatureControls(entity),
|
||||
_buildTargetTemperatureControls(entity),
|
||||
_buildHumidityControls(entity),
|
||||
_buildOperationControl(entity),
|
||||
_buildFanControl(entity),
|
||||
_buildSwingControl(entity),
|
||||
_buildPresetModeControl(entity),
|
||||
_buildAuxHeatControl(entity)
|
||||
_buildTemperatureControls(entity, context),
|
||||
_buildTargetTemperatureControls(entity, context),
|
||||
_buildHumidityControls(entity, context),
|
||||
_buildOperationControl(entity, context),
|
||||
_buildFanControl(entity, context),
|
||||
_buildSwingControl(entity, context),
|
||||
_buildPresetModeControl(entity, context),
|
||||
_buildAuxHeatControl(entity, context)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPresetModeControl(ClimateEntity entity) {
|
||||
Widget _buildPresetModeControl(ClimateEntity entity, BuildContext context) {
|
||||
if (entity.supportPresetMode) {
|
||||
return ModeSelectorWidget(
|
||||
options: entity.presetModes,
|
||||
@ -242,7 +242,7 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
||||
}
|
||||
}*/
|
||||
|
||||
Widget _buildAuxHeatControl(ClimateEntity entity) {
|
||||
Widget _buildAuxHeatControl(ClimateEntity entity, BuildContext context) {
|
||||
if (entity.supportAuxHeat ) {
|
||||
return ModeSwitchWidget(
|
||||
caption: "Aux heat",
|
||||
@ -254,7 +254,7 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildOperationControl(ClimateEntity entity) {
|
||||
Widget _buildOperationControl(ClimateEntity entity, BuildContext context) {
|
||||
if (entity.hvacModes != null) {
|
||||
return ModeSelectorWidget(
|
||||
onChange: (mode) => _setHVACMode(entity, mode),
|
||||
@ -267,7 +267,7 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildFanControl(ClimateEntity entity) {
|
||||
Widget _buildFanControl(ClimateEntity entity, BuildContext context) {
|
||||
if (entity.supportFanMode) {
|
||||
return ModeSelectorWidget(
|
||||
options: entity.fanModes,
|
||||
@ -280,7 +280,7 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildSwingControl(ClimateEntity entity) {
|
||||
Widget _buildSwingControl(ClimateEntity entity, BuildContext context) {
|
||||
if (entity.supportSwingMode) {
|
||||
return ModeSelectorWidget(
|
||||
onChange: (mode) => _setSwingMode(entity, mode),
|
||||
@ -293,17 +293,15 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildTemperatureControls(ClimateEntity entity) {
|
||||
Widget _buildTemperatureControls(ClimateEntity entity, BuildContext context) {
|
||||
if ((entity.supportTargetTemperature) && (entity.temperature != null)) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text("Target temperature", style: TextStyle(
|
||||
fontSize: Sizes.stateFontSize
|
||||
)),
|
||||
Text("Target temperature", style: Theme.of(context).textTheme.body1),
|
||||
TemperatureControlWidget(
|
||||
value: _tmpTemperature,
|
||||
fontColor: _temperaturePending ? Colors.red : Colors.black,
|
||||
active: _temperaturePending,
|
||||
onDec: () => _temperatureDown(entity),
|
||||
onInc: () => _temperatureUp(entity),
|
||||
)
|
||||
@ -314,13 +312,13 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildTargetTemperatureControls(ClimateEntity entity) {
|
||||
Widget _buildTargetTemperatureControls(ClimateEntity entity, BuildContext context) {
|
||||
List<Widget> controls = [];
|
||||
if ((entity.supportTargetTemperatureRange) && (entity.targetLow != null)) {
|
||||
controls.addAll(<Widget>[
|
||||
TemperatureControlWidget(
|
||||
value: _tmpTargetLow,
|
||||
fontColor: _temperaturePending ? Colors.red : Colors.black,
|
||||
active: _temperaturePending,
|
||||
onDec: () => _targetLowDown(entity),
|
||||
onInc: () => _targetLowUp(entity),
|
||||
),
|
||||
@ -333,7 +331,7 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
||||
controls.add(
|
||||
TemperatureControlWidget(
|
||||
value: _tmpTargetHigh,
|
||||
fontColor: _temperaturePending ? Colors.red : Colors.black,
|
||||
active: _temperaturePending,
|
||||
onDec: () => _targetHighDown(entity),
|
||||
onInc: () => _targetHighUp(entity),
|
||||
)
|
||||
@ -343,9 +341,7 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text("Target temperature range", style: TextStyle(
|
||||
fontSize: Sizes.stateFontSize
|
||||
)),
|
||||
Text("Target temperature range", style: Theme.of(context).textTheme.body1),
|
||||
Row(
|
||||
children: controls,
|
||||
)
|
||||
@ -356,13 +352,13 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildHumidityControls(ClimateEntity entity) {
|
||||
Widget _buildHumidityControls(ClimateEntity entity, BuildContext context) {
|
||||
List<Widget> result = [];
|
||||
if (entity.supportTargetHumidity) {
|
||||
result.addAll(<Widget>[
|
||||
Text(
|
||||
"$_tmpTargetHumidity%",
|
||||
style: TextStyle(fontSize: Sizes.largeFontSize),
|
||||
style: Theme.of(context).textTheme.display1,
|
||||
),
|
||||
Expanded(
|
||||
child: Slider(
|
||||
@ -387,9 +383,7 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
0.0, Sizes.rowPadding, 0.0, Sizes.rowPadding),
|
||||
child: Text("Target humidity", style: TextStyle(
|
||||
fontSize: Sizes.stateFontSize
|
||||
)),
|
||||
child: Text("Target humidity", style: Theme.of(context).textTheme.body1),
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
|
@ -33,23 +33,16 @@ class ClimateStateWidget extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
Text("$displayState",
|
||||
textAlign: TextAlign.right,
|
||||
style: new TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: Sizes.stateFontSize,
|
||||
)),
|
||||
style: Theme.of(context).textTheme.body2),
|
||||
Text(" $targetTemp",
|
||||
textAlign: TextAlign.right,
|
||||
style: new TextStyle(
|
||||
fontSize: Sizes.stateFontSize,
|
||||
))
|
||||
style: Theme.of(context).textTheme.body1)
|
||||
],
|
||||
),
|
||||
entity.currentTemperature != null ?
|
||||
Text("Currently: ${entity.currentTemperature}",
|
||||
textAlign: TextAlign.right,
|
||||
style: new TextStyle(
|
||||
fontSize: Sizes.stateFontSize,
|
||||
color: Colors.black45)
|
||||
style: Theme.of(context).textTheme.subtitle
|
||||
) :
|
||||
Container(height: 0.0,)
|
||||
],
|
||||
|
@ -5,8 +5,6 @@ class ModeSelectorWidget extends StatelessWidget {
|
||||
final String caption;
|
||||
final List options;
|
||||
final String value;
|
||||
final double captionFontSize;
|
||||
final double valueFontSize;
|
||||
final onChange;
|
||||
final EdgeInsets padding;
|
||||
|
||||
@ -16,8 +14,6 @@ class ModeSelectorWidget extends StatelessWidget {
|
||||
@required this.options,
|
||||
this.value,
|
||||
@required this.onChange,
|
||||
this.captionFontSize,
|
||||
this.valueFontSize,
|
||||
this.padding: const EdgeInsets.fromLTRB(Sizes.leftWidgetPadding, Sizes.rowPadding, Sizes.rightWidgetPadding, 0.0),
|
||||
}) : super(key: key);
|
||||
|
||||
@ -28,9 +24,7 @@ class ModeSelectorWidget extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text("$caption", style: TextStyle(
|
||||
fontSize: captionFontSize ?? Sizes.stateFontSize
|
||||
)),
|
||||
Text("$caption", style: Theme.of(context).textTheme.body1),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
@ -40,10 +34,7 @@ class ModeSelectorWidget extends StatelessWidget {
|
||||
value: value,
|
||||
iconSize: 30.0,
|
||||
isExpanded: true,
|
||||
style: TextStyle(
|
||||
fontSize: valueFontSize ?? Sizes.largeFontSize,
|
||||
color: Colors.black,
|
||||
),
|
||||
style: Theme.of(context).textTheme.title,
|
||||
hint: Text("Select ${caption.toLowerCase()}"),
|
||||
items: options.map((value) {
|
||||
return new DropdownMenuItem<String>(
|
||||
|
@ -4,7 +4,6 @@ class ModeSwitchWidget extends StatelessWidget {
|
||||
|
||||
final String caption;
|
||||
final onChange;
|
||||
final double captionFontSize;
|
||||
final bool value;
|
||||
final bool expanded;
|
||||
final EdgeInsets padding;
|
||||
@ -13,7 +12,6 @@ class ModeSwitchWidget extends StatelessWidget {
|
||||
Key key,
|
||||
@required this.caption,
|
||||
@required this.onChange,
|
||||
this.captionFontSize,
|
||||
this.value,
|
||||
this.expanded: true,
|
||||
this.padding: const EdgeInsets.only(left: Sizes.leftWidgetPadding, right: Sizes.rightWidgetPadding)
|
||||
@ -25,7 +23,7 @@ class ModeSwitchWidget extends StatelessWidget {
|
||||
padding: this.padding,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
_buildCaption(),
|
||||
_buildCaption(context),
|
||||
Switch(
|
||||
onChanged: (value) => onChange(value),
|
||||
value: value ?? false,
|
||||
@ -35,12 +33,10 @@ class ModeSwitchWidget extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCaption() {
|
||||
Widget _buildCaption(BuildContext context) {
|
||||
Widget captionWidget = Text(
|
||||
"$caption",
|
||||
style: TextStyle(
|
||||
fontSize: captionFontSize ?? Sizes.stateFontSize
|
||||
),
|
||||
style: Theme.of(context).textTheme.body1,
|
||||
);
|
||||
if (expanded) {
|
||||
return Expanded(
|
||||
|
@ -2,8 +2,7 @@ part of '../../../main.dart';
|
||||
|
||||
class TemperatureControlWidget extends StatelessWidget {
|
||||
final double value;
|
||||
final double fontSize;
|
||||
final Color fontColor;
|
||||
final bool active;
|
||||
final onInc;
|
||||
final onDec;
|
||||
|
||||
@ -12,8 +11,9 @@ class TemperatureControlWidget extends StatelessWidget {
|
||||
@required this.value,
|
||||
@required this.onInc,
|
||||
@required this.onDec,
|
||||
this.fontSize,
|
||||
this.fontColor})
|
||||
//this.fontSize,
|
||||
this.active: false
|
||||
})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@ -23,10 +23,7 @@ class TemperatureControlWidget extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
Text(
|
||||
"$value",
|
||||
style: TextStyle(
|
||||
fontSize: fontSize ?? 24.0,
|
||||
color: fontColor ?? Colors.black
|
||||
),
|
||||
style: active ? Theme.of(context).textTheme.display2 : Theme.of(context).textTheme.display1,
|
||||
),
|
||||
Column(
|
||||
children: <Widget>[
|
||||
|
@ -5,18 +5,21 @@ class EntityName extends StatelessWidget {
|
||||
final EdgeInsetsGeometry padding;
|
||||
final TextOverflow textOverflow;
|
||||
final bool wordsWrap;
|
||||
final double fontSize;
|
||||
final TextAlign textAlign;
|
||||
final int maxLines;
|
||||
final TextStyle textStyle;
|
||||
|
||||
const EntityName({Key key, this.maxLines, this.padding: const EdgeInsets.only(right: 10.0), this.textOverflow: TextOverflow.ellipsis, this.wordsWrap: true, this.fontSize: Sizes.nameFontSize, this.textAlign: TextAlign.left}) : super(key: key);
|
||||
const EntityName({Key key, this.maxLines, this.padding: const EdgeInsets.only(right: 10.0), this.textOverflow: TextOverflow.ellipsis, this.textStyle, this.wordsWrap: true, this.textAlign: TextAlign.left}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final EntityWrapper entityWrapper = EntityModel.of(context).entityWrapper;
|
||||
TextStyle textStyle = TextStyle(fontSize: fontSize);
|
||||
if (entityWrapper.entity.statelessType == StatelessEntityType.WEBLINK) {
|
||||
textStyle = textStyle.apply(color: Colors.blue, decoration: TextDecoration.underline);
|
||||
TextStyle tStyle;
|
||||
if (textStyle == null) {
|
||||
tStyle = Theme.of(context).textTheme.body1;
|
||||
if (entityWrapper.entity.statelessType == StatelessEntityType.WEBLINK) {
|
||||
tStyle = tStyle.apply(color: Colors.blue, decoration: TextDecoration.underline);
|
||||
}
|
||||
}
|
||||
return Padding(
|
||||
padding: padding,
|
||||
@ -25,7 +28,7 @@ class EntityName extends StatelessWidget {
|
||||
overflow: textOverflow,
|
||||
softWrap: wordsWrap,
|
||||
maxLines: maxLines,
|
||||
style: textStyle,
|
||||
style: tStyle,
|
||||
textAlign: textAlign,
|
||||
),
|
||||
);
|
||||
|
Reference in New Issue
Block a user