diff --git a/firka/lib/app/initialization.dart b/firka/lib/app/initialization.dart index f72a0f84..3b34ffbb 100644 --- a/firka/lib/app/initialization.dart +++ b/firka/lib/app/initialization.dart @@ -142,12 +142,24 @@ void _applyCustomColors( colors.a10p = colors.accent.withAlpha(0x1a); colors.a15p = colors.accent.withAlpha(0x26); - colors.background = - (isLight - ? Settings.customBackgroundColorLight - : Settings.customBackgroundColorDark) - .value - .toColorFromHexSetting(); + final bgGrad = (isLight + ? Settings.customBackgroundGradientLight + : Settings.customBackgroundGradientDark) + .value + .toColorListFromHexSetting(); + + if (bgGrad.isNotEmpty) { + colors.backgroundGradient = bgGrad; + colors.background = bgGrad.first; + } else { + colors.background = + (isLight + ? Settings.customBackgroundColorLight + : Settings.customBackgroundColorDark) + .value + .toColorFromHexSetting(); + colors.backgroundGradient = null; + } colors.background0p = colors.background.withAlpha(0); colors.card = diff --git a/firka/lib/core/extensions.dart b/firka/lib/core/extensions.dart index 4b58e759..69e001fa 100644 --- a/firka/lib/core/extensions.dart +++ b/firka/lib/core/extensions.dart @@ -1,3 +1,4 @@ +import 'dart:convert'; import 'dart:math'; import 'package:flutter/material.dart'; @@ -303,6 +304,24 @@ extension ColorHexExtension on Color { extension HexSettingExtension on String { Color toColorFromHexSetting() => Color(int.tryParse(this) ?? 0xFFFFFFFF); + + List toColorListFromHexSetting() { + try { + final decoded = jsonDecode(this); + if (decoded is List) { + return decoded + .map((e) => e.toString().toColorFromHexSetting()) + .toList(); + } + } catch (_) {} + return []; + } +} + +extension ColorListHexExtension on List { + String toHexSettingJson() { + return jsonEncode(map((c) => c.toHexSetting()).toList()); + } } extension StringExtension on String { diff --git a/firka/lib/core/settings/settings_effects.dart b/firka/lib/core/settings/settings_effects.dart index 2c9d587d..7762c7dc 100644 --- a/firka/lib/core/settings/settings_effects.dart +++ b/firka/lib/core/settings/settings_effects.dart @@ -106,6 +106,8 @@ void registerSettingsEffects( SettingsRegistry.customErrorTextColorDark, SettingsRegistry.customErrorCardColorLight, SettingsRegistry.customErrorCardColorDark, + SettingsRegistry.customBackgroundGradientLight, + SettingsRegistry.customBackgroundGradientDark, ]) { repo.onChange(setting, refreshCustomColors); } diff --git a/firka/lib/core/settings/settings_schema.dart b/firka/lib/core/settings/settings_schema.dart index febdc8c4..3b2ca9c8 100644 --- a/firka/lib/core/settings/settings_schema.dart +++ b/firka/lib/core/settings/settings_schema.dart @@ -309,4 +309,16 @@ abstract class SettingsSchema { @StringSetting(id: 1086, defaultValue: "0xFF1E030F") String get customErrorCardColorDark; + + @StringSetting( + id: 1087, + defaultValue: "[\"0xFFFAFFF0\",\"0xFFE8F7C8\"]", + ) + String get customBackgroundGradientLight; + + @StringSetting( + id: 1088, + defaultValue: "[\"0xFF0D1202\",\"0xFF1A2405\"]", + ) + String get customBackgroundGradientDark; } diff --git a/firka/lib/core/settings/settings_schema.gen.dart b/firka/lib/core/settings/settings_schema.gen.dart index d5042202..ce3c949c 100644 --- a/firka/lib/core/settings/settings_schema.gen.dart +++ b/firka/lib/core/settings/settings_schema.gen.dart @@ -84,9 +84,11 @@ class SettingsRegistry { static const customErrorTextColorDark = StringSetting(id: 1084, defaultValue: "0xFFF59EC5"); static const customErrorCardColorLight = StringSetting(id: 1085, defaultValue: "0xFFFADCE9"); static const customErrorCardColorDark = StringSetting(id: 1086, defaultValue: "0xFF1E030F"); + static const customBackgroundGradientLight = StringSetting(id: 1087, defaultValue: "[\"0xFFFAFFF0\",\"0xFFE8F7C8\"]"); + static const customBackgroundGradientDark = StringSetting(id: 1088, defaultValue: "[\"0xFF0D1202\",\"0xFF1A2405\"]"); static const all = [ - bellDelay, rounding1, rounding2, rounding3, rounding4, classAvgOnGraph, leftHandedMode, language, appIcon, childProtection, betaWarning, ttToastLessonNo, ttToastTestsAndHw, ttToastBreaks, statsForNerds, developerOptsEnabled, themeBrightness, ttToastSubstitution, ttToastABTimetable, wearOsSupport, titleFont, titleWeight, titleCapitalization, selectedThemeId, selectedCoreThemeId, selectedGradeThemeId, mockBackendEnabled, mockBackendUrl, lastSeen, surpriseGrades, seasonalAppIcons, uwuMode, notifyAll, notifyGrades, notifyHomeworkTests, notifyAbsences, notifyLessons, notifyMessages, notifyMutedSubjects, notifyWakeupInterval, fcmDebugNotifyOnMessage, notificationDeliveryMethod, lessonCacheKeyMigrationDone, progressNotificationEnabled, customGradeColor5, customGradeColor4, customGradeColor3, customGradeColor2, customGradeColor1, customAccentColorLight, customAccentColorDark, customBackgroundColorLight, customBackgroundColorDark, customCardColorLight, customCardColorDark, customButtonColorLight, customButtonColorDark, customSecondaryColorLight, customSecondaryColorDark, customTextColorLight, customTextColorDark, customTextSecondaryColorLight, customTextSecondaryColorDark, customTextTertiaryColorLight, customTextTertiaryColorDark, customShadowColorLight, customShadowColorDark, customSuccessColorLight, customSuccessColorDark, customWarningAccentColorLight, customWarningAccentColorDark, customWarningTextColorLight, customWarningTextColorDark, customWarningCardColorLight, customWarningCardColorDark, customErrorAccentColorLight, customErrorAccentColorDark, customErrorTextColorLight, customErrorTextColorDark, customErrorCardColorLight, customErrorCardColorDark, + bellDelay, rounding1, rounding2, rounding3, rounding4, classAvgOnGraph, leftHandedMode, language, appIcon, childProtection, betaWarning, ttToastLessonNo, ttToastTestsAndHw, ttToastBreaks, statsForNerds, developerOptsEnabled, themeBrightness, ttToastSubstitution, ttToastABTimetable, wearOsSupport, titleFont, titleWeight, titleCapitalization, selectedThemeId, selectedCoreThemeId, selectedGradeThemeId, mockBackendEnabled, mockBackendUrl, lastSeen, surpriseGrades, seasonalAppIcons, uwuMode, notifyAll, notifyGrades, notifyHomeworkTests, notifyAbsences, notifyLessons, notifyMessages, notifyMutedSubjects, notifyWakeupInterval, fcmDebugNotifyOnMessage, notificationDeliveryMethod, lessonCacheKeyMigrationDone, progressNotificationEnabled, customGradeColor5, customGradeColor4, customGradeColor3, customGradeColor2, customGradeColor1, customAccentColorLight, customAccentColorDark, customBackgroundColorLight, customBackgroundColorDark, customCardColorLight, customCardColorDark, customButtonColorLight, customButtonColorDark, customSecondaryColorLight, customSecondaryColorDark, customTextColorLight, customTextColorDark, customTextSecondaryColorLight, customTextSecondaryColorDark, customTextTertiaryColorLight, customTextTertiaryColorDark, customShadowColorLight, customShadowColorDark, customSuccessColorLight, customSuccessColorDark, customWarningAccentColorLight, customWarningAccentColorDark, customWarningTextColorLight, customWarningTextColorDark, customWarningCardColorLight, customWarningCardColorDark, customErrorAccentColorLight, customErrorAccentColorDark, customErrorTextColorLight, customErrorTextColorDark, customErrorCardColorLight, customErrorCardColorDark, customBackgroundGradientLight, customBackgroundGradientDark, ]; } @@ -172,4 +174,6 @@ extension SettingsAccessors on SettingsRepository { SilentlySettable get customErrorTextColorDark => SilentlySettable(this, SettingsRegistry.customErrorTextColorDark); SilentlySettable get customErrorCardColorLight => SilentlySettable(this, SettingsRegistry.customErrorCardColorLight); SilentlySettable get customErrorCardColorDark => SilentlySettable(this, SettingsRegistry.customErrorCardColorDark); + SilentlySettable get customBackgroundGradientLight => SilentlySettable(this, SettingsRegistry.customBackgroundGradientLight); + SilentlySettable get customBackgroundGradientDark => SilentlySettable(this, SettingsRegistry.customBackgroundGradientDark); } diff --git a/firka/lib/routing/shell_with_nav_bar.dart b/firka/lib/routing/shell_with_nav_bar.dart index dc344a60..655fe070 100644 --- a/firka/lib/routing/shell_with_nav_bar.dart +++ b/firka/lib/routing/shell_with_nav_bar.dart @@ -22,17 +22,28 @@ class ShellWithNavBar extends StatelessWidget { final data = initData; final currentIndex = navigationShell.currentIndex; + final bottomBg = + appStyle.colors.backgroundGradient?.last ?? appStyle.colors.background; + return Scaffold( - backgroundColor: appStyle.colors.background, - body: child, + backgroundColor: Colors.transparent, + body: Container( + decoration: BoxDecoration( + color: appStyle.colors.backgroundLinearGradient == null + ? appStyle.colors.background + : null, + gradient: appStyle.colors.backgroundLinearGradient, + ), + child: child, + ), bottomNavigationBar: Container( decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.bottomCenter, end: Alignment.topCenter, colors: [ - appStyle.colors.background, - appStyle.colors.background.withValues(alpha: 0.0), + bottomBg, + bottomBg.withValues(alpha: 0.0), ], stops: const [0.0, 1.0], ), diff --git a/firka/lib/ui/phone/screens/home/home_screen.dart b/firka/lib/ui/phone/screens/home/home_screen.dart index b1fe0bb0..a7795349 100644 --- a/firka/lib/ui/phone/screens/home/home_screen.dart +++ b/firka/lib/ui/phone/screens/home/home_screen.dart @@ -135,15 +135,23 @@ class _HomeScreenState extends FirkaState } }, child: Scaffold( - backgroundColor: appStyle.colors.background, - body: SafeArea( - child: SizedBox( - height: MediaQuery.of(context).size.height, - child: Stack( - children: [ - widget.child, - ?(_toastOverlay(context)), - ], + backgroundColor: Colors.transparent, + body: Container( + decoration: BoxDecoration( + color: appStyle.colors.backgroundLinearGradient == null + ? appStyle.colors.background + : null, + gradient: appStyle.colors.backgroundLinearGradient, + ), + child: SafeArea( + child: SizedBox( + height: MediaQuery.of(context).size.height, + child: Stack( + children: [ + widget.child, + ?(_toastOverlay(context)), + ], + ), ), ), ), diff --git a/firka/lib/ui/phone/screens/theme_editor/theme_editor_screen.dart b/firka/lib/ui/phone/screens/theme_editor/theme_editor_screen.dart index 508770c4..251d28d1 100644 --- a/firka/lib/ui/phone/screens/theme_editor/theme_editor_screen.dart +++ b/firka/lib/ui/phone/screens/theme_editor/theme_editor_screen.dart @@ -75,6 +75,11 @@ const _defaults = <_ThemeSlot, (Color light, Color dark)>{ _ThemeSlot.errorCard: (Color(0xFFFADCE9), Color(0xFF1E030F)), }; +const _defaultGradients = ( + light: [Color(0xFFFAFFF0), Color(0xFFE8F7C8)], + dark: [Color(0xFF0D1202), Color(0xFF1A2405)], +); + (StringSetting, StringSetting) _settingsFor(_ThemeSlot slot) { switch (slot) { case _ThemeSlot.accent: @@ -208,6 +213,7 @@ void _applySlotColor(FirkaColors colors, _ThemeSlot slot, Color color) { class _ThemeEditorScreenState extends State { _ThemeSlot? _slot = _ThemeSlot.accent; _BrightnessMode _mode = _BrightnessMode.both; + int _bgStopIndex = 0; late HSVColor _hsv; late final ThemePreviewData _preview; @@ -246,6 +252,30 @@ class _ThemeEditorScreenState extends State { _BrightnessMode.both => _originalIsLight, }; + List _currentGradient({required bool isLightSource}) { + final raw = _settings.get( + isLightSource + ? SettingsRegistry.customBackgroundGradientLight + : SettingsRegistry.customBackgroundGradientDark, + ); + final list = raw.toColorListFromHexSetting(); + if (list.isNotEmpty) return list; + return isLightSource + ? List.from(_defaultGradients.light) + : List.from(_defaultGradients.dark); + } + + List _gradientForMode(_BrightnessMode mode) { + switch (mode) { + case _BrightnessMode.light: + return _currentGradient(isLightSource: true); + case _BrightnessMode.dark: + return _currentGradient(isLightSource: false); + case _BrightnessMode.both: + return _currentGradient(isLightSource: _originalIsLight); + } + } + // Rebuilds the global `appStyle` for whichever brightness is currently // being previewed, patching in the *live* (possibly not-yet-persisted) // slot color so the preview always reflects what's on screen, not just @@ -257,7 +287,22 @@ class _ThemeEditorScreenState extends State { if (slot != null) { final editingLight = _mode != _BrightnessMode.dark; if (_mode == _BrightnessMode.both || editingLight == isLight) { - _applySlotColor(style.colors, slot, _hsv.toColor()); + if (slot == _ThemeSlot.background) { + final stops = + List.from(_currentGradient(isLightSource: isLight)); + if (_bgStopIndex < stops.length) { + stops[_bgStopIndex] = _hsv.toColor(); + } else { + stops.add(_hsv.toColor()); + } + style.colors.backgroundGradient = stops; + if (stops.isNotEmpty) { + style.colors.background = stops.first; + style.colors.background0p = stops.first.withAlpha(0); + } + } else { + _applySlotColor(style.colors, slot, _hsv.toColor()); + } } } appStyle = style; @@ -275,6 +320,13 @@ class _ThemeEditorScreenState extends State { } Color _colorForSlotAndMode(_ThemeSlot slot, _BrightnessMode mode) { + if (slot == _ThemeSlot.background) { + final stops = _gradientForMode(mode); + final idx = _bgStopIndex.clamp(0, math.max(0, stops.length - 1)).toInt(); + return stops.isNotEmpty + ? stops[idx] + : _defaults[_ThemeSlot.background]!.$1; + } final light = _currentColor(slot, isLightSource: true); final dark = _currentColor(slot, isLightSource: false); switch (mode) { @@ -312,16 +364,50 @@ class _ThemeEditorScreenState extends State { final color = hsv.toColor(); final hex = color.toHexSetting(); - final (light, dark) = _settingsFor(slot); - switch (_mode) { - case _BrightnessMode.both: - await _settings.set(light, hex); - await _settings.set(dark, hex); - case _BrightnessMode.light: - await _settings.set(light, hex); - case _BrightnessMode.dark: - await _settings.set(dark, hex); + if (slot == _ThemeSlot.background) { + Future updateForSource(bool isLightSource) async { + final setting = isLightSource + ? SettingsRegistry.customBackgroundGradientLight + : SettingsRegistry.customBackgroundGradientDark; + final stops = + List.from(_currentGradient(isLightSource: isLightSource)); + final idx = + _bgStopIndex.clamp(0, math.max(0, stops.length - 1)).toInt(); + if (stops.isNotEmpty) { + stops[idx] = color; + } else { + stops.add(color); + } + await _settings.set(setting, stops.toHexSettingJson()); + if (idx == 0) { + final colorSetting = isLightSource + ? SettingsRegistry.customBackgroundColorLight + : SettingsRegistry.customBackgroundColorDark; + await _settings.set(colorSetting, hex); + } + } + + switch (_mode) { + case _BrightnessMode.both: + await updateForSource(true); + await updateForSource(false); + case _BrightnessMode.light: + await updateForSource(true); + case _BrightnessMode.dark: + await updateForSource(false); + } + } else { + final (light, dark) = _settingsFor(slot); + switch (_mode) { + case _BrightnessMode.both: + await _settings.set(light, hex); + await _settings.set(dark, hex); + case _BrightnessMode.light: + await _settings.set(light, hex); + case _BrightnessMode.dark: + await _settings.set(dark, hex); + } } if (isBuiltinThemeId(Settings.selectedThemeId.value)) { @@ -354,6 +440,11 @@ class _ThemeEditorScreenState extends State { return; } _slot = slot; + if (slot == _ThemeSlot.background) { + final stops = _gradientForMode(_mode); + _bgStopIndex = + _bgStopIndex.clamp(0, math.max(0, stops.length - 1)).toInt(); + } _hsv = HSVColor.fromColor(_colorForSlotAndMode(slot, _mode)); _refreshPreviewStyle(); }); @@ -365,6 +456,11 @@ class _ThemeEditorScreenState extends State { _mode = mode; final slot = _slot; if (slot != null) { + if (slot == _ThemeSlot.background) { + final stops = _gradientForMode(mode); + _bgStopIndex = + _bgStopIndex.clamp(0, math.max(0, stops.length - 1)).toInt(); + } _hsv = HSVColor.fromColor(_colorForSlotAndMode(slot, mode)); } _refreshPreviewStyle(); @@ -372,10 +468,148 @@ class _ThemeEditorScreenState extends State { _syncHexField(); } + Future _addGradientStop() async { + Future addForSource(bool isLightSource) async { + final setting = isLightSource + ? SettingsRegistry.customBackgroundGradientLight + : SettingsRegistry.customBackgroundGradientDark; + final stops = + List.from(_currentGradient(isLightSource: isLightSource)); + final lastColor = stops.isNotEmpty + ? stops.last + : (isLightSource + ? _defaultGradients.light.last + : _defaultGradients.dark.last); + stops.add(lastColor); + await _settings.set(setting, stops.toHexSettingJson()); + } + + switch (_mode) { + case _BrightnessMode.both: + await addForSource(true); + await addForSource(false); + case _BrightnessMode.light: + await addForSource(true); + case _BrightnessMode.dark: + await addForSource(false); + } + + if (!mounted) return; + final stops = _gradientForMode(_mode); + setState(() { + _bgStopIndex = stops.length - 1; + _hsv = HSVColor.fromColor(stops[_bgStopIndex]); + _refreshPreviewStyle(); + }); + _syncHexField(); + context.read().refresh(); + } + + Future _removeGradientStop(int index) async { + final currentStops = _gradientForMode(_mode); + if (currentStops.length <= 1) return; + + Future removeForSource(bool isLightSource) async { + final setting = isLightSource + ? SettingsRegistry.customBackgroundGradientLight + : SettingsRegistry.customBackgroundGradientDark; + final stops = + List.from(_currentGradient(isLightSource: isLightSource)); + if (stops.length > 1 && index < stops.length) { + stops.removeAt(index); + await _settings.set(setting, stops.toHexSettingJson()); + if (index == 0 && stops.isNotEmpty) { + final colorSetting = isLightSource + ? SettingsRegistry.customBackgroundColorLight + : SettingsRegistry.customBackgroundColorDark; + await _settings.set(colorSetting, stops.first.toHexSetting()); + } + } + } + + switch (_mode) { + case _BrightnessMode.both: + await removeForSource(true); + await removeForSource(false); + case _BrightnessMode.light: + await removeForSource(true); + case _BrightnessMode.dark: + await removeForSource(false); + } + + if (!mounted) return; + final stops = _gradientForMode(_mode); + final newIndex = index.clamp(0, math.max(0, stops.length - 1)).toInt(); + setState(() { + _bgStopIndex = newIndex; + _hsv = HSVColor.fromColor(stops[newIndex]); + _refreshPreviewStyle(); + }); + _syncHexField(); + context.read().refresh(); + } + Future _reset() async { final slot = _slot; if (slot == null) return; + if (slot == _ThemeSlot.background) { + final lightList = _defaultGradients.light; + final darkList = _defaultGradients.dark; + switch (_mode) { + case _BrightnessMode.both: + await _settings.set( + SettingsRegistry.customBackgroundGradientLight, + lightList.toHexSettingJson(), + ); + await _settings.set( + SettingsRegistry.customBackgroundGradientDark, + darkList.toHexSettingJson(), + ); + await _settings.set( + SettingsRegistry.customBackgroundColorLight, + lightList.first.toHexSetting(), + ); + await _settings.set( + SettingsRegistry.customBackgroundColorDark, + darkList.first.toHexSetting(), + ); + case _BrightnessMode.light: + await _settings.set( + SettingsRegistry.customBackgroundGradientLight, + lightList.toHexSettingJson(), + ); + await _settings.set( + SettingsRegistry.customBackgroundColorLight, + lightList.first.toHexSetting(), + ); + case _BrightnessMode.dark: + await _settings.set( + SettingsRegistry.customBackgroundGradientDark, + darkList.toHexSettingJson(), + ); + await _settings.set( + SettingsRegistry.customBackgroundColorDark, + darkList.first.toHexSetting(), + ); + } + + if (!mounted) return; + setState(() { + _bgStopIndex = 0; + final defStops = switch (_mode) { + _BrightnessMode.light => lightList, + _BrightnessMode.dark => darkList, + _BrightnessMode.both => _originalIsLight ? lightList : darkList, + }; + _hsv = HSVColor.fromColor(defStops.first); + _refreshPreviewStyle(); + }); + _syncHexField(); + context.read().refresh(); + return; + } + final (lightSetting, darkSetting) = _settingsFor(slot); final (lightDefault, darkDefault) = _defaults[slot]!; @@ -440,17 +674,25 @@ class _ThemeEditorScreenState extends State { child: BlocBuilder( builder: (context, _) { return Scaffold( - backgroundColor: appStyle.colors.background, - body: SafeArea( - child: Column( - children: [ - Padding( - padding: const EdgeInsets.all(20), - child: _header(context), - ), - Expanded(child: _previewCarousel()), - _bottomEditor(), - ], + backgroundColor: Colors.transparent, + body: Container( + decoration: BoxDecoration( + color: appStyle.colors.backgroundLinearGradient == null + ? appStyle.colors.background + : null, + gradient: appStyle.colors.backgroundLinearGradient, + ), + child: SafeArea( + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(20), + child: _header(context), + ), + Expanded(child: _previewCarousel()), + _bottomEditor(), + ], + ), ), ), ); @@ -530,6 +772,10 @@ class _ThemeEditorScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ if (_slot != null) ...[ + if (_slot == _ThemeSlot.background) ...[ + _backgroundGradientBar(), + const SizedBox(height: 12), + ], _hueSlider(), const SizedBox(height: 8), _saturationSlider(), @@ -776,6 +1022,70 @@ class _ThemeEditorScreenState extends State { ); } + Widget _backgroundGradientBar() { + final stops = _gradientForMode(_mode); + final l10n = widget.data.l10n; + + return SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: [ + for (var i = 0; i < stops.length; i++) ...[ + _pill( + "${l10n.s_c_slot_background} ${i + 1}", + selected: i == _bgStopIndex, + onTap: () { + setState(() { + _bgStopIndex = i; + _hsv = HSVColor.fromColor(stops[i]); + _refreshPreviewStyle(); + }); + _syncHexField(); + }, + ), + const SizedBox(width: 8), + ], + _gradientActionButton( + icon: Majesticon.plusLine, + onTap: _addGradientStop, + ), + if (stops.length > 1) ...[ + const SizedBox(width: 8), + _gradientActionButton( + icon: Majesticon.minusLine, + onTap: () => _removeGradientStop(_bgStopIndex), + ), + ], + ], + ), + ); + } + + Widget _gradientActionButton({ + required Object icon, + required VoidCallback onTap, + }) { + return GestureDetector( + onTap: onTap, + child: Container( + height: 40, + width: 44, + decoration: BoxDecoration( + color: appStyle.colors.buttonSecondaryFill, + borderRadius: BorderRadius.circular(16), + ), + child: Center( + child: FirkaIconWidget( + FirkaIconType.majesticons, + icon, + size: 20, + color: appStyle.colors.secondary, + ), + ), + ), + ); + } + Widget _pill( String label, { required bool selected, @@ -788,7 +1098,9 @@ class _ThemeEditorScreenState extends State { curve: Curves.easeOut, padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), decoration: BoxDecoration( - color: selected ? appStyle.colors.accent : appStyle.colors.card, + color: selected + ? appStyle.colors.accent + : appStyle.colors.buttonSecondaryFill, borderRadius: BorderRadius.circular(20), ), child: Text( diff --git a/firka/lib/ui/phone/screens/themes/preview/theme_page_preview.dart b/firka/lib/ui/phone/screens/themes/preview/theme_page_preview.dart index b8d7bcb1..111b0a72 100644 --- a/firka/lib/ui/phone/screens/themes/preview/theme_page_preview.dart +++ b/firka/lib/ui/phone/screens/themes/preview/theme_page_preview.dart @@ -30,7 +30,10 @@ class ThemePagePreview extends StatelessWidget { return Container( margin: const EdgeInsets.symmetric(horizontal: 6), decoration: BoxDecoration( - color: appStyle.colors.background, + color: appStyle.colors.backgroundLinearGradient == null + ? appStyle.colors.background + : null, + gradient: appStyle.colors.backgroundLinearGradient, borderRadius: BorderRadius.circular(20), boxShadow: [ BoxShadow( @@ -59,8 +62,13 @@ class ThemePagePreview extends StatelessWidget { child: IgnorePointer( child: DefaultAssetBundle( bundle: FirkaBundle(), - child: ColoredBox( - color: appStyle.colors.background, + child: Container( + decoration: BoxDecoration( + color: appStyle.colors.backgroundLinearGradient == null + ? appStyle.colors.background + : null, + gradient: appStyle.colors.backgroundLinearGradient, + ), child: Column( children: [ _PreviewStatusBar(), @@ -169,8 +177,11 @@ class _PreviewBottomNav extends StatelessWidget { begin: Alignment.bottomCenter, end: Alignment.topCenter, colors: [ - appStyle.colors.background, - appStyle.colors.background.withValues(alpha: 0.0), + appStyle.colors.backgroundGradient?.last ?? + appStyle.colors.background, + (appStyle.colors.backgroundGradient?.last ?? + appStyle.colors.background) + .withValues(alpha: 0.0), ], stops: const [0.0, 1.0], ), diff --git a/firka/lib/ui/phone/screens/themes/theme_screen.dart b/firka/lib/ui/phone/screens/themes/theme_screen.dart index 6b00dfc7..704ca5d4 100644 --- a/firka/lib/ui/phone/screens/themes/theme_screen.dart +++ b/firka/lib/ui/phone/screens/themes/theme_screen.dart @@ -77,11 +77,18 @@ class _ThemeScreenState extends State { bloc: widget.data.themeCubit, builder: (context, _) { return Scaffold( - backgroundColor: appStyle.colors.background, - body: SafeArea( - child: Padding( - padding: const EdgeInsets.all(20), - child: Column( + backgroundColor: Colors.transparent, + body: Container( + decoration: BoxDecoration( + color: appStyle.colors.backgroundLinearGradient == null + ? appStyle.colors.background + : null, + gradient: appStyle.colors.backgroundLinearGradient, + ), + child: SafeArea( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( @@ -230,7 +237,8 @@ class _ThemeScreenState extends State { ), ), ), - ); + ), + ); }, ); } diff --git a/firka_common/lib/ui/theme/core_theme.dart b/firka_common/lib/ui/theme/core_theme.dart index 97f02361..832d2bba 100644 --- a/firka_common/lib/ui/theme/core_theme.dart +++ b/firka_common/lib/ui/theme/core_theme.dart @@ -13,6 +13,7 @@ const Map coreThemes = { /// App chrome colors (everything except grade colors) class CoreThemeColors { final Color background; + final List? backgroundGradient; final Color backgroundAmoled; final Color background0p; final Color success; @@ -51,6 +52,7 @@ class CoreThemeColors { const CoreThemeColors({ required this.background, + this.backgroundGradient, required this.backgroundAmoled, required this.background0p, required this.success, diff --git a/firka_common/lib/ui/theme/style.dart b/firka_common/lib/ui/theme/style.dart index c49b5e6f..255fbe20 100644 --- a/firka_common/lib/ui/theme/style.dart +++ b/firka_common/lib/ui/theme/style.dart @@ -50,11 +50,21 @@ class FirkaFonts { class FirkaColors { Color background; + List? backgroundGradient; Color backgroundAmoled; Color background0p; Color success; int shadowBlur; + LinearGradient? get backgroundLinearGradient => + backgroundGradient != null && backgroundGradient!.length >= 2 + ? LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: backgroundGradient!, + ) + : null; + Color textPrimary; Color textSecondary; Color textTertiary; @@ -94,6 +104,7 @@ class FirkaColors { FirkaColors({ required this.background, + this.backgroundGradient, required this.backgroundAmoled, required this.background0p, required this.success, @@ -269,6 +280,7 @@ final _defaultFonts = buildAppFonts(); FirkaColors mergeColors(CoreThemeColors core, GradeThemeColors grades) { return FirkaColors( background: core.background, + backgroundGradient: core.backgroundGradient, backgroundAmoled: core.backgroundAmoled, background0p: core.background0p, success: core.success,