Skip to content

Commit

Permalink
feat(card): make notice card copy raw content action as debug action
Browse files Browse the repository at this point in the history
  • Loading branch information
realth000 committed Dec 28, 2024
1 parent 9f52fc0 commit 96a3a8a
Showing 1 changed file with 46 additions and 34 deletions.
80 changes: 46 additions & 34 deletions lib/widgets/card/notice_card_v2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:tsdm_client/features/authentication/repository/authentication_re
import 'package:tsdm_client/features/notification/bloc/notification_bloc.dart';
import 'package:tsdm_client/features/notification/bloc/notification_state_cubit.dart';
import 'package:tsdm_client/features/notification/models/models.dart';
import 'package:tsdm_client/features/settings/bloc/settings_bloc.dart';
import 'package:tsdm_client/features/settings/repositories/settings_repository.dart';
import 'package:tsdm_client/i18n/strings.g.dart';
import 'package:tsdm_client/instance.dart';
Expand Down Expand Up @@ -126,16 +127,6 @@ class _NoticeCardV2State extends State<NoticeCardV2> {
],
),
),
PopupMenuItem(
value: _Actions.copyRawContent,
child: Row(
children: [
const Icon(Icons.copy_all_outlined),
sizedBoxPopupMenuItemIconSpacing,
Text(tr.copyRawContent),
],
),
),
PopupMenuItem(
value: _Actions.deleteItem,
child: Row(
Expand All @@ -154,6 +145,31 @@ class _NoticeCardV2State extends State<NoticeCardV2> {
],
),
),
if (context
.read<SettingsBloc>()
.state
.settingsMap
.enableDebugOperations) ...<PopupMenuEntry<_Actions>>[
const PopupMenuDivider(),
PopupMenuItem(
value: _Actions.copyRawContent,
child: Row(
children: [
Icon(
Icons.bug_report_outlined,
color: Theme.of(context).colorScheme.secondary,
),
sizedBoxPopupMenuItemIconSpacing,
Text(
tr.copyRawContent,
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
),
),
],
),
),
],
],
onSelected: (value) async {
switch (value) {
Expand Down Expand Up @@ -334,23 +350,21 @@ class _PersonalMessageCardV2State extends State<PersonalMessageCardV2> {
],
),
),
PopupMenuItem(
value: _Actions.copyRawContent,
child: Row(
children: [
const Icon(Icons.copy_all_outlined),
sizedBoxPopupMenuItemIconSpacing,
Text(tr.copyRawContent),
],
),
),
PopupMenuItem(
value: _Actions.deleteItem,
child: Row(
children: [
const Icon(Icons.delete_forever_outlined),
Icon(
Icons.delete_forever_outlined,
color: Theme.of(context).colorScheme.error,
),
sizedBoxPopupMenuItemIconSpacing,
Text(tr.delete.title),
Text(
tr.delete.title,
style: TextStyle(
color: Theme.of(context).colorScheme.error,
),
),
],
),
),
Expand Down Expand Up @@ -509,23 +523,21 @@ class _BroadcastMessageCardV2State extends State<BroadcastMessageCardV2> {
],
),
),
PopupMenuItem(
value: _Actions.copyRawContent,
child: Row(
children: [
const Icon(Icons.copy_all_outlined),
sizedBoxPopupMenuItemIconSpacing,
Text(tr.copyRawContent),
],
),
),
PopupMenuItem(
value: _Actions.deleteItem,
child: Row(
children: [
const Icon(Icons.delete_forever_outlined),
Icon(
Icons.delete_forever_outlined,
color: Theme.of(context).colorScheme.error,
),
sizedBoxPopupMenuItemIconSpacing,
Text(tr.delete.title),
Text(
tr.delete.title,
style: TextStyle(
color: Theme.of(context).colorScheme.error,
),
),
],
),
),
Expand Down

0 comments on commit 96a3a8a

Please sign in to comment.