diff --git a/lib/pages/fan/view.dart b/lib/pages/fan/view.dart index c1026758..019e7c95 100644 --- a/lib/pages/fan/view.dart +++ b/lib/pages/fan/view.dart @@ -51,6 +51,7 @@ class _FansPageState extends State { @override Widget build(BuildContext context) { + final theme = Theme.of(context).colorScheme; return Scaffold( resizeToAvoidBottomInset: false, appBar: widget.mid != null @@ -64,7 +65,7 @@ class _FansPageState extends State { slivers: [ ViewSliverSafeArea( sliver: Obx( - () => _buildBody(_fansController.loadingState.value), + () => _buildBody(theme, _fansController.loadingState.value), ), ), ], @@ -78,7 +79,10 @@ class _FansPageState extends State { mainAxisExtent: 66, ); - Widget _buildBody(LoadingState?> loadingState) { + Widget _buildBody( + ColorScheme theme, + LoadingState?> loadingState, + ) { return switch (loadingState) { Loading() => SliverGrid.builder( gridDelegate: gridDelegate, @@ -93,67 +97,7 @@ class _FansPageState extends State { if (index == response.length - 1) { _fansController.onLoadMore(); } - final item = response[index]; - return SizedBox( - height: 66, - child: InkWell( - onTap: () { - if (widget.onSelect != null) { - widget.onSelect!( - UserModel( - mid: item.mid!, - name: item.uname!, - avatar: item.face!, - ), - ); - return; - } - Get.toNamed('/member?mid=${item.mid}'); - }, - onLongPress: widget.onSelect != null - ? null - : isOwner - ? () => showConfirmDialog( - context: context, - title: '确定移除 ${item.uname} ?', - onConfirm: () => - _fansController.onRemoveFan(index, item.mid!), - ) - : null, - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 12, - vertical: 10, - ), - child: Row( - spacing: 10, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - NetworkImgLayer( - width: 45, - height: 45, - type: ImageType.avatar, - src: item.face, - ), - Column( - spacing: 5, - children: [ - Text( - item.uname!, - style: const TextStyle(fontSize: 14), - ), - Text( - item.sign ?? '', - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - ], - ), - ], - ), - ), - ), - ); + return _buildItem(theme, index, response[index]); }, itemCount: response!.length, ) @@ -164,4 +108,68 @@ class _FansPageState extends State { ), }; } + + Widget _buildItem(ColorScheme theme, int index, FansItemModel item) { + return SizedBox( + height: 66, + child: InkWell( + onTap: () { + if (widget.onSelect != null) { + widget.onSelect!( + UserModel( + mid: item.mid!, + name: item.uname!, + avatar: item.face!, + ), + ); + return; + } + Get.toNamed('/member?mid=${item.mid}'); + }, + onLongPress: widget.onSelect != null + ? null + : isOwner + ? () => showConfirmDialog( + context: context, + title: '确定移除 ${item.uname} ?', + onConfirm: () => _fansController.onRemoveFan(index, item.mid!), + ) + : null, + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 10, + ), + child: Row( + spacing: 10, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + NetworkImgLayer( + width: 45, + height: 45, + type: ImageType.avatar, + src: item.face, + ), + Column( + spacing: 4, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + item.uname!, + style: const TextStyle(fontSize: 14), + ), + Text( + item.sign ?? '', + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle(fontSize: 13, color: theme.outline), + ), + ], + ), + ], + ), + ), + ), + ); + } }