From 0257f0fa050ffe199abfbe0432d0b92c385a19cd Mon Sep 17 00:00:00 2001 From: neckfire Date: Mon, 13 Jul 2026 11:33:12 +0200 Subject: [PATCH] =?UTF-8?q?feat(ui):=20preprod=20dans=20un=20onglet=20s?= =?UTF-8?q?=C3=A9par=C3=A9=20(TabBar=20Production=20/=20Preprod)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 --- lib/screens/servers_screen.dart | 79 ++++++++++++++------------------- 1 file changed, 33 insertions(+), 46 deletions(-) diff --git a/lib/screens/servers_screen.dart b/lib/screens/servers_screen.dart index 13ce531..9f1663e 100644 --- a/lib/screens/servers_screen.dart +++ b/lib/screens/servers_screen.dart @@ -101,17 +101,23 @@ class _ServersScreenState extends State { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Text('Serveurs'), - actions: [ - IconButton(onPressed: _openSettings, icon: const Icon(Icons.settings_outlined)), - IconButton(onPressed: _logout, icon: const Icon(Icons.logout)), - ], - ), - body: RefreshIndicator( - onRefresh: _refresh, - child: _buildBody(), + return DefaultTabController( + length: 2, + child: Scaffold( + appBar: AppBar( + title: const Text('Serveurs'), + actions: [ + IconButton(onPressed: _openSettings, icon: const Icon(Icons.settings_outlined)), + 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: _buildBody(), ), ); } @@ -134,19 +140,23 @@ class _ServersScreenState extends State { final prod = _servers!.where((s) => !s.isPreprod).toList(); final preprod = _servers!.where((s) => s.isPreprod).toList(); - final children = []; - if (prod.isNotEmpty) { - 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 TabBarView( + children: [_envList(prod), _envList(preprod)], + ); + } - return ListView( - padding: const EdgeInsets.fromLTRB(16, 4, 16, 24), - children: children, + Widget _envList(List 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(), + ), ); } @@ -163,26 +173,3 @@ class _ServersScreenState extends State { ), ); } - -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)), - ], - ), - ); - } -}