mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 19:14:42 +08:00
@@ -1,10 +1,11 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/msg.dart';
|
||||
import 'package:PiliPlus/models/msg/msgfeed_at_me.dart';
|
||||
import 'package:PiliPlus/models_new/msg/msg_at/data.dart';
|
||||
import 'package:PiliPlus/models_new/msg/msg_at/item.dart';
|
||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
|
||||
class AtMeController extends CommonListController<MsgFeedAtMe, AtMeItems> {
|
||||
class AtMeController extends CommonListController<MsgAtData, MsgAtItem> {
|
||||
int? cursor;
|
||||
int? cursorTime;
|
||||
|
||||
@@ -15,19 +16,13 @@ class AtMeController extends CommonListController<MsgFeedAtMe, AtMeItems> {
|
||||
}
|
||||
|
||||
@override
|
||||
List<AtMeItems>? getDataList(MsgFeedAtMe response) {
|
||||
return response.items;
|
||||
}
|
||||
|
||||
@override
|
||||
bool customHandleResponse(bool isRefresh, Success<MsgFeedAtMe> response) {
|
||||
MsgFeedAtMe data = response.response;
|
||||
if (data.cursor?.isEnd == true) {
|
||||
List<MsgAtItem>? getDataList(MsgAtData response) {
|
||||
if (response.cursor?.isEnd == true) {
|
||||
isEnd = true;
|
||||
}
|
||||
cursor = data.cursor?.id;
|
||||
cursorTime = data.cursor?.time;
|
||||
return false;
|
||||
cursor = response.cursor?.id;
|
||||
cursorTime = response.cursor?.time;
|
||||
return response.items;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -38,7 +33,7 @@ class AtMeController extends CommonListController<MsgFeedAtMe, AtMeItems> {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<MsgFeedAtMe>> customGetData() =>
|
||||
Future<LoadingState<MsgAtData>> customGetData() =>
|
||||
MsgHttp.msgFeedAtMe(cursor: cursor, cursorTime: cursorTime);
|
||||
|
||||
Future<void> onRemove(dynamic id, int index) async {
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:PiliPlus/grpc/bilibili/app/im/v1.pbenum.dart'
|
||||
show IMSettingType;
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/image_type.dart';
|
||||
import 'package:PiliPlus/models/msg/msgfeed_at_me.dart';
|
||||
import 'package:PiliPlus/models_new/msg/msg_at/item.dart';
|
||||
import 'package:PiliPlus/pages/msg_feed_top/at_me/controller.dart';
|
||||
import 'package:PiliPlus/pages/whisper_settings/view.dart';
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
@@ -64,7 +64,7 @@ class _AtMePageState extends State<AtMePage> {
|
||||
}
|
||||
|
||||
Widget _buildBody(
|
||||
ThemeData theme, LoadingState<List<AtMeItems>?> loadingState) {
|
||||
ThemeData theme, LoadingState<List<MsgAtItem>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => SliverList.builder(
|
||||
itemCount: 12,
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import 'package:PiliPlus/common/widgets/pair.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/msg.dart';
|
||||
import 'package:PiliPlus/models/msg/msgfeed_like_me.dart';
|
||||
import 'package:PiliPlus/models_new/msg/msg_like/data.dart';
|
||||
import 'package:PiliPlus/models_new/msg/msg_like/item.dart';
|
||||
import 'package:PiliPlus/pages/common/common_data_controller.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
|
||||
class LikeMeController extends CommonDataController<MsgFeedLikeMe, dynamic> {
|
||||
class LikeMeController extends CommonDataController<MsgLikeData,
|
||||
Pair<List<MsgLikeItem>, List<MsgLikeItem>>> {
|
||||
int? cursor;
|
||||
int? cursorTime;
|
||||
|
||||
@@ -27,18 +29,18 @@ class LikeMeController extends CommonDataController<MsgFeedLikeMe, dynamic> {
|
||||
}
|
||||
|
||||
@override
|
||||
bool customHandleResponse(bool isRefresh, Success<MsgFeedLikeMe> response) {
|
||||
MsgFeedLikeMe data = response.response;
|
||||
bool customHandleResponse(bool isRefresh, Success<MsgLikeData> response) {
|
||||
MsgLikeData data = response.response;
|
||||
if (data.total?.cursor?.isEnd == true ||
|
||||
data.total?.items.isNullOrEmpty == true) {
|
||||
isEnd = true;
|
||||
}
|
||||
cursor = data.total?.cursor?.id;
|
||||
cursorTime = data.total?.cursor?.time;
|
||||
List<LikeMeItems> latest = data.latest?.items ?? [];
|
||||
List<LikeMeItems> total = data.total?.items ?? [];
|
||||
List<MsgLikeItem> latest = data.latest?.items ?? <MsgLikeItem>[];
|
||||
List<MsgLikeItem> total = data.total?.items ?? <MsgLikeItem>[];
|
||||
if (!isRefresh && loadingState.value.isSuccess) {
|
||||
Pair<List<LikeMeItems>, List<LikeMeItems>> pair = loadingState.value.data;
|
||||
Pair<List<MsgLikeItem>, List<MsgLikeItem>> pair = loadingState.value.data;
|
||||
latest.insertAll(0, pair.first);
|
||||
total.insertAll(0, pair.second);
|
||||
}
|
||||
@@ -54,14 +56,14 @@ class LikeMeController extends CommonDataController<MsgFeedLikeMe, dynamic> {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<MsgFeedLikeMe>> customGetData() =>
|
||||
Future<LoadingState<MsgLikeData>> customGetData() =>
|
||||
MsgHttp.msgFeedLikeMe(cursor: cursor, cursorTime: cursorTime);
|
||||
|
||||
Future<void> onRemove(dynamic id, int index, bool isLatest) async {
|
||||
try {
|
||||
var res = await MsgHttp.delMsgfeed(0, id);
|
||||
if (res['status']) {
|
||||
Pair<List<LikeMeItems>, List<LikeMeItems>> pair =
|
||||
Pair<List<MsgLikeItem>, List<MsgLikeItem>> pair =
|
||||
loadingState.value.data;
|
||||
if (isLatest) {
|
||||
pair.first.removeAt(index);
|
||||
@@ -81,7 +83,7 @@ class LikeMeController extends CommonDataController<MsgFeedLikeMe, dynamic> {
|
||||
int noticeState = isNotice ? 1 : 0;
|
||||
var res = await MsgHttp.msgSetNotice(id: id, noticeState: noticeState);
|
||||
if (res['status']) {
|
||||
Pair<List<LikeMeItems>, List<LikeMeItems>> pair = loadingState.value.data;
|
||||
Pair<List<MsgLikeItem>, List<MsgLikeItem>> pair = loadingState.value.data;
|
||||
if (isLatest) {
|
||||
pair.first[index].noticeState = noticeState;
|
||||
} else {
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'package:PiliPlus/grpc/bilibili/app/im/v1.pbenum.dart'
|
||||
show IMSettingType;
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/image_type.dart';
|
||||
import 'package:PiliPlus/models/msg/msgfeed_like_me.dart';
|
||||
import 'package:PiliPlus/models_new/msg/msg_like/item.dart';
|
||||
import 'package:PiliPlus/pages/msg_feed_top/like_me/controller.dart';
|
||||
import 'package:PiliPlus/pages/whisper_settings/view.dart';
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
@@ -73,9 +73,9 @@ class _LikeMePageState extends State<LikeMePage> {
|
||||
},
|
||||
),
|
||||
Success(:var response) => () {
|
||||
Pair<List<LikeMeItems>, List<LikeMeItems>> pair = response;
|
||||
List<LikeMeItems> latest = pair.first;
|
||||
List<LikeMeItems> total = pair.second;
|
||||
Pair<List<MsgLikeItem>, List<MsgLikeItem>> pair = response;
|
||||
List<MsgLikeItem> latest = pair.first;
|
||||
List<MsgLikeItem> total = pair.second;
|
||||
if (latest.isNotEmpty || total.isNotEmpty) {
|
||||
return SliverMainAxisGroup(
|
||||
slivers: [
|
||||
@@ -171,7 +171,7 @@ class _LikeMePageState extends State<LikeMePage> {
|
||||
|
||||
Widget _buildItem(
|
||||
ThemeData theme,
|
||||
LikeMeItems item,
|
||||
MsgLikeItem item,
|
||||
ValueChanged<int?> onRemove,
|
||||
Function(bool isNotice, int? id) onSetNotice,
|
||||
) {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/msg.dart';
|
||||
import 'package:PiliPlus/models/msg/msgfeed_reply_me.dart';
|
||||
import 'package:PiliPlus/models_new/msg/msg_reply/data.dart';
|
||||
import 'package:PiliPlus/models_new/msg/msg_reply/item.dart';
|
||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
|
||||
class ReplyMeController
|
||||
extends CommonListController<MsgFeedReplyMe, ReplyMeItems> {
|
||||
extends CommonListController<MsgReplyData, MsgReplyItem> {
|
||||
int? cursor;
|
||||
int? cursorTime;
|
||||
|
||||
@@ -16,19 +17,13 @@ class ReplyMeController
|
||||
}
|
||||
|
||||
@override
|
||||
List<ReplyMeItems>? getDataList(MsgFeedReplyMe response) {
|
||||
return response.items;
|
||||
}
|
||||
|
||||
@override
|
||||
bool customHandleResponse(bool isRefresh, Success<MsgFeedReplyMe> response) {
|
||||
final data = response.response;
|
||||
if (data.cursor?.isEnd == true) {
|
||||
List<MsgReplyItem>? getDataList(MsgReplyData response) {
|
||||
if (response.cursor?.isEnd == true) {
|
||||
isEnd = true;
|
||||
}
|
||||
cursor = data.cursor?.id;
|
||||
cursorTime = data.cursor?.time;
|
||||
return false;
|
||||
cursor = response.cursor?.id;
|
||||
cursorTime = response.cursor?.time;
|
||||
return response.items;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -39,7 +34,7 @@ class ReplyMeController
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<MsgFeedReplyMe>> customGetData() =>
|
||||
Future<LoadingState<MsgReplyData>> customGetData() =>
|
||||
MsgHttp.msgFeedReplyMe(cursor: cursor, cursorTime: cursorTime);
|
||||
|
||||
Future<void> onRemove(dynamic id, int index) async {
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:PiliPlus/grpc/bilibili/app/im/v1.pbenum.dart'
|
||||
show IMSettingType;
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/image_type.dart';
|
||||
import 'package:PiliPlus/models/msg/msgfeed_reply_me.dart';
|
||||
import 'package:PiliPlus/models_new/msg/msg_reply/item.dart';
|
||||
import 'package:PiliPlus/pages/msg_feed_top/reply_me/controller.dart';
|
||||
import 'package:PiliPlus/pages/whisper_settings/view.dart';
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
@@ -64,7 +64,7 @@ class _ReplyMePageState extends State<ReplyMePage> {
|
||||
}
|
||||
|
||||
Widget _buildBody(
|
||||
ThemeData theme, LoadingState<List<ReplyMeItems>?> loadingState) {
|
||||
ThemeData theme, LoadingState<List<MsgReplyItem>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => SliverList.builder(
|
||||
itemCount: 12,
|
||||
@@ -80,7 +80,7 @@ class _ReplyMePageState extends State<ReplyMePage> {
|
||||
_replyMeController.onLoadMore();
|
||||
}
|
||||
|
||||
ReplyMeItems item = response[index];
|
||||
MsgReplyItem item = response[index];
|
||||
return ListTile(
|
||||
onTap: () {
|
||||
String? nativeUri = item.item?.nativeUri;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/msg.dart';
|
||||
import 'package:PiliPlus/models/msg/msgfeed_sys_msg.dart';
|
||||
import 'package:PiliPlus/models_new/msg/msg_sys/data.dart';
|
||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
|
||||
class SysMsgController
|
||||
extends CommonListController<List<SystemNotifyList>?, SystemNotifyList> {
|
||||
extends CommonListController<List<MsgSysItem>?, MsgSysItem> {
|
||||
final pageSize = 20;
|
||||
int? cursor;
|
||||
|
||||
@@ -16,7 +16,7 @@ class SysMsgController
|
||||
}
|
||||
|
||||
@override
|
||||
void handleListResponse(List<SystemNotifyList> dataList) {
|
||||
void handleListResponse(List<MsgSysItem> dataList) {
|
||||
if (cursor == null) {
|
||||
msgSysUpdateCursor(dataList.first.cursor);
|
||||
}
|
||||
@@ -53,6 +53,6 @@ class SysMsgController
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<List<SystemNotifyList>?>> customGetData() =>
|
||||
Future<LoadingState<List<MsgSysItem>?>> customGetData() =>
|
||||
MsgHttp.msgFeedNotify(cursor: cursor, pageSize: pageSize);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:PiliPlus/common/widgets/dialog/dialog.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/msg/msgfeed_sys_msg.dart';
|
||||
import 'package:PiliPlus/models_new/msg/msg_sys/data.dart';
|
||||
import 'package:PiliPlus/pages/msg_feed_top/sys_msg/controller.dart';
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
import 'package:PiliPlus/utils/id_utils.dart';
|
||||
@@ -49,7 +49,7 @@ class _SysMsgPageState extends State<SysMsgPage> {
|
||||
}
|
||||
|
||||
Widget _buildBody(
|
||||
ThemeData theme, LoadingState<List<SystemNotifyList>?> loadingState) {
|
||||
ThemeData theme, LoadingState<List<MsgSysItem>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => SliverSafeArea(
|
||||
sliver: SliverList.builder(
|
||||
|
||||
Reference in New Issue
Block a user