Skip to content

Commit

Permalink
finalize the design changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mrquantumoff committed Jan 15, 2024
1 parent ec2bf88 commit 7d3af3f
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 70 deletions.
14 changes: 11 additions & 3 deletions lib/pages/web/mod/install_mod_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class _InstallModPageState extends State<InstallModPage> {
List<Widget> dependencies = [
Container(
margin: const EdgeInsets.symmetric(vertical: 48, horizontal: 12),
child: const LinearProgressIndicator(),
child: const CircularProgressIndicator(),
),
];
@override
Expand Down Expand Up @@ -858,8 +858,16 @@ class _InstallModPageState extends State<InstallModPage> {
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,
),
),
],
),
Expand Down
141 changes: 74 additions & 67 deletions lib/pages/web/mod/mod.dart
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class _ModState extends State<Mod> 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 {
Expand Down Expand Up @@ -310,6 +310,79 @@ class _ModState extends State<Mod> 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)
Expand Down Expand Up @@ -354,72 +427,6 @@ class _ModState extends State<Mod> 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(
Expand Down

0 comments on commit 7d3af3f

Please sign in to comment.