mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 12:57:24 +00:00
update ui
This commit is contained in:
@@ -13,6 +13,40 @@ abstract class LoadingState<T extends StatefulWidget, S extends Object> extends
|
||||
|
||||
Widget buildContent(BuildContext context, S data);
|
||||
|
||||
Widget buildError() {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(error!),
|
||||
const SizedBox(height: 12),
|
||||
Button(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
error = null;
|
||||
});
|
||||
loadData().then((value) {
|
||||
if(value.success) {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
data = value.data;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
error = value.errorMessage!;
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
child: const Text("Retry"),
|
||||
)
|
||||
],
|
||||
),
|
||||
).paddingHorizontal(16);
|
||||
}
|
||||
|
||||
@override
|
||||
@mustCallSuper
|
||||
void initState() {
|
||||
@@ -40,9 +74,7 @@ abstract class LoadingState<T extends StatefulWidget, S extends Object> extends
|
||||
child: ProgressRing(),
|
||||
);
|
||||
} else if (error != null){
|
||||
return Center(
|
||||
child: Text(error!),
|
||||
);
|
||||
return buildError();
|
||||
} else {
|
||||
return buildContent(context, data!);
|
||||
}
|
||||
@@ -131,8 +163,20 @@ abstract class MultiPageLoadingState<T extends StatefulWidget, S extends Object>
|
||||
|
||||
Widget buildError(BuildContext context, String error) {
|
||||
return Center(
|
||||
child: Text(error),
|
||||
);
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(error),
|
||||
const SizedBox(height: 12),
|
||||
Button(
|
||||
onPressed: () {
|
||||
reset();
|
||||
},
|
||||
child: const Text("Retry"),
|
||||
)
|
||||
],
|
||||
),
|
||||
).paddingHorizontal(16);
|
||||
}
|
||||
|
||||
@override
|
||||
|
25
lib/components/title_bar.dart
Normal file
25
lib/components/title_bar.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
|
||||
class TitleBar extends StatelessWidget {
|
||||
const TitleBar({required this.title, this.action, super.key});
|
||||
|
||||
final String title;
|
||||
|
||||
final Widget? action;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
child: Row(
|
||||
children: [
|
||||
Text(title,
|
||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),),
|
||||
const Spacer(),
|
||||
if(action != null)
|
||||
action!
|
||||
],
|
||||
).paddingHorizontal(16).paddingVertical(8),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user