Phase 3 completed: Flutter MVP with live streaming and auto-refresh

This commit is contained in:
2026-03-18 11:07:21 +08:00
parent 1ca24b61a8
commit 8b0cdd4744
55 changed files with 3015 additions and 98 deletions

View File

@@ -0,0 +1,45 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import '../providers/settings_provider.dart';
class ApiService {
final SettingsProvider settings;
final String? token;
ApiService(this.settings, this.token);
Map<String, String> get _headers => {
'Content-Type': 'application/json',
if (token != null) 'Authorization': 'Bearer $token',
};
Future<http.Response> register(String username, String password) async {
return await http.post(
Uri.parse("${settings.baseUrl}/api/register"),
headers: _headers,
body: jsonEncode({"username": username, "password": password}),
);
}
Future<http.Response> login(String username, String password) async {
return await http.post(
Uri.parse("${settings.baseUrl}/api/login"),
headers: _headers,
body: jsonEncode({"username": username, "password": password}),
);
}
Future<http.Response> getMyRoom() async {
return await http.get(
Uri.parse("${settings.baseUrl}/api/room/my"),
headers: _headers,
);
}
Future<http.Response> getActiveRooms() async {
return await http.get(
Uri.parse("${settings.baseUrl}/api/rooms/active"),
headers: _headers,
);
}
}