From 6bf0b1775a6a6a63bed0aa036c26756cfe3ea2db Mon Sep 17 00:00:00 2001 From: Incredible <46843455+Incr3dible@users.noreply.github.com> Date: Sat, 19 Sep 2020 16:50:22 +0200 Subject: [PATCH] 1.5.2 --- src/client/lib/pages/changelogPage.dart | 77 ++++++++++--------- src/client/lib/pages/statusPage.dart | 63 +++++++-------- src/client/lib/utils/fingerprintUtils.dart | 8 +- src/client/lib/widgets/ExpansionListTile.dart | 36 +++++++++ src/client/pubspec.yaml | 2 +- 5 files changed, 114 insertions(+), 72 deletions(-) create mode 100644 src/client/lib/widgets/ExpansionListTile.dart diff --git a/src/client/lib/pages/changelogPage.dart b/src/client/lib/pages/changelogPage.dart index db81cbf..9260ec8 100644 --- a/src/client/lib/pages/changelogPage.dart +++ b/src/client/lib/pages/changelogPage.dart @@ -214,15 +214,17 @@ class ChangelogPageState extends State builder: (BuildContext context) => ListTile( title: Text(log.sha), subtitle: Text(dateString), - onLongPress: () { - setState(() { - if (!compareModeOn) { - compareList.clear(); - compareList.add(log); - compareModeOn = true; - } - }); - }, + onLongPress: log.hasJson + ? () { + setState(() { + if (!compareModeOn) { + compareList.clear(); + compareList.add(log); + compareModeOn = true; + } + }); + } + : null, onTap: () { setState(() { if (compareList.contains(log)) { @@ -231,35 +233,38 @@ class ChangelogPageState extends State }); }, trailing: compareModeOn - ? Checkbox( - onChanged: compareList.length == 2 && !compareList.contains(log) - ? null - : (bool value) { - setState(() { - if (value) { - compareList.add(log); + ? log.hasJson + ? Checkbox( + onChanged: + compareList.length == 2 && !compareList.contains(log) + ? null + : (bool value) { + setState(() { + if (value) { + compareList.add(log); - if (compareList.length == 2) { - Navigator.push( - context, - new MaterialPageRoute( - builder: (BuildContext context) => - new FingerprintComparePage( - compareList, gameName), - ), - ); + if (compareList.length == 2) { + Navigator.push( + context, + new MaterialPageRoute( + builder: (BuildContext context) => + new FingerprintComparePage( + compareList, gameName), + ), + ); - setState(() { - compareModeOn = false; - }); - } - } else { - compareList.remove(log); - } - }); - }, - value: compareList.contains(log), - ) + setState(() { + compareModeOn = false; + }); + } + } else { + compareList.remove(log); + } + }); + }, + value: compareList.contains(log), + ) + : null : IconButton( icon: const Icon(Icons.content_copy), onPressed: () { diff --git a/src/client/lib/pages/statusPage.dart b/src/client/lib/pages/statusPage.dart index f884120..80a0de9 100644 --- a/src/client/lib/pages/statusPage.dart +++ b/src/client/lib/pages/statusPage.dart @@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:sc_utility/translationProvider.dart'; import 'package:sc_utility/utils/flutterextentions.dart'; +import 'package:sc_utility/widgets/ExpansionListTile.dart'; import '../resources.dart'; import '../api/models/GameStatus.dart'; import '../api/ApiClient.dart'; @@ -342,39 +343,41 @@ class StatusPageState extends State fontSize: 14, fontWeight: FontWeight.w600), ), ), - ListTile( - leading: Icon( - Icons.brightness_1, - color: statusColor, - ), - title: const Text("Status"), - subtitle: Text(statusName), - /*trailing: IconButton( + ExpansionListTile( + leading: Icon( + Icons.brightness_1, + color: statusColor, + ), + title: const Text("Status"), + subtitle: Text(statusName), + /*trailing: IconButton( icon: Icon(Icons.report), onPressed: () {}, ),*/ - ), - status.latestFingerprintVersion == "unknown" - ? SizedBox.shrink() - : ListTile( - trailing: Builder( - builder: (context) => IconButton( - icon: const Icon(Icons.history), - onPressed: () { - Navigator.push( - context, - new MaterialPageRoute( - builder: (BuildContext context) => - new ChangelogPage(status.gameName))); - }, - ), - ), - leading: const Icon( - Icons.fingerprint, - ), - title: Text(status.latestFingerprintVersion), - subtitle: Text(status.latestFingerprintSha), - ) + children: status.latestFingerprintVersion == "unknown" + ? null + : [ + ListTile( + trailing: Builder( + builder: (context) => IconButton( + icon: const Icon(Icons.history), + onPressed: () { + Navigator.push( + context, + new MaterialPageRoute( + builder: (BuildContext context) => + new ChangelogPage( + status.gameName))); + }, + ), + ), + leading: const Icon( + Icons.fingerprint, + ), + title: Text(status.latestFingerprintVersion), + subtitle: Text(status.latestFingerprintSha), + ) + ]), ], )), ), diff --git a/src/client/lib/utils/fingerprintUtils.dart b/src/client/lib/utils/fingerprintUtils.dart index 2fb068e..464ce65 100644 --- a/src/client/lib/utils/fingerprintUtils.dart +++ b/src/client/lib/utils/fingerprintUtils.dart @@ -52,13 +52,11 @@ class FingerprintUtils { static Future downloadFingerprint( FingerprintLog log, String gameName) async { - var fingerprintJson = log.hasJson - ? await http.get("https://api.incinc.xyz/fingerprint?gameName=" + + var fingerprintJson = await http.get( + "https://api.incinc.xyz/fingerprint?gameName=" + gameName + "&sha=" + - log.sha) - : await http - .get(getAssetHostByName(gameName) + log.sha + "/fingerprint.json"); + log.sha); if (fingerprintJson.statusCode == 200) return Fingerprint.fromJson(json.decode(fingerprintJson.body)); diff --git a/src/client/lib/widgets/ExpansionListTile.dart b/src/client/lib/widgets/ExpansionListTile.dart new file mode 100644 index 0000000..6458fe0 --- /dev/null +++ b/src/client/lib/widgets/ExpansionListTile.dart @@ -0,0 +1,36 @@ +import 'package:flutter/material.dart'; + +class ExpansionListTile extends StatefulWidget { + final Widget trailing; + final Widget title; + final Widget subtitle; + final Widget leading; + final List children; + + ExpansionListTile( + {this.trailing, this.title, this.subtitle, this.leading, this.children}); + + @override + ExpansionListTileState createState() => ExpansionListTileState(); +} + +class ExpansionListTileState extends State { + @override + Widget build(BuildContext context) { + return widget.children != null + ? ExpansionTile( + childrenPadding: EdgeInsets.zero, + title: widget.title, + trailing: widget.trailing, + subtitle: widget.subtitle, + leading: widget.leading, + children: widget.children, + ) + : ListTile( + title: widget.title, + trailing: widget.trailing, + subtitle: widget.subtitle, + leading: widget.leading, + ); + } +} diff --git a/src/client/pubspec.yaml b/src/client/pubspec.yaml index 9b43a91..5a19bd8 100644 --- a/src/client/pubspec.yaml +++ b/src/client/pubspec.yaml @@ -11,7 +11,7 @@ description: A tool for games # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.5.0+30 +version: 1.5.2+32 environment: sdk: ">=2.6.0 <3.0.0"