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

@@ -29,9 +29,9 @@ public final class ListSectionContentView: UIView {
public let id: AnyHashable
public let itemView: ItemView
public let size: CGSize
public let transition: Transition
public let transition: ComponentTransition
public init(id: AnyHashable, itemView: ItemView, size: CGSize, transition: Transition) {
public init(id: AnyHashable, itemView: ItemView, size: CGSize, transition: ComponentTransition) {
self.id = id
self.itemView = itemView
self.size = size
@@ -109,7 +109,7 @@ public final class ListSectionContentView: UIView {
self.highlightedItemId = itemId
if configuration.extendsItemHighlightToSection {
let transition: Transition
let transition: ComponentTransition
let backgroundColor: UIColor
if itemId != nil {
transition = .immediate
@@ -122,15 +122,15 @@ public final class ListSectionContentView: UIView {
self.externalContentBackgroundView.updateColor(color: backgroundColor, transition: transition)
} else {
if let previousHighlightedItemId, let previousItemView = self.itemViews[previousHighlightedItemId] {
Transition.easeInOut(duration: 0.2).setBackgroundColor(layer: previousItemView.highlightLayer, color: .clear)
ComponentTransition.easeInOut(duration: 0.2).setBackgroundColor(layer: previousItemView.highlightLayer, color: .clear)
}
if let itemId, let itemView = self.itemViews[itemId] {
Transition.immediate.setBackgroundColor(layer: itemView.highlightLayer, color: configuration.theme.list.itemHighlightedBackgroundColor)
ComponentTransition.immediate.setBackgroundColor(layer: itemView.highlightLayer, color: configuration.theme.list.itemHighlightedBackgroundColor)
}
}
}
public func update(configuration: Configuration, width: CGFloat, leftInset: CGFloat, readyItems: [ReadyItem], transition: Transition) -> UpdateResult {
public func update(configuration: Configuration, width: CGFloat, leftInset: CGFloat, readyItems: [ReadyItem], transition: ComponentTransition) -> UpdateResult {
self.configuration = configuration
switch configuration.background {
@@ -376,7 +376,7 @@ public final class ListSectionComponent: Component {
return self.contentView.itemViews[id]?.contents.view
}
func update(component: ListSectionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
func update(component: ListSectionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
self.component = component
let headerSideInset: CGFloat = 16.0
@@ -511,7 +511,7 @@ public final class ListSectionComponent: Component {
return View(frame: CGRect())
}
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition)
}
}
@@ -576,7 +576,7 @@ public final class ListSubSectionComponent: Component {
return self.contentView.itemViews[id]?.contents.view
}
func update(component: ListSubSectionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
func update(component: ListSubSectionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
self.component = component
var contentHeight: CGFloat = 0.0
@@ -642,7 +642,7 @@ public final class ListSubSectionComponent: Component {
return View(frame: CGRect())
}
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition)
}
}