Skip to content
Snippets Groups Projects
Commit 0c79855b authored by doodlezucc's avatar doodlezucc
Browse files

deprecate teacher view

parent 2179270f
No related branches found
No related tags found
No related merge requests found
......@@ -4,14 +4,29 @@ import '../untis/element.dart';
class LessonChip extends StatelessWidget {
final UntisElement data;
final void Function() onPressed;
final void Function()? onPressed;
const LessonChip(this.data, {super.key, required this.onPressed});
static Color getTextColorOfState(
BuildContext context, {
required bool pressable,
}) {
final theme = Theme.of(context);
return pressable ? theme.primaryColor : theme.iconTheme.color!;
}
static MaterialStateColor getTextColor(BuildContext context) =>
MaterialStateColor.resolveWith((states) => getTextColorOfState(
context,
pressable: !states.contains(MaterialState.disabled),
));
@override
Widget build(BuildContext context) {
return TextButton(
onPressed: onPressed,
style: ButtonStyle(foregroundColor: getTextColor(context)),
child: Text(data.name, overflow: TextOverflow.ellipsis),
);
}
......
......@@ -6,20 +6,27 @@ import 'lesson_chip.dart';
class LessonChipCollection extends StatelessWidget {
final IconData icon;
final Iterable<UntisElement> elements;
final void Function(UntisElement element) onChipTap;
final void Function(UntisElement element)? onChipTap;
const LessonChipCollection(this.icon, this.elements,
{super.key, required this.onChipTap});
const LessonChipCollection(
this.icon,
this.elements, {
super.key,
this.onChipTap,
});
@override
Widget build(BuildContext context) {
return Row(
children: [
Icon(icon, color: Theme.of(context).primaryColor),
Icon(icon,
color: LessonChip.getTextColorOfState(context,
pressable: onChipTap != null)),
Expanded(
child: Wrap(
children: elements
.map((e) => LessonChip(e, onPressed: () => onChipTap(e)))
.map((e) => LessonChip(e,
onPressed: onChipTap == null ? null : () => onChipTap!(e)))
.toList(),
),
)
......
......@@ -6,7 +6,6 @@ import '../untis/lesson.dart';
import '../util/set_extension.dart';
import '../views/lecture_view.dart';
import '../views/room_view.dart';
import '../views/teacher_view.dart';
import '../views/view.dart';
import 'lesson_chip_collection.dart';
import 'weekday_header.dart';
......@@ -102,7 +101,6 @@ class _LessonDialogState extends State<LessonDialog> {
LessonChipCollection(
BrandingIcons.teacher,
lesson.teachers,
onChipTap: (e) => changeView(TeacherView(teacherId: e.id)),
),
],
);
......
......@@ -2,6 +2,7 @@ import '../untis/element_type.dart';
import 'single_element_view.dart';
@Deprecated('Only logged in users can see teacher timetables')
class TeacherView extends SingleElementView {
TeacherView({required int teacherId}) : super(elementId: teacherId);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment