Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a971204b80 | ||
|
|
0257f0fa05 | ||
|
|
25890d7bbc | ||
|
|
6b7287cefd | ||
|
|
4a265e0fd2 | ||
|
|
1fe4528b0b |
@@ -5,6 +5,8 @@ class Config {
|
|||||||
// OIDC pocket-id (client public + PKCE)
|
// OIDC pocket-id (client public + PKCE)
|
||||||
static const String oidcIssuer = 'https://pocket.nfteam.ovh';
|
static const String oidcIssuer = 'https://pocket.nfteam.ovh';
|
||||||
static const String oidcClientId = '83678fb3-9268-42c1-8dcb-0fb141692a6d';
|
static const String oidcClientId = '83678fb3-9268-42c1-8dcb-0fb141692a6d';
|
||||||
|
// Schéma custom capté par flutter_web_auth_2 (CallbackActivity dédiée)
|
||||||
|
static const String oidcScheme = 'nfteam.gamemanager';
|
||||||
static const String oidcRedirect = 'nfteam.gamemanager://oidc';
|
static const String oidcRedirect = 'nfteam.gamemanager://oidc';
|
||||||
static const List<String> oidcScopes = ['openid', 'profile', 'email'];
|
static const List<String> oidcScopes = ['openid', 'profile', 'email'];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ class GameServer {
|
|||||||
final String? subtitle;
|
final String? subtitle;
|
||||||
final String? connect;
|
final String? connect;
|
||||||
final bool onDemand;
|
final bool onDemand;
|
||||||
|
final String env; // prod | preprod
|
||||||
|
final bool web; // jeu web → bouton « Ouvrir »
|
||||||
|
final String? openUrl;
|
||||||
final String status; // stopped | starting | running | online | partial
|
final String status; // stopped | starting | running | online | partial
|
||||||
final int? players;
|
final int? players;
|
||||||
final int? maxPlayers;
|
final int? maxPlayers;
|
||||||
@@ -21,6 +24,9 @@ class GameServer {
|
|||||||
this.subtitle,
|
this.subtitle,
|
||||||
this.connect,
|
this.connect,
|
||||||
this.onDemand = false,
|
this.onDemand = false,
|
||||||
|
this.env = 'prod',
|
||||||
|
this.web = false,
|
||||||
|
this.openUrl,
|
||||||
required this.status,
|
required this.status,
|
||||||
this.players,
|
this.players,
|
||||||
this.maxPlayers,
|
this.maxPlayers,
|
||||||
@@ -35,6 +41,9 @@ class GameServer {
|
|||||||
subtitle: json['subtitle'] as String?,
|
subtitle: json['subtitle'] as String?,
|
||||||
connect: json['connect'] as String?,
|
connect: json['connect'] as String?,
|
||||||
onDemand: json['on_demand'] as bool? ?? false,
|
onDemand: json['on_demand'] as bool? ?? false,
|
||||||
|
env: json['env'] as String? ?? 'prod',
|
||||||
|
web: json['web'] as bool? ?? false,
|
||||||
|
openUrl: json['open_url'] as String?,
|
||||||
status: json['status'] as String? ?? 'stopped',
|
status: json['status'] as String? ?? 'stopped',
|
||||||
players: json['players'] as int?,
|
players: json['players'] as int?,
|
||||||
maxPlayers: json['max_players'] as int?,
|
maxPlayers: json['max_players'] as int?,
|
||||||
@@ -44,6 +53,7 @@ class GameServer {
|
|||||||
|
|
||||||
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';
|
||||||
|
|
||||||
/// Couleur d'accent thématique par jeu (visuel sans dépendance externe).
|
/// Couleur d'accent thématique par jeu (visuel sans dépendance externe).
|
||||||
({Color start, Color end, IconData icon}) get theme {
|
({Color start, Color end, IconData icon}) get theme {
|
||||||
@@ -57,6 +67,9 @@ class GameServer {
|
|||||||
if (g.contains('cycle')) {
|
if (g.contains('cycle')) {
|
||||||
return (start: const Color(0xFF00BCD4), end: const Color(0xFF1A237E), icon: Icons.rocket_launch);
|
return (start: const Color(0xFF00BCD4), end: const Color(0xFF1A237E), icon: Icons.rocket_launch);
|
||||||
}
|
}
|
||||||
|
if (g.contains('swarm') || g.contains('ants')) {
|
||||||
|
return (start: const Color(0xFFF9A825), end: const Color(0xFF6D4C00), icon: Icons.bug_report);
|
||||||
|
}
|
||||||
return (start: const Color(0xFF7E57C2), end: const Color(0xFF311B92), icon: Icons.sports_esports);
|
return (start: const Color(0xFF7E57C2), end: const Color(0xFF311B92), icon: Icons.sports_esports);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,15 +78,37 @@ 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> _openSettings() async {
|
Future<void> _openSettings() async {
|
||||||
await Navigator.push(context,
|
await Navigator.push(context,
|
||||||
@@ -101,17 +123,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(),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -130,13 +158,33 @@ class _ServersScreenState extends State<ServersScreen> {
|
|||||||
if (_servers == null) {
|
if (_servers == null) {
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
}
|
}
|
||||||
return ListView.separated(
|
|
||||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 24),
|
final prod = _servers!.where((s) => !s.isPreprod).toList();
|
||||||
itemCount: _servers!.length,
|
final preprod = _servers!.where((s) => s.isPreprod).toList();
|
||||||
separatorBuilder: (_, __) => const SizedBox(height: 14),
|
|
||||||
itemBuilder: (_, i) {
|
return TabBarView(
|
||||||
final s = _servers![i];
|
children: [_envList(prod), _envList(preprod)],
|
||||||
return FutureBuilder<String>(
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _envList(List<GameServer> list) {
|
||||||
|
return RefreshIndicator(
|
||||||
|
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(
|
||||||
|
padding: const EdgeInsets.only(bottom: 14),
|
||||||
|
child: FutureBuilder<String>(
|
||||||
future: widget.api.iconUrl(s.id),
|
future: widget.api.iconUrl(s.id),
|
||||||
builder: (_, snap) => ServerCard(
|
builder: (_, snap) => ServerCard(
|
||||||
server: s,
|
server: s,
|
||||||
@@ -144,8 +192,6 @@ class _ServersScreenState extends State<ServersScreen> {
|
|||||||
busy: _busy.contains(s.id),
|
busy: _busy.contains(s.id),
|
||||||
onToggle: () => _toggle(s),
|
onToggle: () => _toggle(s),
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,67 +1,115 @@
|
|||||||
import 'package:flutter_appauth/flutter_appauth.dart';
|
import 'dart:convert';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:crypto/crypto.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
|
import 'package:flutter_web_auth_2/flutter_web_auth_2.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
import '../config.dart';
|
import '../config.dart';
|
||||||
|
|
||||||
/// Authentification OIDC pocket-id (Authorization Code + PKCE, client public).
|
/// Auth OIDC pocket-id : Authorization Code + PKCE via flutter_web_auth_2
|
||||||
/// Le jeton d'identité (JWT) est stocké de façon sécurisée et envoyé à l'API.
|
/// (schéma custom capté de façon fiable), échange de token en direct.
|
||||||
class AuthService {
|
class AuthService {
|
||||||
final _appAuth = const FlutterAppAuth();
|
|
||||||
final _storage = const FlutterSecureStorage();
|
final _storage = const FlutterSecureStorage();
|
||||||
|
|
||||||
static const _kIdToken = 'id_token';
|
static const _kIdToken = 'id_token';
|
||||||
static const _kRefresh = 'refresh_token';
|
static const _kRefresh = 'refresh_token';
|
||||||
static const _kExpiry = 'access_expiry';
|
static const _kExpiry = 'expiry';
|
||||||
|
|
||||||
|
Map<String, dynamic>? _discovery;
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> _disco() async {
|
||||||
|
_discovery ??= jsonDecode((await http.get(
|
||||||
|
Uri.parse('${Config.oidcIssuer}/.well-known/openid-configuration'),
|
||||||
|
))
|
||||||
|
.body) as Map<String, dynamic>;
|
||||||
|
return _discovery!;
|
||||||
|
}
|
||||||
|
|
||||||
Future<String?> get idToken => _storage.read(key: _kIdToken);
|
Future<String?> get idToken => _storage.read(key: _kIdToken);
|
||||||
|
|
||||||
Future<bool> isLoggedIn() async => (await idToken) != null;
|
Future<bool> isLoggedIn() async => (await idToken) != null;
|
||||||
|
|
||||||
|
String _rand(int n) {
|
||||||
|
final r = Random.secure();
|
||||||
|
return base64UrlEncode(List<int>.generate(n, (_) => r.nextInt(256)))
|
||||||
|
.replaceAll('=', '')
|
||||||
|
.substring(0, n);
|
||||||
|
}
|
||||||
|
|
||||||
Future<bool> login() async {
|
Future<bool> login() async {
|
||||||
final result = await _appAuth.authorizeAndExchangeCode(
|
final disco = await _disco();
|
||||||
AuthorizationTokenRequest(
|
final verifier = _rand(64);
|
||||||
Config.oidcClientId,
|
final challenge = base64UrlEncode(sha256.convert(ascii.encode(verifier)).bytes)
|
||||||
Config.oidcRedirect,
|
.replaceAll('=', '');
|
||||||
issuer: Config.oidcIssuer,
|
final state = _rand(24);
|
||||||
scopes: Config.oidcScopes,
|
final authUrl = Uri.parse(disco['authorization_endpoint'] as String).replace(queryParameters: {
|
||||||
promptValues: ['login'],
|
'response_type': 'code',
|
||||||
),
|
'client_id': Config.oidcClientId,
|
||||||
|
'redirect_uri': Config.oidcRedirect,
|
||||||
|
'scope': Config.oidcScopes.join(' '),
|
||||||
|
'state': state,
|
||||||
|
'code_challenge': challenge,
|
||||||
|
'code_challenge_method': 'S256',
|
||||||
|
// Pas de prompt=login : on réutilise la session pocket-id (cookie Chrome)
|
||||||
|
// → reconnexion silencieuse, pas de re-cérémonie passkey (qui plante
|
||||||
|
// en boucle dans un Custom Tab Android 10).
|
||||||
|
});
|
||||||
|
|
||||||
|
final result = await FlutterWebAuth2.authenticate(
|
||||||
|
url: authUrl.toString(),
|
||||||
|
callbackUrlScheme: Config.oidcScheme,
|
||||||
);
|
);
|
||||||
if (result.idToken == null) return false;
|
final params = Uri.parse(result).queryParameters;
|
||||||
await _storage.write(key: _kIdToken, value: result.idToken);
|
if (params['state'] != state || params['code'] == null) return false;
|
||||||
await _storage.write(key: _kRefresh, value: result.refreshToken);
|
|
||||||
await _storage.write(
|
final token = await http.post(
|
||||||
key: _kExpiry,
|
Uri.parse(disco['token_endpoint'] as String),
|
||||||
value: result.accessTokenExpirationDateTime?.toIso8601String(),
|
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
||||||
|
body: {
|
||||||
|
'grant_type': 'authorization_code',
|
||||||
|
'code': params['code']!,
|
||||||
|
'redirect_uri': Config.oidcRedirect,
|
||||||
|
'client_id': Config.oidcClientId,
|
||||||
|
'code_verifier': verifier,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
if (token.statusCode != 200) return false;
|
||||||
|
await _store(jsonDecode(token.body) as Map<String, dynamic>);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Rafraîchit le jeton si expiré (via refresh_token), renvoie l'id_token courant.
|
Future<void> _store(Map<String, dynamic> t) async {
|
||||||
Future<String?> validToken() async {
|
await _storage.write(key: _kIdToken, value: t['id_token'] as String?);
|
||||||
final expiry = await _storage.read(key: _kExpiry);
|
if (t['refresh_token'] != null) {
|
||||||
final refresh = await _storage.read(key: _kRefresh);
|
await _storage.write(key: _kRefresh, value: t['refresh_token'] as String);
|
||||||
if (expiry != null && refresh != null) {
|
}
|
||||||
final exp = DateTime.tryParse(expiry);
|
final expiresIn = (t['expires_in'] as num?)?.toInt() ?? 3600;
|
||||||
if (exp != null && exp.isBefore(DateTime.now().add(const Duration(seconds: 30)))) {
|
|
||||||
try {
|
|
||||||
final r = await _appAuth.token(TokenRequest(
|
|
||||||
Config.oidcClientId,
|
|
||||||
Config.oidcRedirect,
|
|
||||||
issuer: Config.oidcIssuer,
|
|
||||||
refreshToken: refresh,
|
|
||||||
scopes: Config.oidcScopes,
|
|
||||||
));
|
|
||||||
if (r.idToken != null) {
|
|
||||||
await _storage.write(key: _kIdToken, value: r.idToken);
|
|
||||||
await _storage.write(key: _kRefresh, value: r.refreshToken ?? refresh);
|
|
||||||
await _storage.write(
|
await _storage.write(
|
||||||
key: _kExpiry,
|
key: _kExpiry,
|
||||||
value: r.accessTokenExpirationDateTime?.toIso8601String(),
|
value: DateTime.now().add(Duration(seconds: expiresIn)).toIso8601String(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (_) {/* on garde l'ancien token, l'API renverra 401 si mort */}
|
|
||||||
}
|
/// Rafraîchit si expiré, renvoie l'id_token courant.
|
||||||
|
Future<String?> validToken() async {
|
||||||
|
final expiry = DateTime.tryParse(await _storage.read(key: _kExpiry) ?? '');
|
||||||
|
final refresh = await _storage.read(key: _kRefresh);
|
||||||
|
if (expiry != null && refresh != null &&
|
||||||
|
expiry.isBefore(DateTime.now().add(const Duration(seconds: 30)))) {
|
||||||
|
try {
|
||||||
|
final disco = await _disco();
|
||||||
|
final r = await http.post(
|
||||||
|
Uri.parse(disco['token_endpoint'] as String),
|
||||||
|
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
||||||
|
body: {
|
||||||
|
'grant_type': 'refresh_token',
|
||||||
|
'refresh_token': refresh,
|
||||||
|
'client_id': Config.oidcClientId,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (r.statusCode == 200) await _store(jsonDecode(r.body) as Map<String, dynamic>);
|
||||||
|
} catch (_) {/* garde l'ancien */}
|
||||||
}
|
}
|
||||||
return idToken;
|
return idToken;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
import '../models.dart';
|
import '../models.dart';
|
||||||
|
|
||||||
@@ -41,13 +42,23 @@ class ServerCard extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(server.name,
|
Row(
|
||||||
|
children: [
|
||||||
|
Flexible(
|
||||||
|
child: Text(server.name,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 19,
|
fontSize: 19,
|
||||||
fontWeight: FontWeight.w800),
|
fontWeight: FontWeight.w800),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis),
|
overflow: TextOverflow.ellipsis),
|
||||||
|
),
|
||||||
|
if (server.isPreprod) ...[
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
const _Tag(label: 'PREPROD'),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
if (server.subtitle != null)
|
if (server.subtitle != null)
|
||||||
Text(server.subtitle!,
|
Text(server.subtitle!,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
@@ -80,6 +91,10 @@ class ServerCard extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
else
|
else
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
|
if (server.web && server.openUrl != null) ...[
|
||||||
|
_OpenButton(url: server.openUrl!),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
],
|
||||||
_ToggleButton(up: server.isUp, busy: busy, onToggle: onToggle),
|
_ToggleButton(up: server.isUp, busy: busy, onToggle: onToggle),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -118,6 +133,44 @@ class _Icon extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _Tag extends StatelessWidget {
|
||||||
|
const _Tag({required this.label});
|
||||||
|
final String label;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 2),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.black.withOpacity(0.28),
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
border: Border.all(color: Colors.white.withOpacity(0.5), width: 1),
|
||||||
|
),
|
||||||
|
child: Text(label,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white, fontSize: 10, fontWeight: FontWeight.w800, letterSpacing: 0.6)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _OpenButton extends StatelessWidget {
|
||||||
|
const _OpenButton({required this.url});
|
||||||
|
final String url;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return OutlinedButton.icon(
|
||||||
|
onPressed: () => launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication),
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
side: BorderSide(color: Colors.white.withOpacity(0.7)),
|
||||||
|
),
|
||||||
|
icon: const Icon(Icons.open_in_new, size: 18),
|
||||||
|
label: const Text('Ouvrir'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class _StatusPill extends StatelessWidget {
|
class _StatusPill extends StatelessWidget {
|
||||||
const _StatusPill({required this.label, required this.color, required this.pulse});
|
const _StatusPill({required this.label, required this.color, required this.pulse});
|
||||||
final String label;
|
final String label;
|
||||||
|
|||||||
+40
-16
@@ -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"
|
||||||
|
crypto:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: crypto
|
||||||
|
sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.7"
|
||||||
cupertino_icons:
|
cupertino_icons:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -41,6 +49,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.8"
|
version: "1.0.8"
|
||||||
|
desktop_webview_window:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: desktop_webview_window
|
||||||
|
sha256: "57cf20d81689d5cbb1adfd0017e96b669398a669d927906073b0e42fc64111c0"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.3"
|
||||||
ffi:
|
ffi:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -62,22 +78,6 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
flutter_appauth:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: flutter_appauth
|
|
||||||
sha256: "0aa449d8991f70e7847d55b8bff0890fb41dc62c1d8526337e4073e806813bcb"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "8.0.3"
|
|
||||||
flutter_appauth_platform_interface:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: flutter_appauth_platform_interface
|
|
||||||
sha256: ccf5e1d8c40dd35b297290b33cc1896648b4b92a2ec3f62a436c62a8eef9a9db
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "8.0.0"
|
|
||||||
flutter_lints:
|
flutter_lints:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
@@ -134,6 +134,22 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.2"
|
version: "3.1.2"
|
||||||
|
flutter_web_auth_2:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_web_auth_2
|
||||||
|
sha256: "3c14babeaa066c371f3a743f204dd0d348b7d42ffa6fae7a9847a521aff33696"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.1.0"
|
||||||
|
flutter_web_auth_2_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_web_auth_2_platform_interface
|
||||||
|
sha256: c63a472c8070998e4e422f6b34a17070e60782ac442107c70000dd1bed645f4d
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.1.0"
|
||||||
flutter_web_plugins:
|
flutter_web_plugins:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -456,6 +472,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.10.1"
|
version: "5.10.1"
|
||||||
|
window_to_front:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: window_to_front
|
||||||
|
sha256: "14fad8984db4415e2eeb30b04bb77140b180e260d6cb66b26de126a8657a9241"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.0.4"
|
||||||
xdg_directories:
|
xdg_directories:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
+4
-1
@@ -10,11 +10,14 @@ dependencies:
|
|||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
http: ^1.2.2
|
http: ^1.2.2
|
||||||
flutter_appauth: ^8.0.0
|
flutter_web_auth_2: ^4.1.0
|
||||||
|
crypto: ^3.0.6
|
||||||
flutter_secure_storage: ^9.2.2
|
flutter_secure_storage: ^9.2.2
|
||||||
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
|
||||||
cupertino_icons: ^1.0.8
|
cupertino_icons: ^1.0.8
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|||||||
+31
-16
@@ -2,7 +2,7 @@
|
|||||||
"""Patche le scaffold Android généré par `flutter create` :
|
"""Patche le scaffold Android généré par `flutter create` :
|
||||||
- permissions (internet + auto-install APK)
|
- permissions (internet + auto-install APK)
|
||||||
- signature release depuis key.properties
|
- signature release depuis key.properties
|
||||||
- schéma de redirection OIDC (flutter_appauth)
|
- CallbackActivity flutter_web_auth_2 (retour OIDC, schéma nfteam.gamemanager)
|
||||||
Lancé dans la CI après `flutter create`. Idempotent."""
|
Lancé dans la CI après `flutter create`. Idempotent."""
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@@ -11,7 +11,7 @@ KSPW = os.environ["KSPW"]
|
|||||||
ALIAS = os.environ["ALIAS"]
|
ALIAS = os.environ["ALIAS"]
|
||||||
KEYSTORE_PATH = os.environ.get("KEYSTORE_PATH", os.path.abspath("gamemanager.keystore"))
|
KEYSTORE_PATH = os.environ.get("KEYSTORE_PATH", os.path.abspath("gamemanager.keystore"))
|
||||||
|
|
||||||
# 1) key.properties (chemin absolu du keystore, robuste peu importe le cwd gradle)
|
# 1) key.properties (chemin absolu du keystore)
|
||||||
with open("android/key.properties", "w") as f:
|
with open("android/key.properties", "w") as f:
|
||||||
f.write(
|
f.write(
|
||||||
f"storePassword={KSPW}\n"
|
f"storePassword={KSPW}\n"
|
||||||
@@ -20,7 +20,7 @@ with open("android/key.properties", "w") as f:
|
|||||||
f"storeFile={KEYSTORE_PATH}\n"
|
f"storeFile={KEYSTORE_PATH}\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
# 2) AndroidManifest : permissions
|
# 2) AndroidManifest : permissions + CallbackActivity OIDC
|
||||||
man = "android/app/src/main/AndroidManifest.xml"
|
man = "android/app/src/main/AndroidManifest.xml"
|
||||||
s = open(man).read()
|
s = open(man).read()
|
||||||
perms = (
|
perms = (
|
||||||
@@ -29,12 +29,25 @@ perms = (
|
|||||||
)
|
)
|
||||||
if "REQUEST_INSTALL_PACKAGES" not in s:
|
if "REQUEST_INSTALL_PACKAGES" not in s:
|
||||||
s = s.replace("<application", perms + " <application", 1)
|
s = s.replace("<application", perms + " <application", 1)
|
||||||
|
callback = (
|
||||||
|
' <activity android:name="com.linusu.flutter_web_auth_2.CallbackActivity" '
|
||||||
|
'android:exported="true">\n'
|
||||||
|
' <intent-filter android:label="flutter_web_auth_2">\n'
|
||||||
|
' <action android:name="android.intent.action.VIEW"/>\n'
|
||||||
|
' <category android:name="android.intent.category.DEFAULT"/>\n'
|
||||||
|
' <category android:name="android.intent.category.BROWSABLE"/>\n'
|
||||||
|
' <data android:scheme="nfteam.gamemanager"/>\n'
|
||||||
|
' </intent-filter>\n'
|
||||||
|
' </activity>\n'
|
||||||
|
)
|
||||||
|
if "flutter_web_auth_2.CallbackActivity" not in s:
|
||||||
|
s = s.replace("</application>", callback + " </application>", 1)
|
||||||
open(man, "w").write(s)
|
open(man, "w").write(s)
|
||||||
|
|
||||||
# 3) build.gradle : signature + schéma OIDC
|
# 3) build.gradle : signature release
|
||||||
gr = "android/app/build.gradle"
|
gr = "android/app/build.gradle"
|
||||||
s = open(gr).read()
|
s = open(gr).read()
|
||||||
# ⚠️ Rien n'est autorisé AVANT le bloc plugins {} → on insère juste avant `android {`
|
# ⚠️ Rien avant plugins {} → insérer juste avant `android {`
|
||||||
if "keystoreProperties" not in s:
|
if "keystoreProperties" not in s:
|
||||||
s = s.replace(
|
s = s.replace(
|
||||||
"android {",
|
"android {",
|
||||||
@@ -44,25 +57,27 @@ if "keystoreProperties" not in s:
|
|||||||
'android {',
|
'android {',
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
if "appAuthRedirectScheme" not in s:
|
|
||||||
s = s.replace(
|
|
||||||
"defaultConfig {",
|
|
||||||
'defaultConfig {\n manifestPlaceholders += [appAuthRedirectScheme: "nfteam.gamemanager"]',
|
|
||||||
1,
|
|
||||||
)
|
|
||||||
if "signingConfigs {" not in s:
|
if "signingConfigs {" not in s:
|
||||||
s = re.sub(
|
s = re.sub(
|
||||||
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