💄 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,6 +64,18 @@ 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),
if (onlineFriends.isEmpty)
Container(
height: 80,
padding: const EdgeInsets.symmetric(horizontal: 16),
child: const Center(
child: Text(
'No friends online',
style: TextStyle(fontSize: 14, color: Colors.grey),
),
),
)
else
SizedBox( SizedBox(
height: 80, height: 80,
child: ListView.builder( child: ListView.builder(
@@ -75,6 +94,12 @@ class FriendsOverviewWidget extends HookConsumerWidget {
], ],
), ),
); );
Widget result = card;
if (padding != null) {
result = Padding(padding: padding!, child: result);
}
return result;
}, },
loading: loading:
() => const SizedBox( () => const SizedBox(