forked from firka/student-legacy
added settings option for custom text color
This commit is contained in:
parent
97049bae46
commit
a6563f9a7e
@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:material_color_utilities/material_color_utilities.dart';
|
import 'package:material_color_utilities/material_color_utilities.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:refilc/ui/flutter_colorpicker/utils.dart';
|
||||||
|
|
||||||
class AppTheme {
|
class AppTheme {
|
||||||
// Dev note: All of these could be constant variables, but this is better for
|
// Dev note: All of these could be constant variables, but this is better for
|
||||||
@ -20,6 +21,8 @@ class AppTheme {
|
|||||||
palette != null ? Color(palette.neutral.get(100)) : null;
|
palette != null ? Color(palette.neutral.get(100)) : null;
|
||||||
static Color? _paletteBackgroundLight(CorePalette? palette) =>
|
static Color? _paletteBackgroundLight(CorePalette? palette) =>
|
||||||
palette != null ? Color(palette.neutral.get(95)) : null;
|
palette != null ? Color(palette.neutral.get(95)) : null;
|
||||||
|
static Color? _paletteTextLight(CorePalette? palette) =>
|
||||||
|
palette != null ? Color(palette.neutral.get(10)) : null;
|
||||||
|
|
||||||
static Color? _paletteAccentDark(CorePalette? palette) =>
|
static Color? _paletteAccentDark(CorePalette? palette) =>
|
||||||
palette != null ? Color(palette.primary.get(80)) : null;
|
palette != null ? Color(palette.primary.get(80)) : null;
|
||||||
@ -27,6 +30,8 @@ class AppTheme {
|
|||||||
palette != null ? Color(palette.neutralVariant.get(10)) : null;
|
palette != null ? Color(palette.neutralVariant.get(10)) : null;
|
||||||
static Color? _paletteHighlightDark(CorePalette? palette) =>
|
static Color? _paletteHighlightDark(CorePalette? palette) =>
|
||||||
palette != null ? Color(palette.neutralVariant.get(20)) : null;
|
palette != null ? Color(palette.neutralVariant.get(20)) : null;
|
||||||
|
static Color? _paletteTextDark(CorePalette? palette) =>
|
||||||
|
palette != null ? Color(palette.neutralVariant.get(100)) : null;
|
||||||
|
|
||||||
static Map<String, TextTheme?> googleFontsMap = {
|
static Map<String, TextTheme?> googleFontsMap = {
|
||||||
"Merienda": GoogleFonts.meriendaTextTheme(),
|
"Merienda": GoogleFonts.meriendaTextTheme(),
|
||||||
@ -61,6 +66,10 @@ class AppTheme {
|
|||||||
? settings.customHighlightColor
|
? settings.customHighlightColor
|
||||||
: _paletteHighlightLight(palette)) ??
|
: _paletteHighlightLight(palette)) ??
|
||||||
lightColors.highlight;
|
lightColors.highlight;
|
||||||
|
Color textColor = (accentColor == AccentColor.custom
|
||||||
|
? settings.customTextColor
|
||||||
|
: _paletteTextLight(palette)) ??
|
||||||
|
lightColors.text;
|
||||||
|
|
||||||
Color newSecondary = (accentColor == AccentColor.adaptive ||
|
Color newSecondary = (accentColor == AccentColor.adaptive ||
|
||||||
accentColor == AccentColor.custom ||
|
accentColor == AccentColor.custom ||
|
||||||
@ -76,12 +85,15 @@ class AppTheme {
|
|||||||
? accent
|
? accent
|
||||||
: ColorsUtils().darken(accent, amount: 0.5);
|
: ColorsUtils().darken(accent, amount: 0.5);
|
||||||
|
|
||||||
|
print(textColor.toHexString());
|
||||||
|
|
||||||
return ThemeData(
|
return ThemeData(
|
||||||
brightness: Brightness.light,
|
brightness: Brightness.light,
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
fontFamily: _defaultFontFamily,
|
fontFamily: _defaultFontFamily,
|
||||||
textTheme: googleFontsMap[settings.fontFamily]
|
textTheme:
|
||||||
?.apply(bodyColor: lightColors.text),
|
googleFontsMap[settings.fontFamily]?.apply(bodyColor: textColor) ??
|
||||||
|
const TextTheme().apply(bodyColor: textColor),
|
||||||
scaffoldBackgroundColor: backgroundColor,
|
scaffoldBackgroundColor: backgroundColor,
|
||||||
primaryColor: lightColors.filc,
|
primaryColor: lightColors.filc,
|
||||||
dividerColor: const Color(0x00000000),
|
dividerColor: const Color(0x00000000),
|
||||||
@ -165,6 +177,10 @@ class AppTheme {
|
|||||||
? settings.customHighlightColor
|
? settings.customHighlightColor
|
||||||
: _paletteHighlightDark(palette)) ??
|
: _paletteHighlightDark(palette)) ??
|
||||||
darkColors.highlight;
|
darkColors.highlight;
|
||||||
|
Color textColor = (accentColor == AccentColor.custom
|
||||||
|
? settings.customTextColor
|
||||||
|
: _paletteTextDark(palette)) ??
|
||||||
|
darkColors.text;
|
||||||
|
|
||||||
Color newSecondary = (accentColor == AccentColor.adaptive ||
|
Color newSecondary = (accentColor == AccentColor.adaptive ||
|
||||||
accentColor == AccentColor.custom ||
|
accentColor == AccentColor.custom ||
|
||||||
@ -184,8 +200,8 @@ class AppTheme {
|
|||||||
brightness: Brightness.dark,
|
brightness: Brightness.dark,
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
fontFamily: _defaultFontFamily,
|
fontFamily: _defaultFontFamily,
|
||||||
textTheme: googleFontsMap[settings.fontFamily]
|
textTheme:
|
||||||
?.apply(bodyColor: darkColors.text),
|
googleFontsMap[settings.fontFamily]?.apply(bodyColor: textColor),
|
||||||
scaffoldBackgroundColor: backgroundColor,
|
scaffoldBackgroundColor: backgroundColor,
|
||||||
primaryColor: darkColors.filc,
|
primaryColor: darkColors.filc,
|
||||||
dividerColor: const Color(0x00000000),
|
dividerColor: const Color(0x00000000),
|
||||||
|
@ -396,7 +396,9 @@ class AbsencesPageState extends State<AbsencesPage>
|
|||||||
child: filterWidgets[index - (activeData <= 1 ? 1 : 0)],
|
child: filterWidgets[index - (activeData <= 1 ? 1 : 0)],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return activeData == 1 ? Empty(subtitle: "emptyDelays".i18n) : Empty(subtitle: "emptyMisses".i18n);
|
return activeData == 1
|
||||||
|
? Empty(subtitle: "emptyDelays".i18n)
|
||||||
|
: Empty(subtitle: "emptyMisses".i18n);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -41,6 +41,7 @@ enum CustomColorMode {
|
|||||||
accent,
|
accent,
|
||||||
background,
|
background,
|
||||||
highlight,
|
highlight,
|
||||||
|
text,
|
||||||
icon,
|
icon,
|
||||||
enterId,
|
enterId,
|
||||||
}
|
}
|
||||||
@ -111,7 +112,7 @@ class _PremiumCustomAccentColorSettingState
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_colorsTabController = TabController(length: 4, vsync: this);
|
_colorsTabController = TabController(length: 5, vsync: this);
|
||||||
_testTabController = TabController(length: 4, vsync: this);
|
_testTabController = TabController(length: 4, vsync: this);
|
||||||
settings = Provider.of<SettingsProvider>(context, listen: false);
|
settings = Provider.of<SettingsProvider>(context, listen: false);
|
||||||
shareProvider = Provider.of<ShareProvider>(context, listen: false);
|
shareProvider = Provider.of<ShareProvider>(context, listen: false);
|
||||||
@ -141,7 +142,8 @@ class _PremiumCustomAccentColorSettingState
|
|||||||
return [
|
return [
|
||||||
settings.customBackgroundColor,
|
settings.customBackgroundColor,
|
||||||
settings.customHighlightColor,
|
settings.customHighlightColor,
|
||||||
settings.customAccentColor
|
settings.customAccentColor,
|
||||||
|
settings.customTextColor,
|
||||||
];
|
];
|
||||||
case CustomColorMode.background:
|
case CustomColorMode.background:
|
||||||
return settings.customBackgroundColor;
|
return settings.customBackgroundColor;
|
||||||
@ -149,6 +151,8 @@ class _PremiumCustomAccentColorSettingState
|
|||||||
return settings.customHighlightColor;
|
return settings.customHighlightColor;
|
||||||
case CustomColorMode.accent:
|
case CustomColorMode.accent:
|
||||||
return settings.customAccentColor;
|
return settings.customAccentColor;
|
||||||
|
case CustomColorMode.text:
|
||||||
|
return settings.customTextColor;
|
||||||
case CustomColorMode.icon:
|
case CustomColorMode.icon:
|
||||||
return settings.customIconColor;
|
return settings.customIconColor;
|
||||||
case CustomColorMode.enterId:
|
case CustomColorMode.enterId:
|
||||||
@ -183,12 +187,15 @@ class _PremiumCustomAccentColorSettingState
|
|||||||
settings.update(
|
settings.update(
|
||||||
customHighlightColor: AppColors.of(context).highlight,
|
customHighlightColor: AppColors.of(context).highlight,
|
||||||
store: store);
|
store: store);
|
||||||
|
settings.update(
|
||||||
|
customTextColor: AppColors.of(context).text, store: store);
|
||||||
settings.update(customAccentColor: v, store: store);
|
settings.update(customAccentColor: v, store: store);
|
||||||
break;
|
break;
|
||||||
case CustomColorMode.saved:
|
case CustomColorMode.saved:
|
||||||
settings.update(customBackgroundColor: v[0], store: store);
|
settings.update(customBackgroundColor: v[0], store: store);
|
||||||
settings.update(customHighlightColor: v[1], store: store);
|
settings.update(customHighlightColor: v[1], store: store);
|
||||||
settings.update(customAccentColor: v[3], store: store);
|
settings.update(customAccentColor: v[3], store: store);
|
||||||
|
settings.update(customTextColor: v[4], store: store);
|
||||||
break;
|
break;
|
||||||
case CustomColorMode.background:
|
case CustomColorMode.background:
|
||||||
settings.update(customBackgroundColor: v, store: store);
|
settings.update(customBackgroundColor: v, store: store);
|
||||||
@ -199,6 +206,9 @@ class _PremiumCustomAccentColorSettingState
|
|||||||
case CustomColorMode.accent:
|
case CustomColorMode.accent:
|
||||||
settings.update(customAccentColor: v, store: store);
|
settings.update(customAccentColor: v, store: store);
|
||||||
break;
|
break;
|
||||||
|
case CustomColorMode.text:
|
||||||
|
settings.update(customTextColor: v, store: store);
|
||||||
|
break;
|
||||||
case CustomColorMode.icon:
|
case CustomColorMode.icon:
|
||||||
settings.update(customIconColor: v, store: store);
|
settings.update(customIconColor: v, store: store);
|
||||||
break;
|
break;
|
||||||
@ -730,6 +740,13 @@ class _PremiumCustomAccentColorSettingState
|
|||||||
tab: Tab(
|
tab: Tab(
|
||||||
text: "colorpicker_accent"
|
text: "colorpicker_accent"
|
||||||
.i18n)),
|
.i18n)),
|
||||||
|
ColorTab(
|
||||||
|
unlocked: hasAccess,
|
||||||
|
color: settings.customTextColor ??
|
||||||
|
unknownColor,
|
||||||
|
tab: Tab(
|
||||||
|
text:
|
||||||
|
"colorpicker_text".i18n)),
|
||||||
// ColorTab(
|
// ColorTab(
|
||||||
// unlocked: hasAccess,
|
// unlocked: hasAccess,
|
||||||
// color: settings.customIconColor ??
|
// color: settings.customIconColor ??
|
||||||
@ -788,6 +805,12 @@ class _PremiumCustomAccentColorSettingState
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
|
setState(() {
|
||||||
|
colorMode =
|
||||||
|
CustomColorMode.text;
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
setState(() {
|
setState(() {
|
||||||
colorMode =
|
colorMode =
|
||||||
CustomColorMode.icon;
|
CustomColorMode.icon;
|
||||||
@ -826,6 +849,12 @@ class _PremiumCustomAccentColorSettingState
|
|||||||
? settings
|
? settings
|
||||||
.customHighlightColor ??
|
.customHighlightColor ??
|
||||||
unknownColor
|
unknownColor
|
||||||
|
: colorMode ==
|
||||||
|
CustomColorMode
|
||||||
|
.text
|
||||||
|
? settings
|
||||||
|
.customTextColor ??
|
||||||
|
unknownColor
|
||||||
: settings
|
: settings
|
||||||
.customIconColor ??
|
.customIconColor ??
|
||||||
unknownColor,
|
unknownColor,
|
||||||
@ -851,6 +880,11 @@ class _PremiumCustomAccentColorSettingState
|
|||||||
AppColors.of(context)
|
AppColors.of(context)
|
||||||
.highlight,
|
.highlight,
|
||||||
store: true);
|
store: true);
|
||||||
|
settings.update(
|
||||||
|
customTextColor:
|
||||||
|
AppColors.of(context)
|
||||||
|
.text,
|
||||||
|
store: true);
|
||||||
settings.update(
|
settings.update(
|
||||||
customIconColor:
|
customIconColor:
|
||||||
const Color(0x00000000),
|
const Color(0x00000000),
|
||||||
|
@ -10,6 +10,7 @@ extension SettingsLocalization on String {
|
|||||||
"colorpicker_panels": "Panels",
|
"colorpicker_panels": "Panels",
|
||||||
"colorpicker_accent": "Accent",
|
"colorpicker_accent": "Accent",
|
||||||
"colorpicker_icon": "Icon",
|
"colorpicker_icon": "Icon",
|
||||||
|
"colorpicker_text": "Text",
|
||||||
"need_sub": "You need Kupak subscription to use modify this.",
|
"need_sub": "You need Kupak subscription to use modify this.",
|
||||||
"advanced": "Advanced",
|
"advanced": "Advanced",
|
||||||
"enter_id": "Enter ID",
|
"enter_id": "Enter ID",
|
||||||
@ -28,6 +29,7 @@ extension SettingsLocalization on String {
|
|||||||
"colorpicker_panels": "Panelek",
|
"colorpicker_panels": "Panelek",
|
||||||
"colorpicker_accent": "Színtónus",
|
"colorpicker_accent": "Színtónus",
|
||||||
"colorpicker_icon": "Ikon",
|
"colorpicker_icon": "Ikon",
|
||||||
|
"colorpicker_text": "Szöveg",
|
||||||
"need_sub": "A módosításhoz Kupak szintű támogatás szükséges.",
|
"need_sub": "A módosításhoz Kupak szintű támogatás szükséges.",
|
||||||
"advanced": "Haladó",
|
"advanced": "Haladó",
|
||||||
"enter_id": "ID megadása",
|
"enter_id": "ID megadása",
|
||||||
@ -46,6 +48,7 @@ extension SettingsLocalization on String {
|
|||||||
"colorpicker_panels": "Tafeln",
|
"colorpicker_panels": "Tafeln",
|
||||||
"colorpicker_accent": "Akzent",
|
"colorpicker_accent": "Akzent",
|
||||||
"colorpicker_icon": "Ikone",
|
"colorpicker_icon": "Ikone",
|
||||||
|
"colorpicker_text": "Text",
|
||||||
"need_sub":
|
"need_sub":
|
||||||
"Sie benötigen ein Kupak-Abonnement, um diese Funktion zu ändern.",
|
"Sie benötigen ein Kupak-Abonnement, um diese Funktion zu ändern.",
|
||||||
"advanced": "Fortschrittlich",
|
"advanced": "Fortschrittlich",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user