Skip to content

Commit

Permalink
feat: add header to note and user menu (#286)
Browse files Browse the repository at this point in the history
* fix: clip drive file sheet

* feat: add header to `NoteSheet`

* feat: add header to `UserSheet`

* feat: show `NoteSheet` on long press

* feat: show `UserSheet` on long press
  • Loading branch information
poppingmoon authored Jul 11, 2024
1 parent fc2175f commit 461808c
Show file tree
Hide file tree
Showing 29 changed files with 648 additions and 398 deletions.
8 changes: 3 additions & 5 deletions lib/util/get_note_action.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:misskey_dart/misskey_dart.dart' hide Clip;
Expand Down Expand Up @@ -26,11 +25,10 @@ void Function()? getNoteAction(
NoteActionType.none => null,
NoteActionType.expand => () =>
ref.context.push('/$account/notes/${appearNote.id}'),
NoteActionType.menu => () => showModalBottomSheet<void>(
NoteActionType.menu => () => showNoteSheet(
context: ref.context,
builder: (context) => NoteSheet(account: account, noteId: note.id),
clipBehavior: Clip.hardEdge,
isScrollControlled: true,
account: account,
noteId: note.id,
),
NoteActionType.reaction => !account.isGuest
? () async {
Expand Down
11 changes: 11 additions & 0 deletions lib/view/dialog/user_select_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import '../../provider/api/search_users_by_username_provider.dart';
import '../../provider/recently_used_users_notifier_provider.dart';
import '../widget/error_message.dart';
import '../widget/user_preview.dart';
import '../widget/user_sheet.dart';

Future<UserDetailed?> selectUser(
BuildContext context,
Expand Down Expand Up @@ -112,6 +113,11 @@ class UserSelectDialog extends HookConsumerWidget {
account: account,
user: recentlyUsedUsers[index],
onTap: () => context.pop(recentlyUsedUsers[index]),
onLongPress: () => showUserSheet(
context: context,
account: account,
userId: recentlyUsedUsers[index].id,
),
),
separatorBuilder: (_, __) => const Divider(height: 0.0),
itemCount: recentlyUsedUsers.length,
Expand All @@ -135,6 +141,11 @@ class UserSelectDialog extends HookConsumerWidget {
.add(users[index]);
context.pop(users[index]);
},
onLongPress: () => showUserSheet(
context: context,
account: account,
userId: users[index].id,
),
)
: const SizedBox.shrink(),
separatorBuilder: (_, __) => const Divider(height: 0.0),
Expand Down
8 changes: 7 additions & 1 deletion lib/view/page/clip_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import '../widget/mfm.dart';
import '../widget/note_widget.dart';
import '../widget/paginated_list_view.dart';
import '../widget/user_avatar.dart';
import '../widget/user_sheet.dart';
import '../widget/username_widget.dart';

class ClipPage extends HookConsumerWidget {
Expand Down Expand Up @@ -219,7 +220,7 @@ class ClipPage extends HookConsumerWidget {
onTap: () =>
context.push('/$account/users/${user.id}'),
),
const SizedBox(width: 2.0),
const SizedBox(width: 4.0),
Expanded(
child: Align(
alignment: Alignment.centerLeft,
Expand All @@ -228,6 +229,11 @@ class ClipPage extends HookConsumerWidget {
user: user,
onTap: () =>
context.push('/$account/users/${user.id}'),
onLongPress: () => showUserSheet(
context: context,
account: account,
userId: user.id,
),
),
),
),
Expand Down
1 change: 1 addition & 0 deletions lib/view/page/drive_file_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class DriveFilePage extends ConsumerWidget {
account: account,
file: file,
),
clipBehavior: Clip.antiAlias,
);
final siblings = await ref.read(
driveFilesNotifierProvider(account, file.folderId).future,
Expand Down
6 changes: 6 additions & 0 deletions lib/view/page/gallery/gallery_post_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import '../../widget/like_button.dart';
import '../../widget/mfm.dart';
import '../../widget/time_widget.dart';
import '../../widget/user_preview.dart';
import '../../widget/user_sheet.dart';

class GalleryPostPage extends ConsumerWidget {
const GalleryPostPage({
Expand Down Expand Up @@ -197,6 +198,11 @@ class GalleryPostPage extends ConsumerWidget {
avatarSize: 50.0,
trailing: FollowButton(account: account, userId: post.userId),
onTap: () => context.push('/$account/users/${post.user.id}'),
onLongPress: () => showUserSheet(
context: context,
account: account,
userId: post.user.id,
),
),
const Divider(),
Padding(
Expand Down
11 changes: 11 additions & 0 deletions lib/view/page/page/page_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import '../../widget/time_widget.dart';
import '../../widget/url_preview.dart';
import '../../widget/user_avatar.dart';
import '../../widget/user_preview.dart';
import '../../widget/user_sheet.dart';
import '../../widget/username_widget.dart';

class PagePage extends ConsumerWidget {
Expand Down Expand Up @@ -249,6 +250,11 @@ class PagePage extends ConsumerWidget {
user: page.user,
onTap: () => context
.push('/$account/users/${page.userId}'),
onLongPress: () => showUserSheet(
context: context,
account: account,
userId: page.userId,
),
),
),
),
Expand Down Expand Up @@ -351,6 +357,11 @@ class PagePage extends ConsumerWidget {
FollowButton(account: account, userId: page.userId),
onTap: () =>
context.push('/$account/users/${page.user.id}'),
onLongPress: () => showUserSheet(
context: context,
account: account,
userId: page.user.id,
),
),
),
ColoredBox(
Expand Down
8 changes: 8 additions & 0 deletions lib/view/page/play/play_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import '../../widget/mfm/code.dart';
import '../../widget/play_widget.dart';
import '../../widget/time_widget.dart';
import '../../widget/user_preview.dart';
import '../../widget/user_sheet.dart';

class PlayPage extends HookConsumerWidget {
const PlayPage({
Expand Down Expand Up @@ -143,6 +144,13 @@ class PlayPage extends HookConsumerWidget {
? '/${this.account}/users/${play.userId}'
: '/${account.value}/@${play.user.username}@${this.account.host}',
),
onLongPress: this.account == account.value
? () => showUserSheet(
context: context,
account: this.account,
userId: play.userId,
)
: null,
),
const Divider(),
DefaultTextStyle.merge(
Expand Down
6 changes: 6 additions & 0 deletions lib/view/page/settings/blocked_users_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import '../../widget/acct_widget.dart';
import '../../widget/paginated_list_view.dart';
import '../../widget/time_widget.dart';
import '../../widget/user_avatar.dart';
import '../../widget/user_sheet.dart';
import '../../widget/username_widget.dart';

class BlockedUsersPage extends ConsumerWidget {
Expand Down Expand Up @@ -57,6 +58,11 @@ class BlockedUsersPage extends ConsumerWidget {
color: Theme.of(context).colorScheme.error,
),
onTap: () => context.push('/$account/users/${blocking.blockeeId}'),
onLongPress: () => showUserSheet(
context: context,
account: account,
userId: blocking.blockeeId,
),
),
onRefresh: () => ref.refresh(blockingsNotifierProvider(account).future),
loadMore: (skipError) => ref
Expand Down
6 changes: 6 additions & 0 deletions lib/view/page/settings/muted_users_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import '../../widget/acct_widget.dart';
import '../../widget/paginated_list_view.dart';
import '../../widget/time_widget.dart';
import '../../widget/user_avatar.dart';
import '../../widget/user_sheet.dart';
import '../../widget/username_widget.dart';

class MutedUsersPage extends ConsumerWidget {
Expand Down Expand Up @@ -60,6 +61,11 @@ class MutedUsersPage extends ConsumerWidget {
color: Theme.of(context).colorScheme.error,
),
onTap: () => context.push('/$account/users/${muting.muteeId}'),
onLongPress: () => showUserSheet(
context: context,
account: account,
userId: muting.muteeId,
),
),
onRefresh: () => ref.refresh(mutingsNotifierProvider(account).future),
loadMore: (skipError) => ref
Expand Down
6 changes: 6 additions & 0 deletions lib/view/page/settings/renote_muted_users_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import '../../widget/acct_widget.dart';
import '../../widget/paginated_list_view.dart';
import '../../widget/time_widget.dart';
import '../../widget/user_avatar.dart';
import '../../widget/user_sheet.dart';
import '../../widget/username_widget.dart';

class RenoteMutedUsersPage extends ConsumerWidget {
Expand Down Expand Up @@ -61,6 +62,11 @@ class RenoteMutedUsersPage extends ConsumerWidget {
color: Theme.of(context).colorScheme.error,
),
onTap: () => context.push('/$account/users/${renoteMuting.muteeId}'),
onLongPress: () => showUserSheet(
context: context,
account: account,
userId: renoteMuting.muteeId,
),
),
onRefresh: () =>
ref.refresh(renoteMutingsNotifierProvider(account).future),
Expand Down
6 changes: 6 additions & 0 deletions lib/view/page/user/user_list_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import '../../dialog/text_field_dialog.dart';
import '../../widget/error_message.dart';
import '../../widget/like_button.dart';
import '../../widget/user_preview.dart';
import '../../widget/user_sheet.dart';

class UserListPage extends HookConsumerWidget {
const UserListPage({
Expand Down Expand Up @@ -67,6 +68,11 @@ class UserListPage extends HookConsumerWidget {
user: user,
onTap: () =>
context.push('/$account/users/${user.id}'),
onLongPress: () => showUserSheet(
context: context,
account: account,
userId: user.id,
),
),
),
),
Expand Down
12 changes: 4 additions & 8 deletions lib/view/page/user/user_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,11 @@ class UserPage extends HookConsumerWidget {
actions: [
if (userId != null)
IconButton(
onPressed: () => showModalBottomSheet<void>(
onPressed: () => showUserSheet(
context: context,
builder: (context) => UserSheet(
account: account,
userId: userId,
hideDetails: true,
),
clipBehavior: Clip.hardEdge,
isScrollControlled: true,
account: account,
userId: userId,
disableHeader: true,
),
icon: const Icon(Icons.more_vert),
),
Expand Down
1 change: 1 addition & 0 deletions lib/view/widget/drive_file_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class DriveFileWidget extends ConsumerWidget {
account: account,
file: file,
),
clipBehavior: Clip.antiAlias,
),
icon: const Icon(Icons.more_vert),
),
Expand Down
12 changes: 7 additions & 5 deletions lib/view/widget/follow_requests_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import '../../util/future_with_dialog.dart';
import 'acct_widget.dart';
import 'pagination_bottom_widget.dart';
import 'user_avatar.dart';
import 'user_sheet.dart';
import 'username_widget.dart';

class FollowRequestsListView extends HookConsumerWidget {
Expand Down Expand Up @@ -226,6 +227,11 @@ class FollowRequestTile extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
return InkWell(
onTap: () => context.push('/$account/users/${user.id}'),
onLongPress: () => showUserSheet(
context: context,
account: account,
userId: user.id,
),
child: Row(
children: [
Padding(
Expand All @@ -245,11 +251,7 @@ class FollowRequestTile extends ConsumerWidget {
children: [
DefaultTextStyle.merge(
style: const TextStyle(fontWeight: FontWeight.bold),
child: UsernameWidget(
account: account,
user: user,
onTap: () => context.push('/$account/users/${user.id}'),
),
child: UsernameWidget(account: account, user: user),
),
AcctWidget(account: account, user: user),
],
Expand Down
7 changes: 7 additions & 0 deletions lib/view/widget/gallery_post_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'image_widget.dart';
import 'mfm.dart';
import 'time_widget.dart';
import 'user_avatar.dart';
import 'user_sheet.dart';
import 'username_widget.dart';

class GalleryPostPreview extends HookConsumerWidget {
Expand Down Expand Up @@ -149,10 +150,16 @@ class GalleryPostPreview extends HookConsumerWidget {
user: post.user,
onTap: () => context.push('/$account/users/${post.userId}'),
),
const SizedBox(width: 2.0),
UsernameWidget(
account: account,
user: post.user,
onTap: () => context.push('/$account/users/${post.userId}'),
onLongPress: () => showUserSheet(
context: context,
account: account,
userId: post.userId,
),
),
],
),
Expand Down
24 changes: 17 additions & 7 deletions lib/view/widget/note_detailed_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import 'renote_header.dart';
import 'time_widget.dart';
import 'url_preview.dart';
import 'user_avatar.dart';
import 'user_sheet.dart';
import 'username_widget.dart';

class NoteDetailedWidget extends HookConsumerWidget {
Expand Down Expand Up @@ -269,6 +270,11 @@ class NoteDetailedWidget extends HookConsumerWidget {
onTap: () => context.push(
'/$account/users/${appearNote.userId}',
),
onLongPress: () => showUserSheet(
context: context,
account: account,
userId: appearNote.userId,
),
),
),
if (appearNote.user.isBot)
Expand Down Expand Up @@ -309,12 +315,16 @@ class NoteDetailedWidget extends HookConsumerWidget {
user: appearNote.user,
),
if (showTicker)
DefaultTextStyle.merge(
style: style.apply(fontSizeFactor: 0.9),
child: InstanceTickerWidget(
account: account,
instance: appearNote.user.instance,
host: appearNote.user.host,
Padding(
padding:
const EdgeInsets.symmetric(vertical: 2.0),
child: DefaultTextStyle.merge(
style: style.apply(fontSizeFactor: 0.9),
child: InstanceTickerWidget(
account: account,
instance: appearNote.user.instance,
host: appearNote.user.host,
),
),
),
],
Expand Down Expand Up @@ -514,7 +524,7 @@ class NoteDetailedWidget extends HookConsumerWidget {
NoteFooter(
account: account,
noteId: noteId,
hideDetails: true,
disableHeader: true,
),
if (children
case AsyncValue(
Expand Down
Loading

0 comments on commit 461808c

Please sign in to comment.