Skip to content

Commit

Permalink
Split main menu into two screens (projects&settings)
Browse files Browse the repository at this point in the history
  • Loading branch information
TechnicJelle committed Sep 21, 2024
1 parent 4b5af29 commit 4325f5e
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 31 deletions.
70 changes: 43 additions & 27 deletions lib/main_menu/main_menu.dart
Original file line number Diff line number Diff line change
@@ -1,37 +1,53 @@
import "package:flutter/material.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";

import "../prefs.dart";
import "java/java_picker.dart";
import "path_picker_button.dart";
import "settings/projects_screen.dart";
import "settings/settings_screen.dart";

class MainMenu extends ConsumerWidget {
enum MainMenuState {
projects,
settings,
}

class MainMenu extends ConsumerStatefulWidget {
const MainMenu({super.key});

@override
Widget build(BuildContext context, WidgetRef ref) {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const JavaPicker(),
if (ref.watch(javaPathProvider.select((path) => path != null))) ...[
ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 600),
child: const Divider(),
),
const Text("Select an empty folder to store your BlueMap files in:"),
const SizedBox(height: 8),
const PathPickerButton(),
const SizedBox(height: 8),
const Text("The BlueMap CLI tool will be downloaded into that folder."),
const SizedBox(height: 4),
const Text("It will generate some default config files for you."),
const SizedBox(height: 4),
const Text("You will then need to configure your maps in the BlueMap GUI."),
],
],
),
ConsumerState<MainMenu> createState() => _MainMenuState();
}

class _MainMenuState extends ConsumerState<MainMenu> {
MainMenuState state = MainMenuState.projects;

@override
Widget build(BuildContext context) {
return Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Container(
constraints: const BoxConstraints(maxWidth: 200),
child: ListView(
children: [
ListTile(
title: const Text("Projects"),
selected: state == MainMenuState.projects,
onTap: () => setState(() => state = MainMenuState.projects),
),
ListTile(
title: const Text("Settings"),
selected: state == MainMenuState.settings,
onTap: () => setState(() => state = MainMenuState.settings),
),
],
),
),
Expanded(
child: switch (state) {
MainMenuState.projects => const ProjectsScreen(),
MainMenuState.settings => const SettingsScreen(),
},
),
],
);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "package:flutter/material.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";

import "../../prefs.dart";
import "../../../prefs.dart";
import "radio_list_tile_custom_java_picker.dart";
import "radio_list_tile_system_java_picker.dart";

Expand All @@ -28,8 +28,6 @@ class JavaPicker extends ConsumerWidget {
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Text("Select your Java executable:"),
const SizedBox(height: 4),
RadioListTileSystemJavaPicker(
groupValue: javaPickerMode,
onSet: () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "package:flutter/material.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";

import "../../utils.dart";
import "../../../utils.dart";
import "java_picker.dart";
import "util_for_checking_java_path_version.dart";

Expand Down
35 changes: 35 additions & 0 deletions lib/main_menu/settings/projects_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import "package:flutter/material.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";

import "../../prefs.dart";
import "../path_picker_button.dart";

class ProjectsScreen extends ConsumerWidget {
const ProjectsScreen({super.key});

@override
Widget build(BuildContext context, WidgetRef ref) {
if (ref.watch(javaPathProvider.select((path) => path == null))) {
return const Center(
child: Text("⬅ Please select your Java in the settings"),
);
}

return const Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text("Select an empty folder to store your BlueMap files in:"),
SizedBox(height: 8),
PathPickerButton(),
SizedBox(height: 8),
Text("The BlueMap CLI tool will be downloaded into that folder."),
SizedBox(height: 4),
Text("It will generate some default config files for you."),
SizedBox(height: 4),
Text("You will then need to configure your maps in the BlueMap GUI."),
],
),
);
}
}
16 changes: 16 additions & 0 deletions lib/main_menu/settings/settings_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import "package:flutter/material.dart";

import "java/java_picker.dart";

class SettingsScreen extends StatelessWidget {
const SettingsScreen({super.key});

@override
Widget build(BuildContext context) {
return ListView(children: const [
Text("Java Executable"), //TODO: Add link to download Java
SizedBox(height: 4),
JavaPicker(),
]);
}
}

0 comments on commit 4325f5e

Please sign in to comment.