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 'package:json_annotation/json_annotation.dart';
|
||||||
|
|
||||||
|
import '../../view/pages/timetable/timetableNameMode.dart';
|
||||||
|
|
||||||
part 'timetableSettings.g.dart';
|
part 'timetableSettings.g.dart';
|
||||||
|
|
||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
class TimetableSettings {
|
class TimetableSettings {
|
||||||
bool connectDoubleLessons;
|
bool connectDoubleLessons;
|
||||||
|
TimetableNameMode timetableNameMode;
|
||||||
|
|
||||||
TimetableSettings({required this.connectDoubleLessons});
|
TimetableSettings({
|
||||||
|
required this.connectDoubleLessons,
|
||||||
|
required this.timetableNameMode
|
||||||
|
});
|
||||||
|
|
||||||
factory TimetableSettings.fromJson(Map<String, dynamic> json) => _$TimetableSettingsFromJson(json);
|
factory TimetableSettings.fromJson(Map<String, dynamic> json) => _$TimetableSettingsFromJson(json);
|
||||||
Map<String, dynamic> toJson() => _$TimetableSettingsToJson(this);
|
Map<String, dynamic> toJson() => _$TimetableSettingsToJson(this);
|
||||||
|
@ -9,9 +9,19 @@ part of 'timetableSettings.dart';
|
|||||||
TimetableSettings _$TimetableSettingsFromJson(Map<String, dynamic> json) =>
|
TimetableSettings _$TimetableSettingsFromJson(Map<String, dynamic> json) =>
|
||||||
TimetableSettings(
|
TimetableSettings(
|
||||||
connectDoubleLessons: json['connectDoubleLessons'] as bool,
|
connectDoubleLessons: json['connectDoubleLessons'] as bool,
|
||||||
|
timetableNameMode:
|
||||||
|
$enumDecode(_$TimetableNameModeEnumMap, json['timetableNameMode']),
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$TimetableSettingsToJson(TimetableSettings instance) =>
|
Map<String, dynamic> _$TimetableSettingsToJson(TimetableSettings instance) =>
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'connectDoubleLessons': instance.connectDoubleLessons,
|
'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 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../widget/dropdownDisplay.dart';
|
||||||
|
|
||||||
class AppTheme {
|
class AppTheme {
|
||||||
static ThemeModeDisplay getDisplayOptions(ThemeMode theme) {
|
static DropdownDisplay getDisplayOptions(ThemeMode theme) {
|
||||||
switch(theme) {
|
switch(theme) {
|
||||||
case ThemeMode.system:
|
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:
|
case ThemeMode.light:
|
||||||
return ThemeModeDisplay(icon: Icons.wb_sunny_outlined, displayName: 'Hell');
|
return DropdownDisplay(icon: Icons.wb_sunny_outlined, displayName: 'Hell');
|
||||||
|
|
||||||
case ThemeMode.dark:
|
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;
|
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 'customTimetableEventEditDialog.dart';
|
||||||
import 'timeRegionComponent.dart';
|
import 'timeRegionComponent.dart';
|
||||||
import 'timetableEvents.dart';
|
import 'timetableEvents.dart';
|
||||||
|
import 'timetableNameMode.dart';
|
||||||
import 'viewCustomTimetableEvents.dart';
|
import 'viewCustomTimetableEvents.dart';
|
||||||
|
|
||||||
class Timetable extends StatefulWidget {
|
class Timetable extends StatefulWidget {
|
||||||
@ -72,7 +73,6 @@ class _TimetableState extends State<Timetable> {
|
|||||||
title = 'Kalendereintrag hinzufügen';
|
title = 'Kalendereintrag hinzufügen';
|
||||||
icon = const Icon(Icons.add);
|
icon = const Icon(Icons.add);
|
||||||
case CalendarActions.viewEvents:
|
case CalendarActions.viewEvents:
|
||||||
default:
|
|
||||||
title = 'Kalendereinträge anzeigen';
|
title = 'Kalendereinträge anzeigen';
|
||||||
icon = const Icon(Icons.perm_contact_calendar_outlined);
|
icon = const Icon(Icons.perm_contact_calendar_outlined);
|
||||||
}
|
}
|
||||||
@ -300,11 +300,20 @@ class _TimetableState extends State<Timetable> {
|
|||||||
try {
|
try {
|
||||||
var startTime = _parseWebuntisTimestamp(element.date, element.startTime);
|
var startTime = _parseWebuntisTimestamp(element.date, element.startTime);
|
||||||
var endTime = _parseWebuntisTimestamp(element.date, element.endTime);
|
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(
|
return Appointment(
|
||||||
id: ArbitraryAppointment(webuntis: element),
|
id: ArbitraryAppointment(webuntis: element),
|
||||||
startTime: startTime,
|
startTime: startTime,
|
||||||
endTime: endTime,
|
endTime: endTime,
|
||||||
subject: subjects.result.firstWhere((subject) => subject.id == element.su[0].id).name,
|
subject: subjectName!,
|
||||||
location: ''
|
location: ''
|
||||||
'${rooms.result.firstWhere((room) => room.id == element.ro[0].id).name}'
|
'${rooms.result.firstWhere((room) => room.id == element.ro[0].id).name}'
|
||||||
'\n'
|
'\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/talk/talkSettings.dart';
|
||||||
import '../../storage/timetable/timetableSettings.dart';
|
import '../../storage/timetable/timetableSettings.dart';
|
||||||
import '../pages/files/files.dart';
|
import '../pages/files/files.dart';
|
||||||
|
import '../pages/timetable/timetableNameMode.dart';
|
||||||
|
|
||||||
class DefaultSettings {
|
class DefaultSettings {
|
||||||
static Settings get() => Settings(
|
static Settings get() => Settings(
|
||||||
@ -18,6 +19,7 @@ class DefaultSettings {
|
|||||||
devToolsEnabled: false,
|
devToolsEnabled: false,
|
||||||
timetableSettings: TimetableSettings(
|
timetableSettings: TimetableSettings(
|
||||||
connectDoubleLessons: false,
|
connectDoubleLessons: false,
|
||||||
|
timetableNameMode: TimetableNameMode.name
|
||||||
),
|
),
|
||||||
talkSettings: TalkSettings(
|
talkSettings: TalkSettings(
|
||||||
sortFavoritesToTop: true,
|
sortFavoritesToTop: true,
|
||||||
|
@ -14,6 +14,7 @@ import '../../theming/appTheme.dart';
|
|||||||
import '../../widget/centeredLeading.dart';
|
import '../../widget/centeredLeading.dart';
|
||||||
import '../../widget/confirmDialog.dart';
|
import '../../widget/confirmDialog.dart';
|
||||||
import '../../widget/debug/cacheView.dart';
|
import '../../widget/debug/cacheView.dart';
|
||||||
|
import '../pages/timetable/timetableNameMode.dart';
|
||||||
import 'defaultSettings.dart';
|
import 'defaultSettings.dart';
|
||||||
import 'devToolsSettingsDialog.dart';
|
import 'devToolsSettingsDialog.dart';
|
||||||
import 'privacyInfo.dart';
|
import 'privacyInfo.dart';
|
||||||
@ -95,6 +96,29 @@ class _SettingsState extends State<Settings> {
|
|||||||
|
|
||||||
const Divider(),
|
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(
|
ListTile(
|
||||||
leading: const Icon(Icons.calendar_view_day_outlined),
|
leading: const Icon(Icons.calendar_view_day_outlined),
|
||||||
title: const Text('Doppelstunden zusammenhängend anzeigen'),
|
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