forked from firka/firka
feat: initial color themes
This commit is contained in:
@@ -8,6 +8,7 @@ import "package:firka/services/fcm_service.dart";
|
||||
import "package:firka/services/notification_delivery_service.dart";
|
||||
import "package:firka/services/progress_notification_service.dart";
|
||||
import "package:firka/services/watch_sync_helper.dart";
|
||||
import "package:firka/ui/phone/screens/themes/builtin_theme_id.dart";
|
||||
|
||||
import "package:firka/data/widget.dart";
|
||||
import "settings_repository.dart";
|
||||
@@ -42,6 +43,24 @@ void registerSettingsEffects(
|
||||
repo.onChange(SettingsRegistry.titleWeight, refreshTitleStyle);
|
||||
repo.onChange(SettingsRegistry.titleCapitalization, refreshTitleStyle);
|
||||
|
||||
Future<void> refreshPresetTheme(_) async {
|
||||
if (isBuiltinThemeId(Settings.selectedThemeId.value)) {
|
||||
final next = composeBuiltinThemeId(
|
||||
Settings.selectedCoreThemeId.value,
|
||||
Settings.selectedGradeThemeId.value,
|
||||
);
|
||||
if (next != Settings.selectedThemeId.value) {
|
||||
await Settings.selectedThemeId.setSilently(next);
|
||||
}
|
||||
}
|
||||
initTheme(initData);
|
||||
initData.themeCubit.refresh();
|
||||
initData.homeRefreshCubit.requestRefresh();
|
||||
}
|
||||
|
||||
repo.onChange(SettingsRegistry.selectedCoreThemeId, refreshPresetTheme);
|
||||
repo.onChange(SettingsRegistry.selectedGradeThemeId, refreshPresetTheme);
|
||||
|
||||
repo.onChange(SettingsRegistry.wearOsSupport, (enabled) async {
|
||||
if (!Platform.isAndroid) return;
|
||||
if (enabled && initDone) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import 'package:firka/core/state/firka_state.dart';
|
||||
import 'package:firka/ui/phone/screens/surprise_grades/surprise_grades_screen.dart';
|
||||
import 'package:firka/ui/shared/firka_icon.dart';
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
import 'package:firka_common/ui/components/filled_circle.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:home_widget/home_widget.dart';
|
||||
import 'package:isar_community/isar.dart';
|
||||
@@ -428,6 +429,16 @@ class _DebugScreen extends FirkaState<DebugScreen> {
|
||||
},
|
||||
child: const Text('wipe users'),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
spacing: 16,
|
||||
runSpacing: 16,
|
||||
children: [
|
||||
for (final entry in _themeColorSwatches())
|
||||
_themeColorSwatch(context, entry.$1, entry.$2),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 600,
|
||||
child: GridView.count(
|
||||
@@ -471,3 +482,70 @@ class _DebugScreen extends FirkaState<DebugScreen> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
List<(String, Color)> _themeColorSwatches() {
|
||||
final c = appStyle.colors;
|
||||
return [
|
||||
("background", c.background),
|
||||
("backgroundAmoled", c.backgroundAmoled),
|
||||
("background0p", c.background0p),
|
||||
("success", c.success),
|
||||
("textPrimary", c.textPrimary),
|
||||
("textSecondary", c.textSecondary),
|
||||
("textTertiary", c.textTertiary),
|
||||
if (c.textTeritary != null) ("textTeritary", c.textTeritary!),
|
||||
("textPrimaryLight", c.textPrimaryLight),
|
||||
("textSecondaryLight", c.textSecondaryLight),
|
||||
("textTertiaryLight", c.textTertiaryLight),
|
||||
("card", c.card),
|
||||
("cardTranslucent", c.cardTranslucent),
|
||||
("buttonSecondaryFill", c.buttonSecondaryFill),
|
||||
("buttonDisabledIcon", c.buttonDisabledIcon),
|
||||
("accent", c.accent),
|
||||
("secondary", c.secondary),
|
||||
("shadowColor", c.shadowColor),
|
||||
("a10p", c.a10p),
|
||||
("a15p", c.a15p),
|
||||
("warningAccent", c.warningAccent),
|
||||
("warningText", c.warningText),
|
||||
("warning15p", c.warning15p),
|
||||
("warningCard", c.warningCard),
|
||||
("errorAccent", c.errorAccent),
|
||||
("errorText", c.errorText),
|
||||
("error15p", c.error15p),
|
||||
("errorCard", c.errorCard),
|
||||
("grade5", c.grade5),
|
||||
("grade4", c.grade4),
|
||||
("grade3", c.grade3),
|
||||
("grade2", c.grade2),
|
||||
("grade1", c.grade1),
|
||||
];
|
||||
}
|
||||
|
||||
Widget _themeColorSwatch(BuildContext context, String name, Color color) {
|
||||
final darkBg = color.computeLuminance() > 0.5;
|
||||
final bg = darkBg ? const Color(0xFF121212) : const Color(0xFFF2F2F2);
|
||||
final labelColor = darkBg ? const Color(0xFFF2F2F2) : const Color(0xFF121212);
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: bg,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
name,
|
||||
style: TextTheme.of(context).bodySmall?.copyWith(color: labelColor),
|
||||
),
|
||||
FilledCircle(
|
||||
diameter: 40,
|
||||
color: color,
|
||||
child: const SizedBox(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import "package:firka/l10n/app_localizations.dart";
|
||||
import "package:firka/ui/shared/firka_icon.dart";
|
||||
import "package:firka/ui/theme/style.dart";
|
||||
import "package:firka_common/ui/components/firka_card.dart";
|
||||
import "package:firka_common/ui/theme/core_theme.dart";
|
||||
import "package:firka_common/ui/theme/grade_theme.dart";
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_bloc/flutter_bloc.dart";
|
||||
import "package:go_router/go_router.dart";
|
||||
@@ -125,23 +127,66 @@ class _SettingsPersonalizationViewState
|
||||
);
|
||||
}
|
||||
|
||||
Widget _swatchPreview(List<Color> colors) {
|
||||
return FirkaCard.single(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.zero,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: SizedBox(
|
||||
height: 88,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
for (final color in colors)
|
||||
Expanded(child: ColoredBox(color: color)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
List<Color> _coreSwatch(CoreThemeColors colors) {
|
||||
return [
|
||||
colors.secondary,
|
||||
colors.accent,
|
||||
colors.background,
|
||||
colors.card,
|
||||
];
|
||||
}
|
||||
|
||||
List<Color> _gradeSwatch(GradeThemeColors colors) {
|
||||
return [
|
||||
colors.grade5,
|
||||
colors.grade4,
|
||||
colors.grade3,
|
||||
colors.grade2,
|
||||
colors.grade1,
|
||||
];
|
||||
}
|
||||
|
||||
Widget _coreThemePager() {
|
||||
final cores = coreThemes.values.toList(growable: false);
|
||||
final selectedId = _settings.get(SettingsRegistry.selectedCoreThemeId);
|
||||
var selectedIndex = cores.indexWhere((theme) => theme.id == selectedId);
|
||||
if (selectedIndex < 0) selectedIndex = 0;
|
||||
|
||||
return _PresetSwatchPager(
|
||||
key: const ValueKey("core-themes"),
|
||||
swatches: [
|
||||
for (final core in cores)
|
||||
_coreSwatch(core.forBrightness(appStyle.isLight)),
|
||||
],
|
||||
selectedIndex: selectedIndex,
|
||||
onSelected: (index) async {
|
||||
await _settings.set(
|
||||
SettingsRegistry.selectedCoreThemeId,
|
||||
cores[index].id,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _gradeThemePager() {
|
||||
final grades = gradeThemes.values.toList(growable: false);
|
||||
final selectedId = _settings.get(SettingsRegistry.selectedGradeThemeId);
|
||||
var selectedIndex = grades.indexWhere((theme) => theme.id == selectedId);
|
||||
if (selectedIndex < 0) selectedIndex = 0;
|
||||
|
||||
return _PresetSwatchPager(
|
||||
key: const ValueKey("grade-themes"),
|
||||
swatches: [
|
||||
for (final grade in grades)
|
||||
_gradeSwatch(grade.forBrightness(appStyle.isLight)),
|
||||
],
|
||||
selectedIndex: selectedIndex,
|
||||
onSelected: (index) async {
|
||||
await _settings.set(
|
||||
SettingsRegistry.selectedGradeThemeId,
|
||||
grades[index].id,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -567,25 +612,14 @@ class _SettingsPersonalizationViewState
|
||||
},
|
||||
),
|
||||
_sectionLabel(_l10n.s_c_colors_header),
|
||||
_swatchPreview([
|
||||
appStyle.colors.secondary,
|
||||
appStyle.colors.accent,
|
||||
appStyle.colors.background,
|
||||
appStyle.colors.card,
|
||||
]),
|
||||
_coreThemePager(),
|
||||
_stubCustomizeButton(),
|
||||
_sectionLabel(_l10n.s_c_theme_header),
|
||||
_themeOption(_l10n.s_c_theme_auto, ThemeBrightness.auto),
|
||||
_themeOption(_l10n.s_c_theme_light, ThemeBrightness.light),
|
||||
_themeOption(_l10n.s_c_theme_dark, ThemeBrightness.dark),
|
||||
_sectionLabel(_l10n.s_c_grade_colors_header),
|
||||
_swatchPreview([
|
||||
appStyle.colors.grade5,
|
||||
appStyle.colors.grade4,
|
||||
appStyle.colors.grade3,
|
||||
appStyle.colors.grade2,
|
||||
appStyle.colors.grade1,
|
||||
]),
|
||||
_gradeThemePager(),
|
||||
_stubCustomizeButton(),
|
||||
_sectionLabel(_l10n.s_c_title_style_header),
|
||||
_fontPicker(selectedFont),
|
||||
@@ -599,3 +633,165 @@ class _SettingsPersonalizationViewState
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _PresetSwatchPager extends StatefulWidget {
|
||||
final List<List<Color>> swatches;
|
||||
final int selectedIndex;
|
||||
final ValueChanged<int> onSelected;
|
||||
|
||||
const _PresetSwatchPager({
|
||||
super.key,
|
||||
required this.swatches,
|
||||
required this.selectedIndex,
|
||||
required this.onSelected,
|
||||
});
|
||||
|
||||
@override
|
||||
State<_PresetSwatchPager> createState() => _PresetSwatchPagerState();
|
||||
}
|
||||
|
||||
class _PresetSwatchPagerState extends State<_PresetSwatchPager> {
|
||||
late final PageController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = PageController(initialPage: widget.selectedIndex);
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(_PresetSwatchPager oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (!_controller.hasClients) return;
|
||||
if (widget.selectedIndex == oldWidget.selectedIndex) return;
|
||||
if (_controller.page?.round() == widget.selectedIndex) return;
|
||||
_controller.animateToPage(
|
||||
widget.selectedIndex,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeOut,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Color _accentFor(double page) {
|
||||
final index = page.round().clamp(0, widget.swatches.length - 1);
|
||||
final swatch = widget.swatches[index];
|
||||
if (swatch.length > 1) return swatch[1];
|
||||
return appStyle.colors.accent;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FirkaCard.single(
|
||||
width: double.infinity,
|
||||
height: 88,
|
||||
padding: EdgeInsets.zero,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
PageView.builder(
|
||||
controller: _controller,
|
||||
itemCount: widget.swatches.length,
|
||||
physics: widget.swatches.length <= 1
|
||||
? const NeverScrollableScrollPhysics()
|
||||
: null,
|
||||
onPageChanged: (index) {
|
||||
if (index == widget.selectedIndex) return;
|
||||
widget.onSelected(index);
|
||||
},
|
||||
itemBuilder: (context, index) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
for (final color in widget.swatches[index])
|
||||
Expanded(child: ColoredBox(color: color)),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
if (widget.swatches.length > 1)
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 8,
|
||||
child: IgnorePointer(
|
||||
child: AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (context, _) {
|
||||
final page = _controller.hasClients
|
||||
? (_controller.page ??
|
||||
widget.selectedIndex.toDouble())
|
||||
: widget.selectedIndex.toDouble();
|
||||
return Center(
|
||||
child: _SwatchPageDots(
|
||||
count: widget.swatches.length,
|
||||
page: page,
|
||||
accent: _accentFor(page),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SwatchPageDots extends StatelessWidget {
|
||||
final int count;
|
||||
final double page;
|
||||
final Color accent;
|
||||
|
||||
const _SwatchPageDots({
|
||||
required this.count,
|
||||
required this.page,
|
||||
required this.accent,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xCCFFFFFF),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (var i = 0; i < count; i++) ...[
|
||||
if (i > 0) const SizedBox(width: 5),
|
||||
_dot(i),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _dot(int index) {
|
||||
final t = (1 - (index - page).abs()).clamp(0.0, 1.0);
|
||||
final size = 5.0 + 3.0 * t;
|
||||
return Container(
|
||||
width: size,
|
||||
height: size,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Color.lerp(
|
||||
accent.withValues(alpha: 0.28),
|
||||
accent,
|
||||
t,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ const butcherVanityCore = CoreTheme(
|
||||
textPrimary: Color(0xFF0D0D0D),
|
||||
textSecondary: Color(0xCC0D0D0D),
|
||||
textTertiary: Color(0x800D0D0D),
|
||||
textTeritary: Color(0xFFF2CB05),
|
||||
textTeritary: Color(0xFFF23838),
|
||||
textPrimaryLight: Color(0xFF0D0D0D),
|
||||
textSecondaryLight: Color(0xCC0D0D0D),
|
||||
textTertiaryLight: Color(0x800D0D0D),
|
||||
@@ -24,14 +24,14 @@ const butcherVanityCore = CoreTheme(
|
||||
shadowColor: Color(0x330D0D0D),
|
||||
a10p: Color(0x1AF2E205),
|
||||
a15p: Color(0x26F2E205),
|
||||
warningAccent: Color(0xFFFFA046),
|
||||
warningText: Color(0xFF8F531B),
|
||||
warning15p: Color(0x26FFA046),
|
||||
warningCard: Color(0xFFFAEBDC),
|
||||
errorAccent: Color(0xFFFF54A1),
|
||||
errorText: Color(0xFF8F1B4F),
|
||||
error15p: Color(0x26FF54A1),
|
||||
errorCard: Color(0xFFFADCE9),
|
||||
warningAccent: Color(0xFFF28D1F),
|
||||
warningText: Color(0xFF8F4A0C),
|
||||
warning15p: Color(0x26F28D1F),
|
||||
warningCard: Color(0xFFFAE6D4),
|
||||
errorAccent: Color(0xFFF23838),
|
||||
errorText: Color(0xFF8F1B1B),
|
||||
error15p: Color(0x26F23838),
|
||||
errorCard: Color(0xFFFADCDC),
|
||||
),
|
||||
dark: CoreThemeColors(
|
||||
background: Color(0xFF0D0D0D),
|
||||
@@ -42,7 +42,7 @@ const butcherVanityCore = CoreTheme(
|
||||
textPrimary: Color(0xFFF2F2F2),
|
||||
textSecondary: Color(0xB3F2F2F2),
|
||||
textTertiary: Color(0x80F2F2F2),
|
||||
textTeritary: Color(0xFFF2CB05),
|
||||
textTeritary: Color(0xFFF23838),
|
||||
textPrimaryLight: Color(0xFF0D0D0D),
|
||||
textSecondaryLight: Color(0xCC0D0D0D),
|
||||
textTertiaryLight: Color(0x800D0D0D),
|
||||
@@ -55,13 +55,13 @@ const butcherVanityCore = CoreTheme(
|
||||
shadowColor: Color(0x26F2CB05),
|
||||
a10p: Color(0x1AF2E205),
|
||||
a15p: Color(0x26F2E205),
|
||||
warningAccent: Color(0xFFFFA046),
|
||||
warningText: Color(0xFFF0B37A),
|
||||
warning15p: Color(0x26FFA046),
|
||||
warningCard: Color(0xFF201203),
|
||||
errorAccent: Color(0xFFFF54A1),
|
||||
errorText: Color(0xFFF59EC5),
|
||||
error15p: Color(0x26FF54A1),
|
||||
errorCard: Color(0xFF1E030F),
|
||||
warningAccent: Color(0xFFF28D1F),
|
||||
warningText: Color(0xFFF0B36A),
|
||||
warning15p: Color(0x26F28D1F),
|
||||
warningCard: Color(0xFF201403),
|
||||
errorAccent: Color(0xFFF23838),
|
||||
errorText: Color(0xFFF59E9E),
|
||||
error15p: Color(0x26F23838),
|
||||
errorCard: Color(0xFF1E0303),
|
||||
),
|
||||
);
|
||||
|
||||
67
firka_common/lib/ui/theme/core/refilc.dart
Normal file
67
firka_common/lib/ui/theme/core/refilc.dart
Normal file
@@ -0,0 +1,67 @@
|
||||
part of "../core_theme.dart";
|
||||
|
||||
const refilcCore = CoreTheme(
|
||||
id: "refilc",
|
||||
light: CoreThemeColors(
|
||||
background: Color(0xFFD9E4F6),
|
||||
backgroundAmoled: Colors.black,
|
||||
background0p: Color(0x00D9E4F6),
|
||||
success: Color(0xFF34C759),
|
||||
shadowBlur: 2,
|
||||
textPrimary: Color(0xFF0B121F),
|
||||
textSecondary: Color(0xCC0B121F),
|
||||
textTertiary: Color(0x800B121F),
|
||||
textTeritary: Color(0xFF545C68),
|
||||
textPrimaryLight: Color(0xFF0B121F),
|
||||
textSecondaryLight: Color(0xCC0B121F),
|
||||
textTertiaryLight: Color(0x800B121F),
|
||||
card: Color(0xFFEDF3FF),
|
||||
cardTranslucent: Color(0x80EDF3FF),
|
||||
buttonSecondaryFill: Color(0xFFFFFFFF),
|
||||
buttonDisabledIcon: Color(0xFFBCC7DA),
|
||||
accent: Color(0xFF3C5AF5),
|
||||
secondary: Color(0xFF2436A8),
|
||||
shadowColor: Color(0x330B121F),
|
||||
a10p: Color(0x1A3C5AF5),
|
||||
a15p: Color(0x263C5AF5),
|
||||
warningAccent: Color(0xFFFFA046),
|
||||
warningText: Color(0xFF8F531B),
|
||||
warning15p: Color(0x26FFA046),
|
||||
warningCard: Color(0xFFFAEBDC),
|
||||
errorAccent: Color(0xFFFF54A1),
|
||||
errorText: Color(0xFF8F1B4F),
|
||||
error15p: Color(0x26FF54A1),
|
||||
errorCard: Color(0xFFFADCE9),
|
||||
),
|
||||
dark: CoreThemeColors(
|
||||
background: Color(0xFF000000),
|
||||
backgroundAmoled: Colors.black,
|
||||
background0p: Color(0x00D9E4F6),
|
||||
success: Color(0xFF32D74B),
|
||||
shadowBlur: 0,
|
||||
textPrimary: Color(0xFFF5F6FA),
|
||||
textSecondary: Color(0xB3F5F6FA),
|
||||
textTertiary: Color(0x80F5F6FA),
|
||||
textTeritary: Color(0xFF9D9FA0),
|
||||
textPrimaryLight: Color(0xFF0B121F),
|
||||
textSecondaryLight: Color(0xCC0B121F),
|
||||
textTertiaryLight: Color(0x800B121F),
|
||||
card: Color(0xFF121619),
|
||||
cardTranslucent: Color(0x80121619),
|
||||
buttonSecondaryFill: Color(0xFF1C2228),
|
||||
buttonDisabledIcon: Color(0xFF3A424D),
|
||||
accent: Color(0xFF3C5AF5),
|
||||
secondary: Color(0xFF8BA3FF),
|
||||
shadowColor: Color(0x263C5AF5),
|
||||
a10p: Color(0x1A3C5AF5),
|
||||
a15p: Color(0x263C5AF5),
|
||||
warningAccent: Color(0xFFFFA046),
|
||||
warningText: Color(0xFFF0B37A),
|
||||
warning15p: Color(0x26FFA046),
|
||||
warningCard: Color(0xFF201203),
|
||||
errorAccent: Color(0xFFFF54A1),
|
||||
errorText: Color(0xFFF59EC5),
|
||||
error15p: Color(0x26FF54A1),
|
||||
errorCard: Color(0xFF1E030F),
|
||||
),
|
||||
);
|
||||
@@ -1,9 +1,13 @@
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
part "core/butcher_vanity.dart";
|
||||
part "core/firka.dart";
|
||||
part "core/refilc.dart";
|
||||
|
||||
const Map<String, CoreTheme> coreThemes = {
|
||||
"firka": firkaCore,
|
||||
"refilc": refilcCore,
|
||||
"butcher_vanity": butcherVanityCore,
|
||||
};
|
||||
|
||||
/// App chrome colors (everything except grade colors)
|
||||
|
||||
25
firka_common/lib/ui/theme/grade/rainbow.dart
Normal file
25
firka_common/lib/ui/theme/grade/rainbow.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
part of "../grade_theme.dart";
|
||||
|
||||
GradeThemeColors _materialShades(MaterialColor color) {
|
||||
return GradeThemeColors(
|
||||
grade5: color.shade500,
|
||||
grade4: color.shade400,
|
||||
grade3: color.shade300,
|
||||
grade2: color.shade200,
|
||||
grade1: color.shade100,
|
||||
);
|
||||
}
|
||||
|
||||
GradeTheme _materialRainbowGrade(String id, MaterialColor color) {
|
||||
final colors = _materialShades(color);
|
||||
return GradeTheme(id: id, light: colors, dark: colors);
|
||||
}
|
||||
|
||||
final redGrade = _materialRainbowGrade("red", Colors.red);
|
||||
final orangeGrade = _materialRainbowGrade("orange", Colors.orange);
|
||||
final yellowGrade = _materialRainbowGrade("yellow", Colors.yellow);
|
||||
final greenGrade = _materialRainbowGrade("green", Colors.green);
|
||||
final blueGrade = _materialRainbowGrade("blue", Colors.blue);
|
||||
final indigoGrade = _materialRainbowGrade("indigo", Colors.indigo);
|
||||
final pinkGrade = _materialRainbowGrade("pink", Colors.pink);
|
||||
final purpleGrade = _materialRainbowGrade("purple", Colors.purple);
|
||||
@@ -1,6 +1,7 @@
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
part "grade/firka.dart";
|
||||
part "grade/rainbow.dart";
|
||||
|
||||
class GradeThemeColors {
|
||||
final Color grade5;
|
||||
@@ -32,8 +33,16 @@ class GradeTheme {
|
||||
GradeThemeColors forBrightness(bool isLight) => isLight ? light : dark;
|
||||
}
|
||||
|
||||
const Map<String, GradeTheme> gradeThemes = {
|
||||
final Map<String, GradeTheme> gradeThemes = {
|
||||
"firka": firkaGrade,
|
||||
"red": redGrade,
|
||||
"orange": orangeGrade,
|
||||
"yellow": yellowGrade,
|
||||
"green": greenGrade,
|
||||
"blue": blueGrade,
|
||||
"indigo": indigoGrade,
|
||||
"pink": pinkGrade,
|
||||
"purple": purpleGrade,
|
||||
};
|
||||
|
||||
GradeTheme resolveGrade(String id) => gradeThemes[id] ?? firkaGrade;
|
||||
|
||||
Reference in New Issue
Block a user