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