💄 Shows friends overview on mobile as well

This commit is contained in:
2025-11-16 18:10:55 +08:00
parent d93b066979
commit d94f8d004f
2 changed files with 48 additions and 18 deletions

View File

@@ -542,6 +542,11 @@ class ExploreScreen extends HookConsumerWidget {
child: PostFeaturedList(), child: PostFeaturedList(),
), ),
), ),
SliverToBoxAdapter(
child: FriendsOverviewWidget(
padding: const EdgeInsets.only(bottom: 8),
),
),
if (notificationCount.value != null && if (notificationCount.value != null &&
notificationCount.value! > 0) notificationCount.value! > 0)
SliverToBoxAdapter( SliverToBoxAdapter(

View File

@@ -24,7 +24,14 @@ Future<List<SnFriendOverviewItem>> friendsOverview(Ref ref) async {
} }
class FriendsOverviewWidget extends HookConsumerWidget { class FriendsOverviewWidget extends HookConsumerWidget {
const FriendsOverviewWidget({super.key}); final bool hideWhenEmpty;
final EdgeInsetsGeometry? padding;
const FriendsOverviewWidget({
super.key,
this.hideWhenEmpty = false,
this.padding,
});
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
@@ -45,11 +52,11 @@ class FriendsOverviewWidget extends HookConsumerWidget {
final onlineFriends = final onlineFriends =
friends.where((friend) => friend.status.isOnline).toList(); friends.where((friend) => friend.status.isOnline).toList();
if (onlineFriends.isEmpty) { if (onlineFriends.isEmpty && hideWhenEmpty) {
return const SizedBox.shrink(); // Hide if no online friends return const SizedBox.shrink();
} }
return Card( final card = Card(
margin: EdgeInsets.zero, margin: EdgeInsets.zero,
child: Column( child: Column(
children: [ children: [
@@ -57,24 +64,42 @@ class FriendsOverviewWidget extends HookConsumerWidget {
spacing: 8, spacing: 8,
children: [const Icon(Symbols.group), Text('Friends Online')], children: [const Icon(Symbols.group), Text('Friends Online')],
).padding(horizontal: 16).height(48), ).padding(horizontal: 16).height(48),
SizedBox( if (onlineFriends.isEmpty)
height: 80, Container(
child: ListView.builder( height: 80,
padding: const EdgeInsets.fromLTRB(8, 0, 8, 4), padding: const EdgeInsets.symmetric(horizontal: 16),
scrollDirection: Axis.horizontal, child: const Center(
itemCount: onlineFriends.length, child: Text(
itemBuilder: (context, index) { 'No friends online',
final friend = onlineFriends[index]; style: TextStyle(fontSize: 14, color: Colors.grey),
return AccountPfcGestureDetector( ),
uname: friend.account.name, ),
child: _FriendTile(friend: friend), )
); else
}, SizedBox(
height: 80,
child: ListView.builder(
padding: const EdgeInsets.fromLTRB(8, 0, 8, 4),
scrollDirection: Axis.horizontal,
itemCount: onlineFriends.length,
itemBuilder: (context, index) {
final friend = onlineFriends[index];
return AccountPfcGestureDetector(
uname: friend.account.name,
child: _FriendTile(friend: friend),
);
},
),
), ),
),
], ],
), ),
); );
Widget result = card;
if (padding != null) {
result = Padding(padding: padding!, child: result);
}
return result;
}, },
loading: loading:
() => const SizedBox( () => const SizedBox(