détail serveur : carte BlueMap intégrée (WebView) + bloc « Se connecter »
Build APK / build (push) Successful in 2m49s
Build APK / build (push) Successful in 2m49s
- Modèle : champ bluemap_url + ConnectInfo (adresse, version, vocal, modpack)
- API : connectInfo() sur /api/servers/{id}/connect (URL mrpack rendue absolue)
- Écran détail : carte BlueMap (WebView, état vide si serveur éteint) + carte Se connecter (copie adresse, vocal, download/copie du .mrpack)
- dep webview_flutter
This commit is contained in:
@@ -18,6 +18,7 @@ class GameServer {
|
||||
final bool hasIcon;
|
||||
final bool hasImage;
|
||||
final bool custom;
|
||||
final String? bluemapUrl;
|
||||
|
||||
const GameServer({
|
||||
required this.id,
|
||||
@@ -36,6 +37,7 @@ class GameServer {
|
||||
this.hasIcon = false,
|
||||
this.hasImage = false,
|
||||
this.custom = false,
|
||||
this.bluemapUrl,
|
||||
});
|
||||
|
||||
factory GameServer.fromJson(Map<String, dynamic> json) => GameServer(
|
||||
@@ -55,8 +57,11 @@ class GameServer {
|
||||
hasIcon: json['has_icon'] 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 isBusy => status == 'starting' || status == 'partial';
|
||||
bool get isPreprod => env == 'preprod';
|
||||
@@ -111,3 +116,40 @@ class DockerContainer {
|
||||
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(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user