Files
Hightube/frontend/lib/providers/settings_provider.dart
CGH0S7 a0c5e7590d feat: implement chat history, theme customization, and password management
- Added chat history persistence for active rooms with auto-cleanup on stream end.
- Overhauled Settings page with user profile, theme color picker, and password change.
- Added backend API for user password updates.
- Integrated flutter_launcher_icons and updated app icon to 'H' logo.
- Fixed 'Duplicate keys' bug in danmaku by using UniqueKey and filtering historical messages.
- Updated version to 1.0.0-beta3.5 and author info.
2026-03-25 11:48:39 +08:00

46 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
class SettingsProvider with ChangeNotifier {
// Default server address for local development.
// Using 10.0.2.2 for Android emulator or localhost for Desktop.
String _baseUrl = "http://localhost:8080";
Color _themeColor = Colors.blue;
String get baseUrl => _baseUrl;
Color get themeColor => _themeColor;
SettingsProvider() {
_loadSettings();
}
void _loadSettings() async {
final prefs = await SharedPreferences.getInstance();
_baseUrl = prefs.getString('baseUrl') ?? _baseUrl;
final colorValue = prefs.getInt('themeColor');
if (colorValue != null) {
_themeColor = Color(colorValue);
}
notifyListeners();
}
void setBaseUrl(String url) async {
_baseUrl = url;
final prefs = await SharedPreferences.getInstance();
await prefs.setString('baseUrl', url);
notifyListeners();
}
void setThemeColor(Color color) async {
_themeColor = color;
final prefs = await SharedPreferences.getInstance();
await prefs.setInt('themeColor', color.value);
notifyListeners();
}
// Also provide the RTMP URL based on the same hostname
String get rtmpUrl {
final uri = Uri.parse(_baseUrl);
return "rtmp://${uri.host}:1935/live";
}
}