mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: set top dyn
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -764,4 +764,6 @@ class Api {
|
|||||||
static const String pgcTimeline = '/pgc/web/timeline';
|
static const String pgcTimeline = '/pgc/web/timeline';
|
||||||
|
|
||||||
static const String searchTrending = '/x/v2/search/trending/ranking';
|
static const String searchTrending = '/x/v2/search/trending/ranking';
|
||||||
|
|
||||||
|
static const String setTopDyn = '/x/dynamic/feed/space/set_top';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,4 +118,23 @@ class DynamicsHttp {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future setTop({
|
||||||
|
required dynamic dynamicId,
|
||||||
|
}) async {
|
||||||
|
var res = await Request().post(
|
||||||
|
Api.setTopDyn,
|
||||||
|
queryParameters: {
|
||||||
|
'csrf': await Request.getCsrf(),
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
'dyn_str': dynamicId,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (res.data['code'] == 0) {
|
||||||
|
return {'status': true};
|
||||||
|
} else {
|
||||||
|
return {'status': false, 'msg': res.data['message']};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,15 @@ class DynamicsTabController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future onSetTop(bool isTop, dynamic dynamicId) async {
|
||||||
|
var res = await DynamicsHttp.setTop(dynamicId: dynamicId);
|
||||||
|
if (res['status']) {
|
||||||
|
SmartDialog.showToast('${isTop ? '取消' : ''}置顶成功');
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(res['msg']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future onReload() {
|
Future onReload() {
|
||||||
scrollController.jumpToTop();
|
scrollController.jumpToTop();
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ class _DynamicsTabPageState
|
|||||||
DynamicPanel(
|
DynamicPanel(
|
||||||
item: i,
|
item: i,
|
||||||
onRemove: controller.onRemove,
|
onRemove: controller.onRemove,
|
||||||
|
// onSetTop: controller.onSetTop,
|
||||||
),
|
),
|
||||||
] else ...[
|
] else ...[
|
||||||
for (var i in loadingState.response!)
|
for (var i in loadingState.response!)
|
||||||
@@ -178,6 +179,7 @@ class _DynamicsTabPageState
|
|||||||
DynamicPanel(
|
DynamicPanel(
|
||||||
item: i,
|
item: i,
|
||||||
onRemove: controller.onRemove,
|
onRemove: controller.onRemove,
|
||||||
|
// onSetTop: controller.onSetTop,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@@ -203,6 +205,7 @@ class _DynamicsTabPageState
|
|||||||
return DynamicPanel(
|
return DynamicPanel(
|
||||||
item: item,
|
item: item,
|
||||||
onRemove: controller.onRemove,
|
onRemove: controller.onRemove,
|
||||||
|
// onSetTop: controller.onSetTop,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class AuthorPanel extends StatelessWidget {
|
|||||||
final String? source;
|
final String? source;
|
||||||
final Function? onRemove;
|
final Function? onRemove;
|
||||||
final bool isSave;
|
final bool isSave;
|
||||||
|
final Function(bool isTop, dynamic dynId)? onSetTop;
|
||||||
|
|
||||||
const AuthorPanel({
|
const AuthorPanel({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -33,6 +34,7 @@ class AuthorPanel extends StatelessWidget {
|
|||||||
this.source,
|
this.source,
|
||||||
this.onRemove,
|
this.onRemove,
|
||||||
this.isSave = false,
|
this.isSave = false,
|
||||||
|
this.onSetTop,
|
||||||
});
|
});
|
||||||
|
|
||||||
Widget _buildAvatar(double size) => NetworkImgLayer(
|
Widget _buildAvatar(double size) => NetworkImgLayer(
|
||||||
@@ -354,6 +356,18 @@ class AuthorPanel extends StatelessWidget {
|
|||||||
title:
|
title:
|
||||||
Text('检查动态', style: Theme.of(context).textTheme.titleSmall!),
|
Text('检查动态', style: Theme.of(context).textTheme.titleSmall!),
|
||||||
),
|
),
|
||||||
|
if (onSetTop != null)
|
||||||
|
ListTile(
|
||||||
|
onTap: () {
|
||||||
|
Get.back();
|
||||||
|
onSetTop!(item.modules?.moduleTag?.text != null, item.idStr);
|
||||||
|
},
|
||||||
|
minLeadingWidth: 0,
|
||||||
|
leading: const Icon(Icons.vertical_align_top, size: 19),
|
||||||
|
title: Text(
|
||||||
|
'${item.modules?.moduleTag?.text != null ? '取消' : ''}置顶',
|
||||||
|
style: Theme.of(context).textTheme.titleSmall!),
|
||||||
|
),
|
||||||
if (onRemove != null)
|
if (onRemove != null)
|
||||||
ListTile(
|
ListTile(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
|||||||
@@ -15,14 +15,16 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
final Function? onRemove;
|
final Function? onRemove;
|
||||||
final Function(List<String>, int)? callback;
|
final Function(List<String>, int)? callback;
|
||||||
final bool isSave;
|
final bool isSave;
|
||||||
|
final Function(bool isTop, dynamic dynId)? onSetTop;
|
||||||
|
|
||||||
const DynamicPanel({
|
const DynamicPanel({
|
||||||
|
super.key,
|
||||||
required this.item,
|
required this.item,
|
||||||
this.source,
|
this.source,
|
||||||
this.onRemove,
|
this.onRemove,
|
||||||
this.callback,
|
this.callback,
|
||||||
this.isSave = false,
|
this.isSave = false,
|
||||||
super.key,
|
this.onSetTop,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -134,6 +136,7 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
source: source,
|
source: source,
|
||||||
onRemove: onRemove,
|
onRemove: onRemove,
|
||||||
isSave: isSave,
|
isSave: isSave,
|
||||||
|
onSetTop: onSetTop,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (item!.modules!.moduleDynamic!.desc != null ||
|
if (item!.modules!.moduleDynamic!.desc != null ||
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:PiliPlus/http/dynamics.dart';
|
||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
import 'package:PiliPlus/http/msg.dart';
|
import 'package:PiliPlus/http/msg.dart';
|
||||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||||
@@ -66,4 +67,25 @@ class MemberDynamicsController
|
|||||||
SmartDialog.showToast(res['msg']);
|
SmartDialog.showToast(res['msg']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future onSetTop(bool isTop, dynamic dynamicId) async {
|
||||||
|
var res = await DynamicsHttp.setTop(dynamicId: dynamicId);
|
||||||
|
if (res['status']) {
|
||||||
|
List<DynamicItemModel> list = (loadingState.value as Success).response;
|
||||||
|
list[0].modules?.moduleTag = null;
|
||||||
|
if (isTop) {
|
||||||
|
loadingState.refresh();
|
||||||
|
SmartDialog.showToast('取消置顶成功');
|
||||||
|
} else {
|
||||||
|
final item = list.firstWhere((item) => item.idStr == dynamicId);
|
||||||
|
item.modules?.moduleTag = ModuleTag(text: '置顶');
|
||||||
|
list.remove(item);
|
||||||
|
list.insert(0, item);
|
||||||
|
loadingState.refresh();
|
||||||
|
SmartDialog.showToast('置顶成功');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(res['msg']);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ class _MemberDynamicsPageState extends State<MemberDynamicsPage>
|
|||||||
(item) => DynamicPanel(
|
(item) => DynamicPanel(
|
||||||
item: item,
|
item: item,
|
||||||
onRemove: _memberDynamicController.onRemove,
|
onRemove: _memberDynamicController.onRemove,
|
||||||
|
onSetTop: _memberDynamicController.onSetTop,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.toList(),
|
.toList(),
|
||||||
@@ -149,6 +150,7 @@ class _MemberDynamicsPageState extends State<MemberDynamicsPage>
|
|||||||
return DynamicPanel(
|
return DynamicPanel(
|
||||||
item: loadingState.response![index],
|
item: loadingState.response![index],
|
||||||
onRemove: _memberDynamicController.onRemove,
|
onRemove: _memberDynamicController.onRemove,
|
||||||
|
onSetTop: _memberDynamicController.onSetTop,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
childCount: loadingState.response!.length,
|
childCount: loadingState.response!.length,
|
||||||
|
|||||||
Reference in New Issue
Block a user