download list add RefreshIndicator

This commit is contained in:
niuhuan 2021-10-24 14:37:46 +08:00
parent 3591c316ba
commit ca956ccb4c
4 changed files with 53 additions and 44 deletions

View File

@ -91,6 +91,8 @@ VPN->代理->分流, 这三个功能如果同时设置, 您会在您手机的VPN
- [安装hover(go-flutter编译脚手架)](https://github.com/go-flutter-desktop/hover) - [安装hover(go-flutter编译脚手架)](https://github.com/go-flutter-desktop/hover)
```shell ```shell
GO111MODULE=on go get -u -a github.com/go-flutter-desktop/hover GO111MODULE=on go get -u -a github.com/go-flutter-desktop/hover
# 或
go install github.com/go-flutter-desktop/hover@latest
``` ```
- 安装gcc - 安装gcc
```shell ```shell
@ -139,11 +141,11 @@ VPN->代理->分流, 这三个功能如果同时设置, 您会在您手机的VPN
- [安装gomobile](https://github.com/golang/mobile) - [安装gomobile](https://github.com/golang/mobile)
```shell ```shell
go install golang.org/x/mobile/cmd/gomobile@latest go install golang.org/x/mobile/cmd/gomobile@latest
go get golang.org/x/mobile/cmd/gobind
``` ```
- 执行编译命令 (bind-android.sh/bind-ios.sh根据平台选择, $system替换为apk/ipa等) - 执行编译命令 (bind-android.sh/bind-ios.sh根据平台选择, $system替换为apk/ipa等)
```shell ```shell
cd go/mobile cd go/mobile
go get golang.org/x/mobile/cmd/gobind
sh bind-ios.sh sh bind-ios.sh
sh bind-android.sh sh bind-android.sh
cd ../../ cd ../../

View File

@ -74,8 +74,10 @@ func (p *Plugin) InitPlugin(messenger plugin.BinaryMessenger) error {
func (p *Plugin) InitPluginGLFW(window *glfw.Window) error { func (p *Plugin) InitPluginGLFW(window *glfw.Window) error {
window.SetSizeCallback(func(w *glfw.Window, width int, height int) { window.SetSizeCallback(func(w *glfw.Window, width int, height int) {
go func() {
properties.SaveProperty("window_width", strconv.Itoa(width)) properties.SaveProperty("window_width", strconv.Itoa(width))
properties.SaveProperty("window_height", strconv.Itoa(height)) properties.SaveProperty("window_height", strconv.Itoa(height))
}()
}) })
return nil return nil
} }

View File

@ -25,4 +25,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
COCOAPODS: 1.10.1 COCOAPODS: 1.11.2

View File

@ -68,20 +68,18 @@ class _DownloadListScreenState extends State<DownloadListScreen> {
future: _f, future: _f,
builder: (BuildContext context, builder: (BuildContext context,
AsyncSnapshot<List<DownloadComic>> snapshot) { AsyncSnapshot<List<DownloadComic>> snapshot) {
if (snapshot.connectionState != ConnectionState.done) {
return ContentLoading(label: '加载中');
}
if (snapshot.hasError) { if (snapshot.hasError) {
print("${snapshot.error}"); print("${snapshot.error}");
print("${snapshot.stackTrace}"); print("${snapshot.stackTrace}");
return Center(child: Text('加载失败')); return Center(child: Text('加载失败'));
} }
if (snapshot.connectionState != ConnectionState.done) {
return ContentLoading(label: '加载中');
}
var data = snapshot.data!; var data = snapshot.data!;
if (_downloading != null) { if (_downloading != null) {
print(_downloading);
try { try {
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
if (_downloading!.id == data[i].id) { if (_downloading!.id == data[i].id) {
@ -94,10 +92,25 @@ class _DownloadListScreenState extends State<DownloadListScreen> {
} }
} }
return ListView( return RefreshIndicator(
onRefresh: () async {
setState(() {
_f = method.allDownloads();
});
},
child: ListView(
children: [ children: [
...data.map( ...data.map(downloadWidget),
(e) => InkWell( ],
),
);
},
),
);
}
Widget downloadWidget(DownloadComic e) {
return InkWell(
onTap: () { onTap: () {
if (e.deleting) { if (e.deleting) {
return; return;
@ -113,8 +126,7 @@ class _DownloadListScreenState extends State<DownloadListScreen> {
); );
}, },
onLongPress: () async { onLongPress: () async {
String? action = String? action = await chooseListDialog(context, e.title, ['删除']);
await chooseListDialog(context, e.title, ['删除']);
if (action == '删除') { if (action == '删除') {
await method.deleteDownloadComic(e.id); await method.deleteDownloadComic(e.id);
setState(() => e.deleting = true); setState(() => e.deleting = true);
@ -122,14 +134,7 @@ class _DownloadListScreenState extends State<DownloadListScreen> {
}, },
child: DownloadInfoCard( child: DownloadInfoCard(
task: e, task: e,
downloading: downloading: _downloading != null && _downloading!.id == e.id,
_downloading != null && _downloading!.id == e.id,
),
),
),
],
);
},
), ),
); );
} }