diff --git a/lib/data/store/setting.dart b/lib/data/store/setting.dart index e212023e..7c7519e0 100644 --- a/lib/data/store/setting.dart +++ b/lib/data/store/setting.dart @@ -6,10 +6,9 @@ import '../model/app/net_view.dart'; import '../res/default.dart'; class SettingStore extends PersistentStore { - // ------BEGIN------ // These settings are not displayed in the settings page - // You can edit them in the settings json editor (by long press the settings + // You can edit them in the settings json editor (by long press the settings // item in the drawer of the server tab page) /// Discussion #146 diff --git a/lib/view/page/server/tab.dart b/lib/view/page/server/tab.dart index d9f0d11a..e80aedac 100644 --- a/lib/view/page/server/tab.dart +++ b/lib/view/page/server/tab.dart @@ -38,6 +38,8 @@ class _ServerPageState extends State late SettingStore _settingStore; late S _s; + final _flipedCardIds = {}; + String? _tag; bool _useDoubleColumn = false; @@ -189,10 +191,16 @@ class _ServerPageState extends State _showFailReason(si.status); } }, - onLongPress: () => AppRoute.serverEdit(spi: si.spi).go(context), + onLongPress: () => setState(() { + if (_flipedCardIds.contains(si.spi.id)) { + _flipedCardIds.remove(si.spi.id); + } else { + _flipedCardIds.add(si.spi.id); + } + }), child: Padding( padding: const EdgeInsets.all(13), - child: _buildRealServerCard(si.status, si.state, si.spi), + child: _buildRealServerCard(si), ), ), ); @@ -207,51 +215,21 @@ class _ServerPageState extends State ); } - Widget _buildRealServerCard( - ServerStatus ss, - ServerState cs, - ServerPrivateInfo spi, - ) { - final rootDisk = findRootDisk(ss.disk); - late final List children; - if (cs != ServerState.finished) { - children = [ - _buildServerCardTitle(ss, cs, spi), - ]; + Widget _buildRealServerCard(Server srv) { + final title = _buildServerCardTitle(srv.status, srv.state, srv.spi); + final List children = [title]; + if (srv.state != ServerState.finished) { + // Do nothing + } else if (_flipedCardIds.contains(srv.spi.id)) { + children.addAll(_buildFlipedCard(srv)); } else { - children = [ - _buildServerCardTitle(ss, cs, spi), - height13, - Padding( - padding: const EdgeInsets.symmetric(horizontal: 13), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - _wrapWithSizedbox(_buildPercentCircle(ss.cpu.usedPercent())), - _wrapWithSizedbox(_buildPercentCircle(ss.mem.usedPercent * 100)), - _wrapWithSizedbox(_buildNet(ss)), - _wrapWithSizedbox(_buildIOData( - 'Total:\n${rootDisk?.size}', - 'Used:\n${rootDisk?.usedPercent}%', - )), - ], - ), - ), - height13, - if (_settingStore.moveOutServerTabFuncBtns.fetch() && - // Discussion #146 - !_settingStore.serverTabUseOldUI.fetch()) - SizedBox( - height: 27, - child: ServerFuncBtns(spi: spi, s: _s), - ), - ]; + children.addAll(_buildNormalCard(srv.status, srv.spi)); } return AnimatedContainer( duration: const Duration(milliseconds: 377), curve: Curves.fastEaseInToSlowEaseOut, - height: _calcCardHeight(cs), + height: _calcCardHeight(srv.state, srv.spi.id), child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start, @@ -261,6 +239,59 @@ class _ServerPageState extends State ); } + List _buildFlipedCard(Server srv) { + return [ + height13, + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + IconButton( + onPressed: () => srv.client?.run('shutdown -h now'), + icon: const Icon(Icons.power_off), + ), + IconButton( + onPressed: () => srv.client?.run('reboot'), + icon: const Icon(Icons.refresh), + ), + IconButton( + onPressed: () => AppRoute.serverEdit(spi: srv.spi).go(context), + icon: const Icon(Icons.edit), + ) + ], + ) + ]; + } + + List _buildNormalCard(ServerStatus ss, ServerPrivateInfo spi) { + final rootDisk = findRootDisk(ss.disk); + return [ + height13, + Padding( + padding: const EdgeInsets.symmetric(horizontal: 13), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + _wrapWithSizedbox(_buildPercentCircle(ss.cpu.usedPercent())), + _wrapWithSizedbox(_buildPercentCircle(ss.mem.usedPercent * 100)), + _wrapWithSizedbox(_buildNet(ss)), + _wrapWithSizedbox(_buildIOData( + 'Total:\n${rootDisk?.size}', + 'Used:\n${rootDisk?.usedPercent}%', + )), + ], + ), + ), + height13, + if (_settingStore.moveOutServerTabFuncBtns.fetch() && + // Discussion #146 + !_settingStore.serverTabUseOldUI.fetch()) + SizedBox( + height: 27, + child: ServerFuncBtns(spi: spi, s: _s), + ), + ]; + } + Widget _buildServerCardTitle( ServerStatus ss, ServerState cs, @@ -450,10 +481,13 @@ class _ServerPageState extends State } } - double _calcCardHeight(ServerState cs) { + double _calcCardHeight(ServerState cs, String id) { if (cs != ServerState.finished) { return 23.0; } + if (_flipedCardIds.contains(id)) { + return 77.0; + } if (_settingStore.moveOutServerTabFuncBtns.fetch() && // Discussion #146 !_settingStore.serverTabUseOldUI.fetch()) {