ну немножечко так оптимизировал чутка, добавил раздел 'производительность' в насторйки, немного сделал чуточку в кастомизации, пару мелочей переделал

This commit is contained in:
Jganenok
2026-05-16 21:10:21 +07:00
parent 4928acc0f9
commit fc7a225b8a
35 changed files with 1818 additions and 944 deletions
+34
View File
@@ -0,0 +1,34 @@
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
class AppAccent {
static const prefKey = 'app_accent_seed';
static const List<({String label, Color? seed})> presets = [
(label: 'Системный', seed: null),
(label: 'Сиреневый', seed: Color(0xFFC1C4FF)),
(label: 'Синий', seed: Color(0xFF4F8EFF)),
(label: 'Бирюзовый', seed: Color(0xFF00BFA5)),
(label: 'Зелёный', seed: Color(0xFF43A047)),
(label: 'Янтарный', seed: Color(0xFFFFB300)),
(label: 'Розовый', seed: Color(0xFFE91E63)),
(label: 'Красный', seed: Color(0xFFE53935)),
(label: 'Фиолетовый', seed: Color(0xFF7E57C2)),
];
static Future<Color?> load() async {
final prefs = await SharedPreferences.getInstance();
final val = prefs.getInt(prefKey);
if (val == null) return null;
return Color(val);
}
static Future<void> save(Color? color) async {
final prefs = await SharedPreferences.getInstance();
if (color == null) {
await prefs.remove(prefKey);
} else {
await prefs.setInt(prefKey, color.toARGB32());
}
}
}
+37
View File
@@ -0,0 +1,37 @@
import 'package:flutter/foundation.dart';
import 'package:shared_preferences/shared_preferences.dart';
enum BubbleStyle { mobile, desktop }
class AppBubbleShape {
static const prefKey = 'app_bubble_shape';
static final ValueNotifier<BubbleStyle> current = ValueNotifier(
BubbleStyle.mobile,
);
static Future<BubbleStyle> load() async {
final prefs = await SharedPreferences.getInstance();
final val = prefs.getString(prefKey);
return _parse(val);
}
static Future<void> save(BubbleStyle style) async {
current.value = style;
final prefs = await SharedPreferences.getInstance();
await prefs.setString(prefKey, style.name);
}
static BubbleStyle _parse(String? val) {
if (val == BubbleStyle.desktop.name) return BubbleStyle.desktop;
return BubbleStyle.mobile;
}
static String label(BubbleStyle style) {
switch (style) {
case BubbleStyle.mobile:
return 'TG Mobile';
case BubbleStyle.desktop:
return 'TG Desktop';
}
}
}
+33
View File
@@ -0,0 +1,33 @@
import 'package:flutter/foundation.dart';
import 'package:shared_preferences/shared_preferences.dart';
class AppCacheExtent {
static const prefKey = 'app_cache_extent';
static const double defaultValue = 5000;
static const double min = 1000;
static const double max = 10000;
static const double lowWarnThreshold = 2500;
static const double highWarnThreshold = 7000;
static final ValueNotifier<double> current = ValueNotifier(defaultValue);
static Future<double> load() async {
final prefs = await SharedPreferences.getInstance();
final raw = prefs.getDouble(prefKey);
if (raw == null) return defaultValue;
return clamp(raw);
}
static Future<void> save(double value) async {
final clamped = clamp(value);
current.value = clamped;
final prefs = await SharedPreferences.getInstance();
await prefs.setDouble(prefKey, clamped);
}
static double clamp(double v) {
if (v < min) return min;
if (v > max) return max;
return v;
}
}