feat: слегонца блюра в chat screen

This commit is contained in:
Jganenokk
2026-07-03 19:07:43 +07:00
parent 473889186b
commit 53125b60a3
4 changed files with 303 additions and 33 deletions
+43
View File
@@ -0,0 +1,43 @@
import 'package:flutter/foundation.dart';
import 'package:shared_preferences/shared_preferences.dart';
enum ChatChromeStyle { color, blur, none }
class AppChatChrome {
static const prefKey = 'app_chat_chrome';
static final ValueNotifier<ChatChromeStyle> current =
ValueNotifier(ChatChromeStyle.blur);
static ChatChromeStyle _parse(String? value) {
switch (value) {
case 'color':
return ChatChromeStyle.color;
case 'none':
return ChatChromeStyle.none;
default:
return ChatChromeStyle.blur;
}
}
static String _encode(ChatChromeStyle value) {
switch (value) {
case ChatChromeStyle.color:
return 'color';
case ChatChromeStyle.blur:
return 'blur';
case ChatChromeStyle.none:
return 'none';
}
}
static Future<ChatChromeStyle> load() async {
final prefs = await SharedPreferences.getInstance();
return _parse(prefs.getString(prefKey));
}
static Future<void> save(ChatChromeStyle value) async {
current.value = value;
final prefs = await SharedPreferences.getInstance();
await prefs.setString(prefKey, _encode(value));
}
}