added option for timetable naming modes
This commit is contained in:
parent
9f51d68531
commit
65b29ec4b8
@ -1,12 +1,18 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import '../../view/pages/timetable/timetableNameMode.dart';
|
||||
|
||||
part 'timetableSettings.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class TimetableSettings {
|
||||
bool connectDoubleLessons;
|
||||
TimetableNameMode timetableNameMode;
|
||||
|
||||
TimetableSettings({required this.connectDoubleLessons});
|
||||
TimetableSettings({
|
||||
required this.connectDoubleLessons,
|
||||
required this.timetableNameMode
|
||||
});
|
||||
|
||||
factory TimetableSettings.fromJson(Map<String, dynamic> json) => _$TimetableSettingsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$TimetableSettingsToJson(this);
|
||||
|
@ -9,9 +9,19 @@ part of 'timetableSettings.dart';
|
||||
TimetableSettings _$TimetableSettingsFromJson(Map<String, dynamic> json) =>
|
||||
TimetableSettings(
|
||||
connectDoubleLessons: json['connectDoubleLessons'] as bool,
|
||||
timetableNameMode:
|
||||
$enumDecode(_$TimetableNameModeEnumMap, json['timetableNameMode']),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$TimetableSettingsToJson(TimetableSettings instance) =>
|
||||
<String, dynamic>{
|
||||
'connectDoubleLessons': instance.connectDoubleLessons,
|
||||
'timetableNameMode':
|
||||
_$TimetableNameModeEnumMap[instance.timetableNameMode]!,
|
||||
};
|
||||
|
||||
const _$TimetableNameModeEnumMap = {
|
||||
TimetableNameMode.name: 'name',
|
||||
TimetableNameMode.longName: 'longName',
|
||||
TimetableNameMode.alternateName: 'alternateName',
|
||||
};
|
||||
|
@ -1,26 +1,21 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../widget/dropdownDisplay.dart';
|
||||
|
||||
class AppTheme {
|
||||
static ThemeModeDisplay getDisplayOptions(ThemeMode theme) {
|
||||
static DropdownDisplay getDisplayOptions(ThemeMode theme) {
|
||||
switch(theme) {
|
||||
case ThemeMode.system:
|
||||
return ThemeModeDisplay(icon: Icons.auto_fix_high_outlined, displayName: 'Systemvorgabe');
|
||||
return DropdownDisplay(icon: Icons.auto_fix_high_outlined, displayName: 'Systemvorgabe');
|
||||
|
||||
case ThemeMode.light:
|
||||
return ThemeModeDisplay(icon: Icons.wb_sunny_outlined, displayName: 'Hell');
|
||||
return DropdownDisplay(icon: Icons.wb_sunny_outlined, displayName: 'Hell');
|
||||
|
||||
case ThemeMode.dark:
|
||||
return ThemeModeDisplay(icon: Icons.dark_mode_outlined, displayName: 'Dunkel');
|
||||
return DropdownDisplay(icon: Icons.dark_mode_outlined, displayName: 'Dunkel');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static bool isDarkMode(BuildContext context) => Theme.of(context).brightness == Brightness.dark;
|
||||
}
|
||||
|
||||
class ThemeModeDisplay {
|
||||
final IconData icon;
|
||||
final String displayName;
|
||||
|
||||
ThemeModeDisplay({required this.icon, required this.displayName});
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import 'customTimetableColors.dart';
|
||||
import 'customTimetableEventEditDialog.dart';
|
||||
import 'timeRegionComponent.dart';
|
||||
import 'timetableEvents.dart';
|
||||
import 'timetableNameMode.dart';
|
||||
import 'viewCustomTimetableEvents.dart';
|
||||
|
||||
class Timetable extends StatefulWidget {
|
||||
@ -72,7 +73,6 @@ class _TimetableState extends State<Timetable> {
|
||||
title = 'Kalendereintrag hinzufügen';
|
||||
icon = const Icon(Icons.add);
|
||||
case CalendarActions.viewEvents:
|
||||
default:
|
||||
title = 'Kalendereinträge anzeigen';
|
||||
icon = const Icon(Icons.perm_contact_calendar_outlined);
|
||||
}
|
||||
@ -300,11 +300,20 @@ class _TimetableState extends State<Timetable> {
|
||||
try {
|
||||
var startTime = _parseWebuntisTimestamp(element.date, element.startTime);
|
||||
var endTime = _parseWebuntisTimestamp(element.date, element.endTime);
|
||||
|
||||
var subject = subjects.result.firstWhere((subject) => subject.id == element.su[0].id);
|
||||
var subjectName = {
|
||||
TimetableNameMode.name: subject.name,
|
||||
TimetableNameMode.longName: subject.longName,
|
||||
TimetableNameMode.alternateName: subject.alternateName,
|
||||
}[settings.val().timetableSettings.timetableNameMode];
|
||||
|
||||
|
||||
return Appointment(
|
||||
id: ArbitraryAppointment(webuntis: element),
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
subject: subjects.result.firstWhere((subject) => subject.id == element.su[0].id).name,
|
||||
subject: subjectName!,
|
||||
location: ''
|
||||
'${rooms.result.firstWhere((room) => room.id == element.ro[0].id).name}'
|
||||
'\n'
|
||||
|
25
lib/view/pages/timetable/timetableNameMode.dart
Normal file
25
lib/view/pages/timetable/timetableNameMode.dart
Normal file
@ -0,0 +1,25 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../widget/dropdownDisplay.dart';
|
||||
|
||||
enum TimetableNameMode {
|
||||
name,
|
||||
longName,
|
||||
alternateName
|
||||
}
|
||||
|
||||
class TimetableNameModes {
|
||||
static DropdownDisplay getDisplayOptions(TimetableNameMode theme) {
|
||||
switch(theme) {
|
||||
case TimetableNameMode.name:
|
||||
return DropdownDisplay(icon: Icons.device_unknown_outlined, displayName: 'Name');
|
||||
|
||||
case TimetableNameMode.longName:
|
||||
return DropdownDisplay(icon: Icons.perm_device_info_outlined, displayName: 'Langname');
|
||||
|
||||
case TimetableNameMode.alternateName:
|
||||
return DropdownDisplay(icon: Icons.on_device_training_outlined, displayName: 'Kurzform');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import '../../storage/notification/notificationSettings.dart';
|
||||
import '../../storage/talk/talkSettings.dart';
|
||||
import '../../storage/timetable/timetableSettings.dart';
|
||||
import '../pages/files/files.dart';
|
||||
import '../pages/timetable/timetableNameMode.dart';
|
||||
|
||||
class DefaultSettings {
|
||||
static Settings get() => Settings(
|
||||
@ -18,6 +19,7 @@ class DefaultSettings {
|
||||
devToolsEnabled: false,
|
||||
timetableSettings: TimetableSettings(
|
||||
connectDoubleLessons: false,
|
||||
timetableNameMode: TimetableNameMode.name
|
||||
),
|
||||
talkSettings: TalkSettings(
|
||||
sortFavoritesToTop: true,
|
||||
|
@ -14,6 +14,7 @@ import '../../theming/appTheme.dart';
|
||||
import '../../widget/centeredLeading.dart';
|
||||
import '../../widget/confirmDialog.dart';
|
||||
import '../../widget/debug/cacheView.dart';
|
||||
import '../pages/timetable/timetableNameMode.dart';
|
||||
import 'defaultSettings.dart';
|
||||
import 'devToolsSettingsDialog.dart';
|
||||
import 'privacyInfo.dart';
|
||||
@ -95,6 +96,29 @@ class _SettingsState extends State<Settings> {
|
||||
|
||||
const Divider(),
|
||||
|
||||
ListTile(
|
||||
leading: const Icon(Icons.abc_outlined),
|
||||
title: const Text('Fachbezeichnung'),
|
||||
trailing: DropdownButton<TimetableNameMode>(
|
||||
value: settings.val().timetableSettings.timetableNameMode,
|
||||
icon: Icon(Icons.arrow_drop_down),
|
||||
items: TimetableNameMode.values.map((e) => DropdownMenuItem(
|
||||
value: e,
|
||||
enabled: e != settings.val().timetableSettings.timetableNameMode,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(TimetableNameModes.getDisplayOptions(e).icon),
|
||||
const SizedBox(width: 10),
|
||||
Text(TimetableNameModes.getDisplayOptions(e).displayName),
|
||||
],
|
||||
),
|
||||
)).toList(),
|
||||
onChanged: (value) {
|
||||
settings.val(write: true).timetableSettings.timetableNameMode = value!;
|
||||
Provider.of<TimetableProps>(context, listen: false).run(renew: false);
|
||||
},
|
||||
)
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.calendar_view_day_outlined),
|
||||
title: const Text('Doppelstunden zusammenhängend anzeigen'),
|
||||
|
8
lib/widget/dropdownDisplay.dart
Normal file
8
lib/widget/dropdownDisplay.dart
Normal file
@ -0,0 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class DropdownDisplay {
|
||||
final IconData icon;
|
||||
final String displayName;
|
||||
|
||||
DropdownDisplay({required this.icon, required this.displayName});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user