forked from firka/firka
tt: add filters
This commit is contained in:
@@ -14,6 +14,12 @@ class Constants {
|
|||||||
"/${initData.devInfo.versionSdkInt}";
|
"/${initData.devInfo.versionSdkInt}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class OmissionConsts {
|
||||||
|
static const present = "Jelenlet";
|
||||||
|
static const absence = "Hianyzas";
|
||||||
|
static const na = "Na";
|
||||||
|
}
|
||||||
|
|
||||||
class KretaEndpoints {
|
class KretaEndpoints {
|
||||||
static String kretaBase = "e-kreta.hu";
|
static String kretaBase = "e-kreta.hu";
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
|
import 'package:firka/helpers/api/consts.dart';
|
||||||
|
import 'package:firka/helpers/api/consts.dart';
|
||||||
|
import 'package:firka/helpers/api/consts.dart';
|
||||||
import 'package:firka/helpers/api/model/timetable.dart';
|
import 'package:firka/helpers/api/model/timetable.dart';
|
||||||
import 'package:firka/helpers/debug_helper.dart';
|
import 'package:firka/helpers/debug_helper.dart';
|
||||||
import 'package:firka/helpers/extensions.dart';
|
import 'package:firka/helpers/extensions.dart';
|
||||||
import 'package:firka/ui/model/style.dart';
|
import 'package:firka/ui/model/style.dart';
|
||||||
import 'package:firka/ui/widget/delayed_spinner.dart';
|
import 'package:firka/ui/widget/delayed_spinner.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||||
import 'package:transparent_pointer/transparent_pointer.dart';
|
import 'package:transparent_pointer/transparent_pointer.dart';
|
||||||
@@ -23,12 +27,15 @@ class HomeTimetableMonthlyScreen extends StatefulWidget {
|
|||||||
_HomeTimetableMonthlyScreen();
|
_HomeTimetableMonthlyScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ActiveFilter { lessonNo, homework, omissions }
|
||||||
|
|
||||||
class _HomeTimetableMonthlyScreen extends State<HomeTimetableMonthlyScreen> {
|
class _HomeTimetableMonthlyScreen extends State<HomeTimetableMonthlyScreen> {
|
||||||
List<Lesson>? lessons;
|
List<Lesson>? lessons;
|
||||||
List<DateTime>? dates;
|
List<DateTime>? dates;
|
||||||
DateTime? now;
|
DateTime? now;
|
||||||
int active = 0;
|
int active = 0;
|
||||||
bool disposed = false;
|
bool disposed = false;
|
||||||
|
ActiveFilter activeFilter = ActiveFilter.lessonNo;
|
||||||
|
|
||||||
_HomeTimetableMonthlyScreen();
|
_HomeTimetableMonthlyScreen();
|
||||||
|
|
||||||
@@ -117,16 +124,72 @@ class _HomeTimetableMonthlyScreen extends State<HomeTimetableMonthlyScreen> {
|
|||||||
lesson.end.isBefore(
|
lesson.end.isBefore(
|
||||||
d.getMidnight().add(Duration(hours: 23, minutes: 59))));
|
d.getMidnight().add(Duration(hours: 23, minutes: 59))));
|
||||||
|
|
||||||
if (lessonsToday.isNotEmpty) {
|
var omissionType = lessonsToday.firstWhereOrNull((lesson) =>
|
||||||
body = Center(
|
lesson.studentPresence != null &&
|
||||||
child: Text(lessonsToday.length.toString(),
|
lesson.studentPresence?.name != OmissionConsts.present);
|
||||||
style: appStyle.fonts.H_16px.apply(
|
|
||||||
color:
|
switch (activeFilter) {
|
||||||
timeNow().day == d.day && timeNow().month == d.month
|
case ActiveFilter.lessonNo:
|
||||||
? appStyle.colors.accent
|
if (lessonsToday.isNotEmpty) {
|
||||||
: appStyle.colors.secondary)),
|
body = Center(
|
||||||
);
|
child: Text(lessonsToday.length.toString(),
|
||||||
|
style: appStyle.fonts.H_16px.apply(
|
||||||
|
color: omissionType != null &&
|
||||||
|
(omissionType.studentPresence!.name ==
|
||||||
|
OmissionConsts.absence ||
|
||||||
|
omissionType.studentPresence!.name ==
|
||||||
|
OmissionConsts.na)
|
||||||
|
? appStyle.colors.errorText
|
||||||
|
: timeNow().day == d.day &&
|
||||||
|
timeNow().month == d.month
|
||||||
|
? appStyle.colors.accent
|
||||||
|
: appStyle.colors.secondary)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ActiveFilter.homework:
|
||||||
|
if (lessonsToday.firstWhereOrNull(
|
||||||
|
(lesson) => lesson.homeworkUid != null) !=
|
||||||
|
null) {
|
||||||
|
body = Center(
|
||||||
|
child: FirkaIconWidget(
|
||||||
|
FirkaIconType.majesticons,
|
||||||
|
Majesticon.editPen4Solid,
|
||||||
|
size: 20.0,
|
||||||
|
color: appStyle.colors.accent,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ActiveFilter.omissions:
|
||||||
|
if (omissionType != null) {
|
||||||
|
switch (omissionType.studentPresence!.name) {
|
||||||
|
case OmissionConsts.na:
|
||||||
|
case OmissionConsts.absence:
|
||||||
|
body = Center(
|
||||||
|
child: FirkaIconWidget(
|
||||||
|
FirkaIconType.majesticons,
|
||||||
|
Majesticon.multiplySolid,
|
||||||
|
size: 20.0,
|
||||||
|
color: appStyle.colors.accent,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
debugPrint(omissionType.studentPresence!.name);
|
||||||
|
body = Center(
|
||||||
|
child: FirkaIconWidget(
|
||||||
|
FirkaIconType.majesticons,
|
||||||
|
Majesticon.timerLine,
|
||||||
|
size: 20.0,
|
||||||
|
color: appStyle.colors.accent,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ttDays.add(Column(
|
ttDays.add(Column(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
@@ -134,9 +197,16 @@ class _HomeTimetableMonthlyScreen extends State<HomeTimetableMonthlyScreen> {
|
|||||||
height: 40,
|
height: 40,
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
decoration: ShapeDecoration(
|
decoration: ShapeDecoration(
|
||||||
color: timeNow().day == d.day && timeNow().month == d.month
|
color: activeFilter == ActiveFilter.lessonNo &&
|
||||||
? appStyle.colors.buttonSecondaryFill
|
omissionType != null &&
|
||||||
: appStyle.colors.card,
|
(omissionType.studentPresence!.name ==
|
||||||
|
OmissionConsts.absence ||
|
||||||
|
omissionType.studentPresence!.name ==
|
||||||
|
OmissionConsts.na)
|
||||||
|
? appStyle.colors.error15p
|
||||||
|
: timeNow().day == d.day && timeNow().month == d.month
|
||||||
|
? appStyle.colors.buttonSecondaryFill
|
||||||
|
: appStyle.colors.card,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(6)),
|
borderRadius: BorderRadius.circular(6)),
|
||||||
),
|
),
|
||||||
@@ -308,37 +378,52 @@ class _HomeTimetableMonthlyScreen extends State<HomeTimetableMonthlyScreen> {
|
|||||||
SizedBox(),
|
SizedBox(),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
_StatusToast(
|
||||||
clipBehavior: Clip.antiAlias,
|
FirkaIconWidget(FirkaIconType.majesticons,
|
||||||
decoration: ShapeDecoration(
|
Majesticon.clockSolid,
|
||||||
color: appStyle.colors.buttonSecondaryFill,
|
color: appStyle.colors.accent, size: 16),
|
||||||
shape: RoundedRectangleBorder(
|
lessons!
|
||||||
borderRadius: BorderRadius.circular(16)),
|
.where((lesson) =>
|
||||||
),
|
lesson.start.isAfter(currentMonthStart) &&
|
||||||
child: Padding(
|
lesson.end.isBefore(currentMonthEnd))
|
||||||
padding: const EdgeInsets.symmetric(
|
.length,
|
||||||
horizontal: 10, vertical: 4),
|
activeFilter == ActiveFilter.lessonNo, () {
|
||||||
child: Row(
|
setState(() {
|
||||||
children: [
|
activeFilter = ActiveFilter.lessonNo;
|
||||||
FirkaIconWidget(FirkaIconType.majesticons,
|
});
|
||||||
Majesticon.clockSolid,
|
}),
|
||||||
color: appStyle.colors.accent, size: 16),
|
_StatusToast(
|
||||||
SizedBox(width: 6),
|
FirkaIconWidget(FirkaIconType.majesticons,
|
||||||
Text(
|
Majesticon.editPen4Solid,
|
||||||
lessons!
|
color: appStyle.colors.accent, size: 16),
|
||||||
.where((lesson) =>
|
lessons!
|
||||||
lesson.start
|
.where((lesson) =>
|
||||||
.isAfter(currentMonthStart) &&
|
lesson.start.isAfter(currentMonthStart) &&
|
||||||
lesson.end
|
lesson.end.isBefore(currentMonthEnd) &&
|
||||||
.isBefore(currentMonthEnd))
|
lesson.homeworkUid != null)
|
||||||
.length
|
.length,
|
||||||
.toString(),
|
activeFilter == ActiveFilter.homework, () {
|
||||||
style: appStyle.fonts.H_16px.apply(
|
setState(() {
|
||||||
color: appStyle.colors.textPrimary))
|
activeFilter = ActiveFilter.homework;
|
||||||
],
|
});
|
||||||
),
|
}),
|
||||||
),
|
_StatusToast(
|
||||||
),
|
FirkaIconWidget(
|
||||||
|
FirkaIconType.majesticons, Majesticon.timerLine,
|
||||||
|
color: appStyle.colors.accent, size: 16),
|
||||||
|
lessons!
|
||||||
|
.where((lesson) =>
|
||||||
|
lesson.start.isAfter(currentMonthStart) &&
|
||||||
|
lesson.end.isBefore(currentMonthEnd) &&
|
||||||
|
lesson.studentPresence != null &&
|
||||||
|
lesson.studentPresence?.name !=
|
||||||
|
OmissionConsts.present)
|
||||||
|
.length,
|
||||||
|
activeFilter == ActiveFilter.omissions, () {
|
||||||
|
setState(() {
|
||||||
|
activeFilter = ActiveFilter.omissions;
|
||||||
|
});
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox()
|
SizedBox()
|
||||||
@@ -364,3 +449,41 @@ class _HomeTimetableMonthlyScreen extends State<HomeTimetableMonthlyScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _StatusToast extends StatelessWidget {
|
||||||
|
final FirkaIconWidget _icon;
|
||||||
|
final int _count;
|
||||||
|
final bool _active;
|
||||||
|
final void Function() _onTap;
|
||||||
|
|
||||||
|
const _StatusToast(this._icon, this._count, this._active, this._onTap);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: _onTap,
|
||||||
|
child: Container(
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
decoration: ShapeDecoration(
|
||||||
|
color: _active
|
||||||
|
? appStyle.colors.buttonSecondaryFill
|
||||||
|
: appStyle.colors.cardTranslucent,
|
||||||
|
shape:
|
||||||
|
RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
_icon,
|
||||||
|
SizedBox(width: 6),
|
||||||
|
Text(_count.toString(),
|
||||||
|
style: appStyle.fonts.H_16px
|
||||||
|
.apply(color: appStyle.colors.textPrimary))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user