Get wrapper working
This commit is contained in:
parent
0ae098318a
commit
26434a9123
19 changed files with 211 additions and 255 deletions
|
@ -54,7 +54,8 @@ class ModManagerState extends State<ModManager> {
|
|||
padding: EdgeInsets.all(12),
|
||||
child: ListTile(
|
||||
title: Text(mod.mod_name),
|
||||
subtitle: Text("ID: ${mod.mod_id}\nLoad Order: ${idx}"),
|
||||
subtitle: Text(
|
||||
"ID: ${mod.mod_id}\nLoad Order: ${idx}\nEnabled: ${mod.enabled}"),
|
||||
onTap: () async {
|
||||
final reply = await Navigator.pushNamed(
|
||||
context, "/server/mods/edit",
|
||||
|
@ -63,7 +64,8 @@ class ModManagerState extends State<ModManager> {
|
|||
mod_name: mod.mod_name,
|
||||
mod_pak: mod.mod_pak,
|
||||
mod_hash: mod.mod_hash,
|
||||
newMod: false));
|
||||
newMod: false,
|
||||
enabled: mod.enabled));
|
||||
|
||||
if (reply != null) {
|
||||
if (reply is bool) {
|
||||
|
@ -100,8 +102,12 @@ class ModManagerState extends State<ModManager> {
|
|||
}
|
||||
}
|
||||
|
||||
class ModPage extends StatelessWidget {
|
||||
bool initDone = false;
|
||||
class ModPage extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() => ModPageState();
|
||||
}
|
||||
|
||||
class ModPageState extends State<ModPage> {
|
||||
TextEditingController id = TextEditingController();
|
||||
TextEditingController name = TextEditingController();
|
||||
String instance = "";
|
||||
|
@ -109,23 +115,25 @@ class ModPage extends StatelessWidget {
|
|||
bool willDelete = false;
|
||||
String pak = "Not initialized";
|
||||
String hash = "";
|
||||
bool enabled = false;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
final args = ModalRoute.of(context)!.settings.arguments as Mod?;
|
||||
|
||||
if (args != null) {
|
||||
id.text = args.mod_id.toString();
|
||||
name.text = args.mod_name;
|
||||
isNewMod = args.newMod;
|
||||
instance = args.mod_instance_id();
|
||||
pak = args.mod_pak;
|
||||
hash = args.mod_hash;
|
||||
enabled = args.enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final args = ModalRoute.of(context)!.settings.arguments as Mod?;
|
||||
|
||||
if (!initDone) {
|
||||
initDone = true;
|
||||
if (args != null) {
|
||||
id.text = args.mod_id.toString();
|
||||
name.text = args.mod_name;
|
||||
isNewMod = args.newMod;
|
||||
instance = args.mod_instance_id();
|
||||
pak = args.mod_pak;
|
||||
hash = args.mod_hash;
|
||||
}
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Mod Editor"),
|
||||
|
@ -142,8 +150,13 @@ class ModPage extends StatelessWidget {
|
|||
if (willDelete) {
|
||||
Navigator.pop(context, true);
|
||||
} else {
|
||||
Navigator.pop(context,
|
||||
Mod(mod_id: idVal, mod_name: name.text, newMod: false));
|
||||
Navigator.pop(
|
||||
context,
|
||||
Mod(
|
||||
mod_id: idVal,
|
||||
mod_name: name.text,
|
||||
newMod: false,
|
||||
enabled: enabled));
|
||||
}
|
||||
},
|
||||
),
|
||||
|
@ -202,6 +215,16 @@ class ModPage extends StatelessWidget {
|
|||
title: Text("Mod Hash"),
|
||||
subtitle: Text(hash),
|
||||
),
|
||||
SwitchListTile(
|
||||
value: enabled,
|
||||
onChanged: (V) {
|
||||
setState(() {
|
||||
enabled = V;
|
||||
});
|
||||
},
|
||||
title: Text("Enabled"),
|
||||
subtitle: Text("Whether mod is enabled or not"),
|
||||
),
|
||||
if (!isNewMod)
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
|
@ -216,7 +239,7 @@ class ModPage extends StatelessWidget {
|
|||
),
|
||||
Text("Remove Mod")
|
||||
],
|
||||
))
|
||||
)),
|
||||
]),
|
||||
),
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue