pikapika/lib/screens/GameDownloadScreen.dart

94 lines
2.5 KiB
Dart
Raw Normal View History

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/Cross.dart';
import 'package:pikapika/basic/Entities.dart';
import 'package:pikapika/basic/Method.dart';
import 'package:pikapika/screens/components/ItemBuilder.dart';
2021-09-29 23:57:09 +00:00
import 'components/GameTitleCard.dart';
2023-05-08 09:57:28 +00:00
import 'components/ListView.dart';
2022-03-19 04:12:27 +00:00
import 'components/RightClickPop.dart';
2021-09-29 23:57:09 +00:00
2021-10-26 11:04:23 +00:00
// 游戏下载地址列表页
2021-09-29 23:57:09 +00:00
class GameDownloadScreen extends StatefulWidget {
final GameInfo info;
const GameDownloadScreen(this.info, {Key? key}) : super(key: key);
@override
State<StatefulWidget> createState() => _GameDownloadScreenState();
}
class _GameDownloadScreenState extends State<GameDownloadScreen> {
late Future<List<String>> _future =
2022-03-17 03:31:25 +00:00
method.downloadGame(widget.info.androidLinks[0]);
2021-09-29 23:57:09 +00:00
@override
2022-03-19 04:12:27 +00:00
Widget build(BuildContext context){
2022-03-25 14:57:30 +00:00
return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
2022-03-19 04:12:27 +00:00
}
Widget buildScreen(BuildContext context) {
2021-09-29 23:57:09 +00:00
return Scaffold(
appBar: AppBar(
title: Text("下载 - ${widget.info.title}"),
),
2023-05-08 09:57:28 +00:00
body: PikaListView(
2021-09-29 23:57:09 +00:00
children: [
GameTitleCard(widget.info),
ItemBuilder(
future: _future,
onRefresh: () async {
setState(() {
_future =
2022-03-17 03:31:25 +00:00
method.downloadGame(widget.info.androidLinks[0]);
2021-09-29 23:57:09 +00:00
});
},
successBuilder:
(BuildContext context, AsyncSnapshot<List<String>> snapshot) {
2022-03-17 03:31:25 +00:00
return Column(
children: [
Container(
padding: const EdgeInsets.all(30),
child: const Text('获取到下载链接, 您只需要选择其中一个'),
),
...snapshot.data!.map((e) => _copyCard(e)),
],
2021-09-29 23:57:09 +00:00
);
},
),
],
),
);
}
Widget _copyCard(String string) {
return InkWell(
onTap: () {
copyToClipBoard(context, string);
},
child: Row(
children: [
Expanded(
child: Container(
2022-03-19 04:12:27 +00:00
margin: const EdgeInsets.all(10),
padding: const EdgeInsets.all(10),
2021-09-29 23:57:09 +00:00
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey.shade500,
width: .5,
style: BorderStyle.solid,
),
),
child: Text(string),
),
),
],
),
);
}
}