From 44d969d569a5e2b2b5b3fa5b8027af3d0f2c0fe4 Mon Sep 17 00:00:00 2001 From: poppingmoon <63451158+poppingmoon@users.noreply.github.com> Date: Tue, 10 Dec 2024 06:49:12 +0900 Subject: [PATCH] fix: use fixed visual density for cw button (#489) * fix: use fixed visual density for cw button * fix: adjust spacing in announcement widget --- lib/view/widget/announcement_widget.dart | 66 ++++++++++++------------ lib/view/widget/cw_button.dart | 1 + lib/view/widget/note_widget.dart | 4 +- lib/view/widget/sub_note_content.dart | 1 + 4 files changed, 39 insertions(+), 33 deletions(-) diff --git a/lib/view/widget/announcement_widget.dart b/lib/view/widget/announcement_widget.dart index 265190a5..f7476971 100644 --- a/lib/view/widget/announcement_widget.dart +++ b/lib/view/widget/announcement_widget.dart @@ -9,6 +9,7 @@ import '../../provider/api/announcements_notifier_provider.dart'; import '../../provider/api/i_notifier_provider.dart'; import '../../provider/misskey_colors_provider.dart'; import '../dialog/confirmation_dialog.dart'; +import '../dialog/image_dialog.dart'; import 'image_widget.dart'; import 'mfm.dart'; import 'time_widget.dart'; @@ -40,14 +41,14 @@ class AnnouncementWidget extends ConsumerWidget { final colors = ref.watch(misskeyColorsProvider(Theme.of(context).brightness)); - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - if (announcement.forYou ?? false) - Padding( - padding: const EdgeInsets.only(left: 8.0, top: 8.0), - child: Row( + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + if (announcement.forYou ?? false) ...[ + Row( children: [ Icon( Icons.push_pin, @@ -61,10 +62,9 @@ class AnnouncementWidget extends ConsumerWidget { ), ], ), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Text.rich( + const SizedBox(height: 8.0), + ], + Text.rich( TextSpan( children: [ if (showButton) const TextSpan(text: '🆕'), @@ -94,19 +94,22 @@ class AnnouncementWidget extends ConsumerWidget { ), style: titleStyle, ), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Mfm(account: account, text: announcement.text), - ), - if (imageUrl != null) - Padding( - padding: const EdgeInsets.all(8.0), - child: Center(child: ImageWidget(url: imageUrl.toString())), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: DefaultTextStyle( + const SizedBox(height: 8.0), + Mfm(account: account, text: announcement.text), + const SizedBox(height: 8.0), + if (imageUrl != null) ...[ + Center( + child: InkWell( + onTap: () => showDialog( + context: context, + builder: (context) => ImageDialog(url: imageUrl.toString()), + ), + child: ImageWidget(url: imageUrl.toString()), + ), + ), + const SizedBox(height: 8.0), + ], + DefaultTextStyle( style: DefaultTextStyle.of(context).style.apply( fontSizeFactor: 0.9, color: @@ -117,11 +120,9 @@ class AnnouncementWidget extends ConsumerWidget { detailed: true, ), ), - ), - if (showButton) - Padding( - padding: const EdgeInsets.all(8.0), - child: ElevatedButton( + if (showButton) ...[ + const SizedBox(height: 8.0), + ElevatedButton( onPressed: () async { if (announcement.needConfirmationToRead ?? false) { final confirmed = await confirm( @@ -143,8 +144,9 @@ class AnnouncementWidget extends ConsumerWidget { }, child: Text(t.misskey.gotIt), ), - ), - ], + ], + ], + ), ); } } diff --git a/lib/view/widget/cw_button.dart b/lib/view/widget/cw_button.dart index e47a08c3..ddc499dd 100644 --- a/lib/view/widget/cw_button.dart +++ b/lib/view/widget/cw_button.dart @@ -31,6 +31,7 @@ class CwButton extends ConsumerWidget { padding: const EdgeInsets.symmetric(vertical: 6.0, horizontal: 12.0), minimumSize: const Size(double.infinity, 0.0), side: BorderSide.none, + visualDensity: VisualDensity.standard, tapTargetSize: MaterialTapTargetSize.shrinkWrap, ), onPressed: onPressed != null ? () => onPressed?.call(!isOpen) : null, diff --git a/lib/view/widget/note_widget.dart b/lib/view/widget/note_widget.dart index 64f590cc..388c9926 100644 --- a/lib/view/widget/note_widget.dart +++ b/lib/view/widget/note_widget.dart @@ -543,6 +543,7 @@ class NoteWidget extends HookConsumerWidget { minimumSize: const Size(double.infinity, 0.0), side: BorderSide.none, + visualDensity: VisualDensity.standard, tapTargetSize: MaterialTapTargetSize.shrinkWrap, ), @@ -556,7 +557,8 @@ class NoteWidget extends HookConsumerWidget { ), const SizedBox(height: 4.0), ], - ], + ] else + const SizedBox(height: 2.0), if (appearNote case Note(:final channel?)) ...[ InkWell( onTap: () => context diff --git a/lib/view/widget/sub_note_content.dart b/lib/view/widget/sub_note_content.dart index 0b0e5266..7a15edcc 100644 --- a/lib/view/widget/sub_note_content.dart +++ b/lib/view/widget/sub_note_content.dart @@ -231,6 +231,7 @@ class SubNoteContent extends HookConsumerWidget { const EdgeInsets.symmetric(vertical: 6.0, horizontal: 12.0), minimumSize: const Size(double.infinity, 0.0), side: BorderSide.none, + visualDensity: VisualDensity.standard, tapTargetSize: MaterialTapTargetSize.shrinkWrap, ), onPressed: () => isCollapsed.value = !isCollapsed.value,