mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-02-19 19:16:16 +00:00
Better profile header (#526)
* Prevent opening quicklook for missing avatar or header. Fixes #127 * Using theme for missing header background in profile * fix --------- Co-authored-by: Thomas Ricouard <ricouard77@gmail.com>
This commit is contained in:
parent
d9546d92d9
commit
c6c066564d
2 changed files with 19 additions and 5 deletions
|
@ -38,20 +38,20 @@ struct AccountDetailHeaderView: View {
|
||||||
ZStack(alignment: .bottomTrailing) {
|
ZStack(alignment: .bottomTrailing) {
|
||||||
if reasons.contains(.placeholder) {
|
if reasons.contains(.placeholder) {
|
||||||
Rectangle()
|
Rectangle()
|
||||||
.foregroundColor(.gray)
|
.foregroundColor(theme.secondaryBackgroundColor)
|
||||||
.frame(height: bannerHeight)
|
.frame(height: bannerHeight)
|
||||||
} else {
|
} else {
|
||||||
LazyImage(url: account.header) { state in
|
LazyImage(url: account.header) { state in
|
||||||
if let image = state.image {
|
if let image = state.image {
|
||||||
image
|
image
|
||||||
.resizingMode(.aspectFill)
|
.resizingMode(.aspectFill)
|
||||||
.overlay(.black.opacity(0.50))
|
.overlay(account.haveHeader ? .black.opacity(0.50) : .clear)
|
||||||
} else if state.isLoading {
|
} else if state.isLoading {
|
||||||
Color.gray
|
theme.secondaryBackgroundColor
|
||||||
.frame(height: bannerHeight)
|
.frame(height: bannerHeight)
|
||||||
.shimmering()
|
.shimmering()
|
||||||
} else {
|
} else {
|
||||||
Color.gray
|
theme.secondaryBackgroundColor
|
||||||
.frame(height: bannerHeight)
|
.frame(height: bannerHeight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,11 +68,14 @@ struct AccountDetailHeaderView: View {
|
||||||
.padding(8)
|
.padding(8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.background(Color.gray)
|
.background(theme.secondaryBackgroundColor)
|
||||||
.frame(height: bannerHeight)
|
.frame(height: bannerHeight)
|
||||||
.offset(y: scrollOffset > 0 ? -scrollOffset : 0)
|
.offset(y: scrollOffset > 0 ? -scrollOffset : 0)
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
|
guard account.haveHeader else {
|
||||||
|
return
|
||||||
|
}
|
||||||
Task {
|
Task {
|
||||||
await quickLook.prepareFor(urls: [account.header], selectedURL: account.header)
|
await quickLook.prepareFor(urls: [account.header], selectedURL: account.header)
|
||||||
}
|
}
|
||||||
|
@ -83,6 +86,9 @@ struct AccountDetailHeaderView: View {
|
||||||
HStack {
|
HStack {
|
||||||
AvatarView(url: account.avatar, size: .account)
|
AvatarView(url: account.avatar, size: .account)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
|
guard account.haveAvatar else {
|
||||||
|
return
|
||||||
|
}
|
||||||
Task {
|
Task {
|
||||||
await quickLook.prepareFor(urls: [account.avatar], selectedURL: account.avatar)
|
await quickLook.prepareFor(urls: [account.avatar], selectedURL: account.avatar)
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,14 @@ public struct Account: Decodable, Identifiable, Equatable, Hashable {
|
||||||
public let bot: Bool
|
public let bot: Bool
|
||||||
public let discoverable: Bool?
|
public let discoverable: Bool?
|
||||||
|
|
||||||
|
public var haveAvatar: Bool {
|
||||||
|
return avatar.lastPathComponent != "missing.png"
|
||||||
|
}
|
||||||
|
|
||||||
|
public var haveHeader: Bool {
|
||||||
|
return header.lastPathComponent != "missing.png"
|
||||||
|
}
|
||||||
|
|
||||||
public static func placeholder() -> Account {
|
public static func placeholder() -> Account {
|
||||||
.init(id: UUID().uuidString,
|
.init(id: UUID().uuidString,
|
||||||
username: "Username",
|
username: "Username",
|
||||||
|
|
Loading…
Reference in a new issue