[imp]: Code cleanup
This commit is contained in:
@@ -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';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,9 +287,6 @@ class _AppDetailsScreenState extends State<AppDetailsScreen> {
|
||||
// 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<Color>(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!
|
||||
|
||||
@@ -564,7 +564,7 @@ Future<void> _toggleRepositoryWithDialog(
|
||||
|
||||
return ValueListenableBuilder<double>(
|
||||
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<void> _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<void> _runRepositoryActionWithDialog(
|
||||
|
||||
return ValueListenableBuilder<double>(
|
||||
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<void> _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<Map<String, String>> _presets = [];
|
||||
final bool _showPresets = true;
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_nameController = TextEditingController();
|
||||
_urlController = TextEditingController();
|
||||
_loadPresets();
|
||||
// _loadPresets();
|
||||
}
|
||||
|
||||
Future<void> _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<void> _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() {
|
||||
|
||||
@@ -211,7 +211,7 @@ class _SearchScreenState extends State<SearchScreen> {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
CircularProgressIndicator(year2023: false),
|
||||
CircularProgressIndicator(),
|
||||
SizedBox(height: 16),
|
||||
Text(AppLocalizations.of(context)!.searching),
|
||||
],
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
|
||||
@@ -52,7 +52,7 @@ class _MListHeaderState extends State<MListHeader> {
|
||||
}
|
||||
|
||||
class MListView extends StatelessWidget {
|
||||
final items;
|
||||
final List items;
|
||||
final bool? enableScroll;
|
||||
final bool? shrinkWrap;
|
||||
const MListView({
|
||||
|
||||
Reference in New Issue
Block a user