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)
```shell
GO111MODULE=on go get -u -a github.com/go-flutter-desktop/hover
# 或
go install github.com/go-flutter-desktop/hover@latest
```
- 安装gcc
```shell
@ -139,11 +141,11 @@ VPN->代理->分流, 这三个功能如果同时设置, 您会在您手机的VPN
- [安装gomobile](https://github.com/golang/mobile)
```shell
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等)
```shell
cd go/mobile
go get golang.org/x/mobile/cmd/gobind
sh bind-ios.sh
sh bind-android.sh
cd ../../

View File

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

View File

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

View File

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