Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb4ab95f13 | ||
|
|
2862fdd408 | ||
|
|
a971204b80 | ||
|
|
0257f0fa05 |
@@ -16,6 +16,7 @@ class GameServer {
|
|||||||
final int? maxPlayers;
|
final int? maxPlayers;
|
||||||
final String? motd;
|
final String? motd;
|
||||||
final bool hasIcon;
|
final bool hasIcon;
|
||||||
|
final bool hasImage;
|
||||||
|
|
||||||
const GameServer({
|
const GameServer({
|
||||||
required this.id,
|
required this.id,
|
||||||
@@ -32,6 +33,7 @@ class GameServer {
|
|||||||
this.maxPlayers,
|
this.maxPlayers,
|
||||||
this.motd,
|
this.motd,
|
||||||
this.hasIcon = false,
|
this.hasIcon = false,
|
||||||
|
this.hasImage = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory GameServer.fromJson(Map<String, dynamic> json) => GameServer(
|
factory GameServer.fromJson(Map<String, dynamic> json) => GameServer(
|
||||||
@@ -49,6 +51,7 @@ class GameServer {
|
|||||||
maxPlayers: json['max_players'] as int?,
|
maxPlayers: json['max_players'] as int?,
|
||||||
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,
|
||||||
);
|
);
|
||||||
|
|
||||||
bool get isUp => status == 'online' || status == 'running';
|
bool get isUp => status == 'online' || status == 'running';
|
||||||
|
|||||||
@@ -0,0 +1,311 @@
|
|||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
|
import '../models.dart';
|
||||||
|
import '../services/api_service.dart';
|
||||||
|
|
||||||
|
/// 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).
|
||||||
|
class ServerDetailScreen extends StatefulWidget {
|
||||||
|
const ServerDetailScreen({super.key, required this.server, required this.api});
|
||||||
|
final GameServer server;
|
||||||
|
final ApiService api;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ServerDetailScreen> createState() => _ServerDetailScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ServerDetailScreenState extends State<ServerDetailScreen> {
|
||||||
|
GameServer get s => _server;
|
||||||
|
late GameServer _server = widget.server;
|
||||||
|
|
||||||
|
Map<String, dynamic>? _stats;
|
||||||
|
Uint8List? _image;
|
||||||
|
bool _busy = false;
|
||||||
|
bool _imgBusy = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_load();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _load() async {
|
||||||
|
final results = await Future.wait([
|
||||||
|
widget.api.stats(s.id).catchError((_) => <String, dynamic>{'running': false}),
|
||||||
|
widget.api.imageBytes(s.id).catchError((_) => null),
|
||||||
|
widget.api.server(s.id).catchError((_) => _server),
|
||||||
|
]);
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() {
|
||||||
|
_stats = results[0] as Map<String, dynamic>;
|
||||||
|
_image = results[1] as Uint8List?;
|
||||||
|
_server = results[2] as GameServer;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _toggle() async {
|
||||||
|
setState(() => _busy = true);
|
||||||
|
try {
|
||||||
|
s.isUp ? await widget.api.stop(s.id) : await widget.api.start(s.id);
|
||||||
|
await Future.delayed(const Duration(seconds: 2));
|
||||||
|
await _load();
|
||||||
|
} catch (e) {
|
||||||
|
_snack('$e');
|
||||||
|
} finally {
|
||||||
|
if (mounted) setState(() => _busy = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _pickImage() async {
|
||||||
|
final x = await ImagePicker().pickImage(source: ImageSource.gallery, maxWidth: 1600);
|
||||||
|
if (x == null) return;
|
||||||
|
setState(() => _imgBusy = true);
|
||||||
|
try {
|
||||||
|
await widget.api.uploadImage(s.id, x.path);
|
||||||
|
final bytes = await widget.api.imageBytes(s.id);
|
||||||
|
if (mounted) setState(() => _image = bytes);
|
||||||
|
} catch (e) {
|
||||||
|
_snack('$e');
|
||||||
|
} finally {
|
||||||
|
if (mounted) setState(() => _imgBusy = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _deleteImage() async {
|
||||||
|
setState(() => _imgBusy = true);
|
||||||
|
try {
|
||||||
|
await widget.api.deleteImage(s.id);
|
||||||
|
if (mounted) setState(() => _image = null);
|
||||||
|
} catch (e) {
|
||||||
|
_snack('$e');
|
||||||
|
} finally {
|
||||||
|
if (mounted) setState(() => _imgBusy = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _snack(String m) {
|
||||||
|
if (mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(m)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final t = s.theme;
|
||||||
|
final badge = s.statusBadge;
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(title: Text(s.name)),
|
||||||
|
body: RefreshIndicator(
|
||||||
|
onRefresh: _load,
|
||||||
|
child: ListView(
|
||||||
|
children: [
|
||||||
|
_banner(t),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
_Pill(label: badge.label, color: badge.color),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
_Pill(label: s.isPreprod ? 'Preprod' : 'Production',
|
||||||
|
color: s.isPreprod ? const Color(0xFFFF9F0A) : const Color(0xFF34C759)),
|
||||||
|
const Spacer(),
|
||||||
|
if (s.web && s.openUrl != null)
|
||||||
|
OutlinedButton.icon(
|
||||||
|
onPressed: () =>
|
||||||
|
launchUrl(Uri.parse(s.openUrl!), mode: LaunchMode.externalApplication),
|
||||||
|
icon: const Icon(Icons.open_in_new, size: 18),
|
||||||
|
label: const Text('Ouvrir'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_toggleButton(),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
if (s.connect != null) _info(Icons.link, 'Connexion', s.connect!),
|
||||||
|
if (s.status == 'online')
|
||||||
|
_info(Icons.people, 'Joueurs', '${s.players ?? 0} / ${s.maxPlayers ?? 0}'),
|
||||||
|
if (s.motd != null) _info(Icons.chat_bubble_outline, 'MOTD', s.motd!),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_statsCard(),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_imageCard(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _banner(({Color start, Color end, IconData icon}) t) {
|
||||||
|
return SizedBox(
|
||||||
|
height: 190,
|
||||||
|
width: double.infinity,
|
||||||
|
child: _image != null
|
||||||
|
? Image.memory(_image!, fit: BoxFit.cover)
|
||||||
|
: DecoratedBox(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [t.start, t.end]),
|
||||||
|
),
|
||||||
|
child: Center(child: Icon(t.icon, size: 72, color: Colors.white70)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _toggleButton() {
|
||||||
|
return SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: FilledButton.icon(
|
||||||
|
onPressed: _busy ? null : _toggle,
|
||||||
|
style: FilledButton.styleFrom(
|
||||||
|
backgroundColor: s.isUp ? const Color(0xFFB3261E) : const Color(0xFF1B5E20),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||||
|
),
|
||||||
|
icon: _busy
|
||||||
|
? const SizedBox(width: 18, height: 18, child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white))
|
||||||
|
: Icon(s.isUp ? Icons.stop : Icons.play_arrow),
|
||||||
|
label: Text(s.isUp ? 'Éteindre le serveur' : 'Démarrer le serveur'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _info(IconData icon, String label, String value) {
|
||||||
|
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),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _statsCard() {
|
||||||
|
final st = _stats;
|
||||||
|
return Card(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text('Utilisation', style: Theme.of(context).textTheme.titleMedium),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
if (st == null)
|
||||||
|
const Center(child: Padding(padding: EdgeInsets.all(8), child: CircularProgressIndicator()))
|
||||||
|
else if (st['running'] != true)
|
||||||
|
const Text('Serveur éteint — pas de stats.')
|
||||||
|
else ...[
|
||||||
|
_gauge('CPU', (st['cpu_percent'] as num?)?.toDouble() ?? 0,
|
||||||
|
'${st['cpu_percent']} %'),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
_gauge('RAM', (st['mem_percent'] as num?)?.toDouble() ?? 0,
|
||||||
|
'${st['mem_used_mb']} Mo${st['mem_limit_mb'] != null ? ' / ${_fmtMb(st['mem_limit_mb'])}' : ''}'),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Text('Réseau : ↓ ${st['net_rx_mb']} Mo ↑ ${st['net_tx_mb']} Mo',
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String _fmtMb(dynamic mb) {
|
||||||
|
final v = (mb as num).toDouble();
|
||||||
|
return v >= 1024 ? '${(v / 1024).toStringAsFixed(1)} Go' : '${v.round()} Mo';
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _gauge(String label, double percent, String value) {
|
||||||
|
final p = (percent / 100).clamp(0.0, 1.0);
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(label, style: const TextStyle(fontWeight: FontWeight.w600)),
|
||||||
|
Text(value, style: Theme.of(context).textTheme.bodyMedium),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
child: LinearProgressIndicator(value: p, minHeight: 8),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _imageCard() {
|
||||||
|
return Card(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text('Image', style: Theme.of(context).textTheme.titleMedium),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
Text('Screenshot ou visuel du serveur (stocké sur RustFS).',
|
||||||
|
style: Theme.of(context).textTheme.bodySmall),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
FilledButton.tonalIcon(
|
||||||
|
onPressed: _imgBusy ? null : _pickImage,
|
||||||
|
icon: _imgBusy
|
||||||
|
? const SizedBox(width: 16, height: 16, child: CircularProgressIndicator(strokeWidth: 2))
|
||||||
|
: const Icon(Icons.upload),
|
||||||
|
label: Text(_image == null ? 'Importer' : 'Remplacer'),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
if (_image != null)
|
||||||
|
OutlinedButton.icon(
|
||||||
|
onPressed: _imgBusy ? null : _deleteImage,
|
||||||
|
icon: const Icon(Icons.delete_outline),
|
||||||
|
label: const Text('Supprimer'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Pill extends StatelessWidget {
|
||||||
|
const _Pill({required this.label, required this.color});
|
||||||
|
final String label;
|
||||||
|
final Color color;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: color.withOpacity(0.18),
|
||||||
|
borderRadius: BorderRadius.circular(999),
|
||||||
|
border: Border.all(color: color),
|
||||||
|
),
|
||||||
|
child: Text(label, style: TextStyle(color: color, fontSize: 12, fontWeight: FontWeight.w700)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 'server_detail_screen.dart';
|
||||||
import 'settings_screen.dart';
|
import 'settings_screen.dart';
|
||||||
|
|
||||||
class ServersScreen extends StatefulWidget {
|
class ServersScreen extends StatefulWidget {
|
||||||
@@ -26,6 +29,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() {
|
||||||
@@ -40,6 +52,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();
|
||||||
@@ -78,14 +91,42 @@ class _ServersScreenState extends State<ServersScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (go == true) {
|
if (go != true || !mounted) return;
|
||||||
final ok = await UpdateService(widget.api.baseUrl).apply(info);
|
|
||||||
|
final progress = ValueNotifier<double?>(0);
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (_) => AlertDialog(
|
||||||
|
title: const Text('Téléchargement…'),
|
||||||
|
content: ValueListenableBuilder<double?>(
|
||||||
|
valueListenable: progress,
|
||||||
|
builder: (_, p, __) => Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
LinearProgressIndicator(value: p),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Text(p == null ? '' : '${(p * 100).round()} %'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final ok = await UpdateService(widget.api.baseUrl)
|
||||||
|
.apply(info, onProgress: (p) => progress.value = p);
|
||||||
|
if (mounted) Navigator.of(context, rootNavigator: true).pop(); // ferme la progression
|
||||||
if (mounted && !ok) {
|
if (mounted && !ok) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(content: Text('Impossible d\'ouvrir le téléchargement.')),
|
const SnackBar(content: Text('Mise à jour impossible.')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _openDetail(GameServer s) async {
|
||||||
|
await Navigator.push(context,
|
||||||
|
MaterialPageRoute(builder: (_) => ServerDetailScreen(server: s, api: widget.api)));
|
||||||
|
_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _openSettings() async {
|
Future<void> _openSettings() async {
|
||||||
@@ -101,17 +142,23 @@ class _ServersScreenState extends State<ServersScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return DefaultTabController(
|
||||||
|
length: 2,
|
||||||
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('Serveurs'),
|
title: const Text('Serveurs'),
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(onPressed: _openSettings, icon: const Icon(Icons.settings_outlined)),
|
IconButton(onPressed: _openSettings, icon: const Icon(Icons.settings_outlined)),
|
||||||
IconButton(onPressed: _logout, icon: const Icon(Icons.logout)),
|
IconButton(onPressed: _logout, icon: const Icon(Icons.logout)),
|
||||||
],
|
],
|
||||||
|
bottom: const TabBar(
|
||||||
|
tabs: [
|
||||||
|
Tab(icon: Icon(Icons.public), text: 'Production'),
|
||||||
|
Tab(icon: Icon(Icons.science_outlined), text: 'Preprod'),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
body: RefreshIndicator(
|
),
|
||||||
onRefresh: _refresh,
|
body: _buildBody(),
|
||||||
child: _buildBody(),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -134,55 +181,38 @@ class _ServersScreenState extends State<ServersScreen> {
|
|||||||
final prod = _servers!.where((s) => !s.isPreprod).toList();
|
final prod = _servers!.where((s) => !s.isPreprod).toList();
|
||||||
final preprod = _servers!.where((s) => s.isPreprod).toList();
|
final preprod = _servers!.where((s) => s.isPreprod).toList();
|
||||||
|
|
||||||
final children = <Widget>[];
|
return TabBarView(
|
||||||
if (prod.isNotEmpty) {
|
children: [_envList(prod), _envList(preprod)],
|
||||||
children.add(const _SectionHeader(label: 'Production', icon: Icons.public));
|
);
|
||||||
children.addAll(prod.map(_card));
|
|
||||||
}
|
|
||||||
if (preprod.isNotEmpty) {
|
|
||||||
children.add(const _SectionHeader(label: 'Preprod', icon: Icons.science_outlined));
|
|
||||||
children.addAll(preprod.map(_card));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ListView(
|
Widget _envList(List<GameServer> list) {
|
||||||
padding: const EdgeInsets.fromLTRB(16, 4, 16, 24),
|
return RefreshIndicator(
|
||||||
children: children,
|
onRefresh: _refresh,
|
||||||
|
child: list.isEmpty
|
||||||
|
? ListView(children: const [
|
||||||
|
SizedBox(height: 120),
|
||||||
|
Center(child: Text('Aucun serveur dans cet environnement.')),
|
||||||
|
])
|
||||||
|
: ListView(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 24),
|
||||||
|
children: list.map(_card).toList(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
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),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SectionHeader extends StatelessWidget {
|
|
||||||
const _SectionHeader({required this.label, required this.icon});
|
|
||||||
final String label;
|
|
||||||
final IconData icon;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final c = Theme.of(context).colorScheme.onSurfaceVariant;
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.fromLTRB(4, 14, 4, 10),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Icon(icon, size: 18, color: c),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Text(label.toUpperCase(),
|
|
||||||
style: TextStyle(
|
|
||||||
color: c, fontSize: 13, fontWeight: FontWeight.w800, letterSpacing: 1.1)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
@@ -36,6 +37,14 @@ class ApiService {
|
|||||||
return list.map((e) => GameServer.fromJson(e as Map<String, dynamic>)).toList();
|
return list.map((e) => GameServer.fromJson(e as Map<String, dynamic>)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<GameServer> server(String id) async {
|
||||||
|
final base = await baseUrl;
|
||||||
|
final res = await http.get(Uri.parse('$base/api/servers/$id'), headers: await _headers());
|
||||||
|
if (res.statusCode == 401) throw UnauthorizedException();
|
||||||
|
if (res.statusCode != 200) throw ApiException('Erreur ${res.statusCode}');
|
||||||
|
return GameServer.fromJson(jsonDecode(res.body) as Map<String, dynamic>);
|
||||||
|
}
|
||||||
|
|
||||||
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');
|
||||||
|
|
||||||
@@ -50,6 +59,42 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<String> iconUrl(String id) async => '${await baseUrl}/api/servers/$id/icon';
|
Future<String> iconUrl(String id) async => '${await baseUrl}/api/servers/$id/icon';
|
||||||
|
|
||||||
|
/// Stats d'utilisation du conteneur (CPU/RAM/réseau). `{running:false}` si éteint.
|
||||||
|
Future<Map<String, dynamic>> stats(String id) async {
|
||||||
|
final base = await baseUrl;
|
||||||
|
final res = await http.get(Uri.parse('$base/api/servers/$id/stats'), headers: await _headers());
|
||||||
|
if (res.statusCode == 401) throw UnauthorizedException();
|
||||||
|
if (res.statusCode != 200) throw ApiException('Erreur ${res.statusCode}');
|
||||||
|
return jsonDecode(res.body) as Map<String, dynamic>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Image importée du serveur (bytes), null si aucune.
|
||||||
|
Future<Uint8List?> imageBytes(String id) async {
|
||||||
|
final base = await baseUrl;
|
||||||
|
final res = await http.get(Uri.parse('$base/api/servers/$id/image'), headers: await _headers());
|
||||||
|
if (res.statusCode == 401) throw UnauthorizedException();
|
||||||
|
if (res.statusCode != 200) return null;
|
||||||
|
return res.bodyBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> uploadImage(String id, String filePath) async {
|
||||||
|
final base = await baseUrl;
|
||||||
|
final token = await _auth.validToken();
|
||||||
|
final req = http.MultipartRequest('POST', Uri.parse('$base/api/servers/$id/image'))
|
||||||
|
..headers['Authorization'] = 'Bearer ${token ?? ''}'
|
||||||
|
..files.add(await http.MultipartFile.fromPath('file', filePath));
|
||||||
|
final res = await http.Response.fromStream(await req.send());
|
||||||
|
if (res.statusCode == 401) throw UnauthorizedException();
|
||||||
|
if (res.statusCode >= 400) throw ApiException('Envoi refusé (${res.statusCode})');
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteImage(String id) async {
|
||||||
|
final base = await baseUrl;
|
||||||
|
final res = await http.delete(Uri.parse('$base/api/servers/$id/image'), headers: await _headers());
|
||||||
|
if (res.statusCode == 401) throw UnauthorizedException();
|
||||||
|
if (res.statusCode >= 400) throw ApiException('Suppression refusée (${res.statusCode})');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UnauthorizedException implements Exception {}
|
class UnauthorizedException implements Exception {}
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:open_filex/open_filex.dart';
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
/// Vérifie s'il existe une version plus récente (API `/version`) et, si oui,
|
/// Détecte une version plus récente (`/version`) et l'installe **in-app** :
|
||||||
/// ouvre l'URL de l'APK (le navigateur télécharge, l'utilisateur installe —
|
/// télécharge l'APK dans le stockage de l'app puis lance l'installeur système
|
||||||
/// robuste, sans dépendance de packaging fragile).
|
/// (un seul tap « Installer »). Fallback navigateur si l'install directe échoue.
|
||||||
class UpdateService {
|
class UpdateService {
|
||||||
UpdateService(this._baseUrl);
|
UpdateService(this._baseUrl);
|
||||||
final Future<String> _baseUrl;
|
final Future<String> _baseUrl;
|
||||||
@@ -31,7 +34,39 @@ class UpdateService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> apply(UpdateInfo info) async {
|
/// Télécharge l'APK puis lance l'installeur. `onProgress` : 0.0 → 1.0
|
||||||
|
/// (ou null si la taille est inconnue). Renvoie true si l'installeur s'ouvre.
|
||||||
|
Future<bool> apply(UpdateInfo info, {void Function(double?)? onProgress}) async {
|
||||||
|
try {
|
||||||
|
final dir = await getExternalStorageDirectory() ?? await getTemporaryDirectory();
|
||||||
|
final file = File('${dir.path}/gamemanager-update.apk');
|
||||||
|
|
||||||
|
final req = http.Request('GET', Uri.parse(info.apkUrl));
|
||||||
|
final resp = await req.send().timeout(const Duration(seconds: 30));
|
||||||
|
if (resp.statusCode != 200) return _fallback(info);
|
||||||
|
|
||||||
|
final total = resp.contentLength ?? 0;
|
||||||
|
var received = 0;
|
||||||
|
final sink = file.openWrite();
|
||||||
|
await for (final chunk in resp.stream) {
|
||||||
|
sink.add(chunk);
|
||||||
|
received += chunk.length;
|
||||||
|
onProgress?.call(total > 0 ? received / total : null);
|
||||||
|
}
|
||||||
|
await sink.close();
|
||||||
|
|
||||||
|
final result = await OpenFilex.open(
|
||||||
|
file.path,
|
||||||
|
type: 'application/vnd.android.package-archive',
|
||||||
|
);
|
||||||
|
if (result.type == ResultType.done) return true;
|
||||||
|
return _fallback(info); // l'installeur n'a pas pris → navigateur
|
||||||
|
} catch (_) {
|
||||||
|
return _fallback(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> _fallback(UpdateInfo info) async {
|
||||||
final uri = Uri.parse(info.apkUrl);
|
final uri = Uri.parse(info.apkUrl);
|
||||||
if (!await canLaunchUrl(uri)) return false;
|
if (!await canLaunchUrl(uri)) return false;
|
||||||
return launchUrl(uri, mode: LaunchMode.externalApplication);
|
return launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||||
|
|||||||
@@ -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';
|
||||||
|
|
||||||
@@ -10,34 +12,58 @@ class ServerCard extends StatelessWidget {
|
|||||||
required this.iconUrl,
|
required this.iconUrl,
|
||||||
required this.busy,
|
required this.busy,
|
||||||
required this.onToggle,
|
required this.onToggle,
|
||||||
|
this.onTap,
|
||||||
|
this.imageBytes,
|
||||||
});
|
});
|
||||||
|
|
||||||
final GameServer server;
|
final GameServer server;
|
||||||
final String iconUrl;
|
final String iconUrl;
|
||||||
final bool busy;
|
final bool busy;
|
||||||
final VoidCallback onToggle;
|
final VoidCallback onToggle;
|
||||||
|
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(
|
||||||
child: Container(
|
clipBehavior: Clip.antiAlias,
|
||||||
decoration: BoxDecoration(
|
child: InkWell(
|
||||||
|
onTap: onTap,
|
||||||
|
child: Ink(
|
||||||
|
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,
|
||||||
@@ -101,6 +127,8 @@ class ServerCard extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,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())
|
||||||
|
|||||||
+129
-1
@@ -33,6 +33,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.18.0"
|
version: "1.18.0"
|
||||||
|
cross_file:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: cross_file
|
||||||
|
sha256: "7caf6a750a0c04effbb52a676dce9a4a592e10ad35c34d6d2d0e4811160d5670"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.3.4+2"
|
||||||
crypto:
|
crypto:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -73,6 +81,38 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "7.0.1"
|
version: "7.0.1"
|
||||||
|
file_selector_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: file_selector_linux
|
||||||
|
sha256: "54cbbd957e1156d29548c7d9b9ec0c0ebb6de0a90452198683a7d23aed617a33"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.9.3+2"
|
||||||
|
file_selector_macos:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: file_selector_macos
|
||||||
|
sha256: "271ab9986df0c135d45c3cdb6bd0faa5db6f4976d3e4b437cf7d0f258d941bfc"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.9.4+2"
|
||||||
|
file_selector_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: file_selector_platform_interface
|
||||||
|
sha256: a3994c26f10378a039faa11de174d7b78eb8f79e4dd0af2a451410c1a5c3f66b
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.6.2"
|
||||||
|
file_selector_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: file_selector_windows
|
||||||
|
sha256: "320fcfb6f33caa90f0b58380489fc5ac05d99ee94b61aa96ec2bff0ba81d3c2b"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.9.3+4"
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -86,6 +126,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.0.0"
|
version: "5.0.0"
|
||||||
|
flutter_plugin_android_lifecycle:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_plugin_android_lifecycle
|
||||||
|
sha256: "1c2b787f99bdca1f3718543f81d38aa1b124817dfeb9fb196201bea85b6134bf"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.26"
|
||||||
flutter_secure_storage:
|
flutter_secure_storage:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -171,6 +219,70 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.2"
|
version: "4.0.2"
|
||||||
|
image_picker:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: image_picker
|
||||||
|
sha256: "021834d9c0c3de46bf0fe40341fa07168407f694d9b2bb18d532dc1261867f7a"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.2"
|
||||||
|
image_picker_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: image_picker_android
|
||||||
|
sha256: "82652a75e3dd667a91187769a6a2cc81bd8c111bbead698d8e938d2b63e5e89a"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.8.12+21"
|
||||||
|
image_picker_for_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: image_picker_for_web
|
||||||
|
sha256: "717eb042ab08c40767684327be06a5d8dbb341fe791d514e4b92c7bbe1b7bb83"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.6"
|
||||||
|
image_picker_ios:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: image_picker_ios
|
||||||
|
sha256: "05da758e67bc7839e886b3959848aa6b44ff123ab4b28f67891008afe8ef9100"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.8.12+2"
|
||||||
|
image_picker_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: image_picker_linux
|
||||||
|
sha256: "34a65f6740df08bbbeb0a1abd8e6d32107941fd4868f67a507b25601651022c9"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.1+2"
|
||||||
|
image_picker_macos:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: image_picker_macos
|
||||||
|
sha256: "1b90ebbd9dcf98fb6c1d01427e49a55bd96b5d67b8c67cf955d60a5de74207c1"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.1+2"
|
||||||
|
image_picker_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: image_picker_platform_interface
|
||||||
|
sha256: "886d57f0be73c4b140004e78b9f28a8914a09e50c2d816bdd0520051a71236a0"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.10.1"
|
||||||
|
image_picker_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: image_picker_windows
|
||||||
|
sha256: "6ad07afc4eb1bc25f3a01084d28520496c4a3bb0cb13685435838167c9dcedeb"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.1+1"
|
||||||
js:
|
js:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -203,6 +315,22 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.15.0"
|
version: "1.15.0"
|
||||||
|
mime:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: mime
|
||||||
|
sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.0"
|
||||||
|
open_filex:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: open_filex
|
||||||
|
sha256: "9976da61b6a72302cf3b1efbce259200cd40232643a467aac7370addf94d6900"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.7.0"
|
||||||
package_info_plus:
|
package_info_plus:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -228,7 +356,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.1"
|
version: "1.9.1"
|
||||||
path_provider:
|
path_provider:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: path_provider
|
name: path_provider
|
||||||
sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd"
|
sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd"
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ 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
|
||||||
|
path_provider: ^2.1.4
|
||||||
|
open_filex: ^4.5.0
|
||||||
|
image_picker: ^1.1.2
|
||||||
cupertino_icons: ^1.0.8
|
cupertino_icons: ^1.0.8
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|||||||
+13
-5
@@ -62,14 +62,22 @@ if "signingConfigs {" not in s:
|
|||||||
r"(\n\s*buildTypes\s*\{)",
|
r"(\n\s*buildTypes\s*\{)",
|
||||||
'\n signingConfigs {\n'
|
'\n signingConfigs {\n'
|
||||||
' release {\n'
|
' release {\n'
|
||||||
' keyAlias keystoreProperties["keyAlias"]\n'
|
' keyAlias = keystoreProperties["keyAlias"]\n'
|
||||||
' keyPassword keystoreProperties["keyPassword"]\n'
|
' keyPassword = keystoreProperties["keyPassword"]\n'
|
||||||
' storeFile file(keystoreProperties["storeFile"])\n'
|
' storeFile = file(keystoreProperties["storeFile"])\n'
|
||||||
' storePassword keystoreProperties["storePassword"]\n'
|
' storePassword = keystoreProperties["storePassword"]\n'
|
||||||
' }\n }\n\\1',
|
' }\n }\n\\1',
|
||||||
s,
|
s,
|
||||||
count=1,
|
count=1,
|
||||||
)
|
)
|
||||||
|
# Flutter 3.24 génère `signingConfig = signingConfigs.debug` (AVEC `=`). On gère
|
||||||
|
# les deux formes pour ne jamais laisser le build release signé en clé debug
|
||||||
|
# (sinon signature différente à chaque run CI → « conflit » à l'install de MAJ).
|
||||||
|
before = s
|
||||||
|
s = s.replace("signingConfig = signingConfigs.debug", "signingConfig = signingConfigs.release")
|
||||||
s = s.replace("signingConfig signingConfigs.debug", "signingConfig signingConfigs.release")
|
s = s.replace("signingConfig signingConfigs.debug", "signingConfig signingConfigs.release")
|
||||||
|
if s == before:
|
||||||
|
raise SystemExit("patch_android: ERREUR — ligne 'signingConfig ... debug' introuvable, "
|
||||||
|
"signature release NON appliquée (build annulé)")
|
||||||
open(gr, "w").write(s)
|
open(gr, "w").write(s)
|
||||||
print("patch_android: OK")
|
print("patch_android: OK (signature release appliquee)")
|
||||||
|
|||||||
Reference in New Issue
Block a user