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