Skip to content

Commit d44d51e

Browse files
committed
metal randomizer
1 parent 8677120 commit d44d51e

File tree

3 files changed

+31
-17
lines changed

3 files changed

+31
-17
lines changed

EatHub/EatHub/Modules/Random/RandomView.swift

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,21 @@ struct RandomView: View {
8989
extension RandomView {
9090
@ViewBuilder
9191
private var bodyView: some View {
92-
switch viewModel.state {
93-
case .loading:
94-
RandomItemView()
95-
case .loaded(let result):
96-
ZStack {
97-
CircleShadow(isLoading: $viewModel.isLoading)
98-
.blur(radius: 20)
99-
.allowsHitTesting(false)
92+
ZStack {
93+
CircleShadow(isLoading: $viewModel.isLoading)
94+
.blur(radius: 20)
95+
.allowsHitTesting(false)
96+
switch viewModel.state {
97+
case .loading:
98+
RandomItemView()
99+
case .loaded(let result):
100+
100101
NavigationLink(value: result) {
101102
RandomItemView(item: result)
102103
}
103-
}
104-
case .error:
105-
CenteredVStaskText(text: Constants.Title.errorText)
104+
case .error:
105+
CenteredVStaskText(text: Constants.Title.errorText)
106+
}
106107
}
107108
}
108109
}

EatHub/EatHub/UIComponents/CircleShadowMetal/CircleShadow.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ struct CircleShadow: View {
2727
var body: some View {
2828
ZStack(alignment: .topLeading) {
2929
Rectangle()
30+
.fill(Color.Custom.backgroundPrimary)
3031
.frame(maxWidth: .infinity, maxHeight: .infinity)
3132
.overlay(
3233
TimelineView(.animation()) { timeline in
3334
let time = date.timeIntervalSince1970 - timeline.date.timeIntervalSince1970
3435

3536
CustomCircle(
3637
time: time,
37-
speed: isLoading ? 6 : 3,
38+
speed: 3,
3839
smoothing: 40,
3940
strength: 15,
4041
lineWidth: 30,
@@ -45,8 +46,8 @@ struct CircleShadow: View {
4546
.foregroundStyle(
4647
LinearGradient(
4748
colors: isLoading
48-
? [.clear, .green, .green]
49-
: [.clear, .gray.opacity(0.3), .gray.opacity(0.4)],
49+
? [.clear, Color.Custom.accent, Color.Custom.accent]
50+
: [.clear, Color.Custom.backgroundAccent.opacity(0.6), .gray.opacity(0.4)],
5051
startPoint: .leading,
5152
endPoint: .trailing
5253
)
@@ -59,7 +60,7 @@ struct CircleShadow: View {
5960

6061
CustomCircle(
6162
time: time,
62-
speed: isLoading ? -6 : -2,
63+
speed: -2,
6364
smoothing: -40,
6465
strength: -30,
6566
lineWidth: 30,
@@ -70,8 +71,8 @@ struct CircleShadow: View {
7071
.foregroundStyle(
7172
LinearGradient(
7273
colors: isLoading
73-
? [.clear, .green, .green]
74-
: [.clear, .gray.opacity(0.2), .gray.opacity(0.3)],
74+
? [.clear, Color.Custom.accent, Color.Custom.accent]
75+
: [.clear, Color.Custom.backgroundAccent.opacity(0.3)],
7576
startPoint: .leading,
7677
endPoint: .trailing
7778
)
@@ -132,3 +133,9 @@ struct CustomCircle: View {
132133
)
133134
}
134135
}
136+
137+
#Preview {
138+
CircleShadow(isLoading: .constant(false))
139+
.blur(radius: 20)
140+
.allowsHitTesting(false)
141+
}

EatHub/EatHub/UIComponents/ColorButton.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,9 @@ struct ColorButtonOutlineGear: View {
139139
.rotationEffect(Angle(degrees: t * 50))
140140
}
141141
}
142+
143+
#Preview {
144+
CircleShadow(isLoading: .constant(false))
145+
.blur(radius: 20)
146+
.allowsHitTesting(false)
147+
}

0 commit comments

Comments
 (0)