forked from firka/firka
feat: omissions
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
|
|
||||||
|
import 'package:firka/ui/phone/pages/home/home_omissions.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:firka/core/firka_bundle.dart';
|
import 'package:firka/core/firka_bundle.dart';
|
||||||
import 'package:firka/app/app_state.dart';
|
import 'package:firka/app/app_state.dart';
|
||||||
@@ -177,6 +178,20 @@ GoRouter createAppRouter() {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
StatefulShellBranch(
|
||||||
|
routes: [
|
||||||
|
GoRoute(
|
||||||
|
path: '/omissions',
|
||||||
|
pageBuilder: (context, state) => NoTransitionPage(
|
||||||
|
key: state.pageKey,
|
||||||
|
child: DefaultAssetBundle(
|
||||||
|
bundle: FirkaBundle(),
|
||||||
|
child: HomeOmissionsScreen(initData),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -57,6 +57,11 @@ class ShellWithNavBar extends StatelessWidget {
|
|||||||
Majesticon.calendarSolid,
|
Majesticon.calendarSolid,
|
||||||
Majesticon.calendarLine,
|
Majesticon.calendarLine,
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
initData.l10n.omissions,
|
||||||
|
Majesticon.timerSolid,
|
||||||
|
Majesticon.timerLine,
|
||||||
|
),
|
||||||
].indexed.map(
|
].indexed.map(
|
||||||
(nav) => BottomNavIconWidget(
|
(nav) => BottomNavIconWidget(
|
||||||
() {
|
() {
|
||||||
|
|||||||
@@ -245,6 +245,119 @@ Future<void> showLessonBottomSheet(
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> showOmissionBottomSheet(
|
||||||
|
BuildContext context,
|
||||||
|
AppInitialization data,
|
||||||
|
String description,
|
||||||
|
List<Omission> omissions,
|
||||||
|
) async {
|
||||||
|
showFirkaBottomSheet(context, [
|
||||||
|
Text(
|
||||||
|
omissions.first.date.format(data.l10n, FormatMode.yyyymmdd),
|
||||||
|
style: appStyle.fonts.H_18px.apply(color: appStyle.colors.textPrimary),
|
||||||
|
),
|
||||||
|
SizedBox(height: 2),
|
||||||
|
Text(
|
||||||
|
description,
|
||||||
|
style: appStyle.fonts.B_16R.apply(color: appStyle.colors.textSecondary),
|
||||||
|
),
|
||||||
|
SizedBox(height: 2),
|
||||||
|
LimitedBox(
|
||||||
|
maxHeight: 336,
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: omissions.length,
|
||||||
|
itemBuilder: (b, i) {
|
||||||
|
final o = omissions[i];
|
||||||
|
return FirkaCard.single(
|
||||||
|
height: 64,
|
||||||
|
margin: EdgeInsets.only(bottom: 10),
|
||||||
|
padding: EdgeInsets.only(left: 14, right: 16),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: 18,
|
||||||
|
height: 18,
|
||||||
|
child: Stack(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
children: [
|
||||||
|
SvgPicture.asset(
|
||||||
|
"assets/icons/subtract.svg",
|
||||||
|
color: appStyle.colors.a15p,
|
||||||
|
width: 18,
|
||||||
|
height: 18,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
o.lesson!.classNo?.toString() ?? "-",
|
||||||
|
style: appStyle.fonts.B_14SB.apply(
|
||||||
|
color: appStyle.colors.secondary,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
FilledCircle(
|
||||||
|
diameter: 36,
|
||||||
|
color: appStyle.colors.a15p,
|
||||||
|
child: ClassIconWidget(
|
||||||
|
uid: o.subject.uid,
|
||||||
|
className: o.subject.name,
|
||||||
|
category: o.subject.name,
|
||||||
|
color: appStyle.colors.accent,
|
||||||
|
size: 24,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
o.subject.name,
|
||||||
|
style: appStyle.fonts.B_16SB.apply(
|
||||||
|
color: appStyle.colors.textPrimary,
|
||||||
|
),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
o.teacher,
|
||||||
|
style: appStyle.fonts.B_14R.apply(
|
||||||
|
color: appStyle.colors.textSecondary,
|
||||||
|
),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 8),
|
||||||
|
Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
o.lesson!.start.format(data.l10n, FormatMode.hmm),
|
||||||
|
style: appStyle.fonts.B_14R.apply(
|
||||||
|
color: appStyle.colors.textPrimary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
o.lesson!.end.format(data.l10n, FormatMode.hmm),
|
||||||
|
style: appStyle.fonts.B_14R.apply(
|
||||||
|
color: appStyle.colors.textPrimary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> showTestBottomSheet(
|
Future<void> showTestBottomSheet(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
AppInitialization data,
|
AppInitialization data,
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
|||||||
List<Test>? tests;
|
List<Test>? tests;
|
||||||
List<Grade>? grades;
|
List<Grade>? grades;
|
||||||
List<Homework>? homework;
|
List<Homework>? homework;
|
||||||
|
List<Omission>? omissions;
|
||||||
Student? student;
|
Student? student;
|
||||||
Timer? timer;
|
Timer? timer;
|
||||||
|
|
||||||
@@ -66,6 +67,7 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
|||||||
var testsFetched = 0;
|
var testsFetched = 0;
|
||||||
var gradesFetched = 0;
|
var gradesFetched = 0;
|
||||||
var homeworkFetched = 0;
|
var homeworkFetched = 0;
|
||||||
|
var omissionFetched = 0;
|
||||||
|
|
||||||
widget.data.client
|
widget.data.client
|
||||||
.getTimeTableStream(
|
.getTimeTableStream(
|
||||||
@@ -139,6 +141,18 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
widget.data.client.getOmissionsStream(cacheOnly: cacheOnly).forEach((
|
||||||
|
omission,
|
||||||
|
) {
|
||||||
|
omissionFetched++;
|
||||||
|
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {
|
||||||
|
this.omissions = omission.response;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
widget.data.client.getHomeworkStream(cacheOnly: cacheOnly).forEach((
|
widget.data.client.getHomeworkStream(cacheOnly: cacheOnly).forEach((
|
||||||
homework,
|
homework,
|
||||||
) {
|
) {
|
||||||
@@ -161,7 +175,8 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
|||||||
studentFetched < r ||
|
studentFetched < r ||
|
||||||
testsFetched < r ||
|
testsFetched < r ||
|
||||||
gradesFetched < r ||
|
gradesFetched < r ||
|
||||||
homeworkFetched < r) {
|
homeworkFetched < r ||
|
||||||
|
omissionFetched < r) {
|
||||||
if (DateTime.now().difference(startTime) > maxWaitTime) {
|
if (DateTime.now().difference(startTime) > maxWaitTime) {
|
||||||
debugPrint('[HomeMain] Data fetch timed out after 30s');
|
debugPrint('[HomeMain] Data fetch timed out after 30s');
|
||||||
break;
|
break;
|
||||||
@@ -198,6 +213,7 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
|||||||
final gradeItems = grades ?? [];
|
final gradeItems = grades ?? [];
|
||||||
final testItems = tests ?? [];
|
final testItems = tests ?? [];
|
||||||
final homeworkItems = homework ?? [];
|
final homeworkItems = homework ?? [];
|
||||||
|
final omissionItems = omissions?.groupList((o) => o.date).values ?? [];
|
||||||
final noticeBoardWidgets = <(Widget, DateTime)>[];
|
final noticeBoardWidgets = <(Widget, DateTime)>[];
|
||||||
|
|
||||||
for (final item in infoItems) {
|
for (final item in infoItems) {
|
||||||
@@ -216,6 +232,13 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
|||||||
noticeBoardWidgets.add((InfoCard.homework(entry), entry.creationDate));
|
noticeBoardWidgets.add((InfoCard.homework(entry), entry.creationDate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (final omission in omissionItems) {
|
||||||
|
noticeBoardWidgets.add((
|
||||||
|
InfoCard.omission(omission),
|
||||||
|
omission.first.date,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
noticeBoardWidgets.sort(
|
noticeBoardWidgets.sort(
|
||||||
(item1, item2) => item2.$2.difference(item1.$2).inMilliseconds,
|
(item1, item2) => item2.$2.difference(item1.$2).inMilliseconds,
|
||||||
);
|
);
|
||||||
|
|||||||
324
firka/lib/ui/phone/pages/home/home_omissions.dart
Normal file
324
firka/lib/ui/phone/pages/home/home_omissions.dart
Normal file
@@ -0,0 +1,324 @@
|
|||||||
|
import 'dart:collection';
|
||||||
|
|
||||||
|
import 'package:firka/core/extensions.dart';
|
||||||
|
import 'package:firka/ui/phone/widgets/info_card.dart';
|
||||||
|
import 'package:firka/ui/phone/widgets/omission_bar.dart';
|
||||||
|
import 'package:firka_common/firka_common.dart';
|
||||||
|
import 'package:kreta_api/kreta_api.dart';
|
||||||
|
import 'package:firka/ui/components/firka_card.dart';
|
||||||
|
import 'package:firka/ui/components/grade_helpers.dart';
|
||||||
|
import 'package:firka/ui/phone/widgets/grade_chart.dart';
|
||||||
|
import 'package:firka/ui/phone/widgets/grade_summary_bar.dart';
|
||||||
|
import 'package:firka/ui/shared/grade_small_card.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
|
import 'package:firka/api/consts.dart';
|
||||||
|
import 'package:firka/core/debug_helper.dart';
|
||||||
|
import 'package:firka/core/state/firka_state.dart';
|
||||||
|
import 'package:firka/app/app_state.dart';
|
||||||
|
import 'package:firka/core/bloc/home_refresh_cubit.dart';
|
||||||
|
import 'package:firka/core/settings.dart';
|
||||||
|
import 'package:firka/ui/theme/style.dart';
|
||||||
|
import 'package:firka/ui/shared/delayed_spinner.dart';
|
||||||
|
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||||
|
|
||||||
|
class HomeOmissionsScreen extends StatefulWidget {
|
||||||
|
final AppInitialization data;
|
||||||
|
|
||||||
|
const HomeOmissionsScreen(this.data, {super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StatefulWidget> createState() => _HomeOmissionsScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _HomeOmissionsScreen extends FirkaState<HomeOmissionsScreen> {
|
||||||
|
ApiResponse<List<Omission>>? omissions;
|
||||||
|
|
||||||
|
void _onRefreshRequested(BuildContext context) async {
|
||||||
|
final cubit = context.read<HomeRefreshCubit>();
|
||||||
|
omissions = await widget.data.client.getOmissions(forceCache: false);
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {});
|
||||||
|
cubit.onRefreshComplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
(() async {
|
||||||
|
omissions = await widget.data.client.getOmissions(forceCache: false);
|
||||||
|
if (mounted) setState(() {});
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BlocListener<HomeRefreshCubit, HomeRefreshState>(
|
||||||
|
listenWhen: (previous, current) =>
|
||||||
|
current.refreshTrigger != previous.refreshTrigger,
|
||||||
|
listener: (context, state) {
|
||||||
|
_onRefreshRequested(context);
|
||||||
|
},
|
||||||
|
child: _buildContent(context),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildContent(BuildContext context) {
|
||||||
|
if (omissions == null) {
|
||||||
|
return Center(child: DelayedSpinnerWidget());
|
||||||
|
}
|
||||||
|
|
||||||
|
final omissionItems = omissions!.response ?? [];
|
||||||
|
|
||||||
|
final overallExcused = omissionItems
|
||||||
|
.where((o) => o.state == OmissionState.excused)
|
||||||
|
.length;
|
||||||
|
|
||||||
|
final overallUnexcused = omissionItems
|
||||||
|
.where((o) => o.state == OmissionState.unexcused)
|
||||||
|
.length;
|
||||||
|
|
||||||
|
final overallPending = omissionItems
|
||||||
|
.where((o) => o.state == OmissionState.pending)
|
||||||
|
.length;
|
||||||
|
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 20.0, right: 20.0, top: 12.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
widget.data.l10n.subjects,
|
||||||
|
style: appStyle.fonts.H_H2.apply(
|
||||||
|
color: appStyle.colors.textPrimary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 20),
|
||||||
|
Row(
|
||||||
|
spacing: 10,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: FirkaCard.single(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 16),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
spacing: 4,
|
||||||
|
children: [
|
||||||
|
FirkaIconWidget(
|
||||||
|
FirkaIconType.majesticons,
|
||||||
|
Majesticon.clipboardCheckSolid,
|
||||||
|
size: 12.0,
|
||||||
|
color: appStyle.colors.accent,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
overallExcused.toString(),
|
||||||
|
style: appStyle.fonts.H_18px.copyWith(
|
||||||
|
color: appStyle.colors.textPrimary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
initData.l10n.omission_state_excused,
|
||||||
|
style: appStyle.fonts.B_16R.copyWith(
|
||||||
|
color: appStyle.colors.textSecondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: FirkaCard.single(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 16),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
spacing: 4,
|
||||||
|
children: [
|
||||||
|
FirkaIconWidget(
|
||||||
|
FirkaIconType.majesticons,
|
||||||
|
Majesticon.timerSolid,
|
||||||
|
size: 12.0,
|
||||||
|
color: appStyle.colors.warningAccent,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
overallPending.toString(),
|
||||||
|
style: appStyle.fonts.H_18px.copyWith(
|
||||||
|
color: appStyle.colors.warningAccent,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
initData.l10n.omission_state_pending,
|
||||||
|
style: appStyle.fonts.B_16R.copyWith(
|
||||||
|
color: appStyle.colors.textSecondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: FirkaCard.single(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 16),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
spacing: 4,
|
||||||
|
children: [
|
||||||
|
FirkaIconWidget(
|
||||||
|
FirkaIconType.majesticons,
|
||||||
|
Majesticon.restrictedSolid,
|
||||||
|
size: 12.0,
|
||||||
|
color: appStyle.colors.errorAccent,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
overallUnexcused.toString(),
|
||||||
|
style: appStyle.fonts.H_18px.copyWith(
|
||||||
|
color: appStyle.colors.errorAccent,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
initData.l10n.omission_state_unexcused,
|
||||||
|
style: appStyle.fonts.B_16R.copyWith(
|
||||||
|
color: appStyle.colors.textSecondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(height: 10),
|
||||||
|
OmissionBar(omissions: omissions!.response!),
|
||||||
|
SizedBox(height: 20),
|
||||||
|
Expanded(
|
||||||
|
child: ListView(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
initData.l10n.subjects,
|
||||||
|
style: appStyle.fonts.B_16SB.copyWith(
|
||||||
|
color: appStyle.colors.textPrimary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 10),
|
||||||
|
...omissionItems
|
||||||
|
.fold(
|
||||||
|
LinkedHashMap<Subject, List<Omission>>(
|
||||||
|
equals: (a, b) => a.uid == b.uid,
|
||||||
|
hashCode: (a) => a.uid.hashCode,
|
||||||
|
),
|
||||||
|
(map, o) =>
|
||||||
|
map
|
||||||
|
..putIfAbsent(o.subject, () => <Omission>[]).add(o),
|
||||||
|
)
|
||||||
|
.entries
|
||||||
|
.map((entry) {
|
||||||
|
final excused = entry.value
|
||||||
|
.where((o) => o.state == OmissionState.excused)
|
||||||
|
.length;
|
||||||
|
|
||||||
|
final unexcused = entry.value
|
||||||
|
.where((o) => o.state == OmissionState.unexcused)
|
||||||
|
.length;
|
||||||
|
|
||||||
|
final pending = entry.value
|
||||||
|
.where((o) => o.state == OmissionState.pending)
|
||||||
|
.length;
|
||||||
|
|
||||||
|
return FirkaCard.single(
|
||||||
|
height: 64,
|
||||||
|
margin: EdgeInsets.only(bottom: 10),
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
child: Row(
|
||||||
|
spacing: 12,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
InfoCard.buildSubject(
|
||||||
|
appStyle.colors.accent,
|
||||||
|
entry.key,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
spacing: 2,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
entry.key.name,
|
||||||
|
style: appStyle.fonts.B_16SB.copyWith(
|
||||||
|
color: appStyle.colors.textPrimary,
|
||||||
|
),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
spacing: 4,
|
||||||
|
children: [
|
||||||
|
FirkaIconWidget(
|
||||||
|
FirkaIconType.majesticons,
|
||||||
|
Majesticon.clipboardCheckSolid,
|
||||||
|
size: 12.0,
|
||||||
|
color: appStyle.colors.accent,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
excused.toString(),
|
||||||
|
style: appStyle.fonts.B_14R.copyWith(
|
||||||
|
color: appStyle.colors.textSecondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 4),
|
||||||
|
FirkaIconWidget(
|
||||||
|
FirkaIconType.majesticons,
|
||||||
|
Majesticon.timerSolid,
|
||||||
|
size: 12.0,
|
||||||
|
color: appStyle.colors.warningAccent,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
pending.toString(),
|
||||||
|
style: appStyle.fonts.B_14R.copyWith(
|
||||||
|
color: appStyle.colors.textSecondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 4),
|
||||||
|
FirkaIconWidget(
|
||||||
|
FirkaIconType.majesticons,
|
||||||
|
Majesticon.restrictedLine,
|
||||||
|
size: 12.0,
|
||||||
|
color: appStyle.colors.errorAccent,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
unexcused.toString(),
|
||||||
|
style: appStyle.fonts.B_14R.copyWith(
|
||||||
|
color: appStyle.colors.textSecondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -230,7 +230,7 @@ class _HomeTimetableMonthlyScreen
|
|||||||
omission.subject.uid == omittedLesson.subject?.uid;
|
omission.subject.uid == omittedLesson.subject?.uid;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (omission?.state == "Igazolt") {
|
if (omission?.state == OmissionState.excused) {
|
||||||
body = Center(
|
body = Center(
|
||||||
child: FirkaIconWidget(
|
child: FirkaIconWidget(
|
||||||
FirkaIconType.majesticons,
|
FirkaIconType.majesticons,
|
||||||
@@ -242,7 +242,7 @@ class _HomeTimetableMonthlyScreen
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (omission?.lateForMin != null) {
|
if (omission?.state == OmissionState.pending) {
|
||||||
body = Center(
|
body = Center(
|
||||||
child: FirkaIconWidget(
|
child: FirkaIconWidget(
|
||||||
FirkaIconType.majesticons,
|
FirkaIconType.majesticons,
|
||||||
|
|||||||
@@ -1,242 +1,268 @@
|
|||||||
import 'package:firka/app/app_state.dart';
|
import 'package:firka/app/app_state.dart';
|
||||||
import 'package:firka/core/extensions.dart';
|
import 'package:firka/core/extensions.dart';
|
||||||
import 'package:firka/data/models/homework_cache_model.dart';
|
import 'package:firka/data/models/homework_cache_model.dart';
|
||||||
import 'package:firka/ui/components/common_bottom_sheets.dart';
|
import 'package:firka/ui/components/common_bottom_sheets.dart';
|
||||||
import 'package:firka/ui/components/firka_card.dart';
|
import 'package:firka/ui/components/firka_card.dart';
|
||||||
import 'package:firka/ui/components/grade.dart';
|
import 'package:firka/ui/components/grade.dart';
|
||||||
import 'package:firka/ui/components/grade_helpers.dart';
|
import 'package:firka/ui/components/grade_helpers.dart';
|
||||||
import 'package:firka/ui/shared/class_icon.dart';
|
import 'package:firka/ui/shared/class_icon.dart';
|
||||||
import 'package:firka/ui/shared/firka_icon.dart';
|
import 'package:firka/ui/shared/firka_icon.dart';
|
||||||
import 'package:firka/ui/theme/style.dart';
|
import 'package:firka/ui/theme/style.dart';
|
||||||
import 'package:firka_common/ui/components/filled_circle.dart';
|
import 'package:firka_common/ui/components/filled_circle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
|
||||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
import 'package:kreta_api/kreta_api.dart';
|
||||||
|
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||||
class InfoCard extends StatelessWidget {
|
|
||||||
final void Function(BuildContext)? onTap;
|
class InfoCard extends StatelessWidget {
|
||||||
final Widget icon;
|
final void Function(BuildContext)? onTap;
|
||||||
final List<String> texts;
|
final Widget icon;
|
||||||
final List<Widget> right;
|
final List<String> texts;
|
||||||
|
final List<Widget> right;
|
||||||
final List<TextStyle> textSyles = [
|
|
||||||
appStyle.fonts.B_16SB.apply(color: appStyle.colors.textPrimary),
|
final List<TextStyle> textSyles = [
|
||||||
appStyle.fonts.B_14R.apply(color: appStyle.colors.textSecondary),
|
appStyle.fonts.B_16SB.apply(color: appStyle.colors.textPrimary),
|
||||||
];
|
appStyle.fonts.B_14R.apply(color: appStyle.colors.textSecondary),
|
||||||
|
];
|
||||||
InfoCard({
|
|
||||||
required this.icon,
|
InfoCard({
|
||||||
required this.texts,
|
required this.icon,
|
||||||
this.right = const [],
|
required this.texts,
|
||||||
this.onTap,
|
this.right = const [],
|
||||||
super.key,
|
this.onTap,
|
||||||
});
|
super.key,
|
||||||
|
});
|
||||||
static Widget buildSubject(Color color, Subject subject) {
|
|
||||||
return FilledCircle(
|
static Widget buildSubject(Color color, Subject subject) {
|
||||||
diameter: 32,
|
return FilledCircle(
|
||||||
color: color.withAlpha(38),
|
diameter: 32,
|
||||||
child: ClassIconWidget.subject(subject: subject, color: color, size: 20),
|
color: color.withAlpha(38),
|
||||||
);
|
child: ClassIconWidget.subject(subject: subject, color: color, size: 20),
|
||||||
}
|
);
|
||||||
|
}
|
||||||
factory InfoCard.test(Test test) {
|
|
||||||
final color = appStyle.colors.accent;
|
factory InfoCard.test(Test test) {
|
||||||
|
final color = appStyle.colors.accent;
|
||||||
return InfoCard(
|
|
||||||
icon: FilledCircle(
|
return InfoCard(
|
||||||
diameter: 36,
|
icon: FilledCircle(
|
||||||
color: color.withAlpha(38),
|
diameter: 36,
|
||||||
child: FirkaIconWidget(
|
color: color.withAlpha(38),
|
||||||
FirkaIconType.majesticons,
|
child: FirkaIconWidget(
|
||||||
Majesticon.editPen4Solid,
|
FirkaIconType.majesticons,
|
||||||
color: color,
|
Majesticon.editPen4Solid,
|
||||||
size: 24,
|
color: color,
|
||||||
),
|
size: 24,
|
||||||
),
|
),
|
||||||
texts: [
|
),
|
||||||
test.theme?.firstUpper() ?? test.method.description,
|
texts: [
|
||||||
test.subject.name.firstUpper(),
|
test.theme?.firstUpper() ?? test.method.description,
|
||||||
],
|
test.subject.name.firstUpper(),
|
||||||
right: [buildSubject(color, test.subject)],
|
],
|
||||||
onTap: (context) => showTestBottomSheet(context, initData, test),
|
right: [buildSubject(color, test.subject)],
|
||||||
);
|
onTap: (context) => showTestBottomSheet(context, initData, test),
|
||||||
}
|
);
|
||||||
|
}
|
||||||
factory InfoCard.testDesc(Test test) {
|
|
||||||
if (test.theme == null) {
|
factory InfoCard.testDesc(Test test) {
|
||||||
return InfoCard.test(test);
|
if (test.theme == null) {
|
||||||
}
|
return InfoCard.test(test);
|
||||||
|
}
|
||||||
final color = appStyle.colors.accent;
|
|
||||||
|
final color = appStyle.colors.accent;
|
||||||
return InfoCard(
|
|
||||||
icon: FilledCircle(
|
return InfoCard(
|
||||||
diameter: 36,
|
icon: FilledCircle(
|
||||||
color: color.withAlpha(38),
|
diameter: 36,
|
||||||
child: FirkaIconWidget(
|
color: color.withAlpha(38),
|
||||||
FirkaIconType.majesticons,
|
child: FirkaIconWidget(
|
||||||
Majesticon.editPen4Solid,
|
FirkaIconType.majesticons,
|
||||||
color: color,
|
Majesticon.editPen4Solid,
|
||||||
size: 24,
|
color: color,
|
||||||
),
|
size: 24,
|
||||||
),
|
),
|
||||||
texts: [test.theme!.firstUpper(), test.method.description.firstUpper()],
|
),
|
||||||
right: [buildSubject(color, test.subject)],
|
texts: [test.theme!.firstUpper(), test.method.description.firstUpper()],
|
||||||
onTap: (context) => showTestBottomSheet(context, initData, test),
|
right: [buildSubject(color, test.subject)],
|
||||||
);
|
onTap: (context) => showTestBottomSheet(context, initData, test),
|
||||||
}
|
);
|
||||||
|
}
|
||||||
factory InfoCard.messageItem(MessageItem item) {
|
|
||||||
return InfoCard(
|
factory InfoCard.messageItem(MessageItem item) {
|
||||||
icon: FilledCircle(
|
return InfoCard(
|
||||||
diameter: 36,
|
icon: FilledCircle(
|
||||||
color: appStyle.colors.accent,
|
diameter: 36,
|
||||||
child: Text(
|
color: appStyle.colors.accent,
|
||||||
item.author[0],
|
child: Text(
|
||||||
style: appStyle.fonts.H_H2.apply(color: appStyle.colors.textPrimary),
|
item.author[0],
|
||||||
),
|
style: appStyle.fonts.H_H2.apply(color: appStyle.colors.textPrimary),
|
||||||
),
|
),
|
||||||
texts: [item.title, item.author],
|
),
|
||||||
onTap: (context) => context.push('/message', extra: item),
|
texts: [item.title, item.author],
|
||||||
);
|
onTap: (context) => context.push('/message', extra: item),
|
||||||
}
|
);
|
||||||
|
}
|
||||||
factory InfoCard.homework(Homework homework) {
|
|
||||||
return InfoCard(
|
factory InfoCard.omission(List<Omission> omissions) {
|
||||||
icon: FilledCircle(
|
String title = "-";
|
||||||
diameter: 36,
|
for (final state in [
|
||||||
color: appStyle.colors.accent.withAlpha(38),
|
OmissionState.pending,
|
||||||
child: FutureBuilder<bool>(
|
OmissionState.unexcused,
|
||||||
future: isHomeworkDone(initData.isar, homework.uid),
|
OmissionState.excused,
|
||||||
builder: (context, snapshot) {
|
]) {
|
||||||
if (!snapshot.hasData) {
|
final count = omissions.where((o) => o.state == state).length;
|
||||||
return SizedBox();
|
title = initData.l10n.omissions_count(state.name, count);
|
||||||
}
|
}
|
||||||
final done = snapshot.data!;
|
return InfoCard(
|
||||||
return done
|
icon: FilledCircle(
|
||||||
? FirkaIconWidget(
|
diameter: 36,
|
||||||
FirkaIconType.majesticonsLocal,
|
color: appStyle.colors.a15p,
|
||||||
"homeWithMark",
|
child: SizedBox(),
|
||||||
color: appStyle.colors.accent,
|
),
|
||||||
size: 24,
|
texts: [
|
||||||
)
|
title,
|
||||||
: FirkaIconWidget(
|
DateFormat.MMMMd(initData.l10n.localeName).format(omissions.first.date),
|
||||||
FirkaIconType.majesticons,
|
],
|
||||||
Majesticon.homeSolid,
|
onTap: (context) =>
|
||||||
color: appStyle.colors.accent,
|
showOmissionBottomSheet(context, initData, title, omissions),
|
||||||
size: 24,
|
);
|
||||||
);
|
}
|
||||||
},
|
|
||||||
),
|
factory InfoCard.homework(Homework homework) {
|
||||||
),
|
return InfoCard(
|
||||||
texts: [initData.l10n.homework, homework.subjectName],
|
icon: FilledCircle(
|
||||||
right: [buildSubject(appStyle.colors.accent, homework.subject)],
|
diameter: 36,
|
||||||
onTap: (context) => showHomeworkBottomSheet(context, initData, homework),
|
color: appStyle.colors.accent.withAlpha(38),
|
||||||
);
|
child: FutureBuilder<bool>(
|
||||||
}
|
future: isHomeworkDone(initData.isar, homework.uid),
|
||||||
|
builder: (context, snapshot) {
|
||||||
factory InfoCard.gradeSubj(
|
if (!snapshot.hasData) {
|
||||||
Grade grade, {
|
return SizedBox();
|
||||||
void Function(BuildContext)? onTap,
|
}
|
||||||
}) {
|
final done = snapshot.data!;
|
||||||
String? value = grade.numericValue == null ? grade.strValue : null;
|
return done
|
||||||
return InfoCard(
|
? FirkaIconWidget(
|
||||||
icon: GradeWidget(grade),
|
FirkaIconType.majesticonsLocal,
|
||||||
texts: [
|
"homeWithMark",
|
||||||
(value ??
|
color: appStyle.colors.accent,
|
||||||
grade.topic ??
|
size: 24,
|
||||||
grade.mode?.description ??
|
)
|
||||||
grade.type.description!)
|
: FirkaIconWidget(
|
||||||
.firstUpper(),
|
FirkaIconType.majesticons,
|
||||||
grade.subject.name.firstUpper(),
|
Majesticon.homeSolid,
|
||||||
],
|
color: appStyle.colors.accent,
|
||||||
right: [
|
size: 24,
|
||||||
buildSubject(
|
);
|
||||||
grade.numericValue != null
|
},
|
||||||
? getGradeColor(grade.numericValue!)
|
),
|
||||||
: appStyle.colors.accent,
|
),
|
||||||
grade.subject,
|
texts: [initData.l10n.homework, homework.subjectName],
|
||||||
),
|
right: [buildSubject(appStyle.colors.accent, homework.subject)],
|
||||||
],
|
onTap: (context) => showHomeworkBottomSheet(context, initData, homework),
|
||||||
onTap:
|
);
|
||||||
onTap ?? (context) => showGradeBottomSheet(context, initData, grade),
|
}
|
||||||
);
|
|
||||||
}
|
factory InfoCard.gradeSubj(
|
||||||
|
Grade grade, {
|
||||||
factory InfoCard.gradeGhost(
|
void Function(BuildContext)? onTap,
|
||||||
int gradeValue,
|
}) {
|
||||||
int gradeWeigth, {
|
String? value = grade.numericValue == null ? grade.strValue : null;
|
||||||
void Function(BuildContext)? onTap,
|
return InfoCard(
|
||||||
}) {
|
icon: GradeWidget(grade),
|
||||||
return InfoCard(
|
texts: [
|
||||||
icon: GradeWidget.gradeValue(gradeValue, gradeWeight: gradeWeigth),
|
(value ??
|
||||||
texts: ["${initData.l10n.ghost_grade} ($gradeWeigth%)"],
|
grade.topic ??
|
||||||
right: [],
|
grade.mode?.description ??
|
||||||
onTap: onTap,
|
grade.type.description!)
|
||||||
);
|
.firstUpper(),
|
||||||
}
|
grade.subject.name.firstUpper(),
|
||||||
|
],
|
||||||
factory InfoCard.gradeDesc(
|
right: [
|
||||||
Grade grade, {
|
buildSubject(
|
||||||
void Function(BuildContext)? onTap,
|
grade.numericValue != null
|
||||||
}) {
|
? getGradeColor(grade.numericValue!)
|
||||||
List<String> texts = [
|
: appStyle.colors.accent,
|
||||||
(grade.mode?.description ?? grade.type.description!).firstUpper(),
|
grade.subject,
|
||||||
];
|
),
|
||||||
|
],
|
||||||
if (grade.topic != null) {
|
onTap:
|
||||||
texts = [grade.topic!.firstUpper(), ...texts];
|
onTap ?? (context) => showGradeBottomSheet(context, initData, grade),
|
||||||
}
|
);
|
||||||
|
}
|
||||||
return InfoCard(
|
|
||||||
icon: GradeWidget(grade),
|
factory InfoCard.gradeGhost(
|
||||||
texts: texts,
|
int gradeValue,
|
||||||
right: [buildSubject(appStyle.colors.accent, grade.subject)],
|
int gradeWeigth, {
|
||||||
onTap:
|
void Function(BuildContext)? onTap,
|
||||||
onTap ?? (context) => showGradeBottomSheet(context, initData, grade),
|
}) {
|
||||||
);
|
return InfoCard(
|
||||||
}
|
icon: GradeWidget.gradeValue(gradeValue, gradeWeight: gradeWeigth),
|
||||||
|
texts: ["${initData.l10n.ghost_grade} ($gradeWeigth%)"],
|
||||||
@override
|
right: [],
|
||||||
Widget build(BuildContext context) {
|
onTap: onTap,
|
||||||
List<Text> children = [];
|
);
|
||||||
int i = 0;
|
}
|
||||||
for (var text in texts) {
|
|
||||||
children.add(
|
factory InfoCard.gradeDesc(
|
||||||
Text(text, style: textSyles[i], overflow: TextOverflow.ellipsis),
|
Grade grade, {
|
||||||
);
|
void Function(BuildContext)? onTap,
|
||||||
if (i < textSyles.length) {
|
}) {
|
||||||
i++;
|
List<String> texts = [
|
||||||
}
|
(grade.mode?.description ?? grade.type.description!).firstUpper(),
|
||||||
}
|
];
|
||||||
return GestureDetector(
|
|
||||||
child: FirkaCard.single(
|
if (grade.topic != null) {
|
||||||
height: 68,
|
texts = [grade.topic!.firstUpper(), ...texts];
|
||||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
}
|
||||||
margin: EdgeInsets.all(0),
|
|
||||||
child: Row(
|
return InfoCard(
|
||||||
spacing: 12,
|
icon: GradeWidget(grade),
|
||||||
children: [
|
texts: texts,
|
||||||
icon,
|
right: [buildSubject(appStyle.colors.accent, grade.subject)],
|
||||||
Expanded(
|
onTap:
|
||||||
child: Column(
|
onTap ?? (context) => showGradeBottomSheet(context, initData, grade),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
);
|
||||||
mainAxisSize: MainAxisSize.min,
|
}
|
||||||
spacing: 2,
|
|
||||||
children: children,
|
@override
|
||||||
),
|
Widget build(BuildContext context) {
|
||||||
),
|
List<Text> children = [];
|
||||||
...right,
|
int i = 0;
|
||||||
],
|
for (var text in texts) {
|
||||||
),
|
children.add(
|
||||||
),
|
Text(text, style: textSyles[i], overflow: TextOverflow.ellipsis),
|
||||||
onTap: () {
|
);
|
||||||
if (onTap == null) return;
|
if (i < textSyles.length) {
|
||||||
onTap!.call(context);
|
i++;
|
||||||
},
|
}
|
||||||
);
|
}
|
||||||
}
|
return GestureDetector(
|
||||||
}
|
child: FirkaCard.single(
|
||||||
|
height: 68,
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
margin: EdgeInsets.all(0),
|
||||||
|
child: Row(
|
||||||
|
spacing: 12,
|
||||||
|
children: [
|
||||||
|
icon,
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
spacing: 2,
|
||||||
|
children: children,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
...right,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
if (onTap == null) return;
|
||||||
|
onTap!.call(context);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -42,12 +42,10 @@ class LessonWidget extends StatelessWidget {
|
|||||||
.group("settings")
|
.group("settings")
|
||||||
.subGroup("timetable_toast")
|
.subGroup("timetable_toast")
|
||||||
.boolean("substitution");
|
.boolean("substitution");
|
||||||
final showLessonNos =
|
final showLessonNos = data.settings
|
||||||
lesson.lessonNumber != null &&
|
.group("settings")
|
||||||
data.settings
|
.subGroup("timetable_toast")
|
||||||
.group("settings")
|
.boolean("lesson_no");
|
||||||
.subGroup("timetable_toast")
|
|
||||||
.boolean("lesson_no");
|
|
||||||
final isDismissed = lesson.type.name == "UresOra";
|
final isDismissed = lesson.type.name == "UresOra";
|
||||||
|
|
||||||
var accent = appStyle.colors.accent;
|
var accent = appStyle.colors.accent;
|
||||||
@@ -115,7 +113,7 @@ class LessonWidget extends StatelessWidget {
|
|||||||
height: 18,
|
height: 18,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
lesson.lessonNumber!.toString(),
|
lesson.lessonNumber?.toString() ?? "-",
|
||||||
style: appStyle.fonts.B_14SB.apply(
|
style: appStyle.fonts.B_14SB.apply(
|
||||||
color: secondary,
|
color: secondary,
|
||||||
),
|
),
|
||||||
|
|||||||
87
firka/lib/ui/phone/widgets/omission_bar.dart
Normal file
87
firka/lib/ui/phone/widgets/omission_bar.dart
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
import 'package:firka/app/app_state.dart';
|
||||||
|
import 'package:firka/core/extensions.dart';
|
||||||
|
import 'package:firka/ui/components/firka_card.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:kreta_api/kreta_api.dart';
|
||||||
|
import 'package:firka/ui/components/grade.dart';
|
||||||
|
import 'package:firka/ui/components/grade_helpers.dart';
|
||||||
|
import 'package:firka/ui/shared/firka_icon.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||||
|
|
||||||
|
import 'package:firka/l10n/app_localizations.dart';
|
||||||
|
import 'package:firka/ui/theme/style.dart';
|
||||||
|
|
||||||
|
class OmissionBar extends StatelessWidget {
|
||||||
|
final List<Omission> omissions;
|
||||||
|
|
||||||
|
const OmissionBar({super.key, required this.omissions});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
DateTime now = DateTime.now();
|
||||||
|
DateTime start = now.copyWith(month: 9, day: 1);
|
||||||
|
DateTime startOfTheYear = now.isBefore(start)
|
||||||
|
? start.subtract(Duration(days: 365))
|
||||||
|
: start;
|
||||||
|
|
||||||
|
Map<int, Color> dayToColor = omissions.fold(
|
||||||
|
Map.identity(),
|
||||||
|
(map, o) => map
|
||||||
|
..putIfAbsent(
|
||||||
|
o.date.difference(startOfTheYear).inDays,
|
||||||
|
() => o.state == OmissionState.excused
|
||||||
|
? appStyle.colors.accent
|
||||||
|
: o.state == OmissionState.unexcused
|
||||||
|
? appStyle.colors.errorAccent
|
||||||
|
: appStyle.colors.warningAccent,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final bar = ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
child: Row(
|
||||||
|
children: List.generate(now.difference(startOfTheYear).inDays, (i) {
|
||||||
|
return Expanded(
|
||||||
|
child: Container(
|
||||||
|
height: 12,
|
||||||
|
color: dayToColor[i] ?? appStyle.colors.a15p,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return FirkaCard.single(
|
||||||
|
margin: EdgeInsets.zero,
|
||||||
|
padding: EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 8),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
spacing: 8,
|
||||||
|
children: [
|
||||||
|
bar,
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
DateFormat.MMMM(
|
||||||
|
initData.l10n.localeName,
|
||||||
|
).format(startOfTheYear).firstUpper(),
|
||||||
|
style: appStyle.fonts.B_14R.copyWith(
|
||||||
|
color: appStyle.colors.textSecondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
initData.l10n.now,
|
||||||
|
style: appStyle.fonts.B_14R.copyWith(
|
||||||
|
color: appStyle.colors.textSecondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,21 +4,21 @@ import 'subject.dart';
|
|||||||
|
|
||||||
class Omission extends UidObj {
|
class Omission extends UidObj {
|
||||||
final Subject subject;
|
final Subject subject;
|
||||||
final Class? c;
|
final OmittedLesson? lesson;
|
||||||
final DateTime date;
|
final DateTime date;
|
||||||
final String teacher;
|
final String teacher;
|
||||||
final NameUidDesc? type;
|
final NameUidDesc? type;
|
||||||
final NameUidDesc? mode;
|
final NameUidDesc? mode;
|
||||||
final int? lateForMin;
|
final int? lateForMin;
|
||||||
final DateTime createdAt;
|
final DateTime createdAt;
|
||||||
final String state;
|
final OmissionState state;
|
||||||
final NameUidDesc? proofType;
|
final NameUidDesc? proofType;
|
||||||
final UidObj? classGroup;
|
final UidObj? classGroup;
|
||||||
|
|
||||||
const Omission({
|
const Omission({
|
||||||
required super.uid,
|
required super.uid,
|
||||||
required this.subject,
|
required this.subject,
|
||||||
required this.c,
|
required this.lesson,
|
||||||
required this.date,
|
required this.date,
|
||||||
required this.teacher,
|
required this.teacher,
|
||||||
this.type,
|
this.type,
|
||||||
@@ -34,14 +34,14 @@ class Omission extends UidObj {
|
|||||||
return Omission(
|
return Omission(
|
||||||
uid: json['Uid'],
|
uid: json['Uid'],
|
||||||
subject: Subject.fromJson(json['Tantargy']),
|
subject: Subject.fromJson(json['Tantargy']),
|
||||||
c: json['Osztaly'] != null ? Class.fromJson(json['Osztaly']) : null,
|
lesson: json['Ora'] != null ? OmittedLesson.fromJson(json['Ora']) : null,
|
||||||
date: json.localDate('Datum')!,
|
date: json.localDate('Datum')!,
|
||||||
teacher: json['RogzitoTanarNeve'],
|
teacher: json['RogzitoTanarNeve'],
|
||||||
type: json.nameUidDesc('Tipus'),
|
type: json.nameUidDesc('Tipus'),
|
||||||
mode: json.nameUidDesc('Mod'),
|
mode: json.nameUidDesc('Mod'),
|
||||||
lateForMin: json['KesesPercben'],
|
lateForMin: json['KesesPercben'],
|
||||||
createdAt: json.localDate('KeszitesDatuma')!,
|
createdAt: json.localDate('KeszitesDatuma')!,
|
||||||
state: json['IgazolasAllapota'],
|
state: OmissionState.fromString(json['IgazolasAllapota']),
|
||||||
proofType: json.nameUidDesc('IgazolasTipusa'),
|
proofType: json.nameUidDesc('IgazolasTipusa'),
|
||||||
classGroup: json.uid('OsztalyCsoport'),
|
classGroup: json.uid('OsztalyCsoport'),
|
||||||
);
|
);
|
||||||
@@ -52,7 +52,7 @@ class Omission extends UidObj {
|
|||||||
return 'Omission('
|
return 'Omission('
|
||||||
'uid: "$uid", '
|
'uid: "$uid", '
|
||||||
'subject: $subject, '
|
'subject: $subject, '
|
||||||
'c: $c, '
|
'c: $lesson, '
|
||||||
'date: $date, '
|
'date: $date, '
|
||||||
'teacher: "$teacher", '
|
'teacher: "$teacher", '
|
||||||
'type: $type, '
|
'type: $type, '
|
||||||
@@ -66,15 +66,39 @@ class Omission extends UidObj {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Class {
|
enum OmissionState {
|
||||||
|
excused("Igazolt"),
|
||||||
|
unexcused("Igazolatlan"),
|
||||||
|
pending("Igazolando"),
|
||||||
|
unknown("");
|
||||||
|
|
||||||
|
final String key;
|
||||||
|
const OmissionState(this.key);
|
||||||
|
|
||||||
|
static fromString(String string) {
|
||||||
|
for (final state in OmissionState.values) {
|
||||||
|
if (state.key == string) {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print("Unknown omission state: ${string}");
|
||||||
|
return OmissionState.unknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class OmittedLesson {
|
||||||
final DateTime start;
|
final DateTime start;
|
||||||
final DateTime end;
|
final DateTime end;
|
||||||
final int classNo;
|
final int? classNo;
|
||||||
|
|
||||||
const Class({required this.start, required this.end, required this.classNo});
|
const OmittedLesson({
|
||||||
|
required this.start,
|
||||||
|
required this.end,
|
||||||
|
required this.classNo,
|
||||||
|
});
|
||||||
|
|
||||||
factory Class.fromJson(Map<String, dynamic> json) {
|
factory OmittedLesson.fromJson(Map<String, dynamic> json) {
|
||||||
return Class(
|
return OmittedLesson(
|
||||||
start: json.localDate('KezdoDatum')!,
|
start: json.localDate('KezdoDatum')!,
|
||||||
end: json.localDate('VegDatum')!,
|
end: json.localDate('VegDatum')!,
|
||||||
classNo: json['Oraszam'],
|
classNo: json['Oraszam'],
|
||||||
@@ -83,7 +107,7 @@ class Class {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Class('
|
return 'OmittedLesson('
|
||||||
'start: "$start", '
|
'start: "$start", '
|
||||||
'end: "$end", '
|
'end: "$end", '
|
||||||
'classNo: $classNo'
|
'classNo: $classNo'
|
||||||
|
|||||||
Reference in New Issue
Block a user