mod: refresh

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-03-04 12:06:50 +08:00
parent 5986add7dd
commit 8ef163dd38
8 changed files with 568 additions and 559 deletions

View File

@@ -1,4 +1,5 @@
import 'package:PiliPlus/common/widgets/dialog.dart'; import 'package:PiliPlus/common/widgets/dialog.dart';
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/http/user.dart'; import 'package:PiliPlus/http/user.dart';
import 'package:PiliPlus/models/user/fav_folder.dart'; import 'package:PiliPlus/models/user/fav_folder.dart';
@@ -71,249 +72,274 @@ class _FavDetailPageState extends State<FavDetailPage> {
) )
: const SizedBox.shrink(), : const SizedBox.shrink(),
), ),
body: CustomScrollView( body: refreshIndicator(
physics: const AlwaysScrollableScrollPhysics(), onRefresh: () async {
controller: _favDetailController.scrollController, await _favDetailController.onRefresh();
slivers: [ },
SliverAppBar( child: CustomScrollView(
leading: _favDetailController.enableMultiSelect.value physics: const AlwaysScrollableScrollPhysics(),
? IconButton( controller: _favDetailController.scrollController,
tooltip: '取消', slivers: [
onPressed: _favDetailController.handleSelect, SliverAppBar(
icon: const Icon(Icons.close_outlined), leading: _favDetailController.enableMultiSelect.value
) ? IconButton(
: null, tooltip: '取消',
expandedHeight: 220 - MediaQuery.of(context).padding.top, onPressed: _favDetailController.handleSelect,
pinned: true, icon: const Icon(Icons.close_outlined),
title: _favDetailController.enableMultiSelect.value )
? Text( : null,
'已选: ${_favDetailController.checkedCount.value}', expandedHeight: 220 - MediaQuery.of(context).padding.top,
) pinned: true,
: Obx( title: _favDetailController.enableMultiSelect.value
() => AnimatedOpacity( ? Text(
opacity: _favDetailController.titleCtr.value ? 1 : 0, '已选: ${_favDetailController.checkedCount.value}',
curve: Curves.easeOut, )
duration: const Duration(milliseconds: 500), : Obx(
child: Column( () => AnimatedOpacity(
crossAxisAlignment: CrossAxisAlignment.start, opacity:
children: [ _favDetailController.titleCtr.value ? 1 : 0,
Text( curve: Curves.easeOut,
_favDetailController.item.value.title ?? '', duration: const Duration(milliseconds: 500),
style: Theme.of(context).textTheme.titleMedium, child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
_favDetailController.item.value.title ?? '',
style:
Theme.of(context).textTheme.titleMedium,
),
Text(
'${_favDetailController.item.value.mediaCount}条视频',
style:
Theme.of(context).textTheme.labelMedium,
)
],
),
),
),
actions: _favDetailController.enableMultiSelect.value
? [
TextButton(
style: TextButton.styleFrom(
visualDensity:
VisualDensity(horizontal: -2, vertical: -2),
),
onPressed: () =>
_favDetailController.handleSelect(true),
child: const Text('全选'),
),
TextButton(
style: TextButton.styleFrom(
visualDensity:
VisualDensity(horizontal: -2, vertical: -2),
),
onPressed: () => Utils.onCopyOrMove(
context: context,
isCopy: true,
ctr: _favDetailController,
mediaId: _favDetailController.mediaId,
),
child: Text(
'复制',
style: TextStyle(
color: Theme.of(context)
.colorScheme
.onSurfaceVariant,
), ),
Text(
'${_favDetailController.item.value.mediaCount}条视频',
style: Theme.of(context).textTheme.labelMedium,
)
],
),
),
),
actions: _favDetailController.enableMultiSelect.value
? [
TextButton(
style: TextButton.styleFrom(
visualDensity:
VisualDensity(horizontal: -2, vertical: -2),
),
onPressed: () =>
_favDetailController.handleSelect(true),
child: const Text('全选'),
),
TextButton(
style: TextButton.styleFrom(
visualDensity:
VisualDensity(horizontal: -2, vertical: -2),
),
onPressed: () => Utils.onCopyOrMove(
context: context,
isCopy: true,
ctr: _favDetailController,
mediaId: _favDetailController.mediaId,
),
child: Text(
'复制',
style: TextStyle(
color: Theme.of(context)
.colorScheme
.onSurfaceVariant,
), ),
), ),
), TextButton(
TextButton( style: TextButton.styleFrom(
style: TextButton.styleFrom( visualDensity:
visualDensity: VisualDensity(horizontal: -2, vertical: -2),
VisualDensity(horizontal: -2, vertical: -2), ),
), onPressed: () => Utils.onCopyOrMove(
onPressed: () => Utils.onCopyOrMove( context: context,
context: context, isCopy: false,
isCopy: false, ctr: _favDetailController,
ctr: _favDetailController, mediaId: _favDetailController.mediaId,
mediaId: _favDetailController.mediaId, ),
), child: Text(
child: Text( '移动',
'移动', style: TextStyle(
style: TextStyle( color: Theme.of(context)
color: Theme.of(context) .colorScheme
.colorScheme .onSurfaceVariant,
.onSurfaceVariant, ),
), ),
), ),
), TextButton(
TextButton( style: TextButton.styleFrom(
style: TextButton.styleFrom( visualDensity:
visualDensity: VisualDensity(horizontal: -2, vertical: -2),
VisualDensity(horizontal: -2, vertical: -2), ),
onPressed: () =>
_favDetailController.onDelChecked(context),
child: Text(
'删除',
style: TextStyle(
color: Theme.of(context).colorScheme.error),
),
), ),
onPressed: () => const SizedBox(width: 6),
_favDetailController.onDelChecked(context), ]
child: Text( : [
'删除', IconButton(
style: TextStyle( tooltip: '搜索',
color: Theme.of(context).colorScheme.error), onPressed: () =>
Get.toNamed('/favSearch', arguments: {
'type': 0,
'mediaId': int.parse(mediaId),
'searchType': SearchType.fav,
}),
icon: const Icon(Icons.search_outlined),
), ),
), // IconButton(
const SizedBox(width: 6), // onPressed: () {},
] // icon: const Icon(Icons.more_vert),
: [ // ),
IconButton( Obx(
tooltip: '搜索', () => _favDetailController.isOwner.value
onPressed: () => ? PopupMenuButton(
Get.toNamed('/favSearch', arguments: { icon: const Icon(Icons.more_vert),
'type': 0, itemBuilder: (context) => [
'mediaId': int.parse(mediaId),
'searchType': SearchType.fav,
}),
icon: const Icon(Icons.search_outlined),
),
// IconButton(
// onPressed: () {},
// icon: const Icon(Icons.more_vert),
// ),
Obx(
() => _favDetailController.isOwner.value
? PopupMenuButton(
icon: const Icon(Icons.more_vert),
itemBuilder: (context) => [
PopupMenuItem(
onTap: () {
Get.toNamed(
'/createFav',
parameters: {'mediaId': mediaId},
)?.then((res) {
if (res is FavFolderItemData) {
_favDetailController.item.value =
res;
}
});
},
child: Text('编辑信息'),
),
PopupMenuItem(
onTap: () {
UserHttp.cleanFav(mediaId: mediaId)
.then((data) {
if (data['status']) {
SmartDialog.showToast('清除成功');
Future.delayed(
const Duration(
milliseconds: 200), () {
_favDetailController.onReload();
});
} else {
SmartDialog.showToast(data['msg']);
}
});
},
child: Text('清除失效内容'),
),
if (!Utils.isDefault(
_favDetailController.item.value.attr ??
0))
PopupMenuItem( PopupMenuItem(
onTap: () { onTap: () {
showConfirmDialog( Get.toNamed(
context: context, '/createFav',
title: '确定删除该收藏夹?', parameters: {'mediaId': mediaId},
onConfirm: () { )?.then((res) {
Get.back(); if (res is FavFolderItemData) {
UserHttp.deleteFolder( _favDetailController.item.value =
mediaIds: [mediaId]) res;
.then((data) { }
if (data['status']) { });
SmartDialog.showToast('删除成功');
Get.back(result: true);
} else {
SmartDialog.showToast(
data['msg']);
}
});
},
);
}, },
child: Text( child: Text('编辑信息'),
'删除', ),
style: TextStyle( PopupMenuItem(
color: Theme.of(context) onTap: () {
.colorScheme UserHttp.cleanFav(mediaId: mediaId)
.error, .then((data) {
if (data['status']) {
SmartDialog.showToast('清除成功');
Future.delayed(
const Duration(
milliseconds: 200), () {
_favDetailController.onReload();
});
} else {
SmartDialog.showToast(
data['msg']);
}
});
},
child: Text('清除失效内容'),
),
if (!Utils.isDefault(_favDetailController
.item.value.attr ??
0))
PopupMenuItem(
onTap: () {
showConfirmDialog(
context: context,
title: '确定删除该收藏夹?',
onConfirm: () {
Get.back();
UserHttp.deleteFolder(
mediaIds: [mediaId])
.then((data) {
if (data['status']) {
SmartDialog.showToast(
'删除成功');
Get.back(result: true);
} else {
SmartDialog.showToast(
data['msg']);
}
});
},
);
},
child: Text(
'删除',
style: TextStyle(
color: Theme.of(context)
.colorScheme
.error,
),
), ),
), ),
), ],
], )
) : const SizedBox.shrink(),
: const SizedBox.shrink(), ),
), const SizedBox(width: 6),
const SizedBox(width: 6), ],
], flexibleSpace: FlexibleSpaceBar(
flexibleSpace: FlexibleSpaceBar( background: Container(
background: Container( padding: EdgeInsets.only(
padding: EdgeInsets.only( top: kTextTabBarHeight +
top: kTextTabBarHeight + MediaQuery.of(context).padding.top +
MediaQuery.of(context).padding.top + 10,
10, left: 14,
left: 14, right: 20,
right: 20, ),
), child: SizedBox(
child: SizedBox( height: 110,
height: 110, child: Obx(
child: Obx( () => Row(
() => Row( crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, children: [
children: [ Hero(
Hero( tag: _favDetailController.heroTag,
tag: _favDetailController.heroTag, child: NetworkImgLayer(
child: NetworkImgLayer( width: 180,
width: 180, height: 110,
height: 110, src: _favDetailController.item.value.cover,
src: _favDetailController.item.value.cover, ),
), ),
), const SizedBox(width: 14),
const SizedBox(width: 14), Expanded(
Expanded( child: SizedBox(
child: SizedBox( height: 110,
height: 110, child: Column(
child: Column( mainAxisSize: MainAxisSize.min,
mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment:
crossAxisAlignment: CrossAxisAlignment.start, CrossAxisAlignment.start,
children: [ children: [
const SizedBox(height: 4), const SizedBox(height: 4),
Text(
_favDetailController.item.value.title ??
'',
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
.titleMedium!
.fontSize,
fontWeight: FontWeight.bold),
),
if (_favDetailController
.item.value.intro?.isNotEmpty ==
true)
Text( Text(
_favDetailController.item.value.intro ?? _favDetailController.item.value.title ??
'',
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
.titleMedium!
.fontSize,
fontWeight: FontWeight.bold),
),
if (_favDetailController
.item.value.intro?.isNotEmpty ==
true)
Text(
_favDetailController
.item.value.intro ??
'',
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
.labelSmall!
.fontSize,
color: Theme.of(context)
.colorScheme
.outline),
),
const SizedBox(height: 4),
Text(
_favDetailController
.item.value.upper?.name ??
'', '',
style: TextStyle( style: TextStyle(
fontSize: Theme.of(context) fontSize: Theme.of(context)
@@ -324,47 +350,35 @@ class _FavDetailPageState extends State<FavDetailPage> {
.colorScheme .colorScheme
.outline), .outline),
), ),
const SizedBox(height: 4), const Spacer(),
Text( if (_favDetailController
_favDetailController .item.value.attr !=
.item.value.upper?.name ?? null)
'', Text(
style: TextStyle( '${_favDetailController.item.value.mediaCount}条视频 · ${Utils.isPublicText(_favDetailController.item.value.attr ?? 0)}',
fontSize: Theme.of(context) style: TextStyle(
.textTheme fontSize: Theme.of(context)
.labelSmall! .textTheme
.fontSize, .labelSmall!
color: Theme.of(context) .fontSize,
.colorScheme color: Theme.of(context)
.outline), .colorScheme
), .outline),
const Spacer(), ),
if (_favDetailController.item.value.attr != ],
null) ),
Text(
'${_favDetailController.item.value.mediaCount}条视频 · ${Utils.isPublicText(_favDetailController.item.value.attr ?? 0)}',
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
.labelSmall!
.fontSize,
color: Theme.of(context)
.colorScheme
.outline),
),
],
), ),
), ),
), ],
], ),
), ),
), ),
), ),
), ),
), ),
), Obx(() => _buildBody(_favDetailController.loadingState.value)),
Obx(() => _buildBody(_favDetailController.loadingState.value)), ],
], ),
), ),
), ),
), ),

View File

@@ -1,4 +1,5 @@
import 'package:PiliPlus/common/widgets/icon_button.dart'; import 'package:PiliPlus/common/widgets/icon_button.dart';
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/pages/history/view.dart' show AppBarWidget; import 'package:PiliPlus/pages/history/view.dart' show AppBarWidget;
import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/extension.dart';
@@ -146,19 +147,24 @@ class _LaterPageState extends State<LaterPage> {
) )
: const SizedBox(), : const SizedBox(),
), ),
body: CustomScrollView( body: refreshIndicator(
physics: const AlwaysScrollableScrollPhysics(), onRefresh: () async {
controller: _laterController.scrollController, await _laterController.onRefresh();
slivers: [ },
SliverPadding( child: CustomScrollView(
padding: EdgeInsets.only( physics: const AlwaysScrollableScrollPhysics(),
bottom: MediaQuery.of(context).padding.bottom + 85, controller: _laterController.scrollController,
slivers: [
SliverPadding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom + 85,
),
sliver: Obx(
() => _buildBody(_laterController.loadingState.value),
),
), ),
sliver: Obx( ],
() => _buildBody(_laterController.loadingState.value), ),
),
),
],
), ),
), ),
), ),

View File

@@ -1,3 +1,4 @@
import 'package:PiliPlus/common/widgets/loading_widget.dart';
import 'package:PiliPlus/common/widgets/refresh_indicator.dart'; import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
import 'package:easy_debounce/easy_throttle.dart'; import 'package:easy_debounce/easy_throttle.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -52,92 +53,85 @@ class _AtMePageState extends State<AtMePage> {
onRefresh: () async { onRefresh: () async {
await _atMeController.onRefresh(); await _atMeController.onRefresh();
}, },
child: SingleChildScrollView( child: Obx(
controller: _scrollController, () {
child: LayoutBuilder( // TODO: refactor
builder: (BuildContext context, BoxConstraints constraints) { if (_atMeController.msgFeedAtMeList.isEmpty) {
return Obx( if (_atMeController.cursor == -1 &&
() { _atMeController.cursorTime == -1) {
if (_atMeController.msgFeedAtMeList.isEmpty) { return const Center(
return const Center( child: CircularProgressIndicator(),
child: CircularProgressIndicator(), );
); } else {
} return scrollErrorWidget(
return ListView.separated( callback: _atMeController.queryMsgFeedAtMe);
itemCount: _atMeController.msgFeedAtMeList.length, }
shrinkWrap: true, }
physics: const NeverScrollableScrollPhysics(), return ListView.separated(
itemBuilder: (context, int i) { controller: _scrollController,
return ListTile( itemCount: _atMeController.msgFeedAtMeList.length,
onTap: () { physics: const AlwaysScrollableScrollPhysics(),
String? nativeUri = itemBuilder: (context, int i) {
_atMeController.msgFeedAtMeList[i].item?.nativeUri; return ListTile(
if (nativeUri != null) { onTap: () {
PiliScheme.routePushFromUrl(nativeUri); String? nativeUri =
} _atMeController.msgFeedAtMeList[i].item?.nativeUri;
// SmartDialog.showToast("跳转至:$nativeUri暂未实现"); if (nativeUri != null) {
}, PiliScheme.routePushFromUrl(nativeUri);
leading: NetworkImgLayer( }
width: 45, // SmartDialog.showToast("跳转至:$nativeUri暂未实现");
height: 45, },
type: 'avatar', leading: NetworkImgLayer(
src: _atMeController.msgFeedAtMeList[i].user?.avatar, width: 45,
), height: 45,
title: Text( type: 'avatar',
"${_atMeController.msgFeedAtMeList[i].user?.nickname} " src: _atMeController.msgFeedAtMeList[i].user?.avatar,
"${_atMeController.msgFeedAtMeList[i].item?.business}中@了我", ),
title: Text(
"${_atMeController.msgFeedAtMeList[i].user?.nickname} "
"${_atMeController.msgFeedAtMeList[i].item?.business}中@了我",
style: Theme.of(context).textTheme.titleMedium!.copyWith(
color: Theme.of(context).colorScheme.primary,
)),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 4),
Text(
_atMeController
.msgFeedAtMeList[i].item?.sourceContent ??
"",
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
.titleMedium! .bodyMedium!
.copyWith( .copyWith(
color: Theme.of(context).colorScheme.primary, color: Theme.of(context).colorScheme.outline))
)), ],
subtitle: Column( ),
crossAxisAlignment: CrossAxisAlignment.start, trailing: _atMeController.msgFeedAtMeList[i].item?.image !=
children: [ null &&
const SizedBox(height: 4), _atMeController.msgFeedAtMeList[i].item?.image != ""
Text( ? NetworkImgLayer(
_atMeController width: 45,
.msgFeedAtMeList[i].item?.sourceContent ?? height: 45,
"", type: 'cover',
maxLines: 3, src: _atMeController.msgFeedAtMeList[i].item?.image,
overflow: TextOverflow.ellipsis, )
style: Theme.of(context) : null,
.textTheme );
.bodyMedium! },
.copyWith( separatorBuilder: (BuildContext context, int index) {
color: Theme.of(context) return Divider(
.colorScheme indent: 72,
.outline)) endIndent: 20,
], height: 6,
), color: Colors.grey.withOpacity(0.1),
trailing: _atMeController
.msgFeedAtMeList[i].item?.image !=
null &&
_atMeController.msgFeedAtMeList[i].item?.image !=
""
? NetworkImgLayer(
width: 45,
height: 45,
type: 'cover',
src: _atMeController
.msgFeedAtMeList[i].item?.image,
)
: null,
);
},
separatorBuilder: (BuildContext context, int index) {
return Divider(
indent: 72,
endIndent: 20,
height: 6,
color: Colors.grey.withOpacity(0.1),
);
},
); );
}, },
); );
}), },
), ),
), ),
); );

View File

@@ -53,6 +53,7 @@ class _LikeMePageState extends State<LikeMePage> {
onRefresh: () async { onRefresh: () async {
await _likeMeController.onRefresh(); await _likeMeController.onRefresh();
}, },
// TODO: refactor
child: SingleChildScrollView( child: SingleChildScrollView(
controller: _scrollController, controller: _scrollController,
child: LayoutBuilder( child: LayoutBuilder(

View File

@@ -51,106 +51,100 @@ class _ReplyMePageState extends State<ReplyMePage> {
onRefresh: () async { onRefresh: () async {
await _replyMeController.onRefresh(); await _replyMeController.onRefresh();
}, },
child: SingleChildScrollView( // TODO: refactor
controller: _scrollController, child: Obx(
child: LayoutBuilder( () {
builder: (BuildContext context, BoxConstraints constraints) { if (_replyMeController.msgFeedReplyMeList.isEmpty) {
return Obx( return const Center(
() { child: CircularProgressIndicator(),
if (_replyMeController.msgFeedReplyMeList.isEmpty) { );
return const Center( }
child: CircularProgressIndicator(), return ListView.separated(
); controller: _scrollController,
} itemCount: _replyMeController.msgFeedReplyMeList.length,
return ListView.separated( physics: const AlwaysScrollableScrollPhysics(),
itemCount: _replyMeController.msgFeedReplyMeList.length, itemBuilder: (context, int i) {
shrinkWrap: true, return ListTile(
physics: const NeverScrollableScrollPhysics(), onTap: () {
itemBuilder: (context, int i) { String? nativeUri = _replyMeController
return ListTile( .msgFeedReplyMeList[i].item?.nativeUri;
onTap: () { if (nativeUri != null) {
String? nativeUri = _replyMeController PiliScheme.routePushFromUrl(nativeUri);
.msgFeedReplyMeList[i].item?.nativeUri; }
if (nativeUri != null) { // SmartDialog.showToast("跳转至:$nativeUri暂未实现");
PiliScheme.routePushFromUrl(nativeUri);
}
// SmartDialog.showToast("跳转至:$nativeUri暂未实现");
},
leading: NetworkImgLayer(
width: 45,
height: 45,
type: 'avatar',
src: _replyMeController
.msgFeedReplyMeList[i].user?.avatar,
),
title: Text(
"${_replyMeController.msgFeedReplyMeList[i].user?.nickname} "
"回复了我的${_replyMeController.msgFeedReplyMeList[i].item?.business}",
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: Theme.of(context).colorScheme.primary),
),
subtitle: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 4),
Text(
_replyMeController.msgFeedReplyMeList[i].item
?.sourceContent ??
"",
style: Theme.of(context).textTheme.bodyMedium),
const SizedBox(height: 4),
if (_replyMeController.msgFeedReplyMeList[i].item
?.targetReplyContent !=
null &&
_replyMeController.msgFeedReplyMeList[i].item
?.targetReplyContent !=
"")
Text(
"| ${_replyMeController.msgFeedReplyMeList[i].item?.targetReplyContent}",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context)
.textTheme
.labelMedium!
.copyWith(
color: Theme.of(context)
.colorScheme
.outline,
height: 1.5)),
if (_replyMeController.msgFeedReplyMeList[i].item
?.rootReplyContent !=
null &&
_replyMeController.msgFeedReplyMeList[i].item
?.rootReplyContent !=
"")
Text(
" | ${_replyMeController.msgFeedReplyMeList[i].item?.rootReplyContent}",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context)
.textTheme
.labelMedium!
.copyWith(
color: Theme.of(context)
.colorScheme
.outline,
height: 1.5)),
]),
);
},
separatorBuilder: (BuildContext context, int index) {
return Divider(
indent: 72,
endIndent: 20,
height: 6,
color: Colors.grey.withOpacity(0.1),
);
}, },
leading: NetworkImgLayer(
width: 45,
height: 45,
type: 'avatar',
src: _replyMeController.msgFeedReplyMeList[i].user?.avatar,
),
title: Text(
"${_replyMeController.msgFeedReplyMeList[i].user?.nickname} "
"回复了我的${_replyMeController.msgFeedReplyMeList[i].item?.business}",
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(color: Theme.of(context).colorScheme.primary),
),
subtitle: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 4),
Text(
_replyMeController.msgFeedReplyMeList[i].item
?.sourceContent ??
"",
style: Theme.of(context).textTheme.bodyMedium),
const SizedBox(height: 4),
if (_replyMeController.msgFeedReplyMeList[i].item
?.targetReplyContent !=
null &&
_replyMeController.msgFeedReplyMeList[i].item
?.targetReplyContent !=
"")
Text(
"| ${_replyMeController.msgFeedReplyMeList[i].item?.targetReplyContent}",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context)
.textTheme
.labelMedium!
.copyWith(
color:
Theme.of(context).colorScheme.outline,
height: 1.5)),
if (_replyMeController.msgFeedReplyMeList[i].item
?.rootReplyContent !=
null &&
_replyMeController.msgFeedReplyMeList[i].item
?.rootReplyContent !=
"")
Text(
" | ${_replyMeController.msgFeedReplyMeList[i].item?.rootReplyContent}",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context)
.textTheme
.labelMedium!
.copyWith(
color:
Theme.of(context).colorScheme.outline,
height: 1.5)),
]),
);
},
separatorBuilder: (BuildContext context, int index) {
return Divider(
indent: 72,
endIndent: 20,
height: 6,
color: Colors.grey.withOpacity(0.1),
); );
}, },
); );
}), },
), ),
), ),
); );

View File

@@ -57,112 +57,105 @@ class _SysMsgPageState extends State<SysMsgPage> {
onRefresh: () async { onRefresh: () async {
await _sysMsgController.onRefresh(); await _sysMsgController.onRefresh();
}, },
child: SingleChildScrollView( // TODO: refactor
controller: _scrollController, child: Obx(
child: LayoutBuilder( () {
builder: (BuildContext context, BoxConstraints constraints) { if (_sysMsgController.msgFeedSysMsgList.isEmpty) {
return Obx( return const Center(
() { child: CircularProgressIndicator(),
if (_sysMsgController.msgFeedSysMsgList.isEmpty) { );
return const Center( }
child: CircularProgressIndicator(), return ListView.separated(
); controller: _scrollController,
} itemCount: _sysMsgController.msgFeedSysMsgList.length,
return ListView.separated( physics: const AlwaysScrollableScrollPhysics(),
itemCount: _sysMsgController.msgFeedSysMsgList.length, itemBuilder: (context, int i) {
shrinkWrap: true, String? content =
physics: const NeverScrollableScrollPhysics(), _sysMsgController.msgFeedSysMsgList[i].content;
itemBuilder: (context, int i) { if (content != null) {
String? content = try {
_sysMsgController.msgFeedSysMsgList[i].content; dynamic jsonContent = json.decode(content);
if (content != null) { if (jsonContent != null && jsonContent['web'] != null) {
try { content = jsonContent['web'];
dynamic jsonContent = json.decode(content);
if (jsonContent != null && jsonContent['web'] != null) {
content = jsonContent['web'];
}
} catch (_) {}
} }
return ListTile( } catch (_) {}
onTap: () {}, }
onLongPress: () { return ListTile(
showDialog( onTap: () {},
context: context, onLongPress: () {
builder: (context) => AlertDialog( showDialog(
title: const Text('确定删除该通知?'), context: context,
actions: [ builder: (context) => AlertDialog(
TextButton( title: const Text('确定删除该通知?'),
onPressed: Get.back, actions: [
child: Text( TextButton(
'取消', onPressed: Get.back,
style: TextStyle( child: Text(
color: Theme.of(context) '取消',
.colorScheme style: TextStyle(
.outline, color:
), Theme.of(context).colorScheme.outline,
),
), ),
TextButton(
onPressed: () {
Get.back();
_sysMsgController.onRemove(i);
},
child: const Text('确定'),
),
],
));
},
title: Text(
"${_sysMsgController.msgFeedSysMsgList[i].title}",
style: Theme.of(context).textTheme.titleMedium,
),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 4),
Text.rich(
_buildContent(content ?? ''),
style: TextStyle(
fontSize: 14,
color: Theme.of(context)
.colorScheme
.onSurface
.withOpacity(0.85),
),
),
const SizedBox(height: 5),
SizedBox(
width: double.infinity,
child: Text(
"${_sysMsgController.msgFeedSysMsgList[i].timeAt}",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(
color:
Theme.of(context).colorScheme.outline,
), ),
textAlign: TextAlign.end, ),
), TextButton(
), onPressed: () {
], Get.back();
_sysMsgController.onRemove(i);
},
child: const Text('确定'),
),
],
));
},
title: Text(
"${_sysMsgController.msgFeedSysMsgList[i].title}",
style: Theme.of(context).textTheme.titleMedium,
),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 4),
Text.rich(
_buildContent(content ?? ''),
style: TextStyle(
fontSize: 14,
color: Theme.of(context)
.colorScheme
.onSurface
.withOpacity(0.85),
),
), ),
); const SizedBox(height: 5),
}, SizedBox(
separatorBuilder: (BuildContext context, int index) { width: double.infinity,
return Divider( child: Text(
indent: 72, "${_sysMsgController.msgFeedSysMsgList[i].timeAt}",
endIndent: 20, maxLines: 1,
height: 6, overflow: TextOverflow.ellipsis,
color: Colors.grey.withOpacity(0.1), style: Theme.of(context)
); .textTheme
}, .bodySmall!
.copyWith(
color: Theme.of(context).colorScheme.outline,
),
textAlign: TextAlign.end,
),
),
],
),
);
},
separatorBuilder: (BuildContext context, int index) {
return Divider(
indent: 72,
endIndent: 20,
height: 6,
color: Colors.grey.withOpacity(0.1),
); );
}, },
); );
}), },
), ),
), ),
); );

View File

@@ -1,5 +1,6 @@
import 'package:PiliPlus/common/constants.dart'; import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/skeleton/video_card_h.dart'; import 'package:PiliPlus/common/skeleton/video_card_h.dart';
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/pages/subscription/widgets/item.dart'; import 'package:PiliPlus/pages/subscription/widgets/item.dart';
import 'package:PiliPlus/utils/grid.dart'; import 'package:PiliPlus/utils/grid.dart';
@@ -22,15 +23,20 @@ class _SubPageState extends State<SubPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: const Text('我的订阅')), appBar: AppBar(title: const Text('我的订阅')),
body: CustomScrollView( body: refreshIndicator(
slivers: [ onRefresh: () async {
Obx(() => _buildBody(_subController.loadingState.value)), await _subController.onRefresh();
SliverToBoxAdapter( },
child: SizedBox( child: CustomScrollView(
height: MediaQuery.of(context).padding.bottom + 80, slivers: [
Obx(() => _buildBody(_subController.loadingState.value)),
SliverToBoxAdapter(
child: SizedBox(
height: MediaQuery.of(context).padding.bottom + 80,
),
), ),
), ],
], ),
), ),
); );
} }

View File

@@ -2,6 +2,7 @@ import 'package:PiliPlus/common/skeleton/video_reply.dart';
import 'package:PiliPlus/common/widgets/icon_button.dart'; import 'package:PiliPlus/common/widgets/icon_button.dart';
import 'package:PiliPlus/common/widgets/loading_widget.dart'; import 'package:PiliPlus/common/widgets/loading_widget.dart';
import 'package:PiliPlus/common/widgets/network_img_layer.dart'; import 'package:PiliPlus/common/widgets/network_img_layer.dart';
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/pages/video/detail/note/note_list_page_ctr.dart'; import 'package:PiliPlus/pages/video/detail/note/note_list_page_ctr.dart';
import 'package:PiliPlus/utils/app_scheme.dart'; import 'package:PiliPlus/utils/app_scheme.dart';
@@ -79,7 +80,7 @@ class _NoteListPageState extends State<NoteListPage> {
], ],
), ),
Success() => (loadingState.response as List?)?.isNotEmpty == true Success() => (loadingState.response as List?)?.isNotEmpty == true
? RefreshIndicator( ? refreshIndicator(
onRefresh: () async { onRefresh: () async {
await _controller.onRefresh(); await _controller.onRefresh();
}, },