feat: 初步支持查看【回复我的】【at我】【收到的赞】内容

This commit is contained in:
orz12
2024-02-03 06:25:18 +08:00
parent 8abbab4c88
commit 4d9e15ad50
17 changed files with 1452 additions and 43 deletions

View File

@@ -0,0 +1,43 @@
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:pilipala/http/msg.dart';
import 'package:pilipala/models/msg/msgfeed_at_me.dart';
class AtMeController extends GetxController {
RxList<AtMeItems> msgFeedAtMeList = <AtMeItems>[].obs;
bool isLoading = false;
int cursor = -1;
int cursorTime = -1;
bool isEnd = false;
Future queryMsgFeedAtMe() async {
if (isLoading) return;
isLoading = true;
var res = await MsgHttp.msgFeedAtMe(cursor: cursor, cursorTime: cursorTime);
isLoading = false;
if (res['status']) {
MsgFeedAtMe data = MsgFeedAtMe.fromJson(res['data']);
isEnd = data.cursor?.isEnd ?? false;
if (cursor == -1) {
msgFeedAtMeList.assignAll(data.items!);
} else {
msgFeedAtMeList.addAll(data.items!);
}
cursor = data.cursor?.id ?? -1;
cursorTime = data.cursor?.time ?? -1;
} else {
SmartDialog.showToast(res['msg']);
}
}
Future onLoad() async {
if (isEnd) return;
queryMsgFeedAtMe();
}
Future onRefresh() async {
cursor = -1;
queryMsgFeedAtMe();
}
}

View File

@@ -0,0 +1,4 @@
library whisper;
export './controller.dart';
export './view.dart';

View File

@@ -0,0 +1,124 @@
import 'package:easy_debounce/easy_throttle.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'controller.dart';
class AtMePage extends StatefulWidget {
const AtMePage({super.key});
@override
State<AtMePage> createState() => _AtMePageState();
}
class _AtMePageState extends State<AtMePage> {
late final AtMeController _atMeController = Get.put(AtMeController());
final ScrollController _scrollController = ScrollController();
@override
void initState() {
_atMeController.queryMsgFeedAtMe();
super.initState();
_scrollController.addListener(_scrollListener);
}
Future _scrollListener() async {
if (_scrollController.position.pixels >=
_scrollController.position.maxScrollExtent - 200) {
EasyThrottle.throttle('my-throttler', const Duration(milliseconds: 800),
() async {
await _atMeController.onLoad();
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('@我的'),
),
body: RefreshIndicator(
onRefresh: () async {
await _atMeController.onRefresh();
},
child: SingleChildScrollView(
controller: _scrollController,
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return Obx(
() {
if (_atMeController.msgFeedAtMeList.isEmpty) {
return const Center(
child: CircularProgressIndicator(),
);
}
return ListView.separated(
itemCount: _atMeController.msgFeedAtMeList.length,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (_, int i) {
return ListTile(
onTap: () {
String nativeUri = _atMeController
.msgFeedAtMeList[i].item?.nativeUri ??
"";
SmartDialog.showToast("跳转至:$nativeUri(暂未实现)");
},
leading: NetworkImgLayer(
width: 45,
height: 45,
type: 'avatar',
src: _atMeController.msgFeedAtMeList[i].user?.avatar,
),
title: Text(
"${_atMeController.msgFeedAtMeList[i].user?.nickname} "
"${_atMeController.msgFeedAtMeList[i].item?.business}中@了我",
style: Theme.of(context).textTheme.bodyMedium!,
),
subtitle: Text(
_atMeController
.msgFeedAtMeList[i].item?.sourceContent ??
"",
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: Theme.of(context)
.textTheme
.labelMedium!
.copyWith(
color:
Theme.of(context).colorScheme.outline)),
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

@@ -0,0 +1,43 @@
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:pilipala/http/msg.dart';
import '../../../models/msg/msgfeed_like_me.dart';
class LikeMeController extends GetxController {
RxList<LikeMeItems> msgFeedLikeMeList = <LikeMeItems>[].obs;
bool isLoading = false;
int cursor = -1;
int cursorTime = -1;
bool isEnd = false;
Future queryMsgFeedLikeMe() async {
if (isLoading) return;
isLoading = true;
var res = await MsgHttp.msgFeedLikeMe(cursor: cursor, cursorTime: cursorTime);
isLoading = false;
if (res['status']) {
MsgFeedLikeMe data = MsgFeedLikeMe.fromJson(res['data']);
isEnd = data.total?.cursor?.isEnd ?? false;
if (cursor == -1) {
msgFeedLikeMeList.assignAll(data.total!.items!);
} else {
msgFeedLikeMeList.addAll(data.total!.items!);
}
cursor = data.total?.cursor?.id ?? -1;
cursorTime = data.total?.cursor?.time ?? -1;
} else {
SmartDialog.showToast(res['msg']);
}
}
Future onLoad() async {
if (isEnd) return;
queryMsgFeedLikeMe();
}
Future onRefresh() async {
cursor = -1;
queryMsgFeedLikeMe();
}
}

View File

@@ -0,0 +1,4 @@
library whisper;
export './controller.dart';
export './view.dart';

View File

@@ -0,0 +1,167 @@
import 'package:easy_debounce/easy_throttle.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'controller.dart';
class LikeMePage extends StatefulWidget {
const LikeMePage({super.key});
@override
State<LikeMePage> createState() => _LikeMePageState();
}
class _LikeMePageState extends State<LikeMePage> {
late final LikeMeController _likeMeController = Get.put(LikeMeController());
final ScrollController _scrollController = ScrollController();
@override
void initState() {
_likeMeController.queryMsgFeedLikeMe();
super.initState();
_scrollController.addListener(_scrollListener);
}
Future _scrollListener() async {
if (_scrollController.position.pixels >=
_scrollController.position.maxScrollExtent - 200) {
EasyThrottle.throttle('my-throttler', const Duration(milliseconds: 800),
() async {
await _likeMeController.onLoad();
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('收到的赞'),
),
body: RefreshIndicator(
onRefresh: () async {
await _likeMeController.onRefresh();
},
child: SingleChildScrollView(
controller: _scrollController,
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return Obx(
() {
if (_likeMeController.msgFeedLikeMeList.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),
);
},
);
},
);
}),
),
),
);
}
}

View File

@@ -0,0 +1,44 @@
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:pilipala/http/msg.dart';
import '../../../models/msg/msgfeed_reply_me.dart';
class ReplyMeController extends GetxController {
RxList<ReplyMeItems> msgFeedReplyMeList = <ReplyMeItems>[].obs;
bool isLoading = false;
int cursor = -1;
int cursorTime = -1;
bool isEnd = false;
Future queryMsgFeedReplyMe() async {
if (isLoading) return;
isLoading = true;
var res = await MsgHttp.msgFeedReplyMe(cursor: cursor, cursorTime: cursorTime);
isLoading = false;
if (res['status']) {
MsgFeedReplyMe data = MsgFeedReplyMe.fromJson(res['data']);
isEnd = data.cursor?.isEnd ?? false;
if (cursor == -1) {
msgFeedReplyMeList.assignAll(data.items!);
} else {
msgFeedReplyMeList.addAll(data.items!);
}
cursor = data.cursor?.id ?? -1;
cursorTime = data.cursor?.time ?? -1;
} else {
SmartDialog.showToast(res['msg']);
}
}
Future onLoad() async {
if (isEnd) return;
queryMsgFeedReplyMe();
}
Future onRefresh() async {
cursor = -1;
queryMsgFeedReplyMe();
}
}

View File

@@ -0,0 +1,4 @@
library whisper;
export './controller.dart';
export './view.dart';

View File

@@ -0,0 +1,149 @@
import 'package:easy_debounce/easy_throttle.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'controller.dart';
class ReplyMePage extends StatefulWidget {
const ReplyMePage({super.key});
@override
State<ReplyMePage> createState() => _ReplyMePageState();
}
class _ReplyMePageState extends State<ReplyMePage> {
late final ReplyMeController _replyMeController =
Get.put(ReplyMeController());
final ScrollController _scrollController = ScrollController();
@override
void initState() {
_replyMeController.queryMsgFeedReplyMe();
super.initState();
_scrollController.addListener(_scrollListener);
}
Future _scrollListener() async {
if (_scrollController.position.pixels >=
_scrollController.position.maxScrollExtent - 200) {
EasyThrottle.throttle('my-throttler', const Duration(milliseconds: 800),
() async {
await _replyMeController.onLoad();
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('回复我的'),
),
body: RefreshIndicator(
onRefresh: () async {
await _replyMeController.onRefresh();
},
child: SingleChildScrollView(
controller: _scrollController,
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return Obx(
() {
if (_replyMeController.msgFeedReplyMeList.isEmpty) {
return const Center(
child: CircularProgressIndicator(),
);
}
return ListView.separated(
itemCount: _replyMeController.msgFeedReplyMeList.length,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (_, int i) {
return ListTile(
onTap: () {
String nativeUri = _replyMeController
.msgFeedReplyMeList[i].item?.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!,
),
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),
);
},
);
},
);
}),
),
),
);
}
}