mod: 异常状态样式

This commit is contained in:
guozhigq
2023-08-19 17:50:26 +08:00
parent 740116e873
commit ec9d9739fe
12 changed files with 134 additions and 32 deletions

View File

@ -9,9 +9,10 @@ import 'package:pilipala/utils/storage.dart';
class HistoryController extends GetxController {
final ScrollController scrollController = ScrollController();
RxList<HisListItem> historyList = [HisListItem()].obs;
bool isLoadingMore = false;
RxBool isLoadingMore = false.obs;
RxBool pauseStatus = false.obs;
Box localCache = GStrorage.localCache;
RxBool isLoading = false.obs;
@override
void onInit() {
@ -26,9 +27,9 @@ class HistoryController extends GetxController {
max = historyList.last.history!.oid!;
viewAt = historyList.last.viewAt!;
}
isLoadingMore = true;
isLoadingMore.value = true;
var res = await UserHttp.historyList(max, viewAt);
isLoadingMore = false;
isLoadingMore.value = false;
if (res['status']) {
if (type == 'onload') {
historyList.addAll(res['data'].list);

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/skeleton/video_card_h.dart';
import 'package:pilipala/common/widgets/http_error.dart';
import 'package:pilipala/common/widgets/no_data.dart';
import 'package:pilipala/pages/history/index.dart';
import 'widgets/item.dart';
@ -27,7 +28,7 @@ class _HistoryPageState extends State<HistoryPage> {
if (_historyController.scrollController.position.pixels >=
_historyController.scrollController.position.maxScrollExtent -
300) {
if (!_historyController.isLoadingMore) {
if (!_historyController.isLoadingMore.value) {
_historyController.onLoad();
}
}
@ -92,13 +93,9 @@ class _HistoryPageState extends State<HistoryPage> {
Map data = snapshot.data;
if (data['status']) {
return Obx(
() => _historyController.historyList.isEmpty
? const SliverToBoxAdapter(
child: Center(
child: Text('没数据'),
),
)
: SliverList(
() => _historyController.historyList.isNotEmpty &&
!_historyController.isLoadingMore.value
? SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return HistoryItem(
@ -108,7 +105,12 @@ class _HistoryPageState extends State<HistoryPage> {
},
childCount:
_historyController.historyList.length),
),
)
: _historyController.isLoadingMore.value
? const SliverToBoxAdapter(
child: Center(child: Text('加载中')),
)
: const NoData(),
);
} else {
return HttpError(

View File

@ -116,7 +116,7 @@ class HistoryItem extends StatelessWidget {
children: [
Padding(
padding: const EdgeInsets.fromLTRB(
StyleString.cardSpace, 5, StyleString.cardSpace, 5),
StyleString.safeSpace, 5, StyleString.safeSpace, 5),
child: LayoutBuilder(
builder: (context, boxConstraints) {
double width =