Skip to content

Commit

Permalink
mod: 增加设置 高亮显示op回复
Browse files Browse the repository at this point in the history
  • Loading branch information
guozhigq committed Mar 19, 2023
1 parent 52b5790 commit 8bfc1ce
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/components/topic/reply_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class _ReplyListItemState extends State<ReplyListItem> {
final GlobalKey repaintKey = GlobalKey();
bool ignoreStatus = false; // 对当前主题的忽略状态 默认false
String? loginUserName;
bool highLightOp = GStorage().getHighlightOp();

@override
void initState() {
Expand Down Expand Up @@ -416,7 +417,7 @@ class _ReplyListItemState extends State<ReplyListItem> {
return RepaintBoundary(
key: repaintKey,
child: Material(
color: reply.isOwner
color: reply.isOwner && highLightOp
? Theme.of(context).colorScheme.onInverseSurface
: null,
child: InkWell(
Expand Down Expand Up @@ -446,7 +447,7 @@ class _ReplyListItemState extends State<ReplyListItem> {
child: Material(
borderRadius: BorderRadius.circular(20),
// color: reply.isOwner ? Theme.of(context).colorScheme.onInverseSurface : null,
elevation: reply.isOwner ? 3 : 0,
elevation: reply.isOwner && highLightOp ? 3 : 0,
child: InkWell(
onTap: () async {
/// 增加200毫秒延迟 水波纹动画
Expand Down
30 changes: 30 additions & 0 deletions lib/pages/page_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class _SettingPageState extends State<SettingPage> {
late String cacheSize = '';
late bool expendAppBar = GStorage().getExpendAppBar();
late bool noticeOn = GStorage().getNoticeOn();
late bool highlightOp = GStorage().getHighlightOp();

@override
void initState() {
Expand Down Expand Up @@ -238,6 +239,35 @@ class _SettingPageState extends State<SettingPage> {
}),
),
),
ListTile(
onTap: () {
setState(() {
highlightOp = !highlightOp;
GStorage().setHighlightOp(noticeOn);
});
},
leading: Icon(Icons.notifications_none, color: iconStyle),
title: const Text('突出显示OP回复'),
trailing: Transform.scale(
scale: 0.8,
child: Switch(
thumbIcon: MaterialStateProperty.resolveWith<Icon?>(
(Set<MaterialState> states) {
if (states.isNotEmpty &&
states.first == MaterialState.selected) {
return const Icon(Icons.done);
}
return null; // All other states will use the default thumbIcon.
}),
value: highlightOp,
onChanged: (value) {
setState(() {
highlightOp = !highlightOp;
GStorage().setHighlightOp(highlightOp);
});
}),
),
),
ListTile(
onTap: () => Get.toNamed('/setFont'),
leading: Icon(Icons.font_download_outlined, color: iconStyle),
Expand Down
8 changes: 7 additions & 1 deletion lib/utils/storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ enum StoreKeys {
htmlFs,
replyFs,
tabs,
autoUpdate
autoUpdate,
highlightOp,
}

class GStorage {
Expand Down Expand Up @@ -166,4 +167,9 @@ class GStorage {
setAutoUpdate(bool value) => _box.write(StoreKeys.autoUpdate.toString(), value);

bool getAutoUpdate() => _box.read<bool>(StoreKeys.autoUpdate.toString()) ?? true;

// 自动更新
setHighlightOp(bool value) => _box.write(StoreKeys.highlightOp.toString(), value);

bool getHighlightOp() => _box.read<bool>(StoreKeys.highlightOp.toString()) ?? false;
}

0 comments on commit 8bfc1ce

Please sign in to comment.