Skip to content

Commit

Permalink
Scroll to top
Browse files Browse the repository at this point in the history
  • Loading branch information
kugel3 committed Aug 22, 2024
1 parent a7fccd1 commit 609ec5a
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions RadixWallet/Features/AppFeature/Overlay/Sheet+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,38 @@ extension Sheet {
}
.padding(.horizontal, .small3)

ScrollView {
VStack(spacing: .zero) {
if let image = viewStore.image {
Image(asset: image)
.resizable()
.frame(.veryLarge)
.padding(.bottom, .medium2)
ScrollViewReader { proxy in
ScrollView {
VStack(spacing: .zero) {
if let image = viewStore.image {
Image(asset: image)
.resizable()
.frame(.veryLarge)
.padding(.bottom, .medium2)
}

ForEach(viewStore.parts, id: \.self) { part in
PartView(part: part)
}
.environment(\.openURL, openURL)
.padding(.horizontal, .large2)
}

ForEach(viewStore.parts, id: \.self) { part in
PartView(part: part)
.padding(.top, .small2)
.id(scrollViewTopID)
}
.animation(.default, value: viewStore.text)
.onChange(of: viewStore.text) { _ in
withAnimation {
proxy.scrollTo(scrollViewTopID, anchor: .top)
}
.environment(\.openURL, openURL)
.padding(.horizontal, .large2)
}
.padding(.top, .small2)
}
.animation(.default, value: viewStore.text)
}
}
}

private let scrollViewTopID = "scrollViewTopID"

private var openURL: OpenURLAction {
OpenURLAction { url in
if let infoLink = OverlayWindowClient.GlossaryItem(url: url) {
Expand Down

0 comments on commit 609ec5a

Please sign in to comment.