From 6274039aec9a374136d3bfdf999b7d1681d5f9fa Mon Sep 17 00:00:00 2001 From: Npepperlinux Date: Sun, 1 Dec 2024 14:54:59 +0900 Subject: [PATCH] =?UTF-8?q?CW=E3=83=86=E3=82=AD=E3=82=B9=E3=83=88=E3=82=92?= =?UTF-8?q?=E3=82=B3=E3=83=94=E3=83=BC=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../copy_note_modal_sheet.dart | 50 ++++++++++++++++--- .../note_modal_sheet/note_modal_sheet.dart | 3 +- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/lib/view/copy_modal_sheet/copy_note_modal_sheet.dart b/lib/view/copy_modal_sheet/copy_note_modal_sheet.dart index 448668c76..ed128d848 100644 --- a/lib/view/copy_modal_sheet/copy_note_modal_sheet.dart +++ b/lib/view/copy_modal_sheet/copy_note_modal_sheet.dart @@ -5,10 +5,12 @@ import "package:flutter_riverpod/flutter_riverpod.dart"; import "package:miria/view/themes/app_theme.dart"; class CopyNoteModalSheet extends ConsumerWidget { - final String note; + final String text; + final String? cw; const CopyNoteModalSheet({ - required this.note, + required this.text, + this.cw, super.key, }); @@ -22,10 +24,11 @@ class CopyNoteModalSheet extends ConsumerWidget { ListTile( title: Text(S.of(context).detail), trailing: IconButton( - onPressed: () { - Clipboard.setData( - ClipboardData(text: note), + onPressed: () async { + await Clipboard.setData( + ClipboardData(text: text), ); + if (!context.mounted) return; ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text(S.of(context).doneCopy), @@ -37,11 +40,46 @@ class CopyNoteModalSheet extends ConsumerWidget { tooltip: S.of(context).copyContents, ), ), + if (cw != null) + Padding( + padding: const EdgeInsets.only(bottom: 5), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: Card( + child: Padding( + padding: const EdgeInsets.all(10), + child: SelectableText( + cw!, + style: AppTheme.of(context).monospaceStyle, + ), + ), + ), + ), + IconButton( + onPressed: () async { + await Clipboard.setData( + ClipboardData(text: cw!), + ); + if (!context.mounted) return; + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(S.of(context).doneCopy), + duration: const Duration(seconds: 1), + ), + ); + }, + icon: const Icon(Icons.copy), + ), + ], + ), + ), Card( child: Padding( padding: const EdgeInsets.all(10), child: SelectableText( - note, + text, style: AppTheme.of(context).monospaceStyle, ), ), diff --git a/lib/view/note_modal_sheet/note_modal_sheet.dart b/lib/view/note_modal_sheet/note_modal_sheet.dart index 09bdffa5f..684b8634c 100644 --- a/lib/view/note_modal_sheet/note_modal_sheet.dart +++ b/lib/view/note_modal_sheet/note_modal_sheet.dart @@ -293,7 +293,8 @@ class NoteModalSheet extends ConsumerWidget implements AutoRouteWrapper { await showModalBottomSheet( context: context, builder: (context) => CopyNoteModalSheet( - note: targetNote.text ?? "", + text: targetNote.text ?? "", + cw: targetNote.cw, ), ); },