Skip to content

Commit

Permalink
feat(card): Highlight thread title and point change in notice card
Browse files Browse the repository at this point in the history
  • Loading branch information
realth000 committed Feb 20, 2024
1 parent 1d5ed2b commit 426cfed
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

### Changed

- 高亮显示通知卡片中的帖子标题和积分变动。
- internal: 支持flutter 3.19。
- internal: 去除安卓gradle构建脚本中标记为弃用的部分。
- internal: 提高最低依赖版本:flutter 3.19和dart 3.3。
Expand Down
6 changes: 3 additions & 3 deletions lib/i18n/strings.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@
"title": "Notifications",
"noticeTab": {
"title": "Notice",
"replyBody": "replied in $threadTitle",
"rateBody": "scored your thread in $threadTitle $score",
"replyBody(rich)": "replied in $threadTitle",
"rateBody(rich)": "scored your thread in $threadTitle $score",
"mentionBody": "mentioned you in thread",
"inviteBody": "invite you to participate in the topic $threadTitle",
"inviteBody(rich)": "invite you to participate in the topic $threadTitle",
"newFriendBody": "became your friend",
"ignoredSameNotice": "$count more same notice ignored",
"taskID": "Task ID: $taskId"
Expand Down
6 changes: 3 additions & 3 deletions lib/i18n/strings_zh-CN.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@
"title": "通知",
"noticeTab": {
"title": "提醒",
"replyBody": "在 $threadTitle 中回复了",
"rateBody": "在 $threadTitle 中给您的帖子评分 $score",
"replyBody(rich)": "在 $threadTitle 中回复了",
"rateBody(rich)": "在 $threadTitle 中给您的帖子评分 $score",
"mentionBody": "在帖子中提到了你",
"inviteBody": "邀请您参与话题 $threadTitle",
"inviteBody(rich)": "邀请您参与话题 $threadTitle",
"newFriendBody": "和您成为了好友",
"ignoredSameNotice": "还有 $count 个相同通知被忽略",
"taskID": "任务ID:$taskId"
Expand Down
6 changes: 3 additions & 3 deletions lib/i18n/strings_zh-TW.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@
"title": "通知",
"noticeTab": {
"title": "提醒",
"replyBody": "在 $threadTitle 中回覆了",
"rateBody": "在 $threadTitle 中給您的帖子評分 $score",
"replyBody(rich)": "在 $threadTitle 中回覆了",
"rateBody(rich)": "在 $threadTitle 中給您的帖子評分 $score",
"mentionBody": "在話題中提到了你",
"inviteBody": "邀請您參與話題 $threadTitle",
"inviteBody(rich)": "邀請您參與話題 $threadTitle",
"newFriendBody": "和您成為好友了",
"ignoredSameNotice": "還有 $count 個相同通知被忽略",
"taskID": "任務ID:$taskId"
Expand Down
40 changes: 31 additions & 9 deletions lib/widgets/card/notice_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ class NoticeCard extends StatelessWidget {

@override
Widget build(BuildContext context) {
final primaryStyle = Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(color: Theme.of(context).colorScheme.primary);
final secondaryStyle = Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(color: Theme.of(context).colorScheme.secondary);
final outlineStyle = Theme.of(context)
.textTheme
.labelMedium
Expand All @@ -40,17 +48,27 @@ class NoticeCard extends StatelessWidget {
}

final noticeBody = switch (notice.noticeType) {
NoticeType.reply => Text(
context.t.noticePage.noticeTab
.replyBody(threadTitle: notice.noticeThreadTitle ?? '-'),
NoticeType.reply => Text.rich(
context.t.noticePage.noticeTab.replyBody(
threadTitle: TextSpan(
text: notice.noticeThreadTitle ?? '-',
style: primaryStyle,
),
),
),
NoticeType.rate || NoticeType.batchRate => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
Text.rich(
context.t.noticePage.noticeTab.rateBody(
threadTitle: notice.noticeThreadTitle ?? '-',
score: notice.score ?? '-',
threadTitle: TextSpan(
text: notice.noticeThreadTitle ?? '-',
style: primaryStyle,
),
score: TextSpan(
text: notice.score ?? '-',
style: secondaryStyle,
),
),
),
if (notice.quotedMessage?.isNotEmpty ?? false)
Expand Down Expand Up @@ -82,9 +100,13 @@ class NoticeCard extends StatelessWidget {
),
],
),
NoticeType.invite => Text(
context.t.noticePage.noticeTab
.inviteBody(threadTitle: notice.noticeThreadTitle ?? ''),
NoticeType.invite => Text.rich(
context.t.noticePage.noticeTab.inviteBody(
threadTitle: TextSpan(
text: notice.noticeThreadTitle ?? '',
style: primaryStyle,
),
),
),
NoticeType.newFriend =>
Text(context.t.noticePage.noticeTab.newFriendBody),
Expand Down

0 comments on commit 426cfed

Please sign in to comment.