Skip to content

Commit

Permalink
using AssociatedIcon, plus color tweaks to match inline avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
EricBAndrews committed Oct 3, 2023
1 parent c79f4af commit 8006a6d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
20 changes: 20 additions & 0 deletions Mlem/Enums/AvatarType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,23 @@ import Foundation
enum AvatarType {
case user, community
}

extension AvatarType: AssociatedIcon {
var iconName: String {
switch self {
case .user:
return Icons.user
case .community:
return Icons.community
}
}

var iconNameFill: String {
switch self {
case .user:
return Icons.userFill
case .community:
return Icons.communityFill
}
}
}
12 changes: 2 additions & 10 deletions Mlem/Views/Tabs/Feeds/Components/Sidebar Header Avatar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ struct SidebarHeaderAvatar: View {
@State var shouldClipAvatar: Bool = false
@State var imageUrl: URL?
let avatarType: AvatarType

var imageName: String {
switch avatarType {
case .user:
return Icons.user
case .community:
return Icons.community
}
}

var body: some View {
avatar
Expand All @@ -47,8 +38,9 @@ struct SidebarHeaderAvatar: View {

func fallbackAvatar() -> AnyView {
AnyView(
Image(systemName: imageName)
Image(systemName: avatarType.iconNameFill)
.font(.system(size: AppConstants.hugeAvatarSize)) // SF Symbols are apparently font
.background(.white)
.foregroundStyle(Color.gray.gradient)
)
}
Expand Down

0 comments on commit 8006a6d

Please sign in to comment.