forked from firka/firka
feat: show notice board items as messages
This commit is contained in:
@@ -84,7 +84,7 @@ GoRouter createAppRouter() {
|
||||
GoRoute(
|
||||
path: '/message',
|
||||
builder: (context, state) {
|
||||
final info = state.extra as InfoBoardItem?;
|
||||
final info = state.extra as MessageItem?;
|
||||
if (info == null) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
@@ -297,13 +297,13 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
||||
}
|
||||
|
||||
if (student != null && lessons != null) {
|
||||
final infoItems = infoBoard ?? [];
|
||||
final infoItems = [...(infoBoard ?? []), ...(noticeBoard ?? [])];
|
||||
final gradeItems = grades ?? [];
|
||||
final homeworkItems = homework ?? [];
|
||||
final noticeBoardWidgets = <(Widget, DateTime)>[];
|
||||
|
||||
for (final item in infoItems) {
|
||||
noticeBoardWidgets.add((InfoCard.infoBoardItem(item), item.date));
|
||||
noticeBoardWidgets.add((InfoCard.messageItem(item), item.date));
|
||||
}
|
||||
|
||||
for (final grade in gradeItems) {
|
||||
|
||||
@@ -10,9 +10,9 @@ import 'package:firka/ui/shared/firka_icon.dart';
|
||||
|
||||
class MessageScreen extends StatelessWidget {
|
||||
final AppInitialization data;
|
||||
final InfoBoardItem info;
|
||||
final MessageItem message;
|
||||
|
||||
const MessageScreen(this.data, this.info, {super.key});
|
||||
const MessageScreen(this.data, this.message, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -68,7 +68,7 @@ class MessageScreen extends StatelessWidget {
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width * 0.85,
|
||||
child: Text(
|
||||
info.title,
|
||||
message.title,
|
||||
textAlign: TextAlign.center,
|
||||
style: appStyle.fonts.H_H2.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
@@ -82,7 +82,7 @@ class MessageScreen extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
info.date.format(data.l10n, FormatMode.yyyymmdd),
|
||||
message.date.format(data.l10n, FormatMode.yyyymmdd),
|
||||
textAlign: TextAlign.center,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textSecondary,
|
||||
@@ -107,7 +107,7 @@ class MessageScreen extends StatelessWidget {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 6),
|
||||
child: Text(
|
||||
info.author[0],
|
||||
message.author[0],
|
||||
style: appStyle.fonts.H_18px.copyWith(
|
||||
fontSize: 20,
|
||||
color: appStyle.colors.textPrimary,
|
||||
@@ -125,7 +125,7 @@ class MessageScreen extends StatelessWidget {
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width / 1.4,
|
||||
child: Text(
|
||||
info.author,
|
||||
message.author,
|
||||
style: appStyle.fonts.B_16SB.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
@@ -151,7 +151,7 @@ class MessageScreen extends StatelessWidget {
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: SingleChildScrollView(
|
||||
child: Text(
|
||||
info.contentText,
|
||||
message.contentText,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
|
||||
@@ -48,7 +48,7 @@ class InfoCard extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
factory InfoCard.infoBoardItem(InfoBoardItem item) {
|
||||
factory InfoCard.messageItem(MessageItem item) {
|
||||
return InfoCard(
|
||||
icon: FilledCircle(
|
||||
diameter: 36,
|
||||
|
||||
@@ -1,24 +1,40 @@
|
||||
import '../extensions.dart';
|
||||
import 'generic.dart';
|
||||
|
||||
class NoticeBoardItem extends UidObj {
|
||||
final String author;
|
||||
final DateTime validFrom;
|
||||
final DateTime validTo;
|
||||
abstract class MessageItem extends UidObj {
|
||||
final String title;
|
||||
final String author;
|
||||
final String contentHTML;
|
||||
final String contentText;
|
||||
|
||||
NoticeBoardItem({
|
||||
MessageItem({
|
||||
required super.uid,
|
||||
required this.author,
|
||||
required this.validFrom,
|
||||
required this.validTo,
|
||||
required this.title,
|
||||
required this.author,
|
||||
required this.contentHTML,
|
||||
required this.contentText,
|
||||
});
|
||||
|
||||
DateTime get date;
|
||||
}
|
||||
|
||||
class NoticeBoardItem extends MessageItem {
|
||||
final DateTime validFrom;
|
||||
final DateTime validTo;
|
||||
|
||||
@override
|
||||
DateTime get date => validFrom;
|
||||
|
||||
NoticeBoardItem({
|
||||
required super.uid,
|
||||
required super.title,
|
||||
required super.author,
|
||||
required super.contentHTML,
|
||||
required super.contentText,
|
||||
required this.validFrom,
|
||||
required this.validTo,
|
||||
});
|
||||
|
||||
factory NoticeBoardItem.fromJson(Map<String, dynamic> json) {
|
||||
return NoticeBoardItem(
|
||||
uid: json['Uid'],
|
||||
@@ -45,23 +61,19 @@ class NoticeBoardItem extends UidObj {
|
||||
}
|
||||
}
|
||||
|
||||
class InfoBoardItem extends UidObj {
|
||||
final String title;
|
||||
class InfoBoardItem extends MessageItem {
|
||||
final DateTime date;
|
||||
final String author;
|
||||
final DateTime createdAt;
|
||||
final String contentHTML;
|
||||
final String contentText;
|
||||
final NameUidDesc type;
|
||||
|
||||
InfoBoardItem({
|
||||
required super.uid,
|
||||
required this.title,
|
||||
required this.date,
|
||||
required this.author,
|
||||
required super.title,
|
||||
required super.author,
|
||||
required super.contentHTML,
|
||||
required super.contentText,
|
||||
required this.createdAt,
|
||||
required this.contentHTML,
|
||||
required this.contentText,
|
||||
required this.date,
|
||||
required this.type,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user