mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-06 01:09:30 +00:00
Account: scrolling banner
This commit is contained in:
parent
2cd28c13f3
commit
ae9f78e737
2 changed files with 15 additions and 6 deletions
|
@ -11,6 +11,11 @@ struct AccountDetailHeaderView: View {
|
|||
let account: Account
|
||||
@Binding var relationship: Relationshionship?
|
||||
@Binding var following: Bool
|
||||
@Binding var scrollOffset: CGFloat
|
||||
|
||||
private var bannerHeight: CGFloat {
|
||||
200 + (scrollOffset > 0 ? scrollOffset * 2 : 0)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
|
@ -27,13 +32,13 @@ struct AccountDetailHeaderView: View {
|
|||
content: { image in
|
||||
image.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(height: 200)
|
||||
.frame(height: bannerHeight)
|
||||
.frame(width: proxy.frame(in: .local).width)
|
||||
.clipped()
|
||||
},
|
||||
placeholder: {
|
||||
Color.gray
|
||||
.frame(height: 200)
|
||||
.frame(height: bannerHeight)
|
||||
}
|
||||
)
|
||||
if relationship?.followedBy == true {
|
||||
|
@ -48,7 +53,8 @@ struct AccountDetailHeaderView: View {
|
|||
}
|
||||
.background(Color.gray)
|
||||
}
|
||||
.frame(height: 200)
|
||||
.frame(height: bannerHeight)
|
||||
.offset(y: scrollOffset > 0 ? -scrollOffset : 0)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
routeurPath.presentedSheet = .imageDetail(url: account.header)
|
||||
|
@ -135,6 +141,7 @@ struct AccountDetailHeaderView_Previews: PreviewProvider {
|
|||
AccountDetailHeaderView(isCurrentUser: false,
|
||||
account: .placeholder(),
|
||||
relationship: .constant(.placeholder()),
|
||||
following: .constant(true))
|
||||
following: .constant(true),
|
||||
scrollOffset: .constant(0))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,8 @@ public struct AccountDetailView: View {
|
|||
AccountDetailHeaderView(isCurrentUser: isCurrentUser,
|
||||
account: .placeholder(),
|
||||
relationship: .constant(.placeholder()),
|
||||
following: .constant(false))
|
||||
following: .constant(false),
|
||||
scrollOffset: $scrollOffset)
|
||||
.redacted(reason: .placeholder)
|
||||
case let .data(account):
|
||||
AccountDetailHeaderView(isCurrentUser: isCurrentUser,
|
||||
|
@ -99,7 +100,8 @@ public struct AccountDetailView: View {
|
|||
await viewModel.unfollow()
|
||||
}
|
||||
}
|
||||
}))
|
||||
}),
|
||||
scrollOffset: $scrollOffset)
|
||||
case let .error(error):
|
||||
Text("Error: \(error.localizedDescription)")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue