Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
851a55cf38 | ||
|
|
e9de38091e | ||
|
|
a582bbee29 | ||
|
|
30786f9706 | ||
|
|
fb4ab95f13 |
@@ -28,6 +28,7 @@ jobs:
|
|||||||
flutter create --platforms=android --org nfteam --project-name gamemanager .
|
flutter create --platforms=android --org nfteam --project-name gamemanager .
|
||||||
python3 tool/patch_android.py
|
python3 tool/patch_android.py
|
||||||
flutter pub get
|
flutter pub get
|
||||||
|
dart run flutter_launcher_icons
|
||||||
flutter build apk --release --build-name="${NAME}" --build-number="${RUN}"
|
flutter build apk --release --build-name="${NAME}" --build-number="${RUN}"
|
||||||
cp build/app/outputs/flutter-apk/app-release.apk gamemanager.apk
|
cp build/app/outputs/flutter-apk/app-release.apk gamemanager.apk
|
||||||
printf '{"version":"1.0.%s","version_code":%s,"notes":"Build CI #%s"}' "${RUN}" "${RUN}" "${RUN}" > version.json
|
printf '{"version":"1.0.%s","version_code":%s,"notes":"Build CI #%s"}' "${RUN}" "${RUN}" "${RUN}" > version.json
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
+2
-2
@@ -18,9 +18,9 @@ class GameManagerApp extends StatelessWidget {
|
|||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'GameManager',
|
title: 'GameManager',
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
theme: AppTheme.light(),
|
theme: AppTheme.dark(),
|
||||||
darkTheme: AppTheme.dark(),
|
darkTheme: AppTheme.dark(),
|
||||||
themeMode: ThemeMode.system,
|
themeMode: ThemeMode.dark,
|
||||||
home: AuthGate(auth: auth, api: api),
|
home: AuthGate(auth: auth, api: api),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ class GameServer {
|
|||||||
final String? motd;
|
final String? motd;
|
||||||
final bool hasIcon;
|
final bool hasIcon;
|
||||||
final bool hasImage;
|
final bool hasImage;
|
||||||
|
final bool custom;
|
||||||
|
final String? bluemapUrl;
|
||||||
|
|
||||||
const GameServer({
|
const GameServer({
|
||||||
required this.id,
|
required this.id,
|
||||||
@@ -34,6 +36,8 @@ class GameServer {
|
|||||||
this.motd,
|
this.motd,
|
||||||
this.hasIcon = false,
|
this.hasIcon = false,
|
||||||
this.hasImage = false,
|
this.hasImage = false,
|
||||||
|
this.custom = false,
|
||||||
|
this.bluemapUrl,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory GameServer.fromJson(Map<String, dynamic> json) => GameServer(
|
factory GameServer.fromJson(Map<String, dynamic> json) => GameServer(
|
||||||
@@ -52,8 +56,12 @@ class GameServer {
|
|||||||
motd: json['motd'] as String?,
|
motd: json['motd'] as String?,
|
||||||
hasIcon: json['has_icon'] as bool? ?? false,
|
hasIcon: json['has_icon'] as bool? ?? false,
|
||||||
hasImage: json['has_image'] as bool? ?? false,
|
hasImage: json['has_image'] as bool? ?? false,
|
||||||
|
custom: json['custom'] as bool? ?? false,
|
||||||
|
bluemapUrl: json['bluemap_url'] as String?,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
bool get hasMap => (bluemapUrl ?? '').isNotEmpty;
|
||||||
|
|
||||||
bool get isUp => status == 'online' || status == 'running';
|
bool get isUp => status == 'online' || status == 'running';
|
||||||
bool get isBusy => status == 'starting' || status == 'partial';
|
bool get isBusy => status == 'starting' || status == 'partial';
|
||||||
bool get isPreprod => env == 'preprod';
|
bool get isPreprod => env == 'preprod';
|
||||||
@@ -84,3 +92,83 @@ class GameServer {
|
|||||||
_ => (label: 'Éteint', color: const Color(0xFF8E8E93)),
|
_ => (label: 'Éteint', color: const Color(0xFF8E8E93)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Conteneur Docker (pour lier un serveur depuis l'app).
|
||||||
|
class DockerContainer {
|
||||||
|
DockerContainer({required this.name, required this.image, required this.state});
|
||||||
|
final String name;
|
||||||
|
final String image;
|
||||||
|
final String state;
|
||||||
|
|
||||||
|
factory DockerContainer.fromJson(Map<String, dynamic> j) => DockerContainer(
|
||||||
|
name: j['name'] as String,
|
||||||
|
image: (j['image'] as String?) ?? '',
|
||||||
|
state: (j['state'] as String?) ?? '',
|
||||||
|
);
|
||||||
|
|
||||||
|
bool get running => state == 'running';
|
||||||
|
|
||||||
|
/// Image sans le registre ni le digest, pour la lisibilité.
|
||||||
|
/// ex: git.nfteam.ovh/neckfire/the-cycle:preprod → the-cycle:preprod
|
||||||
|
String get prettyImage {
|
||||||
|
var s = image.split('/').last;
|
||||||
|
if (s.length > 34) s = '${s.substring(0, 33)}…';
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Infos « Se connecter » d'un serveur (API `/api/servers/{id}/connect`).
|
||||||
|
class ConnectInfo {
|
||||||
|
const ConnectInfo({
|
||||||
|
this.address,
|
||||||
|
this.mcVersion,
|
||||||
|
this.loader,
|
||||||
|
this.bluemapUrl,
|
||||||
|
this.voiceChatPort,
|
||||||
|
this.mrpackUrl,
|
||||||
|
this.instructions,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String? address;
|
||||||
|
final String? mcVersion;
|
||||||
|
final String? loader;
|
||||||
|
final String? bluemapUrl;
|
||||||
|
final int? voiceChatPort;
|
||||||
|
final String? mrpackUrl; // absolue (préfixée par la base API)
|
||||||
|
final List<String>? instructions;
|
||||||
|
|
||||||
|
bool get hasPack => (mrpackUrl ?? '').isNotEmpty;
|
||||||
|
|
||||||
|
/// `base` = URL de l'API, pour rendre `mrpack_url` (relatif) absolu.
|
||||||
|
factory ConnectInfo.fromJson(Map<String, dynamic> j, String base) {
|
||||||
|
final rel = j['mrpack_url'] as String?;
|
||||||
|
return ConnectInfo(
|
||||||
|
address: j['address'] as String?,
|
||||||
|
mcVersion: j['mc_version'] as String?,
|
||||||
|
loader: j['loader'] as String?,
|
||||||
|
bluemapUrl: j['bluemap_url'] as String?,
|
||||||
|
voiceChatPort: (j['voice_chat_port'] as num?)?.toInt(),
|
||||||
|
mrpackUrl: rel == null ? null : '$base$rel',
|
||||||
|
instructions: (j['instructions'] as List?)?.map((e) => e.toString()).toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Résultat de recherche Modrinth (proxy backend /api/modrinth/search).
|
||||||
|
class ModHit {
|
||||||
|
ModHit({required this.slug, required this.title, this.description, this.downloads, this.iconUrl});
|
||||||
|
|
||||||
|
final String slug;
|
||||||
|
final String title;
|
||||||
|
final String? description;
|
||||||
|
final int? downloads;
|
||||||
|
final String? iconUrl;
|
||||||
|
|
||||||
|
factory ModHit.fromJson(Map<String, dynamic> j) => ModHit(
|
||||||
|
slug: (j['slug'] as String?) ?? '',
|
||||||
|
title: (j['title'] as String?) ?? (j['slug'] as String?) ?? '',
|
||||||
|
description: j['description'] as String?,
|
||||||
|
downloads: j['downloads'] as int?,
|
||||||
|
iconUrl: j['icon_url'] as String?,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,230 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../models.dart';
|
||||||
|
import '../services/api_service.dart';
|
||||||
|
|
||||||
|
/// Formulaire d'ajout d'un serveur : infos + sélection du/des conteneur(s)
|
||||||
|
/// Docker liés (liste lisible : nom + image courte + état).
|
||||||
|
class AddServerScreen extends StatefulWidget {
|
||||||
|
const AddServerScreen({super.key, required this.api});
|
||||||
|
final ApiService api;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<AddServerScreen> createState() => _AddServerScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AddServerScreenState extends State<AddServerScreen> {
|
||||||
|
final _name = TextEditingController();
|
||||||
|
final _game = TextEditingController();
|
||||||
|
final _subtitle = TextEditingController();
|
||||||
|
final _connect = TextEditingController();
|
||||||
|
final _openUrl = TextEditingController();
|
||||||
|
final _minecraft = TextEditingController();
|
||||||
|
final _search = TextEditingController();
|
||||||
|
|
||||||
|
String _env = 'prod';
|
||||||
|
bool _web = false;
|
||||||
|
bool _onDemand = false;
|
||||||
|
final _selected = <String>{};
|
||||||
|
|
||||||
|
List<DockerContainer>? _containers;
|
||||||
|
String? _error;
|
||||||
|
bool _saving = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_loadContainers();
|
||||||
|
_search.addListener(() => setState(() {}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
for (final c in [_name, _game, _subtitle, _connect, _openUrl, _minecraft, _search]) {
|
||||||
|
c.dispose();
|
||||||
|
}
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadContainers() async {
|
||||||
|
try {
|
||||||
|
final list = await widget.api.containers();
|
||||||
|
if (mounted) setState(() => _containers = list);
|
||||||
|
} catch (e) {
|
||||||
|
if (mounted) setState(() => _error = '$e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _save() async {
|
||||||
|
if (_name.text.trim().isEmpty || _selected.isEmpty) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(content: Text('Nom et au moins un conteneur requis.')),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() => _saving = true);
|
||||||
|
try {
|
||||||
|
await widget.api.createServer({
|
||||||
|
'name': _name.text.trim(),
|
||||||
|
'game': _game.text.trim(),
|
||||||
|
'subtitle': _subtitle.text.trim(),
|
||||||
|
'env': _env,
|
||||||
|
'containers': _selected.toList(),
|
||||||
|
'connect': _web ? _openUrl.text.trim() : _connect.text.trim(),
|
||||||
|
'web': _web,
|
||||||
|
'open_url': _web ? _openUrl.text.trim() : null,
|
||||||
|
'minecraft': _minecraft.text.trim(),
|
||||||
|
'on_demand': _onDemand,
|
||||||
|
});
|
||||||
|
if (mounted) Navigator.pop(context, true);
|
||||||
|
} catch (e) {
|
||||||
|
if (mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('$e')));
|
||||||
|
setState(() => _saving = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(title: const Text('Nouveau serveur')),
|
||||||
|
body: ListView(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 8, 16, 100),
|
||||||
|
children: [
|
||||||
|
TextField(
|
||||||
|
controller: _name,
|
||||||
|
textCapitalization: TextCapitalization.words,
|
||||||
|
decoration: const InputDecoration(labelText: 'Nom *', hintText: 'ex: Valheim'),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
TextField(
|
||||||
|
controller: _game,
|
||||||
|
decoration: const InputDecoration(labelText: 'Jeu', hintText: 'ex: Valheim'),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
TextField(
|
||||||
|
controller: _subtitle,
|
||||||
|
decoration: const InputDecoration(labelText: 'Sous-titre', hintText: 'ex: serveur privé'),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_envSelector(),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
SwitchListTile(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
title: const Text('Jeu web (bouton « Ouvrir »)'),
|
||||||
|
value: _web,
|
||||||
|
onChanged: (v) => setState(() => _web = v),
|
||||||
|
),
|
||||||
|
if (_web)
|
||||||
|
TextField(
|
||||||
|
controller: _openUrl,
|
||||||
|
keyboardType: TextInputType.url,
|
||||||
|
decoration: const InputDecoration(labelText: 'URL du jeu', hintText: 'https://…'),
|
||||||
|
)
|
||||||
|
else ...[
|
||||||
|
TextField(
|
||||||
|
controller: _connect,
|
||||||
|
decoration: const InputDecoration(labelText: 'Adresse de connexion', hintText: 'ex: jeu.nfteam.ovh'),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
TextField(
|
||||||
|
controller: _minecraft,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Minecraft host:port (MOTD, optionnel)',
|
||||||
|
hintText: 'ex: 192.168.1.136:25565',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
SwitchListTile(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
title: const Text('Serveur à la demande'),
|
||||||
|
value: _onDemand,
|
||||||
|
onChanged: (v) => setState(() => _onDemand = v),
|
||||||
|
),
|
||||||
|
const Divider(height: 28),
|
||||||
|
Text('Conteneur(s) lié(s) *', style: Theme.of(context).textTheme.titleMedium),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
_containerPicker(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
floatingActionButton: FloatingActionButton.extended(
|
||||||
|
onPressed: _saving ? null : _save,
|
||||||
|
icon: _saving
|
||||||
|
? const SizedBox(width: 18, height: 18, child: CircularProgressIndicator(strokeWidth: 2))
|
||||||
|
: const Icon(Icons.check),
|
||||||
|
label: const Text('Créer'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _envSelector() {
|
||||||
|
return SegmentedButton<String>(
|
||||||
|
segments: const [
|
||||||
|
ButtonSegment(value: 'prod', label: Text('Production'), icon: Icon(Icons.public)),
|
||||||
|
ButtonSegment(value: 'preprod', label: Text('Preprod'), icon: Icon(Icons.science_outlined)),
|
||||||
|
],
|
||||||
|
selected: {_env},
|
||||||
|
onSelectionChanged: (s) => setState(() => _env = s.first),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _containerPicker() {
|
||||||
|
if (_error != null) {
|
||||||
|
return Text('Impossible de charger les conteneurs.\n$_error');
|
||||||
|
}
|
||||||
|
if (_containers == null) {
|
||||||
|
return const Padding(padding: EdgeInsets.all(20), child: Center(child: CircularProgressIndicator()));
|
||||||
|
}
|
||||||
|
final q = _search.text.toLowerCase();
|
||||||
|
final list = _containers!
|
||||||
|
.where((c) => q.isEmpty || c.name.toLowerCase().contains(q) || c.image.toLowerCase().contains(q))
|
||||||
|
.toList();
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
TextField(
|
||||||
|
controller: _search,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
prefixIcon: Icon(Icons.search),
|
||||||
|
hintText: 'Filtrer les conteneurs…',
|
||||||
|
isDense: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
if (_selected.isNotEmpty)
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: Text('${_selected.length} sélectionné(s)',
|
||||||
|
style: Theme.of(context).textTheme.labelMedium),
|
||||||
|
),
|
||||||
|
Card(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
for (final c in list)
|
||||||
|
CheckboxListTile(
|
||||||
|
dense: true,
|
||||||
|
value: _selected.contains(c.name),
|
||||||
|
onChanged: (v) => setState(() {
|
||||||
|
v == true ? _selected.add(c.name) : _selected.remove(c.name);
|
||||||
|
}),
|
||||||
|
title: Text(c.name, style: const TextStyle(fontWeight: FontWeight.w600)),
|
||||||
|
subtitle: Text(c.prettyImage,
|
||||||
|
maxLines: 1, overflow: TextOverflow.ellipsis,
|
||||||
|
style: const TextStyle(fontFamily: 'monospace', fontSize: 11)),
|
||||||
|
secondary: Container(
|
||||||
|
width: 10, height: 10,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: c.running ? const Color(0xFF34C759) : const Color(0xFF8E8E93),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (list.isEmpty)
|
||||||
|
const Padding(padding: EdgeInsets.all(16), child: Text('Aucun conteneur.')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,259 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../models.dart';
|
||||||
|
import '../services/api_service.dart';
|
||||||
|
|
||||||
|
/// Gestion des mods d'un serveur via Modrinth.
|
||||||
|
/// Lecture pour tous ceux qui ont accès ; ajout/retrait réservés aux admins
|
||||||
|
/// (le backend renvoie 403 sinon).
|
||||||
|
class ModsScreen extends StatefulWidget {
|
||||||
|
const ModsScreen({super.key, required this.api, required this.serverId, required this.serverName});
|
||||||
|
|
||||||
|
final ApiService api;
|
||||||
|
final String serverId;
|
||||||
|
final String serverName;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ModsScreen> createState() => _ModsScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ModsScreenState extends State<ModsScreen> {
|
||||||
|
bool _loading = true;
|
||||||
|
String? _error;
|
||||||
|
bool _isAdmin = false;
|
||||||
|
List<String> _installed = [];
|
||||||
|
|
||||||
|
final _searchCtrl = TextEditingController();
|
||||||
|
bool _searching = false;
|
||||||
|
List<ModHit> _results = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_load();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_searchCtrl.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _load() async {
|
||||||
|
setState(() {
|
||||||
|
_loading = true;
|
||||||
|
_error = null;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
final role = await widget.api.role().catchError((_) => 'member');
|
||||||
|
final mods = await widget.api.mods(widget.serverId);
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() {
|
||||||
|
_isAdmin = role == 'admin';
|
||||||
|
_installed = mods;
|
||||||
|
_loading = false;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() {
|
||||||
|
_error = '$e';
|
||||||
|
_loading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _search() async {
|
||||||
|
final q = _searchCtrl.text.trim();
|
||||||
|
setState(() => _searching = true);
|
||||||
|
try {
|
||||||
|
final hits = await widget.api.searchMods(q, widget.serverId);
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() => _results = hits);
|
||||||
|
} catch (e) {
|
||||||
|
_snack('$e');
|
||||||
|
} finally {
|
||||||
|
if (mounted) setState(() => _searching = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _add(ModHit hit) async {
|
||||||
|
try {
|
||||||
|
await widget.api.addMod(widget.serverId, hit.slug);
|
||||||
|
_snack('« ${hit.title} » ajouté — le serveur redémarre (téléchargement au boot).');
|
||||||
|
await _load();
|
||||||
|
} catch (e) {
|
||||||
|
_snack('$e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _remove(String slug) async {
|
||||||
|
final ok = await showDialog<bool>(
|
||||||
|
context: context,
|
||||||
|
builder: (c) => AlertDialog(
|
||||||
|
title: Text('Retirer $slug ?'),
|
||||||
|
content: const Text('Le serveur redémarrera pour appliquer le changement.'),
|
||||||
|
actions: [
|
||||||
|
TextButton(onPressed: () => Navigator.pop(c, false), child: const Text('Annuler')),
|
||||||
|
FilledButton(onPressed: () => Navigator.pop(c, true), child: const Text('Retirer')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (ok != true) return;
|
||||||
|
try {
|
||||||
|
await widget.api.removeMod(widget.serverId, slug);
|
||||||
|
_snack('« $slug » retiré — le serveur redémarre.');
|
||||||
|
await _load();
|
||||||
|
} catch (e) {
|
||||||
|
_snack('$e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _snack(String m) {
|
||||||
|
if (mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(m)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(title: Text('Mods — ${widget.serverName}')),
|
||||||
|
body: _loading
|
||||||
|
? const Center(child: CircularProgressIndicator())
|
||||||
|
: _error != null
|
||||||
|
? _ErrorState(message: _error!, onRetry: _load)
|
||||||
|
: RefreshIndicator(
|
||||||
|
onRefresh: _load,
|
||||||
|
child: ListView(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
children: [
|
||||||
|
_InstalledSection(
|
||||||
|
installed: _installed,
|
||||||
|
canRemove: _isAdmin,
|
||||||
|
onRemove: _remove,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
if (_isAdmin) ..._searchSection() else _memberNote(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _memberNote() => const Card(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.all(16),
|
||||||
|
child: Text('La gestion des mods est réservée aux administrateurs.'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
List<Widget> _searchSection() {
|
||||||
|
return [
|
||||||
|
Text('Ajouter depuis Modrinth', style: Theme.of(context).textTheme.titleMedium),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
TextField(
|
||||||
|
controller: _searchCtrl,
|
||||||
|
textInputAction: TextInputAction.search,
|
||||||
|
onSubmitted: (_) => _search(),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'Rechercher un mod (compatible avec ce serveur)…',
|
||||||
|
prefixIcon: const Icon(Icons.search),
|
||||||
|
suffixIcon: IconButton(icon: const Icon(Icons.arrow_forward), onPressed: _search),
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
if (_searching)
|
||||||
|
const Padding(padding: EdgeInsets.all(24), child: Center(child: CircularProgressIndicator()))
|
||||||
|
else if (_results.isEmpty)
|
||||||
|
const Padding(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 24),
|
||||||
|
child: Center(child: Text('Lance une recherche pour trouver des mods.')),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
..._results.map(_resultTile),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _resultTile(ModHit hit) {
|
||||||
|
final already = _installed.contains(hit.slug);
|
||||||
|
return Card(
|
||||||
|
child: ListTile(
|
||||||
|
leading: hit.iconUrl != null
|
||||||
|
? ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
child: Image.network(hit.iconUrl!, width: 40, height: 40,
|
||||||
|
errorBuilder: (_, __, ___) => const Icon(Icons.extension)),
|
||||||
|
)
|
||||||
|
: const Icon(Icons.extension),
|
||||||
|
title: Text(hit.title),
|
||||||
|
subtitle: Text(
|
||||||
|
hit.description ?? hit.slug,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
trailing: already
|
||||||
|
? const Chip(label: Text('Installé'))
|
||||||
|
: FilledButton.tonal(onPressed: () => _add(hit), child: const Text('Ajouter')),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _InstalledSection extends StatelessWidget {
|
||||||
|
const _InstalledSection({required this.installed, required this.canRemove, required this.onRemove});
|
||||||
|
|
||||||
|
final List<String> installed;
|
||||||
|
final bool canRemove;
|
||||||
|
final void Function(String slug) onRemove;
|
||||||
|
|
||||||
|
static const _core = {'fabric-api', 'fabricloader', 'forge', 'neoforge'};
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text('Mods installés (${installed.length})', style: Theme.of(context).textTheme.titleMedium),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
if (installed.isEmpty)
|
||||||
|
const Text('Aucun mod.')
|
||||||
|
else
|
||||||
|
Wrap(
|
||||||
|
spacing: 8,
|
||||||
|
runSpacing: 8,
|
||||||
|
children: [
|
||||||
|
for (final slug in installed)
|
||||||
|
InputChip(
|
||||||
|
label: Text(slug),
|
||||||
|
onDeleted: canRemove && !_core.contains(slug) ? () => onRemove(slug) : null,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ErrorState extends StatelessWidget {
|
||||||
|
const _ErrorState({required this.message, required this.onRetry});
|
||||||
|
final String message;
|
||||||
|
final VoidCallback onRetry;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(24),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.error_outline, size: 40),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Text(message, textAlign: TextAlign.center),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
FilledButton(onPressed: onRetry, child: const Text('Réessayer')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,9 @@ import 'package:url_launcher/url_launcher.dart';
|
|||||||
|
|
||||||
import '../models.dart';
|
import '../models.dart';
|
||||||
import '../services/api_service.dart';
|
import '../services/api_service.dart';
|
||||||
|
import '../widgets/connect_card.dart';
|
||||||
|
import '../widgets/server_map_card.dart';
|
||||||
|
import 'mods_screen.dart';
|
||||||
|
|
||||||
/// Détail d'un serveur : bannière (image importée ou thème), statut, connexion,
|
/// Détail d'un serveur : bannière (image importée ou thème), statut, connexion,
|
||||||
/// stats d'utilisation (CPU/RAM/réseau) et gestion de l'image (import/suppression).
|
/// stats d'utilisation (CPU/RAM/réseau) et gestion de l'image (import/suppression).
|
||||||
@@ -24,6 +27,8 @@ class _ServerDetailScreenState extends State<ServerDetailScreen> {
|
|||||||
|
|
||||||
Map<String, dynamic>? _stats;
|
Map<String, dynamic>? _stats;
|
||||||
Uint8List? _image;
|
Uint8List? _image;
|
||||||
|
ConnectInfo? _connect;
|
||||||
|
bool _connectLoading = true;
|
||||||
bool _busy = false;
|
bool _busy = false;
|
||||||
bool _imgBusy = false;
|
bool _imgBusy = false;
|
||||||
|
|
||||||
@@ -38,12 +43,15 @@ class _ServerDetailScreenState extends State<ServerDetailScreen> {
|
|||||||
widget.api.stats(s.id).catchError((_) => <String, dynamic>{'running': false}),
|
widget.api.stats(s.id).catchError((_) => <String, dynamic>{'running': false}),
|
||||||
widget.api.imageBytes(s.id).catchError((_) => null),
|
widget.api.imageBytes(s.id).catchError((_) => null),
|
||||||
widget.api.server(s.id).catchError((_) => _server),
|
widget.api.server(s.id).catchError((_) => _server),
|
||||||
|
widget.api.connectInfo(s.id).then<ConnectInfo?>((c) => c).catchError((_) => null),
|
||||||
]);
|
]);
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
_stats = results[0] as Map<String, dynamic>;
|
_stats = results[0] as Map<String, dynamic>;
|
||||||
_image = results[1] as Uint8List?;
|
_image = results[1] as Uint8List?;
|
||||||
_server = results[2] as GameServer;
|
_server = results[2] as GameServer;
|
||||||
|
_connect = results[3] as ConnectInfo?;
|
||||||
|
_connectLoading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,6 +95,27 @@ class _ServerDetailScreenState extends State<ServerDetailScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _confirmDelete() async {
|
||||||
|
final ok = await showDialog<bool>(
|
||||||
|
context: context,
|
||||||
|
builder: (ctx) => AlertDialog(
|
||||||
|
title: const Text('Supprimer ce serveur ?'),
|
||||||
|
content: Text('« ${s.name} » sera retiré de l\'app (le conteneur Docker n\'est pas touché).'),
|
||||||
|
actions: [
|
||||||
|
TextButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('Annuler')),
|
||||||
|
FilledButton(onPressed: () => Navigator.pop(ctx, true), child: const Text('Supprimer')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (ok != true) return;
|
||||||
|
try {
|
||||||
|
await widget.api.deleteServer(s.id);
|
||||||
|
if (mounted) Navigator.pop(context);
|
||||||
|
} catch (e) {
|
||||||
|
_snack('$e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _snack(String m) {
|
void _snack(String m) {
|
||||||
if (mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(m)));
|
if (mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(m)));
|
||||||
}
|
}
|
||||||
@@ -96,7 +125,25 @@ class _ServerDetailScreenState extends State<ServerDetailScreen> {
|
|||||||
final t = s.theme;
|
final t = s.theme;
|
||||||
final badge = s.statusBadge;
|
final badge = s.statusBadge;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: Text(s.name)),
|
appBar: AppBar(
|
||||||
|
title: Text(s.name),
|
||||||
|
actions: [
|
||||||
|
if (s.game.toLowerCase().contains('minecraft'))
|
||||||
|
IconButton(
|
||||||
|
tooltip: 'Mods',
|
||||||
|
icon: const Icon(Icons.extension_outlined),
|
||||||
|
onPressed: () => Navigator.of(context).push(MaterialPageRoute(
|
||||||
|
builder: (_) => ModsScreen(api: widget.api, serverId: s.id, serverName: s.name),
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
if (s.custom)
|
||||||
|
IconButton(
|
||||||
|
tooltip: 'Supprimer',
|
||||||
|
icon: const Icon(Icons.delete_outline),
|
||||||
|
onPressed: _confirmDelete,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
body: RefreshIndicator(
|
body: RefreshIndicator(
|
||||||
onRefresh: _load,
|
onRefresh: _load,
|
||||||
child: ListView(
|
child: ListView(
|
||||||
@@ -126,10 +173,15 @@ class _ServerDetailScreenState extends State<ServerDetailScreen> {
|
|||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
_toggleButton(),
|
_toggleButton(),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
if (s.connect != null) _info(Icons.link, 'Connexion', s.connect!),
|
|
||||||
if (s.status == 'online')
|
if (s.status == 'online')
|
||||||
_info(Icons.people, 'Joueurs', '${s.players ?? 0} / ${s.maxPlayers ?? 0}'),
|
_info(Icons.people, 'Joueurs', '${s.players ?? 0} / ${s.maxPlayers ?? 0}'),
|
||||||
if (s.motd != null) _info(Icons.chat_bubble_outline, 'MOTD', s.motd!),
|
if (s.motd != null) _info(Icons.chat_bubble_outline, 'MOTD', s.motd!),
|
||||||
|
if (s.hasMap) ...[
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
ServerMapCard(url: s.bluemapUrl!, serverUp: s.isUp),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
],
|
||||||
|
ConnectCard(info: _connect, loading: _connectLoading),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
_statsCard(),
|
_statsCard(),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../models.dart';
|
import '../models.dart';
|
||||||
@@ -5,6 +7,7 @@ import '../services/api_service.dart';
|
|||||||
import '../services/auth_service.dart';
|
import '../services/auth_service.dart';
|
||||||
import '../services/update_service.dart';
|
import '../services/update_service.dart';
|
||||||
import '../widgets/server_card.dart';
|
import '../widgets/server_card.dart';
|
||||||
|
import 'add_server_screen.dart';
|
||||||
import 'server_detail_screen.dart';
|
import 'server_detail_screen.dart';
|
||||||
import 'settings_screen.dart';
|
import 'settings_screen.dart';
|
||||||
|
|
||||||
@@ -27,6 +30,15 @@ class _ServersScreenState extends State<ServersScreen> {
|
|||||||
List<GameServer>? _servers;
|
List<GameServer>? _servers;
|
||||||
String? _error;
|
String? _error;
|
||||||
final _busy = <String>{};
|
final _busy = <String>{};
|
||||||
|
final _imgCache = <String, Uint8List?>{};
|
||||||
|
|
||||||
|
Future<Uint8List?> _image(GameServer s) async {
|
||||||
|
if (!s.hasImage) return null;
|
||||||
|
if (_imgCache.containsKey(s.id)) return _imgCache[s.id];
|
||||||
|
final b = await widget.api.imageBytes(s.id).catchError((_) => null);
|
||||||
|
_imgCache[s.id] = b;
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -41,6 +53,7 @@ class _ServersScreenState extends State<ServersScreen> {
|
|||||||
if (mounted) setState(() {
|
if (mounted) setState(() {
|
||||||
_servers = servers;
|
_servers = servers;
|
||||||
_error = null;
|
_error = null;
|
||||||
|
_imgCache.clear(); // recharge les images (elles ont pu changer)
|
||||||
});
|
});
|
||||||
} on UnauthorizedException {
|
} on UnauthorizedException {
|
||||||
await widget.auth.logout();
|
await widget.auth.logout();
|
||||||
@@ -147,10 +160,21 @@ class _ServersScreenState extends State<ServersScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: _buildBody(),
|
body: _buildBody(),
|
||||||
|
floatingActionButton: FloatingActionButton.extended(
|
||||||
|
onPressed: _openAdd,
|
||||||
|
icon: const Icon(Icons.add),
|
||||||
|
label: const Text('Ajouter'),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _openAdd() async {
|
||||||
|
final added = await Navigator.push<bool>(context,
|
||||||
|
MaterialPageRoute(builder: (_) => AddServerScreen(api: widget.api)));
|
||||||
|
if (added == true) _refresh();
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildBody() {
|
Widget _buildBody() {
|
||||||
if (_error != null && _servers == null) {
|
if (_error != null && _servers == null) {
|
||||||
return ListView(children: [
|
return ListView(children: [
|
||||||
@@ -191,11 +215,12 @@ class _ServersScreenState extends State<ServersScreen> {
|
|||||||
|
|
||||||
Widget _card(GameServer s) => Padding(
|
Widget _card(GameServer s) => Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 14),
|
padding: const EdgeInsets.only(bottom: 14),
|
||||||
child: FutureBuilder<String>(
|
child: FutureBuilder<Uint8List?>(
|
||||||
future: widget.api.iconUrl(s.id),
|
future: _image(s),
|
||||||
builder: (_, snap) => ServerCard(
|
builder: (_, snap) => ServerCard(
|
||||||
server: s,
|
server: s,
|
||||||
iconUrl: snap.data ?? '',
|
iconUrl: '',
|
||||||
|
imageBytes: snap.data,
|
||||||
busy: _busy.contains(s.id),
|
busy: _busy.contains(s.id),
|
||||||
onToggle: () => _toggle(s),
|
onToggle: () => _toggle(s),
|
||||||
onTap: () => _openDetail(s),
|
onTap: () => _openDetail(s),
|
||||||
|
|||||||
@@ -45,6 +45,56 @@ class ApiService {
|
|||||||
return GameServer.fromJson(jsonDecode(res.body) as Map<String, dynamic>);
|
return GameServer.fromJson(jsonDecode(res.body) as Map<String, dynamic>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Bloc « Se connecter » (adresse, version, vocal, carte, lien modpack).
|
||||||
|
Future<ConnectInfo> connectInfo(String id) async {
|
||||||
|
final base = await baseUrl;
|
||||||
|
final res = await http.get(Uri.parse('$base/api/servers/$id/connect'), headers: await _headers());
|
||||||
|
if (res.statusCode == 401) throw UnauthorizedException();
|
||||||
|
if (res.statusCode != 200) throw ApiException('Erreur ${res.statusCode}');
|
||||||
|
return ConnectInfo.fromJson(jsonDecode(res.body) as Map<String, dynamic>, base);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<DockerContainer>> containers() async {
|
||||||
|
final base = await baseUrl;
|
||||||
|
final res = await http.get(Uri.parse('$base/api/containers'), headers: await _headers());
|
||||||
|
if (res.statusCode == 401) throw UnauthorizedException();
|
||||||
|
if (res.statusCode != 200) throw ApiException('Erreur ${res.statusCode}');
|
||||||
|
return (jsonDecode(res.body) as List)
|
||||||
|
.map((e) => DockerContainer.fromJson(e as Map<String, dynamic>))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<GameServer> createServer(Map<String, dynamic> payload) async {
|
||||||
|
final base = await baseUrl;
|
||||||
|
final res = await http.post(
|
||||||
|
Uri.parse('$base/api/servers'),
|
||||||
|
headers: {...await _headers(), 'Content-Type': 'application/json'},
|
||||||
|
body: jsonEncode(payload),
|
||||||
|
);
|
||||||
|
if (res.statusCode == 401) throw UnauthorizedException();
|
||||||
|
if (res.statusCode >= 400) {
|
||||||
|
throw ApiException(_msg(res.body) ?? 'Création refusée (${res.statusCode})');
|
||||||
|
}
|
||||||
|
return GameServer.fromJson(jsonDecode(res.body) as Map<String, dynamic>);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteServer(String id) async {
|
||||||
|
final base = await baseUrl;
|
||||||
|
final res = await http.delete(Uri.parse('$base/api/servers/$id'), headers: await _headers());
|
||||||
|
if (res.statusCode == 401) throw UnauthorizedException();
|
||||||
|
if (res.statusCode >= 400) {
|
||||||
|
throw ApiException(_msg(res.body) ?? 'Suppression refusée (${res.statusCode})');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String? _msg(String body) {
|
||||||
|
try {
|
||||||
|
return (jsonDecode(body) as Map<String, dynamic>)['detail'] as String?;
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> start(String id) => _action(id, 'start');
|
Future<void> start(String id) => _action(id, 'start');
|
||||||
Future<void> stop(String id) => _action(id, 'stop');
|
Future<void> stop(String id) => _action(id, 'stop');
|
||||||
|
|
||||||
@@ -95,6 +145,63 @@ class ApiService {
|
|||||||
if (res.statusCode == 401) throw UnauthorizedException();
|
if (res.statusCode == 401) throw UnauthorizedException();
|
||||||
if (res.statusCode >= 400) throw ApiException('Suppression refusée (${res.statusCode})');
|
if (res.statusCode >= 400) throw ApiException('Suppression refusée (${res.statusCode})');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Rôle & mods (Modrinth) ──────────────────────────────────
|
||||||
|
Future<String> role() async {
|
||||||
|
final base = await baseUrl;
|
||||||
|
final res = await http.get(Uri.parse('$base/api/me'), headers: await _headers());
|
||||||
|
if (res.statusCode == 401) throw UnauthorizedException();
|
||||||
|
if (res.statusCode >= 400) throw ApiException('Profil indisponible (${res.statusCode})');
|
||||||
|
return (jsonDecode(res.body)['role'] as String?) ?? 'member';
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<String>> mods(String id) async {
|
||||||
|
final base = await baseUrl;
|
||||||
|
final res = await http.get(Uri.parse('$base/api/servers/$id/mods'), headers: await _headers());
|
||||||
|
if (res.statusCode == 401) throw UnauthorizedException();
|
||||||
|
if (res.statusCode >= 400) throw ApiException('Mods indisponibles (${res.statusCode})');
|
||||||
|
return ((jsonDecode(res.body)['projects'] as List?) ?? const []).cast<String>();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<ModHit>> searchMods(String q, String serverId) async {
|
||||||
|
final base = await baseUrl;
|
||||||
|
final uri = Uri.parse('$base/api/modrinth/search')
|
||||||
|
.replace(queryParameters: {'q': q, 'server_id': serverId});
|
||||||
|
final res = await http.get(uri, headers: await _headers());
|
||||||
|
if (res.statusCode == 401) throw UnauthorizedException();
|
||||||
|
if (res.statusCode >= 400) throw ApiException('Recherche échouée (${res.statusCode})');
|
||||||
|
return ((jsonDecode(res.body)['hits'] as List?) ?? const [])
|
||||||
|
.map((h) => ModHit.fromJson(h as Map<String, dynamic>))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> addMod(String id, String slug) async {
|
||||||
|
final base = await baseUrl;
|
||||||
|
final res = await http.post(
|
||||||
|
Uri.parse('$base/api/servers/$id/mods'),
|
||||||
|
headers: {...await _headers(), 'Content-Type': 'application/json'},
|
||||||
|
body: jsonEncode({'slug': slug}),
|
||||||
|
);
|
||||||
|
if (res.statusCode == 401) throw UnauthorizedException();
|
||||||
|
if (res.statusCode == 403) throw ApiException('Réservé aux administrateurs');
|
||||||
|
if (res.statusCode >= 400) throw ApiException(_detail(res) ?? 'Ajout refusé (${res.statusCode})');
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> removeMod(String id, String slug) async {
|
||||||
|
final base = await baseUrl;
|
||||||
|
final res = await http.delete(Uri.parse('$base/api/servers/$id/mods/$slug'), headers: await _headers());
|
||||||
|
if (res.statusCode == 401) throw UnauthorizedException();
|
||||||
|
if (res.statusCode == 403) throw ApiException('Réservé aux administrateurs');
|
||||||
|
if (res.statusCode >= 400) throw ApiException(_detail(res) ?? 'Retrait refusé (${res.statusCode})');
|
||||||
|
}
|
||||||
|
|
||||||
|
String? _detail(http.Response res) {
|
||||||
|
try {
|
||||||
|
return jsonDecode(res.body)['detail']?.toString();
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UnauthorizedException implements Exception {}
|
class UnauthorizedException implements Exception {}
|
||||||
|
|||||||
+97
-11
@@ -1,42 +1,128 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
/// Thèmes Material 3 (clair + sombre) avec un accent unifié.
|
/// Thème « flamme / chaud sombre » — anthracite + accents orange→rouge.
|
||||||
|
/// Remplace la palette Material par défaut (violet/teal).
|
||||||
class AppTheme {
|
class AppTheme {
|
||||||
static const _seed = Color(0xFF5E5CE6);
|
// Palette
|
||||||
|
static const bg = Color(0xFF14110F); // fond anthracite
|
||||||
|
static const surface1 = Color(0xFF1F1B18); // cartes / champs
|
||||||
|
static const surface2 = Color(0xFF262119); // éléments surélevés
|
||||||
|
static const flame = Color(0xFFFF7A18); // orange accent
|
||||||
|
static const ember = Color(0xFFFF3D00); // rouge braise
|
||||||
|
static const ink = Color(0xFFF5EFE9); // texte principal
|
||||||
|
static const inkMuted = Color(0xFFA89F97); // texte secondaire
|
||||||
|
|
||||||
static ThemeData light() => _base(Brightness.light);
|
static ThemeData light() => dark(); // app pensée sombre → même thème
|
||||||
static ThemeData dark() => _base(Brightness.dark);
|
static ThemeData dark() {
|
||||||
|
const scheme = ColorScheme(
|
||||||
|
brightness: Brightness.dark,
|
||||||
|
primary: flame,
|
||||||
|
onPrimary: Color(0xFF230F00),
|
||||||
|
primaryContainer: Color(0xFF3A2410),
|
||||||
|
onPrimaryContainer: Color(0xFFFFD9B8),
|
||||||
|
secondary: ember,
|
||||||
|
onSecondary: Colors.white,
|
||||||
|
secondaryContainer: Color(0xFF4A1A0A),
|
||||||
|
onSecondaryContainer: Color(0xFFFFD5C8),
|
||||||
|
tertiary: Color(0xFFFFB74D),
|
||||||
|
onTertiary: Color(0xFF241400),
|
||||||
|
error: Color(0xFFFF6B5E),
|
||||||
|
onError: Color(0xFF3A0A05),
|
||||||
|
surface: bg,
|
||||||
|
onSurface: ink,
|
||||||
|
surfaceContainerLowest: Color(0xFF0F0D0B),
|
||||||
|
surfaceContainerLow: surface1,
|
||||||
|
surfaceContainer: surface1,
|
||||||
|
surfaceContainerHigh: surface2,
|
||||||
|
surfaceContainerHighest: Color(0xFF2E2820),
|
||||||
|
onSurfaceVariant: inkMuted,
|
||||||
|
outline: Color(0xFF4A433D),
|
||||||
|
outlineVariant: Color(0xFF332E29),
|
||||||
|
inverseSurface: ink,
|
||||||
|
onInverseSurface: bg,
|
||||||
|
shadow: Colors.black,
|
||||||
|
scrim: Colors.black,
|
||||||
|
);
|
||||||
|
|
||||||
static ThemeData _base(Brightness brightness) {
|
|
||||||
final scheme = ColorScheme.fromSeed(seedColor: _seed, brightness: brightness);
|
|
||||||
return ThemeData(
|
return ThemeData(
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
colorScheme: scheme,
|
colorScheme: scheme,
|
||||||
scaffoldBackgroundColor: scheme.surface,
|
scaffoldBackgroundColor: bg,
|
||||||
appBarTheme: AppBarTheme(
|
canvasColor: bg,
|
||||||
backgroundColor: scheme.surface,
|
appBarTheme: const AppBarTheme(
|
||||||
foregroundColor: scheme.onSurface,
|
backgroundColor: bg,
|
||||||
|
foregroundColor: ink,
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
|
scrolledUnderElevation: 0,
|
||||||
titleTextStyle: TextStyle(
|
titleTextStyle: TextStyle(
|
||||||
color: scheme.onSurface,
|
color: ink,
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
fontWeight: FontWeight.w800,
|
fontWeight: FontWeight.w800,
|
||||||
letterSpacing: -0.5,
|
letterSpacing: -0.5,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
cardTheme: CardTheme(
|
cardTheme: CardTheme(
|
||||||
|
color: surface1,
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(22)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(22)),
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
),
|
),
|
||||||
|
tabBarTheme: const TabBarTheme(
|
||||||
|
labelColor: flame,
|
||||||
|
unselectedLabelColor: inkMuted,
|
||||||
|
indicatorColor: flame,
|
||||||
|
dividerColor: Colors.transparent,
|
||||||
|
labelStyle: TextStyle(fontWeight: FontWeight.w700),
|
||||||
|
),
|
||||||
filledButtonTheme: FilledButtonThemeData(
|
filledButtonTheme: FilledButtonThemeData(
|
||||||
style: FilledButton.styleFrom(
|
style: FilledButton.styleFrom(
|
||||||
|
backgroundColor: flame,
|
||||||
|
foregroundColor: const Color(0xFF230F00),
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 22, vertical: 14),
|
padding: const EdgeInsets.symmetric(horizontal: 22, vertical: 14),
|
||||||
textStyle: const TextStyle(fontWeight: FontWeight.w700, fontSize: 15),
|
textStyle: const TextStyle(fontWeight: FontWeight.w700, fontSize: 15),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
outlinedButtonTheme: OutlinedButtonThemeData(
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
foregroundColor: ink,
|
||||||
|
side: const BorderSide(color: Color(0xFF4A433D)),
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
floatingActionButtonTheme: const FloatingActionButtonThemeData(
|
||||||
|
backgroundColor: flame,
|
||||||
|
foregroundColor: Color(0xFF230F00),
|
||||||
|
),
|
||||||
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
|
filled: true,
|
||||||
|
fillColor: surface1,
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
borderSide: BorderSide.none,
|
||||||
|
),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
borderSide: const BorderSide(color: Color(0xFF332E29)),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
borderSide: const BorderSide(color: flame, width: 2),
|
||||||
|
),
|
||||||
|
labelStyle: const TextStyle(color: inkMuted),
|
||||||
|
),
|
||||||
|
progressIndicatorTheme: const ProgressIndicatorThemeData(
|
||||||
|
color: flame,
|
||||||
|
linearTrackColor: Color(0xFF332E29),
|
||||||
|
),
|
||||||
|
dividerTheme: const DividerThemeData(color: Color(0xFF332E29)),
|
||||||
|
snackBarTheme: const SnackBarThemeData(
|
||||||
|
backgroundColor: surface2,
|
||||||
|
contentTextStyle: TextStyle(color: ink),
|
||||||
|
),
|
||||||
|
dialogTheme: const DialogTheme(backgroundColor: surface1),
|
||||||
|
chipTheme: const ChipThemeData(backgroundColor: surface2),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,135 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
|
import '../models.dart';
|
||||||
|
|
||||||
|
/// Carte « Se connecter » : adresse, version/loader, chat vocal, et lien du
|
||||||
|
/// modpack (.mrpack) pour les joueurs PC.
|
||||||
|
class ConnectCard extends StatelessWidget {
|
||||||
|
const ConnectCard({super.key, required this.info, required this.loading});
|
||||||
|
|
||||||
|
final ConnectInfo? info;
|
||||||
|
final bool loading;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final i = info;
|
||||||
|
return Card(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.sports_esports_outlined, size: 20,
|
||||||
|
color: Theme.of(context).colorScheme.primary),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text('Se connecter', style: Theme.of(context).textTheme.titleMedium),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
if (loading && i == null)
|
||||||
|
const Center(child: Padding(padding: EdgeInsets.all(8), child: CircularProgressIndicator()))
|
||||||
|
else if (i == null)
|
||||||
|
const Text('Infos de connexion indisponibles.')
|
||||||
|
else ...[
|
||||||
|
if ((i.address ?? '').isNotEmpty)
|
||||||
|
_Row(
|
||||||
|
icon: Icons.dns_outlined,
|
||||||
|
label: 'Adresse',
|
||||||
|
value: i.address!,
|
||||||
|
onCopy: () => _copy(context, i.address!, 'Adresse copiée'),
|
||||||
|
),
|
||||||
|
if ((i.mcVersion ?? '').isNotEmpty)
|
||||||
|
_Row(
|
||||||
|
icon: Icons.layers_outlined,
|
||||||
|
label: 'Version',
|
||||||
|
value: '${i.mcVersion}${(i.loader ?? '').isNotEmpty ? ' · ${i.loader}' : ''}',
|
||||||
|
),
|
||||||
|
if (i.voiceChatPort != null)
|
||||||
|
_Row(
|
||||||
|
icon: Icons.mic_outlined,
|
||||||
|
label: 'Chat vocal',
|
||||||
|
value: 'Simple Voice Chat (UDP ${i.voiceChatPort})',
|
||||||
|
),
|
||||||
|
if (i.hasPack) ...[
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: FilledButton.tonalIcon(
|
||||||
|
onPressed: () => launchUrl(Uri.parse(i.mrpackUrl!),
|
||||||
|
mode: LaunchMode.externalApplication),
|
||||||
|
icon: const Icon(Icons.download, size: 18),
|
||||||
|
label: const Text('Modpack (.mrpack)'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
OutlinedButton.icon(
|
||||||
|
onPressed: () => _copy(context, i.mrpackUrl!, 'Lien du modpack copié'),
|
||||||
|
icon: const Icon(Icons.copy, size: 18),
|
||||||
|
label: const Text('Copier'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (i.instructions != null && i.instructions!.isNotEmpty) ...[
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
for (final step in i.instructions!)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 4),
|
||||||
|
child: Text('• $step', style: Theme.of(context).textTheme.bodySmall),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _copy(BuildContext context, String text, String msg) {
|
||||||
|
Clipboard.setData(ClipboardData(text: text));
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(msg)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Row extends StatelessWidget {
|
||||||
|
const _Row({required this.icon, required this.label, required this.value, this.onCopy});
|
||||||
|
|
||||||
|
final IconData icon;
|
||||||
|
final String label;
|
||||||
|
final String value;
|
||||||
|
final VoidCallback? onCopy;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 12),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Icon(icon, size: 20, color: Theme.of(context).colorScheme.primary),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(label, style: Theme.of(context).textTheme.labelMedium),
|
||||||
|
Text(value, style: Theme.of(context).textTheme.bodyLarge),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (onCopy != null)
|
||||||
|
IconButton(
|
||||||
|
tooltip: 'Copier',
|
||||||
|
icon: const Icon(Icons.copy, size: 18),
|
||||||
|
onPressed: onCopy,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
@@ -11,6 +13,7 @@ class ServerCard extends StatelessWidget {
|
|||||||
required this.busy,
|
required this.busy,
|
||||||
required this.onToggle,
|
required this.onToggle,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
|
this.imageBytes,
|
||||||
});
|
});
|
||||||
|
|
||||||
final GameServer server;
|
final GameServer server;
|
||||||
@@ -18,31 +21,49 @@ class ServerCard extends StatelessWidget {
|
|||||||
final bool busy;
|
final bool busy;
|
||||||
final VoidCallback onToggle;
|
final VoidCallback onToggle;
|
||||||
final VoidCallback? onTap;
|
final VoidCallback? onTap;
|
||||||
|
final Uint8List? imageBytes;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final t = server.theme;
|
final t = server.theme;
|
||||||
final badge = server.statusBadge;
|
final badge = server.statusBadge;
|
||||||
|
final hasImg = imageBytes != null;
|
||||||
return Card(
|
return Card(
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
child: Container(
|
child: Ink(
|
||||||
decoration: BoxDecoration(
|
decoration: hasImg
|
||||||
|
? BoxDecoration(
|
||||||
|
image: DecorationImage(image: MemoryImage(imageBytes!), fit: BoxFit.cover),
|
||||||
|
)
|
||||||
|
: BoxDecoration(
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
begin: Alignment.topLeft,
|
begin: Alignment.topLeft,
|
||||||
end: Alignment.bottomRight,
|
end: Alignment.bottomRight,
|
||||||
colors: [t.start, t.end],
|
colors: [t.start, t.end],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
child: Container(
|
||||||
|
decoration: hasImg
|
||||||
|
? const BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: [Color(0x66000000), Color(0xCC000000)],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
padding: const EdgeInsets.all(18),
|
padding: const EdgeInsets.all(18),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
|
if (!hasImg) ...[
|
||||||
_Icon(server: server, iconUrl: iconUrl, fallback: t.icon),
|
_Icon(server: server, iconUrl: iconUrl, fallback: t.icon),
|
||||||
const SizedBox(width: 14),
|
const SizedBox(width: 14),
|
||||||
|
],
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -107,6 +128,7 @@ class ServerCard extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,7 +146,7 @@ class _Icon extends StatelessWidget {
|
|||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 52,
|
width: 52,
|
||||||
height: 52,
|
height: 52,
|
||||||
child: (server.hasIcon)
|
child: (server.hasIcon && iconUrl.isNotEmpty)
|
||||||
? Image.network(iconUrl,
|
? Image.network(iconUrl,
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
errorBuilder: (_, __, ___) => _fallbackBox())
|
errorBuilder: (_, __, ___) => _fallbackBox())
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
import 'package:webview_flutter/webview_flutter.dart';
|
||||||
|
|
||||||
|
/// Carte BlueMap (vue web du monde) intégrée dans le détail d'un serveur.
|
||||||
|
/// Ne charge la WebView que si le serveur tourne : BlueMap n'est servi
|
||||||
|
/// que conteneur allumé.
|
||||||
|
class ServerMapCard extends StatefulWidget {
|
||||||
|
const ServerMapCard({super.key, required this.url, required this.serverUp});
|
||||||
|
|
||||||
|
final String url;
|
||||||
|
final bool serverUp;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ServerMapCard> createState() => _ServerMapCardState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ServerMapCardState extends State<ServerMapCard> {
|
||||||
|
WebViewController? _controller;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
if (widget.serverUp) _initController();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(ServerMapCard old) {
|
||||||
|
super.didUpdateWidget(old);
|
||||||
|
if (widget.serverUp && _controller == null) _initController();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _initController() {
|
||||||
|
_controller = WebViewController()
|
||||||
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||||
|
..setBackgroundColor(const Color(0xFF14151B))
|
||||||
|
..loadRequest(Uri.parse(widget.url));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Card(
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 16, 8, 8),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.map_outlined, size: 20, color: Theme.of(context).colorScheme.primary),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text('Carte', style: Theme.of(context).textTheme.titleMedium),
|
||||||
|
const Spacer(),
|
||||||
|
IconButton(
|
||||||
|
tooltip: 'Ouvrir en plein écran',
|
||||||
|
icon: const Icon(Icons.open_in_new, size: 20),
|
||||||
|
onPressed: () =>
|
||||||
|
launchUrl(Uri.parse(widget.url), mode: LaunchMode.externalApplication),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 300, child: _body()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _body() {
|
||||||
|
if (!widget.serverUp || _controller == null) {
|
||||||
|
return const _MapEmpty();
|
||||||
|
}
|
||||||
|
return WebViewWidget(controller: _controller!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MapEmpty extends StatelessWidget {
|
||||||
|
const _MapEmpty();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
color: const Color(0xFF14151B),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.map_outlined, size: 44, color: Colors.white24),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Text('Serveur éteint — démarre-le pour voir la carte',
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(color: Colors.white54)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ dependencies:
|
|||||||
shared_preferences: ^2.3.2
|
shared_preferences: ^2.3.2
|
||||||
package_info_plus: ^8.1.1
|
package_info_plus: ^8.1.1
|
||||||
url_launcher: ^6.3.1
|
url_launcher: ^6.3.1
|
||||||
|
webview_flutter: ^4.10.0
|
||||||
path_provider: ^2.1.4
|
path_provider: ^2.1.4
|
||||||
open_filex: ^4.5.0
|
open_filex: ^4.5.0
|
||||||
image_picker: ^1.1.2
|
image_picker: ^1.1.2
|
||||||
@@ -23,6 +24,17 @@ dependencies:
|
|||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_lints: ^5.0.0
|
flutter_lints: ^5.0.0
|
||||||
|
flutter_launcher_icons: ^0.14.1
|
||||||
|
|
||||||
|
# Icône de lanceur (générée en CI par flutter_launcher_icons après `flutter create`).
|
||||||
|
# Manette blanche sur fond indigo ; adaptatif Android 8+ + PNG legacy.
|
||||||
|
flutter_launcher_icons:
|
||||||
|
android: true
|
||||||
|
ios: false
|
||||||
|
image_path: "assets/brand/gm-legacy.png"
|
||||||
|
adaptive_icon_background: "#4F46E5"
|
||||||
|
adaptive_icon_foreground: "assets/brand/gm-foreground.png"
|
||||||
|
min_sdk_android: 21
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|||||||
Reference in New Issue
Block a user