mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-26 11:08:44 +00: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,
|
||||
|
||||
Reference in New Issue
Block a user