Refactoring

This commit is contained in:
Isaac
2024-06-12 23:04:04 +04:00
parent 1b1846dc63
commit 9a075fa39e
360 changed files with 1830 additions and 1713 deletions

View File

@@ -907,7 +907,7 @@ final class StorageUsageScreenComponent: Component {
}
}
private func updateScrolling(transition: Transition) {
private func updateScrolling(transition: ComponentTransition) {
let scrollBounds = self.scrollView.bounds
let isLockedAtPanels = scrollBounds.maxY == self.scrollView.contentSize.height
@@ -921,7 +921,7 @@ final class StorageUsageScreenComponent: Component {
headerOffset = min(headerOffset, minOffset)
let animatedTransition = Transition(animation: .curve(duration: 0.18, curve: .easeInOut))
let animatedTransition = ComponentTransition(animation: .curve(duration: 0.18, curve: .easeInOut))
let navigationBackgroundAlpha: CGFloat = abs(headerOffset - minOffset) < 4.0 ? 1.0 : 0.0
animatedTransition.setAlpha(view: self.navigationBackgroundView, alpha: navigationBackgroundAlpha)
@@ -971,7 +971,7 @@ final class StorageUsageScreenComponent: Component {
)
}
func update(component: StorageUsageScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<ViewControllerComponentContainer.Environment>, transition: Transition) -> CGSize {
func update(component: StorageUsageScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<ViewControllerComponentContainer.Environment>, transition: ComponentTransition) -> CGSize {
self.component = component
self.state = state
@@ -1098,7 +1098,7 @@ final class StorageUsageScreenComponent: Component {
if let animationHint {
if case .firstStatsUpdate = animationHint.value {
let alphaTransition: Transition
let alphaTransition: ComponentTransition
if environment.isVisible {
alphaTransition = .easeInOut(duration: 0.25)
} else {
@@ -1147,7 +1147,7 @@ final class StorageUsageScreenComponent: Component {
}
if let aggregatedData = self.aggregatedData, !aggregatedData.isSelectingPeers {
aggregatedData.isSelectingPeers = true
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
}
}
).minSize(CGSize(width: 16.0, height: environment.navigationHeight - environment.statusBarHeight))),
@@ -1171,7 +1171,7 @@ final class StorageUsageScreenComponent: Component {
}
aggregatedData.isSelectingPeers = false
aggregatedData.clearPeerSelection()
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
}
).minSize(CGSize(width: 16.0, height: environment.navigationHeight - environment.statusBarHeight))),
environment: {},
@@ -1397,7 +1397,7 @@ final class StorageUsageScreenComponent: Component {
var pieChartTransition = transition
if transition.animation.isImmediate, let animationHint, case .clearedItems = animationHint.value {
pieChartTransition = Transition(animation: .curve(duration: 0.4, curve: .spring))
pieChartTransition = ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))
}
let pieChartSize = self.pieChartView.update(
@@ -1701,7 +1701,7 @@ final class StorageUsageScreenComponent: Component {
aggregatedData.setIsCategorySelected(category: key, isSelected: true)
}
}
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
},
toggleOtherExpanded: { [weak self] in
guard let self else {
@@ -1709,7 +1709,7 @@ final class StorageUsageScreenComponent: Component {
}
self.isOtherCategoryExpanded = !self.isOtherCategoryExpanded
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
},
clearAction: { [weak self] in
guard let self else {
@@ -1991,7 +1991,7 @@ final class StorageUsageScreenComponent: Component {
if aggregatedData.isSelectingPeers {
aggregatedData.togglePeerSelection(id: peer.id)
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
} else {
self.openPeer(peer: peer)
}
@@ -2056,7 +2056,7 @@ final class StorageUsageScreenComponent: Component {
return
}
aggregatedData.togglePeerSelection(id: peer.id)
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
})
))
let items = ContextController.Items(content: .list(itemList))
@@ -2092,7 +2092,7 @@ final class StorageUsageScreenComponent: Component {
return
}
aggregatedData.toggleMessageSelection(id: messageId)
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
},
contextAction: { [weak self] messageId, containerView, sourceRect, gesture in
guard let self else {
@@ -2119,7 +2119,7 @@ final class StorageUsageScreenComponent: Component {
return
}
aggregatedData.toggleMessageSelection(id: messageId)
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
},
contextAction: { [weak self] messageId, containerView, gesture in
guard let self else {
@@ -2146,7 +2146,7 @@ final class StorageUsageScreenComponent: Component {
return
}
aggregatedData.toggleMessageSelection(id: messageId)
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
},
contextAction: { [weak self] messageId, containerView, gesture in
guard let self else {
@@ -2252,7 +2252,7 @@ final class StorageUsageScreenComponent: Component {
}
if delay == 0.0 {
let animationTransition = Transition(animation: .curve(duration: 0.25, curve: .easeInOut))
let animationTransition = ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut))
animationTransition.setAlpha(view: clearingNode.view, alpha: 0.0, completion: { [weak clearingNode] _ in
clearingNode?.removeFromSupernode()
})
@@ -2328,7 +2328,7 @@ final class StorageUsageScreenComponent: Component {
if firstTime {
self.aggregatedData = initialAggregatedData
self.state?.updated(transition: Transition(animation: .none).withUserData(AnimationHint(value: .firstStatsUpdate)))
self.state?.updated(transition: ComponentTransition(animation: .none).withUserData(AnimationHint(value: .firstStatsUpdate)))
self.component?.ready.set(.single(true))
}
@@ -2469,9 +2469,9 @@ final class StorageUsageScreenComponent: Component {
self.isClearing = false
if !firstTime {
self.state?.updated(transition: Transition(animation: .none).withUserData(AnimationHint(value: .clearedItems)))
self.state?.updated(transition: ComponentTransition(animation: .none).withUserData(AnimationHint(value: .clearedItems)))
} else {
self.state?.updated(transition: Transition(animation: .none))
self.state?.updated(transition: ComponentTransition(animation: .none))
}
completion()
@@ -2587,7 +2587,7 @@ final class StorageUsageScreenComponent: Component {
return
}
aggregatedData.toggleMessageSelection(id: message.id)
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
})))
switch previewData {
@@ -2691,7 +2691,7 @@ final class StorageUsageScreenComponent: Component {
return
}
aggregatedData.toggleMessageSelection(id: message.id)
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
})
))
let items = ContextController.Items(content: .list(itemList))
@@ -3271,7 +3271,7 @@ final class StorageUsageScreenComponent: Component {
return View(frame: CGRect())
}
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<ViewControllerComponentContainer.Environment>, transition: Transition) -> CGSize {
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<ViewControllerComponentContainer.Environment>, transition: ComponentTransition) -> CGSize {
return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition)
}
}