feat(flutter): 增加轮播自动播放与站内通知
This commit is contained in:
1 parent
b7b1c50427
commit
b870956665
24 files changed
+1398
-26
No files matched your search
@@ -0,0 +1,53 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'json_numbers.dart';
|
||||
|
||||
/// Server notice list page.
|
||||
class NoticePage {
|
||||
const NoticePage({required this.total, this.notices = const []});
|
||||
|
||||
final int total;
|
||||
final List<AppNotice> notices;
|
||||
|
||||
/// Parses the anonymous `/app/notices` page shell.
|
||||
factory NoticePage.fromJson(Map<String, dynamic> json) {
|
||||
final rawList = json['list'];
|
||||
return NoticePage(
|
||||
total: jsonToInt(json['total']),
|
||||
notices: [
|
||||
if (rawList is List)
|
||||
for (final item in rawList)
|
||||
if (item is Map<String, dynamic>) AppNotice.fromJson(item),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// System notice returned by `/app/notices`.
|
||||
class AppNotice {
|
||||
const AppNotice({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.content,
|
||||
required this.type,
|
||||
required this.publishAt,
|
||||
this.expireAt,
|
||||
});
|
||||
|
||||
final String id;
|
||||
final String title;
|
||||
final String content;
|
||||
final String type;
|
||||
final DateTime? publishAt;
|
||||
final DateTime? expireAt;
|
||||
|
||||
/// Parses string IDs without narrowing them through `int`.
|
||||
factory AppNotice.fromJson(Map<String, dynamic> json) => AppNotice(
|
||||
id: jsonToId(json['id']),
|
||||
title: json['title']?.toString() ?? '',
|
||||
content: json['content']?.toString() ?? '',
|
||||
type: json['type']?.toString() ?? '',
|
||||
publishAt: DateTime.tryParse(json['publishAt']?.toString() ?? ''),
|
||||
expireAt: DateTime.tryParse(json['expireAt']?.toString() ?? ''),
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user