Compare commits
2 Commits
9d03faf594
...
504e4d55ad
| Author | SHA1 | Date | |
|---|---|---|---|
|
504e4d55ad
|
|||
|
38a15bb62a
|
@@ -26,6 +26,7 @@ import 'package:island/widgets/navigation/fab_menu.dart';
|
|||||||
import 'package:island/widgets/paging/pagination_list.dart';
|
import 'package:island/widgets/paging/pagination_list.dart';
|
||||||
import 'package:island/widgets/post/post_featured.dart';
|
import 'package:island/widgets/post/post_featured.dart';
|
||||||
import 'package:island/widgets/post/post_item.dart';
|
import 'package:island/widgets/post/post_item.dart';
|
||||||
|
import 'package:island/widgets/post/post_item_skeleton.dart';
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
import 'package:island/widgets/realm/realm_card.dart';
|
import 'package:island/widgets/realm/realm_card.dart';
|
||||||
import 'package:island/widgets/publisher/publisher_card.dart';
|
import 'package:island/widgets/publisher/publisher_card.dart';
|
||||||
@@ -137,8 +138,7 @@ class ExploreScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
tooltip: 'explore'.tr(),
|
tooltip: 'explore'.tr(),
|
||||||
isSelected: currentFilter.value == null,
|
isSelected: currentFilter.value == null,
|
||||||
color:
|
color: currentFilter.value == null
|
||||||
currentFilter.value == null
|
|
||||||
? Theme.of(context).colorScheme.primary
|
? Theme.of(context).colorScheme.primary
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
@@ -150,8 +150,7 @@ class ExploreScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
tooltip: 'exploreFilterSubscriptions'.tr(),
|
tooltip: 'exploreFilterSubscriptions'.tr(),
|
||||||
isSelected: currentFilter.value == 'subscriptions',
|
isSelected: currentFilter.value == 'subscriptions',
|
||||||
color:
|
color: currentFilter.value == 'subscriptions'
|
||||||
currentFilter.value == 'subscriptions'
|
|
||||||
? Theme.of(context).colorScheme.primary
|
? Theme.of(context).colorScheme.primary
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
@@ -163,8 +162,7 @@ class ExploreScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
tooltip: 'exploreFilterFriends'.tr(),
|
tooltip: 'exploreFilterFriends'.tr(),
|
||||||
isSelected: currentFilter.value == 'friends',
|
isSelected: currentFilter.value == 'friends',
|
||||||
color:
|
color: currentFilter.value == 'friends'
|
||||||
currentFilter.value == 'friends'
|
|
||||||
? Theme.of(context).colorScheme.primary
|
? Theme.of(context).colorScheme.primary
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
@@ -179,8 +177,7 @@ class ExploreScreen extends HookConsumerWidget {
|
|||||||
tooltip: 'webArticlesStand'.tr(),
|
tooltip: 'webArticlesStand'.tr(),
|
||||||
),
|
),
|
||||||
PopupMenuButton(
|
PopupMenuButton(
|
||||||
itemBuilder:
|
itemBuilder: (context) => [
|
||||||
(context) => [
|
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -237,8 +234,7 @@ class ExploreScreen extends HookConsumerWidget {
|
|||||||
).padding(horizontal: 8, vertical: 4),
|
).padding(horizontal: 8, vertical: 4),
|
||||||
);
|
);
|
||||||
|
|
||||||
final appBar =
|
final appBar = isWide
|
||||||
isWide
|
|
||||||
? null
|
? null
|
||||||
: _buildAppBar(currentFilter.value, handleFilterChange, context);
|
: _buildAppBar(currentFilter.value, handleFilterChange, context);
|
||||||
|
|
||||||
@@ -263,8 +259,7 @@ class ExploreScreen extends HookConsumerWidget {
|
|||||||
AppScaffold(
|
AppScaffold(
|
||||||
isNoBackground: false,
|
isNoBackground: false,
|
||||||
appBar: appBar,
|
appBar: appBar,
|
||||||
body:
|
body: isWide
|
||||||
isWide
|
|
||||||
? _buildWideBody(
|
? _buildWideBody(
|
||||||
context,
|
context,
|
||||||
ref,
|
ref,
|
||||||
@@ -295,9 +290,8 @@ class ExploreScreen extends HookConsumerWidget {
|
|||||||
const Gap(16),
|
const Gap(16),
|
||||||
Text(
|
Text(
|
||||||
'dropToShare'.tr(),
|
'dropToShare'.tr(),
|
||||||
style: Theme.of(
|
style: Theme.of(context).textTheme.headlineMedium
|
||||||
context,
|
?.copyWith(
|
||||||
).textTheme.headlineMedium?.copyWith(
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
@@ -321,8 +315,8 @@ class ExploreScreen extends HookConsumerWidget {
|
|||||||
// Sliver list cannot provide refresh handled by the pagination list
|
// Sliver list cannot provide refresh handled by the pagination list
|
||||||
isRefreshable: false,
|
isRefreshable: false,
|
||||||
isSliver: true,
|
isSliver: true,
|
||||||
contentBuilder:
|
footerSkeletonChild: const PostItemSkeleton(),
|
||||||
(data, footer) =>
|
contentBuilder: (data, footer) =>
|
||||||
_ActivityListView(data: data, isWide: isWide, footer: footer),
|
_ActivityListView(data: data, isWide: isWide, footer: footer),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -393,8 +387,7 @@ class ExploreScreen extends HookConsumerWidget {
|
|||||||
else
|
else
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child:
|
child: Column(
|
||||||
Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@@ -491,8 +484,7 @@ class ExploreScreen extends HookConsumerWidget {
|
|||||||
tooltip: 'webArticlesStand'.tr(),
|
tooltip: 'webArticlesStand'.tr(),
|
||||||
),
|
),
|
||||||
PopupMenuButton(
|
PopupMenuButton(
|
||||||
itemBuilder:
|
itemBuilder: (context) => [
|
||||||
(context) => [
|
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'dart:math' as math;
|
|||||||
|
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:island/models/account.dart';
|
import 'package:island/models/account.dart';
|
||||||
@@ -10,7 +11,6 @@ import 'package:island/pods/network.dart';
|
|||||||
import 'package:island/pods/paging.dart';
|
import 'package:island/pods/paging.dart';
|
||||||
import 'package:island/pods/websocket.dart';
|
import 'package:island/pods/websocket.dart';
|
||||||
import 'package:island/route.dart';
|
import 'package:island/route.dart';
|
||||||
import 'package:island/widgets/alert.dart';
|
|
||||||
import 'package:island/widgets/content/cloud_files.dart';
|
import 'package:island/widgets/content/cloud_files.dart';
|
||||||
import 'package:island/widgets/content/markdown.dart';
|
import 'package:island/widgets/content/markdown.dart';
|
||||||
import 'package:island/widgets/content/sheet.dart';
|
import 'package:island/widgets/content/sheet.dart';
|
||||||
@@ -101,8 +101,7 @@ class NotificationListNotifier extends AsyncNotifier<List<SnNotification>>
|
|||||||
queryParameters: queryParams,
|
queryParameters: queryParams,
|
||||||
);
|
);
|
||||||
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
|
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
|
||||||
final notifications =
|
final notifications = response.data
|
||||||
response.data
|
|
||||||
.map((json) => SnNotification.fromJson(json))
|
.map((json) => SnNotification.fromJson(json))
|
||||||
.cast<SnNotification>()
|
.cast<SnNotification>()
|
||||||
.toList();
|
.toList();
|
||||||
@@ -145,15 +144,22 @@ class NotificationSheet extends HookConsumerWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
// Refresh unread count when sheet opens to sync across devices
|
// Refresh unread count when sheet opens to sync across devices
|
||||||
|
useEffect(() {
|
||||||
|
Future(() {
|
||||||
ref.read(notificationUnreadCountProvider.notifier).refresh();
|
ref.read(notificationUnreadCountProvider.notifier).refresh();
|
||||||
|
});
|
||||||
|
return null;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
final isLoading = useState(false);
|
||||||
|
|
||||||
Future<void> markAllRead() async {
|
Future<void> markAllRead() async {
|
||||||
showLoadingModal(context);
|
isLoading.value = true;
|
||||||
final apiClient = ref.watch(apiClientProvider);
|
final apiClient = ref.watch(apiClientProvider);
|
||||||
await apiClient.post('/ring/notifications/all/read');
|
await apiClient.post('/ring/notifications/all/read');
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
hideLoadingModal(context);
|
isLoading.value = false;
|
||||||
ref.invalidate(notificationListProvider);
|
ref.read(notificationListProvider.notifier).refresh();
|
||||||
ref.watch(notificationUnreadCountProvider.notifier).clear();
|
ref.watch(notificationUnreadCountProvider.notifier).clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,6 +171,14 @@ class NotificationSheet extends HookConsumerWidget {
|
|||||||
icon: const Icon(Symbols.mark_as_unread),
|
icon: const Icon(Symbols.mark_as_unread),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
if (isLoading.value)
|
||||||
|
LinearProgressIndicator(
|
||||||
|
minHeight: 2,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
child: PaginationList(
|
child: PaginationList(
|
||||||
provider: notificationListProvider,
|
provider: notificationListProvider,
|
||||||
notifier: notificationListProvider.notifier,
|
notifier: notificationListProvider.notifier,
|
||||||
@@ -175,16 +189,21 @@ class NotificationSheet extends HookConsumerWidget {
|
|||||||
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
isThreeLine: true,
|
isThreeLine: true,
|
||||||
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
contentPadding: EdgeInsets.symmetric(
|
||||||
leading:
|
horizontal: 16,
|
||||||
pfp != null
|
vertical: 8,
|
||||||
|
),
|
||||||
|
leading: pfp != null
|
||||||
? ProfilePictureWidget(fileId: pfp, radius: 20)
|
? ProfilePictureWidget(fileId: pfp, radius: 20)
|
||||||
: CircleAvatar(
|
: CircleAvatar(
|
||||||
backgroundColor:
|
backgroundColor: Theme.of(
|
||||||
Theme.of(context).colorScheme.primaryContainer,
|
context,
|
||||||
|
).colorScheme.primaryContainer,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
_getNotificationIcon(notification.topic),
|
_getNotificationIcon(notification.topic),
|
||||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
color: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.onPrimaryContainer,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
title: Text(notification.title),
|
title: Text(notification.title),
|
||||||
@@ -197,7 +216,9 @@ class NotificationSheet extends HookConsumerWidget {
|
|||||||
spacing: 6,
|
spacing: 6,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
DateFormat().format(notification.createdAt.toLocal()),
|
DateFormat().format(
|
||||||
|
notification.createdAt.toLocal(),
|
||||||
|
),
|
||||||
).fontSize(11),
|
).fontSize(11),
|
||||||
Text('·').fontSize(11).bold(),
|
Text('·').fontSize(11).bold(),
|
||||||
Text(
|
Text(
|
||||||
@@ -209,7 +230,8 @@ class NotificationSheet extends HookConsumerWidget {
|
|||||||
).opacity(0.75).padding(bottom: 4),
|
).opacity(0.75).padding(bottom: 4),
|
||||||
MarkdownTextContent(
|
MarkdownTextContent(
|
||||||
content: notification.content,
|
content: notification.content,
|
||||||
textStyle: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
textStyle: Theme.of(context).textTheme.bodyMedium
|
||||||
|
?.copyWith(
|
||||||
color: Theme.of(
|
color: Theme.of(
|
||||||
context,
|
context,
|
||||||
).colorScheme.onSurface.withOpacity(0.8),
|
).colorScheme.onSurface.withOpacity(0.8),
|
||||||
@@ -221,8 +243,7 @@ class NotificationSheet extends HookConsumerWidget {
|
|||||||
child: Wrap(
|
child: Wrap(
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
runSpacing: 8,
|
runSpacing: 8,
|
||||||
children:
|
children: imageIds.map((imageId) {
|
||||||
imageIds.map((imageId) {
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: 80,
|
width: 80,
|
||||||
height: 80,
|
height: 80,
|
||||||
@@ -240,8 +261,7 @@ class NotificationSheet extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
trailing:
|
trailing: notification.viewedAt != null
|
||||||
notification.viewedAt != null
|
|
||||||
? null
|
? null
|
||||||
: Container(
|
: Container(
|
||||||
width: 12,
|
width: 12,
|
||||||
@@ -268,6 +288,9 @@ class NotificationSheet extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:flutter_riverpod/misc.dart';
|
import 'package:flutter_riverpod/misc.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:island/pods/paging.dart';
|
import 'package:island/pods/paging.dart';
|
||||||
@@ -7,6 +8,7 @@ import 'package:island/widgets/extended_refresh_indicator.dart';
|
|||||||
import 'package:island/widgets/response.dart';
|
import 'package:island/widgets/response.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
import 'package:skeletonizer/skeletonizer.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
import 'package:super_sliver_list/super_sliver_list.dart';
|
import 'package:super_sliver_list/super_sliver_list.dart';
|
||||||
import 'package:visibility_detector/visibility_detector.dart';
|
import 'package:visibility_detector/visibility_detector.dart';
|
||||||
@@ -19,6 +21,7 @@ class PaginationList<T> extends HookConsumerWidget {
|
|||||||
final bool isSliver;
|
final bool isSliver;
|
||||||
final bool showDefaultWidgets;
|
final bool showDefaultWidgets;
|
||||||
final EdgeInsets? padding;
|
final EdgeInsets? padding;
|
||||||
|
final Widget? footerSkeletonChild;
|
||||||
const PaginationList({
|
const PaginationList({
|
||||||
super.key,
|
super.key,
|
||||||
required this.provider,
|
required this.provider,
|
||||||
@@ -28,6 +31,7 @@ class PaginationList<T> extends HookConsumerWidget {
|
|||||||
this.isSliver = false,
|
this.isSliver = false,
|
||||||
this.showDefaultWidgets = true,
|
this.showDefaultWidgets = true,
|
||||||
this.padding,
|
this.padding,
|
||||||
|
this.footerSkeletonChild,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -48,13 +52,16 @@ class PaginationList<T> extends HookConsumerWidget {
|
|||||||
return isSliver ? SliverFillRemaining(child: content) : content;
|
return isSliver ? SliverFillRemaining(child: content) : content;
|
||||||
}
|
}
|
||||||
|
|
||||||
final listView =
|
final listView = isSliver
|
||||||
isSliver
|
|
||||||
? SuperSliverList.builder(
|
? SuperSliverList.builder(
|
||||||
itemCount: (data.value?.length ?? 0) + 1,
|
itemCount: (data.value?.length ?? 0) + 1,
|
||||||
itemBuilder: (context, idx) {
|
itemBuilder: (context, idx) {
|
||||||
if (idx == data.value?.length) {
|
if (idx == data.value?.length) {
|
||||||
return PaginationListFooter(noti: noti, data: data);
|
return PaginationListFooter(
|
||||||
|
noti: noti,
|
||||||
|
data: data,
|
||||||
|
skeletonChild: footerSkeletonChild,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
final entry = data.value?[idx];
|
final entry = data.value?[idx];
|
||||||
if (entry != null) return itemBuilder(context, idx, entry);
|
if (entry != null) return itemBuilder(context, idx, entry);
|
||||||
@@ -66,7 +73,11 @@ class PaginationList<T> extends HookConsumerWidget {
|
|||||||
itemCount: (data.value?.length ?? 0) + 1,
|
itemCount: (data.value?.length ?? 0) + 1,
|
||||||
itemBuilder: (context, idx) {
|
itemBuilder: (context, idx) {
|
||||||
if (idx == data.value?.length) {
|
if (idx == data.value?.length) {
|
||||||
return PaginationListFooter(noti: noti, data: data);
|
return PaginationListFooter(
|
||||||
|
noti: noti,
|
||||||
|
data: data,
|
||||||
|
skeletonChild: footerSkeletonChild,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
final entry = data.value?[idx];
|
final entry = data.value?[idx];
|
||||||
if (entry != null) return itemBuilder(context, idx, entry);
|
if (entry != null) return itemBuilder(context, idx, entry);
|
||||||
@@ -87,6 +98,7 @@ class PaginationWidget<T> extends HookConsumerWidget {
|
|||||||
final bool isRefreshable;
|
final bool isRefreshable;
|
||||||
final bool isSliver;
|
final bool isSliver;
|
||||||
final bool showDefaultWidgets;
|
final bool showDefaultWidgets;
|
||||||
|
final Widget? footerSkeletonChild;
|
||||||
const PaginationWidget({
|
const PaginationWidget({
|
||||||
super.key,
|
super.key,
|
||||||
required this.provider,
|
required this.provider,
|
||||||
@@ -95,6 +107,7 @@ class PaginationWidget<T> extends HookConsumerWidget {
|
|||||||
this.isRefreshable = true,
|
this.isRefreshable = true,
|
||||||
this.isSliver = false,
|
this.isSliver = false,
|
||||||
this.showDefaultWidgets = true,
|
this.showDefaultWidgets = true,
|
||||||
|
this.footerSkeletonChild,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -115,7 +128,11 @@ class PaginationWidget<T> extends HookConsumerWidget {
|
|||||||
return isSliver ? SliverFillRemaining(child: content) : content;
|
return isSliver ? SliverFillRemaining(child: content) : content;
|
||||||
}
|
}
|
||||||
|
|
||||||
final footer = PaginationListFooter(noti: noti, data: data);
|
final footer = PaginationListFooter(
|
||||||
|
noti: noti,
|
||||||
|
data: data,
|
||||||
|
skeletonChild: footerSkeletonChild,
|
||||||
|
);
|
||||||
final content = contentBuilder(data.value ?? [], footer);
|
final content = contentBuilder(data.value ?? [], footer);
|
||||||
|
|
||||||
return isRefreshable
|
return isRefreshable
|
||||||
@@ -124,26 +141,37 @@ class PaginationWidget<T> extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PaginationListFooter<T> extends StatelessWidget {
|
class PaginationListFooter<T> extends HookConsumerWidget {
|
||||||
final PaginationController<T> noti;
|
final PaginationController<T> noti;
|
||||||
final AsyncValue<List<T>> data;
|
final AsyncValue<List<T>> data;
|
||||||
|
final Widget? skeletonChild;
|
||||||
final bool isSliver;
|
final bool isSliver;
|
||||||
|
|
||||||
const PaginationListFooter({
|
const PaginationListFooter({
|
||||||
super.key,
|
super.key,
|
||||||
required this.noti,
|
required this.noti,
|
||||||
required this.data,
|
required this.data,
|
||||||
|
this.skeletonChild,
|
||||||
this.isSliver = false,
|
this.isSliver = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final child = SizedBox(
|
final hasBeenVisible = useState(false);
|
||||||
height: 64,
|
|
||||||
child: Center(
|
final placeholder = Skeletonizer(
|
||||||
|
enabled: true,
|
||||||
child:
|
child:
|
||||||
data.isLoading
|
skeletonChild ??
|
||||||
? CircularProgressIndicator()
|
ListTile(
|
||||||
|
title: Text('Some data'),
|
||||||
|
subtitle: const Text('Subtitle here'),
|
||||||
|
trailing: const Icon(Icons.ac_unit),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final child = hasBeenVisible.value
|
||||||
|
? data.isLoading
|
||||||
|
? placeholder
|
||||||
: Row(
|
: Row(
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
@@ -151,13 +179,13 @@ class PaginationListFooter<T> extends StatelessWidget {
|
|||||||
const Icon(Symbols.close, size: 16),
|
const Icon(Symbols.close, size: 16),
|
||||||
Text('noFurtherData').tr().fontSize(13),
|
Text('noFurtherData').tr().fontSize(13),
|
||||||
],
|
],
|
||||||
).opacity(0.9),
|
).opacity(0.9).height(64).center()
|
||||||
).padding(all: 8),
|
: placeholder;
|
||||||
);
|
|
||||||
|
|
||||||
return VisibilityDetector(
|
return VisibilityDetector(
|
||||||
key: Key("pagination-list-${noti.hashCode}"),
|
key: Key("pagination-list-${noti.hashCode}"),
|
||||||
onVisibilityChanged: (VisibilityInfo info) {
|
onVisibilityChanged: (VisibilityInfo info) {
|
||||||
|
hasBeenVisible.value = true;
|
||||||
if (!noti.fetchedAll && !data.isLoading && !data.hasError) {
|
if (!noti.fetchedAll && !data.isLoading && !data.hasError) {
|
||||||
noti.fetchFurther();
|
noti.fetchFurther();
|
||||||
}
|
}
|
||||||
|
|||||||
427
lib/widgets/post/post_item_skeleton.dart
Normal file
427
lib/widgets/post/post_item_skeleton.dart
Normal file
@@ -0,0 +1,427 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gap/gap.dart';
|
||||||
|
import 'package:skeletonizer/skeletonizer.dart';
|
||||||
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
|
||||||
|
class PostItemSkeleton extends StatelessWidget {
|
||||||
|
final EdgeInsets? padding;
|
||||||
|
final bool isFullPost;
|
||||||
|
final bool isShowReference;
|
||||||
|
final bool isEmbedReply;
|
||||||
|
final bool isCompact;
|
||||||
|
final double? borderRadius;
|
||||||
|
|
||||||
|
const PostItemSkeleton({
|
||||||
|
super.key,
|
||||||
|
this.padding,
|
||||||
|
this.isFullPost = false,
|
||||||
|
this.isShowReference = false,
|
||||||
|
this.isEmbedReply = false,
|
||||||
|
this.isCompact = false,
|
||||||
|
this.borderRadius,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final renderingPadding =
|
||||||
|
padding ?? const EdgeInsets.symmetric(horizontal: 8, vertical: 8);
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Gap(renderingPadding.vertical),
|
||||||
|
_PostHeaderSkeleton(
|
||||||
|
isFullPost: isFullPost,
|
||||||
|
isCompact: isCompact,
|
||||||
|
renderingPadding: renderingPadding,
|
||||||
|
),
|
||||||
|
_PostBodySkeleton(
|
||||||
|
isFullPost: isFullPost,
|
||||||
|
renderingPadding: renderingPadding,
|
||||||
|
),
|
||||||
|
if (isShowReference)
|
||||||
|
_ReferencedPostWidgetSkeleton(renderingPadding: renderingPadding),
|
||||||
|
if (isEmbedReply)
|
||||||
|
_PostReplyPreviewSkeleton(
|
||||||
|
renderingPadding: renderingPadding,
|
||||||
|
).padding(horizontal: renderingPadding.horizontal, top: 8),
|
||||||
|
Gap(renderingPadding.vertical),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PostHeaderSkeleton extends StatelessWidget {
|
||||||
|
final bool isFullPost;
|
||||||
|
final bool isCompact;
|
||||||
|
final EdgeInsets renderingPadding;
|
||||||
|
|
||||||
|
const _PostHeaderSkeleton({
|
||||||
|
required this.isFullPost,
|
||||||
|
required this.isCompact,
|
||||||
|
required this.renderingPadding,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Skeletonizer(
|
||||||
|
enabled: true,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
spacing: 12,
|
||||||
|
children: [
|
||||||
|
// Profile picture skeleton
|
||||||
|
Container(
|
||||||
|
width: 32,
|
||||||
|
height: 32,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
spacing: 4,
|
||||||
|
children: [
|
||||||
|
// Name skeleton
|
||||||
|
Container(
|
||||||
|
height: 16,
|
||||||
|
width: 120,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.surfaceContainer,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (!isCompact)
|
||||||
|
Container(
|
||||||
|
height: 12,
|
||||||
|
width: 80,
|
||||||
|
margin: const EdgeInsets.only(left: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.surfaceContainer,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const Gap(4),
|
||||||
|
// Timestamp skeleton
|
||||||
|
Container(
|
||||||
|
height: 12,
|
||||||
|
width: 60,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Reaction button skeleton
|
||||||
|
if (!isCompact)
|
||||||
|
Container(
|
||||||
|
width: 36,
|
||||||
|
height: 36,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
borderRadius: BorderRadius.circular(18),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).padding(horizontal: renderingPadding.horizontal, bottom: 4),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PostBodySkeleton extends StatelessWidget {
|
||||||
|
final bool isFullPost;
|
||||||
|
final EdgeInsets renderingPadding;
|
||||||
|
|
||||||
|
const _PostBodySkeleton({
|
||||||
|
required this.isFullPost,
|
||||||
|
required this.renderingPadding,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Skeletonizer(
|
||||||
|
enabled: true,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// Title skeleton (if applicable)
|
||||||
|
if (isFullPost)
|
||||||
|
Container(
|
||||||
|
height: 20,
|
||||||
|
width: 200,
|
||||||
|
margin: EdgeInsets.only(
|
||||||
|
left: renderingPadding.horizontal,
|
||||||
|
right: renderingPadding.horizontal,
|
||||||
|
bottom: 8,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Content skeleton
|
||||||
|
Container(
|
||||||
|
height: 16,
|
||||||
|
margin: EdgeInsets.only(
|
||||||
|
left: renderingPadding.horizontal,
|
||||||
|
right: renderingPadding.horizontal,
|
||||||
|
bottom: 4,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
height: 16,
|
||||||
|
width: 250,
|
||||||
|
margin: EdgeInsets.only(
|
||||||
|
left: renderingPadding.horizontal,
|
||||||
|
right: renderingPadding.horizontal,
|
||||||
|
bottom: 4,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
height: 16,
|
||||||
|
width: 180,
|
||||||
|
margin: EdgeInsets.only(
|
||||||
|
left: renderingPadding.horizontal,
|
||||||
|
right: renderingPadding.horizontal,
|
||||||
|
bottom: 8,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Metadata skeleton
|
||||||
|
Row(
|
||||||
|
spacing: 8,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 16,
|
||||||
|
height: 16,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
height: 12,
|
||||||
|
width: 80,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).padding(horizontal: renderingPadding.horizontal + 4, top: 4),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ReferencedPostWidgetSkeleton extends StatelessWidget {
|
||||||
|
final EdgeInsets renderingPadding;
|
||||||
|
|
||||||
|
const _ReferencedPostWidgetSkeleton({required this.renderingPadding});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Skeletonizer(
|
||||||
|
enabled: true,
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: renderingPadding.horizontal,
|
||||||
|
vertical: 8,
|
||||||
|
),
|
||||||
|
margin: EdgeInsets.only(
|
||||||
|
top: 8,
|
||||||
|
left: renderingPadding.vertical,
|
||||||
|
right: renderingPadding.vertical,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.5),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(
|
||||||
|
color: Theme.of(context).dividerColor.withOpacity(0.5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 16,
|
||||||
|
height: 16,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Container(
|
||||||
|
height: 12,
|
||||||
|
width: 60,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 32,
|
||||||
|
height: 32,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height: 14,
|
||||||
|
width: 100,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Container(
|
||||||
|
height: 12,
|
||||||
|
width: 150,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Container(
|
||||||
|
height: 12,
|
||||||
|
width: 120,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PostReplyPreviewSkeleton extends StatelessWidget {
|
||||||
|
final EdgeInsets renderingPadding;
|
||||||
|
|
||||||
|
const _PostReplyPreviewSkeleton({required this.renderingPadding});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Skeletonizer(
|
||||||
|
enabled: true,
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainerLow,
|
||||||
|
border: Border.all(
|
||||||
|
color: Theme.of(context).dividerColor.withOpacity(0.5),
|
||||||
|
),
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
spacing: 4,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height: 14,
|
||||||
|
width: 80,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Gap(8),
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
spacing: 8,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 24,
|
||||||
|
height: 24,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height: 12,
|
||||||
|
width: 150,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Container(
|
||||||
|
height: 10,
|
||||||
|
width: 100,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import 'package:island/pods/paging.dart';
|
|||||||
import 'package:island/widgets/paging/pagination_list.dart';
|
import 'package:island/widgets/paging/pagination_list.dart';
|
||||||
import 'package:island/widgets/post/post_item.dart';
|
import 'package:island/widgets/post/post_item.dart';
|
||||||
import 'package:island/widgets/post/post_item_creator.dart';
|
import 'package:island/widgets/post/post_item_creator.dart';
|
||||||
|
import 'package:island/widgets/post/post_item_skeleton.dart';
|
||||||
|
|
||||||
part 'post_list.freezed.dart';
|
part 'post_list.freezed.dart';
|
||||||
|
|
||||||
@@ -159,6 +160,7 @@ class SliverPostList extends HookConsumerWidget {
|
|||||||
notifier: notifier,
|
notifier: notifier,
|
||||||
isRefreshable: false,
|
isRefreshable: false,
|
||||||
isSliver: true,
|
isSliver: true,
|
||||||
|
footerSkeletonChild: const PostItemSkeleton(),
|
||||||
itemBuilder: (context, index, post) {
|
itemBuilder: (context, index, post) {
|
||||||
if (maxWidth != null) {
|
if (maxWidth != null) {
|
||||||
return Center(
|
return Center(
|
||||||
|
|||||||
@@ -2486,6 +2486,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.1"
|
version: "0.2.1"
|
||||||
|
skeletonizer:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: skeletonizer
|
||||||
|
sha256: "5d2d44120916cc749ede54c236cef60c2478742806df0b1f065212f00721b185"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.1"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ dependencies:
|
|||||||
flutter_animate: ^4.5.2
|
flutter_animate: ^4.5.2
|
||||||
http_parser: ^4.1.2
|
http_parser: ^4.1.2
|
||||||
flutter_code_editor: ^0.3.5
|
flutter_code_editor: ^0.3.5
|
||||||
|
skeletonizer: ^2.1.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Reference in New Issue
Block a user