Skip to content

Commit 25b8340

Browse files
committed
refactor(a11y): reduce animations for loading button is needed (#159)
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
1 parent 79de2fa commit 25b8340

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

OUDS/Core/Components/Sources/Buttons/Internal/OUDSButtonStyle+LoadingModifiers.swift

+19-9
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
// Software Name: OUDS iOS
33
// SPDX-FileCopyrightText: Copyright (c) Orange SA
44
// SPDX-License-Identifier: MIT
5-
//
5+
//
66
// This software is distributed under the MIT license,
77
// the text of which is available at https://opensource.org/license/MIT/
88
// or see the "LICENSE" file for more details.
9-
//
9+
//
1010
// Authors: See CONTRIBUTORS.txt
11-
// Software description: A SwiftUI components library with code examples for Orange Unified Design System
11+
// Software description: A SwiftUI components library with code examples for Orange Unified Design System
1212
//
1313

1414
import OUDS
@@ -26,18 +26,28 @@ private struct LoagingIndicator: View {
2626

2727
@State private var isAnimating = false
2828

29+
@Environment(\.accessibilityReduceMotion) var reduceMotion
30+
2931
// MARK: Body
3032

3133
var body: some View {
34+
if reduceMotion {
35+
circleView()
36+
} else {
37+
circleView()
38+
.rotationEffect(.degrees(isAnimating ? 360 : 0))
39+
.onAppear {
40+
withAnimation(Animation.linear(duration: 1).repeatForever(autoreverses: false)) {
41+
self.isAnimating.toggle()
42+
}
43+
}
44+
}
45+
}
46+
47+
private func circleView() -> some View {
3248
Circle()
3349
.trim(from: 0, to: 0.7)
3450
.stroke(color, lineWidth: 3)
35-
.rotationEffect(.degrees(isAnimating ? 360 : 0))
36-
.onAppear {
37-
withAnimation(Animation.linear(duration: 1).repeatForever(autoreverses: false)) {
38-
self.isAnimating.toggle()
39-
}
40-
}
4151
}
4252
}
4353

0 commit comments

Comments
 (0)