Handle pokes outside chat tabs

This commit is contained in:
Edison Jwa
2026-05-23 05:25:36 +09:00
parent 738b274748
commit 7e28791ec2
10 changed files with 2567 additions and 1347 deletions
@@ -0,0 +1,54 @@
import 'package:shared_preferences/shared_preferences.dart';
class UiSettings {
const UiSettings({
this.host = '',
this.nickname = '',
this.showPokeDialogs = true,
});
final String host;
final String nickname;
final bool showPokeDialogs;
}
class UiPreferencesService {
static const _hostKey = 'ui.host';
static const _nicknameKey = 'ui.nickname';
static const _showPokeDialogsKey = 'ui.show_poke_dialogs';
static const _permissionsExplainedKey = 'perms_explained';
const UiPreferencesService();
Future<UiSettings> loadSettings() async {
final prefs = await SharedPreferences.getInstance();
return UiSettings(
host: prefs.getString(_hostKey) ?? '',
nickname: prefs.getString(_nicknameKey) ?? '',
showPokeDialogs: prefs.getBool(_showPokeDialogsKey) ?? true,
);
}
Future<void> saveSettings({
String? host,
String? nickname,
bool? showPokeDialogs,
}) async {
final prefs = await SharedPreferences.getInstance();
if (host != null) await prefs.setString(_hostKey, host);
if (nickname != null) await prefs.setString(_nicknameKey, nickname);
if (showPokeDialogs != null) {
await prefs.setBool(_showPokeDialogsKey, showPokeDialogs);
}
}
Future<bool> hasExplainedPermissions() async {
final prefs = await SharedPreferences.getInstance();
return prefs.getBool(_permissionsExplainedKey) ?? false;
}
Future<void> markPermissionsExplained() async {
final prefs = await SharedPreferences.getInstance();
await prefs.setBool(_permissionsExplainedKey, true);
}
}