From 14c3850092281e9ab66393de35abe7b333ab009e Mon Sep 17 00:00:00 2001 From: dwindown Date: Thu, 2 Apr 2026 07:06:03 +0700 Subject: [PATCH] fix(about): show update action only when update is available --- lib/features/admin/admin_screen.dart | 63 ++++++++++++++++------------ pubspec.yaml | 2 +- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/lib/features/admin/admin_screen.dart b/lib/features/admin/admin_screen.dart index dc4ae5c..4ce3454 100644 --- a/lib/features/admin/admin_screen.dart +++ b/lib/features/admin/admin_screen.dart @@ -408,6 +408,11 @@ class _AdminScreenState extends ConsumerState { _currentVersion = result.current; _updateCheckResult = result; }); + if (!result.updateAvailable && + _selectedTab == 5 && + _tentangFocusNodes[1].hasFocus) { + _focusTentangRow(0); + } _showStatusBadge( result.hasError ? result.errorMessage! @@ -1141,7 +1146,7 @@ class _AdminScreenState extends ConsumerState { void _focusTentangRow(int index) { if (_selectedTab != 5) return; - if (index < 0 || index >= _tentangFocusNodes.length) return; + if (index < 0 || index >= _tentangRowCount()) return; WidgetsBinding.instance.addPostFrameCallback((_) { if (mounted) { _tentangFocusNodes[index].requestFocus(); @@ -1149,6 +1154,10 @@ class _AdminScreenState extends ConsumerState { }); } + int _tentangRowCount() { + return (_updateCheckResult?.updateAvailable ?? false) ? 2 : 1; + } + void _focusJadwalRow(int index) { if (_selectedTab != 1) return; if (index < 0 || index >= _jadwalFocusNodes.length) return; @@ -3960,38 +3969,38 @@ class _AdminScreenState extends ConsumerState { : 'CEK UPDATE', ), ), - SizedBox(height: 16 * s), - _buildTentangActionButton( - rowIndex: 1, - s: s, - onActivate: _installLatestUpdate, - builder: (isFocused) => _buildTvPrimaryActionSurface( + if (updateResult?.updateAvailable ?? false) ...[ + SizedBox(height: 16 * s), + _buildTentangActionButton( + rowIndex: 1, s: s, - isFocused: isFocused, - icon: _isInstallingUpdate - ? SizedBox( - width: 24 * s, - height: 24 * s, - child: CircularProgressIndicator( + onActivate: _installLatestUpdate, + builder: (isFocused) => _buildTvPrimaryActionSurface( + s: s, + isFocused: isFocused, + icon: _isInstallingUpdate + ? SizedBox( + width: 24 * s, + height: 24 * s, + child: CircularProgressIndicator( + color: isFocused + ? SacredColors.onPrimary + : SacredColors.onSecondary, + strokeWidth: 3, + ), + ) + : HugeIcon( + icon: HugeIcons.strokeRoundedArrowDown01, color: isFocused ? SacredColors.onPrimary : SacredColors.onSecondary, - strokeWidth: 3, ), - ) - : HugeIcon( - icon: HugeIcons.strokeRoundedArrowDown01, - color: isFocused - ? SacredColors.onPrimary - : SacredColors.onSecondary, - ), - label: _isInstallingUpdate - ? 'MENGUNDUH UPDATE ${(100 * _updateDownloadProgress).toStringAsFixed(0)}%' - : (updateResult?.updateAvailable ?? false) - ? 'UPDATE SEKARANG' - : 'BELUM ADA UPDATE', + label: _isInstallingUpdate + ? 'MENGUNDUH UPDATE ${(100 * _updateDownloadProgress).toStringAsFixed(0)}%' + : 'UPDATE SEKARANG', + ), ), - ), + ], ], ), ), diff --git a/pubspec.yaml b/pubspec.yaml index 8818e0e..fb6acac 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: jamshalat_masjid_screen description: Smart Digital Prayer Clock for Android TV Box publish_to: 'none' -version: 1.0.3+4 +version: 1.0.4+5 environment: sdk: '>=3.0.0 <4.0.0'