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

@@ -382,7 +382,7 @@ public final class TextFieldComponent: Component {
self.updateEntities()
if currentAttributedText != updatedAttributedText && !self.isUpdating {
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged)))
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged)))
}
}
@@ -402,7 +402,7 @@ public final class TextFieldComponent: Component {
return state.insertText(text)
}
if !self.isUpdating {
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged)))
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged)))
}
}
@@ -415,7 +415,7 @@ public final class TextFieldComponent: Component {
return TextFieldComponent.InputState(inputText: text, selectionRange: selectionRange)
}
if !self.isUpdating {
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged)))
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged)))
}
}
@@ -449,7 +449,7 @@ public final class TextFieldComponent: Component {
}
}
if !self.isUpdating {
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged)))
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged)))
}
component.paste(.text)
return false
@@ -522,7 +522,7 @@ public final class TextFieldComponent: Component {
self.updateEntities()
if !self.isUpdating {
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged)))
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged)))
}
}
@@ -551,7 +551,7 @@ public final class TextFieldComponent: Component {
return
}
if !self.isUpdating {
self.state?.updated(transition: Transition(animation: .curve(duration: 0.5, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textFocusChanged(isFocused: true))))
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.5, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textFocusChanged(isFocused: true))))
}
if component.isOneLineWhenUnfocused {
Queue.mainQueue().justDispatch {
@@ -562,7 +562,7 @@ public final class TextFieldComponent: Component {
public func chatInputTextNodeDidFinishEditing() {
if !self.isUpdating {
self.state?.updated(transition: Transition(animation: .curve(duration: 0.5, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textFocusChanged(isFocused: false))))
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.5, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textFocusChanged(isFocused: false))))
}
}
@@ -967,7 +967,7 @@ public final class TextFieldComponent: Component {
return TextFieldComponent.InputState(inputText: string, selectionRange: string.length ..< string.length)
}
if updateState && !self.isUpdating {
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged)))
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged)))
}
}
@@ -1050,7 +1050,7 @@ public final class TextFieldComponent: Component {
if let spoilerView = self.spoilerView {
if animated {
let transition = Transition.easeInOut(duration: 0.3)
let transition = ComponentTransition.easeInOut(duration: 0.3)
if revealed {
transition.setAlpha(view: spoilerView, alpha: 0.0)
} else {
@@ -1167,7 +1167,7 @@ public final class TextFieldComponent: Component {
}
}
public func updateEmojiSuggestion(transition: Transition) {
public func updateEmojiSuggestion(transition: ComponentTransition) {
guard let component = self.component else {
return
}
@@ -1253,7 +1253,7 @@ public final class TextFieldComponent: Component {
return CGPoint(x: rightmostX, y: rightmostY)
}
func update(component: TextFieldComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
func update(component: TextFieldComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
self.isUpdating = true
defer {
self.isUpdating = false
@@ -1411,7 +1411,7 @@ public final class TextFieldComponent: Component {
let hasMoreThanOneLine = ellipsisFrame.maxY < self.textView.contentSize.height - 12.0
let ellipsisTransition: Transition
let ellipsisTransition: ComponentTransition
if isEditing {
ellipsisTransition = .easeInOut(duration: 0.2)
} else {
@@ -1435,7 +1435,7 @@ public final class TextFieldComponent: 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)
}
}