refactor(apps): 主题系统迁移至 ColorScheme + 扩展架构并支持 Dark Mode
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
class UserResponse {
|
||||
final String id;
|
||||
final String username;
|
||||
final String? phone;
|
||||
final String? avatarUrl;
|
||||
final String? bio;
|
||||
|
||||
const UserResponse({
|
||||
required this.id,
|
||||
required this.username,
|
||||
this.phone,
|
||||
this.avatarUrl,
|
||||
this.bio,
|
||||
});
|
||||
|
||||
factory UserResponse.fromJson(Map<String, dynamic> json) {
|
||||
return UserResponse(
|
||||
id: json['id'] as String,
|
||||
username: json['username'] as String,
|
||||
phone: json['phone'] as String?,
|
||||
avatarUrl: json['avatar_url'] as String?,
|
||||
bio: json['bio'] as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class UserUpdateRequest {
|
||||
final String? username;
|
||||
final String? avatarUrl;
|
||||
final String? bio;
|
||||
|
||||
const UserUpdateRequest({this.username, this.avatarUrl, this.bio});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
if (username != null) 'username': username,
|
||||
if (avatarUrl != null) 'avatar_url': avatarUrl,
|
||||
if (bio != null) 'bio': bio,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:io';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:social_app/core/network/i_api_client.dart';
|
||||
import 'models/user_response.dart';
|
||||
import 'package:social_app/data/models/user_profile.dart';
|
||||
|
||||
class UserBasicInfo {
|
||||
final String id;
|
||||
@@ -30,14 +30,14 @@ class UsersApi {
|
||||
return UserBasicInfo.fromJson(response.data);
|
||||
}
|
||||
|
||||
Future<UserResponse> getMe() async {
|
||||
Future<UserProfile> getMe() async {
|
||||
final response = await _client.get('$_prefix/me');
|
||||
return UserResponse.fromJson(response.data);
|
||||
return UserProfile.fromJson(response.data);
|
||||
}
|
||||
|
||||
Future<UserResponse> updateMe(UserUpdateRequest request) async {
|
||||
Future<UserProfile> updateMe(UserUpdateRequest request) async {
|
||||
final response = await _client.patch('$_prefix/me', data: request.toJson());
|
||||
return UserResponse.fromJson(response.data);
|
||||
return UserProfile.fromJson(response.data);
|
||||
}
|
||||
|
||||
Future<String> uploadAvatar(File file) async {
|
||||
@@ -62,12 +62,12 @@ class UsersApi {
|
||||
return url;
|
||||
}
|
||||
|
||||
Future<List<UserResponse>> searchUsers(String query) async {
|
||||
Future<List<UserProfile>> searchUsers(String query) async {
|
||||
final response = await _client.post(
|
||||
'$_prefix/search',
|
||||
data: {'query': query},
|
||||
);
|
||||
final List<dynamic> data = response.data;
|
||||
return data.map((json) => UserResponse.fromJson(json)).toList();
|
||||
return data.map((json) => UserProfile.fromJson(json)).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'models/user_response.dart';
|
||||
import '../../../../data/models/user_profile.dart';
|
||||
|
||||
abstract class UsersRepository {
|
||||
Future<UserResponse> getMe();
|
||||
Future<UserResponse> updateMe(UserUpdateRequest request);
|
||||
Future<List<UserResponse>> searchUsers(String query);
|
||||
Future<UserProfile> getMe();
|
||||
Future<UserProfile> updateMe(UserUpdateRequest request);
|
||||
Future<List<UserProfile>> searchUsers(String query);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'users_api.dart';
|
||||
import 'users_repository.dart';
|
||||
import 'models/user_response.dart';
|
||||
import '../../../../data/models/user_profile.dart';
|
||||
|
||||
class UsersRepositoryImpl implements UsersRepository {
|
||||
final UsersApi _api;
|
||||
@@ -8,17 +8,17 @@ class UsersRepositoryImpl implements UsersRepository {
|
||||
UsersRepositoryImpl({required UsersApi api}) : _api = api;
|
||||
|
||||
@override
|
||||
Future<UserResponse> getMe() {
|
||||
Future<UserProfile> getMe() {
|
||||
return _api.getMe();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<UserResponse> updateMe(UserUpdateRequest request) {
|
||||
Future<UserProfile> updateMe(UserUpdateRequest request) {
|
||||
return _api.updateMe(request);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<UserResponse>> searchUsers(String query) {
|
||||
Future<List<UserProfile>> searchUsers(String query) {
|
||||
return _api.searchUsers(query);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user