mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: 点赞支持显示最新与人数
This commit is contained in:
@@ -4,7 +4,8 @@ import 'package:pilipala/http/msg.dart';
|
||||
import '../../../models/msg/msgfeed_like_me.dart';
|
||||
|
||||
class LikeMeController extends GetxController {
|
||||
RxList<LikeMeItems> msgFeedLikeMeList = <LikeMeItems>[].obs;
|
||||
RxList<LikeMeItems> msgFeedLikeMeLatestList = <LikeMeItems>[].obs;
|
||||
RxList<LikeMeItems> msgFeedLikeMeTotalList = <LikeMeItems>[].obs;
|
||||
bool isLoading = false;
|
||||
int cursor = -1;
|
||||
int cursorTime = -1;
|
||||
@@ -19,9 +20,11 @@ class LikeMeController extends GetxController {
|
||||
MsgFeedLikeMe data = MsgFeedLikeMe.fromJson(res['data']);
|
||||
isEnd = data.total?.cursor?.isEnd ?? false;
|
||||
if (cursor == -1) {
|
||||
msgFeedLikeMeList.assignAll(data.total!.items!);
|
||||
msgFeedLikeMeLatestList.assignAll(data.latest?.items??[]);
|
||||
msgFeedLikeMeTotalList.assignAll(data.total?.items??[]);
|
||||
} else {
|
||||
msgFeedLikeMeList.addAll(data.total!.items!);
|
||||
msgFeedLikeMeLatestList.addAll(data.latest?.items??[]);
|
||||
msgFeedLikeMeTotalList.addAll(data.total?.items??[]);
|
||||
}
|
||||
cursor = data.total?.cursor?.id ?? -1;
|
||||
cursorTime = data.total?.cursor?.time ?? -1;
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
|
||||
import '../../../models/msg/msgfeed_like_me.dart';
|
||||
import 'controller.dart';
|
||||
|
||||
class LikeMePage extends StatefulWidget {
|
||||
@@ -50,113 +51,42 @@ class _LikeMePageState extends State<LikeMePage> {
|
||||
builder: (BuildContext context, BoxConstraints constraints) {
|
||||
return Obx(
|
||||
() {
|
||||
if (_likeMeController.msgFeedLikeMeList.isEmpty) {
|
||||
if (_likeMeController.msgFeedLikeMeLatestList.isEmpty &&
|
||||
_likeMeController.msgFeedLikeMeTotalList.isEmpty) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
return ListView.separated(
|
||||
itemCount: _likeMeController.msgFeedLikeMeList.length,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (_, int i) {
|
||||
return ListTile(
|
||||
onTap: () {
|
||||
String nativeUri = _likeMeController
|
||||
.msgFeedLikeMeList[i].item?.nativeUri ??
|
||||
"";
|
||||
SmartDialog.showToast("跳转至:$nativeUri(暂未实现)");
|
||||
},
|
||||
leading: SizedBox(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: Stack(
|
||||
children: [
|
||||
for (var j = 0;
|
||||
j <
|
||||
_likeMeController.msgFeedLikeMeList[i]
|
||||
.users!.length &&
|
||||
j < 4;
|
||||
j++) ...<Widget>[
|
||||
Positioned(
|
||||
left: 15 * (j % 2).toDouble(),
|
||||
top: 15 * (j ~/ 2).toDouble(),
|
||||
child: NetworkImgLayer(
|
||||
width: _likeMeController
|
||||
.msgFeedLikeMeList[i]
|
||||
.users!
|
||||
.length >
|
||||
1
|
||||
? 30
|
||||
: 45,
|
||||
height: _likeMeController
|
||||
.msgFeedLikeMeList[i]
|
||||
.users!
|
||||
.length >
|
||||
1
|
||||
? 30
|
||||
: 45,
|
||||
type: 'avatar',
|
||||
src: _likeMeController
|
||||
.msgFeedLikeMeList[i]
|
||||
.users![j]
|
||||
.avatar,
|
||||
)),
|
||||
]
|
||||
],
|
||||
)),
|
||||
title: Text(
|
||||
"${_likeMeController.msgFeedLikeMeList[i].users!.map((e) => e.nickname).join("、")} "
|
||||
"赞了我的${_likeMeController.msgFeedLikeMeList[i].item?.business}",
|
||||
style: Theme.of(context).textTheme.bodyMedium!,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
subtitle:
|
||||
_likeMeController.msgFeedLikeMeList[i].item?.title !=
|
||||
null &&
|
||||
_likeMeController
|
||||
.msgFeedLikeMeList[i].item?.title !=
|
||||
""
|
||||
? Text(
|
||||
_likeMeController
|
||||
.msgFeedLikeMeList[i].item?.title ??
|
||||
"",
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelMedium!
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline))
|
||||
: null,
|
||||
trailing:
|
||||
_likeMeController.msgFeedLikeMeList[i].item?.image !=
|
||||
null &&
|
||||
_likeMeController
|
||||
.msgFeedLikeMeList[i].item?.image !=
|
||||
""
|
||||
? NetworkImgLayer(
|
||||
width: 45,
|
||||
height: 45,
|
||||
type: 'cover',
|
||||
src: _likeMeController
|
||||
.msgFeedLikeMeList[i].item?.image,
|
||||
)
|
||||
: null,
|
||||
);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return Divider(
|
||||
indent: 72,
|
||||
endIndent: 20,
|
||||
height: 6,
|
||||
color: Colors.grey.withOpacity(0.1),
|
||||
);
|
||||
},
|
||||
);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (_likeMeController
|
||||
.msgFeedLikeMeLatestList.isNotEmpty) ...<Widget>[
|
||||
Text(" 最新",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelMedium!
|
||||
.copyWith(
|
||||
color:
|
||||
Theme.of(context).colorScheme.outline)),
|
||||
LikeMeList(
|
||||
msgFeedLikeMeList:
|
||||
_likeMeController.msgFeedLikeMeLatestList),
|
||||
],
|
||||
if (_likeMeController
|
||||
.msgFeedLikeMeTotalList.isNotEmpty) ...<Widget>[
|
||||
Text(" 累计",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelMedium!
|
||||
.copyWith(
|
||||
color:
|
||||
Theme.of(context).colorScheme.outline)),
|
||||
LikeMeList(
|
||||
msgFeedLikeMeList:
|
||||
_likeMeController.msgFeedLikeMeTotalList),
|
||||
]
|
||||
]);
|
||||
},
|
||||
);
|
||||
}),
|
||||
@@ -165,3 +95,85 @@ class _LikeMePageState extends State<LikeMePage> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class LikeMeList extends StatelessWidget {
|
||||
const LikeMeList({
|
||||
super.key,
|
||||
required this.msgFeedLikeMeList,
|
||||
});
|
||||
final RxList<LikeMeItems> msgFeedLikeMeList;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.separated(
|
||||
itemCount: msgFeedLikeMeList.length,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (_, int i) {
|
||||
return ListTile(
|
||||
onTap: () {
|
||||
String nativeUri = msgFeedLikeMeList[i].item?.nativeUri ?? "";
|
||||
SmartDialog.showToast("跳转至:$nativeUri(暂未实现)");
|
||||
},
|
||||
leading: SizedBox(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: Stack(
|
||||
children: [
|
||||
for (var j = 0;
|
||||
j < msgFeedLikeMeList[i].users!.length && j < 4;
|
||||
j++) ...<Widget>[
|
||||
Positioned(
|
||||
left: 15 * (j % 2).toDouble(),
|
||||
top: 15 * (j ~/ 2).toDouble(),
|
||||
child: NetworkImgLayer(
|
||||
width:
|
||||
msgFeedLikeMeList[i].users!.length > 1 ? 30 : 45,
|
||||
height:
|
||||
msgFeedLikeMeList[i].users!.length > 1 ? 30 : 45,
|
||||
type: 'avatar',
|
||||
src: msgFeedLikeMeList[i].users![j].avatar,
|
||||
)),
|
||||
]
|
||||
],
|
||||
)),
|
||||
title: Text(
|
||||
"${msgFeedLikeMeList[i].users!.map((e) => e.nickname).join("/")}"
|
||||
"等共 ${msgFeedLikeMeList[i].counts} 人"
|
||||
"赞了我的${msgFeedLikeMeList[i].item?.business}",
|
||||
style:
|
||||
Theme.of(context).textTheme.labelMedium!.copyWith(height: 1.5),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
subtitle: msgFeedLikeMeList[i].item?.title != null &&
|
||||
msgFeedLikeMeList[i].item?.title != ""
|
||||
? Text(msgFeedLikeMeList[i].item?.title ?? "",
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.labelMedium!.copyWith(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
height: 1.5))
|
||||
: null,
|
||||
trailing: msgFeedLikeMeList[i].item?.image != null &&
|
||||
msgFeedLikeMeList[i].item?.image != ""
|
||||
? NetworkImgLayer(
|
||||
width: 45,
|
||||
height: 45,
|
||||
type: 'cover',
|
||||
src: msgFeedLikeMeList[i].item?.image,
|
||||
)
|
||||
: null,
|
||||
);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return Divider(
|
||||
indent: 72,
|
||||
endIndent: 20,
|
||||
height: 6,
|
||||
color: Colors.grey.withOpacity(0.1),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user