user artworks; update ui

This commit is contained in:
wgh19
2024-05-13 19:43:24 +08:00
parent 0f225be531
commit 56917f22c1
10 changed files with 291 additions and 179 deletions

View File

@@ -89,30 +89,43 @@ abstract class MultiPageLoadingState<T extends StatefulWidget, S extends Object>
});
}
@override
void initState() {
loadData(_page).then((value) {
if(value.success) {
_page++;
setState(() {
_isFirstLoading = false;
_data = value.data;
});
} else {
setState(() {
_isFirstLoading = false;
_error = value.errorMessage!;
});
}
});
super.initState();
}
Widget buildLoading(BuildContext context) {
return const Center(
child: ProgressRing(),
);
}
Widget buildError(BuildContext context, String error) {
return Center(
child: Text(error),
);
}
@override
Widget build(BuildContext context) {
if(_isFirstLoading){
loadData(_page).then((value) {
if(value.success) {
_page++;
setState(() {
_isFirstLoading = false;
_data = value.data;
});
} else {
setState(() {
_isFirstLoading = false;
_error = value.errorMessage!;
});
}
});
return const Center(
child: ProgressRing(),
);
return buildLoading(context);
} else if (_error != null){
return Center(
child: Text(_error!),
);
return buildError(context, _error!);
} else {
return buildContent(context, _data!);
}