pikapika/lib/screens/components/ComicListBuilder.dart

57 lines
1.4 KiB
Dart
Raw Normal View History

import 'package:event/event.dart';
2021-09-29 23:57:09 +00:00
import 'package:flutter/material.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/basic/Entities.dart';
import 'package:pikapika/basic/config/ShadowCategories.dart';
import 'package:pikapika/screens/components/ComicList.dart';
import 'package:pikapika/screens/components/FitButton.dart';
2021-09-29 23:57:09 +00:00
import 'ContentBuilder.dart';
class ComicListBuilder extends StatefulWidget {
2021-09-29 23:57:09 +00:00
final Future<List<ComicSimple>> future;
final Future Function() reload;
ComicListBuilder(this.future, this.reload);
@override
State<StatefulWidget> createState() => _ComicListBuilderState();
}
class _ComicListBuilderState extends State<ComicListBuilder> {
@override
void initState() {
shadowCategoriesEvent.subscribe(_onShadowChange);
super.initState();
}
@override
void dispose() {
shadowCategoriesEvent.unsubscribe(_onShadowChange);
super.dispose();
}
void _onShadowChange(EventArgs? args) {
setState(() {});
}
2021-09-29 23:57:09 +00:00
@override
Widget build(BuildContext context) {
return ContentBuilder(
future: widget.future,
onRefresh: widget.reload,
2021-09-29 23:57:09 +00:00
successBuilder:
(BuildContext context, AsyncSnapshot<List<ComicSimple>> snapshot) {
return RefreshIndicator(
onRefresh: widget.reload,
2021-09-29 23:57:09 +00:00
child: ComicList(
snapshot.data!,
appendWidget: FitButton(
onPressed: widget.reload,
2021-09-29 23:57:09 +00:00
text: '刷新',
),
),
);
},
);
}
}