@@ -232,13 +232,18 @@ public struct Slider: View {
232232 }
233233 }
234234 . allowsHitTesting ( !disable)
235+ . modifier ( SliderAccessibilityModifier (
236+ label: String ( localized: " ์ฌ๋ผ์ด๋ " , bundle: . module) ,
237+ value: headingLabel,
238+ disable: disable,
239+ onAdjust: handleAccessibilityAdjust
240+ ) )
235241 }
236242
237243 // MARK: - Modifiers
238244 private var heading = false
239245 private var label = false
240246 private var disable = false
241-
242247 /// ์ฌ๋ผ์ด๋ ์๋จ์ ์ ๋ชฉ์ ํ์ํ ์ง ์ฌ๋ถ๋ฅผ ์ค์ ํฉ๋๋ค.
243248 ///
244249 /// - Parameter heading: ์ ๋ชฉ ํ์ ์ฌ๋ถ, ์๋ตํ๋ฉด ๊ธฐ๋ณธ๊ฐ์ผ๋ก `true` ์ ์ฉ
@@ -270,7 +275,30 @@ public struct Slider: View {
270275 }
271276
272277 // MARK: - private
273-
278+
279+ private func handleAccessibilityAdjust( _ direction: AccessibilityAdjustmentDirection ) {
280+ guard !disable else { return }
281+ let step = 0.05
282+ switch direction {
283+ case . increment:
284+ if isRangeSlider, focusedThumb == 1 {
285+ thumbRatio1 = min ( thumbRatio2, thumbRatio1 + step)
286+ } else {
287+ thumbRatio2 = min ( 1.0 , thumbRatio2 + step)
288+ }
289+ case . decrement:
290+ if isRangeSlider, focusedThumb != 1 {
291+ thumbRatio2 = max ( thumbRatio1, thumbRatio2 - step)
292+ } else if isRangeSlider {
293+ thumbRatio1 = max ( 0.0 , thumbRatio1 - step)
294+ } else {
295+ thumbRatio2 = max ( 0.0 , thumbRatio2 - step)
296+ }
297+ @unknown default :
298+ break
299+ }
300+ }
301+
274302 private func updateValues( ) {
275303 lowValue = ( valueRange. upperBound - valueRange. lowerBound) * lowThumbRatio + valueRange. lowerBound
276304 highValue = ( valueRange. upperBound - valueRange. lowerBound) * highThumbRatio + valueRange. lowerBound
@@ -445,3 +473,18 @@ public struct Slider: View {
445473 }
446474 }
447475}
476+
477+ private struct SliderAccessibilityModifier : ViewModifier {
478+ let label : String
479+ let value : String
480+ let disable : Bool
481+ let onAdjust : ( AccessibilityAdjustmentDirection ) -> Void
482+
483+ func body( content: Content ) -> some View {
484+ content
485+ . accessibilityElement ( children: . ignore)
486+ . accessibilityLabel ( label)
487+ . accessibilityValue ( value)
488+ . accessibilityAdjustableAction ( onAdjust)
489+ }
490+ }
0 commit comments