feat(profile): 实现个人资料编辑与策略本地缓存
- 将资料编辑页重构为可交互表单,支持昵称、签名编辑与头像更换 - 新增 DioClient 本地缓存读取与写入方法,支持离线读取策略快照 - 设备策略切换后自动使本地缓存失效,避免数据不一致 - Home Tab 切换时选中态跟随可见页面,滑动过程中实时更新底栏高亮 - 系统设置页引入 loading 遮罩层,防止切换开关时重复操作 - 个人资料页接入 profileController 展示真实用户信息与加载状态 - 适配深色模式,修正 home_tab 中头像与文字颜色硬编码问题
This commit is contained in:
1 parent
5f84a64c3e
commit
e06e12fbbc
30 files changed
+2059
-336
No files matched your search
@@ -0,0 +1,53 @@
|
||||
// Freezed forwards factory parameter annotations to generated fields.
|
||||
// ignore_for_file: invalid_annotation_target
|
||||
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'profile_models.freezed.dart';
|
||||
part 'profile_models.g.dart';
|
||||
|
||||
@freezed
|
||||
class UserProfile with _$UserProfile {
|
||||
const UserProfile._();
|
||||
|
||||
const factory UserProfile({
|
||||
@JsonKey(fromJson: _idToString) required String id,
|
||||
@Default('') String username,
|
||||
@Default('') String nickname,
|
||||
@Default('') String signature,
|
||||
String? avatar,
|
||||
}) = _UserProfile;
|
||||
|
||||
factory UserProfile.fromJson(Map<String, dynamic> json) =>
|
||||
_$UserProfileFromJson(json);
|
||||
|
||||
String get displayName => nickname.isNotEmpty ? nickname : username;
|
||||
}
|
||||
|
||||
String _idToString(Object? value) => value?.toString() ?? '';
|
||||
|
||||
enum ProfileIssue {
|
||||
nicknameInvalid,
|
||||
signatureInvalid,
|
||||
avatarTooLarge,
|
||||
avatarUnsupported,
|
||||
}
|
||||
|
||||
class ProfileInputException implements Exception {
|
||||
const ProfileInputException(this.issue);
|
||||
final ProfileIssue issue;
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ProfileState with _$ProfileState {
|
||||
const factory ProfileState({
|
||||
UserProfile? profile,
|
||||
@Default(true) bool loading,
|
||||
@Default(false) bool saving,
|
||||
String? alert,
|
||||
ProfileIssue? issue,
|
||||
}) = _ProfileState;
|
||||
|
||||
factory ProfileState.fromJson(Map<String, dynamic> json) =>
|
||||
_$ProfileStateFromJson(json);
|
||||
}
|
||||
@@ -0,0 +1,535 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'profile_models.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
||||
);
|
||||
|
||||
UserProfile _$UserProfileFromJson(Map<String, dynamic> json) {
|
||||
return _UserProfile.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$UserProfile {
|
||||
@JsonKey(fromJson: _idToString)
|
||||
String get id => throw _privateConstructorUsedError;
|
||||
String get username => throw _privateConstructorUsedError;
|
||||
String get nickname => throw _privateConstructorUsedError;
|
||||
String get signature => throw _privateConstructorUsedError;
|
||||
String? get avatar => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this UserProfile to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of UserProfile
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$UserProfileCopyWith<UserProfile> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $UserProfileCopyWith<$Res> {
|
||||
factory $UserProfileCopyWith(
|
||||
UserProfile value,
|
||||
$Res Function(UserProfile) then,
|
||||
) = _$UserProfileCopyWithImpl<$Res, UserProfile>;
|
||||
@useResult
|
||||
$Res call({
|
||||
@JsonKey(fromJson: _idToString) String id,
|
||||
String username,
|
||||
String nickname,
|
||||
String signature,
|
||||
String? avatar,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$UserProfileCopyWithImpl<$Res, $Val extends UserProfile>
|
||||
implements $UserProfileCopyWith<$Res> {
|
||||
_$UserProfileCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of UserProfile
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? username = null,
|
||||
Object? nickname = null,
|
||||
Object? signature = null,
|
||||
Object? avatar = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
username: null == username
|
||||
? _value.username
|
||||
: username // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
nickname: null == nickname
|
||||
? _value.nickname
|
||||
: nickname // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
signature: null == signature
|
||||
? _value.signature
|
||||
: signature // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
avatar: freezed == avatar
|
||||
? _value.avatar
|
||||
: avatar // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$UserProfileImplCopyWith<$Res>
|
||||
implements $UserProfileCopyWith<$Res> {
|
||||
factory _$$UserProfileImplCopyWith(
|
||||
_$UserProfileImpl value,
|
||||
$Res Function(_$UserProfileImpl) then,
|
||||
) = __$$UserProfileImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
@JsonKey(fromJson: _idToString) String id,
|
||||
String username,
|
||||
String nickname,
|
||||
String signature,
|
||||
String? avatar,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$UserProfileImplCopyWithImpl<$Res>
|
||||
extends _$UserProfileCopyWithImpl<$Res, _$UserProfileImpl>
|
||||
implements _$$UserProfileImplCopyWith<$Res> {
|
||||
__$$UserProfileImplCopyWithImpl(
|
||||
_$UserProfileImpl _value,
|
||||
$Res Function(_$UserProfileImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of UserProfile
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? username = null,
|
||||
Object? nickname = null,
|
||||
Object? signature = null,
|
||||
Object? avatar = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_$UserProfileImpl(
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
username: null == username
|
||||
? _value.username
|
||||
: username // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
nickname: null == nickname
|
||||
? _value.nickname
|
||||
: nickname // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
signature: null == signature
|
||||
? _value.signature
|
||||
: signature // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
avatar: freezed == avatar
|
||||
? _value.avatar
|
||||
: avatar // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$UserProfileImpl extends _UserProfile {
|
||||
const _$UserProfileImpl({
|
||||
@JsonKey(fromJson: _idToString) required this.id,
|
||||
this.username = '',
|
||||
this.nickname = '',
|
||||
this.signature = '',
|
||||
this.avatar,
|
||||
}) : super._();
|
||||
|
||||
factory _$UserProfileImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$UserProfileImplFromJson(json);
|
||||
|
||||
@override
|
||||
@JsonKey(fromJson: _idToString)
|
||||
final String id;
|
||||
@override
|
||||
@JsonKey()
|
||||
final String username;
|
||||
@override
|
||||
@JsonKey()
|
||||
final String nickname;
|
||||
@override
|
||||
@JsonKey()
|
||||
final String signature;
|
||||
@override
|
||||
final String? avatar;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UserProfile(id: $id, username: $username, nickname: $nickname, signature: $signature, avatar: $avatar)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$UserProfileImpl &&
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.username, username) ||
|
||||
other.username == username) &&
|
||||
(identical(other.nickname, nickname) ||
|
||||
other.nickname == nickname) &&
|
||||
(identical(other.signature, signature) ||
|
||||
other.signature == signature) &&
|
||||
(identical(other.avatar, avatar) || other.avatar == avatar));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, id, username, nickname, signature, avatar);
|
||||
|
||||
/// Create a copy of UserProfile
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$UserProfileImplCopyWith<_$UserProfileImpl> get copyWith =>
|
||||
__$$UserProfileImplCopyWithImpl<_$UserProfileImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$UserProfileImplToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _UserProfile extends UserProfile {
|
||||
const factory _UserProfile({
|
||||
@JsonKey(fromJson: _idToString) required final String id,
|
||||
final String username,
|
||||
final String nickname,
|
||||
final String signature,
|
||||
final String? avatar,
|
||||
}) = _$UserProfileImpl;
|
||||
const _UserProfile._() : super._();
|
||||
|
||||
factory _UserProfile.fromJson(Map<String, dynamic> json) =
|
||||
_$UserProfileImpl.fromJson;
|
||||
|
||||
@override
|
||||
@JsonKey(fromJson: _idToString)
|
||||
String get id;
|
||||
@override
|
||||
String get username;
|
||||
@override
|
||||
String get nickname;
|
||||
@override
|
||||
String get signature;
|
||||
@override
|
||||
String? get avatar;
|
||||
|
||||
/// Create a copy of UserProfile
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$UserProfileImplCopyWith<_$UserProfileImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
ProfileState _$ProfileStateFromJson(Map<String, dynamic> json) {
|
||||
return _ProfileState.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ProfileState {
|
||||
UserProfile? get profile => throw _privateConstructorUsedError;
|
||||
bool get loading => throw _privateConstructorUsedError;
|
||||
bool get saving => throw _privateConstructorUsedError;
|
||||
String? get alert => throw _privateConstructorUsedError;
|
||||
ProfileIssue? get issue => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this ProfileState to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of ProfileState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$ProfileStateCopyWith<ProfileState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ProfileStateCopyWith<$Res> {
|
||||
factory $ProfileStateCopyWith(
|
||||
ProfileState value,
|
||||
$Res Function(ProfileState) then,
|
||||
) = _$ProfileStateCopyWithImpl<$Res, ProfileState>;
|
||||
@useResult
|
||||
$Res call({
|
||||
UserProfile? profile,
|
||||
bool loading,
|
||||
bool saving,
|
||||
String? alert,
|
||||
ProfileIssue? issue,
|
||||
});
|
||||
|
||||
$UserProfileCopyWith<$Res>? get profile;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ProfileStateCopyWithImpl<$Res, $Val extends ProfileState>
|
||||
implements $ProfileStateCopyWith<$Res> {
|
||||
_$ProfileStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of ProfileState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? profile = freezed,
|
||||
Object? loading = null,
|
||||
Object? saving = null,
|
||||
Object? alert = freezed,
|
||||
Object? issue = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
profile: freezed == profile
|
||||
? _value.profile
|
||||
: profile // ignore: cast_nullable_to_non_nullable
|
||||
as UserProfile?,
|
||||
loading: null == loading
|
||||
? _value.loading
|
||||
: loading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
saving: null == saving
|
||||
? _value.saving
|
||||
: saving // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
alert: freezed == alert
|
||||
? _value.alert
|
||||
: alert // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
issue: freezed == issue
|
||||
? _value.issue
|
||||
: issue // ignore: cast_nullable_to_non_nullable
|
||||
as ProfileIssue?,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of ProfileState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$UserProfileCopyWith<$Res>? get profile {
|
||||
if (_value.profile == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $UserProfileCopyWith<$Res>(_value.profile!, (value) {
|
||||
return _then(_value.copyWith(profile: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ProfileStateImplCopyWith<$Res>
|
||||
implements $ProfileStateCopyWith<$Res> {
|
||||
factory _$$ProfileStateImplCopyWith(
|
||||
_$ProfileStateImpl value,
|
||||
$Res Function(_$ProfileStateImpl) then,
|
||||
) = __$$ProfileStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
UserProfile? profile,
|
||||
bool loading,
|
||||
bool saving,
|
||||
String? alert,
|
||||
ProfileIssue? issue,
|
||||
});
|
||||
|
||||
@override
|
||||
$UserProfileCopyWith<$Res>? get profile;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ProfileStateImplCopyWithImpl<$Res>
|
||||
extends _$ProfileStateCopyWithImpl<$Res, _$ProfileStateImpl>
|
||||
implements _$$ProfileStateImplCopyWith<$Res> {
|
||||
__$$ProfileStateImplCopyWithImpl(
|
||||
_$ProfileStateImpl _value,
|
||||
$Res Function(_$ProfileStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of ProfileState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? profile = freezed,
|
||||
Object? loading = null,
|
||||
Object? saving = null,
|
||||
Object? alert = freezed,
|
||||
Object? issue = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_$ProfileStateImpl(
|
||||
profile: freezed == profile
|
||||
? _value.profile
|
||||
: profile // ignore: cast_nullable_to_non_nullable
|
||||
as UserProfile?,
|
||||
loading: null == loading
|
||||
? _value.loading
|
||||
: loading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
saving: null == saving
|
||||
? _value.saving
|
||||
: saving // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
alert: freezed == alert
|
||||
? _value.alert
|
||||
: alert // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
issue: freezed == issue
|
||||
? _value.issue
|
||||
: issue // ignore: cast_nullable_to_non_nullable
|
||||
as ProfileIssue?,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$ProfileStateImpl implements _ProfileState {
|
||||
const _$ProfileStateImpl({
|
||||
this.profile,
|
||||
this.loading = true,
|
||||
this.saving = false,
|
||||
this.alert,
|
||||
this.issue,
|
||||
});
|
||||
|
||||
factory _$ProfileStateImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$ProfileStateImplFromJson(json);
|
||||
|
||||
@override
|
||||
final UserProfile? profile;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool loading;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool saving;
|
||||
@override
|
||||
final String? alert;
|
||||
@override
|
||||
final ProfileIssue? issue;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProfileState(profile: $profile, loading: $loading, saving: $saving, alert: $alert, issue: $issue)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ProfileStateImpl &&
|
||||
(identical(other.profile, profile) || other.profile == profile) &&
|
||||
(identical(other.loading, loading) || other.loading == loading) &&
|
||||
(identical(other.saving, saving) || other.saving == saving) &&
|
||||
(identical(other.alert, alert) || other.alert == alert) &&
|
||||
(identical(other.issue, issue) || other.issue == issue));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, profile, loading, saving, alert, issue);
|
||||
|
||||
/// Create a copy of ProfileState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ProfileStateImplCopyWith<_$ProfileStateImpl> get copyWith =>
|
||||
__$$ProfileStateImplCopyWithImpl<_$ProfileStateImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$ProfileStateImplToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _ProfileState implements ProfileState {
|
||||
const factory _ProfileState({
|
||||
final UserProfile? profile,
|
||||
final bool loading,
|
||||
final bool saving,
|
||||
final String? alert,
|
||||
final ProfileIssue? issue,
|
||||
}) = _$ProfileStateImpl;
|
||||
|
||||
factory _ProfileState.fromJson(Map<String, dynamic> json) =
|
||||
_$ProfileStateImpl.fromJson;
|
||||
|
||||
@override
|
||||
UserProfile? get profile;
|
||||
@override
|
||||
bool get loading;
|
||||
@override
|
||||
bool get saving;
|
||||
@override
|
||||
String? get alert;
|
||||
@override
|
||||
ProfileIssue? get issue;
|
||||
|
||||
/// Create a copy of ProfileState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ProfileStateImplCopyWith<_$ProfileStateImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'profile_models.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$UserProfileImpl _$$UserProfileImplFromJson(Map<String, dynamic> json) =>
|
||||
_$UserProfileImpl(
|
||||
id: _idToString(json['id']),
|
||||
username: json['username'] as String? ?? '',
|
||||
nickname: json['nickname'] as String? ?? '',
|
||||
signature: json['signature'] as String? ?? '',
|
||||
avatar: json['avatar'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$UserProfileImplToJson(_$UserProfileImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'username': instance.username,
|
||||
'nickname': instance.nickname,
|
||||
'signature': instance.signature,
|
||||
'avatar': instance.avatar,
|
||||
};
|
||||
|
||||
_$ProfileStateImpl _$$ProfileStateImplFromJson(Map<String, dynamic> json) =>
|
||||
_$ProfileStateImpl(
|
||||
profile: json['profile'] == null
|
||||
? null
|
||||
: UserProfile.fromJson(json['profile'] as Map<String, dynamic>),
|
||||
loading: json['loading'] as bool? ?? true,
|
||||
saving: json['saving'] as bool? ?? false,
|
||||
alert: json['alert'] as String?,
|
||||
issue: $enumDecodeNullable(_$ProfileIssueEnumMap, json['issue']),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ProfileStateImplToJson(_$ProfileStateImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'profile': instance.profile,
|
||||
'loading': instance.loading,
|
||||
'saving': instance.saving,
|
||||
'alert': instance.alert,
|
||||
'issue': _$ProfileIssueEnumMap[instance.issue],
|
||||
};
|
||||
|
||||
const _$ProfileIssueEnumMap = {
|
||||
ProfileIssue.nicknameInvalid: 'nicknameInvalid',
|
||||
ProfileIssue.signatureInvalid: 'signatureInvalid',
|
||||
ProfileIssue.avatarTooLarge: 'avatarTooLarge',
|
||||
ProfileIssue.avatarUnsupported: 'avatarUnsupported',
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
import 'profile_models.dart';
|
||||
|
||||
abstract class ProfileRepository {
|
||||
Future<UserProfile> load();
|
||||
Future<UserProfile> save(String nickname, String signature);
|
||||
Future<UserProfile?> chooseAvatar();
|
||||
}
|
||||
Reference in new issue
Block a user