diff --git a/lib/core/core.dart b/lib/core/core.dart index 5349e1e7..9b5d06d2 100644 --- a/lib/core/core.dart +++ b/lib/core/core.dart @@ -3,3 +3,5 @@ import 'package:flutter_dotenv/flutter_dotenv.dart'; part 'config/network_config.dart'; part 'utils/text_style.ext.dart'; +part 'theme/theme.ext.dart'; +part 'theme/app_color_scheme.dart'; diff --git a/lib/core/theme/app_color_scheme.dart b/lib/core/theme/app_color_scheme.dart new file mode 100644 index 00000000..28478b68 --- /dev/null +++ b/lib/core/theme/app_color_scheme.dart @@ -0,0 +1,226 @@ +part of '../core.dart'; + +@immutable +class CollactionTheme extends ThemeExtension { + final Color? primaryColor; + final Color? secondaryColor; + final Color? accentColor; + + final Color? shadowColor; + + final Color? inactiveColor; + final Color? almostTransparent; + final Color? secondaryTransparent; + + final Color? enabledButtonColor; + final Color? disabledButtonColor; + + final Color? errorColor; + final Color? successColor; + + final Color? irisColor; + + final Color? primaryColor0; + final Color? primaryColor100; + final Color? primaryColor200; + final Color? primaryColor300; + final Color? primaryColor400; + final Color? primaryColor500; + + final TextStyle? caption1; + final TextStyle? body; + final TextStyle? title1; + + const CollactionTheme({ + required this.primaryColor, + required this.secondaryColor, + required this.accentColor, + required this.shadowColor, + required this.inactiveColor, + required this.almostTransparent, + required this.secondaryTransparent, + required this.enabledButtonColor, + required this.disabledButtonColor, + required this.errorColor, + required this.successColor, + required this.irisColor, + required this.primaryColor0, + required this.primaryColor100, + required this.primaryColor200, + required this.primaryColor300, + required this.primaryColor400, + required this.primaryColor500, + required this.caption1, + required this.body, + required this.title1, + }); + + @override + ThemeExtension copyWith({ + Color? primaryColor, + Color? secondaryColor, + Color? accentColor, + Color? shadowColor, + Color? inactiveColor, + Color? almostTransparent, + Color? secondaryTransparent, + Color? enabledButtonColor, + Color? disabledButtonColor, + Color? errorColor, + Color? successColor, + Color? irisColor, + Color? primaryColor0, + Color? primaryColor100, + Color? primaryColor200, + Color? primaryColor300, + Color? primaryColor400, + Color? primaryColor500, + TextStyle? caption1, + TextStyle? body, + TextStyle? title1, + }) { + return CollactionTheme( + primaryColor: primaryColor ?? this.primaryColor, + secondaryColor: secondaryColor ?? this.secondaryColor, + accentColor: accentColor ?? this.accentColor, + shadowColor: shadowColor ?? this.shadowColor, + inactiveColor: inactiveColor ?? this.inactiveColor, + almostTransparent: almostTransparent ?? this.almostTransparent, + secondaryTransparent: secondaryTransparent ?? this.secondaryTransparent, + enabledButtonColor: enabledButtonColor ?? this.enabledButtonColor, + disabledButtonColor: disabledButtonColor ?? this.disabledButtonColor, + errorColor: errorColor ?? this.errorColor, + successColor: successColor ?? this.successColor, + irisColor: irisColor ?? this.irisColor, + primaryColor0: primaryColor0 ?? this.primaryColor0, + primaryColor100: primaryColor100 ?? this.primaryColor100, + primaryColor200: primaryColor200 ?? this.primaryColor200, + primaryColor300: primaryColor300 ?? this.primaryColor300, + primaryColor400: primaryColor400 ?? this.primaryColor400, + primaryColor500: primaryColor500 ?? this.primaryColor500, + caption1: caption1 ?? this.caption1, + body: body ?? this.body, + title1: title1 ?? this.title1, + ); + } + + @override + ThemeExtension lerp( + covariant ThemeExtension? other, double t) { + if (other is! CollactionTheme) { + return this; + } + + return CollactionTheme( + primaryColor: Color.lerp(primaryColor, other.primaryColor, t), + secondaryColor: Color.lerp(secondaryColor, other.secondaryColor, t), + accentColor: Color.lerp(accentColor, other.accentColor, t), + shadowColor: Color.lerp(shadowColor, other.shadowColor, t), + inactiveColor: Color.lerp(inactiveColor, other.inactiveColor, t), + almostTransparent: Color.lerp( + almostTransparent, + other.almostTransparent, + t, + ), + secondaryTransparent: Color.lerp( + secondaryTransparent, + other.secondaryTransparent, + t, + ), + enabledButtonColor: Color.lerp( + enabledButtonColor, + other.enabledButtonColor, + t, + ), + disabledButtonColor: Color.lerp( + disabledButtonColor, + other.disabledButtonColor, + t, + ), + errorColor: Color.lerp(errorColor, other.errorColor, t), + successColor: Color.lerp(successColor, other.successColor, t), + irisColor: Color.lerp(irisColor, other.irisColor, t), + primaryColor0: Color.lerp(primaryColor0, other.primaryColor0, t), + primaryColor100: Color.lerp(primaryColor100, other.primaryColor100, t), + primaryColor200: Color.lerp(primaryColor200, other.primaryColor200, t), + primaryColor300: Color.lerp(primaryColor300, other.primaryColor300, t), + primaryColor400: Color.lerp(primaryColor400, other.primaryColor400, t), + primaryColor500: Color.lerp(primaryColor500, other.primaryColor500, t), + caption1: TextStyle.lerp(caption1, other.caption1, t), + body: TextStyle.lerp(body, other.body, t), + title1: TextStyle.lerp(title1, other.title1, t), + ); + } + + // the light theme + static const light = CollactionTheme( + primaryColor: Colors.black, + secondaryColor: Color(0xFFF9F9F9), + accentColor: Color(0xFF2EB494), + shadowColor: Color.fromRGBO(0, 0, 0, 0.1), + inactiveColor: Color(0xFF666666), + almostTransparent: Color(0xFFEFEFEF), + secondaryTransparent: Color(0xFFCCCCCC), + enabledButtonColor: Color(0xFF2EB494), + disabledButtonColor: Color(0xFF999999), + errorColor: Color(0xFFE11900), + successColor: Color(0xFF2EB494), + irisColor: Color(0xFF5D5FEF), + primaryColor0: Color(0xFFEFEFEF), + primaryColor100: Color(0xFFCCCCCC), + primaryColor200: Color(0xFF999999), + primaryColor300: Color(0xFF666666), + primaryColor400: Color(0xFF333333), + primaryColor500: Color(0xFF000000), + caption1: TextStyle( + fontSize: 12, + height: 16 / 12, + ), + body: TextStyle( + fontSize: 17, + fontWeight: FontWeight.w300, + height: 26 / 17, + ), + title1: TextStyle( + fontSize: 28, + height: 34 / 28, + fontWeight: FontWeight.w700, + ), + ); + + // the dark theme + static const dark = CollactionTheme( + primaryColor: Colors.white, + secondaryColor: Color(0xFF060606), + accentColor: Color(0xFF2EB494), + shadowColor: Color.fromRGBO(255, 255, 255, 0.1), + inactiveColor: Color(0xFF666666), + almostTransparent: Color(0xFF101010), + secondaryTransparent: Color(0xFF333333), + enabledButtonColor: Color(0xFF2EB494), + disabledButtonColor: Color(0xFF666666), + errorColor: Color(0xFFE11900), + successColor: Color(0xFF2EB494), + irisColor: Color(0xFF5D5FEF), + primaryColor0: Color(0xFF101010), + primaryColor100: Color(0xFF333333), + primaryColor200: Color(0xFF666666), + primaryColor300: Color(0xFF999999), + primaryColor400: Color(0xFFCCCCCC), + primaryColor500: Colors.white, + caption1: TextStyle( + fontSize: 12, + height: 16 / 12, + ), + body: TextStyle( + fontSize: 17, + fontWeight: FontWeight.w300, + height: 26 / 17, + ), + title1: TextStyle( + fontSize: 28, + height: 34 / 28, + fontWeight: FontWeight.w700, + ), + ); +} diff --git a/lib/core/theme/theme.ext.dart b/lib/core/theme/theme.ext.dart new file mode 100644 index 00000000..f6959dbe --- /dev/null +++ b/lib/core/theme/theme.ext.dart @@ -0,0 +1,41 @@ +part of '../core.dart'; + +extension ThemeBuildContextX on BuildContext { + ThemeData get theme => Theme.of(this); + + // Primary Color + Color get primary => theme.primary; + + // Secondary/Accent Color + Color get secondary => theme.colorScheme.secondary; + + // Formerly Secondary Color + Color get tertiary => theme.colorScheme.secondaryContainer; + + // Background Color + Color get background => theme.colorScheme.background; + + // Scaffold color + Color get scaffoldColor => theme.scaffoldBackgroundColor; + + // Foreground color + Color get onBackground => theme.onBackground; + + // If brightness dark + bool get isDark => theme.brightness == Brightness.dark; + + CollactionTheme get kTheme => theme.kTheme; +} + +extension ThemeX on ThemeData { + CollactionTheme get kTheme => extension()!; + + // Primary Color + Color get primary => colorScheme.primary; + + // Foreground color + Color get onBackground => colorScheme.onBackground; + + // Scaffold color + Color get scaffoldColor => scaffoldBackgroundColor; +} diff --git a/lib/presentation/auth/auth_screen.dart b/lib/presentation/auth/auth_screen.dart index f066cb25..dd89d967 100644 --- a/lib/presentation/auth/auth_screen.dart +++ b/lib/presentation/auth/auth_screen.dart @@ -5,9 +5,9 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import '../../application/auth/auth_bloc.dart'; import '../../application/user/profile/profile_bloc.dart'; +import '../../core/core.dart'; import '../routes/app_routes.gr.dart'; import '../shared_widgets/custom_app_bars/custom_appbar.dart'; -import '../themes/constants.dart'; import '../utils/context.ext.dart'; import 'widgets/enter_username.dart'; import 'widgets/profile_photo.dart'; @@ -99,8 +99,8 @@ class AuthPageState extends State { DotsIndicator( position: _currentPage % 3, dotsCount: 3, - decorator: const DotsDecorator( - activeColor: kAccentColor, + decorator: DotsDecorator( + activeColor: context.kTheme.accentColor, color: Color(0xFFCCCCCC), size: Size(12.0, 12.0), activeSize: Size(12.0, 12.0), diff --git a/lib/presentation/auth/unauthenticated_screen.dart b/lib/presentation/auth/unauthenticated_screen.dart index f5e91a29..e6981792 100644 --- a/lib/presentation/auth/unauthenticated_screen.dart +++ b/lib/presentation/auth/unauthenticated_screen.dart @@ -1,9 +1,9 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; +import '../../core/core.dart'; import '../routes/app_routes.gr.dart'; import '../shared_widgets/pill_button.dart'; -import '../themes/constants.dart'; import '../../domain/core/i_settings_repository.dart'; import '../../infrastructure/core/injection.dart'; @@ -15,7 +15,7 @@ class UnauthenticatedPage extends StatelessWidget { }); return Scaffold( - backgroundColor: kAccentColor, + backgroundColor: context.kTheme.accentColor, body: Container( decoration: BoxDecoration( image: DecorationImage( diff --git a/lib/presentation/auth/widgets/enter_username.dart b/lib/presentation/auth/widgets/enter_username.dart index b6d0c16a..2ee13ec2 100644 --- a/lib/presentation/auth/widgets/enter_username.dart +++ b/lib/presentation/auth/widgets/enter_username.dart @@ -3,9 +3,9 @@ import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import '../../../application/username/username_bloc.dart'; +import '../../../core/core.dart'; import '../../../infrastructure/core/injection.dart'; import '../../shared_widgets/pill_button.dart'; -import '../../themes/constants.dart'; class EnterUserName extends StatefulWidget { final void Function(String fullname) onDone; @@ -67,12 +67,12 @@ class EnterUserNameState extends State { ), const SizedBox(height: 10.0), Row( - children: const [ + children: [ Expanded( child: Text( 'Enter your first name or use a recognizable name that others can identify you by', textAlign: TextAlign.center, - style: TextStyle(color: kInactiveColor), + style: TextStyle(color: context.kTheme.inactiveColor), ), ), ], @@ -93,7 +93,7 @@ class EnterUserNameState extends State { keyboardType: TextInputType.text, decoration: InputDecoration( hintText: 'Your First Name', - focusColor: kAccentColor, + focusColor: context.kTheme.accentColor, enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(20.0), borderSide: const BorderSide( @@ -131,7 +131,7 @@ class EnterUserNameState extends State { keyboardType: TextInputType.text, decoration: InputDecoration( hintText: 'Your Last Name', - focusColor: kAccentColor, + focusColor: context.kTheme.accentColor, enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(20.0), borderSide: const BorderSide( diff --git a/lib/presentation/auth/widgets/legal_notice.dart b/lib/presentation/auth/widgets/legal_notice.dart index c73ee51d..4c8c6a95 100644 --- a/lib/presentation/auth/widgets/legal_notice.dart +++ b/lib/presentation/auth/widgets/legal_notice.dart @@ -1,8 +1,8 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; +import '../../../core/core.dart'; import '../../../presentation/utils/launch_url.dart'; -import '../../themes/constants.dart'; class LegalNotice extends StatelessWidget { const LegalNotice({ @@ -11,12 +11,12 @@ class LegalNotice extends StatelessWidget { @override Widget build(BuildContext context) { - const textStyle = TextStyle(color: kPrimaryColor300); + final textStyle = TextStyle(color: context.kTheme.primaryColor300); return RichText( textAlign: TextAlign.center, text: TextSpan( children: [ - const TextSpan( + TextSpan( text: "By clicking the button, you agree to CollAction’s ", style: textStyle, ), @@ -30,7 +30,7 @@ class LegalNotice extends StatelessWidget { context: context, ), ), - const TextSpan( + TextSpan( style: textStyle, text: " and ", ), @@ -44,7 +44,7 @@ class LegalNotice extends StatelessWidget { context: context, ), ), - const TextSpan( + TextSpan( style: textStyle, text: ".", ), diff --git a/lib/presentation/auth/widgets/profile_photo.dart b/lib/presentation/auth/widgets/profile_photo.dart index 0d4ff7ec..4df2e523 100644 --- a/lib/presentation/auth/widgets/profile_photo.dart +++ b/lib/presentation/auth/widgets/profile_photo.dart @@ -6,10 +6,10 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import '../../../application/auth/auth_bloc.dart'; import '../../../application/user/avatar/avatar_bloc.dart'; +import '../../../core/core.dart'; import '../../../infrastructure/core/injection.dart'; import '../../shared_widgets/photo_selector.dart'; import '../../shared_widgets/pill_button.dart'; -import '../../themes/constants.dart'; class SelectProfilePhoto extends StatefulWidget { final Function() onSkip; @@ -83,7 +83,7 @@ class SelectProfilePhotoState extends State { }); }, ), - backgroundColor: kAccentColor, + backgroundColor: context.kTheme.accentColor, mini: true, child: const Icon(Icons.add), ), @@ -108,12 +108,12 @@ class SelectProfilePhotoState extends State { ), const SizedBox(height: 10.0), Row( - children: const [ + children: [ Expanded( child: Text( 'We love to see happy faces', textAlign: TextAlign.center, - style: TextStyle(color: kInactiveColor), + style: TextStyle(color: context.kTheme.inactiveColor), ), ), ], @@ -146,10 +146,10 @@ class SelectProfilePhotoState extends State { Expanded( child: TextButton( onPressed: () => widget.onSkip.call(), - child: const Text( + child: Text( 'Maybe later', style: TextStyle( - color: kAccentColor, + color: context.kTheme.accentColor, fontWeight: FontWeight.w700, fontSize: 14.0, ), diff --git a/lib/presentation/auth/widgets/verification_code.dart b/lib/presentation/auth/widgets/verification_code.dart index fa73e62b..12d76bc2 100644 --- a/lib/presentation/auth/widgets/verification_code.dart +++ b/lib/presentation/auth/widgets/verification_code.dart @@ -2,8 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import '../../../application/auth/auth_bloc.dart'; +import '../../../core/core.dart'; import '../../shared_widgets/pin_input/pin_input.dart'; -import '../../themes/constants.dart'; class EnterVerificationCode extends StatefulWidget { final int pinLength; @@ -45,12 +45,12 @@ class EnterVerificationCodeState extends State { ), const SizedBox(height: 10.0), Row( - children: const [ + children: [ Expanded( child: Text( 'We just sent you a text message with a 6-digit code to verify your account', textAlign: TextAlign.center, - style: TextStyle(color: kInactiveColor), + style: TextStyle(color: context.kTheme.inactiveColor), ), ), ], @@ -71,11 +71,11 @@ class EnterVerificationCodeState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ if (state is SigningInUser || state is AwaitingCodeResend) ...[ - const SizedBox( + SizedBox( width: 25, height: 25, child: CircularProgressIndicator( - color: kAccentColor, + color: context.kTheme.accentColor, strokeWidth: 2, ), ), @@ -85,10 +85,10 @@ class EnterVerificationCodeState extends State { onPressed: () => context .read() .add(const AuthEvent.resendCode()), - child: const Text( + child: Text( 'No code? Click here and we will send a new one', style: TextStyle( - color: kAccentColor, + color: context.kTheme.accentColor, fontWeight: FontWeight.w700, fontSize: 14.0, ), diff --git a/lib/presentation/auth/widgets/verified.dart b/lib/presentation/auth/widgets/verified.dart index 1729d16a..ea0fd2e2 100644 --- a/lib/presentation/auth/widgets/verified.dart +++ b/lib/presentation/auth/widgets/verified.dart @@ -5,11 +5,11 @@ import 'package:rive/rive.dart'; import 'package:shimmer/shimmer.dart'; import '../../../application/user/profile/profile_bloc.dart'; +import '../../../core/core.dart'; import '../../../infrastructure/core/injection.dart'; import '../../routes/app_routes.gr.dart'; import '../../shared_widgets/pill_button.dart'; import '../../shared_widgets/shimmers/title_shimmer_line.dart'; -import '../../themes/constants.dart'; class VerifiedPage extends StatelessWidget { const VerifiedPage({super.key}); @@ -87,10 +87,10 @@ class VerifiedPage extends StatelessWidget { TextButton( onPressed: () => context.router.replaceAll([const HomeRoute()]), - child: const Text( + child: Text( 'Show me all CrowdActions', style: TextStyle( - color: kAccentColor, + color: context.kTheme.accentColor, fontWeight: FontWeight.w700, fontSize: 14.0, ), diff --git a/lib/presentation/contact_form/contact_form_screen.dart b/lib/presentation/contact_form/contact_form_screen.dart index bf8ebb92..a34841a8 100644 --- a/lib/presentation/contact_form/contact_form_screen.dart +++ b/lib/presentation/contact_form/contact_form_screen.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; +import '../../core/core.dart'; import '../../presentation/contact_form/widgets/contact_form.dart'; import '../../presentation/shared_widgets/no_ripple_behavior.dart'; import '../shared_widgets/custom_app_bars/custom_appbar.dart'; -import '../themes/constants.dart'; class ContactFormPage extends StatefulWidget { const ContactFormPage({super.key}); @@ -33,7 +33,7 @@ class ContactFormPageState extends State { child: Scaffold( extendBodyBehindAppBar: true, appBar: const CustomAppBar(), - backgroundColor: kSecondaryColor, + backgroundColor: context.kTheme.secondaryColor, body: ScrollConfiguration( behavior: NoRippleBehavior(), child: SingleChildScrollView( diff --git a/lib/presentation/contact_form/widgets/contact_form.dart b/lib/presentation/contact_form/widgets/contact_form.dart index a7260a40..8da098fa 100644 --- a/lib/presentation/contact_form/widgets/contact_form.dart +++ b/lib/presentation/contact_form/widgets/contact_form.dart @@ -3,10 +3,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import '../../../application/contact_form/contact_form_bloc.dart'; +import '../../../core/core.dart'; import '../../../infrastructure/contact_form/contact_form_dto.dart'; import '../../../infrastructure/core/injection.dart'; import '../../../presentation/shared_widgets/pill_button.dart'; -import '../../../presentation/themes/constants.dart'; class ContactForm extends StatefulWidget { final bool centerTitle; @@ -112,7 +112,7 @@ class _ContactFormState extends State { style: Theme.of(context) .textTheme .bodySmall! - .copyWith(color: kPrimaryColor300), + .copyWith(color: context.kTheme.primaryColor300), maxLines: 2, textAlign: TextAlign.left, ), diff --git a/lib/presentation/core/app_widget.dart b/lib/presentation/core/app_widget.dart index db9b4925..83fc16a2 100644 --- a/lib/presentation/core/app_widget.dart +++ b/lib/presentation/core/app_widget.dart @@ -40,6 +40,8 @@ class AppWidget extends StatelessWidget { color: Colors.white, title: 'CollAction', theme: lightTheme(), + darkTheme: darkTheme(), + themeMode: ThemeMode.system, routerDelegate: _appRouter.delegate(), routeInformationParser: _appRouter.defaultRouteParser(), ), diff --git a/lib/presentation/crowdaction/crowdaction_browse/crowdaction_browse_screen.dart b/lib/presentation/crowdaction/crowdaction_browse/crowdaction_browse_screen.dart index 6e73504d..3c9e52f8 100644 --- a/lib/presentation/crowdaction/crowdaction_browse/crowdaction_browse_screen.dart +++ b/lib/presentation/crowdaction/crowdaction_browse/crowdaction_browse_screen.dart @@ -3,11 +3,11 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import '../../../application/crowdaction/crowdaction_getter/crowdaction_getter_bloc.dart'; +import '../../../core/core.dart'; import '../../../domain/crowdaction/crowdaction.dart'; import '../../../infrastructure/core/injection.dart'; import '../../shared_widgets/custom_app_bars/custom_appbar.dart'; import '../../shared_widgets/micro_crowdaction_card.dart'; -import '../../themes/constants.dart'; class CrowdActionBrowsePage extends StatelessWidget { CrowdActionBrowsePage({super.key}); @@ -56,7 +56,7 @@ class CrowdActionBrowsePage extends StatelessWidget { title: "Browse CrowdActions", ), body: RefreshIndicator( - color: kAccentColor, + color: context.kTheme.accentColor, onRefresh: () async { pagingController.refresh(); }, @@ -70,11 +70,15 @@ class CrowdActionBrowsePage extends StatelessWidget { MicroCrowdActionCard( crowdAction, ), - firstPageProgressIndicatorBuilder: (context) => const Center( - child: CircularProgressIndicator(color: kAccentColor), + firstPageProgressIndicatorBuilder: (context) => Center( + child: CircularProgressIndicator( + color: context.kTheme.accentColor, + ), ), - newPageProgressIndicatorBuilder: (context) => const Center( - child: CircularProgressIndicator(color: kAccentColor), + newPageProgressIndicatorBuilder: (context) => Center( + child: CircularProgressIndicator( + color: context.kTheme.accentColor, + ), ), firstPageErrorIndicatorBuilder: (context) => const Text( 'Something went wrong, try to refresh by dragging down', diff --git a/lib/presentation/crowdaction/crowdaction_comments/crowdaction_comments_page.dart b/lib/presentation/crowdaction/crowdaction_comments/crowdaction_comments_page.dart index 6765f865..6fab7205 100644 --- a/lib/presentation/crowdaction/crowdaction_comments/crowdaction_comments_page.dart +++ b/lib/presentation/crowdaction/crowdaction_comments/crowdaction_comments_page.dart @@ -6,7 +6,6 @@ import '../../../domain/crowdaction/crowdaction_comment.dart'; import '../../../infrastructure/crowdaction/crowdaction_comment_dto.dart'; import '../../core/collaction_icons.dart'; import '../../shared_widgets/expandable_text.dart'; -import '../../themes/constants.dart'; part 'parts/comment_actions.dart'; part 'parts/comment_appbar_delegate.dart'; @@ -24,7 +23,7 @@ class CrowdActionCommentsPage extends StatelessWidget { SliverPersistentHeader( delegate: CommentAppBarDelegate( expandedHeight: 156, - color: kPrimaryColor400, + color: context.kTheme.primaryColor400!, ), pinned: true, ), diff --git a/lib/presentation/crowdaction/crowdaction_comments/parts/comment_appbar_delegate.dart b/lib/presentation/crowdaction/crowdaction_comments/parts/comment_appbar_delegate.dart index 5a58d537..3657b9ce 100644 --- a/lib/presentation/crowdaction/crowdaction_comments/parts/comment_appbar_delegate.dart +++ b/lib/presentation/crowdaction/crowdaction_comments/parts/comment_appbar_delegate.dart @@ -25,7 +25,7 @@ class CommentAppBarDelegate extends SliverPersistentHeaderDelegate { icon: const Icon(CollactionIcons.left), iconSize: 24, onPressed: () => context.router.pop(), - color: Colors.white, + color: context.background, ), ) ] else @@ -61,13 +61,14 @@ class _HeaderContent extends StatelessWidget { children: [ Text( 'Comments', - style: kTitle1.copyWith(color: Colors.white), + style: context.kTheme.title1?.copyWith(color: context.background), textAlign: TextAlign.center, ), const SizedBox(height: 10), Text( 'See what others are saying about this crowdaction and join in on the conversation', - style: kCaption1.copyWith(color: Colors.white), + style: + context.kTheme.caption1?.copyWith(color: context.background), textAlign: TextAlign.center, maxLines: 2, ) diff --git a/lib/presentation/crowdaction/crowdaction_comments/parts/comment_item.dart b/lib/presentation/crowdaction/crowdaction_comments/parts/comment_item.dart index f65a7af1..a9d86992 100644 --- a/lib/presentation/crowdaction/crowdaction_comments/parts/comment_item.dart +++ b/lib/presentation/crowdaction/crowdaction_comments/parts/comment_item.dart @@ -27,7 +27,7 @@ class CommentItem extends StatelessWidget { Container( padding: const EdgeInsets.fromLTRB(16, 12, 14, 14), decoration: BoxDecoration( - color: kPrimaryColor0, + color: context.kTheme.primaryColor0, borderRadius: BorderRadius.circular(20), ), child: ExpandableText( diff --git a/lib/presentation/crowdaction/crowdaction_comments/parts/comment_textfield.dart b/lib/presentation/crowdaction/crowdaction_comments/parts/comment_textfield.dart index 0e1cba20..8b550a4a 100644 --- a/lib/presentation/crowdaction/crowdaction_comments/parts/comment_textfield.dart +++ b/lib/presentation/crowdaction/crowdaction_comments/parts/comment_textfield.dart @@ -12,13 +12,13 @@ class CommentTextField extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10), color: Theme.of(context).scaffoldBackgroundColor, child: TextFormField( - decoration: const InputDecoration( + decoration: InputDecoration( border: _border, focusedBorder: _border, enabledBorder: _border, errorBorder: _border, hintText: 'Write a comment', - hintStyle: body, + hintStyle: context.kTheme.body, suffixIcon: Padding( padding: EdgeInsets.all(8.0), child: Icon( diff --git a/lib/presentation/crowdaction/crowdaction_comments/widgets/flag_comment.dart b/lib/presentation/crowdaction/crowdaction_comments/widgets/flag_comment.dart index 18a46210..467ed918 100644 --- a/lib/presentation/crowdaction/crowdaction_comments/widgets/flag_comment.dart +++ b/lib/presentation/crowdaction/crowdaction_comments/widgets/flag_comment.dart @@ -1,9 +1,9 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; +import '../../../../core/core.dart'; import '../../../shared_widgets/pill_button.dart'; import '../../../shared_widgets/selectable_chip.dart'; -import '../../../themes/constants.dart'; class FlagComment extends StatelessWidget { final bool flagged; @@ -72,7 +72,7 @@ class FlagDialogState extends State { height: 5.0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.0), - color: kSecondaryTransparent, + color: context.kTheme.secondaryTransparent, ), ), const SizedBox( @@ -100,7 +100,7 @@ class FlagDialogState extends State { "Modal description. Nam quis nulla. Integer malesuada. In in enim a arcu imperdiet malesuada. Sed vel lectus. Donec odio uma, tempus molestie, porttitor ut, iaculis quis.", overflow: TextOverflow.fade, style: Theme.of(context).textTheme.bodySmall?.copyWith( - color: kPrimaryColor400, + color: context.kTheme.primaryColor400, ), textAlign: TextAlign.center, ), @@ -173,7 +173,7 @@ class FlagSuccess extends StatelessWidget { height: 5.0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.0), - color: kSecondaryTransparent, + color: context.kTheme.secondaryTransparent, ), ), const SizedBox( @@ -205,7 +205,7 @@ class FlagSuccess extends StatelessWidget { child: Text( "Thank you for letting us know. We will look into it and dlete the comment if necessary.", style: Theme.of(context).textTheme.bodySmall?.copyWith( - color: kPrimaryColor400, + color: context.kTheme.primaryColor400, ), textAlign: TextAlign.center, ), diff --git a/lib/presentation/crowdaction/crowdaction_details/crowdaction_details_screen.dart b/lib/presentation/crowdaction/crowdaction_details/crowdaction_details_screen.dart index cea76a9d..0ea76c4a 100644 --- a/lib/presentation/crowdaction/crowdaction_details/crowdaction_details_screen.dart +++ b/lib/presentation/crowdaction/crowdaction_details/crowdaction_details_screen.dart @@ -8,10 +8,10 @@ import '../../../application/auth/auth_bloc.dart'; import '../../../application/crowdaction/crowdaction_details/crowdaction_details_bloc.dart'; import '../../../application/participation/participation_bloc.dart'; import '../../../application/user/profile_tab/profile_tab_bloc.dart'; +import '../../../core/core.dart'; import '../../routes/app_routes.gr.dart'; import '../../shared_widgets/commitments/commitment_card_list.dart'; import '../../shared_widgets/pill_button.dart'; -import '../../themes/constants.dart'; import 'widgets/confirm_participation.dart'; import 'widgets/crowdaction_chips.dart'; import 'widgets/crowdaction_description.dart'; @@ -155,13 +155,13 @@ class CrowdActionDetailsPageState extends State { BlocProvider.of(context).add( CrowdActionDetailsEvent.fetchCrowdAction(id: id), ), - color: kAccentColor, + color: context.kTheme.accentColor, child: SingleChildScrollView( child: Column( children: [ Container( width: double.infinity, - color: kAlmostTransparent, + color: context.kTheme.almostTransparent, padding: const EdgeInsets.symmetric( horizontal: 20, vertical: 30, @@ -217,7 +217,8 @@ class CrowdActionDetailsPageState extends State { .textTheme .bodySmall! .copyWith( - color: kPrimaryColor300, + color: + context.kTheme.primaryColor300, fontWeight: FontWeight.w400, ), textAlign: TextAlign.center, @@ -309,7 +310,7 @@ class CrowdActionDetailsPageState extends State { height: 5.0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.0), - color: kSecondaryTransparent, + color: context.kTheme.secondaryTransparent, ), ), const SizedBox( @@ -326,7 +327,7 @@ class CrowdActionDetailsPageState extends State { Text( "You need to create an account in order to participate in a crowdaction. If you have an account already, please log in.", style: Theme.of(context).textTheme.bodySmall?.copyWith( - color: kPrimaryColor400, + color: context.kTheme.primaryColor400, ), ), const SizedBox( diff --git a/lib/presentation/crowdaction/crowdaction_details/widgets/commitment_badges.dart b/lib/presentation/crowdaction/crowdaction_details/widgets/commitment_badges.dart index 0ec7f79c..2ccb49eb 100644 --- a/lib/presentation/crowdaction/crowdaction_details/widgets/commitment_badges.dart +++ b/lib/presentation/crowdaction/crowdaction_details/widgets/commitment_badges.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; +import '../../../../core/core.dart'; import '../../../core/collaction_icons.dart'; -import '../../../themes/constants.dart'; class CommitmentBadges extends StatelessWidget { static const String _heroBadgesTag = 'display-badges'; @@ -12,7 +12,7 @@ class CommitmentBadges extends StatelessWidget { Widget build(BuildContext context) { return Container( padding: const EdgeInsets.all(20), - color: kAlmostTransparent, + color: context.kTheme.almostTransparent, child: Column( children: [ Container( @@ -21,12 +21,13 @@ class CommitmentBadges extends StatelessWidget { tag: _heroBadgesTag, child: Center( child: Material( - color: kAlmostTransparent, + color: context.kTheme.almostTransparent, borderRadius: BorderRadius.circular(20), child: GestureDetector( onTap: () { Navigator.of(context).push( HeroBadgesDialogRoute( + context: context, builder: (context) { return _BadgesPopupCard(key: key); }, @@ -37,8 +38,8 @@ class CommitmentBadges extends StatelessWidget { margin: const EdgeInsets.all(8), child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: const [ - Text( + children: [ + const Text( 'My badge', style: TextStyle( fontWeight: FontWeight.w700, @@ -48,7 +49,7 @@ class CommitmentBadges extends StatelessWidget { SizedBox(width: 10), Icon( CollactionIcons.question, - color: kAccentColor, + color: context.kTheme.accentColor, ), ], ), @@ -59,11 +60,11 @@ class CommitmentBadges extends StatelessWidget { ), ), const SizedBox(height: 4), - const Text( + Text( 'The commitments you’ve chosen will give you the following badge', textAlign: TextAlign.center, style: TextStyle( - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, ), ), const SizedBox(height: 30), @@ -74,10 +75,10 @@ class CommitmentBadges extends StatelessWidget { height: 100, ), const SizedBox(height: 5), - const Text( + Text( 'Jan, 2021', style: TextStyle( - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, fontSize: 16, fontWeight: FontWeight.w400, ), @@ -91,10 +92,10 @@ class CommitmentBadges extends StatelessWidget { ), ), const SizedBox(height: 5), - const Text( + Text( 'Gold', style: TextStyle( - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, fontSize: 16, fontWeight: FontWeight.w400, ), @@ -120,7 +121,7 @@ class _BadgesPopupCard extends StatelessWidget { child: Hero( tag: _heroTag, child: Material( - color: kAlmostTransparent, + color: context.kTheme.almostTransparent, borderRadius: BorderRadius.circular(10), elevation: 4.0, child: Padding( @@ -154,7 +155,7 @@ class _BadgesPopupCard extends StatelessWidget { Theme.of(context).textTheme.bodySmall!.copyWith( fontWeight: FontWeight.w400, fontSize: 12, - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, ), textAlign: TextAlign.center, ), @@ -179,7 +180,7 @@ class _BadgesPopupCard extends StatelessWidget { .copyWith( fontWeight: FontWeight.w400, fontSize: 12, - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, ), ), ], @@ -213,7 +214,7 @@ class _BadgesPopupCard extends StatelessWidget { .copyWith( fontWeight: FontWeight.w400, fontSize: 12, - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, ), ), ], @@ -246,7 +247,7 @@ class _BadgesPopupCard extends StatelessWidget { .copyWith( fontWeight: FontWeight.w400, fontSize: 12, - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, ), ), ], @@ -260,7 +261,7 @@ class _BadgesPopupCard extends StatelessWidget { Align( alignment: Alignment.topRight, child: CircleAvatar( - backgroundColor: kSecondaryColor, + backgroundColor: context.kTheme.secondaryColor, child: IconButton( onPressed: () => Navigator.of(context).pop(), icon: const Icon(CollactionIcons.cross), @@ -280,11 +281,13 @@ class _BadgesPopupCard extends StatelessWidget { class HeroBadgesDialogRoute extends PageRoute { HeroBadgesDialogRoute({ required WidgetBuilder builder, + required this.context, super.settings, super.fullscreenDialog = true, }) : _builder = builder; final WidgetBuilder _builder; + final BuildContext context; @override bool get opaque => false; @@ -299,7 +302,7 @@ class HeroBadgesDialogRoute extends PageRoute { bool get maintainState => true; @override - Color get barrierColor => kPrimaryColor.withOpacity(0.25); + Color get barrierColor => context.kTheme.primaryColor!.withOpacity(0.25); @override Widget buildTransitions( diff --git a/lib/presentation/crowdaction/crowdaction_details/widgets/confirm_participation.dart b/lib/presentation/crowdaction/crowdaction_details/widgets/confirm_participation.dart index d6cbf014..a21fe14d 100644 --- a/lib/presentation/crowdaction/crowdaction_details/widgets/confirm_participation.dart +++ b/lib/presentation/crowdaction/crowdaction_details/widgets/confirm_participation.dart @@ -4,9 +4,9 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import '../../../../../domain/crowdaction/crowdaction.dart'; import '../../../../application/participation/participation_bloc.dart'; +import '../../../../core/core.dart'; import '../../../shared_widgets/commitments/commitment_card.dart'; import '../../../shared_widgets/pill_button.dart'; -import '../../../themes/constants.dart'; class ConfirmParticipation extends StatelessWidget { final CrowdAction crowdAction; @@ -52,7 +52,7 @@ class ParticipationSuccess extends StatelessWidget { height: 5.0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.0), - color: kSecondaryTransparent, + color: context.kTheme.secondaryTransparent, ), ), const SizedBox( @@ -83,7 +83,7 @@ class ParticipationSuccess extends StatelessWidget { Text( "You have successfully registered for this CrowdAction", style: Theme.of(context).textTheme.bodySmall?.copyWith( - color: kPrimaryColor400, + color: context.kTheme.primaryColor400, ), ), const SizedBox( @@ -103,7 +103,7 @@ class ParticipationSuccess extends StatelessWidget { child: Text( "You can change your commitment until the CrowdAction starts", style: Theme.of(context).textTheme.bodySmall?.copyWith( - color: kPrimaryColor200, + color: context.kTheme.primaryColor200, ), textAlign: TextAlign.center, ), @@ -141,7 +141,7 @@ class ParticipationDialog extends StatelessWidget { height: 5.0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.0), - color: kSecondaryTransparent, + color: context.kTheme.secondaryTransparent, ), ), const SizedBox( @@ -170,7 +170,7 @@ class ParticipationDialog extends StatelessWidget { "You’re almost there! You’ve selected the displayed commitment${selectedCommitments.length > 1 ? 's' : ''} to stick to through this CrowdAction. By clicking “Confirm” you will officially commit to this CrowdAction.", overflow: TextOverflow.fade, style: Theme.of(context).textTheme.bodySmall?.copyWith( - color: kPrimaryColor400, + color: context.kTheme.primaryColor400, ), ), ), @@ -178,10 +178,8 @@ class ParticipationDialog extends StatelessWidget { Text( "Your commitment${selectedCommitments.length > 1 ? 's' : ''}", textAlign: TextAlign.center, - style: Theme.of(context) - .textTheme - .bodySmall - ?.copyWith(color: kPrimaryColor300, fontSize: 12), + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: context.kTheme.primaryColor300, fontSize: 12), ), const SizedBox(height: 20), ListView.builder( diff --git a/lib/presentation/crowdaction/crowdaction_details/widgets/crowdaction_chips.dart b/lib/presentation/crowdaction/crowdaction_details/widgets/crowdaction_chips.dart index 71293551..51b278e0 100644 --- a/lib/presentation/crowdaction/crowdaction_details/widgets/crowdaction_chips.dart +++ b/lib/presentation/crowdaction/crowdaction_details/widgets/crowdaction_chips.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; import 'package:shimmer/shimmer.dart'; +import '../../../../core/core.dart'; import '../../../shared_widgets/accent_chip.dart'; import '../../../shared_widgets/secondary_chip.dart'; -import '../../../themes/constants.dart'; class CrowdActionChips extends StatelessWidget { const CrowdActionChips({ @@ -26,7 +26,9 @@ class CrowdActionChips extends StatelessWidget { ...[ AccentChip( text: isOpen ? "Open" : "Closed", - color: isOpen ? kAccentColor : kPrimaryColor200, + color: isOpen + ? context.kTheme.accentColor! + : context.kTheme.primaryColor200!, ), SecondaryChip(text: category!), if (subCategory != null) ...[SecondaryChip(text: subCategory!)], diff --git a/lib/presentation/crowdaction/crowdaction_details/widgets/crowdaction_description.dart b/lib/presentation/crowdaction/crowdaction_details/widgets/crowdaction_description.dart index 5c6e6a76..d4e3343e 100644 --- a/lib/presentation/crowdaction/crowdaction_details/widgets/crowdaction_description.dart +++ b/lib/presentation/crowdaction/crowdaction_details/widgets/crowdaction_description.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:shimmer/shimmer.dart'; +import '../../../../core/core.dart'; import '../../../shared_widgets/expandable_markdown_text.dart'; -import '../../../themes/constants.dart'; class CrowdActionDescription extends StatefulWidget { final String? description; @@ -21,13 +21,13 @@ class _CrowdActionDescriptionState extends State { Widget build(BuildContext context) { if (widget.description == null) { return Shimmer.fromColors( - baseColor: kPrimaryColor100, - highlightColor: kPrimaryColor200, + baseColor: context.kTheme.primaryColor100!, + highlightColor: context.kTheme.primaryColor200!, child: Container( height: 150, width: double.infinity, decoration: BoxDecoration( - color: kPrimaryColor100, + color: context.kTheme.primaryColor100, borderRadius: BorderRadius.circular(10), ), ), diff --git a/lib/presentation/crowdaction/crowdaction_details/widgets/crowdaction_details_banner.dart b/lib/presentation/crowdaction/crowdaction_details/widgets/crowdaction_details_banner.dart index b7d20feb..c0b2567c 100644 --- a/lib/presentation/crowdaction/crowdaction_details/widgets/crowdaction_details_banner.dart +++ b/lib/presentation/crowdaction/crowdaction_details/widgets/crowdaction_details_banner.dart @@ -9,16 +9,15 @@ import '../../../core/collaction_icons.dart'; import '../../../shared_widgets/country_icon.dart'; import '../../../shared_widgets/custom_fab.dart'; import '../../../shared_widgets/image_skeleton_loader.dart'; -import '../../../themes/constants.dart'; class CrowdActionDetailsBanner extends StatelessWidget { - final CrowdAction? crowdAction; - const CrowdActionDetailsBanner({ super.key, required this.crowdAction, }); + final CrowdAction? crowdAction; + @override Widget build(BuildContext context) { return SliverAppBar( @@ -40,9 +39,9 @@ class CrowdActionDetailsBanner extends StatelessWidget { child: InkWell( borderRadius: BorderRadius.circular(20), onTap: () => context.router.pop(), - child: const Icon( + child: Icon( CollactionIcons.left, - color: kPrimaryColor400, + color: context.kTheme.primaryColor400, ), ), ), @@ -75,33 +74,34 @@ class CrowdActionDetailsBanner extends StatelessWidget { ), ), Positioned( - bottom: 10, - right: 10, - child: Row( - children: [ - if (crowdAction?.hasPassword ?? false) ...[ - CustomFAB( - heroTag: 'locked', - isMini: true, - color: kSecondaryColor, - child: Icon( - CollactionIcons.lock, - color: kPrimaryColor300, - ), - ), - ], - if ((crowdAction?.hasPassword ?? false) && - (crowdAction?.location != null)) ...[ - const SizedBox(width: 6), - ], - if (crowdAction?.location != null) ...[ - CountryIcon( - countryCode: crowdAction?.location.code ?? 'nl', - radius: 20, + bottom: 10, + right: 10, + child: Row( + children: [ + if (crowdAction?.hasPassword ?? false) ...[ + CustomFAB( + heroTag: 'locked', + isMini: true, + color: context.kTheme.secondaryColor, + child: Icon( + CollactionIcons.lock, + color: context.kTheme.primaryColor300, ), - ], + ), ], - )), + if ((crowdAction?.hasPassword ?? false) && + (crowdAction?.location != null)) ...[ + const SizedBox(width: 6), + ], + if (crowdAction?.location != null) ...[ + CountryIcon( + countryCode: crowdAction?.location.code ?? 'nl', + radius: 20, + ), + ], + ], + ), + ), ], ), ), diff --git a/lib/presentation/crowdaction/crowdaction_details/widgets/participation_count_text.dart b/lib/presentation/crowdaction/crowdaction_details/widgets/participation_count_text.dart index 38fe58cb..44bd99c2 100644 --- a/lib/presentation/crowdaction/crowdaction_details/widgets/participation_count_text.dart +++ b/lib/presentation/crowdaction/crowdaction_details/widgets/participation_count_text.dart @@ -3,9 +3,9 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:shimmer/shimmer.dart'; import '../../../../application/crowdaction/crowdaction_details/crowdaction_details_bloc.dart'; +import '../../../../core/core.dart'; import '../../../../domain/crowdaction/crowdaction.dart'; import '../../../../infrastructure/core/injection.dart'; -import '../../../../presentation/themes/constants.dart'; import '../../../shared_widgets/shimmers/title_shimmer_line.dart'; class ParticipationCountText extends StatelessWidget { @@ -83,7 +83,7 @@ class ParticipationCountText extends StatelessWidget { "${!isEnded ? 'Join ' : ''}$participantCount ${participantCount > 1 ? 'people' : 'person'} ${!isEnded ? 'participating' : 'participated'}", style: Theme.of(context).textTheme.bodySmall?.copyWith( fontSize: 14, - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, height: 1.2, ), ); diff --git a/lib/presentation/crowdaction/crowdaction_details/widgets/withdraw_participation.dart b/lib/presentation/crowdaction/crowdaction_details/widgets/withdraw_participation.dart index 513b3f92..c5bbbdd6 100644 --- a/lib/presentation/crowdaction/crowdaction_details/widgets/withdraw_participation.dart +++ b/lib/presentation/crowdaction/crowdaction_details/widgets/withdraw_participation.dart @@ -4,8 +4,8 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import '../../../../../domain/crowdaction/crowdaction.dart'; import '../../../../application/participation/participation_bloc.dart'; +import '../../../../core/core.dart'; import '../../../shared_widgets/pill_button.dart'; -import '../../../themes/constants.dart'; class WithdrawParticipation extends StatelessWidget { final ParticipationBloc participationBloc; @@ -31,7 +31,7 @@ class WithdrawParticipation extends StatelessWidget { style: Theme.of(context).textTheme.displaySmall!.copyWith( fontSize: 15, fontWeight: FontWeight.w700, - color: kSuccessColor, + color: context.kTheme.successColor, ), ), ), @@ -67,7 +67,7 @@ class WithdrawParticipation extends StatelessWidget { height: 5.0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.0), - color: kSecondaryTransparent, + color: context.kTheme.secondaryTransparent, ), ), const SizedBox( @@ -122,7 +122,7 @@ class WithdrawParticipation extends StatelessWidget { height: 5.0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.0), - color: kSecondaryTransparent, + color: context.kTheme.secondaryTransparent, ), ), const SizedBox( @@ -142,7 +142,7 @@ class WithdrawParticipation extends StatelessWidget { Text( "You are about to cancel your participation. You are free to sign up for this CrowdAction again any time before it starts.", style: Theme.of(context).textTheme.bodySmall?.copyWith( - color: kPrimaryColor400, + color: context.kTheme.primaryColor400, ), ), const SizedBox( diff --git a/lib/presentation/crowdaction/crowdaction_home/crowdaction_home_screen.dart b/lib/presentation/crowdaction/crowdaction_home/crowdaction_home_screen.dart index ac0e6ef6..ceff53de 100644 --- a/lib/presentation/crowdaction/crowdaction_home/crowdaction_home_screen.dart +++ b/lib/presentation/crowdaction/crowdaction_home/crowdaction_home_screen.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import '../../../application/crowdaction/spotlight/spotlight_bloc.dart'; +import '../../../core/core.dart'; import '../../../infrastructure/core/injection.dart'; import '../../home/widgets/current_upcoming_layout.dart'; -import '../../themes/constants.dart'; import 'widgets/in_spotlight_header.dart'; import 'widgets/share_collaction_card.dart'; @@ -22,7 +22,7 @@ class CrowdActionHomeScreen extends StatelessWidget { child: RefreshIndicator( onRefresh: () async => BlocProvider.of(context) .add(const SpotlightEvent.getSpotLightCrowdActions()), - color: kAccentColor, + color: context.kTheme.accentColor, child: SingleChildScrollView( child: SizedBox( width: double.infinity, diff --git a/lib/presentation/crowdaction/crowdaction_home/widgets/in_spotlight_header.dart b/lib/presentation/crowdaction/crowdaction_home/widgets/in_spotlight_header.dart index 03a69c4c..41dd83c8 100644 --- a/lib/presentation/crowdaction/crowdaction_home/widgets/in_spotlight_header.dart +++ b/lib/presentation/crowdaction/crowdaction_home/widgets/in_spotlight_header.dart @@ -3,8 +3,8 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:intl/intl.dart'; import '../../../../application/crowdaction/spotlight/spotlight_bloc.dart'; +import '../../../../core/core.dart'; import '../../../shared_widgets/content_placeholder.dart'; -import '../../../themes/constants.dart'; import 'spotlight_crowdactions/spotlight_crowdactions.dart'; class InSpotLightHeader extends StatefulWidget { @@ -39,7 +39,7 @@ class _InSpotLightHeaderState extends State { sectionHeadingText(), style: Theme.of(context).textTheme.headlineSmall?.copyWith( fontWeight: FontWeight.bold, - color: kPrimaryColor400, + color: context.kTheme.primaryColor400, ), ), ), @@ -53,8 +53,8 @@ class _InSpotLightHeaderState extends State { return const SpotlightEmptyHeader(); }, spotLightCrowdActionsError: (_) { - return const ContentPlaceholder( - textColor: Colors.white, + return ContentPlaceholder( + textColor: context.onBackground, ); }, spotLightCrowdActions: (pages) { diff --git a/lib/presentation/crowdaction/crowdaction_home/widgets/share_collaction_card.dart b/lib/presentation/crowdaction/crowdaction_home/widgets/share_collaction_card.dart index 5d16883e..f3247b4d 100644 --- a/lib/presentation/crowdaction/crowdaction_home/widgets/share_collaction_card.dart +++ b/lib/presentation/crowdaction/crowdaction_home/widgets/share_collaction_card.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import '../../../themes/constants.dart'; +import '../../../../core/core.dart'; import 'share_collaction_button.dart'; class ShareCollActionCard extends StatelessWidget { @@ -14,9 +14,9 @@ class ShareCollActionCard extends StatelessWidget { margin: const EdgeInsets.all(12.0), decoration: BoxDecoration( borderRadius: BorderRadius.circular(20.0), - boxShadow: const [ + boxShadow: [ BoxShadow( - color: kShadowColor, + color: context.kTheme.shadowColor!, blurRadius: 4.0, offset: Offset(0, 4), ), @@ -25,7 +25,7 @@ class ShareCollActionCard extends StatelessWidget { child: DecoratedBox( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20.0), - color: kPrimaryColor400, + color: context.kTheme.primaryColor400, ), child: Column( children: [ @@ -37,7 +37,7 @@ class ShareCollActionCard extends StatelessWidget { textAlign: TextAlign.center, style: Theme.of(context).textTheme.headlineSmall?.copyWith( fontWeight: FontWeight.bold, - color: kSecondaryColor, + color: context.kTheme.secondaryColor, ), ), const SizedBox( @@ -51,7 +51,7 @@ class ShareCollActionCard extends StatelessWidget { style: Theme.of(context) .textTheme .bodySmall - ?.copyWith(color: kSecondaryColor), + ?.copyWith(color: context.kTheme.secondaryColor), ), ), const SizedBox( diff --git a/lib/presentation/crowdaction/crowdaction_home/widgets/spotlight_crowdactions/spotlight_crowdactions.dart b/lib/presentation/crowdaction/crowdaction_home/widgets/spotlight_crowdactions/spotlight_crowdactions.dart index e7241844..358c616e 100644 --- a/lib/presentation/crowdaction/crowdaction_home/widgets/spotlight_crowdactions/spotlight_crowdactions.dart +++ b/lib/presentation/crowdaction/crowdaction_home/widgets/spotlight_crowdactions/spotlight_crowdactions.dart @@ -3,10 +3,10 @@ import 'package:expandable_page_view/expandable_page_view.dart'; import 'package:flutter/material.dart'; import 'package:shimmer/shimmer.dart'; +import '../../../../../core/core.dart'; import '../../../../../domain/crowdaction/crowdaction.dart'; import '../../../../shared_widgets/crowdaction_card.dart'; import '../../../../shared_widgets/secondary_chip.dart'; -import '../../../../themes/constants.dart'; part 'in_spotlight_header_empty.dart'; @@ -59,8 +59,8 @@ class _SpotlightCrowdActionsState extends State { DotsIndicator( position: _currentPage, dotsCount: widget.pages.length, - decorator: const DotsDecorator( - activeColor: kAccentColor, + decorator: DotsDecorator( + activeColor: context.kTheme.accentColor, color: Color(0xFFCCCCCC), size: Size(12.0, 12.0), activeSize: Size(12.0, 12.0), diff --git a/lib/presentation/crowdaction/crowdaction_participants/crowdaction_participants_screen.dart b/lib/presentation/crowdaction/crowdaction_participants/crowdaction_participants_screen.dart index aaab2124..7aec3865 100644 --- a/lib/presentation/crowdaction/crowdaction_participants/crowdaction_participants_screen.dart +++ b/lib/presentation/crowdaction/crowdaction_participants/crowdaction_participants_screen.dart @@ -4,9 +4,9 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import '../../../application/crowdaction/crowdaction_participants/crowdaction_participants_bloc.dart'; +import '../../../core/core.dart'; import '../../../domain/participation/participation.dart'; import '../../../infrastructure/core/injection.dart'; -import '../../themes/constants.dart'; class CrowdActionParticipantsPage extends StatelessWidget { final String crowdActionId; @@ -63,22 +63,22 @@ class CrowdActionParticipantsPage extends StatelessWidget { elevation: 0, backgroundColor: Colors.transparent, leading: IconButton( - icon: const Icon( + icon: Icon( Icons.chevron_left, - color: kPrimaryColor200, + color: context.kTheme.primaryColor200, ), onPressed: () => context.router.pop(), ), - title: const Text( + title: Text( "Participants", style: TextStyle( fontWeight: FontWeight.bold, - color: kPrimaryColor400, + color: context.kTheme.primaryColor400, ), ), ), body: RefreshIndicator( - color: kAccentColor, + color: context.kTheme.accentColor, onRefresh: () async { pagingController.refresh(); }, @@ -106,11 +106,15 @@ class CrowdActionParticipantsPage extends StatelessWidget { ?.copyWith(fontSize: 17, fontWeight: FontWeight.w300), ), ), - firstPageProgressIndicatorBuilder: (context) => const Center( - child: CircularProgressIndicator(color: kAccentColor), + firstPageProgressIndicatorBuilder: (context) => Center( + child: CircularProgressIndicator( + color: context.kTheme.accentColor, + ), ), - newPageProgressIndicatorBuilder: (context) => const Center( - child: CircularProgressIndicator(color: kAccentColor), + newPageProgressIndicatorBuilder: (context) => Center( + child: CircularProgressIndicator( + color: context.kTheme.accentColor, + ), ), firstPageErrorIndicatorBuilder: (context) => const Text( 'Something went wrong, try to refresh by dragging down', diff --git a/lib/presentation/demo/components_demo/components_demo_screen.dart b/lib/presentation/demo/components_demo/components_demo_screen.dart index c89d83b6..2cfdb428 100644 --- a/lib/presentation/demo/components_demo/components_demo_screen.dart +++ b/lib/presentation/demo/components_demo/components_demo_screen.dart @@ -1,7 +1,12 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; +import '../../../core/core.dart'; import '../../../domain/crowdaction/crowdaction.dart'; +import '../../crowdaction/crowdaction_comments/widgets/comment_delete_button.dart'; +import '../../crowdaction/crowdaction_comments/widgets/comment_flag_button.dart'; +import '../../crowdaction/crowdaction_comments/widgets/comment_like_button.dart'; +import '../../crowdaction/crowdaction_comments/widgets/flag_comment.dart'; import '../../shared_widgets/accent_chip.dart'; import '../../shared_widgets/crowdaction_card.dart'; import '../../shared_widgets/custom_app_bars/clean_app_bar.dart'; @@ -9,11 +14,6 @@ import '../../shared_widgets/custom_fab.dart'; import '../../shared_widgets/pill_button.dart'; import '../../shared_widgets/rectangle_button.dart'; import '../../shared_widgets/secondary_chip.dart'; -import '../../crowdaction/crowdaction_comments/widgets/comment_delete_button.dart'; -import '../../crowdaction/crowdaction_comments/widgets/comment_like_button.dart'; -import '../../crowdaction/crowdaction_comments/widgets/comment_flag_button.dart'; -import '../../crowdaction/crowdaction_comments/widgets/flag_comment.dart'; -import '../../themes/constants.dart'; class ComponentsDemoPage extends StatefulWidget { const ComponentsDemoPage({super.key}); @@ -302,7 +302,7 @@ class ComponentsDemoPageState extends State { height: 5.0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.0), - color: kSecondaryTransparent, + color: context.kTheme.secondaryTransparent, ), ), const SizedBox( diff --git a/lib/presentation/home/home_screen.dart b/lib/presentation/home/home_screen.dart index 9c04554c..f90b12b9 100644 --- a/lib/presentation/home/home_screen.dart +++ b/lib/presentation/home/home_screen.dart @@ -2,7 +2,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import '../../../presentation/themes/constants.dart'; +import '../../core/core.dart'; import '../core/collaction_icons.dart'; import '../routes/app_routes.gr.dart'; @@ -17,17 +17,20 @@ class HomePage extends StatelessWidget { DemoScreenRouter(), ], ], - bottomNavigationBuilder: (_, tabsRouter) => bottomNavbar(tabsRouter), + bottomNavigationBuilder: (_, tabsRouter) => bottomNavbar( + tabsRouter, + context, + ), ); } - Widget bottomNavbar(TabsRouter tabsRouter) { + Widget bottomNavbar(TabsRouter tabsRouter, BuildContext context) { return BottomNavigationBar( - backgroundColor: Colors.white, + backgroundColor: context.background, showSelectedLabels: false, showUnselectedLabels: false, - selectedItemColor: kEnabledButtonColor, - unselectedItemColor: kDisabledButtonColor, + selectedItemColor: context.kTheme.enabledButtonColor, + unselectedItemColor: context.kTheme.disabledButtonColor, type: BottomNavigationBarType.fixed, elevation: 0, items: const [ diff --git a/lib/presentation/home/widgets/crowdaction_carousel.dart b/lib/presentation/home/widgets/crowdaction_carousel.dart index 73645866..331fc631 100644 --- a/lib/presentation/home/widgets/crowdaction_carousel.dart +++ b/lib/presentation/home/widgets/crowdaction_carousel.dart @@ -4,10 +4,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import '../../../application/crowdaction/spotlight/spotlight_bloc.dart'; +import '../../../core/core.dart'; import '../../../infrastructure/core/injection.dart'; import '../../shared_widgets/crowdaction_card.dart'; import '../../shared_widgets/no_ripple_behavior.dart'; -import '../../themes/constants.dart'; class CrowdActionCarousel extends StatefulWidget { const CrowdActionCarousel({super.key}); @@ -63,10 +63,10 @@ class CrowdActionCarouselState extends State { DotsIndicator( dotsCount: crowdActions.length, position: _currentPage, - decorator: const DotsDecorator( - color: kShadowColor, + decorator: DotsDecorator( + color: context.kTheme.shadowColor!, size: Size(12.0, 12.0), - activeColor: kAccentColor, + activeColor: context.kTheme.accentColor, activeSize: Size(12.0, 12.0), ), onTap: (position) { diff --git a/lib/presentation/home/widgets/current_upcoming_layout.dart b/lib/presentation/home/widgets/current_upcoming_layout.dart index 593bddc1..65aa1c64 100644 --- a/lib/presentation/home/widgets/current_upcoming_layout.dart +++ b/lib/presentation/home/widgets/current_upcoming_layout.dart @@ -3,11 +3,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import '../../../application/crowdaction/spotlight/spotlight_bloc.dart'; +import '../../../core/core.dart'; import '../../routes/app_routes.gr.dart'; import '../../shared_widgets/content_placeholder.dart'; import '../../shared_widgets/micro_crowdaction_card.dart'; import '../../shared_widgets/micro_crowdaction_card_loading.dart'; -import '../../themes/constants.dart'; class CurrentAndUpcomingLayout extends StatefulWidget { final bool isCurrent; @@ -50,19 +50,19 @@ class _CurrentAndUpcomingLayoutState extends State { .headlineSmall ?.copyWith( fontWeight: FontWeight.bold, - color: kPrimaryColor400, + color: context.kTheme.primaryColor400, ), ), TextButton( onPressed: () => context.router.push(CrowdActionBrowseRoute()), - child: const Text( + child: Text( 'View all', textAlign: TextAlign.center, style: TextStyle( fontWeight: FontWeight.w700, fontSize: 15.0, - color: kAccentColor, + color: context.kTheme.accentColor, ), ), ), @@ -92,9 +92,8 @@ class _CurrentAndUpcomingLayoutState extends State { ], ); }, - spotLightCrowdActionsError: (failure) => - const ContentPlaceholder( - textColor: Colors.black, + spotLightCrowdActionsError: (failure) => ContentPlaceholder( + textColor: context.onBackground, ), orElse: () => const SizedBox(), ), diff --git a/lib/presentation/home/widgets/password_modal.dart b/lib/presentation/home/widgets/password_modal.dart index e2288136..ae67e5f4 100644 --- a/lib/presentation/home/widgets/password_modal.dart +++ b/lib/presentation/home/widgets/password_modal.dart @@ -1,12 +1,12 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; +import '../../../core/core.dart'; import '../../../domain/core/i_settings_repository.dart'; import '../../../domain/crowdaction/crowdaction.dart'; import '../../../infrastructure/core/injection.dart'; import '../../../presentation/core/collaction_icons.dart'; import '../../../presentation/routes/app_routes.gr.dart'; -import '../../../presentation/themes/constants.dart'; class PasswordModal extends StatefulWidget { final CrowdAction crowdAction; @@ -61,8 +61,8 @@ class _PasswordModalState extends State { constraints: const BoxConstraints(minWidth: 380), margin: const EdgeInsets.all(10), padding: const EdgeInsets.all(20), - decoration: const BoxDecoration( - color: kSecondaryColor, + decoration: BoxDecoration( + color: context.kTheme.secondaryColor, borderRadius: BorderRadius.all(Radius.circular(20)), ), child: Column( @@ -74,7 +74,7 @@ class _PasswordModalState extends State { Text( 'Enter password', style: Theme.of(context).textTheme.displayLarge!.copyWith( - color: kPrimaryColor400, + color: context.kTheme.primaryColor400, fontSize: 28, fontWeight: FontWeight.w700, ), @@ -83,7 +83,7 @@ class _PasswordModalState extends State { Text( 'This crowdaction is private. Please enter the password to see it.', style: Theme.of(context).textTheme.displayLarge!.copyWith( - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, fontSize: 12, ), textAlign: TextAlign.center, @@ -121,13 +121,13 @@ class _PasswordModalState extends State { ), suffixIcon: IconButton( icon: _showInput - ? const Icon( + ? Icon( CollactionIcons.eye, - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, ) - : const Icon( + : Icon( CollactionIcons.eye_off, - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, ), onPressed: () { setState(() { @@ -137,11 +137,12 @@ class _PasswordModalState extends State { splashRadius: 2, ), ), - cursorColor: kAccentColor, + cursorColor: context.kTheme.accentColor, ), CircleAvatar( - backgroundColor: - _disableButton ? kDisabledButtonColor : kAccentColor, + backgroundColor: _disableButton + ? context.kTheme.disabledButtonColor + : context.kTheme.accentColor, minRadius: 30, child: IconButton( onPressed: !_disableButton ? () => _validatePassword() : null, diff --git a/lib/presentation/licenses/licenses_page.dart b/lib/presentation/licenses/licenses_page.dart index 4534b47f..eb5af0a7 100644 --- a/lib/presentation/licenses/licenses_page.dart +++ b/lib/presentation/licenses/licenses_page.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; +import '../../core/core.dart'; import '../core/collaction_icons.dart'; import '../shared_widgets/custom_app_bars/custom_appbar.dart'; import '../shared_widgets/no_ripple_behavior.dart'; -import '../themes/constants.dart'; import '../utils/launch_url.dart'; import 'oss_licenses.dart'; @@ -24,7 +24,7 @@ class LicensesPage extends StatelessWidget { 'https://github.com/CollActionteam/collaction_app', ), style: ElevatedButton.styleFrom( - backgroundColor: kAccentColor, + backgroundColor: context.kTheme.accentColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(52), ), @@ -41,7 +41,7 @@ class LicensesPage extends StatelessWidget { ), ), ), - backgroundColor: kSecondaryColor, + backgroundColor: context.kTheme.secondaryColor, body: ScrollConfiguration( behavior: NoRippleBehavior(), child: SingleChildScrollView( diff --git a/lib/presentation/onboarding/onboarding_screen.dart b/lib/presentation/onboarding/onboarding_screen.dart index 12c13b4a..64e9234c 100644 --- a/lib/presentation/onboarding/onboarding_screen.dart +++ b/lib/presentation/onboarding/onboarding_screen.dart @@ -2,11 +2,11 @@ import 'package:auto_route/auto_route.dart'; import 'package:dots_indicator/dots_indicator.dart'; import 'package:flutter/material.dart'; +import '../../core/core.dart'; import '../../domain/core/i_settings_repository.dart'; import '../../infrastructure/core/injection.dart'; import '../../presentation/shared_widgets/no_ripple_behavior.dart'; import '../core/collaction_icons.dart'; -import '../themes/constants.dart'; import 'widgets/onboarding_step.dart'; class OnboardingPage extends StatefulWidget { @@ -79,20 +79,20 @@ class OnboardingPageState extends State { DotsIndicator( position: currentPage, dotsCount: 3, - decorator: const DotsDecorator( - activeColor: kAccentColor, - color: kSecondaryTransparent, + decorator: DotsDecorator( + activeColor: context.kTheme.accentColor, + color: context.kTheme.secondaryTransparent!, size: Size(12, 12), activeSize: Size(12, 12), ), ), const SizedBox(height: 25.0), FloatingActionButton( - backgroundColor: kAccentColor, + backgroundColor: context.kTheme.accentColor, onPressed: () => currentPage == 2.0 ? getStarted() : nextPage(), - child: const Icon( + child: Icon( CollactionIcons.arrow_right, - color: kSecondaryColor, + color: context.kTheme.secondaryColor, ), ), const SizedBox(height: 25.0), @@ -101,11 +101,11 @@ class OnboardingPageState extends State { onPressed: () => settingsRepository .setWasUserOnboarded(wasOnboarded: true) .then((_) => context.router.pop()), - child: const Text( + child: Text( "Skip", style: TextStyle( fontWeight: FontWeight.w700, - color: kAccentColor, + color: context.kTheme.accentColor, ), ), ), diff --git a/lib/presentation/onboarding/widgets/onboarding_step.dart b/lib/presentation/onboarding/widgets/onboarding_step.dart index da234b7a..12169ec8 100644 --- a/lib/presentation/onboarding/widgets/onboarding_step.dart +++ b/lib/presentation/onboarding/widgets/onboarding_step.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; +import '../../../core/core.dart'; import '../../core/collaction_icons.dart'; -import '../../themes/constants.dart'; /// Single onboarding slate class OnboardingStep extends StatelessWidget { @@ -32,7 +32,7 @@ class OnboardingStep extends StatelessWidget { Expanded( child: Icon( icon, - color: kAccentColor, + color: context.kTheme.accentColor, size: icon == CollactionIcons.goal ? 40 : 180 * scaleFactor, ), ), @@ -44,7 +44,7 @@ class OnboardingStep extends StatelessWidget { style: TextStyle( fontWeight: FontWeight.w700, fontSize: 34.0 * scaleFactor, - color: kPrimaryColor400, + color: context.kTheme.primaryColor400, ), ), SizedBox(height: 25.0 * scaleFactor), @@ -56,7 +56,7 @@ class OnboardingStep extends StatelessWidget { style: TextStyle( fontWeight: FontWeight.w300, fontSize: 16.0 * scaleFactor, - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, ), ), ), diff --git a/lib/presentation/profile/profile_screen.dart b/lib/presentation/profile/profile_screen.dart index ea260b62..302aa219 100644 --- a/lib/presentation/profile/profile_screen.dart +++ b/lib/presentation/profile/profile_screen.dart @@ -7,11 +7,11 @@ import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:share_plus/share_plus.dart'; import '../../application/user/profile/profile_bloc.dart'; +import '../../core/core.dart'; import '../core/collaction_icons.dart'; import '../routes/app_routes.gr.dart'; import '../shared_widgets/photo_selector.dart'; import '../shared_widgets/pill_button.dart'; -import '../themes/constants.dart'; import 'widget/profile_picture.dart'; import 'widget/profile_tab.dart'; @@ -42,7 +42,7 @@ class _UserProfilePageState extends State { final scaffold = Scaffold( extendBodyBehindAppBar: true, - backgroundColor: kAlmostTransparent, + backgroundColor: context.kTheme.almostTransparent, floatingActionButtonLocation: FloatingActionButtonLocation.miniEndTop, floatingActionButton: Column( @@ -52,7 +52,7 @@ class _UserProfilePageState extends State { onPressed: share, style: ElevatedButton.styleFrom( shape: const CircleBorder(), - backgroundColor: kEnabledButtonColor, + backgroundColor: context.kTheme.enabledButtonColor, ).merge( ButtonStyle( elevation: MaterialStateProperty.resolveWith( @@ -74,8 +74,8 @@ class _UserProfilePageState extends State { ElevatedButton( onPressed: () => context.router.push(const SettingsRoute()), style: ElevatedButton.styleFrom( - foregroundColor: kPrimaryColor0, - backgroundColor: Colors.white, + foregroundColor: context.kTheme.primaryColor0, + backgroundColor: context.background, shape: const CircleBorder(), tapTargetSize: MaterialTapTargetSize.padded, ).merge( @@ -90,11 +90,12 @@ class _UserProfilePageState extends State { ), ), ), - child: const Padding( - padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 4), + child: Padding( + padding: const EdgeInsets.symmetric( + vertical: 8.0, horizontal: 4), child: Icon( CollactionIcons.settings, - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, ), ), ), @@ -145,7 +146,8 @@ class _UserProfilePageState extends State { ); }, ), - backgroundColor: kAccentColor, + backgroundColor: + context.kTheme.accentColor, mini: true, child: const Icon( Icons.drive_file_rename_outline, @@ -208,9 +210,9 @@ class _UserProfilePageState extends State { state.isBioEditing == true ? 'Save' : 'Edit', - style: const TextStyle( + style: TextStyle( fontSize: 11, - color: kAccentColor, + color: context.kTheme.accentColor, fontWeight: FontWeight.w700, ), ), @@ -225,7 +227,7 @@ class _UserProfilePageState extends State { Expanded( child: TextFormField( controller: bioController, - cursorColor: kAccentColor, + cursorColor: context.kTheme.accentColor, maxLength: 150, decoration: InputDecoration( counterText: '', @@ -254,7 +256,8 @@ class _UserProfilePageState extends State { .copyWith( fontWeight: FontWeight.w300, fontSize: 17, - color: kPrimaryColor400, + color: + context.kTheme.primaryColor400, ), ), ), @@ -273,7 +276,7 @@ class _UserProfilePageState extends State { .copyWith( fontSize: 12, fontWeight: FontWeight.w400, - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, ), ), ], @@ -287,7 +290,7 @@ class _UserProfilePageState extends State { .copyWith( fontWeight: FontWeight.w300, fontSize: 17, - color: kPrimaryColor400, + color: context.kTheme.primaryColor400, ), ), ], @@ -295,8 +298,8 @@ class _UserProfilePageState extends State { RichText( text: TextSpan( text: 'Joined ', - style: const TextStyle( - color: kPrimaryColor200, + style: TextStyle( + color: context.kTheme.primaryColor200, fontWeight: FontWeight.w700, fontSize: 11, ), @@ -304,8 +307,8 @@ class _UserProfilePageState extends State { TextSpan( text: state .userProfile?.user.formattedJoinDate, - style: const TextStyle( - color: kPrimaryColor300, + style: TextStyle( + color: context.kTheme.primaryColor300, fontWeight: FontWeight.w700, fontSize: 11, ), diff --git a/lib/presentation/profile/widget/commitments_tab.dart b/lib/presentation/profile/widget/commitments_tab.dart index f8ed87e1..97c2aa70 100644 --- a/lib/presentation/profile/widget/commitments_tab.dart +++ b/lib/presentation/profile/widget/commitments_tab.dart @@ -1,11 +1,11 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; +import '../../../core/core.dart'; import '../../../domain/crowdaction/crowdaction.dart'; import '../../../domain/user/user.dart'; import '../../routes/app_routes.gr.dart'; import '../../shared_widgets/commitments/commitment_card.dart'; -import '../../themes/constants.dart'; import 'signup_cta.dart'; class CommitmentsTab extends StatelessWidget { @@ -33,12 +33,12 @@ class CommitmentsTab extends StatelessWidget { Padding( padding: const EdgeInsets.symmetric(horizontal: 10) + const EdgeInsets.only(top: 20), - child: const Text( + child: Text( 'My commitments', style: TextStyle( fontWeight: FontWeight.w700, fontSize: 28.0, - color: kPrimaryColor400, + color: context.kTheme.primaryColor400, ), ), ), diff --git a/lib/presentation/profile/widget/crowdactions_tab.dart b/lib/presentation/profile/widget/crowdactions_tab.dart index 05dad387..c6eb32eb 100644 --- a/lib/presentation/profile/widget/crowdactions_tab.dart +++ b/lib/presentation/profile/widget/crowdactions_tab.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; +import '../../../core/core.dart'; import '../../../domain/crowdaction/crowdaction.dart'; import '../../../domain/user/user.dart'; import '../../shared_widgets/micro_crowdaction_card.dart'; -import '../../themes/constants.dart'; import 'signup_cta.dart'; class CrowdActionsTab extends StatelessWidget { @@ -32,12 +32,12 @@ class CrowdActionsTab extends StatelessWidget { Padding( padding: const EdgeInsets.symmetric(horizontal: 10) + const EdgeInsets.only(top: 20), - child: const Text( + child: Text( 'My crowdactions', style: TextStyle( fontWeight: FontWeight.w700, fontSize: 28.0, - color: kPrimaryColor400, + color: context.kTheme.primaryColor400, ), ), ), diff --git a/lib/presentation/profile/widget/profile_tab.dart b/lib/presentation/profile/widget/profile_tab.dart index 39d23df9..b78c70e7 100644 --- a/lib/presentation/profile/widget/profile_tab.dart +++ b/lib/presentation/profile/widget/profile_tab.dart @@ -2,8 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import '../../../application/user/profile_tab/profile_tab_bloc.dart'; +import '../../../core/core.dart'; import '../../../domain/user/user.dart'; -import '../../themes/constants.dart'; import 'badges_tab.dart'; import 'commitments_tab.dart'; import 'crowdactions_tab.dart'; @@ -34,7 +34,7 @@ class _UserProfileTabState extends State child: DefaultTabController( length: 3, child: Container( - color: Colors.white, + color: context.background, constraints: const BoxConstraints(maxHeight: 600), child: Column( mainAxisSize: MainAxisSize.min, @@ -46,10 +46,10 @@ class _UserProfileTabState extends State margin: const EdgeInsets.only(bottom: 5.0), decoration: BoxDecoration( borderRadius: BorderRadius.circular(5.0), - color: kAlmostTransparent, + color: context.kTheme.almostTransparent, boxShadow: [ BoxShadow( - color: Colors.black.withOpacity(0.2), + color: context.onBackground.withOpacity(0.2), offset: const Offset(0, 2), blurRadius: 5.0, ), @@ -93,7 +93,7 @@ class _UserProfileTabState extends State ], unselectedLabelColor: const Color(0xffacb3bf), indicatorColor: Colors.transparent, - labelColor: kAccentColor, + labelColor: context.kTheme.accentColor, controller: _tabController, ), ), @@ -102,7 +102,7 @@ class _UserProfileTabState extends State builder: (context, state) { return Expanded( child: ColoredBox( - color: Colors.white, + color: context.background, child: TabBarView( controller: _tabController, children: [ diff --git a/lib/presentation/profile/widget/signup_cta.dart b/lib/presentation/profile/widget/signup_cta.dart index b924fd40..e994e37c 100644 --- a/lib/presentation/profile/widget/signup_cta.dart +++ b/lib/presentation/profile/widget/signup_cta.dart @@ -1,10 +1,10 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; +import '../../../core/core.dart'; import '../../../domain/user/user.dart'; import '../../routes/app_routes.gr.dart'; import '../../shared_widgets/pill_button.dart'; -import '../../themes/constants.dart'; class SignUpCTA extends StatelessWidget { final User? user; @@ -28,21 +28,21 @@ class SignUpCTA extends StatelessWidget { ? title! : 'Unique content based on your activity') : 'Become part of the CollAction crowd', - style: const TextStyle( + style: TextStyle( fontWeight: FontWeight.w700, fontSize: 34, - color: kPrimaryColor400, + color: context.kTheme.primaryColor400, ), textAlign: TextAlign.center, ), const SizedBox(height: 10), if (user == null) ...[ - const Text( + Text( 'Create an account to participate in \nCrowdActions and make waves with other \nlikeminded people!', style: TextStyle( fontWeight: FontWeight.w300, fontSize: 17, - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, ), textAlign: TextAlign.center, ), diff --git a/lib/presentation/settings/settings_layout.dart b/lib/presentation/settings/settings_layout.dart index 56dbdbc1..20b4fcfe 100644 --- a/lib/presentation/settings/settings_layout.dart +++ b/lib/presentation/settings/settings_layout.dart @@ -1,7 +1,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; -import '../themes/constants.dart'; +import '../../core/core.dart'; class SettingsLayout extends StatelessWidget { const SettingsLayout({super.key}); @@ -11,15 +11,15 @@ class SettingsLayout extends StatelessWidget { return Scaffold( appBar: AppBar( elevation: 0, - backgroundColor: kSecondaryColor, + backgroundColor: context.kTheme.secondaryColor, leading: RawMaterialButton( elevation: 5, onPressed: () => context.router.pop(), - child: const CircleAvatar( - backgroundColor: kSecondaryColor, + child: CircleAvatar( + backgroundColor: context.kTheme.secondaryColor, child: Icon( Icons.arrow_back_ios_new_outlined, - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, ), ), ), @@ -27,15 +27,16 @@ class SettingsLayout extends StatelessWidget { ElevatedButton( style: ButtonStyle( padding: MaterialStateProperty.all(const EdgeInsets.all(8)), - backgroundColor: MaterialStateProperty.all(kSecondaryColor), + backgroundColor: + MaterialStateProperty.all(context.kTheme.secondaryColor), elevation: MaterialStateProperty.all(2), ), onPressed: () => context.router.pop(), - child: const CircleAvatar( - backgroundColor: kSecondaryColor, + child: CircleAvatar( + backgroundColor: context.kTheme.secondaryColor, child: Icon( Icons.close_outlined, - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, ), ), ) diff --git a/lib/presentation/settings/settings_screen.dart b/lib/presentation/settings/settings_screen.dart index 1689e386..3b74b52e 100644 --- a/lib/presentation/settings/settings_screen.dart +++ b/lib/presentation/settings/settings_screen.dart @@ -2,6 +2,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import '../../core/core.dart'; import '/application/settings/build_information/build_information_bloc.dart'; import '../../../presentation/utils/launch_url.dart'; import '../../application/auth/auth_bloc.dart'; @@ -10,7 +11,6 @@ import '../../infrastructure/core/injection.dart'; import '../core/collaction_icons.dart'; import '../routes/app_routes.gr.dart'; import '../shared_widgets/custom_app_bars/custom_appbar.dart'; -import '../themes/constants.dart'; import 'widgets/build_information_tile.dart'; import 'widgets/settings_list_tile.dart'; import 'widgets/share_collaction_list_tile.dart'; @@ -93,7 +93,7 @@ class SettingsPage extends StatelessWidget { SettingsListTile( title: 'Log out', icon: CollactionIcons.logout, - iconColor: kErrorColor, + iconColor: context.kTheme.errorColor, onTap: () async { BlocProvider.of(context) .add(const AuthEvent.signedOut()); diff --git a/lib/presentation/settings/widgets/build_information_tile.dart b/lib/presentation/settings/widgets/build_information_tile.dart index 1092d7e6..62951d10 100644 --- a/lib/presentation/settings/widgets/build_information_tile.dart +++ b/lib/presentation/settings/widgets/build_information_tile.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; +import '../../../core/core.dart'; import '../../../domain/settings/build_information.dart'; -import '../../themes/constants.dart'; class BuildInformationTile extends StatelessWidget { final BuildInformation information; @@ -20,8 +20,8 @@ class BuildInformationTile extends StatelessWidget { const SizedBox(height: 5), Text( 'Build ${information.buildNumber}', - style: const TextStyle( - color: kPrimaryColor100, + style: TextStyle( + color: context.kTheme.primaryColor100, fontSize: 17, fontWeight: FontWeight.w300, ), @@ -29,17 +29,17 @@ class BuildInformationTile extends StatelessWidget { const SizedBox(height: 5), Text( 'Version ${information.version}', - style: const TextStyle( - color: kPrimaryColor100, + style: TextStyle( + color: context.kTheme.primaryColor100, fontSize: 17, fontWeight: FontWeight.w300, ), ), const SizedBox(height: 5), - const Text( + Text( 'Stichting CollAction', style: TextStyle( - color: kPrimaryColor100, + color: context.kTheme.primaryColor100, fontSize: 17, fontWeight: FontWeight.w300, ), @@ -48,8 +48,8 @@ class BuildInformationTile extends StatelessWidget { const SizedBox(height: 5), Text( 'Environment ${information.environment!.toUpperCase()}', - style: const TextStyle( - color: kPrimaryColor100, + style: TextStyle( + color: context.kTheme.primaryColor100, fontSize: 17, fontWeight: FontWeight.w300, ), diff --git a/lib/presentation/settings/widgets/settings_list_tile.dart b/lib/presentation/settings/widgets/settings_list_tile.dart index 4f9e1307..4de5921e 100644 --- a/lib/presentation/settings/widgets/settings_list_tile.dart +++ b/lib/presentation/settings/widgets/settings_list_tile.dart @@ -1,10 +1,11 @@ import 'package:flutter/material.dart'; -import '../../themes/constants.dart'; + +import '../../../core/core.dart'; class SettingsListTile extends StatelessWidget { final String title; final IconData icon; - final Color iconColor; + final Color? iconColor; final Function() onTap; final IconData? trailingIcon; @@ -13,7 +14,7 @@ class SettingsListTile extends StatelessWidget { required this.title, required this.icon, required this.onTap, - this.iconColor = kPrimaryColor300, + this.iconColor, this.trailingIcon, }); @@ -25,16 +26,16 @@ class SettingsListTile extends StatelessWidget { vertical: 15, horizontal: 20, ), - tileColor: kAlmostTransparent, + tileColor: context.kTheme.almostTransparent, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), ), leading: CircleAvatar( radius: 32.5, - backgroundColor: kSecondaryColor, + backgroundColor: context.kTheme.secondaryColor, child: Icon( icon, - color: iconColor, + color: iconColor ?? context.kTheme.primaryColor300, ), ), title: Text(title), diff --git a/lib/presentation/settings/widgets/share_collaction_list_tile.dart b/lib/presentation/settings/widgets/share_collaction_list_tile.dart index 3d3ef6ad..d2901a0c 100644 --- a/lib/presentation/settings/widgets/share_collaction_list_tile.dart +++ b/lib/presentation/settings/widgets/share_collaction_list_tile.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:share_plus/share_plus.dart'; +import '../../../core/core.dart'; import '../../core/collaction_icons.dart'; -import '../../themes/constants.dart'; import '../../utils/strings.dart'; class ShareCollactionListTile extends StatefulWidget { @@ -63,16 +63,16 @@ class ShareCollactionListTileState extends State { vertical: 15, horizontal: 20, ), - tileColor: kAlmostTransparent, + tileColor: context.kTheme.almostTransparent, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), ), - leading: const CircleAvatar( + leading: CircleAvatar( radius: 32.5, - backgroundColor: kSecondaryColor, + backgroundColor: context.kTheme.secondaryColor, child: Icon( CollactionIcons.share, - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, ), ), title: const Text( diff --git a/lib/presentation/shared_widgets/accent_chip.dart b/lib/presentation/shared_widgets/accent_chip.dart index d347b1ca..b2cd828f 100644 --- a/lib/presentation/shared_widgets/accent_chip.dart +++ b/lib/presentation/shared_widgets/accent_chip.dart @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; -import '../themes/constants.dart'; +import '../../core/core.dart'; class AccentChip extends StatelessWidget { final String text; final Widget? leading; final VoidCallback? onDeleted; - final Color color; + final Color? color; final bool noMaterialTapTargetSize; const AccentChip({ @@ -14,7 +14,7 @@ class AccentChip extends StatelessWidget { required this.text, this.leading, this.onDeleted, - this.color = kAccentColor, + this.color, this.noMaterialTapTargetSize = false, }); @@ -25,8 +25,12 @@ class AccentChip extends StatelessWidget { ? MaterialTapTargetSize.shrinkWrap : MaterialTapTargetSize.padded, avatar: leading, - backgroundColor: color, - shape: StadiumBorder(side: BorderSide(color: color)), + backgroundColor: color ?? context.kTheme.accentColor, + shape: StadiumBorder( + side: BorderSide( + color: color ?? context.kTheme.accentColor!, + ), + ), label: Text( text, style: Theme.of(context).textTheme.bodySmall?.copyWith( diff --git a/lib/presentation/shared_widgets/centered_loading_indicator.dart b/lib/presentation/shared_widgets/centered_loading_indicator.dart index 1392e7ca..73038787 100644 --- a/lib/presentation/shared_widgets/centered_loading_indicator.dart +++ b/lib/presentation/shared_widgets/centered_loading_indicator.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import '../themes/constants.dart'; +import '../../core/core.dart'; class CenteredLoadingIndicator extends StatelessWidget { final String label; @@ -17,11 +17,11 @@ class CenteredLoadingIndicator extends StatelessWidget { Center( child: Column( children: [ - const SizedBox( + SizedBox( height: 60, width: 60, child: CircularProgressIndicator( - color: kAccentColor, + color: context.kTheme.accentColor, strokeWidth: 5.0, ), ), diff --git a/lib/presentation/shared_widgets/commitment_card.dart b/lib/presentation/shared_widgets/commitment_card.dart index 7a1d4941..9eddef38 100644 --- a/lib/presentation/shared_widgets/commitment_card.dart +++ b/lib/presentation/shared_widgets/commitment_card.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; +import '../../core/core.dart'; import '../../domain/commitment/commitment.dart'; -import '../../presentation/themes/constants.dart'; import '../core/collaction_icons.dart'; import '../core/ionicons_utils.dart'; @@ -91,7 +91,9 @@ class _CommitmentCardState extends State<_CommitmentCard> { child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15.0), - color: active ? kSecondaryTransparent : kAlmostTransparent, + color: active + ? context.kTheme.secondaryTransparent + : context.kTheme.almostTransparent, ), margin: const EdgeInsets.symmetric( vertical: 5.0, @@ -102,20 +104,20 @@ class _CommitmentCardState extends State<_CommitmentCard> { children: [ Container( padding: const EdgeInsets.all(15.0), - decoration: const BoxDecoration( + decoration: BoxDecoration( shape: BoxShape.circle, - color: kAlmostTransparent, + color: context.kTheme.almostTransparent, ), alignment: Alignment.center, child: widget.commitment.icon != null ? Icon( IconUtil.fromString(widget.commitment.icon!), - color: kAccentColor, + color: context.kTheme.accentColor, size: 30, ) - : const Icon( + : Icon( CollactionIcons.collaction, - color: kAccentColor, + color: context.kTheme.accentColor, size: 30, ), ), @@ -153,10 +155,14 @@ class _CommitmentCardState extends State<_CommitmentCard> { minWidth: 40, ), decoration: BoxDecoration( - color: active ? kPrimaryColor400 : Colors.transparent, + color: active + ? context.kTheme.primaryColor400 + : Colors.transparent, shape: BoxShape.circle, border: Border.all( - color: active ? kPrimaryColor400 : kPrimaryColor200, + color: active + ? context.kTheme.primaryColor400! + : context.kTheme.primaryColor200!, width: 3, ), ), diff --git a/lib/presentation/shared_widgets/commitments/commitment_card.dart b/lib/presentation/shared_widgets/commitments/commitment_card.dart index f3bf6376..31f40571 100644 --- a/lib/presentation/shared_widgets/commitments/commitment_card.dart +++ b/lib/presentation/shared_widgets/commitments/commitment_card.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; +import '../../../core/core.dart'; import '../../../domain/crowdaction/crowdaction.dart'; -import '../../themes/constants.dart'; /// Creates a new CommitmentCard /// @@ -43,10 +43,12 @@ class CommitmentCard extends StatelessWidget { child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20.0), - color: active ? kAlmostTransparent : kSecondaryColor, + color: active + ? context.kTheme.almostTransparent + : context.kTheme.secondaryColor, border: active ? Border.all(color: Colors.transparent) - : Border.all(color: kPrimaryColor0), + : Border.all(color: context.kTheme.primaryColor0!), ), margin: const EdgeInsets.symmetric(vertical: 5.0), padding: const EdgeInsets.all(10.0), @@ -54,14 +56,14 @@ class CommitmentCard extends StatelessWidget { children: [ Container( padding: const EdgeInsets.all(15.0), - decoration: const BoxDecoration( + decoration: BoxDecoration( shape: BoxShape.circle, - color: kSecondaryColor, + color: context.kTheme.secondaryColor, ), alignment: Alignment.center, child: Icon( commitment.icon, - color: kAccentColor, + color: context.kTheme.accentColor, size: 30, ), ), @@ -80,7 +82,9 @@ class CommitmentCard extends StatelessWidget { style: textTheme.bodySmall!.copyWith( fontSize: 16, fontWeight: FontWeight.bold, - color: deactivated ? kPrimaryColor300 : kPrimaryColor400, + color: deactivated + ? context.kTheme.primaryColor300 + : context.kTheme.primaryColor400, ), maxLines: 1, overflow: TextOverflow.ellipsis, @@ -91,8 +95,9 @@ class CommitmentCard extends StatelessWidget { commitment.description!, style: textTheme.bodySmall!.copyWith( fontSize: 13, - color: - deactivated ? kPrimaryColor200 : kPrimaryColor300, + color: deactivated + ? context.kTheme.primaryColor200 + : context.kTheme.primaryColor300, ), softWrap: true, maxLines: 3, @@ -113,13 +118,15 @@ class CommitmentCard extends StatelessWidget { ), decoration: BoxDecoration( color: active - ? kPrimaryColor400.withAlpha(deactivated ? 50 : 255) + ? context.kTheme.primaryColor400 + ?.withAlpha(deactivated ? 50 : 255) : Colors.transparent, shape: BoxShape.circle, border: Border.all( color: active - ? kPrimaryColor400.withAlpha(deactivated ? 0 : 255) - : kPrimaryColor200, + ? context.kTheme.primaryColor400! + .withAlpha(deactivated ? 0 : 255) + : context.kTheme.primaryColor200!, width: 3, ), ), diff --git a/lib/presentation/shared_widgets/country_search_dialog.dart b/lib/presentation/shared_widgets/country_search_dialog.dart index cbe0ff7b..5016783b 100644 --- a/lib/presentation/shared_widgets/country_search_dialog.dart +++ b/lib/presentation/shared_widgets/country_search_dialog.dart @@ -1,7 +1,7 @@ import 'package:country_codes/country_codes.dart'; import 'package:flutter/material.dart'; -import '../themes/constants.dart'; +import '../../core/core.dart'; /// Dialog to search and select country for phone input class CountrySearch extends StatefulWidget { @@ -40,8 +40,11 @@ class CountrySearchState extends State { children: [ Expanded( child: TextField( - decoration: const InputDecoration( - prefixIcon: Icon(Icons.search, color: kAccentColor), + decoration: InputDecoration( + prefixIcon: Icon( + Icons.search, + color: context.kTheme.accentColor, + ), ), onChanged: _searchCountry, ), diff --git a/lib/presentation/shared_widgets/crowdaction_card.dart b/lib/presentation/shared_widgets/crowdaction_card.dart index 7d2a8d28..ced80ce5 100644 --- a/lib/presentation/shared_widgets/crowdaction_card.dart +++ b/lib/presentation/shared_widgets/crowdaction_card.dart @@ -5,12 +5,12 @@ import 'package:cached_network_image_platform_interface/cached_network_image_pla import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; +import '../../core/core.dart'; import '../../domain/crowdaction/crowdaction.dart'; import '../core/collaction_icons.dart'; import '../crowdaction/crowdaction_details/widgets/participants.dart'; import '../home/widgets/password_modal.dart'; import '../routes/app_routes.gr.dart'; -import '../themes/constants.dart'; import 'country_icon.dart'; import 'custom_fab.dart'; @@ -38,7 +38,7 @@ class _CrowdActionCardState extends State margin: const EdgeInsets.all(12.0), child: Material( borderRadius: BorderRadius.circular(20.0), - color: kSecondaryColor, + color: context.kTheme.secondaryColor, elevation: 4, child: InkWell( borderRadius: BorderRadius.circular(20.0), @@ -87,10 +87,10 @@ class _CrowdActionCardState extends State CustomFAB( heroTag: 'locked', isMini: true, - color: kSecondaryColor, + color: context.kTheme.secondaryColor, child: Icon( CollactionIcons.lock, - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, ), ), CountryIcon( @@ -126,10 +126,10 @@ class _CrowdActionCardState extends State widget.crowdAction.title, maxLines: 3, overflow: TextOverflow.ellipsis, - style: const TextStyle( + style: TextStyle( fontSize: 22.0, fontWeight: FontWeight.bold, - color: kPrimaryColor400, + color: context.kTheme.primaryColor400, ), ), ], @@ -145,7 +145,7 @@ class _CrowdActionCardState extends State style: Theme.of(context) .textTheme .bodyMedium - ?.copyWith(color: kInactiveColor), + ?.copyWith(color: context.kTheme.inactiveColor), ), ), if (widget.crowdAction.participantCount > 0) ...[ diff --git a/lib/presentation/shared_widgets/custom_app_bars/clean_app_bar.dart b/lib/presentation/shared_widgets/custom_app_bars/clean_app_bar.dart index bdfcc8bf..1a59e270 100644 --- a/lib/presentation/shared_widgets/custom_app_bars/clean_app_bar.dart +++ b/lib/presentation/shared_widgets/custom_app_bars/clean_app_bar.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; -import '../../themes/constants.dart'; +import '../../../core/core.dart'; class CleanAppBar extends StatelessWidget implements PreferredSizeWidget { final String title; final bool centerTitle; - final Color backgroundColor; + final Color? backgroundColor; final ElevatedButton? leading; final List? actions; final double elevation; @@ -17,7 +17,7 @@ class CleanAppBar extends StatelessWidget implements PreferredSizeWidget { this.centerTitle = true, this.leading, this.actions, - this.backgroundColor = kSecondaryColor, + this.backgroundColor, this.titleTextStyle, this.elevation = 0.0, }); @@ -29,7 +29,7 @@ class CleanAppBar extends StatelessWidget implements PreferredSizeWidget { elevatedButtonTheme: ElevatedButtonThemeData( style: ButtonStyle( overlayColor: MaterialStateProperty.resolveWith( - (states) => kAlmostTransparent, + (states) => context.kTheme.almostTransparent, ), elevation: MaterialStateProperty.all(0.0), shape: MaterialStateProperty.all( @@ -41,7 +41,7 @@ class CleanAppBar extends StatelessWidget implements PreferredSizeWidget { ), child: AppBar( automaticallyImplyLeading: false, - backgroundColor: backgroundColor, + backgroundColor: backgroundColor ?? context.kTheme.secondaryColor, elevation: elevation, centerTitle: centerTitle, leading: leading, @@ -51,7 +51,7 @@ class CleanAppBar extends StatelessWidget implements PreferredSizeWidget { Theme.of(context) .textTheme .titleLarge - ?.copyWith(color: kPrimaryColor), + ?.copyWith(color: context.kTheme.primaryColor), ), ); } diff --git a/lib/presentation/shared_widgets/custom_app_bars/custom_appbar.dart b/lib/presentation/shared_widgets/custom_app_bars/custom_appbar.dart index be10ad26..dd49ba23 100644 --- a/lib/presentation/shared_widgets/custom_app_bars/custom_appbar.dart +++ b/lib/presentation/shared_widgets/custom_app_bars/custom_appbar.dart @@ -1,8 +1,8 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; +import '../../../core/core.dart'; import '../../core/collaction_icons.dart'; -import '../../themes/constants.dart'; class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { final String title; @@ -26,13 +26,13 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { padding: const EdgeInsets.all(8.0), child: Material( borderRadius: BorderRadius.circular(20), - color: Colors.white, + color: context.background, child: InkWell( borderRadius: BorderRadius.circular(20), onTap: () => context.router.pop(), - child: const Icon( + child: Icon( CollactionIcons.left, - color: kPrimaryColor400, + color: context.kTheme.primaryColor400, ), ), ), @@ -45,8 +45,8 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { child: ElevatedButton( onPressed: () => context.router.pop(), style: ElevatedButton.styleFrom( - foregroundColor: kPrimaryColor0, - backgroundColor: Colors.white, + foregroundColor: context.kTheme.primaryColor0, + backgroundColor: context.background, shape: const CircleBorder(), tapTargetSize: MaterialTapTargetSize.padded, ).merge( @@ -61,16 +61,16 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { ), ), ), - child: const Icon( + child: Icon( CollactionIcons.cross, - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, ), ), ), ], title: Text( title, - style: const TextStyle(color: kPrimaryColor), + style: TextStyle(color: context.kTheme.primaryColor), ), ); } diff --git a/lib/presentation/shared_widgets/custom_app_bars/scrollable_app_bar.dart b/lib/presentation/shared_widgets/custom_app_bars/scrollable_app_bar.dart index 80faef6e..ed19ec2e 100644 --- a/lib/presentation/shared_widgets/custom_app_bars/scrollable_app_bar.dart +++ b/lib/presentation/shared_widgets/custom_app_bars/scrollable_app_bar.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; -import '../../themes/constants.dart'; +import '../../../core/core.dart'; class ScrollableAppBar extends StatefulWidget implements PreferredSizeWidget { final String title; final bool centerTitle; - final Color backgroundColor; + final Color? backgroundColor; final ElevatedButton? leading; final List? actions; final TextStyle? titleTextStyle; @@ -18,7 +18,7 @@ class ScrollableAppBar extends StatefulWidget implements PreferredSizeWidget { super.key, this.title = '', this.centerTitle = true, - this.backgroundColor = kSecondaryColor, + this.backgroundColor, this.titleTextStyle, this.leading, this.actions, @@ -75,7 +75,7 @@ class ScrollableAppBarState extends State { elevatedButtonTheme: ElevatedButtonThemeData( style: ButtonStyle( overlayColor: MaterialStateProperty.resolveWith( - (states) => kAlmostTransparent, + (states) => context.kTheme.almostTransparent, ), elevation: MaterialStateProperty.all(0.0), shape: MaterialStateProperty.all( @@ -86,7 +86,8 @@ class ScrollableAppBarState extends State { ), ), child: AppBar( - backgroundColor: widget.backgroundColor, + backgroundColor: + widget.backgroundColor ?? context.kTheme.secondaryColor, elevation: currentElevation, centerTitle: widget.centerTitle, leading: widget.leading, @@ -106,7 +107,7 @@ class ScrollableAppBarState extends State { Theme.of(context) .textTheme .titleLarge - ?.copyWith(color: kPrimaryColor), + ?.copyWith(color: context.kTheme.primaryColor), ), ); } diff --git a/lib/presentation/shared_widgets/custom_fab.dart b/lib/presentation/shared_widgets/custom_fab.dart index f1050f23..40e21aae 100644 --- a/lib/presentation/shared_widgets/custom_fab.dart +++ b/lib/presentation/shared_widgets/custom_fab.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import '../themes/constants.dart'; +import '../../core/core.dart'; class CustomFAB extends StatelessWidget { final Widget child; @@ -23,8 +23,10 @@ class CustomFAB extends StatelessWidget { return FloatingActionButton( onPressed: onPressed, heroTag: heroTag, - backgroundColor: - color ?? (onPressed != null ? kAccentColor : kDisabledButtonColor), + backgroundColor: color ?? + (onPressed != null + ? context.kTheme.accentColor + : context.kTheme.disabledButtonColor), mini: isMini, child: child, ); diff --git a/lib/presentation/shared_widgets/expandable_markdown_text.dart b/lib/presentation/shared_widgets/expandable_markdown_text.dart index 4fb18865..c2c1f652 100644 --- a/lib/presentation/shared_widgets/expandable_markdown_text.dart +++ b/lib/presentation/shared_widgets/expandable_markdown_text.dart @@ -3,7 +3,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; -import '../themes/constants.dart'; +import '../../core/core.dart'; import '../themes/markdown_stylesheet.dart'; import '../utils/launch_url.dart'; @@ -86,7 +86,7 @@ class _ExpandableMarkdownState extends State text: TextSpan( style: Theme.of(context).textTheme.bodyMedium?.copyWith( fontWeight: FontWeight.w300, - color: kAccentColor, + color: context.kTheme.accentColor, fontSize: 17, height: 1.5, ), diff --git a/lib/presentation/shared_widgets/expandable_text.dart b/lib/presentation/shared_widgets/expandable_text.dart index 1276c265..431899a4 100644 --- a/lib/presentation/shared_widgets/expandable_text.dart +++ b/lib/presentation/shared_widgets/expandable_text.dart @@ -1,7 +1,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; -import '../themes/constants.dart'; +import '../../core/core.dart'; /// Text widget to show read more and read less class ExpandableText extends StatefulWidget { @@ -9,7 +9,7 @@ class ExpandableText extends StatefulWidget { this.text, { super.key, this.trimLines = 3, - this.clickableTextColor = kAccentColor, + this.clickableTextColor, this.readMoreText = "more", this.readLessText = "less", this.style = const TextStyle(color: Colors.black), @@ -22,7 +22,7 @@ class ExpandableText extends StatefulWidget { final int trimLines; /// Read More & Read Less text color - final Color clickableTextColor; + final Color? clickableTextColor; /// Read More text final String readMoreText; @@ -91,8 +91,9 @@ class ExpandableTextState extends State TextSpan( text: readMore ? widget.readMoreText : widget.readLessText, style: TextStyle( - color: widget.clickableTextColor, - decorationColor: widget.clickableTextColor, + color: widget.clickableTextColor ?? context.kTheme.accentColor, + decorationColor: + widget.clickableTextColor ?? context.kTheme.accentColor, decorationStyle: TextDecorationStyle.solid, ), recognizer: TapGestureRecognizer()..onTap = onTapLink, diff --git a/lib/presentation/shared_widgets/image_skeleton_loader.dart b/lib/presentation/shared_widgets/image_skeleton_loader.dart index fda6823a..a5f51a1f 100644 --- a/lib/presentation/shared_widgets/image_skeleton_loader.dart +++ b/lib/presentation/shared_widgets/image_skeleton_loader.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:shimmer/shimmer.dart'; -import '../themes/constants.dart'; +import '../../core/core.dart'; class ImageSkeletonLoader extends StatelessWidget { final double height; @@ -16,13 +16,13 @@ class ImageSkeletonLoader extends StatelessWidget { @override Widget build(BuildContext context) { return Shimmer.fromColors( - baseColor: kSecondaryTransparent, - highlightColor: kAlmostTransparent, + baseColor: context.kTheme.secondaryTransparent!, + highlightColor: context.kTheme.almostTransparent!, child: Container( height: height, width: MediaQuery.of(context).size.width, decoration: BoxDecoration( - color: kSecondaryTransparent, + color: context.kTheme.secondaryTransparent, shape: isCircle ? BoxShape.circle : BoxShape.rectangle, ), ), diff --git a/lib/presentation/shared_widgets/micro_crowdaction_card.dart b/lib/presentation/shared_widgets/micro_crowdaction_card.dart index ab695dda..e9513051 100644 --- a/lib/presentation/shared_widgets/micro_crowdaction_card.dart +++ b/lib/presentation/shared_widgets/micro_crowdaction_card.dart @@ -2,10 +2,10 @@ import 'package:auto_route/auto_route.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; +import '../../core/core.dart'; import '../../domain/crowdaction/crowdaction.dart'; import '../home/widgets/password_modal.dart'; import '../routes/app_routes.gr.dart'; -import '../themes/constants.dart'; import 'accent_chip.dart'; import 'country_icon.dart'; import 'micro_lock.dart'; @@ -70,8 +70,8 @@ class MicroCrowdActionCard extends StatelessWidget { AccentChip( text: crowdAction.statusChipLabel, color: crowdAction.isOpen || crowdAction.isWaiting - ? kAccentColor - : kPrimaryColor200, + ? context.kTheme.accentColor + : context.kTheme.primaryColor200, leading: Icon( crowdAction.isOpen || crowdAction.isWaiting ? Icons.check @@ -111,10 +111,10 @@ class MicroCrowdActionCard extends StatelessWidget { crowdAction.description, softWrap: false, maxLines: 1, - style: const TextStyle( + style: TextStyle( fontSize: 12, fontWeight: FontWeight.w400, - color: kInactiveColor, + color: context.kTheme.inactiveColor, ), overflow: TextOverflow.ellipsis, ), diff --git a/lib/presentation/shared_widgets/micro_lock.dart b/lib/presentation/shared_widgets/micro_lock.dart index 91149c12..3fa2b33c 100644 --- a/lib/presentation/shared_widgets/micro_lock.dart +++ b/lib/presentation/shared_widgets/micro_lock.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; +import '../../core/core.dart'; import '../core/collaction_icons.dart'; -import '../themes/constants.dart'; class MicroLock extends StatelessWidget { const MicroLock({super.key}); @@ -13,11 +13,11 @@ class MicroLock extends StatelessWidget { height: 32, decoration: BoxDecoration( shape: BoxShape.circle, - border: Border.all(color: kPrimaryColor0), + border: Border.all(color: context.kTheme.primaryColor0!), ), - child: const Icon( + child: Icon( CollactionIcons.lock, - color: kPrimaryColor300, + color: context.kTheme.primaryColor300, size: 15.0, ), ); diff --git a/lib/presentation/shared_widgets/participant_avatars.dart b/lib/presentation/shared_widgets/participant_avatars.dart index a357f1cb..ef21c430 100644 --- a/lib/presentation/shared_widgets/participant_avatars.dart +++ b/lib/presentation/shared_widgets/participant_avatars.dart @@ -7,9 +7,9 @@ import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:shimmer/shimmer.dart'; import '../../application/participation/top_participants/top_participants_bloc.dart'; +import '../../core/core.dart'; import '../../domain/participation/participation.dart'; import '../../infrastructure/core/injection.dart'; -import '../themes/constants.dart'; import 'shimmers/top_participants_shimmer.dart'; class TopParticipantAvatars extends StatelessWidget { @@ -34,8 +34,8 @@ class TopParticipantAvatars extends StatelessWidget { return state.map( initial: (_) => const SizedBox.shrink(), fetching: (_) => Shimmer.fromColors( - baseColor: kPrimaryColor100, - highlightColor: kPrimaryColor200, + baseColor: context.kTheme.primaryColor100!, + highlightColor: context.kTheme.primaryColor200!, child: const TopParticipantsShimmer(), ), fetched: (state) => SizedBox( diff --git a/lib/presentation/shared_widgets/phone_input.dart b/lib/presentation/shared_widgets/phone_input.dart index b0db1661..785efe50 100644 --- a/lib/presentation/shared_widgets/phone_input.dart +++ b/lib/presentation/shared_widgets/phone_input.dart @@ -2,7 +2,7 @@ import 'package:country_codes/country_codes.dart'; import 'package:flutter/material.dart'; import 'package:phone_number/phone_number.dart'; -import '../themes/constants.dart'; +import '../../core/core.dart'; import 'country_search_dialog.dart'; /// Phone input with country search and selection @@ -160,10 +160,10 @@ class PhoneInputState extends State { : 'Your phone number is not valid'), style: TextStyle( color: validatedNumber - ? kInactiveColor + ? context.kTheme.inactiveColor : widget.phoneNumberController.value.text.isEmpty - ? kInactiveColor - : kErrorColor, + ? context.kTheme.inactiveColor + : context.kTheme.errorColor, ), ), ), diff --git a/lib/presentation/shared_widgets/photo_selector.dart b/lib/presentation/shared_widgets/photo_selector.dart index 2c4b16b8..d57d35c9 100644 --- a/lib/presentation/shared_widgets/photo_selector.dart +++ b/lib/presentation/shared_widgets/photo_selector.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:image_cropper/image_cropper.dart'; import 'package:image_picker/image_picker.dart'; -import '../themes/constants.dart'; +import '../../core/core.dart'; class PhotoSelector extends StatefulWidget { final Function(File)? onSelected; @@ -142,7 +142,7 @@ class PhotoSelectorState extends State { uiSettings: [ AndroidUiSettings( toolbarTitle: 'Profile Photo', - toolbarColor: kAccentColor, + toolbarColor: context.kTheme.accentColor, toolbarWidgetColor: Colors.white, lockAspectRatio: true, ), diff --git a/lib/presentation/shared_widgets/pill_button.dart b/lib/presentation/shared_widgets/pill_button.dart index 16cf8b7e..525a180a 100644 --- a/lib/presentation/shared_widgets/pill_button.dart +++ b/lib/presentation/shared_widgets/pill_button.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import '../themes/constants.dart'; +import '../../core/core.dart'; class PillButton extends StatelessWidget { final String text; @@ -12,27 +12,29 @@ class PillButton extends StatelessWidget { final bool isLoading; final bool lightBackground; - const PillButton( - {super.key, - required this.text, - this.leading, - this.onTap, - this.isEnabled = true, - this.margin, - this.width, - this.isLoading = false, - this.lightBackground = false}); + const PillButton({ + super.key, + required this.text, + this.leading, + this.onTap, + this.isEnabled = true, + this.margin, + this.width, + this.isLoading = false, + this.lightBackground = false, + }); - const PillButton.icon( - {super.key, - required this.text, - required this.leading, - this.onTap, - this.isEnabled = true, - this.margin, - this.width, - this.isLoading = false, - this.lightBackground = false}); + const PillButton.icon({ + super.key, + required this.text, + required this.leading, + this.onTap, + this.isEnabled = true, + this.margin, + this.width, + this.isLoading = false, + this.lightBackground = false, + }); @override Widget build(BuildContext context) { @@ -49,14 +51,17 @@ class PillButton extends StatelessWidget { ? ElevatedButton( onPressed: () {}, style: ElevatedButton.styleFrom( - backgroundColor: - lightBackground ? Colors.white : kAccentColor, + backgroundColor: lightBackground + ? Colors.white + : context.kTheme.accentColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(52), ), ), child: CircularProgressIndicator( - color: lightBackground ? kAccentColor : Colors.white, + color: lightBackground + ? context.kTheme.accentColor + : Colors.white, ), ) : ElevatedButton.icon( @@ -66,7 +71,9 @@ class PillButton extends StatelessWidget { style: TextStyle( fontWeight: FontWeight.w700, fontSize: 15, - color: lightBackground ? kAccentColor : Colors.white, + color: lightBackground + ? context.kTheme.accentColor + : Colors.white, ), ), onPressed: isEnabled ? onTap : null, @@ -74,9 +81,11 @@ class PillButton extends StatelessWidget { backgroundColor: MaterialStateProperty.resolveWith( (states) { if (states.contains(MaterialState.disabled)) { - return kAlmostTransparent; + return context.kTheme.almostTransparent; } - return lightBackground ? Colors.white : kAccentColor; + return lightBackground + ? Colors.white + : context.kTheme.accentColor; }, ), elevation: MaterialStateProperty.all(0), diff --git a/lib/presentation/shared_widgets/pin_input/pin_input.dart b/lib/presentation/shared_widgets/pin_input/pin_input.dart index 5ccd4698..23a3c76c 100644 --- a/lib/presentation/shared_widgets/pin_input/pin_input.dart +++ b/lib/presentation/shared_widgets/pin_input/pin_input.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import '../../themes/constants.dart'; +import '../../../core/core.dart'; class PinInput extends StatefulWidget { final int pinLength; @@ -48,7 +48,7 @@ class PinInputState extends State { FilteringTextInputFormatter.allow(RegExp('[0-9]')), ], style: const TextStyle(fontSize: 28, letterSpacing: 4), - cursorColor: kAccentColor, + cursorColor: context.kTheme.accentColor, decoration: InputDecoration( contentPadding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.02), @@ -60,11 +60,11 @@ class PinInputState extends State { ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(20.0), - borderSide: const BorderSide(color: kAccentColor), + borderSide: BorderSide(color: context.kTheme.accentColor!), ), errorBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(20.0), - borderSide: const BorderSide(color: kAccentColor), + borderSide: BorderSide(color: context.kTheme.accentColor!), ), ), onChanged: (value) { diff --git a/lib/presentation/shared_widgets/pin_input/pin_text_field.dart b/lib/presentation/shared_widgets/pin_input/pin_text_field.dart index e79edb0e..311e4abc 100644 --- a/lib/presentation/shared_widgets/pin_input/pin_text_field.dart +++ b/lib/presentation/shared_widgets/pin_input/pin_text_field.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import '../../themes/constants.dart'; +import '../../../core/core.dart'; class PinTextField extends StatelessWidget { final bool readOnly; @@ -46,11 +46,11 @@ class PinTextField extends StatelessWidget { ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(20.0), - borderSide: const BorderSide(color: kAccentColor), + borderSide: BorderSide(color: context.kTheme.accentColor!), ), errorBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(20.0), - borderSide: const BorderSide(color: kAccentColor), + borderSide: BorderSide(color: context.kTheme.accentColor!), ), ), focusNode: focusNode, diff --git a/lib/presentation/shared_widgets/rectangle_button.dart b/lib/presentation/shared_widgets/rectangle_button.dart index 633d2427..d09c8fd6 100644 --- a/lib/presentation/shared_widgets/rectangle_button.dart +++ b/lib/presentation/shared_widgets/rectangle_button.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import '../themes/constants.dart'; +import '../../core/core.dart'; class RectangleButton extends StatelessWidget { final String text; @@ -21,14 +21,16 @@ class RectangleButton extends StatelessWidget { onPressed: enabled ? onTap : null, style: ButtonStyle( overlayColor: MaterialStateProperty.all( - kSecondaryColor.withOpacity(0.1), + context.kTheme.secondaryColor?.withOpacity(0.1), ), padding: MaterialStateProperty.all( const EdgeInsets.symmetric(vertical: 16.0), ), backgroundColor: enabled - ? MaterialStateProperty.all(kEnabledButtonColor) - : MaterialStateProperty.all(kDisabledButtonColor), + ? MaterialStateProperty.all( + context.kTheme.enabledButtonColor) + : MaterialStateProperty.all( + context.kTheme.disabledButtonColor), shape: MaterialStateProperty.all( const RoundedRectangleBorder(), ), @@ -42,8 +44,8 @@ class RectangleButton extends StatelessWidget { ], Text( text, - style: const TextStyle( - color: kSecondaryColor, + style: TextStyle( + color: context.kTheme.secondaryColor, fontWeight: FontWeight.w700, ), ), diff --git a/lib/presentation/shared_widgets/secondary_chip.dart b/lib/presentation/shared_widgets/secondary_chip.dart index ffcb2cb6..dd77abf0 100644 --- a/lib/presentation/shared_widgets/secondary_chip.dart +++ b/lib/presentation/shared_widgets/secondary_chip.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import '../themes/constants.dart'; +import '../../core/core.dart'; class SecondaryChip extends StatelessWidget { final String text; @@ -17,8 +17,10 @@ class SecondaryChip extends StatelessWidget { Widget build(BuildContext context) { return Chip( avatar: leading, - backgroundColor: kSecondaryColor, - shape: const StadiumBorder(side: BorderSide(color: kAlmostTransparent)), + backgroundColor: context.kTheme.secondaryColor, + shape: StadiumBorder( + side: BorderSide(color: context.kTheme.almostTransparent!), + ), label: Text( text, style: Theme.of(context).textTheme.bodySmall, diff --git a/lib/presentation/shared_widgets/selectable_chip.dart b/lib/presentation/shared_widgets/selectable_chip.dart index 465db34a..7cb0dfe2 100644 --- a/lib/presentation/shared_widgets/selectable_chip.dart +++ b/lib/presentation/shared_widgets/selectable_chip.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import '../themes/constants.dart'; +import '../../core/core.dart'; class SelectableChip extends StatelessWidget { final String text; @@ -30,20 +30,27 @@ class SelectableChip extends StatelessWidget { ), shape: MaterialStateProperty.all( StadiumBorder( - side: BorderSide( - color: selected ? kPrimaryColor400 : kAlmostTransparent)), + side: BorderSide( + color: selected + ? context.kTheme.primaryColor400! + : context.kTheme.almostTransparent!, + ), + ), ), overlayColor: MaterialStateColor.resolveWith( - (states) => kSecondaryColor.withOpacity(0.1), + (states) => context.kTheme.secondaryColor!.withOpacity(0.1), ), - backgroundColor: MaterialStateProperty.all( - selected ? kPrimaryColor400 : kSecondaryColor), + backgroundColor: MaterialStateProperty.all(selected + ? context.kTheme.primaryColor400 + : context.kTheme.secondaryColor), ), child: Text( text, style: Theme.of(context).textTheme.bodySmall?.copyWith( fontSize: 11, - color: selected ? kSecondaryColor : kPrimaryColor400, + color: selected + ? context.kTheme.secondaryColor + : context.kTheme.primaryColor400, fontWeight: FontWeight.w700, ), ), diff --git a/lib/presentation/shared_widgets/shimmers/commitment_card_shimmer.dart b/lib/presentation/shared_widgets/shimmers/commitment_card_shimmer.dart index e1e7a655..f1d6fc14 100644 --- a/lib/presentation/shared_widgets/shimmers/commitment_card_shimmer.dart +++ b/lib/presentation/shared_widgets/shimmers/commitment_card_shimmer.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:shimmer/shimmer.dart'; +import '../../../core/core.dart'; import '../../core/collaction_icons.dart'; -import '../../themes/constants.dart'; import 'title_shimmer_line.dart'; class CommitmentCardShimmer extends StatelessWidget { @@ -13,8 +13,8 @@ class CommitmentCardShimmer extends StatelessWidget { return Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20.0), - color: kSecondaryColor, - border: Border.all(color: kPrimaryColor0), + color: context.kTheme.secondaryColor, + border: Border.all(color: context.kTheme.primaryColor0!), ), margin: const EdgeInsets.symmetric(vertical: 5.0), padding: const EdgeInsets.all(10.0), @@ -22,17 +22,17 @@ class CommitmentCardShimmer extends StatelessWidget { children: [ Container( padding: const EdgeInsets.all(15.0), - decoration: const BoxDecoration( + decoration: BoxDecoration( shape: BoxShape.circle, - color: kSecondaryColor, + color: context.kTheme.secondaryColor, ), alignment: Alignment.center, child: Shimmer.fromColors( - baseColor: kSecondaryTransparent, - highlightColor: kAlmostTransparent, - child: const Icon( + baseColor: context.kTheme.secondaryTransparent!, + highlightColor: context.kTheme.almostTransparent!, + child: Icon( CollactionIcons.commitment, - color: kPrimaryColor0, + color: context.kTheme.primaryColor0, size: 30, ), ), diff --git a/lib/presentation/shared_widgets/shimmers/title_shimmer_line.dart b/lib/presentation/shared_widgets/shimmers/title_shimmer_line.dart index 57015f63..b9018146 100644 --- a/lib/presentation/shared_widgets/shimmers/title_shimmer_line.dart +++ b/lib/presentation/shared_widgets/shimmers/title_shimmer_line.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import '../../themes/constants.dart'; +import '../../../core/core.dart'; class TitleShimmerLine extends StatelessWidget { final double width; @@ -17,7 +17,7 @@ class TitleShimmerLine extends StatelessWidget { width: width, height: height, decoration: BoxDecoration( - color: kSecondaryTransparent, + color: context.kTheme.secondaryTransparent, borderRadius: BorderRadius.circular(10), ), ); diff --git a/lib/presentation/shared_widgets/shimmers/top_participants_shimmer.dart b/lib/presentation/shared_widgets/shimmers/top_participants_shimmer.dart index 56e5b3c5..98bd9efc 100644 --- a/lib/presentation/shared_widgets/shimmers/top_participants_shimmer.dart +++ b/lib/presentation/shared_widgets/shimmers/top_participants_shimmer.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import '../../themes/constants.dart'; +import '../../../core/core.dart'; class TopParticipantsShimmer extends StatelessWidget { const TopParticipantsShimmer(); @@ -17,7 +17,7 @@ class TopParticipantsShimmer extends StatelessWidget { width: 40, height: 40, decoration: BoxDecoration( - color: kSecondaryTransparent, + color: context.kTheme.secondaryTransparent, borderRadius: BorderRadius.circular(20), ), ), @@ -28,7 +28,7 @@ class TopParticipantsShimmer extends StatelessWidget { height: 40, padding: const EdgeInsets.all(2), decoration: BoxDecoration( - color: kSecondaryTransparent, + color: context.kTheme.secondaryTransparent, borderRadius: BorderRadius.circular(20), ), ), @@ -39,7 +39,7 @@ class TopParticipantsShimmer extends StatelessWidget { width: 40, height: 40, decoration: BoxDecoration( - color: kSecondaryTransparent, + color: context.kTheme.secondaryTransparent, borderRadius: BorderRadius.circular(20), ), ), diff --git a/lib/presentation/themes/constants.dart b/lib/presentation/themes/constants.dart deleted file mode 100644 index af0ecc4d..00000000 --- a/lib/presentation/themes/constants.dart +++ /dev/null @@ -1,43 +0,0 @@ -import 'package:flutter/material.dart'; - -const Color kPrimaryColor = Colors.black; -const Color kSecondaryColor = Color(0xFFF9F9F9); -const Color kAccentColor = Color(0xFF2EB494); - -const Color kShadowColor = Color.fromRGBO(0, 0, 0, 0.1); - -const Color kInactiveColor = Color(0xFF666666); -const Color kAlmostTransparent = Color(0xFFEFEFEF); -const Color kSecondaryTransparent = Color(0xFFCCCCCC); - -const Color kEnabledButtonColor = Color(0xFF2EB494); -const Color kDisabledButtonColor = Color(0xFF999999); - -const Color kErrorColor = Color(0xFFE11900); -const Color kSuccessColor = Color(0xFF2EB494); - -const Color kIrisColor = Color(0xFF5D5FEF); - -const Color kPrimaryColor0 = Color(0xFFEFEFEF); -const Color kPrimaryColor100 = Color(0xFFCCCCCC); -const Color kPrimaryColor200 = Color(0xFF999999); -const Color kPrimaryColor300 = Color(0xFF666666); -const Color kPrimaryColor400 = Color(0xFF333333); -const Color kPrimaryColor500 = Color(0xFF000000); - -const TextStyle kCaption1 = TextStyle( - fontSize: 12, - height: 16 / 12, -); - -const TextStyle body = TextStyle( - fontSize: 17, - fontWeight: FontWeight.w300, - height: 26 / 17, -); - -const TextStyle kTitle1 = TextStyle( - fontSize: 28, - height: 34 / 28, - fontWeight: FontWeight.w700, -); diff --git a/lib/presentation/themes/markdown_stylesheet.dart b/lib/presentation/themes/markdown_stylesheet.dart index 429732d2..0d6f3233 100644 --- a/lib/presentation/themes/markdown_stylesheet.dart +++ b/lib/presentation/themes/markdown_stylesheet.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; -import 'constants.dart'; +import '../../core/core.dart'; MarkdownStyleSheet getStylesheetFromTheme(ThemeData theme) => MarkdownStyleSheet( @@ -13,7 +13,7 @@ MarkdownStyleSheet getStylesheetFromTheme(ThemeData theme) => a: theme.textTheme.bodyMedium?.copyWith( fontSize: 17, fontWeight: FontWeight.w300, - color: kAccentColor, + color: theme.kTheme.accentColor, height: 1.5, ), ); diff --git a/lib/presentation/themes/themes.dart b/lib/presentation/themes/themes.dart index 54a6fb5e..54ff5a57 100644 --- a/lib/presentation/themes/themes.dart +++ b/lib/presentation/themes/themes.dart @@ -1,68 +1,50 @@ import 'package:flutter/material.dart'; import 'package:widgetbook_annotation/widgetbook_annotation.dart'; -import 'constants.dart'; +import '../../core/core.dart'; + +part 'widget_themes/button.theme.dart'; +part 'widget_themes/input.theme.dart'; +part 'widget_themes/scheme.theme.dart'; +part 'widget_themes/text.theme.dart'; @WidgetbookTheme(name: 'Light') ThemeData lightTheme() { final theme = ThemeData.light(); - return theme.copyWith( - primaryColor: kPrimaryColor, - colorScheme: theme.colorScheme.copyWith( - secondary: kAccentColor, - primary: kAccentColor, - ), - brightness: Brightness.light, - scaffoldBackgroundColor: Colors.white, - textTheme: theme.textTheme.apply( - fontFamily: 'Rubik', - bodyColor: Colors.black, - displayColor: Colors.black, - ), - buttonTheme: const ButtonThemeData( - buttonColor: kPrimaryColor, - ), - textButtonTheme: TextButtonThemeData( - style: TextButton.styleFrom( - foregroundColor: kAccentColor, - ), - ), - inputDecorationTheme: const InputDecorationTheme( - hintStyle: TextStyle( - fontSize: 15, - fontWeight: FontWeight.w300, - ), - labelStyle: TextStyle(color: kInactiveColor), - filled: true, - fillColor: kAlmostTransparent, - focusColor: kInactiveColor, - enabledBorder: UnderlineInputBorder( - borderSide: BorderSide.none, - borderRadius: BorderRadius.zero, - ), - focusedBorder: UnderlineInputBorder( - borderSide: BorderSide( - color: kAccentColor, - width: 1.5, - ), - borderRadius: BorderRadius.zero, - ), - focusedErrorBorder: UnderlineInputBorder( - borderSide: BorderSide( - color: kErrorColor, - width: 1.5, + return theme + .copyWith( + extensions: >[ + CollactionTheme.light, + ], + colorScheme: theme.colorScheme.copyWith( + background: Colors.white, + onBackground: Colors.black, ), - borderRadius: BorderRadius.zero, - ), - errorBorder: UnderlineInputBorder( - borderSide: BorderSide( - color: kErrorColor, - width: 1.5, + brightness: Brightness.light, + ) + .themeScheme() + .themeButtons() + .themeInputs() + .themeText(); +} + +@WidgetbookTheme(name: 'Dark') +ThemeData darkTheme() { + final theme = ThemeData.dark(); + + return theme + .copyWith( + extensions: >[ + CollactionTheme.dark, + ], + colorScheme: theme.colorScheme.copyWith( + background: theme.scaffoldBackgroundColor, + onBackground: Colors.white, ), - borderRadius: BorderRadius.zero, - ), - contentPadding: EdgeInsets.all(10.0), - ), - ); + ) + .themeScheme() + .themeButtons() + .themeInputs() + .themeText(); } diff --git a/lib/presentation/themes/widget_themes/button.theme.dart b/lib/presentation/themes/widget_themes/button.theme.dart new file mode 100644 index 00000000..cb053ba8 --- /dev/null +++ b/lib/presentation/themes/widget_themes/button.theme.dart @@ -0,0 +1,63 @@ +part of '../themes.dart'; + +extension ButtonX on ThemeData { + ThemeData themeButtons() { + return copyWith( + buttonTheme: ButtonThemeData( + buttonColor: kTheme.primaryColor, + ), + textButtonTheme: TextButtonThemeData( + style: TextButton.styleFrom( + foregroundColor: kTheme.accentColor, + ), + ), + elevatedButtonTheme: ElevatedButtonThemeData( + style: ButtonStyle( + // foregroundColor: MaterialStateProperty.resolveWith((states) { + // if (states.contains(MaterialState.disabled)) { + // // TODO: Return disabled button color + // } + // return colorScheme.background; + // }), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(52), + ), + ), + backgroundColor: MaterialStateProperty.resolveWith( + (states) { + if (states.contains(MaterialState.disabled)) { + // TODO: Replace with theme color + return kTheme.almostTransparent; + } + return kTheme.accentColor; + }, + ), + elevation: MaterialStateProperty.all(0), + ), + ), + outlinedButtonTheme: OutlinedButtonThemeData( + style: ButtonStyle( + foregroundColor: MaterialStateProperty.all( + kTheme.primaryColor, + ), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(52), + ), + ), + side: MaterialStateProperty.all( + BorderSide(color: kTheme.primaryColor!), + ), + padding: MaterialStateProperty.all( + const EdgeInsets.symmetric(vertical: 12, horizontal: 15), + ), + backgroundColor: MaterialStateProperty.all( + Colors.transparent, + ), + elevation: MaterialStateProperty.all(0), + ), + ), + ); + } +} diff --git a/lib/presentation/themes/widget_themes/input.theme.dart b/lib/presentation/themes/widget_themes/input.theme.dart new file mode 100644 index 00000000..cc405f55 --- /dev/null +++ b/lib/presentation/themes/widget_themes/input.theme.dart @@ -0,0 +1,44 @@ +part of '../themes.dart'; + +extension InputX on ThemeData { + ThemeData themeInputs() { + return copyWith( + inputDecorationTheme: InputDecorationTheme( + hintStyle: TextStyle( + fontSize: 15, + fontWeight: FontWeight.w300, + ), + labelStyle: TextStyle(color: kTheme.inactiveColor), + filled: true, + fillColor: kTheme.almostTransparent, + focusColor: kTheme.inactiveColor, + enabledBorder: UnderlineInputBorder( + borderSide: BorderSide.none, + borderRadius: BorderRadius.zero, + ), + focusedBorder: UnderlineInputBorder( + borderSide: BorderSide( + color: kTheme.accentColor!, + width: 1.5, + ), + borderRadius: BorderRadius.zero, + ), + focusedErrorBorder: UnderlineInputBorder( + borderSide: BorderSide( + color: kTheme.errorColor!, + width: 1.5, + ), + borderRadius: BorderRadius.zero, + ), + errorBorder: UnderlineInputBorder( + borderSide: BorderSide( + color: kTheme.errorColor!, + width: 1.5, + ), + borderRadius: BorderRadius.zero, + ), + contentPadding: EdgeInsets.all(10.0), + ), + ); + } +} diff --git a/lib/presentation/themes/widget_themes/scheme.theme.dart b/lib/presentation/themes/widget_themes/scheme.theme.dart new file mode 100644 index 00000000..ff73684c --- /dev/null +++ b/lib/presentation/themes/widget_themes/scheme.theme.dart @@ -0,0 +1,14 @@ +part of '../themes.dart'; + +extension SchemeX on ThemeData { + ThemeData themeScheme() { + return copyWith( + primaryColor: kTheme.primaryColor, + colorScheme: colorScheme.copyWith( + secondary: kTheme.accentColor, + primary: kTheme.primaryColor, + error: kTheme.errorColor, + ), + ); + } +} diff --git a/lib/presentation/themes/widget_themes/text.theme.dart b/lib/presentation/themes/widget_themes/text.theme.dart new file mode 100644 index 00000000..3d6c77bc --- /dev/null +++ b/lib/presentation/themes/widget_themes/text.theme.dart @@ -0,0 +1,13 @@ +part of '../themes.dart'; + +extension TextX on ThemeData { + ThemeData themeText() { + return copyWith( + textTheme: textTheme.apply( + fontFamily: 'Rubik', + bodyColor: onBackground, + displayColor: onBackground, + ), + ); + } +} diff --git a/lib/presentation/utils/context.ext.dart b/lib/presentation/utils/context.ext.dart index d36c026f..12fa0d8f 100644 --- a/lib/presentation/utils/context.ext.dart +++ b/lib/presentation/utils/context.ext.dart @@ -1,17 +1,17 @@ import 'package:flutter/material.dart'; -import '../themes/constants.dart'; +import '../../core/core.dart'; extension ContextX on BuildContext { void showErrorSnack(String message) { ScaffoldMessenger.of(this).removeCurrentSnackBar(); ScaffoldMessenger.of(this).showSnackBar( SnackBar( - backgroundColor: kErrorColor, + backgroundColor: kTheme.errorColor, behavior: SnackBarBehavior.floating, content: Text( message, - style: const TextStyle(color: kSecondaryColor), + style: TextStyle(color: kTheme.secondaryColor), ), ), ); diff --git a/lib/widgetbook/app.widgetbook.dart b/lib/widgetbook/app.widgetbook.dart index ef6c091a..7db802f9 100644 --- a/lib/widgetbook/app.widgetbook.dart +++ b/lib/widgetbook/app.widgetbook.dart @@ -5,7 +5,7 @@ // ************************************************************************** import 'dart:core'; -import 'package:collaction_app/presentation/themes/constants.dart'; +import 'package:collaction_app/core/core.dart'; import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:collaction_app/widgetbook/usecases/expandable_text/expandable_text.dart'; import 'package:flutter/gestures.dart'; @@ -30,6 +30,10 @@ class HotReload extends StatelessWidget { name: 'Light', data: lightTheme(), ), + WidgetbookTheme( + name: 'Dark', + data: darkTheme(), + ), ], categories: [ WidgetbookCategory( diff --git a/test/presentation/auth/profile_photo_test.dart b/test/presentation/auth/profile_photo_test.dart index 112bd6e5..287bb305 100644 --- a/test/presentation/auth/profile_photo_test.dart +++ b/test/presentation/auth/profile_photo_test.dart @@ -7,6 +7,7 @@ import 'package:collaction_app/application/user/avatar/avatar_bloc.dart'; import 'package:collaction_app/presentation/auth/widgets/profile_photo.dart'; import 'package:collaction_app/presentation/shared_widgets/photo_selector.dart'; import 'package:collaction_app/presentation/shared_widgets/pill_button.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; diff --git a/test/presentation/auth/profile_photo_test.ext.dart b/test/presentation/auth/profile_photo_test.ext.dart index 03a3fb9c..e3242d33 100644 --- a/test/presentation/auth/profile_photo_test.ext.dart +++ b/test/presentation/auth/profile_photo_test.ext.dart @@ -8,6 +8,7 @@ extension WidgetX on WidgetTester { BlocProvider( create: (context) => authBloc, child: MaterialApp( + theme: lightTheme(), home: Scaffold( body: SelectProfilePhoto( onSkip: onSkip, diff --git a/test/presentation/auth/verification_code_test.dart b/test/presentation/auth/verification_code_test.dart index 37407232..eaceef44 100644 --- a/test/presentation/auth/verification_code_test.dart +++ b/test/presentation/auth/verification_code_test.dart @@ -1,5 +1,6 @@ import 'package:collaction_app/application/auth/auth_bloc.dart'; import 'package:collaction_app/presentation/auth/widgets/verification_code.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/test/presentation/auth/verification_code_test.ext.dart b/test/presentation/auth/verification_code_test.ext.dart index a319f87d..9e03077b 100644 --- a/test/presentation/auth/verification_code_test.ext.dart +++ b/test/presentation/auth/verification_code_test.ext.dart @@ -7,6 +7,7 @@ extension WidgetX on WidgetTester { BlocProvider( create: (context) => authBloc, child: MaterialApp( + theme: lightTheme(), home: Scaffold( body: EnterVerificationCode( pinLength: pinLength, diff --git a/test/presentation/auth/verified_test.dart b/test/presentation/auth/verified_test.dart index 0ea2d3ed..91218e2b 100644 --- a/test/presentation/auth/verified_test.dart +++ b/test/presentation/auth/verified_test.dart @@ -3,6 +3,7 @@ import 'package:collaction_app/application/user/profile/profile_bloc.dart'; import 'package:collaction_app/presentation/auth/widgets/verified.dart'; import 'package:collaction_app/presentation/shared_widgets/pill_button.dart'; import 'package:collaction_app/presentation/routes/app_routes.gr.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:get_it/get_it.dart'; diff --git a/test/presentation/auth/verified_test.ext.dart b/test/presentation/auth/verified_test.ext.dart index 4838d665..f89b0b8c 100644 --- a/test/presentation/auth/verified_test.ext.dart +++ b/test/presentation/auth/verified_test.ext.dart @@ -4,6 +4,7 @@ extension WidgetX on WidgetTester { Future pumpVerifiedPage(StackRouter stackRouter) async { await pumpWidget( MaterialApp( + theme: lightTheme(), home: Scaffold( body: VerifiedPage(), ), diff --git a/test/presentation/auth/verify_phone_test.dart b/test/presentation/auth/verify_phone_test.dart index 3abe9a53..08619fd9 100644 --- a/test/presentation/auth/verify_phone_test.dart +++ b/test/presentation/auth/verify_phone_test.dart @@ -1,6 +1,7 @@ import 'package:collaction_app/application/auth/auth_bloc.dart'; import 'package:collaction_app/presentation/auth/widgets/verify_phone.dart'; import 'package:collaction_app/presentation/shared_widgets/pill_button.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; diff --git a/test/presentation/auth/verify_phone_test.ext.dart b/test/presentation/auth/verify_phone_test.ext.dart index 27e97697..afda2b8b 100644 --- a/test/presentation/auth/verify_phone_test.ext.dart +++ b/test/presentation/auth/verify_phone_test.ext.dart @@ -6,6 +6,7 @@ extension WidgetX on WidgetTester { BlocProvider( create: (context) => authBloc, child: MaterialApp( + theme: lightTheme(), home: Scaffold( body: VerifyPhonePage(), ), diff --git a/test/presentation/crowdaction/crowdaction_details/confirm_participation_test.dart b/test/presentation/crowdaction/crowdaction_details/confirm_participation_test.dart index fc1e4820..d327b4cb 100644 --- a/test/presentation/crowdaction/crowdaction_details/confirm_participation_test.dart +++ b/test/presentation/crowdaction/crowdaction_details/confirm_participation_test.dart @@ -4,6 +4,7 @@ import 'package:collaction_app/domain/crowdaction/crowdaction.dart'; import 'package:collaction_app/presentation/crowdaction/crowdaction_details/widgets/confirm_participation.dart'; import 'package:collaction_app/presentation/shared_widgets/commitments/commitment_card.dart'; import 'package:collaction_app/presentation/shared_widgets/pill_button.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/test/presentation/crowdaction/crowdaction_details/confirm_participation_test.ext.dart b/test/presentation/crowdaction/crowdaction_details/confirm_participation_test.ext.dart index 45ea656f..ee1951bd 100644 --- a/test/presentation/crowdaction/crowdaction_details/confirm_participation_test.ext.dart +++ b/test/presentation/crowdaction/crowdaction_details/confirm_participation_test.ext.dart @@ -10,6 +10,7 @@ extension WidgetX on WidgetTester { BlocProvider( create: (_) => participationBloc, child: MaterialApp( + theme: lightTheme(), home: Scaffold( body: ConfirmParticipation( crowdAction: crowdAction, diff --git a/test/presentation/crowdaction/crowdaction_details/crowdaction_chips_test.dart b/test/presentation/crowdaction/crowdaction_details/crowdaction_chips_test.dart index 40b67f61..cea159cd 100644 --- a/test/presentation/crowdaction/crowdaction_details/crowdaction_chips_test.dart +++ b/test/presentation/crowdaction/crowdaction_details/crowdaction_chips_test.dart @@ -1,6 +1,7 @@ import 'package:collaction_app/presentation/crowdaction/crowdaction_details/widgets/crowdaction_chips.dart'; import 'package:collaction_app/presentation/shared_widgets/accent_chip.dart'; import 'package:collaction_app/presentation/shared_widgets/secondary_chip.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:shimmer/shimmer.dart'; @@ -12,7 +13,8 @@ void main() { testWidgets('No Category State', (WidgetTester tester) async { await buildAndPump( tester: tester, - widget: MaterialApp(home: CrowdActionChips(category: null)), + widget: MaterialApp( + theme: lightTheme(), home: CrowdActionChips(category: null)), ); await tester.pump(); @@ -26,6 +28,7 @@ void main() { await buildAndPump( tester: tester, widget: MaterialApp( + theme: lightTheme(), home: CrowdActionChips( category: 'Category-Test', subCategory: 'Subcategory-Test', diff --git a/test/presentation/crowdaction/crowdaction_details/crowdaction_title_test.dart b/test/presentation/crowdaction/crowdaction_details/crowdaction_title_test.dart index 81e01203..86af1071 100644 --- a/test/presentation/crowdaction/crowdaction_details/crowdaction_title_test.dart +++ b/test/presentation/crowdaction/crowdaction_details/crowdaction_title_test.dart @@ -1,5 +1,6 @@ import 'package:collaction_app/presentation/crowdaction/crowdaction_details/widgets/crowdaction_title.dart'; import 'package:collaction_app/presentation/shared_widgets/shimmers/title_shimmer_line.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -23,6 +24,7 @@ void main() { testWidgets('shimmers', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( + theme: lightTheme(), home: CrowdActionTitle( title: null, ), diff --git a/test/presentation/crowdaction/crowdaction_details/participants_test.dart b/test/presentation/crowdaction/crowdaction_details/participants_test.dart index 8ae9f6d6..78d337c0 100644 --- a/test/presentation/crowdaction/crowdaction_details/participants_test.dart +++ b/test/presentation/crowdaction/crowdaction_details/participants_test.dart @@ -4,6 +4,7 @@ import 'package:collaction_app/application/participation/top_participants/top_pa import 'package:collaction_app/presentation/crowdaction/crowdaction_details/widgets/participants.dart'; import 'package:collaction_app/presentation/crowdaction/crowdaction_details/widgets/participation_count_text.dart'; import 'package:collaction_app/presentation/shared_widgets/participant_avatars.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -58,6 +59,7 @@ void main() { BlocProvider( create: (_) => crowdActionDetailsBloc, child: MaterialApp( + theme: lightTheme(), home: Scaffold( body: Participants( crowdAction: null, @@ -102,6 +104,7 @@ void main() { await tester.pumpWidget( MaterialApp( + theme: lightTheme(), home: Scaffold( body: Participants( crowdAction: tCrowdaction, diff --git a/test/presentation/crowdaction/crowdaction_details/participation_count_text_test.dart b/test/presentation/crowdaction/crowdaction_details/participation_count_text_test.dart index e294572c..eae2868c 100644 --- a/test/presentation/crowdaction/crowdaction_details/participation_count_text_test.dart +++ b/test/presentation/crowdaction/crowdaction_details/participation_count_text_test.dart @@ -1,6 +1,7 @@ import 'package:collaction_app/application/crowdaction/crowdaction_details/crowdaction_details_bloc.dart'; import 'package:collaction_app/domain/crowdaction/crowdaction_failures.dart'; import 'package:collaction_app/presentation/crowdaction/crowdaction_details/widgets/participation_count_text.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -33,6 +34,7 @@ void main() { BlocProvider( create: (_) => crowdActionDetailsBloc, child: MaterialApp( + theme: lightTheme(), home: Scaffold( body: ParticipationCountText( crowdAction: null, @@ -131,6 +133,7 @@ void main() { BlocProvider( create: (_) => crowdActionDetailsBloc, child: MaterialApp( + theme: lightTheme(), home: Scaffold( body: ParticipationCountText( crowdAction: null, diff --git a/test/presentation/crowdaction/crowdaction_details/withdraw_participation_test.dart b/test/presentation/crowdaction/crowdaction_details/withdraw_participation_test.dart index 33d8cd8e..092ab01b 100644 --- a/test/presentation/crowdaction/crowdaction_details/withdraw_participation_test.dart +++ b/test/presentation/crowdaction/crowdaction_details/withdraw_participation_test.dart @@ -2,6 +2,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:collaction_app/application/participation/participation_bloc.dart'; import 'package:collaction_app/presentation/crowdaction/crowdaction_details/widgets/withdraw_participation.dart'; import 'package:collaction_app/presentation/shared_widgets/pill_button.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; @@ -88,6 +89,7 @@ void main() { testWidgets('modal can be closed', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( + theme: lightTheme(), home: Scaffold( body: WithdrawParticipation( participationBloc: participationBloc, diff --git a/test/presentation/crowdaction/crowdaction_home/in_spotlight_header_test.dart b/test/presentation/crowdaction/crowdaction_home/in_spotlight_header_test.dart index ec8750e7..7dde37c6 100644 --- a/test/presentation/crowdaction/crowdaction_home/in_spotlight_header_test.dart +++ b/test/presentation/crowdaction/crowdaction_home/in_spotlight_header_test.dart @@ -6,6 +6,7 @@ import 'package:collaction_app/domain/crowdaction/crowdaction_failures.dart'; import 'package:collaction_app/presentation/crowdaction/crowdaction_home/widgets/in_spotlight_header.dart'; import 'package:collaction_app/presentation/crowdaction/crowdaction_home/widgets/spotlight_crowdactions/spotlight_crowdactions.dart'; import 'package:collaction_app/presentation/shared_widgets/content_placeholder.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; diff --git a/test/presentation/crowdaction/crowdaction_home/in_spotlight_header_test.ext.dart b/test/presentation/crowdaction/crowdaction_home/in_spotlight_header_test.ext.dart index 453f9be4..1743a455 100644 --- a/test/presentation/crowdaction/crowdaction_home/in_spotlight_header_test.ext.dart +++ b/test/presentation/crowdaction/crowdaction_home/in_spotlight_header_test.ext.dart @@ -4,6 +4,7 @@ extension WidgetX on WidgetTester { Future pumpInSpotLightHeader(SpotlightBloc spotlightBloc) async { await pumpWidget( MaterialApp( + theme: lightTheme(), home: BlocProvider( create: (_) => spotlightBloc, child: Scaffold( diff --git a/test/presentation/crowdaction/crowdaction_home/widgets/spotlight_crowdactions/spotlight_crowdactions_test.dart b/test/presentation/crowdaction/crowdaction_home/widgets/spotlight_crowdactions/spotlight_crowdactions_test.dart index e8d161a8..3a5e1eb6 100644 --- a/test/presentation/crowdaction/crowdaction_home/widgets/spotlight_crowdactions/spotlight_crowdactions_test.dart +++ b/test/presentation/crowdaction/crowdaction_home/widgets/spotlight_crowdactions/spotlight_crowdactions_test.dart @@ -2,6 +2,7 @@ import 'package:collaction_app/application/crowdaction/crowdaction_details/crowd import 'package:collaction_app/application/participation/top_participants/top_participants_bloc.dart'; import 'package:collaction_app/domain/crowdaction/crowdaction.dart'; import 'package:collaction_app/presentation/crowdaction/crowdaction_home/widgets/spotlight_crowdactions/spotlight_crowdactions.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:dots_indicator/dots_indicator.dart'; import 'package:expandable_page_view/expandable_page_view.dart'; import 'package:flutter/material.dart'; @@ -74,6 +75,7 @@ extension WidgetTesterX on WidgetTester { {List? crowdActions}) async { await pumpWidget( MaterialApp( + theme: lightTheme(), home: Scaffold( body: SpotlightCrowdActions( pages: crowdActions ?? [], diff --git a/test/presentation/home/home_screen_test.dart b/test/presentation/home/home_screen_test.dart index 6f8b6cdf..c7993e8e 100644 --- a/test/presentation/home/home_screen_test.dart +++ b/test/presentation/home/home_screen_test.dart @@ -3,6 +3,7 @@ import 'package:collaction_app/domain/core/i_settings_repository.dart'; import 'package:collaction_app/domain/crowdaction/crowdaction_failures.dart'; import 'package:collaction_app/presentation/home/home_screen.dart'; import 'package:collaction_app/presentation/routes/app_routes.gr.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:dartz/dartz.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -51,6 +52,7 @@ void main() { widget: MaterialApp.router( color: Colors.white, title: 'CollAction', + theme: lightTheme(), routerDelegate: appRouter.delegate(), routeInformationParser: appRouter.defaultRouteParser(), ), diff --git a/test/presentation/home/widgets/current_upcoming_layout_test.dart b/test/presentation/home/widgets/current_upcoming_layout_test.dart index c5bb05ef..b0eb7525 100644 --- a/test/presentation/home/widgets/current_upcoming_layout_test.dart +++ b/test/presentation/home/widgets/current_upcoming_layout_test.dart @@ -2,6 +2,7 @@ import 'package:collaction_app/application/crowdaction/spotlight/spotlight_bloc. import 'package:collaction_app/presentation/home/widgets/current_upcoming_layout.dart'; import 'package:collaction_app/presentation/shared_widgets/micro_crowdaction_card.dart'; import 'package:collaction_app/presentation/shared_widgets/micro_crowdaction_card_loading.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; @@ -76,6 +77,7 @@ extension WidgetTesterX on WidgetTester { }) async { await pumpWidget( MaterialApp( + theme: lightTheme(), home: BlocProvider.value( value: bloc, child: Scaffold( diff --git a/test/presentation/home/widgets/password_modal_test.dart b/test/presentation/home/widgets/password_modal_test.dart index 5c65446a..bddf3a16 100644 --- a/test/presentation/home/widgets/password_modal_test.dart +++ b/test/presentation/home/widgets/password_modal_test.dart @@ -1,8 +1,9 @@ import 'package:auto_route/auto_route.dart'; +import 'package:collaction_app/core/core.dart'; import 'package:collaction_app/domain/core/i_settings_repository.dart'; import 'package:collaction_app/presentation/home/widgets/password_modal.dart'; -import 'package:collaction_app/presentation/themes/constants.dart'; import 'package:collaction_app/presentation/routes/app_routes.gr.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:get_it/get_it.dart'; @@ -51,9 +52,18 @@ void main() { testWidgets( 'button enabled after text input', (WidgetTester tester) async { + late BuildContext ctx; await buildAndPump( tester: tester, - widget: PasswordModal(crowdAction: tCrowdaction), + widget: MaterialApp( + theme: lightTheme(), + home: Builder( + builder: (context) { + ctx = context; + return PasswordModal(crowdAction: tCrowdaction); + }, + ), + ), ); await tester.pumpAndSettle(); @@ -61,7 +71,7 @@ void main() { tester .widget(find.byType(CircleAvatar)) .backgroundColor, - kDisabledButtonColor, + ctx.kTheme.disabledButtonColor, ); await tester.enterText(find.byType(TextField), 't'); @@ -71,7 +81,7 @@ void main() { tester .widget(find.byType(CircleAvatar)) .backgroundColor, - kAccentColor, + ctx.kTheme.accentColor, ); }, ); @@ -136,6 +146,7 @@ void main() { await buildAndPump( tester: tester, widget: MaterialApp( + theme: lightTheme(), home: Scaffold( body: Container(), ), diff --git a/test/presentation/profile/profile_screen_test.dart b/test/presentation/profile/profile_screen_test.dart index 3de6e058..d1252d15 100644 --- a/test/presentation/profile/profile_screen_test.dart +++ b/test/presentation/profile/profile_screen_test.dart @@ -11,6 +11,7 @@ import 'package:collaction_app/presentation/core/collaction_icons.dart'; import 'package:collaction_app/presentation/home/home_screen.dart'; import 'package:collaction_app/presentation/profile/profile_screen.dart'; import 'package:collaction_app/presentation/routes/app_routes.gr.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:dartz/dartz.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -93,6 +94,7 @@ void main() { child: MaterialApp.router( color: Colors.white, title: 'CollAction', + theme: lightTheme(), routerDelegate: appRouter.delegate(), routeInformationParser: appRouter.defaultRouteParser(), ), diff --git a/test/presentation/profile/profile_tab_test.dart b/test/presentation/profile/profile_tab_test.dart index 2158adea..67103ac7 100644 --- a/test/presentation/profile/profile_tab_test.dart +++ b/test/presentation/profile/profile_tab_test.dart @@ -4,6 +4,7 @@ import 'package:collaction_app/presentation/profile/widget/badges_tab.dart'; import 'package:collaction_app/presentation/profile/widget/commitments_tab.dart'; import 'package:collaction_app/presentation/profile/widget/crowdactions_tab.dart'; import 'package:collaction_app/presentation/profile/widget/profile_tab.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/test/presentation/profile/profile_tab_test.ext.dart b/test/presentation/profile/profile_tab_test.ext.dart index 41943596..b514739a 100644 --- a/test/presentation/profile/profile_tab_test.ext.dart +++ b/test/presentation/profile/profile_tab_test.ext.dart @@ -7,6 +7,7 @@ extension WidgetX on WidgetTester { BlocProvider( create: (context) => profileTabBloc, child: MaterialApp( + theme: lightTheme(), home: Scaffold( body: UserProfileTab(user: user), ), diff --git a/test/presentation/settings/settings_layout_test.dart b/test/presentation/settings/settings_layout_test.dart index bdf4dfe0..0c737e73 100644 --- a/test/presentation/settings/settings_layout_test.dart +++ b/test/presentation/settings/settings_layout_test.dart @@ -1,5 +1,6 @@ import 'package:auto_route/auto_route.dart'; import 'package:collaction_app/presentation/settings/settings_layout.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; diff --git a/test/presentation/settings/settings_layout_test.ext.dart b/test/presentation/settings/settings_layout_test.ext.dart index 3998c210..3d36a270 100644 --- a/test/presentation/settings/settings_layout_test.ext.dart +++ b/test/presentation/settings/settings_layout_test.ext.dart @@ -6,6 +6,7 @@ extension WidgetX on WidgetTester { ]) async { await pumpWidget( MaterialApp( + theme: lightTheme(), home: Scaffold( body: SettingsLayout(), ), diff --git a/test/presentation/settings/settings_screen_test.dart b/test/presentation/settings/settings_screen_test.dart index 6e87405a..42fa81ce 100644 --- a/test/presentation/settings/settings_screen_test.dart +++ b/test/presentation/settings/settings_screen_test.dart @@ -9,6 +9,7 @@ import 'package:collaction_app/infrastructure/core/injection.dart'; import 'package:collaction_app/presentation/routes/app_routes.gr.dart'; import 'package:collaction_app/presentation/settings/settings_screen.dart'; import 'package:collaction_app/presentation/settings/widgets/build_information_tile.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; diff --git a/test/presentation/settings/settings_screen_test.ext.dart b/test/presentation/settings/settings_screen_test.ext.dart index ff0d65bf..f8e93d3e 100644 --- a/test/presentation/settings/settings_screen_test.ext.dart +++ b/test/presentation/settings/settings_screen_test.ext.dart @@ -6,6 +6,7 @@ extension WidgetX on WidgetTester { ]) async { await pumpWidget( MaterialApp( + theme: lightTheme(), home: Scaffold( body: MultiBlocProvider( providers: [ diff --git a/test/presentation/shared_widgets/commitment_card_list_test.dart b/test/presentation/shared_widgets/commitment_card_list_test.dart index 7d29494c..7bb65e4b 100644 --- a/test/presentation/shared_widgets/commitment_card_list_test.dart +++ b/test/presentation/shared_widgets/commitment_card_list_test.dart @@ -3,6 +3,7 @@ import 'package:collaction_app/domain/crowdaction/crowdaction.dart'; import 'package:collaction_app/presentation/shared_widgets/commitments/commitment_card.dart'; import 'package:collaction_app/presentation/shared_widgets/commitments/commitment_card_list.dart'; import 'package:collaction_app/presentation/shared_widgets/shimmers/commitment_card_shimmer.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/test/presentation/shared_widgets/commitment_card_list_test.ext.dart b/test/presentation/shared_widgets/commitment_card_list_test.ext.dart index 427bc5da..19bbb33f 100644 --- a/test/presentation/shared_widgets/commitment_card_list_test.ext.dart +++ b/test/presentation/shared_widgets/commitment_card_list_test.ext.dart @@ -15,6 +15,7 @@ extension WidgetX on WidgetTester { ) ], child: MaterialApp( + theme: lightTheme(), home: Scaffold( body: CommitmentCardList( isEnded: isEnded, diff --git a/test/presentation/shared_widgets/crowdaction_card_test.dart b/test/presentation/shared_widgets/crowdaction_card_test.dart index dfef0712..9cdbc341 100644 --- a/test/presentation/shared_widgets/crowdaction_card_test.dart +++ b/test/presentation/shared_widgets/crowdaction_card_test.dart @@ -4,6 +4,7 @@ import 'package:collaction_app/application/participation/top_participants/top_pa import 'package:collaction_app/domain/crowdaction/crowdaction.dart'; import 'package:collaction_app/presentation/routes/app_routes.gr.dart'; import 'package:collaction_app/presentation/shared_widgets/crowdaction_card.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/test/presentation/shared_widgets/crowdaction_card_test.ext.dart b/test/presentation/shared_widgets/crowdaction_card_test.ext.dart index 2ad4dae4..25260e9b 100644 --- a/test/presentation/shared_widgets/crowdaction_card_test.ext.dart +++ b/test/presentation/shared_widgets/crowdaction_card_test.ext.dart @@ -7,6 +7,7 @@ extension WidgetX on WidgetTester { ]) async { await pumpWidget( MaterialApp( + theme: lightTheme(), home: Scaffold( body: CrowdActionCard( crowdAction: crowdAction, diff --git a/test/presentation/shared_widgets/custom_appbar_test.dart b/test/presentation/shared_widgets/custom_appbar_test.dart index 50bfd404..279748a3 100644 --- a/test/presentation/shared_widgets/custom_appbar_test.dart +++ b/test/presentation/shared_widgets/custom_appbar_test.dart @@ -1,4 +1,5 @@ import 'package:collaction_app/presentation/shared_widgets/custom_app_bars/custom_appbar.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -22,7 +23,8 @@ void main() { testWidgets('preferredSize', (WidgetTester tester) async { final appbar = CustomAppBar(); - await tester.pumpWidget(MaterialApp(home: Scaffold(appBar: appbar))); + await tester.pumpWidget( + MaterialApp(theme: lightTheme(), home: Scaffold(appBar: appbar))); await tester.pump(); expect(find.byType(CustomAppBar), findsOneWidget); diff --git a/test/presentation/shared_widgets/expandable_text_test.dart b/test/presentation/shared_widgets/expandable_text_test.dart index 7a641cd1..74ef0645 100644 --- a/test/presentation/shared_widgets/expandable_text_test.dart +++ b/test/presentation/shared_widgets/expandable_text_test.dart @@ -1,9 +1,8 @@ import 'package:collaction_app/presentation/shared_widgets/expandable_text.dart'; import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:flutter/material.dart'; -import 'package:collaction_app/presentation/themes/constants.dart'; import '../../test_helper.dart'; @@ -11,7 +10,7 @@ void main() { group('AccentActionChip test:', () { final String text = 'this is a sample text. '; final int trimLines = 3; - final Color clickableTextColor = kAccentColor; + final Color clickableTextColor = Colors.black; final String readMoreText = 'more'; final String readLessText = 'less'; final TextStyle style = const TextStyle(color: Colors.black); diff --git a/test/presentation/shared_widgets/micro_crowdaction_card_test.dart b/test/presentation/shared_widgets/micro_crowdaction_card_test.dart index 982ed1c4..d12d8939 100644 --- a/test/presentation/shared_widgets/micro_crowdaction_card_test.dart +++ b/test/presentation/shared_widgets/micro_crowdaction_card_test.dart @@ -2,6 +2,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:collaction_app/application/crowdaction/crowdaction_details/crowdaction_details_bloc.dart'; import 'package:collaction_app/presentation/routes/app_routes.gr.dart'; import 'package:collaction_app/presentation/shared_widgets/micro_crowdaction_card.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -39,6 +40,7 @@ void main() { 'and [MicroCrowdActionCard] is tapped', (tester) async { await tester.pumpWidget( MaterialApp( + theme: lightTheme(), home: Scaffold( body: MicroCrowdActionCard( tCrowdactionNoPassword, diff --git a/test/test_helper.dart b/test/test_helper.dart index b3da9810..8b82805d 100644 --- a/test/test_helper.dart +++ b/test/test_helper.dart @@ -1,3 +1,4 @@ +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -7,6 +8,7 @@ Future buildAndPump({ }) async { await tester.pumpWidget( MaterialApp( + theme: lightTheme(), home: Scaffold( body: Center( child: widget, diff --git a/test/widgets/clean_app_bar_test.dart b/test/widgets/clean_app_bar_test.dart index 509b9e3f..40c98314 100644 --- a/test/widgets/clean_app_bar_test.dart +++ b/test/widgets/clean_app_bar_test.dart @@ -1,5 +1,6 @@ +import 'package:collaction_app/core/core.dart'; import 'package:collaction_app/presentation/shared_widgets/custom_app_bars/clean_app_bar.dart'; -import 'package:collaction_app/presentation/themes/constants.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -11,7 +12,8 @@ void main() { 'The value of parameter title should be used as title, if provided', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( + MaterialApp( + theme: lightTheme(), home: Scaffold( appBar: CleanAppBar( title: 'Home', @@ -27,7 +29,8 @@ void main() { 'An empty string should be used as title if title is not provided', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( + MaterialApp( + theme: lightTheme(), home: Scaffold( appBar: CleanAppBar(), ), @@ -46,7 +49,8 @@ void main() { 'The value of parameter backgroundColor should be used as backgroundColor, if provided', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( + MaterialApp( + theme: lightTheme(), home: Scaffold( appBar: CleanAppBar( backgroundColor: Colors.red, @@ -68,17 +72,25 @@ void main() { testWidgets( 'kSecondaryColor should be used as backgroundColor if backgroundColor is not provided', (WidgetTester tester) async { + late BuildContext ctx; + await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - appBar: CleanAppBar(), - ), + MaterialApp( + theme: lightTheme(), + home: Builder(builder: (context) { + ctx = context; + return Scaffold( + appBar: CleanAppBar(), + ); + }), ), ); + expect( find.byWidgetPredicate( (widget) => - widget is AppBar && widget.backgroundColor == kSecondaryColor, + widget is AppBar && + widget.backgroundColor == ctx.kTheme.secondaryColor, ), findsOneWidget, ); @@ -93,7 +105,8 @@ void main() { 'The value of parameter centerTitle should be used to center the title, if provided', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( + MaterialApp( + theme: lightTheme(), home: Scaffold( appBar: CleanAppBar( centerTitle: false, @@ -115,7 +128,8 @@ void main() { 'The boolean value true should be the default value of property centerTitle', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( + MaterialApp( + theme: lightTheme(), home: Scaffold( appBar: CleanAppBar(), ), @@ -139,7 +153,8 @@ void main() { 'The value of parameter elevation should be used to elevate the AppBar, if provided', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( + MaterialApp( + theme: lightTheme(), home: Scaffold( appBar: CleanAppBar( elevation: 3.0, @@ -161,7 +176,8 @@ void main() { 'The default value of property elevation should be 0.0', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( + MaterialApp( + theme: lightTheme(), home: Scaffold( appBar: CleanAppBar(), ), @@ -186,7 +202,8 @@ void main() { 'The value of parameter titleTextStyle should be used to style the title, if provided', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( + MaterialApp( + theme: lightTheme(), home: Scaffold( appBar: CleanAppBar( title: 'Home', @@ -217,13 +234,19 @@ void main() { testWidgets( 'CleanAppBar should use headline6 colored with kPrimaryColor as default value of property titleTextStyle', (WidgetTester tester) async { + late BuildContext ctx; + await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - appBar: CleanAppBar( - title: 'Home', - ), - ), + MaterialApp( + theme: lightTheme(), + home: Builder(builder: (context) { + ctx = context; + return Scaffold( + appBar: CleanAppBar( + title: 'Home', + ), + ); + }), ), ); @@ -232,7 +255,7 @@ void main() { matching: find.byWidgetPredicate( (widget) => widget is AppBar && - widget.titleTextStyle?.color == kPrimaryColor, + widget.titleTextStyle?.color == ctx.kTheme.primaryColor, ), ); }, diff --git a/test/widgets/scrollable_app_bar_test.dart b/test/widgets/scrollable_app_bar_test.dart index edb6fa2c..f974f08d 100644 --- a/test/widgets/scrollable_app_bar_test.dart +++ b/test/widgets/scrollable_app_bar_test.dart @@ -1,5 +1,6 @@ +import 'package:collaction_app/core/core.dart'; import 'package:collaction_app/presentation/shared_widgets/custom_app_bars/scrollable_app_bar.dart'; -import 'package:collaction_app/presentation/themes/constants.dart'; +import 'package:collaction_app/presentation/themes/themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -12,6 +13,7 @@ void main() { (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( + theme: lightTheme(), home: Scaffold( appBar: ScrollableAppBar( pageScrollController: ScrollController(), @@ -29,6 +31,7 @@ void main() { (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( + theme: lightTheme(), home: Scaffold( appBar: ScrollableAppBar( pageScrollController: ScrollController(), @@ -50,6 +53,7 @@ void main() { (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( + theme: lightTheme(), home: Scaffold( appBar: ScrollableAppBar( backgroundColor: Colors.red, @@ -72,19 +76,26 @@ void main() { testWidgets( 'kSecondaryColor should be used as backgroundColor if backgroundColor is not provided', (WidgetTester tester) async { + late BuildContext ctx; + await tester.pumpWidget( MaterialApp( - home: Scaffold( - appBar: ScrollableAppBar( - pageScrollController: ScrollController(), - ), - ), + theme: lightTheme(), + home: Builder(builder: (context) { + ctx = context; + return Scaffold( + appBar: ScrollableAppBar( + pageScrollController: ScrollController(), + ), + ); + }), ), ); expect( find.byWidgetPredicate( (widget) => - widget is AppBar && widget.backgroundColor == kSecondaryColor, + widget is AppBar && + widget.backgroundColor == ctx.kTheme.secondaryColor, ), findsOneWidget, ); @@ -101,6 +112,7 @@ void main() { (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( + theme: lightTheme(), home: Scaffold( appBar: ScrollableAppBar( pageScrollController: ScrollController(), @@ -124,6 +136,7 @@ void main() { (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( + theme: lightTheme(), home: Scaffold( appBar: ScrollableAppBar( pageScrollController: ScrollController(), @@ -165,6 +178,7 @@ void main() { (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( + theme: lightTheme(), home: Scaffold( appBar: ScrollableAppBar( pageScrollController: scrollController, @@ -222,6 +236,7 @@ void main() { await tester.pumpWidget( MaterialApp( + theme: lightTheme(), home: Scaffold( appBar: scrollableAppBar, body: ListView.builder( @@ -271,6 +286,7 @@ void main() { await tester.pumpWidget( MaterialApp( + theme: lightTheme(), home: Scaffold( appBar: scrollableAppBar, body: ListView.builder( @@ -328,6 +344,7 @@ void main() { (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( + theme: lightTheme(), home: Scaffold( appBar: ScrollableAppBar( pageScrollController: ScrollController(), @@ -359,14 +376,20 @@ void main() { testWidgets( 'ScrollableAppBar should use headline6 colored with kPrimaryColor as default value of property titleTextStyle', (WidgetTester tester) async { + late BuildContext ctx; + await tester.pumpWidget( MaterialApp( - home: Scaffold( - appBar: ScrollableAppBar( - pageScrollController: ScrollController(), - title: 'Home', - ), - ), + theme: lightTheme(), + home: Builder(builder: (context) { + ctx = context; + return Scaffold( + appBar: ScrollableAppBar( + pageScrollController: ScrollController(), + title: 'Home', + ), + ); + }), ), ); @@ -375,7 +398,7 @@ void main() { matching: find.byWidgetPredicate( (widget) => widget is AppBar && - widget.titleTextStyle?.color == kPrimaryColor, + widget.titleTextStyle?.color == ctx.kTheme.primaryColor, ), ); },