forked from firka/student-legacy
Added function Live Activity Color change, Fixes
This commit is contained in:
parent
625c43d786
commit
0245ddb99e
@ -216,13 +216,13 @@
|
||||
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
|
||||
buildPhases = (
|
||||
779338C8D92BCBC36F75F791 /* [CP] Check Pods Manifest.lock */,
|
||||
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
|
||||
71459C0EB905E05018E3D78F /* [CP] Embed Pods Frameworks */,
|
||||
9740EEB61CF901F6004384FC /* Run Script */,
|
||||
97C146EC1CF9000F007C117D /* Resources */,
|
||||
97C146EA1CF9000F007C117D /* Sources */,
|
||||
97C146EB1CF9000F007C117D /* Frameworks */,
|
||||
97C146EC1CF9000F007C117D /* Resources */,
|
||||
9705A1C41CF9048500538489 /* Embed Frameworks */,
|
||||
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
|
||||
71459C0EB905E05018E3D78F /* [CP] Embed Pods Frameworks */,
|
||||
3127F74F28EAEC8A00C2EFB3 /* Embed Foundation Extensions */,
|
||||
);
|
||||
buildRules = (
|
||||
@ -299,7 +299,7 @@
|
||||
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
alwaysOutOfDate = 1;
|
||||
buildActionMask = 2147483647;
|
||||
buildActionMask = 12;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
@ -314,7 +314,7 @@
|
||||
};
|
||||
71459C0EB905E05018E3D78F /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
buildActionMask = 12;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
|
@ -2,6 +2,8 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>aps-environment</key>
|
||||
<string>development</string>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.refilcnaplo.livecard</string>
|
||||
|
@ -1,6 +1,7 @@
|
||||
import Foundation
|
||||
|
||||
class LessonData {
|
||||
var color: String
|
||||
var icon: String
|
||||
var index: String
|
||||
var title: String
|
||||
@ -13,8 +14,9 @@ class LessonData {
|
||||
var nextRoom: String
|
||||
|
||||
init?() {
|
||||
let sharedDefault = UserDefaults(suiteName: "group.refilc.livecard")!
|
||||
let sharedDefault = UserDefaults(suiteName: "group.refilc2.livecard")!
|
||||
|
||||
self.color = sharedDefault.string(forKey: "color")!
|
||||
self.icon = sharedDefault.string(forKey: "icon")!
|
||||
self.index = sharedDefault.string(forKey: "index")!
|
||||
self.title = sharedDefault.string(forKey: "title")!
|
||||
|
@ -2,6 +2,8 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>aps-environment</key>
|
||||
<string>development</string>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.refilcnaplo.livecard</string>
|
||||
|
@ -68,6 +68,9 @@ struct LockScreenLiveActivityView: View {
|
||||
.monospacedDigit()
|
||||
.padding(.trailing, CGFloat(24))
|
||||
}
|
||||
.activityBackgroundTint(
|
||||
lesson!.color != "0xFF676767" ? Color(lesson!.color) : nil
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,6 +110,7 @@ class LiveCardProvider extends ChangeNotifier {
|
||||
switch (currentState) {
|
||||
case LiveCardState.duringLesson:
|
||||
return {
|
||||
"color": _settings.liveActivityColor.toString(),
|
||||
"icon": currentLesson != null
|
||||
? SubjectIcon.resolveName(subject: currentLesson?.subject)
|
||||
: "book",
|
||||
@ -142,6 +143,7 @@ class LiveCardProvider extends ChangeNotifier {
|
||||
final diff = getFloorDifference();
|
||||
|
||||
return {
|
||||
"color": _settings.liveActivityColor.toString(),
|
||||
"icon": iconFloorMap[diff] ?? "cup.and.saucer",
|
||||
"title": "Szünet",
|
||||
"description": "go $diff".i18n.fill([
|
||||
|
@ -28,6 +28,7 @@ const settingsDB = DatabaseStruct("settings", {
|
||||
"last_account_id": String, "renamed_subjects_enabled": int,
|
||||
"renamed_subjects_italics": int, "renamed_teachers_enabled": int,
|
||||
"renamed_teachers_italics": int,
|
||||
"live_activity_color": String,
|
||||
});
|
||||
// DON'T FORGET TO UPDATE DEFAULT VALUES IN `initDB` MIGRATION OR ELSE PARENTS WILL COMPLAIN ABOUT THEIR CHILDREN MISSING
|
||||
// YOU'VE BEEN WARNED!!!
|
||||
|
@ -71,6 +71,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
bool _renamedSubjectsItalics;
|
||||
bool _renamedTeachersEnabled;
|
||||
bool _renamedTeachersItalics;
|
||||
Color _liveActivityColor;
|
||||
|
||||
SettingsProvider({
|
||||
DatabaseProvider? database,
|
||||
@ -110,6 +111,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
required bool renameSubjectsItalics,
|
||||
required bool renameTeachersEnabled,
|
||||
required bool renameTeachersItalics,
|
||||
required Color liveActivityColor,
|
||||
}) : _database = database,
|
||||
_language = language,
|
||||
_startPage = startPage,
|
||||
@ -146,7 +148,8 @@ class SettingsProvider extends ChangeNotifier {
|
||||
_renamedSubjectsEnabled = renameSubjectsEnabled,
|
||||
_renamedSubjectsItalics = renameSubjectsItalics,
|
||||
_renamedTeachersEnabled = renameTeachersEnabled,
|
||||
_renamedTeachersItalics = renameTeachersItalics;
|
||||
_renamedTeachersItalics = renameTeachersItalics,
|
||||
_liveActivityColor = liveActivityColor;
|
||||
|
||||
factory SettingsProvider.fromMap(Map map,
|
||||
{required DatabaseProvider database}) {
|
||||
@ -205,6 +208,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
renameSubjectsItalics: map["renamed_subjects_italics"] == 1,
|
||||
renameTeachersEnabled: map["renamed_teachers_enabled"] == 1,
|
||||
renameTeachersItalics: map["renamed_teachers_italics"] == 1,
|
||||
liveActivityColor: Color(map["live_activity_color"]),
|
||||
);
|
||||
}
|
||||
|
||||
@ -249,6 +253,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
"renamed_subjects_italics": _renamedSubjectsItalics ? 1 : 0,
|
||||
"renamed_teachers_enabled": _renamedTeachersEnabled ? 1 : 0,
|
||||
"renamed_teachers_italics": _renamedTeachersItalics ? 1 : 0,
|
||||
"live_activity_color": _liveActivityColor.value,
|
||||
};
|
||||
}
|
||||
|
||||
@ -297,6 +302,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
renameSubjectsItalics: false,
|
||||
renameTeachersEnabled: false,
|
||||
renameTeachersItalics: false,
|
||||
liveActivityColor: Color(0xFF676767),
|
||||
);
|
||||
}
|
||||
|
||||
@ -340,6 +346,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
bool get renamedSubjectsItalics => _renamedSubjectsItalics;
|
||||
bool get renamedTeachersEnabled => _renamedTeachersEnabled;
|
||||
bool get renamedTeachersItalics => _renamedTeachersItalics;
|
||||
Color get liveActivityColor => _liveActivityColor;
|
||||
|
||||
Future<void> update({
|
||||
bool store = true,
|
||||
@ -379,6 +386,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
bool? renamedSubjectsItalics,
|
||||
bool? renamedTeachersEnabled,
|
||||
bool? renamedTeachersItalics,
|
||||
Color? liveActivityColor,
|
||||
}) async {
|
||||
if (language != null && language != _language) _language = language;
|
||||
if (startPage != null && startPage != _startPage) _startPage = startPage;
|
||||
@ -478,6 +486,9 @@ class SettingsProvider extends ChangeNotifier {
|
||||
renamedTeachersItalics != _renamedTeachersItalics) {
|
||||
_renamedTeachersItalics = renamedTeachersItalics;
|
||||
}
|
||||
if (liveActivityColor != null && liveActivityColor != _liveActivityColor) {
|
||||
_liveActivityColor = liveActivityColor;
|
||||
}
|
||||
if (store) await _database?.store.storeSettings(this);
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -261,6 +261,13 @@ class SettingsHelper {
|
||||
);
|
||||
}
|
||||
|
||||
static void liveActivityColor(BuildContext context) {
|
||||
showRoundedModalBottomSheet(
|
||||
context,
|
||||
child: const LiveActivityColorSetting(),
|
||||
);
|
||||
}
|
||||
|
||||
static void vibrate(BuildContext context) {
|
||||
showBottomSheetMenu(
|
||||
context,
|
||||
@ -607,3 +614,67 @@ class _GradeColorsSettingState extends State<GradeColorsSetting> {
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
class LiveActivityColorSetting extends StatefulWidget {
|
||||
const LiveActivityColorSetting({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_LiveActivityColorSettingState createState() =>
|
||||
_LiveActivityColorSettingState();
|
||||
}
|
||||
|
||||
class _LiveActivityColorSettingState extends State<LiveActivityColorSetting> {
|
||||
late SettingsProvider settings;
|
||||
Color currentColor = const Color(0x00000000);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
settings = Provider.of<SettingsProvider>(context, listen: false);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: Column(children: [
|
||||
MaterialColorPicker(
|
||||
allowShades: false,
|
||||
selectedColor: settings.liveActivityColor,
|
||||
onMainColorChange: (k) {
|
||||
setState(() {
|
||||
currentColor = k as Color;
|
||||
settings.update(
|
||||
liveActivityColor: currentColor.withAlpha(255));
|
||||
Navigator.of(context).maybePop();
|
||||
});
|
||||
},
|
||||
elevation: 0,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0, top: 40.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
MaterialActionButton(
|
||||
onPressed: () {
|
||||
var defaultColors =
|
||||
SettingsProvider.defaultSettings().liveActivityColor;
|
||||
settings.update(liveActivityColor: defaultColors);
|
||||
Navigator.of(context).maybePop();
|
||||
},
|
||||
child: Text(SettingsLocalization("reset").i18n),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -712,6 +712,25 @@ class _SettingsScreenState extends State<SettingsScreen>
|
||||
),
|
||||
),
|
||||
const PremiumIconPackSelector(),
|
||||
// If iOS, show the iOS specific settings
|
||||
|
||||
if (defaultTargetPlatform == TargetPlatform.iOS)
|
||||
PanelButton(
|
||||
onPressed: () {
|
||||
SettingsHelper.liveActivityColor(context);
|
||||
setState(() {});
|
||||
},
|
||||
title: Text("live_activity_color".i18n),
|
||||
leading: const Icon(FeatherIcons.activity),
|
||||
trailing: Container(
|
||||
width: 12.0,
|
||||
height: 12.0,
|
||||
decoration: BoxDecoration(
|
||||
color: settings.liveActivityColor,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -25,6 +25,7 @@ extension SettingsLocalization on String {
|
||||
"theme": "Theme",
|
||||
"color": "Color",
|
||||
"grade_colors": "Grade Colors",
|
||||
"live_activity_color": "Live Activity Color",
|
||||
"notifications": "Notifications",
|
||||
"news": "News",
|
||||
"extras": "Extras",
|
||||
@ -94,6 +95,7 @@ extension SettingsLocalization on String {
|
||||
"theme": "Téma",
|
||||
"color": "Színek",
|
||||
"grade_colors": "Jegyek színei",
|
||||
"live_activity_color": "Live Activity színe",
|
||||
"notifications": "Értesítések",
|
||||
"news": "Hírek",
|
||||
"extras": "Extrák",
|
||||
@ -163,6 +165,7 @@ extension SettingsLocalization on String {
|
||||
"theme": "Thema",
|
||||
"color": "Farbe",
|
||||
"grade_colors": "Grad Farben",
|
||||
"live_activity_color": "Live Activity Farben",
|
||||
"notifications": "Mitteilung",
|
||||
"news": "Nachrichten",
|
||||
"extras": "Extras",
|
||||
|
Loading…
x
Reference in New Issue
Block a user