diff --git a/lib/src/components/components.dart b/lib/src/components/components.dart
index a518073..acc917e 100644
--- a/lib/src/components/components.dart
+++ b/lib/src/components/components.dart
@@ -17,6 +17,28 @@
* along with this program. If not, see .
*/
+import 'package:flutter/material.dart';
+
export 'date_time_editor.dart';
export 'error.dart';
export 'team_chip.dart';
+export 'select_gamemode_component.dart';
+export 'select_map_component.dart';
+
+class Disabled extends StatelessWidget {
+ final String? initialValue;
+ const Disabled({Key? key, this.initialValue = ""}) : super(key: key);
+
+ @override
+ Widget build(BuildContext context) {
+ return DropdownMenu(
+ width: 200,
+ label: Text(initialValue!),
+ enabled: false,
+ dropdownMenuEntries: [
+ if (initialValue != null)
+ DropdownMenuEntry(value: initialValue, label: initialValue!),
+ ],
+ );
+ }
+}
diff --git a/lib/src/components/select_gamemode_component.dart b/lib/src/components/select_gamemode_component.dart
new file mode 100644
index 0000000..8853c36
--- /dev/null
+++ b/lib/src/components/select_gamemode_component.dart
@@ -0,0 +1,70 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2023 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+import 'package:flutter/material.dart';
+import 'package:hooks_riverpod/hooks_riverpod.dart';
+import 'package:steamwar_multitool/src/provider/data.dart';
+
+import 'components.dart';
+
+class SelectGameModeComponent extends HookConsumerWidget {
+ final String? initialValue;
+ final void Function(String?) onChanged;
+
+ const SelectGameModeComponent({
+ Key? key,
+ required this.initialValue,
+ required this.onChanged,
+ }) : super(key: key);
+
+ @override
+ Widget build(BuildContext context, WidgetRef ref) {
+ return ref.watch(fightServersProvider).when(
+ data: (data) {
+ if (initialValue != null && !data.contains(initialValue)) {
+ return Disabled(
+ initialValue: initialValue,
+ );
+ }
+
+ return DropdownMenu(
+ width: 200,
+ menuHeight: 300,
+ initialSelection: initialValue,
+ onSelected: onChanged,
+ enableFilter: true,
+ enableSearch: true,
+ label: const Text("Game Mode"),
+ dropdownMenuEntries: [
+ const DropdownMenuEntry(value: null, label: ""),
+ for (final gameMode in data)
+ DropdownMenuEntry(
+ value: gameMode,
+ label: gameMode,
+ ),
+ ],
+ );
+ },
+ error: (error, stack) => Disabled(
+ initialValue: initialValue,
+ ),
+ loading: () => const Disabled(initialValue: "Game Mode"),
+ );
+ }
+}
diff --git a/lib/src/components/select_map_component.dart b/lib/src/components/select_map_component.dart
new file mode 100644
index 0000000..1486843
--- /dev/null
+++ b/lib/src/components/select_map_component.dart
@@ -0,0 +1,110 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2023 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+import 'dart:math';
+
+import 'package:flutter/material.dart';
+import 'package:hooks_riverpod/hooks_riverpod.dart';
+import 'package:steamwar_multitool/src/components/components.dart';
+import 'package:steamwar_multitool/src/provider/data.dart';
+
+class SelectMapComponent extends HookConsumerWidget {
+ final String? gameMode;
+ final String? initialValue;
+ final void Function(String?) onChanged;
+
+ const SelectMapComponent({
+ Key? key,
+ required this.gameMode,
+ required this.initialValue,
+ required this.onChanged,
+ }) : super(key: key);
+
+ @override
+ Widget build(BuildContext context, WidgetRef ref) {
+ if (gameMode == null) {
+ return const Disabled(initialValue: "Select Map");
+ }
+
+ return ProviderScope(
+ overrides: [
+ mapGameModeProvider.overrideWithValue(gameMode!),
+ mapsProvider
+ ],
+ child: _SelectMapInternal(
+ initialValue: initialValue,
+ onChanged: onChanged,
+ ),
+ );
+ }
+}
+
+class _SelectMapInternal extends HookConsumerWidget {
+ final String? initialValue;
+ final void Function(String?) onChanged;
+
+ const _SelectMapInternal({
+ Key? key,
+ required this.initialValue,
+ required this.onChanged,
+ }) : super(key: key);
+
+ @override
+ Widget build(BuildContext context, WidgetRef ref) {
+ final maps = ref.watch(mapsProvider);
+ return maps.when(
+ data: (data) {
+ return DropdownMenu(
+ width: 200,
+ menuHeight: 300,
+ initialSelection: initialValue,
+ onSelected: (value) {
+ if (value == "%random%") {
+ onChanged(data[Random().nextInt(data.length)]);
+ return;
+ }
+ onChanged(value);
+ },
+ enableSearch: true,
+ enableFilter: true,
+ label: const Text("Select Map"),
+ dropdownMenuEntries: [
+ const DropdownMenuEntry(
+ value: null,
+ label: "",
+ ),
+ const DropdownMenuEntry(
+ value: "%random%",
+ label: "Random",
+ ),
+ for (final map in data)
+ DropdownMenuEntry(
+ value: map,
+ label: map,
+ ),
+ ],
+ );
+ },
+ error: (error, stack) => Disabled(
+ initialValue: initialValue,
+ ),
+ loading: () => const Disabled(initialValue: "Select Map"),
+ );
+ }
+}
diff --git a/lib/src/provider/data.dart b/lib/src/provider/data.dart
index 9f21a28..789c6b4 100644
--- a/lib/src/provider/data.dart
+++ b/lib/src/provider/data.dart
@@ -43,15 +43,17 @@ final schematicTypesProvider = FutureProvider((ref) async {
});
});
-final mapsProvider = FutureProvider