more refactors
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:immich_mobile/domain/models/store.model.dart';
|
||||
import 'package:immich_mobile/presentation/modules/theme/models/app_theme.model.dart';
|
||||
import 'package:immich_mobile/presentation/theme/app_theme.dart';
|
||||
|
||||
// AppSetting needs to store UI specific settings as well as domain specific settings
|
||||
// This model is the only exclusion which refers to entities from the presentation layer
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:immich_mobile/utils/collection_util.dart';
|
||||
import 'package:immich_mobile/utils/extensions/string.extension.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
enum AssetType {
|
||||
// do not change this order!
|
||||
@@ -49,19 +47,6 @@ class Asset {
|
||||
this.livePhotoVideoId,
|
||||
});
|
||||
|
||||
factory Asset.remote(AssetResponseDto dto) => Asset(
|
||||
remoteId: dto.id,
|
||||
createdTime: dto.fileCreatedAt,
|
||||
duration: dto.duration.tryParseInt() ?? 0,
|
||||
height: dto.exifInfo?.exifImageHeight?.toInt(),
|
||||
width: dto.exifInfo?.exifImageWidth?.toInt(),
|
||||
hash: dto.checksum,
|
||||
name: dto.originalFileName,
|
||||
livePhotoVideoId: dto.livePhotoVideoId,
|
||||
modifiedTime: dto.fileModifiedAt,
|
||||
type: _toAssetType(dto.type),
|
||||
);
|
||||
|
||||
Asset copyWith({
|
||||
int? id,
|
||||
String? name,
|
||||
@@ -177,10 +162,3 @@ class Asset {
|
||||
static int compareByLocalId(Asset a, Asset b) =>
|
||||
CollectionUtil.compareToNullable(a.localId, b.localId);
|
||||
}
|
||||
|
||||
AssetType _toAssetType(AssetTypeEnum type) => switch (type) {
|
||||
AssetTypeEnum.AUDIO => AssetType.audio,
|
||||
AssetTypeEnum.IMAGE => AssetType.image,
|
||||
AssetTypeEnum.VIDEO => AssetType.video,
|
||||
_ => AssetType.other,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
class ServerConfig {
|
||||
final String? oauthButtonText;
|
||||
|
||||
@@ -11,12 +9,7 @@ class ServerConfig {
|
||||
);
|
||||
}
|
||||
|
||||
factory ServerConfig.fromDto(ServerConfigDto dto) => ServerConfig(
|
||||
oauthButtonText:
|
||||
dto.oauthButtonText.isEmpty ? null : dto.oauthButtonText,
|
||||
);
|
||||
|
||||
const ServerConfig.reset() : oauthButtonText = null;
|
||||
const ServerConfig.initial() : oauthButtonText = null;
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
|
||||
@@ -17,9 +17,9 @@ class ServerFeatureConfig {
|
||||
);
|
||||
}
|
||||
|
||||
const ServerFeatureConfig.reset()
|
||||
: features = const ServerFeatures.reset(),
|
||||
config = const ServerConfig.reset();
|
||||
const ServerFeatureConfig.initial()
|
||||
: features = const ServerFeatures.initial(),
|
||||
config = const ServerConfig.initial();
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
class ServerFeatures {
|
||||
final bool hasPasswordLogin;
|
||||
final bool hasOAuthLogin;
|
||||
@@ -16,12 +14,7 @@ class ServerFeatures {
|
||||
);
|
||||
}
|
||||
|
||||
factory ServerFeatures.fromDto(ServerFeaturesDto dto) => ServerFeatures(
|
||||
hasPasswordLogin: dto.passwordLogin,
|
||||
hasOAuthLogin: dto.oauth,
|
||||
);
|
||||
|
||||
const ServerFeatures.reset()
|
||||
const ServerFeatures.initial()
|
||||
: hasPasswordLogin = true,
|
||||
hasOAuthLogin = false;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:immich_mobile/domain/interfaces/store.interface.dart';
|
||||
import 'package:immich_mobile/domain/models/user.model.dart';
|
||||
import 'package:immich_mobile/domain/utils/store_converters.dart';
|
||||
import 'package:immich_mobile/presentation/modules/theme/models/app_theme.model.dart';
|
||||
import 'package:immich_mobile/presentation/theme/app_theme.dart';
|
||||
|
||||
@immutable
|
||||
class StoreValue<T> {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:openapi/api.dart' as api;
|
||||
|
||||
class User {
|
||||
const User({
|
||||
required this.id,
|
||||
@@ -96,25 +94,6 @@ class User {
|
||||
memoryEnabled.hashCode ^
|
||||
avatarColor.hashCode;
|
||||
}
|
||||
|
||||
factory User.fromAdminDto(
|
||||
api.UserAdminResponseDto userDto, [
|
||||
api.UserPreferencesResponseDto? userPreferences,
|
||||
]) {
|
||||
return User(
|
||||
id: userDto.id,
|
||||
updatedAt: DateTime.now(),
|
||||
name: userDto.name,
|
||||
email: userDto.email,
|
||||
isAdmin: userDto.isAdmin,
|
||||
quotaSizeInBytes: userDto.quotaSizeInBytes ?? 0,
|
||||
quotaUsageInBytes: userDto.quotaUsageInBytes ?? 0,
|
||||
inTimeline: true,
|
||||
profileImagePath: userDto.profileImagePath,
|
||||
memoryEnabled: userPreferences?.memories.enabled ?? true,
|
||||
avatarColor: userDto.avatarColor.toEnum(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
enum UserAvatarColor {
|
||||
@@ -131,34 +110,6 @@ enum UserAvatarColor {
|
||||
amber,
|
||||
}
|
||||
|
||||
extension AvatarColorEnumHelper on api.UserAvatarColor {
|
||||
UserAvatarColor toEnum() {
|
||||
switch (this) {
|
||||
case api.UserAvatarColor.primary:
|
||||
return UserAvatarColor.primary;
|
||||
case api.UserAvatarColor.pink:
|
||||
return UserAvatarColor.pink;
|
||||
case api.UserAvatarColor.red:
|
||||
return UserAvatarColor.red;
|
||||
case api.UserAvatarColor.yellow:
|
||||
return UserAvatarColor.yellow;
|
||||
case api.UserAvatarColor.blue:
|
||||
return UserAvatarColor.blue;
|
||||
case api.UserAvatarColor.green:
|
||||
return UserAvatarColor.green;
|
||||
case api.UserAvatarColor.purple:
|
||||
return UserAvatarColor.purple;
|
||||
case api.UserAvatarColor.orange:
|
||||
return UserAvatarColor.orange;
|
||||
case api.UserAvatarColor.gray:
|
||||
return UserAvatarColor.gray;
|
||||
case api.UserAvatarColor.amber:
|
||||
return UserAvatarColor.amber;
|
||||
}
|
||||
return UserAvatarColor.primary;
|
||||
}
|
||||
}
|
||||
|
||||
extension AvatarColorToColorHelper on UserAvatarColor {
|
||||
Color toColor([bool isDarkTheme = false]) {
|
||||
switch (this) {
|
||||
|
||||
Reference in New Issue
Block a user