Skip to content

Commit 96a3a8a

Browse files
committed
feat(card): make notice card copy raw content action as debug action
1 parent 9f52fc0 commit 96a3a8a

File tree

1 file changed

+46
-34
lines changed

1 file changed

+46
-34
lines changed

lib/widgets/card/notice_card_v2.dart

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:tsdm_client/features/authentication/repository/authentication_re
99
import 'package:tsdm_client/features/notification/bloc/notification_bloc.dart';
1010
import 'package:tsdm_client/features/notification/bloc/notification_state_cubit.dart';
1111
import 'package:tsdm_client/features/notification/models/models.dart';
12+
import 'package:tsdm_client/features/settings/bloc/settings_bloc.dart';
1213
import 'package:tsdm_client/features/settings/repositories/settings_repository.dart';
1314
import 'package:tsdm_client/i18n/strings.g.dart';
1415
import 'package:tsdm_client/instance.dart';
@@ -126,16 +127,6 @@ class _NoticeCardV2State extends State<NoticeCardV2> {
126127
],
127128
),
128129
),
129-
PopupMenuItem(
130-
value: _Actions.copyRawContent,
131-
child: Row(
132-
children: [
133-
const Icon(Icons.copy_all_outlined),
134-
sizedBoxPopupMenuItemIconSpacing,
135-
Text(tr.copyRawContent),
136-
],
137-
),
138-
),
139130
PopupMenuItem(
140131
value: _Actions.deleteItem,
141132
child: Row(
@@ -154,6 +145,31 @@ class _NoticeCardV2State extends State<NoticeCardV2> {
154145
],
155146
),
156147
),
148+
if (context
149+
.read<SettingsBloc>()
150+
.state
151+
.settingsMap
152+
.enableDebugOperations) ...<PopupMenuEntry<_Actions>>[
153+
const PopupMenuDivider(),
154+
PopupMenuItem(
155+
value: _Actions.copyRawContent,
156+
child: Row(
157+
children: [
158+
Icon(
159+
Icons.bug_report_outlined,
160+
color: Theme.of(context).colorScheme.secondary,
161+
),
162+
sizedBoxPopupMenuItemIconSpacing,
163+
Text(
164+
tr.copyRawContent,
165+
style: TextStyle(
166+
color: Theme.of(context).colorScheme.secondary,
167+
),
168+
),
169+
],
170+
),
171+
),
172+
],
157173
],
158174
onSelected: (value) async {
159175
switch (value) {
@@ -334,23 +350,21 @@ class _PersonalMessageCardV2State extends State<PersonalMessageCardV2> {
334350
],
335351
),
336352
),
337-
PopupMenuItem(
338-
value: _Actions.copyRawContent,
339-
child: Row(
340-
children: [
341-
const Icon(Icons.copy_all_outlined),
342-
sizedBoxPopupMenuItemIconSpacing,
343-
Text(tr.copyRawContent),
344-
],
345-
),
346-
),
347353
PopupMenuItem(
348354
value: _Actions.deleteItem,
349355
child: Row(
350356
children: [
351-
const Icon(Icons.delete_forever_outlined),
357+
Icon(
358+
Icons.delete_forever_outlined,
359+
color: Theme.of(context).colorScheme.error,
360+
),
352361
sizedBoxPopupMenuItemIconSpacing,
353-
Text(tr.delete.title),
362+
Text(
363+
tr.delete.title,
364+
style: TextStyle(
365+
color: Theme.of(context).colorScheme.error,
366+
),
367+
),
354368
],
355369
),
356370
),
@@ -509,23 +523,21 @@ class _BroadcastMessageCardV2State extends State<BroadcastMessageCardV2> {
509523
],
510524
),
511525
),
512-
PopupMenuItem(
513-
value: _Actions.copyRawContent,
514-
child: Row(
515-
children: [
516-
const Icon(Icons.copy_all_outlined),
517-
sizedBoxPopupMenuItemIconSpacing,
518-
Text(tr.copyRawContent),
519-
],
520-
),
521-
),
522526
PopupMenuItem(
523527
value: _Actions.deleteItem,
524528
child: Row(
525529
children: [
526-
const Icon(Icons.delete_forever_outlined),
530+
Icon(
531+
Icons.delete_forever_outlined,
532+
color: Theme.of(context).colorScheme.error,
533+
),
527534
sizedBoxPopupMenuItemIconSpacing,
528-
Text(tr.delete.title),
535+
Text(
536+
tr.delete.title,
537+
style: TextStyle(
538+
color: Theme.of(context).colorScheme.error,
539+
),
540+
),
529541
],
530542
),
531543
),

0 commit comments

Comments
 (0)