diff --git a/packages/smooth_app/lib/generic_lib/buttons/smooth_simple_button.dart b/packages/smooth_app/lib/generic_lib/buttons/smooth_simple_button.dart index 7c8e086c61a..cc978a528ab 100644 --- a/packages/smooth_app/lib/generic_lib/buttons/smooth_simple_button.dart +++ b/packages/smooth_app/lib/generic_lib/buttons/smooth_simple_button.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import 'package:smooth_app/generic_lib/design_constants.dart'; +import 'package:smooth_app/themes/theme_provider.dart'; class SmoothSimpleButton extends StatelessWidget { const SmoothSimpleButton({ @@ -35,6 +37,18 @@ class SmoothSimpleButton extends StatelessWidget { shape: MaterialStateProperty.all( RoundedRectangleBorder(borderRadius: borderRadius), ), + overlayColor: context.read().isAmoledTheme + ? MaterialStateProperty.resolveWith((Set states) { + return states.contains(MaterialState.pressed) + ? Theme.of(context).colorScheme.primary.withOpacity(0.3) + : null; + }) + : null, + side: context.read().isAmoledTheme + ? MaterialStateProperty.all( + const BorderSide(color: Colors.white), + ) + : null, ), onPressed: onPressed, child: Padding( diff --git a/packages/smooth_app/lib/themes/theme_provider.dart b/packages/smooth_app/lib/themes/theme_provider.dart index 4b226f060da..42c6e42e763 100644 --- a/packages/smooth_app/lib/themes/theme_provider.dart +++ b/packages/smooth_app/lib/themes/theme_provider.dart @@ -10,6 +10,7 @@ class ThemeProvider with ChangeNotifier { ThemeProvider(this._userPreferences); final UserPreferences _userPreferences; + // The onboarding needs the light mode. bool _forceLight = false; @@ -20,6 +21,12 @@ class ThemeProvider with ChangeNotifier { _forceLight = !onboardingComplete; } + bool get isLightTheme => _forceLight || currentTheme == THEME_LIGHT; + + bool get isDarkTheme => !_forceLight && currentTheme == THEME_DARK; + + bool get isAmoledTheme => !_forceLight && currentTheme == THEME_AMOLED; + void finishOnboarding() { setOnboardingComplete(true); notifyListeners(); diff --git a/packages/smooth_app/test/pages/generic_lib/widgets/smooth_error_card_test.dart b/packages/smooth_app/test/pages/generic_lib/widgets/smooth_error_card_test.dart index 51fd1f202f8..7cf960cf59d 100644 --- a/packages/smooth_app/test/pages/generic_lib/widgets/smooth_error_card_test.dart +++ b/packages/smooth_app/test/pages/generic_lib/widgets/smooth_error_card_test.dart @@ -1,10 +1,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:provider/provider.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:smooth_app/data_models/user_preferences.dart'; import 'package:smooth_app/generic_lib/buttons/smooth_simple_button.dart'; import 'package:smooth_app/generic_lib/widgets/smooth_error_card.dart'; +import 'package:smooth_app/themes/theme_provider.dart'; import 'package:smooth_app/widgets/smooth_scaffold.dart'; +import '../../../tests_utils/mocks.dart'; + void main() { const String errorMessageTest = 'error message test'; const String smoothErrorCardTitle = 'There was an error'; @@ -40,15 +46,24 @@ void main() { tryAgainFunctionTest = () {}; }); - Future pumpSmoothErrorCardOnScreen(WidgetTester tester) { + Future pumpSmoothErrorCardOnScreen(WidgetTester tester) async { + SharedPreferences.setMockInitialValues( + mockSharedPreferences(), + ); + + final UserPreferences prefs = await UserPreferences.getUserPreferences(); + return tester.pumpWidget( - MaterialApp( - localizationsDelegates: AppLocalizations.localizationsDelegates, - locale: const Locale('en'), - home: SmoothScaffold( - body: SmoothErrorCard( - errorMessage: errorMessageTest, - tryAgainFunction: tryAgainFunctionTest, + ChangeNotifierProvider( + create: (_) => ThemeProvider(prefs), + child: MaterialApp( + localizationsDelegates: AppLocalizations.localizationsDelegates, + locale: const Locale('en'), + home: SmoothScaffold( + body: SmoothErrorCard( + errorMessage: errorMessageTest, + tryAgainFunction: tryAgainFunctionTest, + ), ), ), ),