mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-29 23:10:13 +08:00
opt handle res
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/user.dart';
|
||||
import 'package:PiliPlus/models/fav_article/data.dart';
|
||||
import 'package:PiliPlus/models/fav_article/item.dart';
|
||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
|
||||
class FavArticleController extends CommonListController {
|
||||
class FavArticleController
|
||||
extends CommonListController<FavArticleData, FavArticleItemModel> {
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
@@ -11,20 +14,16 @@ class FavArticleController extends CommonListController {
|
||||
}
|
||||
|
||||
@override
|
||||
List? getDataList(response) {
|
||||
return response?['items'];
|
||||
}
|
||||
|
||||
@override
|
||||
bool customHandleResponse(bool isRefresh, Success response) {
|
||||
if (response.response?['has_more'] == false) {
|
||||
List<FavArticleItemModel>? getDataList(FavArticleData response) {
|
||||
if (response.hasMore == false) {
|
||||
isEnd = true;
|
||||
}
|
||||
return false;
|
||||
return response.items;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState> customGetData() => UserHttp.favArticle(page: page);
|
||||
Future<LoadingState<FavArticleData>> customGetData() =>
|
||||
UserHttp.favArticle(page: page);
|
||||
|
||||
Future<void> onRemove(index, id) async {
|
||||
final res = await UserHttp.communityAction(opusId: id, action: 4);
|
||||
|
||||
@@ -4,6 +4,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/fav_article/item.dart';
|
||||
import 'package:PiliPlus/pages/fav/article/controller.dart';
|
||||
import 'package:PiliPlus/pages/fav/article/widget/item.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
@@ -47,7 +48,7 @@ class _FavArticlePageState extends State<FavArticlePage>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody(LoadingState<List<dynamic>?> loadingState) {
|
||||
Widget _buildBody(LoadingState<List<FavArticleItemModel>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
@@ -74,7 +75,7 @@ class _FavArticlePageState extends State<FavArticlePage>
|
||||
onConfirm: () {
|
||||
_favArticleController.onRemove(
|
||||
index,
|
||||
response[index]['opus_id'],
|
||||
response[index].opusId,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/button/icon_button.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/stat/stat.dart';
|
||||
import 'package:PiliPlus/models/fav_article/item.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
@@ -12,7 +13,7 @@ class FavArticleItem extends StatelessWidget {
|
||||
required this.onDelete,
|
||||
});
|
||||
|
||||
final dynamic item;
|
||||
final FavArticleItemModel item;
|
||||
final VoidCallback onDelete;
|
||||
|
||||
@override
|
||||
@@ -27,7 +28,7 @@ class FavArticleItem extends StatelessWidget {
|
||||
onTap: () => Get.toNamed(
|
||||
'/articlePage',
|
||||
parameters: {
|
||||
'id': item['opus_id'],
|
||||
'id': item.opusId!.toString(),
|
||||
'type': 'opus',
|
||||
},
|
||||
),
|
||||
@@ -40,14 +41,14 @@ class FavArticleItem extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (item['cover'] != null) ...[
|
||||
if (item.cover != null) ...[
|
||||
AspectRatio(
|
||||
aspectRatio: StyleString.aspectRatio,
|
||||
child: LayoutBuilder(
|
||||
builder: (BuildContext context,
|
||||
BoxConstraints boxConstraints) {
|
||||
return NetworkImgLayer(
|
||||
src: item['cover']['url'],
|
||||
src: item.cover!.url,
|
||||
width: boxConstraints.maxWidth,
|
||||
height: boxConstraints.maxHeight,
|
||||
);
|
||||
@@ -63,7 +64,7 @@ class FavArticleItem extends StatelessWidget {
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
item['content'],
|
||||
item.content!,
|
||||
style: TextStyle(
|
||||
fontSize: theme.textTheme.bodyMedium!.fontSize,
|
||||
height: 1.42,
|
||||
@@ -77,7 +78,7 @@ class FavArticleItem extends StatelessWidget {
|
||||
children: [
|
||||
// StatView(
|
||||
// context: context,
|
||||
// value: item['stat']['view'],
|
||||
// value: item.stat!.view!,
|
||||
// goto: 'picture',
|
||||
// textColor: theme.colorScheme.outline,
|
||||
// ),
|
||||
@@ -85,16 +86,15 @@ class FavArticleItem extends StatelessWidget {
|
||||
StatView(
|
||||
context: context,
|
||||
goto: 'like',
|
||||
value: item['stat']['like'] == ''
|
||||
? 0
|
||||
: item['stat']['like'],
|
||||
value:
|
||||
item.stat!.like == '' ? 0 : item.stat!.like!,
|
||||
textColor: theme.colorScheme.outline,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
'${item['author']['name']} · ${item['pub_time']}',
|
||||
'${item.author!.name} · ${item.pubTime}',
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
|
||||
@@ -132,7 +132,7 @@ class _FavNoteChildPageState extends State<FavNoteChildPage>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody(LoadingState<List<FavArticleModel>?> loadingState) {
|
||||
Widget _buildBody(LoadingState<List<FavNoteModel>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:PiliPlus/pages/common/multi_select_controller.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
|
||||
class FavNoteController
|
||||
extends MultiSelectController<List<FavArticleModel>?, FavArticleModel> {
|
||||
extends MultiSelectController<List<FavNoteModel>?, FavNoteModel> {
|
||||
FavNoteController(this.isPublish);
|
||||
|
||||
final bool isPublish;
|
||||
@@ -28,15 +28,15 @@ class FavNoteController
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<List<FavArticleModel>?>> customGetData() {
|
||||
Future<LoadingState<List<FavNoteModel>?>> customGetData() {
|
||||
return isPublish
|
||||
? VideoHttp.userNoteList(page: page)
|
||||
: VideoHttp.noteList(page: page);
|
||||
}
|
||||
|
||||
Future<void> onRemove() async {
|
||||
List<FavArticleModel> dataList = (loadingState.value as Success).response;
|
||||
Set<FavArticleModel> removeList =
|
||||
List<FavNoteModel> dataList = (loadingState.value as Success).response;
|
||||
Set<FavNoteModel> removeList =
|
||||
dataList.where((item) => item.checked == true).toSet();
|
||||
final res = await VideoHttp.delNote(
|
||||
isPublish: isPublish,
|
||||
@@ -45,7 +45,7 @@ class FavNoteController
|
||||
.toList(),
|
||||
);
|
||||
if (res['status']) {
|
||||
List<FavArticleModel> remainList =
|
||||
List<FavNoteModel> remainList =
|
||||
dataList.toSet().difference(removeList).toList();
|
||||
loadingState.value = Success(remainList);
|
||||
enableMultiSelect.value = false;
|
||||
|
||||
@@ -13,7 +13,7 @@ class FavNoteItem extends StatelessWidget {
|
||||
required this.onSelect,
|
||||
});
|
||||
|
||||
final FavArticleModel item;
|
||||
final FavNoteModel item;
|
||||
final FavNoteController ctr;
|
||||
final VoidCallback onSelect;
|
||||
|
||||
|
||||
@@ -4,7 +4,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/bangumi/list.dart';
|
||||
import 'package:PiliPlus/models/pgc/list.dart';
|
||||
import 'package:PiliPlus/pages/fav/pgc/controller.dart';
|
||||
import 'package:PiliPlus/pages/fav/pgc/widget/item.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
@@ -111,15 +111,15 @@ class _FavPgcChildPageState extends State<FavPgcChildPage>
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
...[
|
||||
{'followStatus': 1, 'title': '想看'},
|
||||
{'followStatus': 2, 'title': '在看'},
|
||||
{'followStatus': 3, 'title': '看过'},
|
||||
...const <({int followStatus, String title})>[
|
||||
(followStatus: 1, title: '想看'),
|
||||
(followStatus: 2, title: '在看'),
|
||||
(followStatus: 3, title: '看过'),
|
||||
]
|
||||
.where((item) =>
|
||||
item['followStatus'] != widget.followStatus)
|
||||
item.followStatus != widget.followStatus)
|
||||
.map(
|
||||
(Map item) => Padding(
|
||||
(item) => Padding(
|
||||
padding: const EdgeInsets.only(left: 25),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
@@ -127,14 +127,14 @@ class _FavPgcChildPageState extends State<FavPgcChildPage>
|
||||
if (_favPgcController.checkedCount.value !=
|
||||
0) {
|
||||
_favPgcController
|
||||
.onUpdateList(item['followStatus']);
|
||||
.onUpdateList(item.followStatus);
|
||||
}
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 14, horizontal: 5),
|
||||
child: Text(
|
||||
'标记为${item['title']}',
|
||||
'标记为${item.title}',
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:PiliPlus/http/bangumi.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/models/bangumi/list.dart';
|
||||
import 'package:PiliPlus/models/pgc/list.dart';
|
||||
import 'package:PiliPlus/pages/common/multi_select_controller.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -2,8 +2,8 @@ import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/badge.dart';
|
||||
import 'package:PiliPlus/common/widgets/button/icon_button.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/models/bangumi/list.dart';
|
||||
import 'package:PiliPlus/models/common/badge_type.dart';
|
||||
import 'package:PiliPlus/models/pgc/list.dart';
|
||||
import 'package:PiliPlus/pages/common/multi_select_controller.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -144,10 +144,10 @@ class FavPgcItem extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(item.title!),
|
||||
if (item.newEp?['index_show'] != null) ...[
|
||||
if (item.newEp?.indexShow != null) ...[
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
'${item.newEp?['index_show']}${item.isFinish == 0 && item.renewalTime?.isNotEmpty == true ? ',${item.renewalTime}' : ''}',
|
||||
'${item.newEp!.indexShow}${item.isFinish == 0 && item.renewalTime?.isNotEmpty == true ? ',${item.renewalTime}' : ''}',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
@@ -156,8 +156,7 @@ class FavPgcItem extends StatelessWidget {
|
||||
],
|
||||
if (item.progress != null) ...[
|
||||
SizedBox(
|
||||
height:
|
||||
item.newEp?['index_show'] != null ? 2 : 6),
|
||||
height: item.newEp?.indexShow != null ? 2 : 6),
|
||||
Text(
|
||||
item.progress!,
|
||||
style: TextStyle(
|
||||
|
||||
Reference in New Issue
Block a user