forked from firka/firka
feat: settings screen redesign with extras page and toggles
This commit is contained in:
@@ -200,7 +200,7 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) {
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.settingsCogSolid,
|
||||
l10n.s_a,
|
||||
l10n.s_ag,
|
||||
[
|
||||
SettingsUiBackHeader(l10n.s_settings, always),
|
||||
SettingsUiHeader(l10n.s_ag, always),
|
||||
@@ -280,6 +280,8 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) {
|
||||
], always),
|
||||
],
|
||||
always,
|
||||
null,
|
||||
l10n.s_a_desc,
|
||||
),
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticons,
|
||||
@@ -289,6 +291,17 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) {
|
||||
SettingsUiPersonalization(appIconPickerTree, always),
|
||||
],
|
||||
always,
|
||||
null,
|
||||
l10n.s_c_desc,
|
||||
),
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.bellSolid,
|
||||
l10n.s_notifications,
|
||||
const [],
|
||||
always,
|
||||
null,
|
||||
l10n.s_todo,
|
||||
),
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticons,
|
||||
@@ -351,11 +364,85 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) {
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.lightningBoltSolid,
|
||||
l10n.s_extras,
|
||||
[SettingsUiBackHeader(l10n.s_settings, always)],
|
||||
never,
|
||||
[
|
||||
SettingsUiBackHeader(l10n.s_settings, always),
|
||||
SettingsUiHeader(l10n.s_extras, always),
|
||||
SettingsUiPadding(23, always),
|
||||
SettingsUiBoolean(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.questionCircleSolid,
|
||||
l10n.s_surprise_grades,
|
||||
SettingsRegistry.surpriseGrades,
|
||||
always,
|
||||
),
|
||||
SettingsUiBoolean(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.shootingStarSolid,
|
||||
l10n.s_seasonal_icons,
|
||||
SettingsRegistry.seasonalAppIcons,
|
||||
always,
|
||||
),
|
||||
SettingsUiBoolean(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.flower2Solid,
|
||||
l10n.s_uwu_mode,
|
||||
SettingsRegistry.uwuMode,
|
||||
always,
|
||||
),
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.calendarSolid,
|
||||
l10n.s_calendar_sync,
|
||||
const [],
|
||||
always,
|
||||
null,
|
||||
l10n.s_todo,
|
||||
),
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.bookmarkSolid,
|
||||
l10n.s_save_grades,
|
||||
const [],
|
||||
always,
|
||||
null,
|
||||
l10n.s_todo,
|
||||
),
|
||||
SettingsUiPadding(20, always),
|
||||
SettingsUiHeaderSmall(l10n.s_welcome_msg, always),
|
||||
SettingsUiSubGroup(
|
||||
null,
|
||||
null,
|
||||
l10n.s_welcome_msg,
|
||||
const [],
|
||||
always,
|
||||
null,
|
||||
l10n.s_todo,
|
||||
),
|
||||
],
|
||||
always,
|
||||
null,
|
||||
l10n.s_extras_desc,
|
||||
),
|
||||
SettingsUiPadding(20, always),
|
||||
SettingsUiHeaderSmall(l10n.s_other, always),
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.mapMarkerAreaSolid,
|
||||
l10n.s_sticker_map,
|
||||
const [],
|
||||
always,
|
||||
null,
|
||||
l10n.s_todo,
|
||||
),
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.qrCodeSolid,
|
||||
l10n.s_qr_reader,
|
||||
const [],
|
||||
always,
|
||||
null,
|
||||
l10n.s_todo,
|
||||
),
|
||||
SettingsUiPadding(20, never),
|
||||
SettingsUiHeaderSmall(l10n.s_other, never),
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticonsLocal,
|
||||
"wrenchSolid",
|
||||
@@ -417,6 +504,15 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) {
|
||||
],
|
||||
always,
|
||||
),
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.phoneSolid,
|
||||
l10n.s_feedback,
|
||||
const [],
|
||||
always,
|
||||
null,
|
||||
l10n.s_todo,
|
||||
),
|
||||
SettingsUiBoolean(
|
||||
null,
|
||||
null,
|
||||
|
||||
@@ -148,4 +148,37 @@ abstract class SettingsSchema {
|
||||
|
||||
@StringSetting(id: 1033, defaultValue: "http://10.0.0.144:8090")
|
||||
String get mockBackendUrl;
|
||||
|
||||
@StringSetting(id: 1034, defaultValue: "{}")
|
||||
String get lastSeen;
|
||||
|
||||
@BoolSetting(id: 1035, defaultValue: true)
|
||||
bool get surpriseGrades;
|
||||
|
||||
@BoolSetting(id: 1036, defaultValue: true)
|
||||
bool get seasonalAppIcons;
|
||||
|
||||
@BoolSetting(id: 1037, defaultValue: false)
|
||||
bool get uwuMode;
|
||||
|
||||
@BoolSetting(id: 1038, defaultValue: true)
|
||||
bool get notifyAll;
|
||||
|
||||
@BoolSetting(id: 1039, defaultValue: true)
|
||||
bool get notifyGrades;
|
||||
|
||||
@BoolSetting(id: 1040, defaultValue: true)
|
||||
bool get notifyHomeworkTests;
|
||||
|
||||
@BoolSetting(id: 1041, defaultValue: true)
|
||||
bool get notifyAbsences;
|
||||
|
||||
@BoolSetting(id: 1042, defaultValue: true)
|
||||
bool get notifyLessons;
|
||||
|
||||
@BoolSetting(id: 1043, defaultValue: true)
|
||||
bool get notifyMessages;
|
||||
|
||||
@StringSetting(id: 1044, defaultValue: "[]")
|
||||
String get notifyMutedSubjects;
|
||||
}
|
||||
|
||||
@@ -35,9 +35,20 @@ class SettingsRegistry {
|
||||
static const selectedGradeThemeId = StringSetting(id: 1031, defaultValue: "firka");
|
||||
static const mockBackendEnabled = BoolSetting(id: 1032, defaultValue: false);
|
||||
static const mockBackendUrl = StringSetting(id: 1033, defaultValue: "http://10.0.0.144:8090");
|
||||
static const lastSeen = StringSetting(id: 1034, defaultValue: "{}");
|
||||
static const surpriseGrades = BoolSetting(id: 1035, defaultValue: true);
|
||||
static const seasonalAppIcons = BoolSetting(id: 1036, defaultValue: true);
|
||||
static const uwuMode = BoolSetting(id: 1037, defaultValue: false);
|
||||
static const notifyAll = BoolSetting(id: 1038, defaultValue: true);
|
||||
static const notifyGrades = BoolSetting(id: 1039, defaultValue: true);
|
||||
static const notifyHomeworkTests = BoolSetting(id: 1040, defaultValue: true);
|
||||
static const notifyAbsences = BoolSetting(id: 1041, defaultValue: true);
|
||||
static const notifyLessons = BoolSetting(id: 1042, defaultValue: true);
|
||||
static const notifyMessages = BoolSetting(id: 1043, defaultValue: true);
|
||||
static const notifyMutedSubjects = StringSetting(id: 1044, defaultValue: "[]");
|
||||
|
||||
static const all = <Setting>[
|
||||
bellDelay, rounding1, rounding2, rounding3, rounding4, classAvgOnGraph, leftHandedMode, language, appIcon, childProtection, betaWarning, ttToastLessonNo, ttToastTestsAndHw, ttToastBreaks, statsForNerds, developerOptsEnabled, themeBrightness, ttToastSubstitution, liveActivityEnabled, liveActivityPrivacyEverDeclined, morningNotificationEnabled, morningNotificationTime, ttToastABTimetable, wearOsSupport, titleFont, titleWeight, titleCapitalization, selectedThemeId, selectedCoreThemeId, selectedGradeThemeId, mockBackendEnabled, mockBackendUrl,
|
||||
bellDelay, rounding1, rounding2, rounding3, rounding4, classAvgOnGraph, leftHandedMode, language, appIcon, childProtection, betaWarning, ttToastLessonNo, ttToastTestsAndHw, ttToastBreaks, statsForNerds, developerOptsEnabled, themeBrightness, ttToastSubstitution, liveActivityEnabled, liveActivityPrivacyEverDeclined, morningNotificationEnabled, morningNotificationTime, ttToastABTimetable, wearOsSupport, titleFont, titleWeight, titleCapitalization, selectedThemeId, selectedCoreThemeId, selectedGradeThemeId, mockBackendEnabled, mockBackendUrl, lastSeen, surpriseGrades, seasonalAppIcons, uwuMode, notifyAll, notifyGrades, notifyHomeworkTests, notifyAbsences, notifyLessons, notifyMessages, notifyMutedSubjects,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -74,4 +85,15 @@ extension SettingsAccessors on SettingsRepository {
|
||||
SilentlySettable<String> get selectedGradeThemeId => SilentlySettable(this, SettingsRegistry.selectedGradeThemeId);
|
||||
SilentlySettable<bool> get mockBackendEnabled => SilentlySettable(this, SettingsRegistry.mockBackendEnabled);
|
||||
SilentlySettable<String> get mockBackendUrl => SilentlySettable(this, SettingsRegistry.mockBackendUrl);
|
||||
SilentlySettable<String> get lastSeen => SilentlySettable(this, SettingsRegistry.lastSeen);
|
||||
SilentlySettable<bool> get surpriseGrades => SilentlySettable(this, SettingsRegistry.surpriseGrades);
|
||||
SilentlySettable<bool> get seasonalAppIcons => SilentlySettable(this, SettingsRegistry.seasonalAppIcons);
|
||||
SilentlySettable<bool> get uwuMode => SilentlySettable(this, SettingsRegistry.uwuMode);
|
||||
SilentlySettable<bool> get notifyAll => SilentlySettable(this, SettingsRegistry.notifyAll);
|
||||
SilentlySettable<bool> get notifyGrades => SilentlySettable(this, SettingsRegistry.notifyGrades);
|
||||
SilentlySettable<bool> get notifyHomeworkTests => SilentlySettable(this, SettingsRegistry.notifyHomeworkTests);
|
||||
SilentlySettable<bool> get notifyAbsences => SilentlySettable(this, SettingsRegistry.notifyAbsences);
|
||||
SilentlySettable<bool> get notifyLessons => SilentlySettable(this, SettingsRegistry.notifyLessons);
|
||||
SilentlySettable<bool> get notifyMessages => SilentlySettable(this, SettingsRegistry.notifyMessages);
|
||||
SilentlySettable<String> get notifyMutedSubjects => SilentlySettable(this, SettingsRegistry.notifyMutedSubjects);
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ class SettingsUiSubGroup extends SettingsUiNode {
|
||||
final String title;
|
||||
final List<SettingsUiNode> children;
|
||||
final String? redirectTo;
|
||||
final String? subtitle;
|
||||
|
||||
const SettingsUiSubGroup(
|
||||
this.iconType,
|
||||
@@ -67,6 +68,7 @@ class SettingsUiSubGroup extends SettingsUiNode {
|
||||
this.children,
|
||||
bool Function() visible, [
|
||||
this.redirectTo,
|
||||
this.subtitle,
|
||||
]) : super(visible);
|
||||
}
|
||||
|
||||
@@ -158,3 +160,7 @@ class SettingsUiLogs extends SettingsUiNode {
|
||||
class SettingsUiLicensePage extends SettingsUiNode {
|
||||
const SettingsUiLicensePage(super.visible);
|
||||
}
|
||||
|
||||
class SettingsUiSubjectNotifications extends SettingsUiNode {
|
||||
const SettingsUiSubjectNotifications(super.visible);
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ class SettingsAppIconPickerView extends StatelessWidget {
|
||||
if (group == data.l10n.s_ci_icon_g7 || group == data.l10n.s_ci_icon_g8) {
|
||||
pWidgets.add(SizedBox(height: 12));
|
||||
pWidgets.add(
|
||||
buildBoolRow(item.childProtection, settings, setStateOuter),
|
||||
buildBoolRow(context, item.childProtection, settings, setStateOuter),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
import "package:firka/core/settings/settings_repository.dart";
|
||||
import "package:firka/core/settings/settings_ui.dart";
|
||||
import "package:firka/ui/phone/screens/settings/settings_metrics.dart";
|
||||
import "package:firka/ui/phone/screens/settings/settings_toggle.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:flutter/material.dart";
|
||||
|
||||
Widget buildBoolRow(
|
||||
BuildContext context,
|
||||
SettingsUiBoolean item,
|
||||
SettingsRepository settings,
|
||||
void Function(VoidCallback fn) setStateOuter,
|
||||
) {
|
||||
final value = settings.get(item.setting);
|
||||
final scale = settingsScale(context);
|
||||
|
||||
return FirkaCard(
|
||||
height: 52 + 12,
|
||||
height: settingsItemHeight * scale,
|
||||
rounding: settingsItemRounding * scale,
|
||||
left: [
|
||||
item.iconType != null
|
||||
? Row(
|
||||
@@ -23,7 +28,7 @@ Widget buildBoolRow(
|
||||
item.iconData!,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
SizedBox(width: 12 * scale),
|
||||
],
|
||||
)
|
||||
: SizedBox(),
|
||||
@@ -33,20 +38,9 @@ Widget buildBoolRow(
|
||||
),
|
||||
],
|
||||
right: [
|
||||
Switch(
|
||||
SettingsToggle(
|
||||
value: value,
|
||||
thumbColor: WidgetStateProperty.fromMap({
|
||||
WidgetState.selected: appStyle.colors.buttonSecondaryFill,
|
||||
WidgetState.any: appStyle.colors.accent,
|
||||
}),
|
||||
trackColor: WidgetStateProperty.fromMap({
|
||||
WidgetState.selected: appStyle.colors.accent,
|
||||
WidgetState.any: appStyle.colors.a10p,
|
||||
}),
|
||||
trackOutlineColor: WidgetStateProperty.fromMap({
|
||||
WidgetState.selected: appStyle.colors.accent,
|
||||
WidgetState.any: appStyle.colors.a15p,
|
||||
}),
|
||||
scale: scale,
|
||||
onChanged: (v) async {
|
||||
await settings.set(item.setting, v);
|
||||
setStateOuter(() {});
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import "package:flutter/widgets.dart";
|
||||
|
||||
const settingsDesignWidth = 376.0;
|
||||
const settingsItemHeight = 56.0;
|
||||
const settingsItemRounding = 16.0;
|
||||
|
||||
double settingsScale(BuildContext context) =>
|
||||
MediaQuery.sizeOf(context).width / settingsDesignWidth;
|
||||
@@ -24,6 +24,7 @@ import 'package:firka/core/state/firka_state.dart';
|
||||
import 'settings_account_picker.dart';
|
||||
import 'settings_app_icon_picker.dart';
|
||||
import 'settings_bool_row.dart';
|
||||
import 'settings_metrics.dart';
|
||||
import 'settings_license_page.dart';
|
||||
import 'settings_logs.dart';
|
||||
import 'settings_personalization_view.dart';
|
||||
@@ -77,6 +78,7 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
bool forceRender = false,
|
||||
}) {
|
||||
var widgets = List<Widget>.empty(growable: true);
|
||||
final scale = settingsScale(context);
|
||||
|
||||
for (var item in items) {
|
||||
if (!forceRender && !item.visible()) continue;
|
||||
@@ -93,34 +95,38 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
if (item is SettingsUiBackHeader) {
|
||||
widgets.add(
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Transform.translate(
|
||||
offset: const Offset(-4, 0),
|
||||
child: GestureDetector(
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.chevronLeftLine,
|
||||
color: appStyle.colors.textSecondary,
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () => Navigator.of(context).pop(),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(4, 8, 16, 8),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Transform.translate(
|
||||
offset: const Offset(-8, 0),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.chevronLeftLine,
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
),
|
||||
Transform.translate(
|
||||
offset: const Offset(-4, 1),
|
||||
child: Text(
|
||||
item.title,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
Transform.translate(
|
||||
offset: const Offset(-8, 1),
|
||||
child: Text(
|
||||
item.title,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 13),
|
||||
SizedBox(height: 5),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -174,21 +180,42 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
);
|
||||
cardWidgets.add(SizedBox(width: 8));
|
||||
cardWidgets.add(SizedBox(width: 12 * scale));
|
||||
}
|
||||
|
||||
cardWidgets.add(
|
||||
Text(
|
||||
item.title,
|
||||
style: appStyle.fonts.B_16SB.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
item.subtitle == null
|
||||
? Text(
|
||||
item.title,
|
||||
style: appStyle.fonts.B_16SB.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
)
|
||||
: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 2,
|
||||
children: [
|
||||
Text(
|
||||
item.title,
|
||||
style: appStyle.fonts.B_16SB
|
||||
.apply(color: appStyle.colors.textPrimary)
|
||||
.copyWith(height: 1.1),
|
||||
),
|
||||
Text(
|
||||
item.subtitle!,
|
||||
style: appStyle.fonts.B_14R
|
||||
.apply(color: appStyle.colors.textSecondary)
|
||||
.copyWith(height: 1.1),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
widgets.add(
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
if (item.children.isEmpty && item.redirectTo == null) return;
|
||||
if (item.redirectTo != null && item.redirectTo == "discord") {
|
||||
launchUrlString(
|
||||
"https://discord.com/invite/firka-1111649116020285532",
|
||||
@@ -204,6 +231,8 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
},
|
||||
child: item.redirectTo != null
|
||||
? FirkaCard(
|
||||
height: settingsItemHeight * scale,
|
||||
rounding: settingsItemRounding * scale,
|
||||
left: cardWidgets,
|
||||
right: [
|
||||
RotationTransition(
|
||||
@@ -217,7 +246,11 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
),
|
||||
],
|
||||
)
|
||||
: FirkaCard(left: cardWidgets),
|
||||
: FirkaCard(
|
||||
height: settingsItemHeight * scale,
|
||||
rounding: settingsItemRounding * scale,
|
||||
left: cardWidgets,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -231,7 +264,8 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
widgets.add(
|
||||
GestureDetector(
|
||||
child: FirkaCard(
|
||||
height: 52 + 12,
|
||||
height: settingsItemHeight * scale,
|
||||
rounding: settingsItemRounding * scale,
|
||||
left: [
|
||||
item.iconType != null
|
||||
? Row(
|
||||
@@ -270,7 +304,7 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
continue;
|
||||
}
|
||||
if (item is SettingsUiBoolean) {
|
||||
widgets.add(buildBoolRow(item, settings, setState));
|
||||
widgets.add(buildBoolRow(context, item, settings, setState));
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -282,7 +316,8 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
if (i == activeIndex) {
|
||||
widgets.add(
|
||||
FirkaCard(
|
||||
height: 52 + 12,
|
||||
height: settingsItemHeight * scale,
|
||||
rounding: settingsItemRounding * scale,
|
||||
left: [
|
||||
Text(
|
||||
k,
|
||||
@@ -320,7 +355,8 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
widgets.add(
|
||||
GestureDetector(
|
||||
child: FirkaCard(
|
||||
height: 52 + 12,
|
||||
height: settingsItemHeight * scale,
|
||||
rounding: settingsItemRounding * scale,
|
||||
left: [
|
||||
Text(
|
||||
k,
|
||||
@@ -388,6 +424,8 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
widgets.add(
|
||||
GestureDetector(
|
||||
child: FirkaCard(
|
||||
height: settingsItemHeight * scale,
|
||||
rounding: settingsItemRounding * scale,
|
||||
left: [
|
||||
item.iconType != null
|
||||
? Row(
|
||||
@@ -437,21 +475,16 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
child: Scaffold(
|
||||
backgroundColor: appStyle.colors.background,
|
||||
body: SafeArea(
|
||||
child: SizedBox(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: Stack(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsetsGeometry.all(20),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: body,
|
||||
),
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
padding: const EdgeInsets.fromLTRB(20, 20, 20, 40),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: body,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
63
firka/lib/ui/phone/screens/settings/settings_toggle.dart
Normal file
63
firka/lib/ui/phone/screens/settings/settings_toggle.dart
Normal file
@@ -0,0 +1,63 @@
|
||||
import "package:firka/ui/theme/style.dart";
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
class SettingsToggle extends StatelessWidget {
|
||||
static const _designWidth = 40.0;
|
||||
static const _designHeight = 24.0;
|
||||
static const _designKnob = 20.0;
|
||||
|
||||
final bool value;
|
||||
final double scale;
|
||||
final ValueChanged<bool> onChanged;
|
||||
|
||||
const SettingsToggle({
|
||||
required this.value,
|
||||
required this.onChanged,
|
||||
this.scale = 1,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final width = _designWidth * scale;
|
||||
final height = _designHeight * scale;
|
||||
final knob = _designKnob * scale;
|
||||
final inset = (height - knob) / 2;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () => onChanged(!value),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 150),
|
||||
curve: Curves.easeOut,
|
||||
width: width,
|
||||
height: height,
|
||||
decoration: BoxDecoration(
|
||||
color: value ? appStyle.colors.accent : appStyle.colors.a15p,
|
||||
borderRadius: BorderRadius.circular(height / 2),
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
AnimatedAlign(
|
||||
duration: const Duration(milliseconds: 150),
|
||||
curve: Curves.easeOut,
|
||||
alignment: value ? Alignment.centerRight : Alignment.centerLeft,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: inset),
|
||||
child: Container(
|
||||
width: knob,
|
||||
height: knob,
|
||||
decoration: BoxDecoration(
|
||||
color: value
|
||||
? appStyle.colors.buttonSecondaryFill
|
||||
: appStyle.colors.accent,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ class FirkaCard extends StatelessWidget {
|
||||
final Attach attached;
|
||||
final Color? color;
|
||||
final bool? isLightMode;
|
||||
final double? rounding;
|
||||
final Widget child;
|
||||
|
||||
factory FirkaCard({
|
||||
@@ -29,6 +30,7 @@ class FirkaCard extends StatelessWidget {
|
||||
double? height,
|
||||
double? width,
|
||||
bool? isLightMode,
|
||||
double? rounding,
|
||||
}) {
|
||||
final leftRow = Row(children: left);
|
||||
|
||||
@@ -50,6 +52,7 @@ class FirkaCard extends StatelessWidget {
|
||||
height: height,
|
||||
shadow: shadow,
|
||||
isLightMode: isLightMode,
|
||||
rounding: rounding,
|
||||
child: extra == null ? alignedRow : Column(children: [alignedRow, extra]),
|
||||
);
|
||||
}
|
||||
@@ -64,13 +67,14 @@ class FirkaCard extends StatelessWidget {
|
||||
this.height,
|
||||
this.width,
|
||||
this.isLightMode,
|
||||
this.rounding,
|
||||
required this.child,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final defaultRounding = 16.0;
|
||||
final defaultRounding = rounding ?? 16.0;
|
||||
final attachedRounding = 8.0;
|
||||
final isLight =
|
||||
isLightMode ?? Theme.of(context).brightness == Brightness.light;
|
||||
|
||||
Reference in New Issue
Block a user