From a2361da56056b1f7469cafce1f768a3a7ee6c475 Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Sun, 7 May 2023 20:44:15 +0800 Subject: [PATCH] opt. for `pkg` --- ios/Runner.xcodeproj/project.pbxproj | 12 +- lib/data/res/build_data.dart | 6 +- lib/view/page/docker.dart | 4 +- lib/view/page/pkg.dart | 186 ++++++++++++++------------- lib/view/page/sftp/view.dart | 2 +- 5 files changed, 107 insertions(+), 103 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 35f98ed5..edce4046 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -359,7 +359,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 286; + CURRENT_PROJECT_VERSION = 287; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -367,7 +367,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.286; + MARKETING_VERSION = 1.0.287; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -490,7 +490,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 286; + CURRENT_PROJECT_VERSION = 287; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -498,7 +498,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.286; + MARKETING_VERSION = 1.0.287; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -515,7 +515,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 286; + CURRENT_PROJECT_VERSION = 287; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -523,7 +523,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.286; + MARKETING_VERSION = 1.0.287; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index 8b208ab1..e38c075f 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,8 +2,8 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 286; + static const int build = 287; static const String engine = "3.7.11"; - static const String buildAt = "2023-05-07 18:10:41.721685"; - static const int modifications = 19; + static const String buildAt = "2023-05-07 18:25:45.312302"; + static const int modifications = 2; } diff --git a/lib/view/page/docker.dart b/lib/view/page/docker.dart index 987eddb7..f9d7da7c 100644 --- a/lib/view/page/docker.dart +++ b/lib/view/page/docker.dart @@ -97,7 +97,7 @@ class _DockerManagePageState extends State { children: [ buildInput( type: TextInputType.text, - label: _s.dockerImage, + label: _s.dockerImage, hint: 'xxx:1.1', controller: imageCtrl, autoCorrect: false, @@ -105,7 +105,7 @@ class _DockerManagePageState extends State { buildInput( type: TextInputType.text, controller: nameCtrl, - label: _s.dockerContainerName, + label: _s.dockerContainerName, hint: 'xxx', autoCorrect: false, ), diff --git a/lib/view/page/pkg.dart b/lib/view/page/pkg.dart index ff2f0ff9..94aa2a02 100644 --- a/lib/view/page/pkg.dart +++ b/lib/view/page/pkg.dart @@ -120,107 +120,111 @@ class _PkgManagePageState extends State @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - centerTitle: true, - title: TwoLineText(up: _s.pkg, down: widget.spi.name), - ), - body: Consumer(builder: (_, apt, __) { - if (apt.error != null) { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Icon( - Icons.error, - color: Colors.redAccent, - size: 37, - ), - const SizedBox( - height: 37, - ), - ConstrainedBox( - constraints: BoxConstraints( - maxHeight: _media.size.height * 0.3, - minWidth: _media.size.width), - child: Padding( - padding: const EdgeInsets.all(17), - child: RoundRectCard( - SingleChildScrollView( - padding: const EdgeInsets.all(17), - child: Text( - apt.error!, - ), - ), - ), - ), - ), - ], - ); - } - if (apt.updateLog == null && apt.upgradeable == null) { - return centerLoading; - } - if (apt.updateLog != null && apt.upgradeable == null) { - return SizedBox( - height: - _media.size.height - _media.padding.top - _media.padding.bottom, - child: ConstrainedBox( - constraints: const BoxConstraints.expand(), - child: SingleChildScrollView( - padding: const EdgeInsets.all(18), - controller: _scrollControllerUpdate, - child: Text(apt.updateLog!), - ), - ), - ); - } - return ListView( - padding: const EdgeInsets.all(13), - children: [ - _buildUpdatePanel(apt), - ].map((e) => RoundRectCard(e)).toList(), - ); - }), + return Consumer(builder: (_, pkg, __) { + return Scaffold( + appBar: AppBar( + centerTitle: true, + title: TwoLineText(up: _s.pkg, down: widget.spi.name), + ), + body: _buildBody(pkg), + floatingActionButton: _buildFAB(pkg), + ); + }); + } + + Widget _buildFAB(PkgProvider pkg) { + if (pkg.isBusy || (pkg.upgradeable?.isEmpty ?? true)) { + return const SizedBox(); + } + return FloatingActionButton( + onPressed: () { + pkg.upgrade(); + }, + child: const Icon(Icons.upgrade), ); } - Widget _buildUpdatePanel(PkgProvider apt) { + Widget _buildBody(PkgProvider pkg) { + if (pkg.error != null) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon( + Icons.error, + color: Colors.redAccent, + size: 37, + ), + const SizedBox( + height: 37, + ), + ConstrainedBox( + constraints: BoxConstraints( + maxHeight: _media.size.height * 0.3, + minWidth: _media.size.width), + child: Padding( + padding: const EdgeInsets.all(17), + child: RoundRectCard( + SingleChildScrollView( + padding: const EdgeInsets.all(17), + child: Text( + pkg.error!, + ), + ), + ), + ), + ), + ], + ); + } + if (pkg.upgradeable == null) { + if (pkg.updateLog == null) { + return centerLoading; + } + return SizedBox( + height: _media.size.height - _media.padding.top - _media.padding.bottom, + child: ConstrainedBox( + constraints: const BoxConstraints.expand(), + child: SingleChildScrollView( + padding: const EdgeInsets.all(18), + controller: _scrollControllerUpdate, + child: Text(pkg.updateLog!), + ), + ), + ); + } + + return ListView( + padding: const EdgeInsets.all(13), + children: _buildUpdatePanel(pkg).map((e) => RoundRectCard(e)).toList(), + ); + } + + List _buildUpdatePanel(PkgProvider apt) { + final children = []; if (apt.upgradeable!.isEmpty) { - return ListTile( + children.add(ListTile( title: Text( _s.noUpdateAvailable, textAlign: TextAlign.center, ), subtitle: const Text('>_<', textAlign: TextAlign.center), - ); + )); + return children; } - return ExpansionTile( - title: Text(_s.foundNUpdate(apt.upgradeable!.length)), - subtitle: Text( - apt.upgradeable!.map((e) => e.package).join(', '), - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: grey, - ), - initiallyExpanded: true, - children: apt.upgradeLog == null - ? [ - TextButton( - child: Text(_s.updateAll), - onPressed: () { - apt.upgrade(); - }, - ), - ...apt.upgradeable!.map((e) => _buildUpdateItem(e, apt)).toList() - ] - : [ - SingleChildScrollView( - padding: const EdgeInsets.all(18), - controller: _scrollController, - child: Text(apt.upgradeLog!), - ) - ], - ); + + if (apt.upgradeLog == null) { + children.addAll( + apt.upgradeable?.map((e) => _buildUpdateItem(e, apt)).toList() ?? [], + ); + } else { + children.add(SingleChildScrollView( + padding: const EdgeInsets.all(18), + controller: _scrollController, + child: Text(apt.upgradeLog ?? ''), + )); + } + + return children; } Widget _buildUpdateItem(UpgradePkgInfo info, PkgProvider apt) { diff --git a/lib/view/page/sftp/view.dart b/lib/view/page/sftp/view.dart index f5a562d3..072b0fb0 100644 --- a/lib/view/page/sftp/view.dart +++ b/lib/view/page/sftp/view.dart @@ -184,7 +184,7 @@ class _SFTPPageState extends State { if (_status.files == null) { _status.path = AbsolutePath('/'); listDir(path: '/', client: _client); - return centerSizedLoading; + return centerLoading; } else { return RefreshIndicator( child: FadeIn(