2021-09-30 07:12:23 +00:00
|
|
|
import 'package:event/event.dart';
|
2021-09-29 23:57:09 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:pikapi/basic/Entities.dart';
|
2021-09-30 07:12:23 +00:00
|
|
|
import 'package:pikapi/basic/config/ShadowCategories.dart';
|
2021-09-29 23:57:09 +00:00
|
|
|
import 'package:pikapi/screens/components/ComicList.dart';
|
|
|
|
import 'package:pikapi/screens/components/FitButton.dart';
|
|
|
|
import 'ContentBuilder.dart';
|
|
|
|
|
2021-09-30 07:12:23 +00:00
|
|
|
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);
|
|
|
|
|
2021-09-30 07:12:23 +00:00
|
|
|
@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(
|
2021-09-30 07:12:23 +00:00
|
|
|
future: widget.future,
|
|
|
|
onRefresh: widget.reload,
|
2021-09-29 23:57:09 +00:00
|
|
|
successBuilder:
|
|
|
|
(BuildContext context, AsyncSnapshot<List<ComicSimple>> snapshot) {
|
|
|
|
return RefreshIndicator(
|
2021-09-30 07:12:23 +00:00
|
|
|
onRefresh: widget.reload,
|
2021-09-29 23:57:09 +00:00
|
|
|
child: ComicList(
|
|
|
|
snapshot.data!,
|
|
|
|
appendWidget: FitButton(
|
2021-09-30 07:12:23 +00:00
|
|
|
onPressed: widget.reload,
|
2021-09-29 23:57:09 +00:00
|
|
|
text: '刷新',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|