diff --git a/lib/providers/addictions_provider.dart b/lib/providers/addictions_provider.dart index ef126d7..0b5fb60 100644 --- a/lib/providers/addictions_provider.dart +++ b/lib/providers/addictions_provider.dart @@ -125,7 +125,7 @@ class AddictionsProvider with ChangeNotifier { } void reorderAddictions(int oldIndex, int newIndex) async { - // if reverting a delete, skip (see insertAddiction func.) + // if reverting a delete, skip (see insertAddiction funt.) if (oldIndex != _addictions.length) { Addiction temp = _addictions.removeAt(oldIndex); _addictions.insert(newIndex, temp); diff --git a/lib/screens/addiction_item_screen.dart b/lib/screens/addiction_item_screen.dart index ba464df..8e689cb 100644 --- a/lib/screens/addiction_item_screen.dart +++ b/lib/screens/addiction_item_screen.dart @@ -39,6 +39,7 @@ class _AddictionItemState extends State { @override Widget build(BuildContext context) { + final t = Theme.of(context); final AddictionItemScreenArgs args = ModalRoute.of(context).settings.arguments; final local = AppLocalizations.of(context); @@ -56,20 +57,20 @@ class _AddictionItemState extends State { PersistentBottomNavBarItem( icon: FaIcon(FontAwesomeIcons.infoCircle), title: (local.overview), - activeColor: Theme.of(context).primaryColor, - inactiveColor: Theme.of(context).hintColor, + activeColor: t.primaryColor, + inactiveColor: t.hintColor, ), PersistentBottomNavBarItem( icon: FaIcon(FontAwesomeIcons.gifts), title: (local.rewards), - activeColor: Theme.of(context).primaryColor, - inactiveColor: Theme.of(context).hintColor, + activeColor: t.primaryColor, + inactiveColor: t.hintColor, ), PersistentBottomNavBarItem( icon: FaIcon(FontAwesomeIcons.trophy), title: (local.achievements), - activeColor: Theme.of(context).primaryColor, - inactiveColor: Theme.of(context).hintColor, + activeColor: t.primaryColor, + inactiveColor: t.hintColor, ), ]; } @@ -96,14 +97,14 @@ class _AddictionItemState extends State { screens: _buildScreens(), items: _navBarItems(), confineInSafeArea: true, - backgroundColor: Theme.of(context).cardColor, + backgroundColor: t.cardColor, handleAndroidBackButtonPress: true, resizeToAvoidBottomInset: true, stateManagement: true, hideNavigationBarWhenKeyboardShows: true, decoration: NavBarDecoration( borderRadius: BorderRadius.circular(0.0), - colorBehindNavBar: Theme.of(context).canvasColor, + colorBehindNavBar: t.canvasColor, ), popAllScreensOnTapOfSelectedTab: true, popActionScreens: PopActionScreensType.all, diff --git a/lib/screens/addictions_screen.dart b/lib/screens/addictions_screen.dart index 93584fa..8d17d52 100644 --- a/lib/screens/addictions_screen.dart +++ b/lib/screens/addictions_screen.dart @@ -87,6 +87,7 @@ class _AddictionsScreenState extends State { @override Widget build(BuildContext context) { + final t = Theme.of(context); final deviceSize = MediaQuery.of(context).size; final local = AppLocalizations.of(context); @@ -114,7 +115,7 @@ class _AddictionsScreenState extends State { child: FloatingActionButton( heroTag: 'newAddiction', onPressed: pushCreateAddictionScreen, - backgroundColor: Theme.of(context).primaryColor, + backgroundColor: t.primaryColor, tooltip: local.newMsg, child: Icon(Icons.add), ), @@ -133,8 +134,8 @@ class _AddictionsScreenState extends State { _setProgNotifTasks(addictionsData.addictions); return addictionsData.addictions.length > 0 ? Theme( - data: Theme.of(context).copyWith( - cardColor: Theme.of(context).canvasColor, + data: t.copyWith( + cardColor: t.canvasColor, canvasColor: Colors.transparent, shadowColor: Colors.black26, ), @@ -167,11 +168,11 @@ class _AddictionsScreenState extends State { child: FloatingActionButton( heroTag: 'newAddiction', elevation: 0, - backgroundColor: Theme.of(context).primaryColor, - foregroundColor: Theme.of(context).canvasColor, + backgroundColor: t.primaryColor, + foregroundColor: t.canvasColor, child: Icon( Icons.add, - size: Theme.of(context).textTheme.headline1.fontSize, + size: t.textTheme.headline1.fontSize, ), onPressed: null, ), @@ -184,9 +185,8 @@ class _AddictionsScreenState extends State { child: Text( local.appName, style: TextStyle( - fontSize: - Theme.of(context).textTheme.headline2.fontSize, - color: Theme.of(context).primaryColor, + fontSize: t.textTheme.headline2.fontSize, + color: t.primaryColor, fontWeight: FontWeight.bold, ), ), diff --git a/lib/screens/create_addiction_screen.dart b/lib/screens/create_addiction_screen.dart index c1c7661..e13ed3e 100644 --- a/lib/screens/create_addiction_screen.dart +++ b/lib/screens/create_addiction_screen.dart @@ -17,13 +17,14 @@ class CreateAddictionScreen extends StatelessWidget { @override Widget build(BuildContext context) { + final t = Theme.of(context); final statusBarHeight = MediaQuery.of(context).padding.top; return Hero( tag: 'newAddiction', transitionOnUserGestures: true, child: Scaffold( appBar: AppBar( - backgroundColor: Theme.of(context).primaryColor, + backgroundColor: t.primaryColor, ), body: AddictionCard(statusBarHeight), ), @@ -182,12 +183,13 @@ class _AddictionCardState extends State @override Widget build(BuildContext context) { + final t = Theme.of(context); final local = AppLocalizations.of(context); final deviceSize = MediaQuery.of(context).size; return Container( margin: EdgeInsets.zero, - color: Theme.of(context).cardColor, + color: t.cardColor, child: Form( key: _formKey, child: SingleChildScrollView( @@ -216,11 +218,11 @@ class _AddictionCardState extends State children: [ Material( type: MaterialType.button, - color: Theme.of(context).canvasColor, + color: t.canvasColor, borderRadius: BorderRadius.circular(5), child: InkWell( borderRadius: BorderRadius.circular(5), - splashColor: Theme.of(context).highlightColor, + splashColor: t.highlightColor, onTap: () { setState(() { FocusScope.of(context).unfocus(); @@ -231,7 +233,7 @@ class _AddictionCardState extends State }); }, child: Container( - height: Theme.of(context).buttonTheme.height * 2, + height: t.buttonTheme.height * 2, padding: const EdgeInsets.all(10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -246,7 +248,7 @@ class _AddictionCardState extends State .subtitle2 .fontSize, fontWeight: FontWeight.bold, - color: Theme.of(context).hintColor, + color: t.hintColor, ), ), Wrap( @@ -261,12 +263,12 @@ class _AddictionCardState extends State addictionData['quit_date']), ), style: TextStyle( - color: Theme.of(context).hintColor, + color: t.hintColor, ), ), Icon( Icons.date_range, - color: Theme.of(context).hintColor, + color: t.hintColor, ), ], ), @@ -277,12 +279,12 @@ class _AddictionCardState extends State ), Material( type: MaterialType.button, - color: Theme.of(context).canvasColor, + color: t.canvasColor, borderRadius: BorderRadius.circular(5), child: InkWell( focusNode: _focusNode, borderRadius: BorderRadius.circular(5), - splashColor: Theme.of(context).highlightColor, + splashColor: t.highlightColor, onTap: () { setState(() { showModalBottomSheet( @@ -290,7 +292,7 @@ class _AddictionCardState extends State context: context, builder: (context) => Container( decoration: BoxDecoration( - color: Theme.of(context).cardColor, + color: t.cardColor, borderRadius: BorderRadius.only( topLeft: Radius.circular(10), topRight: Radius.circular(10), @@ -318,13 +320,12 @@ class _AddictionCardState extends State }, icon: Icon( Icons.iso_outlined, - color: Theme.of(context).hintColor, + color: t.hintColor, ), label: Text( local.quantity, style: TextStyle( - color: - Theme.of(context).hintColor, + color: t.hintColor, fontWeight: FontWeight.bold, ), ), @@ -351,13 +352,12 @@ class _AddictionCardState extends State }, icon: Icon( Icons.hourglass_bottom_rounded, - color: Theme.of(context).hintColor, + color: t.hintColor, ), label: Text( local.hour(0), style: TextStyle( - color: - Theme.of(context).hintColor, + color: t.hintColor, fontWeight: FontWeight.bold, ), ), @@ -369,11 +369,11 @@ class _AddictionCardState extends State }); }, child: Container( - height: Theme.of(context).buttonTheme.height * 2, + height: t.buttonTheme.height * 2, padding: const EdgeInsets.all(10), decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), - color: Theme.of(context).canvasColor, + color: t.canvasColor, ), child: Column( mainAxisAlignment: @@ -388,7 +388,7 @@ class _AddictionCardState extends State .subtitle2 .fontSize, fontWeight: FontWeight.bold, - color: Theme.of(context).hintColor, + color: t.hintColor, ), ), Text( @@ -400,7 +400,7 @@ class _AddictionCardState extends State .textTheme .subtitle2 .fontSize, - color: Theme.of(context).hintColor, + color: t.hintColor, ), ), ], @@ -456,8 +456,7 @@ class _AddictionCardState extends State child: Text( local.quitAddiction, style: TextStyle( - fontSize: - Theme.of(context).textTheme.headline6.fontSize, + fontSize: t.textTheme.headline6.fontSize, ), ), ), diff --git a/lib/widgets/achievements.dart b/lib/widgets/achievements.dart index dcc6ea6..c96b7c6 100644 --- a/lib/widgets/achievements.dart +++ b/lib/widgets/achievements.dart @@ -105,6 +105,7 @@ class _AchievementsState extends State { @override Widget build(BuildContext context) { final deviceSize = MediaQuery.of(context).size; + final t = Theme.of(context); final double tileHeight = deviceSize.width; double totalHeight = 0.0; @@ -138,7 +139,7 @@ class _AchievementsState extends State { LiquidLinearProgressIndicator( value: .8, valueColor: AlwaysStoppedAnimation( - Theme.of(context).accentColor.withOpacity(.5), + t.accentColor.withOpacity(.5), ), backgroundColor: Colors.transparent, direction: Axis.vertical, @@ -157,7 +158,7 @@ class _AchievementsState extends State { FontAwesomeIcons.checkCircle, color: achLevel == maxAchLevel ? Colors.amber - : Theme.of(context).highlightColor, + : t.highlightColor, size: tileHeight / 2, ), ), @@ -173,8 +174,8 @@ class _AchievementsState extends State { decoration: BoxDecoration( gradient: LinearGradient( colors: [ - Theme.of(context).accentColor, - Theme.of(context).accentColor.withOpacity(.5), + t.accentColor, + t.accentColor.withOpacity(.5), ], stops: [percentage.clamp(.0, .8), 1], begin: Alignment.bottomCenter, @@ -191,10 +192,7 @@ class _AchievementsState extends State { // subtitle: localizedAchDurations[index + 1], level: index + 1, height: achievementHeights[index], - trophySize: Theme.of(context) - .textTheme - .headline3 - .fontSize * + trophySize: t.textTheme.headline3.fontSize * (index + 1).clamp(0.0, deviceSize.width * .5), active: index + 1 <= achLevel ? true : false, ), @@ -263,8 +261,8 @@ class _TrophyState extends State { @override Widget build(BuildContext context) { - final color = - widget.active ? Colors.amber : Theme.of(context).highlightColor; + final t = Theme.of(context); + final color = widget.active ? Colors.amber : t.highlightColor; final stars = List.filled( widget.level, FaIcon( @@ -275,16 +273,16 @@ class _TrophyState extends State { ); final bool isTitleOverflowed = widget.trophySize / widget.title.length < - Theme.of(context).textTheme.bodyText1.fontSize; + t.textTheme.bodyText1.fontSize; final bool isSubtitleOverflowed = widget.trophySize / widget.subtitle.length < - Theme.of(context).textTheme.bodyText1.fontSize; + t.textTheme.bodyText1.fontSize; return ConfettiWidget( confettiController: _confettiController, blastDirectionality: BlastDirectionality.explosive, colors: [ - Theme.of(context).primaryColor, + t.primaryColor, Colors.amber, ], numberOfParticles: widget.level, @@ -302,7 +300,7 @@ class _TrophyState extends State { Padding( padding: EdgeInsets.only( top: isTitleOverflowed - ? Theme.of(context).textTheme.bodyText1.fontSize * + ? t.textTheme.bodyText1.fontSize * (isSubtitleOverflowed ? 2 : 1) : 0.0, ), @@ -318,23 +316,23 @@ class _TrophyState extends State { widget.title, style: TextStyle( color: !widget.active - ? Theme.of(context).hintColor.withOpacity(.5) + ? t.hintColor.withOpacity(.5) : isTitleOverflowed ? Colors.amber - : Theme.of(context).accentColor, + : t.accentColor, ), ), ), Positioned( top: isSubtitleOverflowed - ? Theme.of(context).textTheme.bodyText1.fontSize + ? t.textTheme.bodyText1.fontSize : widget.trophySize * .4, child: Text( widget.subtitle, style: TextStyle( color: widget.active ? Colors.amber - : Theme.of(context).hintColor.withOpacity(.5), + : t.hintColor.withOpacity(.5), ), ), ), diff --git a/lib/widgets/addiction_details.dart b/lib/widgets/addiction_details.dart index aa7263e..da447d2 100644 --- a/lib/widgets/addiction_details.dart +++ b/lib/widgets/addiction_details.dart @@ -16,6 +16,7 @@ class AddictionDetails extends StatelessWidget { @override Widget build(BuildContext context) { + final t = Theme.of(context); final double notUsedCount = addictionData.notUsedCount; final Duration abstinenceTime = addictionData.abstinenceTime; final double dailySavings = @@ -33,9 +34,9 @@ class AddictionDetails extends StatelessWidget { )); return DefaultTextStyle( - style: Theme.of(context).textTheme.bodyText2.copyWith( - fontWeight: FontWeight.bold, - ), + style: t.textTheme.bodyText2.copyWith( + fontWeight: FontWeight.bold, + ), child: Padding( padding: const EdgeInsets.all(16.0), child: Wrap( diff --git a/lib/widgets/addiction_item.dart b/lib/widgets/addiction_item.dart index 32405c9..9fe3fd4 100644 --- a/lib/widgets/addiction_item.dart +++ b/lib/widgets/addiction_item.dart @@ -14,18 +14,17 @@ class AddictionItem extends StatelessWidget { @override Widget build(BuildContext context) { + final t = Theme.of(context); final isDark = MediaQuery.of(context).platformBrightness == Brightness.dark; return Container( - color: isDark - ? Theme.of(context).highlightColor.withOpacity(.1) - : Theme.of(context).accentColor, + color: isDark ? t.highlightColor.withOpacity(.1) : t.accentColor, child: SingleChildScrollView( child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - color: Theme.of(context).canvasColor, + color: t.canvasColor, child: AddictionProgress( addictionData: args.data, ), diff --git a/lib/widgets/addiction_item_card.dart b/lib/widgets/addiction_item_card.dart index 8b7c263..00f12c1 100644 --- a/lib/widgets/addiction_item_card.dart +++ b/lib/widgets/addiction_item_card.dart @@ -30,6 +30,7 @@ class AddictionItemCard extends StatelessWidget { @override Widget build(BuildContext context) { + final t = Theme.of(context); final local = AppLocalizations.of(context); final isDark = MediaQuery.of(context).platformBrightness == Brightness.dark; @@ -58,20 +59,16 @@ class AddictionItemCard extends StatelessWidget { width: 0, style: BorderStyle.none, ), - color: isDark - ? Theme.of(context).highlightColor.withOpacity(.1) - : Theme.of(context).accentColor, + color: isDark ? t.highlightColor.withOpacity(.1) : t.accentColor, ), padding: const EdgeInsets.only(bottom: 4), child: OpenContainer( - closedColor: isDark - ? Theme.of(context).highlightColor.withOpacity(.1) - : Theme.of(context).accentColor, + closedColor: isDark ? t.highlightColor.withOpacity(.1) : t.accentColor, closedShape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), side: BorderSide( width: 3, - color: Theme.of(context).highlightColor, + color: t.highlightColor, ), ), transitionDuration: Duration(milliseconds: 250), @@ -98,7 +95,7 @@ class AddictionItemCard extends StatelessWidget { actions: [ IconSlideAction( caption: local.share, - color: Theme.of(context).accentColor, + color: t.accentColor, icon: Icons.share, onTap: _share, ), @@ -106,7 +103,7 @@ class AddictionItemCard extends StatelessWidget { secondaryActions: [ IconSlideAction( caption: local.delete, - color: Theme.of(context).errorColor, + color: t.errorColor, icon: Icons.delete, ), ], @@ -117,7 +114,7 @@ class AddictionItemCard extends StatelessWidget { shape: RoundedRectangleBorder( side: BorderSide( width: 1, - color: Theme.of(context).highlightColor, + color: t.highlightColor, ), ), child: Padding( @@ -140,8 +137,7 @@ class AddictionItemCard extends StatelessWidget { .textTheme .headline5 .fontSize, - color: - Theme.of(context).textTheme.bodyText1.color, + color: t.textTheme.bodyText1.color, ), ), ), diff --git a/lib/widgets/addiction_progress.dart b/lib/widgets/addiction_progress.dart index ad56938..9534d6e 100644 --- a/lib/widgets/addiction_progress.dart +++ b/lib/widgets/addiction_progress.dart @@ -18,6 +18,7 @@ class AddictionProgress extends StatelessWidget { @override Widget build(BuildContext context) { + final t = Theme.of(context); final local = AppLocalizations.of(context); final consumptionType = (addictionData.consumptionType == 1) ? local.hour(addictionData.notUsedCount.toInt()) @@ -36,11 +37,10 @@ class AddictionProgress extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ DefaultTextStyle( - style: Theme.of(context).textTheme.bodyText1.copyWith( - fontSize: - Theme.of(context).textTheme.subtitle1.fontSize, - fontWeight: FontWeight.bold, - ), + style: t.textTheme.bodyText1.copyWith( + fontSize: t.textTheme.subtitle1.fontSize, + fontWeight: FontWeight.bold, + ), child: Column( children: [ Text( @@ -59,11 +59,10 @@ class AddictionProgress extends StatelessWidget { thickness: 0, ), DefaultTextStyle( - style: Theme.of(context).textTheme.bodyText1.copyWith( - fontSize: - Theme.of(context).textTheme.subtitle1.fontSize, - fontWeight: FontWeight.bold, - ), + style: t.textTheme.bodyText1.copyWith( + fontSize: t.textTheme.subtitle1.fontSize, + fontWeight: FontWeight.bold, + ), child: FittedBox( fit: BoxFit.contain, child: addictionData.unitCost == 0 diff --git a/lib/widgets/currency_picker.dart b/lib/widgets/currency_picker.dart index c548ff9..1f418fb 100644 --- a/lib/widgets/currency_picker.dart +++ b/lib/widgets/currency_picker.dart @@ -35,12 +35,13 @@ class _CurrencyPickerState extends State { @override Widget build(BuildContext context) { + final t = Theme.of(context); final mediaQuery = MediaQuery.of(context); final deviceHeight = mediaQuery.size.height; final deviceWidth = mediaQuery.size.width; return new SimpleDialog( - backgroundColor: Theme.of(context).cardColor, + backgroundColor: t.cardColor, contentPadding: EdgeInsets.zero, children: [ SingleChildScrollView( @@ -56,10 +57,10 @@ class _CurrencyPickerState extends State { BeveledRectangleBorder(), ), backgroundColor: MaterialStateProperty.all( - Theme.of(context).canvasColor, + t.canvasColor, ), foregroundColor: MaterialStateProperty.all( - Theme.of(context).hintColor, + t.hintColor, ), tapTargetSize: MaterialTapTargetSize.shrinkWrap, padding: MaterialStateProperty.all( @@ -75,7 +76,7 @@ class _CurrencyPickerState extends State { child: Text( _currencies[index]['code'], style: TextStyle( - color: Theme.of(context).accentColor, + color: t.accentColor, ), ), ), diff --git a/lib/widgets/custom_text_form_field.dart b/lib/widgets/custom_text_form_field.dart index 41344e9..5ac1d98 100644 --- a/lib/widgets/custom_text_form_field.dart +++ b/lib/widgets/custom_text_form_field.dart @@ -32,6 +32,7 @@ class CustomTextFormField extends StatelessWidget { if (onSubmit == null && inputAction == TextInputAction.done) throw 'Error: onSubmit == null && inputAction == TextInputAction.done. Provide an onSubmit function.'; + final t = Theme.of(context); return TextFormField( onFieldSubmitted: (_) { if (inputAction != TextInputAction.done) return; @@ -41,9 +42,7 @@ class CustomTextFormField extends StatelessWidget { key: ValueKey(valKey), decoration: InputDecoration( filled: true, - fillColor: backgroundColor != null - ? backgroundColor - : Theme.of(context).canvasColor, + fillColor: backgroundColor != null ? backgroundColor : t.canvasColor, border: OutlineInputBorder( borderRadius: BorderRadius.circular(5), borderSide: BorderSide( @@ -55,7 +54,7 @@ class CustomTextFormField extends StatelessWidget { borderRadius: BorderRadius.circular(5), borderSide: BorderSide( width: 0, - color: Theme.of(context).primaryColorDark, + color: t.primaryColorDark, style: BorderStyle.solid, ), ), @@ -65,9 +64,9 @@ class CustomTextFormField extends StatelessWidget { ), ), style: TextStyle( - color: Theme.of(context).hintColor, + color: t.hintColor, ), - cursorColor: Theme.of(context).primaryColor, + cursorColor: t.primaryColor, keyboardType: inputType, validator: validator, textInputAction: inputAction, diff --git a/lib/widgets/gifts.dart b/lib/widgets/gifts.dart index f4907d3..7f4ff70 100644 --- a/lib/widgets/gifts.dart +++ b/lib/widgets/gifts.dart @@ -70,6 +70,7 @@ class _GiftsState extends State { @override Widget build(BuildContext context) { + final t = Theme.of(context); final local = AppLocalizations.of(context); final deviceSize = MediaQuery.of(context).size; @@ -100,7 +101,7 @@ class _GiftsState extends State { Text( local.available + ' ', style: TextStyle( - color: Theme.of(context).hintColor, + color: t.hintColor, fontWeight: FontWeight.bold, ), ), @@ -121,7 +122,7 @@ class _GiftsState extends State { Text( local.spent + ' ', style: TextStyle( - color: Theme.of(context).hintColor, + color: t.hintColor, fontWeight: FontWeight.bold, ), ), @@ -182,6 +183,7 @@ class _GiftCardState extends State { @override Widget build(BuildContext context) { + final t = Theme.of(context); final local = AppLocalizations.of(context); final materialLocal = MaterialLocalizations.of(context); final deviceSize = MediaQuery.of(context).size; @@ -238,7 +240,7 @@ class _GiftCardState extends State { borderRadius: BorderRadius.circular(5), side: BorderSide( width: 8, - color: Theme.of(context).highlightColor, + color: t.highlightColor, ), ), child: InkWell( @@ -278,7 +280,7 @@ class _GiftCardState extends State { ), ), child: DefaultTextStyle( - style: Theme.of(context).textTheme.bodyText1, + style: t.textTheme.bodyText1, child: Padding( padding: const EdgeInsets.all(16.0), child: Flex( @@ -295,38 +297,6 @@ class _GiftCardState extends State { ), ), ), - // Flexible( - // flex: 6, - // fit: FlexFit.tight, - // child: Row( - // mainAxisAlignment: MainAxisAlignment.center, - // crossAxisAlignment: CrossAxisAlignment.stretch, - // children: [ - // Text( - // (percentage * 100).toStringAsFixed(2), - // style: TextStyle( - // fontWeight: - // percentage == 1 ? FontWeight.w900 : null, - // fontSize: Theme.of(context) - // .textTheme - // .headline6 - // .fontSize, - // ), - // ), - // Text( - // '%', - // style: TextStyle( - // fontWeight: - // percentage == 1 ? FontWeight.w900 : null, - // fontSize: Theme.of(context) - // .textTheme - // .bodyText1 - // .fontSize, - // ), - // ), - // ], - // ), - // ), Flexible( flex: 2, fit: FlexFit.tight, @@ -371,9 +341,9 @@ class _GiftCardState extends State { ClipRRect( borderRadius: BorderRadius.circular(5), child: LinearProgressIndicator( - backgroundColor: Theme.of(context).cardColor, + backgroundColor: t.cardColor, valueColor: AlwaysStoppedAnimation( - Theme.of(context).accentColor.withOpacity(.8), + t.accentColor.withOpacity(.8), ), value: percentage, ), @@ -409,7 +379,7 @@ class _GiftCardState extends State { flex: 1, child: Icon( Icons.drag_handle_rounded, - color: Theme.of(context).highlightColor, + color: t.highlightColor, ), ), ], @@ -426,14 +396,14 @@ class _GiftCardState extends State { type: MaterialType.circle, color: Colors.transparent, child: InkWell( - splashColor: Theme.of(context).errorColor, + splashColor: t.errorColor, customBorder: CircleBorder(), child: Padding( padding: const EdgeInsets.all(8.0), child: Icon( Icons.delete, - color: Theme.of(context).errorColor.withOpacity(.8), - size: Theme.of(context).textTheme.headline6.fontSize, + color: t.errorColor.withOpacity(.8), + size: t.textTheme.headline6.fontSize, ), ), onLongPress: _deleteDialog, @@ -453,20 +423,21 @@ class AddGiftButton extends StatelessWidget { @override Widget build(BuildContext context) { + final t = Theme.of(context); final deviceSize = MediaQuery.of(context).size; return ClipRRect( borderRadius: BorderRadius.circular(5), child: Container( height: deviceSize.width * .46, width: deviceSize.width * .46, - color: Theme.of(context).highlightColor, + color: t.highlightColor, child: Material( type: MaterialType.transparency, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(5), side: BorderSide( width: 8, - color: Theme.of(context).highlightColor, + color: t.highlightColor, ), ), child: InkWell( @@ -482,8 +453,8 @@ class AddGiftButton extends StatelessWidget { child: Center( child: Icon( Icons.add, - size: Theme.of(context).textTheme.headline4.fontSize, - // color: Theme.of(context).hintColor, + size: t.textTheme.headline4.fontSize, + // color: t.hintColor, ), ), ), diff --git a/lib/widgets/gifts_create.dart b/lib/widgets/gifts_create.dart index 0afecf2..dff4f1e 100644 --- a/lib/widgets/gifts_create.dart +++ b/lib/widgets/gifts_create.dart @@ -52,20 +52,21 @@ class _CreateGiftNoteState extends State { @override Widget build(BuildContext context) { + final t = Theme.of(context); final local = AppLocalizations.of(context); - final inputBackgroundColor = Theme.of(context).canvasColor; - final buttonHeight = Theme.of(context).buttonTheme.height * 2; + final inputBackgroundColor = t.canvasColor; + final buttonHeight = t.buttonTheme.height * 2; return DefaultTextStyle( style: TextStyle( - color: Theme.of(context).hintColor, + color: t.hintColor, fontWeight: FontWeight.bold, ), child: Form( key: _formKey, child: Container( decoration: BoxDecoration( - color: Theme.of(context).cardColor, + color: t.cardColor, borderRadius: BorderRadius.only( topLeft: Radius.circular(10), topRight: Radius.circular(10), @@ -120,12 +121,12 @@ class _CreateGiftNoteState extends State { children: [ Icon( Icons.save, - color: Theme.of(context).primaryColorLight, + color: t.primaryColorLight, ), Text( local.save, style: TextStyle( - color: Theme.of(context).primaryColorLight, + color: t.primaryColorLight, fontWeight: FontWeight.bold, ), ), diff --git a/lib/widgets/note.dart b/lib/widgets/note.dart index ae28acb..e3ac803 100644 --- a/lib/widgets/note.dart +++ b/lib/widgets/note.dart @@ -13,16 +13,17 @@ class Note extends StatelessWidget { @override Widget build(BuildContext context) { + final t = Theme.of(context); final _controller = TextEditingController(text: data.text); final local = AppLocalizations.of(context); final quitDateFormatted = DateFormat.yMMMd(local.localeName).format(DateTime.parse(data.date)); return Container( decoration: BoxDecoration( - color: Theme.of(context).canvasColor, + color: t.canvasColor, borderRadius: BorderRadius.circular(5.0), border: Border.all( - color: Theme.of(context).highlightColor, + color: t.highlightColor, width: 1, ), ), @@ -42,7 +43,7 @@ class Note extends StatelessWidget { child: Text( data.title, style: TextStyle( - color: Theme.of(context).hintColor, + color: t.hintColor, fontWeight: FontWeight.bold, ), ), @@ -54,7 +55,7 @@ class Note extends StatelessWidget { quitDateFormatted, textAlign: TextAlign.right, style: TextStyle( - color: Theme.of(context).hintColor, + color: t.hintColor, fontWeight: FontWeight.bold, ), ), @@ -71,7 +72,7 @@ class Note extends StatelessWidget { scrollPhysics: PageScrollPhysics(), enabled: true, style: TextStyle( - color: Theme.of(context).hintColor, + color: t.hintColor, fontWeight: FontWeight.normal, ), decoration: InputDecoration( diff --git a/lib/widgets/personal_note_create.dart b/lib/widgets/personal_note_create.dart index 462926d..249f308 100644 --- a/lib/widgets/personal_note_create.dart +++ b/lib/widgets/personal_note_create.dart @@ -73,21 +73,22 @@ class _CreatePersonalNoteState extends State { @override Widget build(BuildContext context) { + final t = Theme.of(context); final local = AppLocalizations.of(context); final deviceWidth = MediaQuery.of(context).size.width; - final inputBackgroundColor = Theme.of(context).canvasColor; - final buttonHeight = Theme.of(context).buttonTheme.height * 2; + final inputBackgroundColor = t.canvasColor; + final buttonHeight = t.buttonTheme.height * 2; return DefaultTextStyle( style: TextStyle( - color: Theme.of(context).hintColor, + color: t.hintColor, fontWeight: FontWeight.bold, ), child: Form( key: _formKey, child: Container( decoration: BoxDecoration( - color: Theme.of(context).cardColor, + color: t.cardColor, borderRadius: BorderRadius.only( topLeft: Radius.circular(10), topRight: Radius.circular(10), @@ -111,7 +112,7 @@ class _CreatePersonalNoteState extends State { backgroundColor: inputBackgroundColor, ), TextFormField( - cursorColor: Theme.of(context).primaryColor, + cursorColor: t.primaryColor, decoration: InputDecoration( filled: true, fillColor: inputBackgroundColor, @@ -126,14 +127,14 @@ class _CreatePersonalNoteState extends State { borderRadius: BorderRadius.circular(5), borderSide: BorderSide( width: 0, - color: Theme.of(context).primaryColorLight, + color: t.primaryColorLight, style: BorderStyle.solid, ), ), hintText: local.note, ), style: TextStyle( - color: Theme.of(context).hintColor, + color: t.hintColor, ), keyboardType: TextInputType.multiline, textInputAction: TextInputAction.newline, @@ -160,7 +161,7 @@ class _CreatePersonalNoteState extends State { }); } }, - splashColor: Theme.of(context).primaryColor, + splashColor: t.primaryColor, borderRadius: BorderRadius.circular(5), child: Padding( padding: const EdgeInsets.all(10), @@ -173,14 +174,14 @@ class _CreatePersonalNoteState extends State { DateTime.parse(noteData['date']), ), style: TextStyle( - color: Theme.of(context).hintColor, + color: t.hintColor, fontWeight: FontWeight.bold), ), SizedBox( width: deviceWidth * .1, child: Icon( Icons.date_range, - color: Theme.of(context).primaryColor, + color: t.primaryColor, ), ), ], @@ -201,19 +202,18 @@ class _CreatePersonalNoteState extends State { }, child: Padding( padding: EdgeInsets.symmetric( - horizontal: - Theme.of(context).textTheme.headline6.fontSize, + horizontal: t.textTheme.headline6.fontSize, ), child: Row( children: [ Icon( Icons.save, - color: Theme.of(context).primaryColor, + color: t.primaryColor, ), Text( local.save, style: TextStyle( - color: Theme.of(context).primaryColor, + color: t.primaryColor, fontWeight: FontWeight.bold, ), ), diff --git a/lib/widgets/personal_notes_view.dart b/lib/widgets/personal_notes_view.dart index 7bba6a4..7308f6d 100644 --- a/lib/widgets/personal_notes_view.dart +++ b/lib/widgets/personal_notes_view.dart @@ -20,6 +20,7 @@ class PersonalNotesView extends StatefulWidget { class _PersonalNotesViewState extends State { @override Widget build(BuildContext context) { + final t = Theme.of(context); final local = AppLocalizations.of(context); return Stack( alignment: Alignment.topCenter, @@ -84,7 +85,7 @@ class _PersonalNotesViewState extends State { }, ); }, - backgroundColor: Theme.of(context).primaryColor, + backgroundColor: t.primaryColor, child: Icon( Icons.add, color: Colors.white, diff --git a/lib/widgets/settings_view.dart b/lib/widgets/settings_view.dart index e5d3e61..e6673b5 100644 --- a/lib/widgets/settings_view.dart +++ b/lib/widgets/settings_view.dart @@ -37,8 +37,8 @@ class _SettingsViewState extends State { @override Widget build(BuildContext context) { + final t = Theme.of(context); final local = AppLocalizations.of(context); - final isDark = MediaQuery.of(context).platformBrightness == Brightness.dark; return Drawer( child: LayoutBuilder( @@ -63,7 +63,7 @@ class _SettingsViewState extends State { border: Border( bottom: BorderSide( width: 0, - color: Theme.of(context).primaryColor, + color: t.primaryColor, ), ), ), @@ -75,7 +75,7 @@ class _SettingsViewState extends State { .headline6 .fontSize, fontWeight: FontWeight.bold, - color: Theme.of(context).primaryColor, + color: t.primaryColor, ), ), ), @@ -89,11 +89,11 @@ class _SettingsViewState extends State { subtitle: Text( local.progressNotificationDesc, style: TextStyle( - color: Theme.of(context).hintColor, + color: t.hintColor, ), ), value: _progressCheck, - activeColor: Theme.of(context).accentColor, + activeColor: t.accentColor, onChanged: (value) { if (mounted) { setState(() { @@ -116,11 +116,11 @@ class _SettingsViewState extends State { subtitle: Text( local.quoteOfTheDayDesc, style: TextStyle( - color: Theme.of(context).hintColor, + color: t.hintColor, ), ), value: _quoteCheck, - activeColor: Theme.of(context).accentColor, + activeColor: t.accentColor, onChanged: (value) { if (mounted) { setState(() { @@ -151,7 +151,7 @@ class _SettingsViewState extends State { .textTheme .subtitle2 .fontSize, - color: Theme.of(context).hintColor, + color: t.hintColor, ), ), trailing: Text( @@ -160,7 +160,7 @@ class _SettingsViewState extends State { locale: local.localeName, ).currencySymbol})', style: TextStyle( - color: Theme.of(context).accentColor, + color: t.accentColor, fontWeight: FontWeight.bold, fontSize: Theme.of(context) .textTheme @@ -188,7 +188,7 @@ class _SettingsViewState extends State { Text( local.appName.toUpperCase(), style: TextStyle( - color: Theme.of(context).primaryColor, + color: t.primaryColor, fontWeight: FontWeight.bold, ), ), @@ -197,7 +197,7 @@ class _SettingsViewState extends State { IconButton( icon: FaIcon( FontAwesomeIcons.infoCircle, - color: Theme.of(context).primaryColor, + color: t.primaryColor, ), tooltip: local.licenses, onPressed: () { diff --git a/lib/widgets/target_duration_indicator.dart b/lib/widgets/target_duration_indicator.dart index 6f2ecb5..c66e869 100644 --- a/lib/widgets/target_duration_indicator.dart +++ b/lib/widgets/target_duration_indicator.dart @@ -15,6 +15,7 @@ class TargetDurationIndicator extends StatelessWidget { @override Widget build(BuildContext context) { + final t = Theme.of(context); final Duration time = data.abstinenceTime; String targetUnit; int targetValue; @@ -65,27 +66,27 @@ class TargetDurationIndicator extends StatelessWidget { infoProperties: InfoProperties( bottomLabelText: targetValue.toString() + ' ' + targetUnit, bottomLabelStyle: TextStyle( - color: Theme.of(context).hintColor, + color: t.hintColor, fontWeight: FontWeight.bold, ), mainLabelStyle: TextStyle( - color: Theme.of(context).primaryColor, - fontSize: Theme.of(context).textTheme.headline5.fontSize, + color: t.primaryColor, + fontSize: t.textTheme.headline5.fontSize, fontWeight: FontWeight.bold, ), ), customWidths: CustomSliderWidths( handlerSize: 0, - progressBarWidth: Theme.of(context).textTheme.bodyText1.fontSize, - trackWidth: Theme.of(context).textTheme.bodyText1.fontSize, + progressBarWidth: t.textTheme.bodyText1.fontSize, + trackWidth: t.textTheme.bodyText1.fontSize, ), customColors: CustomSliderColors( hideShadow: true, progressBarColors: [ - Theme.of(context).accentColor, - Theme.of(context).accentColor.withOpacity(.5), + t.accentColor, + t.accentColor.withOpacity(.5), ], - trackColor: Theme.of(context).accentColor.withAlpha(100), + trackColor: t.accentColor.withAlpha(100), ), animationEnabled: false, ),