Skip to content

Commit

Permalink
Activity Indicator: Remove branching views to improve performance (#1957
Browse files Browse the repository at this point in the history
)
  • Loading branch information
imthath-m committed Feb 1, 2024
1 parent ae6228e commit 4669412
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions ios/FluentUI/ActivityIndicator/ActivityIndicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,16 @@ public struct ActivityIndicator: View, TokenizedControlView {
#endif

return semiRing
.modifyIf(state.isAnimating, { animatedView in
animatedView
.rotationEffect(.degrees(rotationAngle), anchor: .center)
.onAppear {
startAnimation()
}
})
.modifyIf(!state.isAnimating) { staticView in
staticView
.onAppear {
stopAnimation()
}
.onAppear {
if state.isAnimating {
startAnimation()
}
}
.opacity(!state.isAnimating && state.hidesWhenStopped ? 0 : 1)
.rotationEffect(.degrees(rotationAngle), anchor: .center)
.onChange(of: state.isAnimating) { newValue in
newValue ? startAnimation() : stopAnimation()
}
.modifyIf(!state.isAnimating && state.hidesWhenStopped, { view in
view.hidden()
})
.frame(width: side,
height: side,
alignment: .center)
Expand Down

0 comments on commit 4669412

Please sign in to comment.