Skip to content

Commit

Permalink
using proper fallback avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
EricBAndrews committed Oct 3, 2023
1 parent 9329a64 commit 9906732
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions Mlem/Views/Tabs/Feeds/Components/Sidebar Header Avatar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,20 @@ struct SidebarHeaderAvatar: View {

@ViewBuilder
var avatar: some View {
if let avatarURL = imageUrl {
CachedImage(
url: avatarURL,
shouldExpand: false,
fixedSize: CGSize(width: AppConstants.hugeAvatarSize, height: AppConstants.hugeAvatarSize),
contentMode: .fill
)
} else {
VStack(alignment: .center) {
Image(systemName: imageName)
.font(.system(size: AppConstants.hugeAvatarSize)) // SF Symbols are apparently font
.foregroundStyle(Color.gray.gradient)
}
}
CachedImage(
url: imageUrl,
shouldExpand: false,
fixedSize: CGSize(width: AppConstants.hugeAvatarSize, height: AppConstants.hugeAvatarSize),
imageNotFound: fallbackAvatar,
contentMode: .fill
)
}

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

0 comments on commit 9906732

Please sign in to comment.