@@ -15,12 +15,15 @@ final class T3SegmentedControlView: ExpoView {
1515 }
1616 }
1717 var selectedIndex = - 1 { didSet { updateSelection ( ) } }
18- var trackColor : UIColor = . secondarySystemBackground { didSet { control . backgroundColor = trackColor } }
19- var selectedColor : UIColor = . secondarySystemFill { didSet { control . selectedSegmentTintColor = selectedColor } }
20- var textColor : UIColor = . label { didSet { updateColors ( ) } }
21- var mutedColor : UIColor = . secondaryLabel { didSet { updateColors ( ) } }
18+ var trackColor : UIColor = . secondarySystemBackground { didSet { if trackColor != oldValue { control . backgroundColor = trackColor } } }
19+ var selectedColor : UIColor = . secondarySystemFill { didSet { if selectedColor != oldValue { control . selectedSegmentTintColor = selectedColor } } }
20+ var textColor : UIColor = . label { didSet { if textColor != oldValue { updateColors ( ) } } }
21+ var mutedColor : UIColor = . secondaryLabel { didSet { if mutedColor != oldValue { updateColors ( ) } } }
2222 var appearance = " light " {
23- didSet { overrideUserInterfaceStyle = appearance == " dark " ? . dark : . light }
23+ didSet {
24+ guard appearance != oldValue else { return }
25+ overrideUserInterfaceStyle = appearance == " dark " ? . dark : . light
26+ }
2427 }
2528
2629 required init ( appContext : AppContext ? = nil ) {
@@ -31,11 +34,20 @@ final class T3SegmentedControlView: ExpoView {
3134
3235 override func layoutSubviews ( ) {
3336 super . layoutSubviews ( )
34- control . frame = bounds
37+ guard control . frame != bounds else { return }
38+ UIView . performWithoutAnimation {
39+ control . frame = bounds
40+ }
3541 }
3642
3743 private func updateSelection ( ) {
38- control . selectedSegmentIndex = labels . indices . contains ( selectedIndex ) ? selectedIndex : UISegmentedControl . noSegment
44+ let index = labels . indices . contains ( selectedIndex ) ? selectedIndex : UISegmentedControl . noSegment
45+ // React echoes native selections while UIKit is still settling the glass lens.
46+ guard control . selectedSegmentIndex != index else { return }
47+ UIView . performWithoutAnimation {
48+ control . selectedSegmentIndex = index
49+ control . layoutIfNeeded ( )
50+ }
3951 }
4052
4153 private func updateColors ( ) {
0 commit comments