diff --git a/lib/pages/web/mod/install_mod_page.dart b/lib/pages/web/mod/install_mod_page.dart index 6d897a0..fab49d3 100644 --- a/lib/pages/web/mod/install_mod_page.dart +++ b/lib/pages/web/mod/install_mod_page.dart @@ -49,7 +49,7 @@ class _InstallModPageState extends State { List dependencies = [ Container( margin: const EdgeInsets.symmetric(vertical: 48, horizontal: 12), - child: const LinearProgressIndicator(), + child: const CircularProgressIndicator(), ), ]; @override @@ -858,8 +858,16 @@ class _InstallModPageState extends State { onSelected: (newValue) => updateDependencies(), ), ), - Column( - children: dependencies, + SizedBox( + height: 720, + child: GridView.extent( + maxCrossAxisExtent: 540, + mainAxisSpacing: 15, + crossAxisSpacing: 0, + childAspectRatio: 1.35, + padding: const EdgeInsets.only(bottom: 0), + children: dependencies, + ), ), ], ), diff --git a/lib/pages/web/mod/mod.dart b/lib/pages/web/mod/mod.dart index f6e2ff8..148cadd 100644 --- a/lib/pages/web/mod/mod.dart +++ b/lib/pages/web/mod/mod.dart @@ -254,7 +254,7 @@ class _ModState extends State with AutomaticKeepAliveClientMixin { children: [ Container( margin: - const EdgeInsets.symmetric(vertical: 0, horizontal: 12), + const EdgeInsets.symmetric(vertical: 8, horizontal: 12), child: widget.downloadable ? FilledButton.icon( onPressed: () async { @@ -310,6 +310,79 @@ class _ModState extends State with AutomaticKeepAliveClientMixin { ) : null, ), + Container( + margin: widget.showPreVersion + ? const EdgeInsets.symmetric(horizontal: 0) + : EdgeInsets.symmetric( + vertical: (showUpdateButton ? 20 : 50), + horizontal: 0), + child: !isNewVersionUrl || !areButttonsActive + ? showUpdateButton + ? Container( + margin: const EdgeInsets.symmetric( + horizontal: 12, vertical: 8), + child: FilledButton.icon( + onPressed: () async { + setState(() { + showUpdateButton = false; + areButttonsActive = false; + }); + http.Response res = await http + .get(Uri.parse(widget.newVersionUrl)); + Directory modpackFolder = Directory( + "${getMinecraftFolder().path}/modpacks/${widget.modpackToUpdate}"); + File resFile = File( + "${modpackFolder.path}/${widget.newVersionUrl.trim().split("/").last}"); + if (!await resFile.exists()) { + await resFile.create(recursive: true); + } + await resFile.writeAsBytes(res.bodyBytes, + flush: true, mode: FileMode.write); + File modConfig = File( + "${modpackFolder.path}/modConfig.json"); + Map modConf = json + .decode((await modConfig.readAsString())); + int modIndex = 0; + + for (var mod in modConf["mods"]) { + if (mod["id"] != widget.id) { + modIndex += 1; + } else { + modConf["mods"][modIndex]["downloadUrl"] = + widget.newVersionUrl; + break; + } + } + String newConf = json.encode(modConf); + await modConfig.writeAsString(newConf); + + File oldVer = File( + "${modpackFolder.path}/${widget.preVersion}"); + if (await oldVer.exists()) { + await oldVer.delete(); + } + setState(() { + hide = true; + }); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + AppLocalizations.of(context)! + .downloadSuccess), + ), + ); + }, + icon: const Icon(Icons.update), + label: + Text(AppLocalizations.of(context)!.update), + ), + ) + : SizedBox.fromSize( + size: const Size(240, 2), + child: const LinearProgressIndicator(), + ) + : Container(), + ), Container( margin: widget.downloadable ? const EdgeInsets.symmetric(horizontal: 0) @@ -354,72 +427,6 @@ class _ModState extends State with AutomaticKeepAliveClientMixin { label: Text(AppLocalizations.of(context)!.openInTheWeb), ), ), - Container( - margin: widget.showPreVersion - ? const EdgeInsets.symmetric(horizontal: 0) - : EdgeInsets.symmetric( - vertical: (showUpdateButton ? 20 : 50)), - child: !isNewVersionUrl || !areButttonsActive - ? showUpdateButton - ? FilledButton.icon( - onPressed: () async { - setState(() { - showUpdateButton = false; - areButttonsActive = false; - }); - http.Response res = await http - .get(Uri.parse(widget.newVersionUrl)); - Directory modpackFolder = Directory( - "${getMinecraftFolder().path}/modpacks/${widget.modpackToUpdate}"); - File resFile = File( - "${modpackFolder.path}/${widget.newVersionUrl.trim().split("/").last}"); - if (!await resFile.exists()) { - await resFile.create(recursive: true); - } - await resFile.writeAsBytes(res.bodyBytes, - flush: true, mode: FileMode.write); - File modConfig = File( - "${modpackFolder.path}/modConfig.json"); - Map modConf = json - .decode((await modConfig.readAsString())); - int modIndex = 0; - - for (var mod in modConf["mods"]) { - if (mod["id"] != widget.id) { - modIndex += 1; - } else { - modConf["mods"][modIndex]["downloadUrl"] = - widget.newVersionUrl; - break; - } - } - String newConf = json.encode(modConf); - await modConfig.writeAsString(newConf); - - File oldVer = File( - "${modpackFolder.path}/${widget.preVersion}"); - if (await oldVer.exists()) { - await oldVer.delete(); - } - setState(() { - hide = true; - }); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text(AppLocalizations.of(context)! - .downloadSuccess), - ), - ); - }, - icon: const Icon(Icons.update), - label: Text(AppLocalizations.of(context)!.update), - ) - : SizedBox.fromSize( - size: const Size(240, 2), - child: const LinearProgressIndicator(), - ) - : Container(), - ), ], ), Container(