Skip to content

Commit 51669a3

Browse files
authored
AboutView Animation Improvements (#1915)
1 parent d92b5d9 commit 51669a3

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

CodeEdit/Features/About/Acknowledgements/Views/AcknowledgementsView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct AcknowledgementsView: View {
1414

1515
var body: some View {
1616
AboutDetailView(title: "Acknowledgements", aboutMode: $aboutMode, namespace: namespace) {
17-
VStack(spacing: 0) {
17+
LazyVStack(spacing: 0) {
1818
ForEach(
1919
model.indexedAcknowledgements,
2020
id: \.acknowledgement.name

CodeEdit/Features/About/Contributors/ContributorsView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct ContributorsView: View {
1414

1515
var body: some View {
1616
AboutDetailView(title: "Contributors", aboutMode: $aboutMode, namespace: namespace) {
17-
VStack(spacing: 0) {
17+
LazyVStack(spacing: 0) {
1818
ForEach(model.contributors) { contributor in
1919
ContributorRowView(contributor: contributor)
2020
Divider()

CodeEdit/Features/About/Views/AboutDefaultView.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ struct AboutDefaultView: View {
4444
VStack(spacing: 0) {
4545
Text("CodeEdit")
4646
.matchedGeometryEffect(id: "Title", in: namespace, properties: .position, anchor: .center)
47+
.blur(radius: aboutMode == .about ? 0 : 10)
4748
.foregroundColor(.primary)
4849
.font(.system(
4950
size: 26,
@@ -61,6 +62,8 @@ struct AboutDefaultView: View {
6162
properties: .position,
6263
anchor: UnitPoint(x: 0.5, y: -0.75)
6364
)
65+
.blur(radius: aboutMode == .about ? 0 : 10)
66+
.opacity(aboutMode == .about ? 1 : 0)
6467
}
6568
.padding(.horizontal)
6669
}
@@ -106,6 +109,8 @@ struct AboutDefaultView: View {
106109
}
107110
.matchedGeometryEffect(id: "Titlebar", in: namespace, properties: .position, anchor: .top)
108111
.matchedGeometryEffect(id: "ScrollView", in: namespace, properties: .position, anchor: .top)
112+
.blur(radius: aboutMode == .about ? 0 : 10)
113+
.opacity(aboutMode == .about ? 1 : 0)
109114
}
110115
.padding(.horizontal)
111116
}

CodeEdit/Features/About/Views/AboutDetailView.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ struct AboutDetailView<Content: View>: View {
4646
}
4747
.frame(maxWidth: .infinity)
4848
.matchedGeometryEffect(id: "ScrollView", in: namespace, properties: .position, anchor: .top)
49+
.blur(radius: aboutMode != .about ? 0 : 10)
50+
.opacity(aboutMode != .about ? 1 : 0)
4951
.clipShape(Rectangle())
5052
}
5153

@@ -113,6 +115,8 @@ struct AboutDetailView<Content: View>: View {
113115
}
114116
.contentShape(Rectangle())
115117
.matchedGeometryEffect(id: "Title", in: namespace, properties: .position, anchor: .center)
118+
.blur(radius: aboutMode != .about ? 0 : 10)
119+
.opacity(aboutMode != .about ? 1 : 0)
116120
}
117121
.buttonStyle(.plain)
118122

@@ -135,9 +139,17 @@ struct AboutDetailView<Content: View>: View {
135139
minOffset: CGFloat,
136140
maxOffset: CGFloat
137141
) -> CGFloat {
142+
let currentOffset = scrollOffset
143+
let threshold: CGFloat = 1.0
144+
145+
/// Prevents unnecessary view updates if the scroll offset is below the threshold
146+
if abs(currentOffset) < threshold {
147+
return minValue
148+
}
149+
138150
let valueRange = maxValue - minValue
139151
let offsetRange = maxOffset - minOffset
140-
let currentOffset = scrollOffset
152+
141153
let percentage = (currentOffset - minOffset) / offsetRange
142154
let value = minValue + (valueRange * percentage)
143155

CodeEdit/Features/About/Views/AboutView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public struct AboutView: View {
3636
ContributorsView(aboutMode: $aboutMode, namespace: animator)
3737
}
3838
}
39-
.animation(.spring(), value: aboutMode)
39+
.animation(.smooth, value: aboutMode)
4040
.ignoresSafeArea()
4141
.frame(width: 280, height: 400 - 28)
4242
.fixedSize()

0 commit comments

Comments
 (0)