50 lines
1.5 KiB
Dart
50 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../access/access_requirement.dart';
|
|
import '../../../session/session_manager.dart';
|
|
import 'sections/about_section.dart';
|
|
import 'sections/account_section.dart';
|
|
import 'sections/appearance_section.dart';
|
|
import 'sections/files_section.dart';
|
|
import 'sections/modules_section.dart';
|
|
import 'sections/notifications_section.dart';
|
|
import 'sections/talk_section.dart';
|
|
import 'sections/timetable_section.dart';
|
|
|
|
class Settings extends StatelessWidget {
|
|
const Settings({super.key});
|
|
|
|
/// Sections in display order with the backend identities they need;
|
|
/// sections the session cannot use are left out.
|
|
static const List<(Widget, Set<AccessRequirement>)> _sections = [
|
|
(AccountSection(), {}),
|
|
(AppearanceSection(), {}),
|
|
(ModulesSection(), {}),
|
|
(TimetableSection(), {}),
|
|
(NotificationsSection(), {}),
|
|
(TalkSection(), {AccessRequirement.nextcloud}),
|
|
(FilesSection(), {AccessRequirement.nextcloud}),
|
|
(AboutSection(), {}),
|
|
];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final session = SessionManager().current;
|
|
final visible = [
|
|
for (final (section, requirements) in _sections)
|
|
if (requirements.areMetBy(session)) section,
|
|
];
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('Einstellungen')),
|
|
body: ListView(
|
|
children: [
|
|
for (final (i, section) in visible.indexed) ...[
|
|
if (i > 0) const Divider(),
|
|
section,
|
|
],
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|