forked from firka/student-legacy
fixed the entire SHIT fullscreen timetable they made
This commit is contained in:
parent
2ff8974cc9
commit
076d6a12a2
@ -1,9 +1,11 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:filcnaplo/helpers/subject.dart';
|
import 'package:filcnaplo/helpers/subject.dart';
|
||||||
import 'package:filcnaplo/models/settings.dart';
|
import 'package:filcnaplo/models/settings.dart';
|
||||||
import 'package:filcnaplo/theme/colors/colors.dart';
|
import 'package:filcnaplo/theme/colors/colors.dart';
|
||||||
import 'package:filcnaplo_kreta_api/controllers/timetable_controller.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:filcnaplo_mobile_ui/common/empty.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@ -60,16 +62,16 @@ class _FSTimetableState extends State<FSTimetable> {
|
|||||||
(a, b) => math.max(
|
(a, b) => math.max(
|
||||||
a, b.where((l) => l.subject.id != "" || l.isEmpty).length));
|
a, b.where((l) => l.subject.id != "" || l.isEmpty).length));
|
||||||
|
|
||||||
const prefixw = 40;
|
const prefixw = 45;
|
||||||
const padding = prefixw + 6 * 2;
|
const padding = prefixw + 6 * 2;
|
||||||
final colw = (MediaQuery.of(context).size.width - padding) / days.length;
|
final colw = (MediaQuery.of(context).size.width - padding) / days.length;
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
// appBar: AppBar(
|
||||||
surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
|
// surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
leading: BackButton(color: AppColors.of(context).text),
|
// leading: BackButton(color: AppColors.of(context).text),
|
||||||
shadowColor: Colors.transparent,
|
// shadowColor: Colors.transparent,
|
||||||
),
|
// ),
|
||||||
body: ListView.builder(
|
body: ListView.builder(
|
||||||
physics: const BouncingScrollPhysics(),
|
physics: const BouncingScrollPhysics(),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 6.0, vertical: 24.0),
|
padding: const EdgeInsets.symmetric(horizontal: 6.0, vertical: 24.0),
|
||||||
@ -85,15 +87,28 @@ class _FSTimetableState extends State<FSTimetable> {
|
|||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
"$index.",
|
"${index - 1}.",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Theme.of(context).colorScheme.secondary),
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
} else {
|
} 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;
|
continue;
|
||||||
}
|
}
|
||||||
@ -104,7 +119,8 @@ class _FSTimetableState extends State<FSTimetable> {
|
|||||||
|
|
||||||
if (lessons.isEmpty) continue;
|
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) {
|
if (index == 0 && dayIndex >= 0) {
|
||||||
columns.add(
|
columns.add(
|
||||||
@ -127,12 +143,19 @@ class _FSTimetableState extends State<FSTimetable> {
|
|||||||
|
|
||||||
final lessonIndex = index - dayOffset;
|
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));
|
columns.add(SizedBox(width: colw));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lessons[lessonIndex].isEmpty) {
|
if (lsn.isEmpty) {
|
||||||
columns.add(
|
columns.add(
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: colw,
|
width: colw,
|
||||||
@ -158,9 +181,26 @@ class _FSTimetableState extends State<FSTimetable> {
|
|||||||
continue;
|
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(
|
columns.add(
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: colw,
|
width: colw,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 4.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@ -170,7 +210,7 @@ class _FSTimetableState extends State<FSTimetable> {
|
|||||||
Icon(
|
Icon(
|
||||||
SubjectIcon.resolveVariant(
|
SubjectIcon.resolveVariant(
|
||||||
context: context,
|
context: context,
|
||||||
subject: lessons[lessonIndex].subject,
|
subject: lsn.subject,
|
||||||
),
|
),
|
||||||
size: 18.0,
|
size: 18.0,
|
||||||
color: AppColors.of(context).text.withOpacity(.7),
|
color: AppColors.of(context).text.withOpacity(.7),
|
||||||
@ -178,12 +218,11 @@ class _FSTimetableState extends State<FSTimetable> {
|
|||||||
const SizedBox(width: 8.0),
|
const SizedBox(width: 8.0),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
lessons[lessonIndex].subject.renamedTo ??
|
lsn.subject.renamedTo ??
|
||||||
lessons[lessonIndex].subject.name.capital(),
|
lsn.subject.name.capital(),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontStyle:
|
fontStyle: lsn.subject.isRenamed &&
|
||||||
lessons[lessonIndex].subject.isRenamed &&
|
|
||||||
settings.renamedSubjectsItalics
|
settings.renamedSubjectsItalics
|
||||||
? FontStyle.italic
|
? FontStyle.italic
|
||||||
: null,
|
: null,
|
||||||
@ -198,7 +237,7 @@ class _FSTimetableState extends State<FSTimetable> {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 26.0),
|
padding: const EdgeInsets.only(left: 26.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
lessons[lessonIndex].room,
|
lsn.room,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: AppColors.of(context).text.withOpacity(.5),
|
color: AppColors.of(context).text.withOpacity(.5),
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
@ -208,6 +247,7 @@ class _FSTimetableState extends State<FSTimetable> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user