diff --git a/mobile/lib/shared/models/user.dart b/mobile/lib/shared/models/user.dart index d9d99836d..632f43b9e 100644 --- a/mobile/lib/shared/models/user.dart +++ b/mobile/lib/shared/models/user.dart @@ -47,6 +47,7 @@ class User { profileImagePath = dto.profileImagePath, isAdmin = dto.isAdmin, memoryEnabled = dto.memoriesEnabled, + avatarColor = dto.avatarColor.toAvatarColor(), inTimeline = dto.inTimeline; @Index(unique: true, replace: false, type: IndexType.hash) @@ -113,7 +114,7 @@ enum AvatarColorEnum { amber, } -extension AvatarColorEnumHelper on UserResponseDtoAvatarColorEnum { +extension UserResponseAvatarColorEnumHelper on UserResponseDtoAvatarColorEnum { AvatarColorEnum toAvatarColor() { switch (this) { case UserResponseDtoAvatarColorEnum.primary: @@ -141,6 +142,35 @@ extension AvatarColorEnumHelper on UserResponseDtoAvatarColorEnum { } } +extension PartnerResponseAvatarColorEnumHelper + on PartnerResponseDtoAvatarColorEnum { + AvatarColorEnum toAvatarColor() { + switch (this) { + case PartnerResponseDtoAvatarColorEnum.primary: + return AvatarColorEnum.primary; + case PartnerResponseDtoAvatarColorEnum.pink: + return AvatarColorEnum.pink; + case PartnerResponseDtoAvatarColorEnum.red: + return AvatarColorEnum.red; + case PartnerResponseDtoAvatarColorEnum.yellow: + return AvatarColorEnum.yellow; + case PartnerResponseDtoAvatarColorEnum.blue: + return AvatarColorEnum.blue; + case PartnerResponseDtoAvatarColorEnum.green: + return AvatarColorEnum.green; + case PartnerResponseDtoAvatarColorEnum.purple: + return AvatarColorEnum.purple; + case PartnerResponseDtoAvatarColorEnum.orange: + return AvatarColorEnum.orange; + case PartnerResponseDtoAvatarColorEnum.gray: + return AvatarColorEnum.gray; + case PartnerResponseDtoAvatarColorEnum.amber: + return AvatarColorEnum.amber; + } + return AvatarColorEnum.primary; + } +} + extension AvatarColorToColorHelper on AvatarColorEnum { Color toColor([bool isDarkTheme = false]) { switch (this) { diff --git a/mobile/lib/shared/ui/user_circle_avatar.dart b/mobile/lib/shared/ui/user_circle_avatar.dart index 3c3ab661c..e729eb8fe 100644 --- a/mobile/lib/shared/ui/user_circle_avatar.dart +++ b/mobile/lib/shared/ui/user_circle_avatar.dart @@ -3,7 +3,6 @@ import 'dart:math'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:immich_mobile/extensions/build_context_extensions.dart'; import 'package:immich_mobile/shared/models/store.dart'; import 'package:immich_mobile/shared/models/user.dart'; import 'package:immich_mobile/shared/ui/transparent_image.dart'; @@ -37,9 +36,7 @@ class UserCircleAvatar extends ConsumerWidget { ), ); return CircleAvatar( - backgroundColor: useRandomBackgroundColor - ? randomColors[Random().nextInt(randomColors.length)] - : context.primaryColor, + backgroundColor: user.avatarColor.toColor(), radius: radius, child: user.profileImagePath.isEmpty ? textIcon