From 59209d88389b672eb8df909591c68634cab11966 Mon Sep 17 00:00:00 2001 From: nahnah Date: Tue, 10 Feb 2026 11:45:55 +0000 Subject: [PATCH] [imp]: Code cleanup --- lib/providers/download_provider.dart | 3 +- lib/screens/app_details_screen.dart | 20 ++++------ lib/screens/repositories_screen.dart | 55 +++++++++++++--------------- lib/screens/search_screen.dart | 2 +- lib/services/fdroid_api_service.dart | 14 +++---- lib/themes/app_themes.dart | 2 +- lib/widgets/app_list_item.dart | 4 +- lib/widgets/m_list.dart | 2 +- 8 files changed, 46 insertions(+), 56 deletions(-) diff --git a/lib/providers/download_provider.dart b/lib/providers/download_provider.dart index 0396b56..b5282ae 100644 --- a/lib/providers/download_provider.dart +++ b/lib/providers/download_provider.dart @@ -68,8 +68,9 @@ class DownloadInfo { static String _formatBytes(int bytes) { if (bytes < 1024) return '$bytes B'; if (bytes < 1024 * 1024) return '${(bytes / 1024).toStringAsFixed(1)} KB'; - if (bytes < 1024 * 1024 * 1024) + if (bytes < 1024 * 1024 * 1024) { return '${(bytes / (1024 * 1024)).toStringAsFixed(1)} MB'; + } return '${(bytes / (1024 * 1024 * 1024)).toStringAsFixed(2)} GB'; } } diff --git a/lib/screens/app_details_screen.dart b/lib/screens/app_details_screen.dart index 59704d9..a698b1a 100644 --- a/lib/screens/app_details_screen.dart +++ b/lib/screens/app_details_screen.dart @@ -287,9 +287,6 @@ class _AppDetailsScreenState extends State { // Get the tracked repository for this app (if any) final trackedRepo = await downloadProvider.getAppSource(app.packageName); - // Capture the mounted context before showing dialog - final scaffoldMessenger = ScaffoldMessenger.of(context); - await showModalBottomSheet( context: context, builder: (dialogContext) => Padding( @@ -1340,7 +1337,6 @@ class _DownloadSectionState extends State<_DownloadSection> { const SizedBox(height: 8), LinearProgressIndicator( value: progress, - year2023: false, ) .animate() .fadeIn(duration: Duration(milliseconds: 300)) @@ -1648,7 +1644,7 @@ class _IzzyStatsLoadingCard extends StatelessWidget { child: Row( spacing: 12, children: [ - CircularProgressIndicator(year2023: false), + CircularProgressIndicator(), Expanded( child: Text( 'Loading IzzyOnDroid download stats...', @@ -2153,14 +2149,14 @@ class _AppDetailsIconState extends State<_AppDetailsIcon> { Widget build(BuildContext context) { if (_showFallback) { return Container( - color: Colors.white.withOpacity(0.2), + color: Colors.white.withValues(alpha: 0.2), child: const Icon(Symbols.android, color: Colors.white, size: 40), ); } if (_index >= _candidates.length) { return Container( - color: Colors.white.withOpacity(0.2), + color: Colors.white.withValues(alpha: 0.2), child: const Icon(Symbols.apps, color: Colors.white, size: 40), ); } @@ -2173,7 +2169,7 @@ class _AppDetailsIconState extends State<_AppDetailsIcon> { // Move to next candidate or fallback _next(); return Container( - color: Colors.white.withOpacity(0.2), + color: Colors.white.withValues(alpha: 0.2), child: const Icon( Symbols.broken_image, color: Colors.white, @@ -2184,14 +2180,13 @@ class _AppDetailsIconState extends State<_AppDetailsIcon> { loadingBuilder: (context, child, loadingProgress) { if (loadingProgress == null) return child; return Container( - color: Colors.white.withOpacity(0.2), + color: Colors.white.withValues(alpha: 0.2), alignment: Alignment.center, child: const SizedBox( width: 20, height: 20, child: CircularProgressIndicator( strokeWidth: 2, - year2023: false, valueColor: AlwaysStoppedAnimation(Colors.white), ), ), @@ -2481,7 +2476,7 @@ class _VersionDownloadButton extends StatelessWidget { ], ), const SizedBox(height: 8), - LinearProgressIndicator(value: progress, year2023: false), + LinearProgressIndicator(value: progress), ], ); } @@ -2670,7 +2665,7 @@ class _ScreenshotsSectionState extends State<_ScreenshotsSection> { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - const CircularProgressIndicator(year2023: false), + const CircularProgressIndicator(), const SizedBox(height: 12), Padding( padding: const EdgeInsets.symmetric( @@ -2795,7 +2790,6 @@ class _FullScreenScreenshotsState extends State<_FullScreenScreenshots> { if (loadingProgress == null) return child; return Center( child: CircularProgressIndicator( - year2023: false, value: loadingProgress.expectedTotalBytes != null ? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes! diff --git a/lib/screens/repositories_screen.dart b/lib/screens/repositories_screen.dart index f73d10c..0ec385c 100644 --- a/lib/screens/repositories_screen.dart +++ b/lib/screens/repositories_screen.dart @@ -564,7 +564,7 @@ Future _toggleRepositoryWithDialog( return ValueListenableBuilder( valueListenable: progress, - builder: (_, value, __) { + builder: (_, value, _) { final pct = (value * 100).clamp(0, 100).round(); return Padding( padding: const EdgeInsets.symmetric( @@ -599,7 +599,6 @@ Future _toggleRepositoryWithDialog( SizedBox(height: 16), LinearProgressIndicator( value: value == 0.0 ? null : value, - year2023: false, ), const SizedBox(height: 8), Text('$pct%', textAlign: TextAlign.right), @@ -638,7 +637,7 @@ Future _runRepositoryActionWithDialog( return ValueListenableBuilder( valueListenable: progress, - builder: (_, value, __) { + builder: (_, value, _) { final pct = (value * 100).clamp(0, 100).round(); return Padding( padding: const EdgeInsets.symmetric( @@ -673,7 +672,6 @@ Future _runRepositoryActionWithDialog( SizedBox(height: 16), LinearProgressIndicator( value: value == 0.0 ? null : value, - year2023: false, ), const SizedBox(height: 8), Text('$pct%', textAlign: TextAlign.right), @@ -700,39 +698,38 @@ class _AddRepositoryDialog extends StatefulWidget { class _AddRepositoryDialogState extends State<_AddRepositoryDialog> { late TextEditingController _nameController; late TextEditingController _urlController; - List> _presets = []; - final bool _showPresets = true; + @override void initState() { super.initState(); _nameController = TextEditingController(); _urlController = TextEditingController(); - _loadPresets(); + // _loadPresets(); } - Future _loadPresets() async { - try { - final jsonString = await DefaultAssetBundle.of( - context, - ).loadString('assets/repositories.json'); - final jsonData = jsonDecode(jsonString); - final repos = (jsonData['repositories'] as List) - .map( - (e) => { - 'name': e['name'] as String, - 'url': e['url'] as String, - 'description': e['description'] as String? ?? '', - }, - ) - .toList(); - setState(() { - _presets = repos; - }); - } catch (e) { - debugPrint('Error loading presets: $e'); - } - } + // Future _loadPresets() async { + // try { + // final jsonString = await DefaultAssetBundle.of( + // context, + // ).loadString('assets/repositories.json'); + // final jsonData = jsonDecode(jsonString); + // final repos = (jsonData['repositories'] as List) + // .map( + // (e) => { + // 'name': e['name'] as String, + // 'url': e['url'] as String, + // 'description': e['description'] as String? ?? '', + // }, + // ) + // .toList(); + // setState(() { + // _presets = repos; + // }); + // } catch (e) { + // debugPrint('Error loading presets: $e'); + // } + // } @override void dispose() { diff --git a/lib/screens/search_screen.dart b/lib/screens/search_screen.dart index a4acce5..1f54f01 100644 --- a/lib/screens/search_screen.dart +++ b/lib/screens/search_screen.dart @@ -211,7 +211,7 @@ class _SearchScreenState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - CircularProgressIndicator(year2023: false), + CircularProgressIndicator(), SizedBox(height: 16), Text(AppLocalizations.of(context)!.searching), ], diff --git a/lib/services/fdroid_api_service.dart b/lib/services/fdroid_api_service.dart index 9bb114b..5600fa0 100644 --- a/lib/services/fdroid_api_service.dart +++ b/lib/services/fdroid_api_service.dart @@ -763,9 +763,9 @@ class FDroidApiService { // Log download URL and file path final downloadUrl = version.downloadUrl(repositoryUrl); - print('[FDroidApiService] Downloading APK:'); - print(' URL: $downloadUrl'); - print(' To: $filePath'); + debugPrint('[FDroidApiService] Downloading APK:'); + debugPrint(' URL: $downloadUrl'); + debugPrint(' To: $filePath'); final token = cancelToken ?? CancelToken(); _downloadTokens[packageName] = token; @@ -785,7 +785,7 @@ class FDroidApiService { try { final status = response.statusCode; final contentType = response.headers.value('content-type'); - print( + debugPrint( '[FDroidApiService] Download response: status=$status, contentType=$contentType', ); } catch (_) {} @@ -814,7 +814,7 @@ class FDroidApiService { magic[2] == 0x03 && magic[3] == 0x04; - print( + debugPrint( '[FDroidApiService] Downloaded file: $filePath (exists: $fileExists, size: $fileSize bytes, zipMagic=$isZip, magicBytes=$magic)', ); @@ -822,7 +822,7 @@ class FDroidApiService { throw Exception('Downloaded APK is invalid or missing'); } } catch (e) { - print('[FDroidApiService] Error checking file after download: $e'); + debugPrint('[FDroidApiService] Error checking file after download: $e'); rethrow; } @@ -830,7 +830,7 @@ class FDroidApiService { return filePath; } catch (e) { _downloadTokens.remove(packageName); - print('[FDroidApiService] Error downloading APK: $e'); + debugPrint('[FDroidApiService] Error downloading APK: $e'); throw Exception('Error downloading APK: $e'); } } diff --git a/lib/themes/app_themes.dart b/lib/themes/app_themes.dart index d1ca83b..49b4e76 100644 --- a/lib/themes/app_themes.dart +++ b/lib/themes/app_themes.dart @@ -65,7 +65,7 @@ class AppThemes { borderSide: BorderSide.none, ), filled: true, - ), + ), progressIndicatorTheme: ProgressIndicatorThemeData(year2023: false), ); } diff --git a/lib/widgets/app_list_item.dart b/lib/widgets/app_list_item.dart index 43aa550..bbe2dd9 100644 --- a/lib/widgets/app_list_item.dart +++ b/lib/widgets/app_list_item.dart @@ -63,7 +63,6 @@ class AppListItem extends StatelessWidget { child: CircularProgressIndicator( value: isDownloading ? progress : null, strokeWidth: 2, - year2023: false, backgroundColor: theme.colorScheme.surfaceContainerHighest, ), @@ -196,7 +195,7 @@ class _MultiIconState extends State<_MultiIcon> { child: const SizedBox( width: 20, height: 20, - child: CircularProgressIndicator(strokeWidth: 2, year2023: false), + child: CircularProgressIndicator(strokeWidth: 2), ), ), errorWidget: (context, url, error) { @@ -284,7 +283,6 @@ class _QuickViewModal extends StatelessWidget { child: CircularProgressIndicator( value: isDownloading ? progress : null, strokeWidth: 4, - year2023: false, backgroundColor: theme.colorScheme.surfaceContainerHighest, ), diff --git a/lib/widgets/m_list.dart b/lib/widgets/m_list.dart index f3813db..e6ae4b9 100644 --- a/lib/widgets/m_list.dart +++ b/lib/widgets/m_list.dart @@ -52,7 +52,7 @@ class _MListHeaderState extends State { } class MListView extends StatelessWidget { - final items; + final List items; final bool? enableScroll; final bool? shrinkWrap; const MListView({