mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-15 19:28:16 +02:00
feat: implement IPTV settings management with streaming and display preferences
This commit is contained in:
1 parent
62fc19598a
commit
63846c090a
8 files changed
+265
-10
No files matched your search
@@ -0,0 +1,51 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:html' as html;
|
||||
import '../models/app_user.dart';
|
||||
|
||||
class SettingsApiService {
|
||||
final String _baseUrl = html.window.location.origin;
|
||||
|
||||
Future<Map<String, dynamic>?> getSettings() async {
|
||||
final token = html.window.localStorage['auth_token'];
|
||||
if (token == null) return null;
|
||||
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse('$_baseUrl/api/settings'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
if (response.body.isEmpty) return {};
|
||||
return jsonDecode(response.body) as Map<String, dynamic>;
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> saveSettings(Map<String, dynamic> settings) async {
|
||||
final token = html.window.localStorage['auth_token'];
|
||||
if (token == null) return false;
|
||||
|
||||
try {
|
||||
final response = await http.post(
|
||||
Uri.parse('$_baseUrl/api/settings'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: jsonEncode(settings),
|
||||
);
|
||||
|
||||
return response.statusCode == 200;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user