From f74514796fc478bf854cce9870caa8d6817a1d4c Mon Sep 17 00:00:00 2001 From: BroodjeAap Date: Wed, 30 Dec 2020 18:19:13 +0100 Subject: [PATCH] another textstyle change attempt --- .../instructions/YearInstructionPage.dart | 46 +++++++++---------- lib/util/TextStyles.dart | 16 ++++++- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/lib/pages/practice/instructions/YearInstructionPage.dart b/lib/pages/practice/instructions/YearInstructionPage.dart index 2ee7149..36e3b92 100644 --- a/lib/pages/practice/instructions/YearInstructionPage.dart +++ b/lib/pages/practice/instructions/YearInstructionPage.dart @@ -57,8 +57,8 @@ class _YearInstructionPageState extends State { Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text("YY", style: TextStyles.textStyle20.apply(color: Colors.grey)), - Text("YY", style: TextStyles.textStyle20.apply(color: Colors.green)), + Text20("YY", color: Colors.grey), + Text20("YY", color: Colors.green), ], ), Text20("Calculate:"), @@ -66,9 +66,9 @@ class _YearInstructionPageState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Text20("("), - Text("YY", style: TextStyles.textStyle20.apply(color: Colors.green)), + Text20("YY", color: Colors.green), Text20(" + floor("), - Text("YY", style: TextStyles.textStyle20.apply(color: Colors.green)), + Text20("YY", color: Colors.green), Text20(" / 4)) % 7"), ], ), @@ -76,9 +76,9 @@ class _YearInstructionPageState extends State { Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text("1", style: TextStyles.textStyle20.apply(color: Colors.blue)), - Text(" - ", style: TextStyles.textStyle20.apply(color: Colors.grey)), - Text("2", style: TextStyles.textStyle20.apply(color: Colors.grey)), + Text20("1", color: Colors.blue), + Text20(" - ", color: Colors.grey), + Text20("2", color: Colors.grey), ], ) ], @@ -101,7 +101,7 @@ class _YearInstructionPageState extends State { children: [ Text20("For "), Text20(centuriesString), - Text(year.toString().substring(2), style: TextStyles.textStyle20.apply(color: Colors.green)), + Text20(year.toString().substring(2), color: Colors.green), Text20(" our formula becomes: "), ], ), @@ -109,10 +109,10 @@ class _YearInstructionPageState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Text20("("), - Text(yyString, style: TextStyles.textStyle20.apply(color: Colors.green)), + Text20(yyString, color: Colors.green), Text20(" + floor("), - Text(yyString, style: TextStyles.textStyle20u.apply(color: Colors.green)), - Text20u(" / 4"), + Text20(yyString, color: Colors.green), + Text20(" / 4", decor: TextDecoration.underline), Text20(")) % 7"), ], ), @@ -121,9 +121,9 @@ class _YearInstructionPageState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Text20("("), - Text(yyString, style: TextStyles.textStyle20u.apply(color: Colors.green)), + Text20(yyString, color: Colors.green), Text20(" + "), - Text20u("floor(" + yyDiv4.toString() + ")"), + Text20("floor(" + yyDiv4.toString() + ")", decor: TextDecoration.underline), Text20(") % 7"), ], ), @@ -131,18 +131,18 @@ class _YearInstructionPageState extends State { Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text20u("("), - Text(yyString, style: TextStyles.textStyle20u.apply(color: Colors.green)), - Text20u(" + " + yyDiv4Floored.toString() + ")"), - Text20u(" % 7"), + Text20("(", decor: TextDecoration.underline), + Text20(yyString, color: Colors.green, decor: TextDecoration.underline), + Text20(" + " + yyDiv4Floored.toString() + ")", decor: TextDecoration.underline), + Text20(" % 7"), ], ), Text(glyph.unicodeGlyphs.downArrow, style: TextStyle(fontSize: 15)), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text20u((yy + yyDiv4Floored).toString()), - Text20u(" % 7"), + Text20((yy + yyDiv4Floored).toString(), decor: TextDecoration.underline), + Text20(" % 7", decor: TextDecoration.underline), ], ), Text(glyph.unicodeGlyphs.downArrow, style: TextStyle(fontSize: 15)), @@ -150,16 +150,16 @@ class _YearInstructionPageState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Text20("So the year value of " + year.toString() + " is: "), - Text20u(yearValue.toString()), + Text20(yearValue.toString(), decor: TextDecoration.underline), ], ), Spacer(), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text("1", style: TextStyles.textStyle20.apply(color: Colors.grey)), - Text(" - ", style: TextStyles.textStyle20.apply(color: Colors.grey)), - Text("2", style: TextStyles.textStyle20.apply(color: Colors.blue)), + Text20("1", color: Colors.grey), + Text20(" - ", color: Colors.grey), + Text20("2", color: Colors.blue), ], ) ] diff --git a/lib/util/TextStyles.dart b/lib/util/TextStyles.dart index 30e8f97..e72327a 100644 --- a/lib/util/TextStyles.dart +++ b/lib/util/TextStyles.dart @@ -1,4 +1,5 @@ import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; class TextStyles { static const TextStyle textStyle15 = TextStyle(fontSize: 15); @@ -24,14 +25,25 @@ class Text15 extends StatelessWidget { class Text20 extends StatelessWidget { final String text; + final TextDecoration decor; + final Color color; - Text20(this.text, {Key key}) : super(key: key); + Text20( + this.text, { + this.decor = TextDecoration.none, + this.color = Colors.black, + Key key + }) : super(key: key); @override Widget build(BuildContext context) { return Text( this.text, - style: TextStyles.textStyle20 + style: TextStyle( + fontSize: 20, + color: color, + decoration: decor, + ), ); } }