ConanServerManager/client/lib/home.dart
2024-05-22 00:14:25 -07:00

107 lines
3.3 KiB
Dart

import 'dart:io';
import 'package:file_selector/file_selector.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:servermanager/settings.dart';
class HomePage extends StatefulWidget {
Settings settings;
HomePage({super.key, required this.settings});
@override
HomePageState createState() => HomePageState(settings: settings);
}
class HomePageState extends State<HomePage> {
Settings settings = Settings();
HomePageState({required this.settings});
@override
Widget build(BuildContext context) {
settings.Read();
return Scaffold(
appBar: AppBar(
title: Text("Conan Exiles Server Manager"),
backgroundColor: Color.fromARGB(255, 100, 0, 0),
),
drawer: Drawer(
child: SingleChildScrollView(
child: Column(children: [
DrawerHeader(
child: Column(
children: [
Icon(Icons.computer),
Text("Conan Exiles Server Manager")
],
)),
Column(
children: [
ListTile(
title: Text("S E R V E R"),
leading: Icon(Icons.cloud),
subtitle: Text("The game server!"),
onTap: () {
Navigator.pushNamed(context, "/server");
},
)
],
)
]),
)),
body: SingleChildScrollView(
padding: EdgeInsets.all(16),
child: Column(
children: [
if (Platform.isLinux)
ListTile(
title: Text("Proton"),
leading: Icon(CupertinoIcons.gear),
subtitle: Text("Linux Proton"),
onTap: () {
if (settings.steamcmd_path.isNotEmpty) {
Navigator.pushNamed(context, "/proton");
}
},
), // Not yet implemented
ListTile(
title: Text("SteamCMD"),
leading: Icon(Icons.comment_rounded),
subtitle: settings.steamcmd_path.isEmpty
? Text("Path Not Set")
: Text(settings.steamcmd_path),
onTap: () {
if (settings.steamcmd_path.isNotEmpty) {
Navigator.pushNamed(context, "/steamcmd");
}
},
),
ListTile(
title: Text("Server Path"),
leading: Icon(CupertinoIcons.folder),
subtitle: settings.game_path.isEmpty
? Text("Not Set")
: Text(settings.game_path),
onTap: () async {
var path = await getDirectoryPath();
setState(() {
if (path != null && path.isNotEmpty) {
settings.game_path = path;
settings.steamcmd_path =
"$path${Platform.pathSeparator}scmd";
Directory.current = Directory(settings.game_path);
}
});
await settings.Open();
settings.Read();
},
)
],
)),
);
}
}