Skip to content

Commit 9342f85

Browse files
committed
Start pulsing when next button is enabled
1 parent dbeb5d6 commit 9342f85

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

‎LLMonFHIR/FHIRInterpretation/UserStudy/UserStudyChatToolbar.swift‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ struct UserStudyChatToolbar: ToolbarContent {
5757
} label: {
5858
Image(systemName: "arrow.forward.circle")
5959
.accessibilityLabel("Next Task")
60+
.modifier(PulsatingEffect(isEnabled: !isInputDisabled))
6061
}
6162
.disabled(isInputDisabled)
6263
}
@@ -78,3 +79,40 @@ struct UserStudyChatToolbar: ToolbarContent {
7879
}
7980
}
8081
}
82+
83+
private struct PulsatingEffect: ViewModifier {
84+
let isEnabled: Bool
85+
@State private var scale: CGFloat = 1.0
86+
87+
func body(content: Content) -> some View {
88+
content
89+
.scaleEffect(scale)
90+
.onChange(of: isEnabled) { _, newValue in
91+
if newValue {
92+
startPulsing()
93+
} else {
94+
stopPulsing()
95+
}
96+
}
97+
.onAppear {
98+
if isEnabled {
99+
startPulsing()
100+
}
101+
}
102+
}
103+
104+
private func startPulsing() {
105+
withAnimation(
106+
.easeInOut(duration: 1.0)
107+
.repeatForever(autoreverses: true)
108+
) {
109+
scale = 1.2
110+
}
111+
}
112+
113+
private func stopPulsing() {
114+
withAnimation {
115+
scale = 1.0
116+
}
117+
}
118+
}

0 commit comments

Comments
 (0)