mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 04:57:23 +00:00
user artworks; update ui
This commit is contained in:
@@ -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!);
|
||||
}
|
||||
|
Reference in New Issue
Block a user