forked from firka/firka
tt: settings toast
This commit is contained in:
@@ -27,6 +27,10 @@ const appIcon = 1009;
|
||||
const childProtection = 1010;
|
||||
const betaWarning = 1011;
|
||||
|
||||
const ttToastLessonNo = 1012;
|
||||
const ttToastTestsAndHw = 1013;
|
||||
const ttToastBreaks = 1014;
|
||||
|
||||
bool always() {
|
||||
return true;
|
||||
}
|
||||
@@ -228,7 +232,39 @@ class SettingsStore {
|
||||
|
||||
// misc
|
||||
"beta_warning": SettingsBoolean(
|
||||
betaWarning, null, null, "Beta warning", false, never)
|
||||
betaWarning, null, null, "Beta warning", false, never),
|
||||
"timetable_toast": SettingsSubGroup(
|
||||
0,
|
||||
null,
|
||||
null,
|
||||
l10n.tt_settings_toast,
|
||||
LinkedHashMap.of({
|
||||
"header":
|
||||
SettingsMediumHeader(0, l10n.tt_settings_toast, always),
|
||||
"padding": SettingsPadding(0, 16, always),
|
||||
"lesson_no": SettingsBoolean(
|
||||
ttToastLessonNo,
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.clockSolid,
|
||||
l10n.tt_settings_toast_lesson_nos,
|
||||
true,
|
||||
always),
|
||||
"tests_and_homework": SettingsBoolean(
|
||||
ttToastTestsAndHw,
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.editPen4Solid,
|
||||
l10n.tt_settings_toast_lesson_tests,
|
||||
true,
|
||||
always),
|
||||
"breaks": SettingsBoolean(
|
||||
ttToastBreaks,
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.viewRowsLine,
|
||||
l10n.tt_settings_toast_lesson_breaks,
|
||||
true,
|
||||
always),
|
||||
}),
|
||||
never)
|
||||
}),
|
||||
always);
|
||||
|
||||
@@ -456,6 +492,28 @@ class SettingsHeader implements SettingsItem {
|
||||
Future<void> save(IsarCollection<AppSettingsModel> model) async {}
|
||||
}
|
||||
|
||||
class SettingsMediumHeader implements SettingsItem {
|
||||
@override
|
||||
Id key;
|
||||
@override
|
||||
FirkaIconType? iconType;
|
||||
@override
|
||||
Object? iconData;
|
||||
@override
|
||||
bool Function() visibilityProvider;
|
||||
@override
|
||||
Future<void> Function() postUpdate = () async {};
|
||||
String title;
|
||||
|
||||
SettingsMediumHeader(this.key, this.title, this.visibilityProvider);
|
||||
|
||||
@override
|
||||
Future<void> load(IsarCollection<AppSettingsModel> model) async {}
|
||||
|
||||
@override
|
||||
Future<void> save(IsarCollection<AppSettingsModel> model) async {}
|
||||
}
|
||||
|
||||
class SettingsHeaderSmall implements SettingsItem {
|
||||
@override
|
||||
Id key;
|
||||
|
||||
Submodule firka/lib/l10n updated: 46e7616f7d...e69d8c3723
@@ -2,7 +2,9 @@ import 'package:carousel_slider/carousel_slider.dart';
|
||||
import 'package:firka/helpers/api/model/timetable.dart';
|
||||
import 'package:firka/helpers/debug_helper.dart';
|
||||
import 'package:firka/helpers/extensions.dart';
|
||||
import 'package:firka/helpers/settings/setting.dart';
|
||||
import 'package:firka/ui/model/style.dart';
|
||||
import 'package:firka/ui/phone/screens/settings/settings_screen.dart';
|
||||
import 'package:firka/ui/widget/delayed_spinner.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||
@@ -199,17 +201,28 @@ class _HomeTimetableScreen extends State<HomeTimetableScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
Card(
|
||||
color: appStyle.colors.buttonSecondaryFill,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.settingsCogSolid,
|
||||
size: 26.0,
|
||||
color: appStyle.colors.accent,
|
||||
GestureDetector(
|
||||
child: Card(
|
||||
color: appStyle.colors.buttonSecondaryFill,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.settingsCogSolid,
|
||||
size: 26.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
showSettingsSheet(
|
||||
context,
|
||||
MediaQuery.of(context).size.height * 0.4,
|
||||
widget.data,
|
||||
widget.data.settings
|
||||
.group("settings")
|
||||
.subGroup("timetable_toast"));
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
|
||||
@@ -82,6 +82,14 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
|
||||
continue;
|
||||
}
|
||||
if (item is SettingsMediumHeader) {
|
||||
widgets.add(Text(
|
||||
item.title,
|
||||
style: appStyle.fonts.H_H2.apply(color: appStyle.colors.textPrimary),
|
||||
));
|
||||
|
||||
continue;
|
||||
}
|
||||
if (item is SettingsHeaderSmall) {
|
||||
widgets.add(Text(
|
||||
item.title,
|
||||
@@ -554,3 +562,41 @@ void showSetDoubleSheet(BuildContext context, SettingsDouble setting,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void showSettingsSheet(BuildContext context, double height,
|
||||
AppInitialization data, LinkedHashMap<String, SettingsItem> items) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
elevation: 100,
|
||||
isScrollControlled: true,
|
||||
enableDrag: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
barrierColor: appStyle.colors.a15p,
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: height,
|
||||
),
|
||||
builder: (BuildContext context) {
|
||||
return Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: GestureDetector(
|
||||
onTap: () => Navigator.pop(context),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(color: Colors.transparent),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: appStyle.colors.card,
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
||||
),
|
||||
child: SettingsScreen(data, items),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user