норм отображение памяти

This commit is contained in:
jganenok
2025-11-17 15:05:02 +07:00
parent 2c405b49e3
commit ff42723f6f
3 changed files with 23 additions and 43 deletions

View File

@@ -180,7 +180,7 @@ class _HomeScreenState extends State<HomeScreen> {
return; return;
} }
final isAutoUpdateEnabled = prefs.getBool('auto_update_enabled') ?? true; final isAutoUpdateEnabled = prefs.getBool('auto_update_enabled') ?? false;
final showUpdateNotification = final showUpdateNotification =
prefs.getBool('show_update_notification') ?? true; prefs.getBool('show_update_notification') ?? true;
@@ -640,7 +640,7 @@ class _HomeScreenState extends State<HomeScreen> {
try { try {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
final isAutoUpdateEnabled = prefs.getBool('auto_update_enabled') ?? true; final isAutoUpdateEnabled = prefs.getBool('auto_update_enabled') ?? false;
final currentVersion = prefs.getString('spoof_appversion') ?? '0.0.0'; final currentVersion = prefs.getString('spoof_appversion') ?? '0.0.0';
final latestVersion = await VersionChecker.getLatestVersion(); final latestVersion = await VersionChecker.getLatestVersion();

View File

@@ -14,7 +14,7 @@ class KometMiscScreen extends StatefulWidget {
class _KometMiscScreenState extends State<KometMiscScreen> { class _KometMiscScreenState extends State<KometMiscScreen> {
bool? _isBatteryOptimizationDisabled; bool? _isBatteryOptimizationDisabled;
bool _isAutoUpdateEnabled = true; bool _isAutoUpdateEnabled = false;
bool _showUpdateNotification = true; bool _showUpdateNotification = true;
bool _enableWebVersionCheck = false; bool _enableWebVersionCheck = false;
bool _showSpoofUpdateDialog = true; bool _showSpoofUpdateDialog = true;
@@ -29,7 +29,7 @@ class _KometMiscScreenState extends State<KometMiscScreen> {
Future<void> _loadUpdateSettings() async { Future<void> _loadUpdateSettings() async {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
setState(() { setState(() {
_isAutoUpdateEnabled = prefs.getBool('auto_update_enabled') ?? true; _isAutoUpdateEnabled = prefs.getBool('auto_update_enabled') ?? false;
_showUpdateNotification = _showUpdateNotification =
prefs.getBool('show_update_notification') ?? true; prefs.getBool('show_update_notification') ?? true;
_enableWebVersionCheck = _enableWebVersionCheck =

View File

@@ -5,7 +5,7 @@ import 'dart:math';
class StorageScreen extends StatefulWidget { class StorageScreen extends StatefulWidget {
final bool isModal; final bool isModal;
const StorageScreen({super.key, this.isModal = false}); const StorageScreen({super.key, this.isModal = false});
@override @override
@@ -28,14 +28,11 @@ class _StorageScreenState extends State<StorageScreen>
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
child: Column( child: Column(
children: [ children: [
_buildStorageChart(colors), _buildStorageChart(colors),
const SizedBox(height: 20), const SizedBox(height: 20),
_buildStorageDetails(colors), _buildStorageDetails(colors),
const SizedBox(height: 20), const SizedBox(height: 20),
_buildActionButtons(colors), _buildActionButtons(colors),
], ],
@@ -85,15 +82,16 @@ class _StorageScreenState extends State<StorageScreen>
final cacheSize = await _getDirectorySize(cacheDir); final cacheSize = await _getDirectorySize(cacheDir);
final totalSize = appSize + cacheSize; final totalSize = appSize + cacheSize;
final messagesSize = (totalSize * 0.4).round(); final messagesSize = totalSize > 0 ? (totalSize * 0.3).round() : 0;
final mediaSize = (totalSize * 0.3).round(); final mediaSize = totalSize > 0 ? (totalSize * 0.25).round() : 0;
final otherSize = totalSize - messagesSize - mediaSize; final cacheSizeAdjusted = totalSize > 0 ? (totalSize * 0.2).round() : 0;
final otherSize = totalSize - messagesSize - mediaSize - cacheSizeAdjusted;
return StorageInfo( return StorageInfo(
totalSize: totalSize, totalSize: totalSize,
messagesSize: messagesSize, messagesSize: messagesSize,
mediaSize: mediaSize, mediaSize: mediaSize,
cacheSize: cacheSize, cacheSize: cacheSizeAdjusted,
otherSize: otherSize, otherSize: otherSize,
); );
} }
@@ -109,8 +107,8 @@ class _StorageScreenState extends State<StorageScreen>
} }
} }
} catch (e) { } catch (e) {
print('Ошибка при подсчете размера директории ${dir.path}: $e');
totalSize = Random().nextInt(50) * 1024 * 1024; // 0-50 MB totalSize = 0; // В случае ошибки возвращаем 0
} }
return totalSize; return totalSize;
} }
@@ -260,17 +258,14 @@ class _StorageScreenState extends State<StorageScreen>
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
_buildStorageChart(colors), _buildStorageChart(colors),
const SizedBox(height: 32), const SizedBox(height: 32),
_buildStorageDetails(colors), _buildStorageDetails(colors),
const SizedBox(height: 32), const SizedBox(height: 32),
_buildActionButtons(colors), _buildActionButtons(colors),
], ],
), ),
@@ -283,7 +278,6 @@ class _StorageScreenState extends State<StorageScreen>
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
body: Stack( body: Stack(
children: [ children: [
GestureDetector( GestureDetector(
onTap: () => Navigator.of(context).pop(), onTap: () => Navigator.of(context).pop(),
child: Container( child: Container(
@@ -292,7 +286,6 @@ class _StorageScreenState extends State<StorageScreen>
color: Colors.black.withOpacity(0.3), color: Colors.black.withOpacity(0.3),
), ),
), ),
Center( Center(
child: Container( child: Container(
@@ -312,7 +305,6 @@ class _StorageScreenState extends State<StorageScreen>
), ),
child: Column( child: Column(
children: [ children: [
Container( Container(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
decoration: BoxDecoration( decoration: BoxDecoration(
@@ -346,7 +338,6 @@ class _StorageScreenState extends State<StorageScreen>
], ],
), ),
), ),
Expanded( Expanded(
child: _isLoading child: _isLoading
@@ -355,14 +346,11 @@ class _StorageScreenState extends State<StorageScreen>
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
child: Column( child: Column(
children: [ children: [
_buildStorageChart(colors), _buildStorageChart(colors),
const SizedBox(height: 20), const SizedBox(height: 20),
_buildStorageDetails(colors), _buildStorageDetails(colors),
const SizedBox(height: 20), const SizedBox(height: 20),
_buildActionButtons(colors), _buildActionButtons(colors),
], ],
@@ -406,7 +394,6 @@ class _StorageScreenState extends State<StorageScreen>
), ),
const SizedBox(height: 24), const SizedBox(height: 24),
AnimatedBuilder( AnimatedBuilder(
animation: _animation, animation: _animation,
builder: (context, child) { builder: (context, child) {
@@ -415,7 +402,6 @@ class _StorageScreenState extends State<StorageScreen>
height: 200, height: 200,
child: Stack( child: Stack(
children: [ children: [
Container( Container(
width: 200, width: 200,
height: 200, height: 200,
@@ -425,7 +411,6 @@ class _StorageScreenState extends State<StorageScreen>
), ),
), ),
CustomPaint( CustomPaint(
size: const Size(200, 200), size: const Size(200, 200),
painter: StorageChartPainter( painter: StorageChartPainter(
@@ -436,7 +421,6 @@ class _StorageScreenState extends State<StorageScreen>
), ),
), ),
Center( Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@@ -467,7 +451,6 @@ class _StorageScreenState extends State<StorageScreen>
const SizedBox(height: 24), const SizedBox(height: 24),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
@@ -725,35 +708,32 @@ class StorageChartPainter extends CustomPainter {
final paint = Paint() final paint = Paint()
..style = PaintingStyle.stroke ..style = PaintingStyle.stroke
..strokeWidth = 24 // Увеличиваем толщину с 16 до 24 ..strokeWidth = 20
..strokeCap = StrokeCap.round; ..strokeCap = StrokeCap.butt;
paint.color = colors.surfaceContainerHighest; paint.color = colors.surfaceContainerHighest;
canvas.drawCircle(center, radius, paint); canvas.drawCircle(center, radius, paint);
final totalSize = storageInfo.totalSize; final totalSize = storageInfo.totalSize;
if (totalSize > 0) { if (totalSize > 0) {
double startAngle = -pi / 2;
final messagesRatio = storageInfo.messagesSize / totalSize; final messagesRatio = storageInfo.messagesSize / totalSize;
final mediaRatio = storageInfo.mediaSize / totalSize; final mediaRatio = storageInfo.mediaSize / totalSize;
final cacheRatio = storageInfo.cacheSize / totalSize; final cacheRatio = storageInfo.cacheSize / totalSize;
final otherRatio = storageInfo.otherSize / totalSize; final otherRatio = storageInfo.otherSize / totalSize;
double currentAngle = -pi / 2;
if (messagesRatio > 0) { if (messagesRatio > 0) {
paint.color = Colors.blue; paint.color = Colors.blue;
final sweepAngle = 2 * pi * messagesRatio * animationValue; final sweepAngle = 2 * pi * messagesRatio * animationValue;
canvas.drawArc( canvas.drawArc(
Rect.fromCircle(center: center, radius: radius), Rect.fromCircle(center: center, radius: radius),
startAngle, currentAngle,
sweepAngle, sweepAngle,
false, false,
paint, paint,
); );
startAngle += 2 * pi * messagesRatio; // Обновляем без анимации currentAngle += sweepAngle;
} }
if (mediaRatio > 0) { if (mediaRatio > 0) {
@@ -761,12 +741,12 @@ class StorageChartPainter extends CustomPainter {
final sweepAngle = 2 * pi * mediaRatio * animationValue; final sweepAngle = 2 * pi * mediaRatio * animationValue;
canvas.drawArc( canvas.drawArc(
Rect.fromCircle(center: center, radius: radius), Rect.fromCircle(center: center, radius: radius),
startAngle, currentAngle,
sweepAngle, sweepAngle,
false, false,
paint, paint,
); );
startAngle += 2 * pi * mediaRatio; // Обновляем без анимации currentAngle += sweepAngle;
} }
if (cacheRatio > 0) { if (cacheRatio > 0) {
@@ -774,12 +754,12 @@ class StorageChartPainter extends CustomPainter {
final sweepAngle = 2 * pi * cacheRatio * animationValue; final sweepAngle = 2 * pi * cacheRatio * animationValue;
canvas.drawArc( canvas.drawArc(
Rect.fromCircle(center: center, radius: radius), Rect.fromCircle(center: center, radius: radius),
startAngle, currentAngle,
sweepAngle, sweepAngle,
false, false,
paint, paint,
); );
startAngle += 2 * pi * cacheRatio; // Обновляем без анимации currentAngle += sweepAngle;
} }
if (otherRatio > 0) { if (otherRatio > 0) {
@@ -787,7 +767,7 @@ class StorageChartPainter extends CustomPainter {
final sweepAngle = 2 * pi * otherRatio * animationValue; final sweepAngle = 2 * pi * otherRatio * animationValue;
canvas.drawArc( canvas.drawArc(
Rect.fromCircle(center: center, radius: radius), Rect.fromCircle(center: center, radius: radius),
startAngle, currentAngle,
sweepAngle, sweepAngle,
false, false,
paint, paint,