fixed the entire SHIT fullscreen timetable they made

This commit is contained in:
Kima 2024-02-08 21:55:46 +01:00
parent 2ff8974cc9
commit 076d6a12a2

View File

@ -1,9 +1,11 @@
import 'dart:io';
import 'package:collection/collection.dart';
import 'package:filcnaplo/helpers/subject.dart';
import 'package:filcnaplo/models/settings.dart';
import 'package:filcnaplo/theme/colors/colors.dart';
import 'package:filcnaplo_kreta_api/controllers/timetable_controller.dart';
import 'package:filcnaplo_kreta_api/models/lesson.dart';
import 'package:filcnaplo_mobile_ui/common/empty.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@ -60,16 +62,16 @@ class _FSTimetableState extends State<FSTimetable> {
(a, b) => math.max(
a, b.where((l) => l.subject.id != "" || l.isEmpty).length));
const prefixw = 40;
const prefixw = 45;
const padding = prefixw + 6 * 2;
final colw = (MediaQuery.of(context).size.width - padding) / days.length;
return Scaffold(
appBar: AppBar(
surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
leading: BackButton(color: AppColors.of(context).text),
shadowColor: Colors.transparent,
),
// appBar: AppBar(
// surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
// leading: BackButton(color: AppColors.of(context).text),
// shadowColor: Colors.transparent,
// ),
body: ListView.builder(
physics: const BouncingScrollPhysics(),
padding: const EdgeInsets.symmetric(horizontal: 6.0, vertical: 24.0),
@ -85,15 +87,28 @@ class _FSTimetableState extends State<FSTimetable> {
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Text(
"$index.",
"${index - 1}.",
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.secondary),
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.secondary,
),
),
),
));
} else {
columns.add(SizedBox(width: prefixw.toDouble()));
columns.add(
SizedBox(
width: prefixw.toDouble(),
child: Padding(
padding: const EdgeInsets.only(top: 4.0),
child: GestureDetector(
onTap: () => Navigator.of(context).pop(),
child: const Icon(FeatherIcons.x),
),
),
),
);
}
continue;
}
@ -104,7 +119,8 @@ class _FSTimetableState extends State<FSTimetable> {
if (lessons.isEmpty) continue;
final dayOffset = int.tryParse(lessons.first.lessonIndex) ?? 0;
int lsnIndx = int.tryParse(lessons.first.lessonIndex) ?? 1;
final dayOffset = lsnIndx == 0 ? 1 : lsnIndx;
if (index == 0 && dayIndex >= 0) {
columns.add(
@ -127,12 +143,19 @@ class _FSTimetableState extends State<FSTimetable> {
final lessonIndex = index - dayOffset;
if (lessonIndex < 0 || lessonIndex >= lessons.length) {
Lesson? lsn = lessons.firstWhereOrNull(
(e) => e.lessonIndex == (index - 1).toString());
if (lessonIndex < 0 ||
lessonIndex > lessons.length ||
(index == 1 && lsnIndx != 0) ||
(lsnIndx != 0 && lessonIndex - 1 == -1) ||
lsn == null) {
columns.add(SizedBox(width: colw));
continue;
}
if (lessons[lessonIndex].isEmpty) {
if (lsn.isEmpty) {
columns.add(
SizedBox(
width: colw,
@ -158,54 +181,71 @@ class _FSTimetableState extends State<FSTimetable> {
continue;
}
// print(lessons.map((e) => e.name + '---' + e.lessonIndex));
// print(lessons[lessonIndex].name +
// '---' +
// index.toString() +
// '_' +
// lessonIndex.toString());
// print(lessonIndex);
// if (lsnIndx != 1 && index - 2 >= 0) {
// lsn = lessons[index - 2];
// }
// if (index > 1 && lsnIndx > 0) {
// lsn = lessons[lessonIndex - 1];
// }
columns.add(
SizedBox(
width: colw,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(
SubjectIcon.resolveVariant(
context: context,
subject: lessons[lessonIndex].subject,
),
size: 18.0,
color: AppColors.of(context).text.withOpacity(.7),
),
const SizedBox(width: 8.0),
Expanded(
child: Text(
lessons[lessonIndex].subject.renamedTo ??
lessons[lessonIndex].subject.name.capital(),
maxLines: 1,
style: TextStyle(
fontStyle:
lessons[lessonIndex].subject.isRenamed &&
settings.renamedSubjectsItalics
? FontStyle.italic
: null,
child: Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(
SubjectIcon.resolveVariant(
context: context,
subject: lsn.subject,
),
overflow: TextOverflow.clip,
softWrap: false,
size: 18.0,
color: AppColors.of(context).text.withOpacity(.7),
),
const SizedBox(width: 8.0),
Expanded(
child: Text(
lsn.subject.renamedTo ??
lsn.subject.name.capital(),
maxLines: 1,
style: TextStyle(
fontStyle: lsn.subject.isRenamed &&
settings.renamedSubjectsItalics
? FontStyle.italic
: null,
),
overflow: TextOverflow.clip,
softWrap: false,
),
),
const SizedBox(width: 15),
],
),
Padding(
padding: const EdgeInsets.only(left: 26.0),
child: Text(
lsn.room,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(.5),
overflow: TextOverflow.ellipsis,
),
),
const SizedBox(width: 15),
],
),
Padding(
padding: const EdgeInsets.only(left: 26.0),
child: Text(
lessons[lessonIndex].room,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(.5),
overflow: TextOverflow.ellipsis,
),
),
),
],
],
),
),
),
);