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';
|
import '../../../models/msg/msgfeed_like_me.dart';
|
||||||
|
|
||||||
class LikeMeController extends GetxController {
|
class LikeMeController extends GetxController {
|
||||||
RxList<LikeMeItems> msgFeedLikeMeList = <LikeMeItems>[].obs;
|
RxList<LikeMeItems> msgFeedLikeMeLatestList = <LikeMeItems>[].obs;
|
||||||
|
RxList<LikeMeItems> msgFeedLikeMeTotalList = <LikeMeItems>[].obs;
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
int cursor = -1;
|
int cursor = -1;
|
||||||
int cursorTime = -1;
|
int cursorTime = -1;
|
||||||
@@ -19,9 +20,11 @@ class LikeMeController extends GetxController {
|
|||||||
MsgFeedLikeMe data = MsgFeedLikeMe.fromJson(res['data']);
|
MsgFeedLikeMe data = MsgFeedLikeMe.fromJson(res['data']);
|
||||||
isEnd = data.total?.cursor?.isEnd ?? false;
|
isEnd = data.total?.cursor?.isEnd ?? false;
|
||||||
if (cursor == -1) {
|
if (cursor == -1) {
|
||||||
msgFeedLikeMeList.assignAll(data.total!.items!);
|
msgFeedLikeMeLatestList.assignAll(data.latest?.items??[]);
|
||||||
|
msgFeedLikeMeTotalList.assignAll(data.total?.items??[]);
|
||||||
} else {
|
} else {
|
||||||
msgFeedLikeMeList.addAll(data.total!.items!);
|
msgFeedLikeMeLatestList.addAll(data.latest?.items??[]);
|
||||||
|
msgFeedLikeMeTotalList.addAll(data.total?.items??[]);
|
||||||
}
|
}
|
||||||
cursor = data.total?.cursor?.id ?? -1;
|
cursor = data.total?.cursor?.id ?? -1;
|
||||||
cursorTime = data.total?.cursor?.time ?? -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:get/get.dart';
|
||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
|
|
||||||
|
import '../../../models/msg/msgfeed_like_me.dart';
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
|
|
||||||
class LikeMePage extends StatefulWidget {
|
class LikeMePage extends StatefulWidget {
|
||||||
@@ -50,113 +51,42 @@ class _LikeMePageState extends State<LikeMePage> {
|
|||||||
builder: (BuildContext context, BoxConstraints constraints) {
|
builder: (BuildContext context, BoxConstraints constraints) {
|
||||||
return Obx(
|
return Obx(
|
||||||
() {
|
() {
|
||||||
if (_likeMeController.msgFeedLikeMeList.isEmpty) {
|
if (_likeMeController.msgFeedLikeMeLatestList.isEmpty &&
|
||||||
|
_likeMeController.msgFeedLikeMeTotalList.isEmpty) {
|
||||||
return const Center(
|
return const Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return ListView.separated(
|
return Column(
|
||||||
itemCount: _likeMeController.msgFeedLikeMeList.length,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
shrinkWrap: true,
|
children: [
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
if (_likeMeController
|
||||||
itemBuilder: (_, int i) {
|
.msgFeedLikeMeLatestList.isNotEmpty) ...<Widget>[
|
||||||
return ListTile(
|
Text(" 最新",
|
||||||
onTap: () {
|
style: Theme.of(context)
|
||||||
String nativeUri = _likeMeController
|
.textTheme
|
||||||
.msgFeedLikeMeList[i].item?.nativeUri ??
|
.labelMedium!
|
||||||
"";
|
.copyWith(
|
||||||
SmartDialog.showToast("跳转至:$nativeUri(暂未实现)");
|
color:
|
||||||
},
|
Theme.of(context).colorScheme.outline)),
|
||||||
leading: SizedBox(
|
LikeMeList(
|
||||||
width: 50,
|
msgFeedLikeMeList:
|
||||||
height: 50,
|
_likeMeController.msgFeedLikeMeLatestList),
|
||||||
child: Stack(
|
],
|
||||||
children: [
|
if (_likeMeController
|
||||||
for (var j = 0;
|
.msgFeedLikeMeTotalList.isNotEmpty) ...<Widget>[
|
||||||
j <
|
Text(" 累计",
|
||||||
_likeMeController.msgFeedLikeMeList[i]
|
style: Theme.of(context)
|
||||||
.users!.length &&
|
.textTheme
|
||||||
j < 4;
|
.labelMedium!
|
||||||
j++) ...<Widget>[
|
.copyWith(
|
||||||
Positioned(
|
color:
|
||||||
left: 15 * (j % 2).toDouble(),
|
Theme.of(context).colorScheme.outline)),
|
||||||
top: 15 * (j ~/ 2).toDouble(),
|
LikeMeList(
|
||||||
child: NetworkImgLayer(
|
msgFeedLikeMeList:
|
||||||
width: _likeMeController
|
_likeMeController.msgFeedLikeMeTotalList),
|
||||||
.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),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
@@ -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