WIP Themes: font size standartization

This commit is contained in:
Yegor Vialov 2020-04-04 12:47:40 +00:00
parent b8ba3c59e9
commit 4432124e8c
16 changed files with 47 additions and 118 deletions

View File

@ -108,10 +108,8 @@ class _GaugeCardBodyState extends State<GaugeCardBody> {
//textAlign: TextAlign.center, //textAlign: TextAlign.center,
expanded: false, expanded: false,
maxLines: 1, maxLines: 1,
bold: true,
textAlign: TextAlign.center, textAlign: TextAlign.center,
padding: EdgeInsets.all(0.0), padding: EdgeInsets.all(0.0)
fontSize: fontSize,
//padding: EdgeInsets.only(top: Sizes.rowPadding), //padding: EdgeInsets.only(top: Sizes.rowPadding),
), ),
); );

View File

@ -69,7 +69,7 @@ class GlanceCardEntityContainer extends StatelessWidget {
textOverflow: TextOverflow.ellipsis, textOverflow: TextOverflow.ellipsis,
wordsWrap: wordsWrapInName, wordsWrap: wordsWrapInName,
textAlign: TextAlign.center, textAlign: TextAlign.center,
textStyle: Theme.of(context).textTheme.caption, textStyle: Theme.of(context).textTheme.body1,
); );
} }

View File

@ -34,60 +34,5 @@ class _LightCardBodyState extends State<LightCardBody> {
), ),
); );
return InkWell(
onTap: () => entityWrapper.handleTap(),
onLongPress: () => entityWrapper.handleHold(),
onDoubleTap: () => entityWrapper.handleDoubleTap(),
child: AspectRatio(
aspectRatio: 1.5,
child: Stack(
fit: StackFit.expand,
overflow: Overflow.clip,
children: [
Align(
alignment: Alignment.bottomCenter,
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
double fontSize = constraints.maxHeight / 7;
return Padding(
padding: EdgeInsets.only(bottom: 2*fontSize),
child: SimpleEntityState(
//textAlign: TextAlign.center,
expanded: false,
maxLines: 1,
bold: true,
textAlign: TextAlign.center,
padding: EdgeInsets.all(0.0),
fontSize: fontSize,
//padding: EdgeInsets.only(top: Sizes.rowPadding),
),
);
}
),
),
Align(
alignment: Alignment.bottomCenter,
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
double fontSize = constraints.maxHeight / 7;
return Padding(
padding: EdgeInsets.only(bottom: fontSize),
child: EntityName(
textStyle: Theme.of(context).textTheme.body1.copyWith(
fontSize: fontSize
),
maxLines: 1,
padding: EdgeInsets.all(0.0),
textAlign: TextAlign.center,
textOverflow: TextOverflow.ellipsis,
),
);
}
),
)
]
)
),
);
} }
} }

View File

@ -126,10 +126,10 @@ class Sizes {
static const extendedWidgetHeight = 50.0; static const extendedWidgetHeight = 50.0;
static const iconSize = 28.0; static const iconSize = 28.0;
static const largeIconSize = 46.0; static const largeIconSize = 46.0;
static const stateFontSize = 15.0; //static const stateFontSize = 15.0;
static const nameFontSize = 15.0; //static const nameFontSize = 15.0;
static const smallFontSize = 14.0; //static const smallFontSize = 14.0;
static const largeFontSize = 24.0; //static const largeFontSize = 24.0;
static const inputWidth = 160.0; static const inputWidth = 160.0;
static const rowPadding = 10.0; static const rowPadding = 10.0;
static const doubleRowPadding = rowPadding*2; static const doubleRowPadding = rowPadding*2;

View File

@ -64,9 +64,7 @@ class _CoverControlWidgetState extends State<CoverControlWidget> {
Padding( Padding(
padding: EdgeInsets.fromLTRB( padding: EdgeInsets.fromLTRB(
0.0, Sizes.rowPadding, 0.0, Sizes.rowPadding), 0.0, Sizes.rowPadding, 0.0, Sizes.rowPadding),
child: Text("Position", style: TextStyle( child: Text("Position"),
fontSize: Sizes.stateFontSize
)),
), ),
Slider( Slider(
value: _tmpPosition, value: _tmpPosition,
@ -118,9 +116,7 @@ class _CoverControlWidgetState extends State<CoverControlWidget> {
controls.insert(0, Padding( controls.insert(0, Padding(
padding: EdgeInsets.fromLTRB( padding: EdgeInsets.fromLTRB(
0.0, Sizes.rowPadding, 0.0, Sizes.rowPadding), 0.0, Sizes.rowPadding, 0.0, Sizes.rowPadding),
child: Text("Tilt position", style: TextStyle( child: Text("Tilt position"),
fontSize: Sizes.stateFontSize
)),
)); ));
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,

View File

@ -9,10 +9,8 @@ class DateTimeStateWidget extends StatelessWidget {
padding: EdgeInsets.fromLTRB(0.0, 0.0, Sizes.rightWidgetPadding, 0.0), padding: EdgeInsets.fromLTRB(0.0, 0.0, Sizes.rightWidgetPadding, 0.0),
child: GestureDetector( child: GestureDetector(
child: Text("${entity.formattedState}", child: Text("${entity.formattedState}",
textAlign: TextAlign.right, textAlign: TextAlign.right
style: new TextStyle( ),
fontSize: Sizes.stateFontSize,
)),
onTap: () => _handleStateTap(context, entity), onTap: () => _handleStateTap(context, entity),
)); ));
} }

View File

@ -6,7 +6,6 @@ class FlatServiceButton extends StatelessWidget {
final String serviceName; final String serviceName;
final String entityId; final String entityId;
final String text; final String text;
final double fontSize;
FlatServiceButton({ FlatServiceButton({
Key key, Key key,
@ -14,7 +13,6 @@ class FlatServiceButton extends StatelessWidget {
@required this.serviceName, @required this.serviceName,
@required this.entityId, @required this.entityId,
@required this.text, @required this.text,
this.fontSize: Sizes.stateFontSize
}) : super(key: key); }) : super(key: key);
void _setNewState() { void _setNewState() {
@ -24,7 +22,7 @@ class FlatServiceButton extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SizedBox( return SizedBox(
height: fontSize*2.5, height: Theme.of(context).textTheme.subhead.fontSize*2.5,
child: FlatButton( child: FlatButton(
onPressed: (() { onPressed: (() {
_setNewState(); _setNewState();
@ -32,8 +30,7 @@ class FlatServiceButton extends StatelessWidget {
child: Text( child: Text(
text, text,
textAlign: TextAlign.right, textAlign: TextAlign.right,
style: style: Theme.of(context).textTheme.subhead,
new TextStyle(fontSize: fontSize, color: Colors.blue),
), ),
) )
); );

View File

@ -28,8 +28,9 @@ class LockStateWidget extends StatelessWidget {
onPressed: () => _unlock(entity), onPressed: () => _unlock(entity),
child: Text("UNLOCK", child: Text("UNLOCK",
textAlign: TextAlign.right, textAlign: TextAlign.right,
style: style: Theme.of(context).textTheme.subhead.copyWith(
new TextStyle(fontSize: Sizes.stateFontSize, color: Colors.blue), color: Colors.blue
)
), ),
) )
), ),
@ -39,8 +40,9 @@ class LockStateWidget extends StatelessWidget {
onPressed: () => _lock(entity), onPressed: () => _lock(entity),
child: Text("LOCK", child: Text("LOCK",
textAlign: TextAlign.right, textAlign: TextAlign.right,
style: style: Theme.of(context).textTheme.subhead.copyWith(
new TextStyle(fontSize: Sizes.stateFontSize, color: Colors.blue), color: Colors.blue
),
), ),
) )
) )
@ -56,8 +58,9 @@ class LockStateWidget extends StatelessWidget {
child: Text( child: Text(
entity.isLocked ? "UNLOCK" : "LOCK", entity.isLocked ? "UNLOCK" : "LOCK",
textAlign: TextAlign.right, textAlign: TextAlign.right,
style: style: Theme.of(context).textTheme.subhead.copyWith(
new TextStyle(fontSize: Sizes.stateFontSize, color: Colors.blue), color: Colors.blue
),
), ),
) )
); );

View File

@ -7,10 +7,9 @@ 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;
final bool bold;
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); const SimpleEntityState({Key key,/*this.bold: false,*/ 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);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -22,16 +21,17 @@ class SimpleEntityState extends StatelessWidget {
} else { } else {
state = customValue; state = customValue;
} }
TextStyle textStyle = TextStyle( TextStyle textStyle;
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 = Theme.of(context).textTheme.subhead.copyWith(
color: Colors.blue
);
} else {
textStyle = Theme.of(context).textTheme.body1;
} }
if (this.bold) { /*if (this.bold) {
textStyle = textStyle.apply(fontWeightDelta: 100); textStyle = textStyle.apply(fontWeightDelta: 100);
} }*/
while (state.contains(" ")){ while (state.contains(" ")){
state = state.replaceAll(" ", " "); state = state.replaceAll(" ", " ");
} }

View File

@ -62,8 +62,7 @@ class _SliderControlsWidgetState extends State<SliderControlsWidget> {
children: <Widget>[ children: <Widget>[
Text( Text(
"$_newValue", "$_newValue",
style: TextStyle( style: Theme.of(context).textTheme.display1.copyWith(
fontSize: Sizes.largeFontSize,
color: Colors.blue color: Colors.blue
), ),
), ),

View File

@ -40,10 +40,7 @@ class UniversalSlider extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Container(height: Sizes.rowPadding,), Container(height: Sizes.rowPadding,),
Text( Text("$title"),
"$title",
style: TextStyle(fontSize: Sizes.stateFontSize),
),
Container(height: Sizes.rowPadding,), Container(height: Sizes.rowPadding,),
Row( Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,

View File

@ -10,7 +10,7 @@ class VacuumControls extends StatelessWidget {
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
_buildStatusAndBattery(entity), _buildStatusAndBattery(entity, context),
_buildCommands(entity), _buildCommands(entity),
_buildFanSpeed(entity), _buildFanSpeed(entity),
_buildAdditionalInfo(entity) _buildAdditionalInfo(entity)
@ -19,12 +19,12 @@ class VacuumControls extends StatelessWidget {
); );
} }
Widget _buildStatusAndBattery(VacuumEntity entity) { Widget _buildStatusAndBattery(VacuumEntity entity, BuildContext context) {
List<Widget> result = []; List<Widget> result = [];
if (entity.supportStatus) { if (entity.supportStatus) {
result.addAll( result.addAll(
<Widget>[ <Widget>[
Text("Status:", style: TextStyle(fontSize: Sizes.stateFontSize),), Text("Status:"),
Container(width: 6,), Container(width: 6,),
Expanded( Expanded(
//flex: 1, //flex: 1,
@ -33,10 +33,7 @@ class VacuumControls extends StatelessWidget {
maxLines: 1, maxLines: 1,
softWrap: true, softWrap: true,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: Theme.of(context).textTheme.body2,
fontSize: Sizes.stateFontSize,
fontWeight: FontWeight.bold
),
), ),
), ),
] ]
@ -48,7 +45,7 @@ class VacuumControls extends StatelessWidget {
result.addAll(<Widget>[ result.addAll(<Widget>[
Icon(MaterialDesignIcons.getIconDataFromIconName(iconName)), Icon(MaterialDesignIcons.getIconDataFromIconName(iconName)),
Container(width: 6,), Container(width: 6,),
Text("$batteryLevel %", style: TextStyle(fontSize: Sizes.stateFontSize)) Text("$batteryLevel %")
] ]
); );
} }
@ -172,7 +169,7 @@ class VacuumControls extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text("Vacuum cleaner commands:", style: TextStyle(fontSize: Sizes.stateFontSize)), Text("Vacuum cleaner commands:"),
Container(height: Sizes.rowPadding,), Container(height: Sizes.rowPadding,),
Row( Row(
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,

View File

@ -14,17 +14,18 @@ class HAClientTheme {
HAClientTheme._internal(); HAClientTheme._internal();
final ThemeData lightTheme = ThemeData.light().copyWith( final ThemeData lightTheme = ThemeData.light().copyWith(
primaryColor: Colors.lightBlue,
textTheme: ThemeData.light().textTheme.copyWith( textTheme: ThemeData.light().textTheme.copyWith(
display1: TextStyle(fontSize: 34, fontWeight: FontWeight.normal, color: Colors.black54), display1: TextStyle(fontSize: 34, fontWeight: FontWeight.normal, color: Colors.black54),
display2: TextStyle(fontSize: 34, fontWeight: FontWeight.normal, color: Colors.redAccent), display2: TextStyle(fontSize: 34, fontWeight: FontWeight.normal, color: Colors.redAccent),
headline: TextStyle(fontSize: 24, fontWeight: FontWeight.normal, color: defaultFontColor), headline: TextStyle(fontSize: 24, fontWeight: FontWeight.normal, color: defaultFontColor),
title: TextStyle(fontSize: 20, fontWeight: FontWeight.w700, color: defaultFontColor), title: TextStyle(fontSize: 20, fontWeight: FontWeight.w700, color: defaultFontColor),
subhead: TextStyle(fontSize: 16, fontWeight: FontWeight.w500, color: defaultFontColor), subhead: TextStyle(fontSize: 16, fontWeight: FontWeight.normal, color: Colors.black54),
body1: TextStyle(fontSize: 15, fontWeight: FontWeight.normal, color: defaultFontColor), body1: TextStyle(fontSize: 15, fontWeight: FontWeight.normal, color: defaultFontColor),
body2: TextStyle(fontSize: 15, fontWeight: FontWeight.w500, color: defaultFontColor), body2: TextStyle(fontSize: 15, fontWeight: FontWeight.w500, color: defaultFontColor),
subtitle: TextStyle(fontSize: 15, fontWeight: FontWeight.w500, color: Colors.black45), subtitle: TextStyle(fontSize: 15, fontWeight: FontWeight.w500, color: Colors.black45),
caption: TextStyle(fontSize: 13, fontWeight: FontWeight.normal, color: defaultFontColor), caption: TextStyle(fontSize: 14, fontWeight: FontWeight.normal, color: Colors.black26),
overline: TextStyle(fontSize: 10, fontWeight: FontWeight.normal, color: Colors.black54), overline: TextStyle(fontSize: 10, fontWeight: FontWeight.normal, color: Colors.black26),
) )
); );

View File

@ -539,9 +539,8 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
} }
void _showErrorBottomBar(HAError error) { void _showErrorBottomBar(HAError error) {
TextStyle textStyle = TextStyle( TextStyle textStyle = Theme.of(context).textTheme.subhead.copyWith(
color: Colors.blue, color: Colors.blue
fontSize: Sizes.nameFontSize
); );
_bottomBarColor = Colors.red.shade100; _bottomBarColor = Colors.red.shade100;
List<Widget> actions = []; List<Widget> actions = [];

View File

@ -10,8 +10,7 @@ class LastUpdatedWidget extends StatelessWidget {
child: Text( child: Text(
'${entityModel.entityWrapper.entity.lastUpdated}', '${entityModel.entityWrapper.entity.lastUpdated}',
textAlign: TextAlign.left, textAlign: TextAlign.left,
style: TextStyle( style: Theme.of(context).textTheme.caption
fontSize: Sizes.smallFontSize, color: Colors.black26),
), ),
); );
} }

View File

@ -16,7 +16,7 @@ class LinkToWebConfig extends StatelessWidget {
title: Text("${this.name}", title: Text("${this.name}",
textAlign: TextAlign.left, textAlign: TextAlign.left,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: new TextStyle(fontWeight: FontWeight.bold, fontSize: Sizes.largeFontSize)), style: Theme.of(context).textTheme.headline),
subtitle: Text("Tap to open web version"), subtitle: Text("Tap to open web version"),
onTap: () { onTap: () {
Launcher.launchAuthenticatedWebView(context: context, url: this.url, title: this.name); Launcher.launchAuthenticatedWebView(context: context, url: this.url, title: this.name);