d6956395c8
Rename the whole project from CommGate to gsmnode and re-skin every surface onto the new signal-green + ink design system (Space Grotesk / IBM Plex Sans / JetBrains Mono, flat surfaces, two-arrow routing mark, lowercase gsm+node wordmark). - Web App + API panel: rewrite token layer, gn-* utilities, data-gsm-theme, new logo/favicon assets; both builds verified. - Phone App (Flutter): green theme, new mark/wordmark widgets, adaptive launcher icons; rename Android applicationId/package to app.gsmnode.phone; bump AGP to 8.6.0 and google_fonts to 8.1.0; debug APK build verified. - API Server (Go): panel routes, User-Agent, health service id, branding. - Home Assistant Plugin: rename integration domain sms_gateway to gsmnode (folder, DOMAIN, services, entity ids, classes); py_compile verified. - Update all READMEs; add .gitignore (excludes Design/, build artifacts). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
55 lines
1.7 KiB
Dart
55 lines
1.7 KiB
Dart
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
/// Persists connection settings and credentials across app launches.
|
|
class Storage {
|
|
static const _kApiBase = 'api_base';
|
|
static const _kJwt = 'jwt';
|
|
static const _kDeviceToken = 'device_token';
|
|
static const _kDeviceId = 'device_id';
|
|
static const _kDeviceName = 'device_name';
|
|
static const _kUserEmail = 'user_email';
|
|
|
|
final SharedPreferences _prefs;
|
|
Storage(this._prefs);
|
|
|
|
static Future<Storage> create() async {
|
|
return Storage(await SharedPreferences.getInstance());
|
|
}
|
|
|
|
String? get apiBase => _prefs.getString(_kApiBase);
|
|
set apiBase(String? v) => _set(_kApiBase, v);
|
|
|
|
String? get jwt => _prefs.getString(_kJwt);
|
|
set jwt(String? v) => _set(_kJwt, v);
|
|
|
|
String? get deviceToken => _prefs.getString(_kDeviceToken);
|
|
set deviceToken(String? v) => _set(_kDeviceToken, v);
|
|
|
|
String? get deviceId => _prefs.getString(_kDeviceId);
|
|
set deviceId(String? v) => _set(_kDeviceId, v);
|
|
|
|
String? get deviceName => _prefs.getString(_kDeviceName);
|
|
set deviceName(String? v) => _set(_kDeviceName, v);
|
|
|
|
String? get userEmail => _prefs.getString(_kUserEmail);
|
|
set userEmail(String? v) => _set(_kUserEmail, v);
|
|
|
|
bool get isRegistered => (deviceToken ?? '').isNotEmpty;
|
|
|
|
Future<void> clearSession() async {
|
|
await _prefs.remove(_kJwt);
|
|
await _prefs.remove(_kDeviceToken);
|
|
await _prefs.remove(_kUserEmail);
|
|
// Keep device_id stable across logout so re-registering updates the same
|
|
// device record instead of creating a new (phantom) one.
|
|
}
|
|
|
|
void _set(String key, String? v) {
|
|
if (v == null) {
|
|
_prefs.remove(key);
|
|
} else {
|
|
_prefs.setString(key, v);
|
|
}
|
|
}
|
|
}
|