mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-15 13:35:19 +00:00
Refactoring
This commit is contained in:
parent
1b1846dc63
commit
9a075fa39e
Binary file not shown.
Before Width: | Height: | Size: 4.2 KiB |
@ -1,119 +1,115 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "BlueNotificationIcon@2x.png",
|
||||
"scale" : "2x"
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "BlueNotificationIcon@3x.png",
|
||||
"scale" : "3x"
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Simple@58x58.png",
|
||||
"scale" : "2x"
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Simple@87x87.png",
|
||||
"scale" : "3x"
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Simple@80x80.png",
|
||||
"scale" : "2x"
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "BlueIcon@2x-1.png",
|
||||
"scale" : "3x"
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"size" : "60x60",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "BlueIcon@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "60x60",
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "60x60"
|
||||
},
|
||||
{
|
||||
"filename" : "BlueIcon@3x.png",
|
||||
"scale" : "3x"
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "60x60"
|
||||
},
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "BlueNotificationIcon.png",
|
||||
"scale" : "1x"
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "BlueNotificationIcon@2x-1.png",
|
||||
"scale" : "2x"
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Simple@29x29.png",
|
||||
"scale" : "1x"
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Simple@58x58-1.png",
|
||||
"scale" : "2x"
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Simple@40x40-1.png",
|
||||
"scale" : "1x"
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Simple@80x80-1.png",
|
||||
"scale" : "2x"
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"size" : "76x76",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "BlueIconIpad.png",
|
||||
"scale" : "1x"
|
||||
"scale" : "1x",
|
||||
"size" : "76x76"
|
||||
},
|
||||
{
|
||||
"size" : "76x76",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "BlueIconIpad@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "83.5x83.5",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "BlueIconLargeIpad@2x.png",
|
||||
"scale" : "2x"
|
||||
"scale" : "2x",
|
||||
"size" : "76x76"
|
||||
},
|
||||
{
|
||||
"filename" : "BlueIconLargeIpad@2x.png",
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "83.5x83.5"
|
||||
},
|
||||
{
|
||||
"size" : "1024x1024",
|
||||
"idiom" : "ios-marketing",
|
||||
"filename" : "Simple-iTunesArtwork.png",
|
||||
"scale" : "1x"
|
||||
"idiom" : "ios-marketing",
|
||||
"scale" : "1x",
|
||||
"size" : "1024x1024"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
},
|
||||
"properties" : {
|
||||
"pre-rendered" : true
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,10 +67,10 @@ final class AttachmentTextInputActionButtonsNode: ASDisplayNode, ChatSendMessage
|
||||
}
|
||||
} else {
|
||||
if highlighted {
|
||||
let transition: Transition = .easeInOut(duration: 0.4)
|
||||
let transition: ComponentTransition = .easeInOut(duration: 0.4)
|
||||
transition.setScale(layer: strongSelf.sendContainerNode.layer, scale: 0.75)
|
||||
} else {
|
||||
let transition: Transition = .easeInOut(duration: 0.25)
|
||||
let transition: ComponentTransition = .easeInOut(duration: 0.25)
|
||||
transition.setScale(layer: strongSelf.sendContainerNode.layer, scale: 1.0)
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ private final class IconComponent: Component {
|
||||
self.disposable?.dispose()
|
||||
}
|
||||
|
||||
func update(component: IconComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
func update(component: IconComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
if self.component?.name != component.name || self.component?.fileReference?.media.fileId != component.fileReference?.media.fileId || self.component?.tintColor != component.tintColor {
|
||||
if let fileReference = component.fileReference {
|
||||
let previousName = self.component?.name ?? ""
|
||||
@ -117,7 +117,7 @@ private final class IconComponent: 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, transition: transition)
|
||||
}
|
||||
}
|
||||
@ -1163,7 +1163,7 @@ final class AttachmentPanel: ASDisplayNode, ASScrollViewDelegate {
|
||||
self.updateViews(transition: .init(animation: .curve(duration: 0.2, curve: .spring)))
|
||||
}
|
||||
|
||||
func updateViews(transition: Transition) {
|
||||
func updateViews(transition: ComponentTransition) {
|
||||
guard let layout = self.validLayout else {
|
||||
return
|
||||
}
|
||||
|
@ -1192,7 +1192,7 @@ public final class AvatarNode: ASDisplayNode {
|
||||
self.contentNode.setCustomLetters(letters, explicitColor: explicitColor, icon: icon)
|
||||
}
|
||||
|
||||
public func setStoryStats(storyStats: StoryStats?, presentationParams: StoryPresentationParams, transition: Transition) {
|
||||
public func setStoryStats(storyStats: StoryStats?, presentationParams: StoryPresentationParams, transition: ComponentTransition) {
|
||||
if self.storyStats != storyStats || self.storyPresentationParams != presentationParams {
|
||||
self.storyStats = storyStats
|
||||
self.storyPresentationParams = presentationParams
|
||||
@ -1242,7 +1242,7 @@ public final class AvatarNode: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
|
||||
private func updateStoryIndicator(transition: Transition) {
|
||||
private func updateStoryIndicator(transition: ComponentTransition) {
|
||||
if !self.isNodeLoaded {
|
||||
return
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ protocol BrowserContent: UIView {
|
||||
|
||||
func scrollToTop()
|
||||
|
||||
func updateLayout(size: CGSize, insets: UIEdgeInsets, transition: Transition)
|
||||
func updateLayout(size: CGSize, insets: UIEdgeInsets, transition: ComponentTransition)
|
||||
}
|
||||
|
||||
struct ContentScrollingUpdate {
|
||||
@ -102,7 +102,7 @@ struct ContentScrollingUpdate {
|
||||
public var absoluteOffsetToBottomEdge: CGFloat?
|
||||
public var isReset: Bool
|
||||
public var isInteracting: Bool
|
||||
public var transition: Transition
|
||||
public var transition: ComponentTransition
|
||||
|
||||
public init(
|
||||
relativeOffset: CGFloat,
|
||||
@ -110,7 +110,7 @@ struct ContentScrollingUpdate {
|
||||
absoluteOffsetToBottomEdge: CGFloat?,
|
||||
isReset: Bool,
|
||||
isInteracting: Bool,
|
||||
transition: Transition
|
||||
transition: ComponentTransition
|
||||
) {
|
||||
self.relativeOffset = relativeOffset
|
||||
self.absoluteOffsetToTopEdge = absoluteOffsetToTopEdge
|
||||
|
@ -873,7 +873,7 @@
|
||||
//final class BrowserInstantPageContent: UIView, BrowserContent {
|
||||
// var onScrollingUpdate: (ContentScrollingUpdate) -> Void
|
||||
//
|
||||
// func updateLayout(size: CGSize, insets: UIEdgeInsets, transition: ComponentFlow.Transition) {
|
||||
// func updateLayout(size: CGSize, insets: UIEdgeInsets, transition: ComponentFlow.ComponentTransition) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
|
@ -289,7 +289,7 @@ private final class LoadingProgressComponent: Component {
|
||||
preconditionFailure()
|
||||
}
|
||||
|
||||
func update(component: LoadingProgressComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
func update(component: LoadingProgressComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
self.lineView.backgroundColor = component.color
|
||||
|
||||
let value = component.value
|
||||
@ -306,14 +306,14 @@ private final class LoadingProgressComponent: Component {
|
||||
|
||||
self.currentValue = value
|
||||
|
||||
let transition: Transition
|
||||
let transition: ComponentTransition
|
||||
if animated && value > 0.0 {
|
||||
transition = .spring(duration: 0.7)
|
||||
} else {
|
||||
transition = .immediate
|
||||
}
|
||||
|
||||
let alphaTransition: Transition
|
||||
let alphaTransition: ComponentTransition
|
||||
if animated {
|
||||
alphaTransition = .easeInOut(duration: 0.3)
|
||||
} else {
|
||||
@ -333,7 +333,7 @@ private final class LoadingProgressComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
return view.update(component: self, availableSize: availableSize, transition: transition)
|
||||
}
|
||||
}
|
||||
@ -414,7 +414,7 @@ final class ReferenceButtonComponent: Component {
|
||||
self.component?.action()
|
||||
}
|
||||
|
||||
func update(component: ReferenceButtonComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
func update(component: ReferenceButtonComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
self.component = component
|
||||
|
||||
let componentSize = self.componentView.update(
|
||||
@ -441,7 +441,7 @@ final class ReferenceButtonComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
return view.update(component: self, availableSize: availableSize, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -600,13 +600,13 @@ public class BrowserScreen: ViewController {
|
||||
}
|
||||
}
|
||||
|
||||
func requestLayout(transition: Transition) {
|
||||
func requestLayout(transition: ComponentTransition) {
|
||||
if let (layout, navigationBarHeight) = self.validLayout {
|
||||
self.containerLayoutUpdated(layout: layout, navigationBarHeight: navigationBarHeight, transition: transition)
|
||||
}
|
||||
}
|
||||
|
||||
func containerLayoutUpdated(layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: Transition) {
|
||||
func containerLayoutUpdated(layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ComponentTransition) {
|
||||
self.validLayout = (layout, navigationBarHeight)
|
||||
|
||||
let environment = ViewControllerComponentContainer.Environment(
|
||||
@ -705,7 +705,7 @@ public class BrowserScreen: ViewController {
|
||||
override public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
||||
super.containerLayoutUpdated(layout, transition: transition)
|
||||
|
||||
(self.displayNode as! Node).containerLayoutUpdated(layout: layout, navigationBarHeight: self.navigationLayout(layout: layout).navigationFrame.height, transition: Transition(transition))
|
||||
(self.displayNode as! Node).containerLayoutUpdated(layout: layout, navigationBarHeight: self.navigationLayout(layout: layout).navigationFrame.height, transition: ComponentTransition(transition))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@ final class SearchBarContentComponent: Component {
|
||||
}
|
||||
}
|
||||
|
||||
func update(component: SearchBarContentComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
func update(component: SearchBarContentComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
self.component = component
|
||||
|
||||
self.update(theme: component.theme, strings: component.strings, size: availableSize, transition: transition)
|
||||
@ -249,7 +249,7 @@ final class SearchBarContentComponent: Component {
|
||||
return availableSize
|
||||
}
|
||||
|
||||
public func update(theme: PresentationTheme, strings: PresentationStrings, size: CGSize, transition: Transition) {
|
||||
public func update(theme: PresentationTheme, strings: PresentationStrings, size: CGSize, transition: ComponentTransition) {
|
||||
let params = Params(
|
||||
theme: theme,
|
||||
strings: strings,
|
||||
@ -351,7 +351,7 @@ final class SearchBarContentComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
return view.update(component: self, availableSize: availableSize, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -100,10 +100,10 @@ final class BrowserToolbarComponent: CombinedComponent {
|
||||
if let centerItem = item {
|
||||
context.add(centerItem
|
||||
.position(CGPoint(x: context.availableSize.width / 2.0, y: contentHeight / 2.0 + offset))
|
||||
.appear(Transition.Appear({ _, view, transition in
|
||||
.appear(ComponentTransition.Appear({ _, view, transition in
|
||||
transition.animatePosition(view: view, from: CGPoint(x: 0.0, y: size.height), to: .zero, additive: true)
|
||||
}))
|
||||
.disappear(Transition.Disappear({ view, transition, completion in
|
||||
.disappear(ComponentTransition.Disappear({ view, transition, completion in
|
||||
transition.animatePosition(view: view, from: .zero, to: CGPoint(x: 0.0, y: size.height), additive: true, completion: { _ in
|
||||
completion()
|
||||
})
|
||||
|
@ -258,7 +258,7 @@ final class BrowserWebContent: UIView, BrowserContent, UIScrollViewDelegate {
|
||||
self.webView.scrollView.setContentOffset(CGPoint(x: 0.0, y: -self.webView.scrollView.contentInset.top), animated: true)
|
||||
}
|
||||
|
||||
func updateLayout(size: CGSize, insets: UIEdgeInsets, transition: Transition) {
|
||||
func updateLayout(size: CGSize, insets: UIEdgeInsets, transition: ComponentTransition) {
|
||||
var scrollInsets = insets
|
||||
scrollInsets.top = 0.0
|
||||
if self.webView.scrollView.contentInset != insets {
|
||||
@ -303,7 +303,7 @@ final class BrowserWebContent: UIView, BrowserContent, UIScrollViewDelegate {
|
||||
}
|
||||
|
||||
private func snapScrollingOffsetToInsets() {
|
||||
let transition = Transition(animation: .curve(duration: 0.4, curve: .spring))
|
||||
let transition = ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))
|
||||
self.updateScrollingOffset(isReset: false, transition: transition)
|
||||
}
|
||||
|
||||
@ -317,7 +317,7 @@ final class BrowserWebContent: UIView, BrowserContent, UIScrollViewDelegate {
|
||||
self.snapScrollingOffsetToInsets()
|
||||
}
|
||||
|
||||
private func updateScrollingOffset(isReset: Bool, transition: Transition) {
|
||||
private func updateScrollingOffset(isReset: Bool, transition: ComponentTransition) {
|
||||
let scrollView = self.webView.scrollView
|
||||
let isInteracting = scrollView.isDragging || scrollView.isDecelerating
|
||||
if let previousScrollingOffsetValue = self.previousScrollingOffset {
|
||||
|
@ -404,7 +404,7 @@ private final class DayComponent: Component {
|
||||
self.action?()
|
||||
}
|
||||
|
||||
func update(component: DayComponent, availableSize: CGSize, environment: Environment<DayEnvironment>, transition: Transition) -> CGSize {
|
||||
func update(component: DayComponent, availableSize: CGSize, environment: Environment<DayEnvironment>, transition: ComponentTransition) -> CGSize {
|
||||
let isFirstTime = self.action == nil
|
||||
|
||||
self.action = component.action
|
||||
@ -613,7 +613,7 @@ private final class DayComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<DayEnvironment>, transition: Transition) -> CGSize {
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<DayEnvironment>, transition: ComponentTransition) -> CGSize {
|
||||
return view.update(component: self, availableSize: availableSize, environment: environment, transition: transition)
|
||||
}
|
||||
}
|
||||
@ -859,7 +859,7 @@ private final class MonthComponent: CombinedComponent {
|
||||
let delayIndex = dayEnvironment.selectionDelayCoordination
|
||||
context.add(selection
|
||||
.position(CGPoint(x: selectionRect.midX, y: selectionRect.midY))
|
||||
.appear(Transition.Appear { _, view, transition in
|
||||
.appear(ComponentTransition.Appear { _, view, transition in
|
||||
if case .none = transition.animation {
|
||||
return
|
||||
}
|
||||
@ -867,7 +867,7 @@ private final class MonthComponent: CombinedComponent {
|
||||
view.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.05, delay: delay)
|
||||
view.layer.animateFrame(from: CGRect(origin: view.frame.origin, size: CGSize(width: selectionRadius, height: view.frame.height)), to: view.frame, duration: 0.25, delay: delay, timingFunction: kCAMediaTimingFunctionSpring)
|
||||
})
|
||||
.disappear(Transition.Disappear { view, transition, completion in
|
||||
.disappear(ComponentTransition.Disappear { view, transition, completion in
|
||||
if case .none = transition.animation {
|
||||
completion()
|
||||
return
|
||||
@ -1203,12 +1203,12 @@ public final class CalendarMessageScreen: ViewController {
|
||||
}
|
||||
|
||||
func toggleSelectionMode() {
|
||||
var transition: Transition = .immediate
|
||||
var transition: ComponentTransition = .immediate
|
||||
if self.selectionState == nil {
|
||||
self.selectionState = SelectionState(dayRange: nil)
|
||||
} else {
|
||||
self.selectionState = nil
|
||||
transition = Transition(animation: .curve(duration: 0.25, curve: .easeInOut))
|
||||
transition = ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut))
|
||||
transition = transition.withUserData(SelectionTransition.end)
|
||||
}
|
||||
|
||||
@ -1236,7 +1236,7 @@ public final class CalendarMessageScreen: ViewController {
|
||||
self.selectionToolbarActionSelected()
|
||||
}
|
||||
|
||||
func containerLayoutUpdated(layout: ContainerViewLayout, navigationHeight: CGFloat, transition: ContainedViewLayoutTransition, componentsTransition: Transition) {
|
||||
func containerLayoutUpdated(layout: ContainerViewLayout, navigationHeight: CGFloat, transition: ContainedViewLayoutTransition, componentsTransition: ComponentTransition) {
|
||||
let isFirstLayout = self.validLayout == nil
|
||||
self.validLayout = (layout, navigationHeight)
|
||||
|
||||
@ -1614,7 +1614,7 @@ public final class CalendarMessageScreen: ViewController {
|
||||
return true
|
||||
}
|
||||
|
||||
func updateMonthViews(transition: Transition) {
|
||||
func updateMonthViews(transition: ComponentTransition) {
|
||||
guard let (width, _, frames) = self.scrollLayout else {
|
||||
return
|
||||
}
|
||||
@ -1657,7 +1657,7 @@ public final class CalendarMessageScreen: ViewController {
|
||||
return
|
||||
}
|
||||
if var selectionState = strongSelf.selectionState {
|
||||
var transition = Transition(animation: .curve(duration: 0.2, curve: .spring))
|
||||
var transition = ComponentTransition(animation: .curve(duration: 0.2, curve: .spring))
|
||||
if let dayRange = selectionState.dayRange {
|
||||
if dayRange.lowerBound == timestamp || dayRange.upperBound == timestamp {
|
||||
selectionState.dayRange = nil
|
||||
@ -1712,7 +1712,7 @@ public final class CalendarMessageScreen: ViewController {
|
||||
guard var selectionState = strongSelf.selectionState else {
|
||||
return
|
||||
}
|
||||
var transition = Transition(animation: .curve(duration: 0.2, curve: .spring))
|
||||
var transition = ComponentTransition(animation: .curve(duration: 0.2, curve: .spring))
|
||||
if let dayRange = selectionState.dayRange {
|
||||
if dayRange == range {
|
||||
selectionState.dayRange = nil
|
||||
@ -1751,7 +1751,7 @@ public final class CalendarMessageScreen: ViewController {
|
||||
}
|
||||
}
|
||||
|
||||
private func updateSelectionState(transition: Transition) {
|
||||
private func updateSelectionState(transition: ComponentTransition) {
|
||||
var title = self.presentationData.strings.MessageCalendar_Title
|
||||
if let selectionState = self.selectionState, let dayRange = selectionState.dayRange {
|
||||
var selectedCount = 0
|
||||
|
@ -303,7 +303,7 @@ final class ChatListContainerItemNode: ASDisplayNode {
|
||||
|
||||
if let chatFolderUpdates = self.chatFolderUpdates {
|
||||
let topPanel: TopPanelItem
|
||||
var topPanelTransition = Transition(transition)
|
||||
var topPanelTransition = ComponentTransition(transition)
|
||||
if let current = self.topPanel {
|
||||
topPanel = current
|
||||
} else {
|
||||
@ -350,7 +350,7 @@ final class ChatListContainerItemNode: ASDisplayNode {
|
||||
additionalTopInset += topPanelHeight
|
||||
} else if self.canReportPeer {
|
||||
let topPanel: TopPanelItem
|
||||
var topPanelTransition = Transition(transition)
|
||||
var topPanelTransition = ComponentTransition(transition)
|
||||
if let current = self.topPanel {
|
||||
topPanel = current
|
||||
} else {
|
||||
|
@ -897,7 +897,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
return
|
||||
}
|
||||
|
||||
self.chatListDisplayNode.requestNavigationBarLayout(transition: Transition.immediate.withUserData(ChatListNavigationBar.AnimationHint(
|
||||
self.chatListDisplayNode.requestNavigationBarLayout(transition: ComponentTransition.immediate.withUserData(ChatListNavigationBar.AnimationHint(
|
||||
disableStoriesAnimations: false,
|
||||
crossfadeStoryPeers: true
|
||||
)))
|
||||
|
@ -1302,7 +1302,7 @@ final class ChatListControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
private func updateNavigationBar(layout: ContainerViewLayout, deferScrollApplication: Bool, transition: Transition) -> (navigationHeight: CGFloat, storiesInset: CGFloat) {
|
||||
private func updateNavigationBar(layout: ContainerViewLayout, deferScrollApplication: Bool, transition: ComponentTransition) -> (navigationHeight: CGFloat, storiesInset: CGFloat) {
|
||||
let headerContent = self.controller?.updateHeaderContent()
|
||||
|
||||
var tabsNode: ASDisplayNode?
|
||||
@ -1445,7 +1445,7 @@ final class ChatListControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
|
||||
}
|
||||
|
||||
if let navigationBarComponentView = self.navigationBarView.view as? ChatListNavigationBar.View {
|
||||
navigationBarComponentView.applyScroll(offset: offset, allowAvatarsExpansion: allowAvatarsExpansion, forceUpdate: false, transition: Transition(transition).withUserData(ChatListNavigationBar.AnimationHint(
|
||||
navigationBarComponentView.applyScroll(offset: offset, allowAvatarsExpansion: allowAvatarsExpansion, forceUpdate: false, transition: ComponentTransition(transition).withUserData(ChatListNavigationBar.AnimationHint(
|
||||
disableStoriesAnimations: self.tempDisableStoriesAnimations,
|
||||
crossfadeStoryPeers: false
|
||||
)))
|
||||
@ -1460,7 +1460,7 @@ final class ChatListControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
|
||||
transition.updateSublayerTransformOffset(layer: self.mainContainerNode.layer, offset: CGPoint(x: 0.0, y: -mainDelta))
|
||||
}
|
||||
|
||||
func requestNavigationBarLayout(transition: Transition) {
|
||||
func requestNavigationBarLayout(transition: ComponentTransition) {
|
||||
guard let (layout, _, _, _, _) = self.containerLayout else {
|
||||
return
|
||||
}
|
||||
@ -1491,7 +1491,7 @@ final class ChatListControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
|
||||
var cleanNavigationBarHeight = cleanNavigationBarHeight
|
||||
var storiesInset = storiesInset
|
||||
|
||||
let navigationBarLayout = self.updateNavigationBar(layout: layout, deferScrollApplication: true, transition: Transition(transition))
|
||||
let navigationBarLayout = self.updateNavigationBar(layout: layout, deferScrollApplication: true, transition: ComponentTransition(transition))
|
||||
self.mainContainerNode.initialScrollingOffset = ChatListNavigationBar.searchScrollHeight + navigationBarLayout.storiesInset
|
||||
|
||||
navigationBarHeight = navigationBarLayout.navigationHeight
|
||||
@ -1613,7 +1613,7 @@ final class ChatListControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
|
||||
|
||||
if let navigationBarComponentView = self.navigationBarView.view as? ChatListNavigationBar.View {
|
||||
navigationBarComponentView.deferScrollApplication = false
|
||||
navigationBarComponentView.applyCurrentScroll(transition: Transition(transition))
|
||||
navigationBarComponentView.applyCurrentScroll(transition: ComponentTransition(transition))
|
||||
}
|
||||
}
|
||||
|
||||
@ -1714,7 +1714,7 @@ final class ChatListControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
|
||||
|
||||
func willScrollToTop() {
|
||||
if let navigationBarComponentView = self.navigationBarView.view as? ChatListNavigationBar.View {
|
||||
navigationBarComponentView.applyScroll(offset: 0.0, allowAvatarsExpansion: false, transition: Transition(animation: .curve(duration: 0.3, curve: .slide)))
|
||||
navigationBarComponentView.applyScroll(offset: 0.0, allowAvatarsExpansion: false, transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .slide)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ final class ChatListEmptyNode: ASDisplayNode {
|
||||
self.emptyArchive = emptyArchive
|
||||
}
|
||||
let emptyArchiveSize = emptyArchive.update(
|
||||
transition: Transition(transition),
|
||||
transition: ComponentTransition(transition),
|
||||
component: AnyComponent(ArchiveInfoContentComponent(
|
||||
theme: self.theme,
|
||||
strings: self.strings,
|
||||
|
@ -318,7 +318,7 @@ private final class ChatListItemTagListComponent: Component {
|
||||
preconditionFailure()
|
||||
}
|
||||
|
||||
func update(component: ChatListItemTagListComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(component: ChatListItemTagListComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
var validIds: [Int32] = []
|
||||
let spacing: CGFloat = floorToScreenPixels(5.0 * component.sizeFactor)
|
||||
var nextX: CGFloat = 0.0
|
||||
@ -387,7 +387,7 @@ private final class ChatListItemTagListComponent: Component {
|
||||
return View(frame: CGRect())
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -44,10 +44,10 @@ public protocol ChatSendMessageContextScreenMediaPreview: AnyObject {
|
||||
var globalClippingRect: CGRect? { get }
|
||||
var layoutType: ChatSendMessageContextScreenMediaPreviewLayoutType { get }
|
||||
|
||||
func animateIn(transition: Transition)
|
||||
func animateOut(transition: Transition)
|
||||
func animateOutOnSend(transition: Transition)
|
||||
func update(containerSize: CGSize, transition: Transition) -> CGSize
|
||||
func animateIn(transition: ComponentTransition)
|
||||
func animateOut(transition: ComponentTransition)
|
||||
func animateOutOnSend(transition: ComponentTransition)
|
||||
func update(containerSize: CGSize, transition: ComponentTransition) -> CGSize
|
||||
}
|
||||
|
||||
final class ChatSendMessageContextScreenComponent: Component {
|
||||
@ -270,7 +270,7 @@ final class ChatSendMessageContextScreenComponent: Component {
|
||||
return false
|
||||
}
|
||||
|
||||
func update(component: ChatSendMessageContextScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: Transition) -> CGSize {
|
||||
func update(component: ChatSendMessageContextScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: ComponentTransition) -> CGSize {
|
||||
self.isUpdating = true
|
||||
defer {
|
||||
self.isUpdating = false
|
||||
@ -308,7 +308,7 @@ final class ChatSendMessageContextScreenComponent: Component {
|
||||
|
||||
let messageActionsSpacing: CGFloat = 7.0
|
||||
|
||||
let alphaTransition: Transition
|
||||
let alphaTransition: ComponentTransition
|
||||
if transition.animation.isImmediate {
|
||||
alphaTransition = .immediate
|
||||
} else {
|
||||
@ -617,7 +617,7 @@ final class ChatSendMessageContextScreenComponent: Component {
|
||||
return
|
||||
}
|
||||
if !self.isUpdating {
|
||||
self.state?.updated(transition: Transition(transition))
|
||||
self.state?.updated(transition: ComponentTransition(transition))
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -775,7 +775,7 @@ final class ChatSendMessageContextScreenComponent: Component {
|
||||
return
|
||||
}
|
||||
if !self.isUpdating {
|
||||
self.state?.updated(transition: Transition(transition))
|
||||
self.state?.updated(transition: ComponentTransition(transition))
|
||||
}
|
||||
},
|
||||
requestLayout: { [weak self] transition in
|
||||
@ -783,7 +783,7 @@ final class ChatSendMessageContextScreenComponent: Component {
|
||||
return
|
||||
}
|
||||
if !self.isUpdating {
|
||||
self.state?.updated(transition: Transition(transition))
|
||||
self.state?.updated(transition: ComponentTransition(transition))
|
||||
}
|
||||
},
|
||||
requestUpdateOverlayWantsToBeBelowKeyboard: { [weak self] transition in
|
||||
@ -1167,7 +1167,7 @@ final class ChatSendMessageContextScreenComponent: Component {
|
||||
break
|
||||
case .animatedIn:
|
||||
transition.setAlpha(view: actionsStackNode.view, alpha: 1.0)
|
||||
Transition.immediate.setScale(view: actionsStackNode.view, scale: 1.0)
|
||||
ComponentTransition.immediate.setScale(view: actionsStackNode.view, scale: 1.0)
|
||||
actionsStackNode.layer.animateSpring(from: 0.001 as NSNumber, to: 1.0 as NSNumber, keyPath: "transform.scale", duration: 0.42, damping: 104.0)
|
||||
|
||||
messageItemView.animateIn(
|
||||
@ -1340,7 +1340,7 @@ final class ChatSendMessageContextScreenComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: Transition) -> CGSize {
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: ComponentTransition) -> CGSize {
|
||||
return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public final class ChatSendMessageScreenEffectIcon: Component {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func update(component: ChatSendMessageScreenEffectIcon, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(component: ChatSendMessageScreenEffectIcon, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
if case let .file(file) = component.content {
|
||||
let fileView: ReactionIconView
|
||||
if let current = self.fileView {
|
||||
@ -130,7 +130,7 @@ public final class ChatSendMessageScreenEffectIcon: 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)
|
||||
}
|
||||
}
|
||||
@ -246,7 +246,7 @@ final class MessageItemView: UIView {
|
||||
func animateIn(
|
||||
sourceTextInputView: ChatInputTextView?,
|
||||
isEditMessage: Bool,
|
||||
transition: Transition
|
||||
transition: ComponentTransition
|
||||
) {
|
||||
if isEditMessage {
|
||||
transition.animateScale(view: self, from: 0.001, to: 1.0)
|
||||
@ -262,7 +262,7 @@ final class MessageItemView: UIView {
|
||||
sourceTextInputView: ChatInputTextView?,
|
||||
toEmpty: Bool,
|
||||
isEditMessage: Bool,
|
||||
transition: Transition
|
||||
transition: ComponentTransition
|
||||
) {
|
||||
if isEditMessage {
|
||||
transition.setScale(view: self, scale: 0.001)
|
||||
@ -294,7 +294,7 @@ final class MessageItemView: UIView {
|
||||
containerSize: CGSize,
|
||||
effect: AvailableMessageEffects.MessageEffect?,
|
||||
isEditMessage: Bool,
|
||||
transition: Transition
|
||||
transition: ComponentTransition
|
||||
) -> CGSize {
|
||||
self.emojiViewProvider = emojiViewProvider
|
||||
|
||||
@ -351,7 +351,7 @@ final class MessageItemView: UIView {
|
||||
backgroundNode: backgroundNode
|
||||
)
|
||||
|
||||
let alphaTransition: Transition = transition.animation.isImmediate ? .immediate : .easeInOut(duration: 0.25)
|
||||
let alphaTransition: ComponentTransition = transition.animation.isImmediate ? .immediate : .easeInOut(duration: 0.25)
|
||||
|
||||
if let sourceMediaPreview {
|
||||
let mediaPreviewClippingView: UIView
|
||||
@ -764,7 +764,7 @@ final class MessageItemView: UIView {
|
||||
isAnimatedIn: Bool,
|
||||
localFrame: CGRect,
|
||||
containerSize: CGSize,
|
||||
transition: Transition
|
||||
transition: ComponentTransition
|
||||
) {
|
||||
if let mediaPreviewClippingView = self.mediaPreviewClippingView, let sourceMediaPreview {
|
||||
let clippingFrame: CGRect
|
||||
|
@ -67,7 +67,7 @@ final class SendButton: HighlightTrackingButton {
|
||||
isAnimatedIn: Bool,
|
||||
isLoadingEffectAnimation: Bool,
|
||||
size: CGSize,
|
||||
transition: Transition
|
||||
transition: ComponentTransition
|
||||
) {
|
||||
let innerSize = CGSize(width: size.width - 5.5 * 2.0, height: 33.0)
|
||||
let containerFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((size.width - innerSize.width) * 0.5), y: floorToScreenPixels((size.height - innerSize.height) * 0.5)), size: innerSize)
|
||||
@ -197,7 +197,7 @@ final class SendButton: HighlightTrackingButton {
|
||||
}
|
||||
}
|
||||
|
||||
func updateGlobalRect(rect: CGRect, within containerSize: CGSize, transition: Transition) {
|
||||
func updateGlobalRect(rect: CGRect, within containerSize: CGSize, transition: ComponentTransition) {
|
||||
if let backgroundContent = self.backgroundContent {
|
||||
backgroundContent.update(rect: CGRect(origin: CGPoint(x: rect.minX + self.containerView.frame.minX, y: rect.minY + self.containerView.frame.minY), size: backgroundContent.bounds.size), within: containerSize, transition: transition.containedViewLayoutTransition)
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
public extension Transition.Appear {
|
||||
static func `default`(scale: Bool = false, alpha: Bool = false) -> Transition.Appear {
|
||||
return Transition.Appear { component, view, transition in
|
||||
public extension ComponentTransition.Appear {
|
||||
static func `default`(scale: Bool = false, alpha: Bool = false) -> ComponentTransition.Appear {
|
||||
return ComponentTransition.Appear { component, view, transition in
|
||||
if scale {
|
||||
transition.animateScale(view: view, from: 0.01, to: 1.0)
|
||||
}
|
||||
@ -13,16 +13,16 @@ public extension Transition.Appear {
|
||||
}
|
||||
}
|
||||
|
||||
static func scaleIn() -> Transition.Appear {
|
||||
return Transition.Appear { component, view, transition in
|
||||
static func scaleIn() -> ComponentTransition.Appear {
|
||||
return ComponentTransition.Appear { component, view, transition in
|
||||
transition.animateScale(view: view, from: 0.01, to: 1.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public extension Transition.AppearWithGuide {
|
||||
static func `default`(scale: Bool = false, alpha: Bool = false) -> Transition.AppearWithGuide {
|
||||
return Transition.AppearWithGuide { component, view, guide, transition in
|
||||
public extension ComponentTransition.AppearWithGuide {
|
||||
static func `default`(scale: Bool = false, alpha: Bool = false) -> ComponentTransition.AppearWithGuide {
|
||||
return ComponentTransition.AppearWithGuide { component, view, guide, transition in
|
||||
if scale {
|
||||
transition.animateScale(view: view, from: 0.01, to: 1.0)
|
||||
}
|
||||
@ -34,9 +34,9 @@ public extension Transition.AppearWithGuide {
|
||||
}
|
||||
}
|
||||
|
||||
public extension Transition.Disappear {
|
||||
static func `default`(scale: Bool = false, alpha: Bool = true) -> Transition.Disappear {
|
||||
return Transition.Disappear { view, transition, completion in
|
||||
public extension ComponentTransition.Disappear {
|
||||
static func `default`(scale: Bool = false, alpha: Bool = true) -> ComponentTransition.Disappear {
|
||||
return ComponentTransition.Disappear { view, transition, completion in
|
||||
if scale {
|
||||
transition.setScale(view: view, scale: 0.01, completion: { _ in
|
||||
if !alpha {
|
||||
@ -56,9 +56,9 @@ public extension Transition.Disappear {
|
||||
}
|
||||
}
|
||||
|
||||
public extension Transition.DisappearWithGuide {
|
||||
static func `default`(alpha: Bool = true) -> Transition.DisappearWithGuide {
|
||||
return Transition.DisappearWithGuide { stage, view, guide, transition, completion in
|
||||
public extension ComponentTransition.DisappearWithGuide {
|
||||
static func `default`(alpha: Bool = true) -> ComponentTransition.DisappearWithGuide {
|
||||
return ComponentTransition.DisappearWithGuide { stage, view, guide, transition, completion in
|
||||
switch stage {
|
||||
case .begin:
|
||||
if alpha {
|
||||
@ -78,8 +78,8 @@ public extension Transition.DisappearWithGuide {
|
||||
}
|
||||
}
|
||||
|
||||
public extension Transition.Update {
|
||||
static let `default` = Transition.Update { component, view, transition in
|
||||
public extension ComponentTransition.Update {
|
||||
static let `default` = ComponentTransition.Update { component, view, transition in
|
||||
let frame = component.size.centered(around: component._position ?? CGPoint())
|
||||
if let scale = component._scale {
|
||||
transition.setBounds(view: view, bounds: CGRect(origin: CGPoint(), size: frame.size))
|
||||
|
@ -6,7 +6,7 @@ private func updateChildAnyComponent<EnvironmentType>(
|
||||
component: AnyComponent<EnvironmentType>,
|
||||
view: UIView,
|
||||
availableSize: CGSize,
|
||||
transition: Transition
|
||||
transition: ComponentTransition
|
||||
) -> _UpdatedChildComponent {
|
||||
let parentContext = _AnyCombinedComponentContext.current
|
||||
|
||||
@ -85,7 +85,7 @@ public final class _ConcreteChildComponent<ComponentType: Component>: _AnyChildC
|
||||
return .direct(self.directId)
|
||||
}
|
||||
|
||||
public func update(component: ComponentType, @EnvironmentBuilder environment: () -> Environment<ComponentType.EnvironmentType>, availableSize: CGSize, transition: Transition) -> _UpdatedChildComponent {
|
||||
public func update(component: ComponentType, @EnvironmentBuilder environment: () -> Environment<ComponentType.EnvironmentType>, availableSize: CGSize, transition: ComponentTransition) -> _UpdatedChildComponent {
|
||||
let parentContext = _AnyCombinedComponentContext.current
|
||||
if !parentContext.updateContext.configuredViews.insert(self.id).inserted {
|
||||
preconditionFailure("Child component can only be configured once")
|
||||
@ -119,7 +119,7 @@ public final class _ConcreteChildComponent<ComponentType: Component>: _AnyChildC
|
||||
}
|
||||
|
||||
public extension _ConcreteChildComponent where ComponentType.EnvironmentType == Empty {
|
||||
func update(component: ComponentType, availableSize: CGSize, transition: Transition) -> _UpdatedChildComponent {
|
||||
func update(component: ComponentType, availableSize: CGSize, transition: ComponentTransition) -> _UpdatedChildComponent {
|
||||
return self.update(component: component, environment: {}, availableSize: availableSize, transition: transition)
|
||||
}
|
||||
}
|
||||
@ -141,7 +141,7 @@ public final class _ChildComponentGuide {
|
||||
return .direct(self.directId)
|
||||
}
|
||||
|
||||
public func update(position: CGPoint, transition: Transition) -> _UpdatedChildComponentGuide {
|
||||
public func update(position: CGPoint, transition: ComponentTransition) -> _UpdatedChildComponentGuide {
|
||||
let parentContext = _AnyCombinedComponentContext.current
|
||||
|
||||
let previousPosition = parentContext.guides[self.id]
|
||||
@ -182,11 +182,11 @@ public final class _UpdatedChildComponent {
|
||||
var _clipsToBounds: Bool?
|
||||
var _shadow: Shadow?
|
||||
|
||||
fileprivate var transitionAppear: Transition.Appear?
|
||||
fileprivate var transitionAppearWithGuide: (Transition.AppearWithGuide, _AnyChildComponent.Id)?
|
||||
fileprivate var transitionDisappear: Transition.Disappear?
|
||||
fileprivate var transitionDisappearWithGuide: (Transition.DisappearWithGuide, _AnyChildComponent.Id)?
|
||||
fileprivate var transitionUpdate: Transition.Update?
|
||||
fileprivate var transitionAppear: ComponentTransition.Appear?
|
||||
fileprivate var transitionAppearWithGuide: (ComponentTransition.AppearWithGuide, _AnyChildComponent.Id)?
|
||||
fileprivate var transitionDisappear: ComponentTransition.Disappear?
|
||||
fileprivate var transitionDisappearWithGuide: (ComponentTransition.DisappearWithGuide, _AnyChildComponent.Id)?
|
||||
fileprivate var transitionUpdate: ComponentTransition.Update?
|
||||
fileprivate var gestures: [Gesture] = []
|
||||
|
||||
fileprivate init(
|
||||
@ -203,31 +203,31 @@ public final class _UpdatedChildComponent {
|
||||
self.size = size
|
||||
}
|
||||
|
||||
@discardableResult public func appear(_ transition: Transition.Appear) -> _UpdatedChildComponent {
|
||||
@discardableResult public func appear(_ transition: ComponentTransition.Appear) -> _UpdatedChildComponent {
|
||||
self.transitionAppear = transition
|
||||
self.transitionAppearWithGuide = nil
|
||||
return self
|
||||
}
|
||||
|
||||
@discardableResult public func appear(_ transition: Transition.AppearWithGuide, guide: _UpdatedChildComponentGuide) -> _UpdatedChildComponent {
|
||||
@discardableResult public func appear(_ transition: ComponentTransition.AppearWithGuide, guide: _UpdatedChildComponentGuide) -> _UpdatedChildComponent {
|
||||
self.transitionAppear = nil
|
||||
self.transitionAppearWithGuide = (transition, guide.instance.id)
|
||||
return self
|
||||
}
|
||||
|
||||
@discardableResult public func disappear(_ transition: Transition.Disappear) -> _UpdatedChildComponent {
|
||||
@discardableResult public func disappear(_ transition: ComponentTransition.Disappear) -> _UpdatedChildComponent {
|
||||
self.transitionDisappear = transition
|
||||
self.transitionDisappearWithGuide = nil
|
||||
return self
|
||||
}
|
||||
|
||||
@discardableResult public func disappear(_ transition: Transition.DisappearWithGuide, guide: _UpdatedChildComponentGuide) -> _UpdatedChildComponent {
|
||||
@discardableResult public func disappear(_ transition: ComponentTransition.DisappearWithGuide, guide: _UpdatedChildComponentGuide) -> _UpdatedChildComponent {
|
||||
self.transitionDisappear = nil
|
||||
self.transitionDisappearWithGuide = (transition, guide.instance.id)
|
||||
return self
|
||||
}
|
||||
|
||||
@discardableResult public func update(_ transition: Transition.Update) -> _UpdatedChildComponent {
|
||||
@discardableResult public func update(_ transition: ComponentTransition.Update) -> _UpdatedChildComponent {
|
||||
self.transitionUpdate = transition
|
||||
return self
|
||||
}
|
||||
@ -278,7 +278,7 @@ public final class _EnvironmentChildComponent<EnvironmentType>: _AnyChildCompone
|
||||
return .direct(self.directId)
|
||||
}
|
||||
|
||||
func update(component: AnyComponent<EnvironmentType>, @EnvironmentBuilder environment: () -> Environment<EnvironmentType>, availableSize: CGSize, transition: Transition) -> _UpdatedChildComponent {
|
||||
func update(component: AnyComponent<EnvironmentType>, @EnvironmentBuilder environment: () -> Environment<EnvironmentType>, availableSize: CGSize, transition: ComponentTransition) -> _UpdatedChildComponent {
|
||||
let parentContext = _AnyCombinedComponentContext.current
|
||||
if !parentContext.updateContext.configuredViews.insert(self.id).inserted {
|
||||
preconditionFailure("Child component can only be configured once")
|
||||
@ -312,17 +312,17 @@ public final class _EnvironmentChildComponent<EnvironmentType>: _AnyChildCompone
|
||||
}
|
||||
|
||||
public extension _EnvironmentChildComponent where EnvironmentType == Empty {
|
||||
func update(component: AnyComponent<EnvironmentType>, availableSize: CGSize, transition: Transition) -> _UpdatedChildComponent {
|
||||
func update(component: AnyComponent<EnvironmentType>, availableSize: CGSize, transition: ComponentTransition) -> _UpdatedChildComponent {
|
||||
return self.update(component: component, environment: {}, availableSize: availableSize, transition: transition)
|
||||
}
|
||||
}
|
||||
|
||||
public extension _EnvironmentChildComponent {
|
||||
func update<ComponentType: Component>(_ component: ComponentType, @EnvironmentBuilder environment: () -> Environment<EnvironmentType>, availableSize: CGSize, transition: Transition) -> _UpdatedChildComponent where ComponentType.EnvironmentType == EnvironmentType {
|
||||
func update<ComponentType: Component>(_ component: ComponentType, @EnvironmentBuilder environment: () -> Environment<EnvironmentType>, availableSize: CGSize, transition: ComponentTransition) -> _UpdatedChildComponent where ComponentType.EnvironmentType == EnvironmentType {
|
||||
return self.update(component: AnyComponent(component), environment: environment, availableSize: availableSize, transition: transition)
|
||||
}
|
||||
|
||||
func update<ComponentType: Component>(_ component: ComponentType, @EnvironmentBuilder environment: () -> Environment<EnvironmentType>, availableSize: CGSize, transition: Transition) -> _UpdatedChildComponent where ComponentType.EnvironmentType == EnvironmentType, EnvironmentType == Empty {
|
||||
func update<ComponentType: Component>(_ component: ComponentType, @EnvironmentBuilder environment: () -> Environment<EnvironmentType>, availableSize: CGSize, transition: ComponentTransition) -> _UpdatedChildComponent where ComponentType.EnvironmentType == EnvironmentType, EnvironmentType == Empty {
|
||||
return self.update(component: AnyComponent(component), environment: {}, availableSize: availableSize, transition: transition)
|
||||
}
|
||||
}
|
||||
@ -334,7 +334,7 @@ public final class _EnvironmentChildComponentFromMap<EnvironmentType>: _AnyChild
|
||||
self.id = id
|
||||
}
|
||||
|
||||
public func update(component: AnyComponent<EnvironmentType>, @EnvironmentBuilder environment: () -> Environment<EnvironmentType>, availableSize: CGSize, transition: Transition) -> _UpdatedChildComponent {
|
||||
public func update(component: AnyComponent<EnvironmentType>, @EnvironmentBuilder environment: () -> Environment<EnvironmentType>, availableSize: CGSize, transition: ComponentTransition) -> _UpdatedChildComponent {
|
||||
let parentContext = _AnyCombinedComponentContext.current
|
||||
if !parentContext.updateContext.configuredViews.insert(self.id).inserted {
|
||||
preconditionFailure("Child component can only be configured once")
|
||||
@ -368,7 +368,7 @@ public final class _EnvironmentChildComponentFromMap<EnvironmentType>: _AnyChild
|
||||
}
|
||||
|
||||
public extension _EnvironmentChildComponentFromMap where EnvironmentType == Empty {
|
||||
func update(component: AnyComponent<EnvironmentType>, availableSize: CGSize, transition: Transition) -> _UpdatedChildComponent {
|
||||
func update(component: AnyComponent<EnvironmentType>, availableSize: CGSize, transition: ComponentTransition) -> _UpdatedChildComponent {
|
||||
return self.update(component: component, environment: {}, availableSize: availableSize, transition: transition)
|
||||
}
|
||||
}
|
||||
@ -393,7 +393,7 @@ public final class CombinedComponentContext<ComponentType: Component> {
|
||||
|
||||
public let component: ComponentType
|
||||
public let availableSize: CGSize
|
||||
public let transition: Transition
|
||||
public let transition: ComponentTransition
|
||||
private let addImpl: (_ updatedComponent: _UpdatedChildComponent) -> Void
|
||||
|
||||
public var environment: Environment<ComponentType.EnvironmentType> {
|
||||
@ -408,7 +408,7 @@ public final class CombinedComponentContext<ComponentType: Component> {
|
||||
view: UIView,
|
||||
component: ComponentType,
|
||||
availableSize: CGSize,
|
||||
transition: Transition,
|
||||
transition: ComponentTransition,
|
||||
add: @escaping (_ updatedComponent: _UpdatedChildComponent) -> Void
|
||||
) {
|
||||
self.context = context
|
||||
@ -467,8 +467,8 @@ private class _AnyCombinedComponentContext {
|
||||
class ChildView {
|
||||
let view: UIView
|
||||
var index: Int
|
||||
var transition: Transition.Disappear?
|
||||
var transitionWithGuide: (Transition.DisappearWithGuide, _AnyChildComponent.Id)?
|
||||
var transition: ComponentTransition.Disappear?
|
||||
var transitionWithGuide: (ComponentTransition.DisappearWithGuide, _AnyChildComponent.Id)?
|
||||
|
||||
var gestures: [UInt: UIGestureRecognizer] = [:]
|
||||
|
||||
@ -507,15 +507,15 @@ private class _AnyCombinedComponentContext {
|
||||
class DisappearingChildView {
|
||||
let view: UIView
|
||||
let guideId: _AnyChildComponent.Id?
|
||||
let transition: Transition.Disappear?
|
||||
let transitionWithGuide: Transition.DisappearWithGuide?
|
||||
let transition: ComponentTransition.Disappear?
|
||||
let transitionWithGuide: ComponentTransition.DisappearWithGuide?
|
||||
let completion: () -> Void
|
||||
|
||||
init(
|
||||
view: UIView,
|
||||
guideId: _AnyChildComponent.Id?,
|
||||
transition: Transition.Disappear?,
|
||||
transitionWithGuide: Transition.DisappearWithGuide?,
|
||||
transition: ComponentTransition.Disappear?,
|
||||
transitionWithGuide: ComponentTransition.DisappearWithGuide?,
|
||||
completion: @escaping () -> Void
|
||||
) {
|
||||
self.view = view
|
||||
@ -555,39 +555,39 @@ private extension UIView {
|
||||
}
|
||||
}
|
||||
|
||||
public extension Transition {
|
||||
public extension ComponentTransition {
|
||||
final class Appear {
|
||||
private let f: (_UpdatedChildComponent, UIView, Transition) -> Void
|
||||
private let f: (_UpdatedChildComponent, UIView, ComponentTransition) -> Void
|
||||
|
||||
public init(_ f: @escaping (_UpdatedChildComponent, UIView, Transition) -> Void) {
|
||||
public init(_ f: @escaping (_UpdatedChildComponent, UIView, ComponentTransition) -> Void) {
|
||||
self.f = f
|
||||
}
|
||||
|
||||
public func callAsFunction(component: _UpdatedChildComponent, view: UIView, transition: Transition) {
|
||||
public func callAsFunction(component: _UpdatedChildComponent, view: UIView, transition: ComponentTransition) {
|
||||
self.f(component, view, transition)
|
||||
}
|
||||
}
|
||||
|
||||
final class AppearWithGuide {
|
||||
private let f: (_UpdatedChildComponent, UIView, CGPoint, Transition) -> Void
|
||||
private let f: (_UpdatedChildComponent, UIView, CGPoint, ComponentTransition) -> Void
|
||||
|
||||
public init(_ f: @escaping (_UpdatedChildComponent, UIView, CGPoint, Transition) -> Void) {
|
||||
public init(_ f: @escaping (_UpdatedChildComponent, UIView, CGPoint, ComponentTransition) -> Void) {
|
||||
self.f = f
|
||||
}
|
||||
|
||||
public func callAsFunction(component: _UpdatedChildComponent, view: UIView, guide: CGPoint, transition: Transition) {
|
||||
public func callAsFunction(component: _UpdatedChildComponent, view: UIView, guide: CGPoint, transition: ComponentTransition) {
|
||||
self.f(component, view, guide, transition)
|
||||
}
|
||||
}
|
||||
|
||||
final class Disappear {
|
||||
private let f: (UIView, Transition, @escaping () -> Void) -> Void
|
||||
private let f: (UIView, ComponentTransition, @escaping () -> Void) -> Void
|
||||
|
||||
public init(_ f: @escaping (UIView, Transition, @escaping () -> Void) -> Void) {
|
||||
public init(_ f: @escaping (UIView, ComponentTransition, @escaping () -> Void) -> Void) {
|
||||
self.f = f
|
||||
}
|
||||
|
||||
public func callAsFunction(view: UIView, transition: Transition, completion: @escaping () -> Void) {
|
||||
public func callAsFunction(view: UIView, transition: ComponentTransition, completion: @escaping () -> Void) {
|
||||
self.f(view, transition, completion)
|
||||
}
|
||||
}
|
||||
@ -598,26 +598,26 @@ public extension Transition {
|
||||
case update
|
||||
}
|
||||
|
||||
private let f: (Stage, UIView, CGPoint, Transition, @escaping () -> Void) -> Void
|
||||
private let f: (Stage, UIView, CGPoint, ComponentTransition, @escaping () -> Void) -> Void
|
||||
|
||||
public init(_ f: @escaping (Stage, UIView, CGPoint, Transition, @escaping () -> Void) -> Void
|
||||
public init(_ f: @escaping (Stage, UIView, CGPoint, ComponentTransition, @escaping () -> Void) -> Void
|
||||
) {
|
||||
self.f = f
|
||||
}
|
||||
|
||||
public func callAsFunction(stage: Stage, view: UIView, guide: CGPoint, transition: Transition, completion: @escaping () -> Void) {
|
||||
public func callAsFunction(stage: Stage, view: UIView, guide: CGPoint, transition: ComponentTransition, completion: @escaping () -> Void) {
|
||||
self.f(stage, view, guide, transition, completion)
|
||||
}
|
||||
}
|
||||
|
||||
final class Update {
|
||||
private let f: (_UpdatedChildComponent, UIView, Transition) -> Void
|
||||
private let f: (_UpdatedChildComponent, UIView, ComponentTransition) -> Void
|
||||
|
||||
public init(_ f: @escaping (_UpdatedChildComponent, UIView, Transition) -> Void) {
|
||||
public init(_ f: @escaping (_UpdatedChildComponent, UIView, ComponentTransition) -> Void) {
|
||||
self.f = f
|
||||
}
|
||||
|
||||
public func callAsFunction(component: _UpdatedChildComponent, view: UIView, transition: Transition) {
|
||||
public func callAsFunction(component: _UpdatedChildComponent, view: UIView, transition: ComponentTransition) {
|
||||
self.f(component, view, transition)
|
||||
}
|
||||
}
|
||||
@ -628,7 +628,7 @@ public extension CombinedComponent {
|
||||
return UIView()
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: State, environment: Environment<EnvironmentType>, transition: Transition) -> CGSize {
|
||||
func update(view: View, availableSize: CGSize, state: State, environment: Environment<EnvironmentType>, transition: ComponentTransition) -> CGSize {
|
||||
let context = view.getCombinedComponentContext(Self.self)
|
||||
|
||||
let storedBody: Body
|
||||
@ -683,7 +683,7 @@ public extension CombinedComponent {
|
||||
previousView.transition = updatedChild.transitionDisappear
|
||||
previousView.transitionWithGuide = updatedChild.transitionDisappearWithGuide
|
||||
|
||||
(updatedChild.transitionUpdate ?? Transition.Update.default)(component: updatedChild, view: updatedChild.view, transition: transition)
|
||||
(updatedChild.transitionUpdate ?? ComponentTransition.Update.default)(component: updatedChild, view: updatedChild.view, transition: transition)
|
||||
} else {
|
||||
for i in index ..< context.childViewIndices.count {
|
||||
if let moveView = context.childViews[context.childViewIndices[i]] {
|
||||
|
@ -89,13 +89,13 @@ extension UIView {
|
||||
}
|
||||
|
||||
open class ComponentState {
|
||||
open var _updated: ((Transition, Bool) -> Void)?
|
||||
open var _updated: ((ComponentTransition, Bool) -> Void)?
|
||||
var isUpdated: Bool = false
|
||||
|
||||
public init() {
|
||||
}
|
||||
|
||||
public final func updated(transition: Transition = .immediate, isLocal: Bool = false) {
|
||||
public final func updated(transition: ComponentTransition = .immediate, isLocal: Bool = false) {
|
||||
self.isUpdated = true
|
||||
self._updated?(transition, isLocal)
|
||||
}
|
||||
@ -107,7 +107,7 @@ public final class EmptyComponentState: ComponentState {
|
||||
public protocol _TypeErasedComponent {
|
||||
func _makeView() -> UIView
|
||||
func _makeContext() -> _TypeErasedComponentContext
|
||||
func _update(view: UIView, availableSize: CGSize, environment: Any, transition: Transition) -> CGSize
|
||||
func _update(view: UIView, availableSize: CGSize, environment: Any, transition: ComponentTransition) -> CGSize
|
||||
func _isEqual(to other: _TypeErasedComponent) -> Bool
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ public protocol Component: _TypeErasedComponent, Equatable {
|
||||
|
||||
func makeView() -> View
|
||||
func makeState() -> State
|
||||
func update(view: View, availableSize: CGSize, state: State, environment: Environment<EnvironmentType>, transition: Transition) -> CGSize
|
||||
func update(view: View, availableSize: CGSize, state: State, environment: Environment<EnvironmentType>, transition: ComponentTransition) -> CGSize
|
||||
}
|
||||
|
||||
public extension Component {
|
||||
@ -139,7 +139,7 @@ public extension Component {
|
||||
return ComponentContext<Self>(component: self, environment: Environment<EnvironmentType>(), state: self.makeState())
|
||||
}
|
||||
|
||||
func _update(view: UIView, availableSize: CGSize, environment: Any, transition: Transition) -> CGSize {
|
||||
func _update(view: UIView, availableSize: CGSize, environment: Any, transition: ComponentTransition) -> CGSize {
|
||||
let view = view as! Self.View
|
||||
|
||||
return self.update(view: view, availableSize: availableSize, state: view.context(component: self).state, environment: environment as! Environment<EnvironmentType>, transition: transition)
|
||||
@ -191,7 +191,7 @@ public class AnyComponent<EnvironmentType>: _TypeErasedComponent, Equatable {
|
||||
return self.wrapped._makeContext()
|
||||
}
|
||||
|
||||
public func _update(view: UIView, availableSize: CGSize, environment: Any, transition: Transition) -> CGSize {
|
||||
public func _update(view: UIView, availableSize: CGSize, environment: Any, transition: ComponentTransition) -> CGSize {
|
||||
return self.wrapped._update(view: view, availableSize: availableSize, environment: environment as! Environment<EnvironmentType>, transition: transition)
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ public extension UIView {
|
||||
}
|
||||
|
||||
private extension CALayer {
|
||||
func animate(from: AnyObject, to: AnyObject, keyPath: String, duration: Double, delay: Double, curve: Transition.Animation.Curve, removeOnCompletion: Bool, additive: Bool, completion: ((Bool) -> Void)? = nil) {
|
||||
func animate(from: AnyObject, to: AnyObject, keyPath: String, duration: Double, delay: Double, curve: ComponentTransition.Animation.Curve, removeOnCompletion: Bool, additive: Bool, completion: ((Bool) -> Void)? = nil) {
|
||||
let timingFunction: String
|
||||
let mediaTimingFunction: CAMediaTimingFunction?
|
||||
switch curve {
|
||||
@ -44,7 +44,7 @@ private extension CALayer {
|
||||
}
|
||||
}
|
||||
|
||||
private extension Transition.Animation.Curve {
|
||||
private extension ComponentTransition.Animation.Curve {
|
||||
func asTimingFunction() -> CAMediaTimingFunction {
|
||||
switch self {
|
||||
case .easeInOut:
|
||||
@ -59,7 +59,7 @@ private extension Transition.Animation.Curve {
|
||||
}
|
||||
}
|
||||
|
||||
public extension Transition.Animation {
|
||||
public extension ComponentTransition.Animation {
|
||||
var isImmediate: Bool {
|
||||
if case .none = self {
|
||||
return true
|
||||
@ -69,7 +69,7 @@ public extension Transition.Animation {
|
||||
}
|
||||
}
|
||||
|
||||
public struct Transition {
|
||||
public struct ComponentTransition {
|
||||
public enum Animation {
|
||||
public enum Curve {
|
||||
case easeInOut
|
||||
@ -111,19 +111,19 @@ public struct Transition {
|
||||
return nil
|
||||
}
|
||||
|
||||
public func withUserData(_ userData: Any) -> Transition {
|
||||
public func withUserData(_ userData: Any) -> ComponentTransition {
|
||||
var result = self
|
||||
result._userData.append(userData)
|
||||
return result
|
||||
}
|
||||
|
||||
public func withAnimation(_ animation: Animation) -> Transition {
|
||||
public func withAnimation(_ animation: Animation) -> ComponentTransition {
|
||||
var result = self
|
||||
result.animation = animation
|
||||
return result
|
||||
}
|
||||
|
||||
public func withAnimationIfAnimated(_ animation: Animation) -> Transition {
|
||||
public func withAnimationIfAnimated(_ animation: Animation) -> ComponentTransition {
|
||||
switch self.animation {
|
||||
case .none:
|
||||
return self
|
||||
@ -134,14 +134,14 @@ public struct Transition {
|
||||
}
|
||||
}
|
||||
|
||||
public static var immediate: Transition = Transition(animation: .none)
|
||||
public static var immediate: ComponentTransition = ComponentTransition(animation: .none)
|
||||
|
||||
public static func easeInOut(duration: Double) -> Transition {
|
||||
return Transition(animation: .curve(duration: duration, curve: .easeInOut))
|
||||
public static func easeInOut(duration: Double) -> ComponentTransition {
|
||||
return ComponentTransition(animation: .curve(duration: duration, curve: .easeInOut))
|
||||
}
|
||||
|
||||
public static func spring(duration: Double) -> Transition {
|
||||
return Transition(animation: .curve(duration: duration, curve: .spring))
|
||||
public static func spring(duration: Double) -> ComponentTransition {
|
||||
return ComponentTransition(animation: .curve(duration: duration, curve: .spring))
|
||||
}
|
||||
|
||||
public init(animation: Animation) {
|
||||
@ -1184,7 +1184,7 @@ public struct Transition {
|
||||
}
|
||||
}
|
||||
|
||||
public func animateContentsImage(layer: CALayer, from fromImage: CGImage, to toImage: CGImage, duration: Double, curve: Transition.Animation.Curve, completion: ((Bool) -> Void)? = nil) {
|
||||
public func animateContentsImage(layer: CALayer, from fromImage: CGImage, to toImage: CGImage, duration: Double, curve: ComponentTransition.Animation.Curve, completion: ((Bool) -> Void)? = nil) {
|
||||
layer.animate(
|
||||
from: fromImage,
|
||||
to: toImage,
|
||||
|
@ -154,7 +154,7 @@ public final class Button: Component {
|
||||
}
|
||||
}
|
||||
|
||||
private func updateAlpha(transition: Transition) {
|
||||
private func updateAlpha(transition: ComponentTransition) {
|
||||
guard let component = self.component else {
|
||||
return
|
||||
}
|
||||
@ -271,7 +271,7 @@ public final class Button: Component {
|
||||
super.cancelTracking(with: event)
|
||||
}
|
||||
|
||||
func update(component: Button, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(component: Button, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
let contentSize = self.contentView.update(
|
||||
transition: transition,
|
||||
component: component.content,
|
||||
@ -301,7 +301,7 @@ public final class Button: 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 {
|
||||
view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public final class Circle: Component {
|
||||
var component: Circle?
|
||||
var currentSize: CGSize?
|
||||
|
||||
func update(component: Circle, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
func update(component: Circle, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
let size = CGSize(width: min(availableSize.width, component.size.width), height: min(availableSize.height, component.size.height))
|
||||
|
||||
if self.currentSize != size || self.component != component {
|
||||
@ -63,7 +63,7 @@ public final class Circle: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
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, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public final class Image: Component {
|
||||
preconditionFailure()
|
||||
}
|
||||
|
||||
func update(component: Image, availableSize: CGSize, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(component: Image, availableSize: CGSize, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
self.image = component.image
|
||||
self.contentMode = component.contentMode
|
||||
|
||||
@ -63,7 +63,7 @@ public final class Image: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
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, environment: environment, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,9 @@ public final class List<ChildEnvironment: Equatable>: CombinedComponent {
|
||||
private let items: [AnyComponentWithIdentity<ChildEnvironment>]
|
||||
private let direction: Direction
|
||||
private let centerAlignment: Bool
|
||||
private let appear: Transition.Appear
|
||||
private let appear: ComponentTransition.Appear
|
||||
|
||||
public init(_ items: [AnyComponentWithIdentity<ChildEnvironment>], direction: Direction = .vertical, centerAlignment: Bool = false, appear: Transition.Appear = .default()) {
|
||||
public init(_ items: [AnyComponentWithIdentity<ChildEnvironment>], direction: Direction = .vertical, centerAlignment: Bool = false, appear: ComponentTransition.Appear = .default()) {
|
||||
self.items = items
|
||||
self.direction = direction
|
||||
self.centerAlignment = centerAlignment
|
||||
|
@ -53,7 +53,7 @@ public final class Rectangle: 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 {
|
||||
var size = availableSize
|
||||
if let width = self.width {
|
||||
size.width = min(size.width, width)
|
||||
|
@ -47,7 +47,7 @@ public final class RoundedRectangle: Component {
|
||||
public final class View: UIImageView {
|
||||
var component: RoundedRectangle?
|
||||
|
||||
func update(component: RoundedRectangle, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
func update(component: RoundedRectangle, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
if self.component != component {
|
||||
let cornerRadius = component.cornerRadius ?? min(availableSize.width, availableSize.height) * 0.5
|
||||
|
||||
@ -113,7 +113,7 @@ public final class RoundedRectangle: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
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, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public final class Text: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -37,13 +37,13 @@ public final class ComponentHostView<EnvironmentType>: UIView {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
public func update(transition: Transition, component: AnyComponent<EnvironmentType>, @EnvironmentBuilder environment: () -> Environment<EnvironmentType>, forceUpdate: Bool = false, containerSize: CGSize) -> CGSize {
|
||||
public func update(transition: ComponentTransition, component: AnyComponent<EnvironmentType>, @EnvironmentBuilder environment: () -> Environment<EnvironmentType>, forceUpdate: Bool = false, containerSize: CGSize) -> CGSize {
|
||||
let size = self._update(transition: transition, component: component, maybeEnvironment: environment, updateEnvironment: true, forceUpdate: forceUpdate, containerSize: containerSize)
|
||||
self.currentSize = size
|
||||
return size
|
||||
}
|
||||
|
||||
private func _update(transition: Transition, component: AnyComponent<EnvironmentType>, maybeEnvironment: () -> Environment<EnvironmentType>, updateEnvironment: Bool, forceUpdate: Bool, containerSize: CGSize) -> CGSize {
|
||||
private func _update(transition: ComponentTransition, component: AnyComponent<EnvironmentType>, maybeEnvironment: () -> Environment<EnvironmentType>, updateEnvironment: Bool, forceUpdate: Bool, containerSize: CGSize) -> CGSize {
|
||||
precondition(!self.isUpdating)
|
||||
self.isUpdating = true
|
||||
|
||||
@ -150,13 +150,13 @@ public final class ComponentView<EnvironmentType> {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
public func update(transition: Transition, component: AnyComponent<EnvironmentType>, @EnvironmentBuilder environment: () -> Environment<EnvironmentType>, forceUpdate: Bool = false, containerSize: CGSize) -> CGSize {
|
||||
public func update(transition: ComponentTransition, component: AnyComponent<EnvironmentType>, @EnvironmentBuilder environment: () -> Environment<EnvironmentType>, forceUpdate: Bool = false, containerSize: CGSize) -> CGSize {
|
||||
let size = self._update(transition: transition, component: component, maybeEnvironment: environment, updateEnvironment: true, forceUpdate: forceUpdate, containerSize: containerSize)
|
||||
self.currentSize = size
|
||||
return size
|
||||
}
|
||||
|
||||
public func updateEnvironment(transition: Transition, @EnvironmentBuilder environment: () -> Environment<EnvironmentType>) -> CGSize? {
|
||||
public func updateEnvironment(transition: ComponentTransition, @EnvironmentBuilder environment: () -> Environment<EnvironmentType>) -> CGSize? {
|
||||
guard let currentComponent = self.currentComponent, let currentContainerSize = self.currentContainerSize else {
|
||||
return nil
|
||||
}
|
||||
@ -165,7 +165,7 @@ public final class ComponentView<EnvironmentType> {
|
||||
return size
|
||||
}
|
||||
|
||||
private func _update(transition: Transition, component: AnyComponent<EnvironmentType>, maybeEnvironment: () -> Environment<EnvironmentType>, updateEnvironment: Bool, forceUpdate: Bool, containerSize: CGSize) -> CGSize {
|
||||
private func _update(transition: ComponentTransition, component: AnyComponent<EnvironmentType>, maybeEnvironment: () -> Environment<EnvironmentType>, updateEnvironment: Bool, forceUpdate: Bool, containerSize: CGSize) -> CGSize {
|
||||
precondition(!self.isUpdating)
|
||||
self.isUpdating = true
|
||||
|
||||
|
@ -27,7 +27,7 @@ public final class ActivityIndicatorComponent: Component {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func update(component: ActivityIndicatorComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
func update(component: ActivityIndicatorComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
if component.color != self.color {
|
||||
self.color = component.color
|
||||
}
|
||||
@ -44,7 +44,7 @@ public final class ActivityIndicatorComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
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, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public final class AnimatedStickerComponent: Component {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func update(component: AnimatedStickerComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
func update(component: AnimatedStickerComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
if self.component?.animation != component.animation {
|
||||
self.animationNode?.view.removeFromSuperview()
|
||||
|
||||
@ -145,7 +145,7 @@ public final class AnimatedStickerComponent: 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, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ public final class BalancedTextComponent: Component {
|
||||
return self.textView.attributeSubstring(name: name, index: index)
|
||||
}
|
||||
|
||||
public func update(component: BalancedTextComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
public func update(component: BalancedTextComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
let attributedString: NSAttributedString
|
||||
switch component.text {
|
||||
case let .plain(string):
|
||||
@ -203,7 +203,7 @@ public final class BalancedTextComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
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, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public final class BlurredBackgroundComponent: Component {
|
||||
private var tintContainerView: UIView?
|
||||
private var vibrancyEffectView: UIVisualEffectView?
|
||||
|
||||
public func update(component: BlurredBackgroundComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
public func update(component: BlurredBackgroundComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
self.updateColor(color: component.color, transition: transition.containedViewLayoutTransition)
|
||||
|
||||
self.update(size: availableSize, cornerRadius: component.cornerRadius, transition: transition.containedViewLayoutTransition)
|
||||
@ -56,7 +56,7 @@ public final class BlurredBackgroundComponent: Component {
|
||||
return View(color: nil, enableBlur: true)
|
||||
}
|
||||
|
||||
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, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public final class BundleIconComponent: Component {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func update(component: BundleIconComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
func update(component: BundleIconComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
if self.component?.name != component.name || self.component?.tintColor != component.tintColor {
|
||||
if let tintColor = component.tintColor {
|
||||
self.image = generateTintedImage(image: UIImage(bundleImageName: component.name), color: tintColor, backgroundColor: nil)
|
||||
@ -62,7 +62,7 @@ public final class BundleIconComponent: 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, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import UIKit
|
||||
import ComponentFlow
|
||||
import Display
|
||||
|
||||
public extension Transition.Animation.Curve {
|
||||
public extension ComponentTransition.Animation.Curve {
|
||||
init(_ curve: ContainedViewLayoutTransitionCurve) {
|
||||
switch curve {
|
||||
case .linear:
|
||||
@ -33,13 +33,13 @@ public extension Transition.Animation.Curve {
|
||||
}
|
||||
}
|
||||
|
||||
public extension Transition {
|
||||
public extension ComponentTransition {
|
||||
init(_ transition: ContainedViewLayoutTransition) {
|
||||
switch transition {
|
||||
case .immediate:
|
||||
self.init(animation: .none)
|
||||
case let .animated(duration, curve):
|
||||
self.init(animation: .curve(duration: duration, curve: Transition.Animation.Curve(curve)))
|
||||
self.init(animation: .curve(duration: duration, curve: ComponentTransition.Animation.Curve(curve)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ public final class CreditCardInputComponent: Component {
|
||||
}
|
||||
}
|
||||
|
||||
func update(component: CreditCardInputComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(component: CreditCardInputComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
switch component.dataType {
|
||||
case .cardNumber:
|
||||
self.textField.autoFormattingBehavior = .cardNumbers
|
||||
@ -166,7 +166,7 @@ public final class CreditCardInputComponent: 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)
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public final class PrefixSectionGroupComponent: Component {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func update(component: PrefixSectionGroupComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(component: PrefixSectionGroupComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
let spacing: CGFloat = 16.0
|
||||
let sideInset: CGFloat = 16.0
|
||||
|
||||
@ -188,7 +188,7 @@ public final class PrefixSectionGroupComponent: 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)
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public final class TextInputComponent: Component {
|
||||
self.component?.updated(self.text ?? "")
|
||||
}
|
||||
|
||||
func update(component: TextInputComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(component: TextInputComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
self.font = UIFont.systemFont(ofSize: 17.0)
|
||||
self.textColor = component.textColor
|
||||
|
||||
@ -80,7 +80,7 @@ public final class TextInputComponent: 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)
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ public final class LottieAnimationComponent: Component {
|
||||
}
|
||||
}
|
||||
|
||||
func update(component: LottieAnimationComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
func update(component: LottieAnimationComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
var updatePlayback = false
|
||||
var updateColors = false
|
||||
|
||||
@ -319,7 +319,7 @@ public final class LottieAnimationComponent: 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, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ public final class MultilineTextComponent: Component {
|
||||
}
|
||||
|
||||
public final class View: ImmediateTextView {
|
||||
public func update(component: MultilineTextComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
public func update(component: MultilineTextComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
let attributedString: NSAttributedString
|
||||
switch component.text {
|
||||
case let .plain(string):
|
||||
@ -169,7 +169,7 @@ public final class MultilineTextComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
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, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ public final class MultilineTextWithEntitiesComponent: Component {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
public func update(component: MultilineTextWithEntitiesComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
public func update(component: MultilineTextWithEntitiesComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
let attributedString: NSAttributedString
|
||||
switch component.text {
|
||||
case let .plain(string):
|
||||
@ -205,7 +205,7 @@ public final class MultilineTextWithEntitiesComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
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, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ open class PagerExternalTopPanelContainer: SparseContainerView {
|
||||
}
|
||||
|
||||
public protocol PagerContentViewWithBackground: UIView {
|
||||
func pagerUpdateBackground(backgroundFrame: CGRect, topPanelHeight: CGFloat, transition: Transition)
|
||||
func pagerUpdateBackground(backgroundFrame: CGRect, topPanelHeight: CGFloat, transition: ComponentTransition)
|
||||
}
|
||||
|
||||
public final class PagerComponentChildEnvironment: Equatable {
|
||||
@ -24,7 +24,7 @@ public final class PagerComponentChildEnvironment: Equatable {
|
||||
public var absoluteOffsetToBottomEdge: CGFloat?
|
||||
public var isReset: Bool
|
||||
public var isInteracting: Bool
|
||||
public var transition: Transition
|
||||
public var transition: ComponentTransition
|
||||
|
||||
public init(
|
||||
relativeOffset: CGFloat,
|
||||
@ -32,7 +32,7 @@ public final class PagerComponentChildEnvironment: Equatable {
|
||||
absoluteOffsetToBottomEdge: CGFloat?,
|
||||
isReset: Bool,
|
||||
isInteracting: Bool,
|
||||
transition: Transition
|
||||
transition: ComponentTransition
|
||||
) {
|
||||
self.relativeOffset = relativeOffset
|
||||
self.absoluteOffsetToTopEdge = absoluteOffsetToTopEdge
|
||||
@ -78,8 +78,8 @@ public final class PagerComponentPanelEnvironment<TopPanelEnvironment>: Equatabl
|
||||
public let contentAccessoryRightButtons: [AnyComponentWithIdentity<Empty>]
|
||||
public let activeContentId: AnyHashable?
|
||||
public let navigateToContentId: (AnyHashable) -> Void
|
||||
public let visibilityFractionUpdated: ActionSlot<(CGFloat, Transition)>
|
||||
public let isExpandedUpdated: (Bool, Transition) -> Void
|
||||
public let visibilityFractionUpdated: ActionSlot<(CGFloat, ComponentTransition)>
|
||||
public let isExpandedUpdated: (Bool, ComponentTransition) -> Void
|
||||
|
||||
init(
|
||||
isContentInFocus: Bool,
|
||||
@ -90,8 +90,8 @@ public final class PagerComponentPanelEnvironment<TopPanelEnvironment>: Equatabl
|
||||
contentAccessoryRightButtons: [AnyComponentWithIdentity<Empty>],
|
||||
activeContentId: AnyHashable?,
|
||||
navigateToContentId: @escaping (AnyHashable) -> Void,
|
||||
visibilityFractionUpdated: ActionSlot<(CGFloat, Transition)>,
|
||||
isExpandedUpdated: @escaping (Bool, Transition) -> Void
|
||||
visibilityFractionUpdated: ActionSlot<(CGFloat, ComponentTransition)>,
|
||||
isExpandedUpdated: @escaping (Bool, ComponentTransition) -> Void
|
||||
) {
|
||||
self.isContentInFocus = isContentInFocus
|
||||
self.contentOffset = contentOffset
|
||||
@ -206,9 +206,9 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
|
||||
public let externalTopPanelContainer: PagerExternalTopPanelContainer?
|
||||
public let bottomPanel: AnyComponent<PagerComponentPanelEnvironment<TopPanelEnvironment>>?
|
||||
public let externalBottomPanelContainer: PagerExternalTopPanelContainer?
|
||||
public let panelStateUpdated: ((PagerComponentPanelState, Transition) -> Void)?
|
||||
public let isTopPanelExpandedUpdated: (Bool, Transition) -> Void
|
||||
public let isTopPanelHiddenUpdated: (Bool, Transition) -> Void
|
||||
public let panelStateUpdated: ((PagerComponentPanelState, ComponentTransition) -> Void)?
|
||||
public let isTopPanelExpandedUpdated: (Bool, ComponentTransition) -> Void
|
||||
public let isTopPanelHiddenUpdated: (Bool, ComponentTransition) -> Void
|
||||
public let contentIdUpdated: (AnyHashable) -> Void
|
||||
public let panelHideBehavior: PagerComponentPanelHideBehavior
|
||||
public let clipContentToTopPanel: Bool
|
||||
@ -228,9 +228,9 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
|
||||
externalTopPanelContainer: PagerExternalTopPanelContainer?,
|
||||
bottomPanel: AnyComponent<PagerComponentPanelEnvironment<TopPanelEnvironment>>?,
|
||||
externalBottomPanelContainer: PagerExternalTopPanelContainer?,
|
||||
panelStateUpdated: ((PagerComponentPanelState, Transition) -> Void)?,
|
||||
isTopPanelExpandedUpdated: @escaping (Bool, Transition) -> Void,
|
||||
isTopPanelHiddenUpdated: @escaping (Bool, Transition) -> Void,
|
||||
panelStateUpdated: ((PagerComponentPanelState, ComponentTransition) -> Void)?,
|
||||
isTopPanelExpandedUpdated: @escaping (Bool, ComponentTransition) -> Void,
|
||||
isTopPanelHiddenUpdated: @escaping (Bool, ComponentTransition) -> Void,
|
||||
contentIdUpdated: @escaping (AnyHashable) -> Void,
|
||||
panelHideBehavior: PagerComponentPanelHideBehavior,
|
||||
clipContentToTopPanel: Bool,
|
||||
@ -329,9 +329,9 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
|
||||
private var contentClippingView: UIView
|
||||
private var contentViews: [AnyHashable: ContentView] = [:]
|
||||
private var contentBackgroundView: ComponentHostView<Empty>?
|
||||
private let topPanelVisibilityFractionUpdated = ActionSlot<(CGFloat, Transition)>()
|
||||
private let topPanelVisibilityFractionUpdated = ActionSlot<(CGFloat, ComponentTransition)>()
|
||||
private var topPanelView: ComponentHostView<PagerComponentPanelEnvironment<TopPanelEnvironment>>?
|
||||
private let bottomPanelVisibilityFractionUpdated = ActionSlot<(CGFloat, Transition)>()
|
||||
private let bottomPanelVisibilityFractionUpdated = ActionSlot<(CGFloat, ComponentTransition)>()
|
||||
private var bottomPanelView: ComponentHostView<PagerComponentPanelEnvironment<TopPanelEnvironment>>?
|
||||
|
||||
private var topPanelHeight: CGFloat?
|
||||
@ -440,9 +440,9 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
|
||||
}
|
||||
|
||||
if updateTopPanelExpanded {
|
||||
self.isTopPanelExpandedUpdated(isExpanded: false, transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
self.isTopPanelExpandedUpdated(isExpanded: false, transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
} else {
|
||||
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
}
|
||||
if let centralId = self.centralId {
|
||||
self.component?.contentIdUpdated(centralId)
|
||||
@ -472,7 +472,7 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
|
||||
/*paneTransitionGestureState.fraction = 1.0
|
||||
|
||||
self.paneTransitionGestureState = paneTransitionGestureState
|
||||
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))*/
|
||||
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))*/
|
||||
|
||||
self.centralId = id
|
||||
|
||||
@ -484,19 +484,19 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
|
||||
}
|
||||
|
||||
if updateTopPanelExpanded {
|
||||
self.isTopPanelExpandedUpdated(isExpanded: false, transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
self.isTopPanelExpandedUpdated(isExpanded: false, transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
} else {
|
||||
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
}
|
||||
self.component?.contentIdUpdated(id)
|
||||
}
|
||||
|
||||
func update(component: PagerComponent<ChildEnvironmentType, TopPanelEnvironment>, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: Transition) -> CGSize {
|
||||
func update(component: PagerComponent<ChildEnvironmentType, TopPanelEnvironment>, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: ComponentTransition) -> CGSize {
|
||||
let previousPanelHideBehavior = self.component?.panelHideBehavior
|
||||
|
||||
var panelStateTransition = transition
|
||||
if let previousPanelHideBehavior = previousPanelHideBehavior, previousPanelHideBehavior != component.panelHideBehavior, panelStateTransition.animation.isImmediate {
|
||||
panelStateTransition = Transition(animation: .curve(duration: 0.3, curve: .spring))
|
||||
panelStateTransition = ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))
|
||||
}
|
||||
|
||||
self.component = component
|
||||
@ -1005,7 +1005,7 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
|
||||
|
||||
if self.isTopPanelExpanded {
|
||||
self.isTopPanelExpanded = false
|
||||
self.component?.isTopPanelExpandedUpdated(self.isTopPanelExpanded, Transition(animation: .curve(duration: 0.25, curve: .easeInOut)))
|
||||
self.component?.isTopPanelExpandedUpdated(self.isTopPanelExpanded, ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1017,12 +1017,12 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
|
||||
|
||||
if contentView.wantsExclusiveMode != wantsExclusiveMode {
|
||||
contentView.wantsExclusiveMode = wantsExclusiveMode
|
||||
//self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
self.component?.isTopPanelHiddenUpdated(wantsExclusiveMode, Transition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
//self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
self.component?.isTopPanelHiddenUpdated(wantsExclusiveMode, ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
}
|
||||
}
|
||||
|
||||
private func isTopPanelExpandedUpdated(isExpanded: Bool, transition: Transition) {
|
||||
private func isTopPanelExpandedUpdated(isExpanded: Bool, transition: ComponentTransition) {
|
||||
if self.isTopPanelExpanded == isExpanded {
|
||||
return
|
||||
}
|
||||
@ -1036,7 +1036,7 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
|
||||
return
|
||||
}
|
||||
|
||||
self.isTopPanelExpandedUpdated(isExpanded: false, transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
self.isTopPanelExpandedUpdated(isExpanded: false, transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
}
|
||||
}
|
||||
|
||||
@ -1044,7 +1044,7 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
|
||||
return View(frame: CGRect())
|
||||
}
|
||||
|
||||
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: Transition) -> CGSize {
|
||||
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: ComponentTransition) -> CGSize {
|
||||
return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public final class ProgressIndicatorComponent: Component {
|
||||
return CAShapeLayer.self
|
||||
}
|
||||
|
||||
func update(component: ProgressIndicatorComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
func update(component: ProgressIndicatorComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
let lineWidth: CGFloat = 1.33
|
||||
let size = CGSize(width: component.diameter, height: component.diameter)
|
||||
|
||||
@ -107,7 +107,7 @@ public final class ProgressIndicatorComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
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, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ public final class SheetComponent<ChildEnvironmentType: Equatable>: Component {
|
||||
|
||||
private var currentHasInputHeight = false
|
||||
private var currentAvailableSize: CGSize?
|
||||
func update(component: SheetComponent<ChildEnvironmentType>, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: Transition) -> CGSize {
|
||||
func update(component: SheetComponent<ChildEnvironmentType>, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: ComponentTransition) -> CGSize {
|
||||
let previousHasInputHeight = self.currentHasInputHeight
|
||||
let sheetEnvironment = environment[SheetComponentEnvironment.self].value
|
||||
component.animateOut.connect { [weak self] completion in
|
||||
@ -424,7 +424,7 @@ public final class SheetComponent<ChildEnvironmentType: Equatable>: Component {
|
||||
return View(frame: CGRect())
|
||||
}
|
||||
|
||||
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: Transition) -> CGSize {
|
||||
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: ComponentTransition) -> CGSize {
|
||||
return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public final class SolidRoundedButtonComponent: Component {
|
||||
|
||||
private var currentIsLoading = false
|
||||
|
||||
public func update(component: SolidRoundedButtonComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
public func update(component: SolidRoundedButtonComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
if self.button == nil {
|
||||
let button = SolidRoundedButtonView(
|
||||
title: component.title,
|
||||
@ -182,7 +182,7 @@ public final class SolidRoundedButtonComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
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, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public final class UndoPanelComponent: Component {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
public func update(component: UndoPanelComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
public func update(component: UndoPanelComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
self.effect = UIBlurEffect(style: .dark)
|
||||
|
||||
self.layer.cornerRadius = 10.0
|
||||
@ -61,7 +61,7 @@ public final class UndoPanelComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
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, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -22,14 +22,14 @@ public final class UndoPanelContainerComponent: Component {
|
||||
|
||||
private var nextPanel: UndoPanelComponent?
|
||||
|
||||
public func update(component: UndoPanelContainerComponent, availableSize: CGSize, state: EmptyComponentState, transition: Transition) -> CGSize {
|
||||
public func update(component: UndoPanelContainerComponent, availableSize: CGSize, state: EmptyComponentState, transition: ComponentTransition) -> CGSize {
|
||||
component.push.connect { [weak self, weak state] panel in
|
||||
guard let strongSelf = self, let state = state else {
|
||||
return
|
||||
}
|
||||
|
||||
strongSelf.nextPanel = panel
|
||||
state.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
state.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
}
|
||||
|
||||
var animateTopPanelIn = false
|
||||
@ -77,7 +77,7 @@ public final class UndoPanelContainerComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
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, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ open class ViewControllerComponentContainer: ViewController {
|
||||
self.view.addSubview(self.hostView)
|
||||
}
|
||||
|
||||
func containerLayoutUpdated(layout: ContainerViewLayout, navigationHeight: CGFloat, transition: Transition) {
|
||||
func containerLayoutUpdated(layout: ContainerViewLayout, navigationHeight: CGFloat, transition: ComponentTransition) {
|
||||
self.currentLayout = (layout, navigationHeight)
|
||||
|
||||
let environment = ViewControllerComponentContainer.Environment(
|
||||
@ -206,10 +206,10 @@ open class ViewControllerComponentContainer: ViewController {
|
||||
guard let currentLayout = self.currentLayout else {
|
||||
return
|
||||
}
|
||||
self.containerLayoutUpdated(layout: currentLayout.layout, navigationHeight: currentLayout.navigationHeight, transition: animated ? Transition(animation: .none).withUserData(isVisible ? AnimateInTransition() : AnimateOutTransition()) : .immediate)
|
||||
self.containerLayoutUpdated(layout: currentLayout.layout, navigationHeight: currentLayout.navigationHeight, transition: animated ? ComponentTransition(animation: .none).withUserData(isVisible ? AnimateInTransition() : AnimateOutTransition()) : .immediate)
|
||||
}
|
||||
|
||||
func updateComponent(component: AnyComponent<ViewControllerComponentContainer.Environment>, transition: Transition) {
|
||||
func updateComponent(component: AnyComponent<ViewControllerComponentContainer.Environment>, transition: ComponentTransition) {
|
||||
self.component = component
|
||||
|
||||
guard let currentLayout = self.currentLayout else {
|
||||
@ -369,10 +369,10 @@ open class ViewControllerComponentContainer: ViewController {
|
||||
let navigationHeight = self.navigationLayout(layout: layout).navigationFrame.maxY
|
||||
|
||||
self.validLayout = layout
|
||||
self.node.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: Transition(transition))
|
||||
self.node.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(transition))
|
||||
}
|
||||
|
||||
public func updateComponent(component: AnyComponent<ViewControllerComponentContainer.Environment>, transition: Transition) {
|
||||
public func updateComponent(component: AnyComponent<ViewControllerComponentContainer.Environment>, transition: ComponentTransition) {
|
||||
self.node.updateComponent(component: component, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ final class ComposePollScreenComponent: Component {
|
||||
}
|
||||
}
|
||||
|
||||
private func updateScrolling(transition: Transition) {
|
||||
private func updateScrolling(transition: ComponentTransition) {
|
||||
let navigationAlphaDistance: CGFloat = 16.0
|
||||
let navigationAlpha: CGFloat = max(0.0, min(1.0, self.scrollView.contentOffset.y / navigationAlphaDistance))
|
||||
if let controller = self.environment?.controller(), let navigationBar = controller.navigationBar {
|
||||
@ -297,7 +297,7 @@ final class ComposePollScreenComponent: Component {
|
||||
effectiveInputHeight: CGFloat,
|
||||
metrics: LayoutMetrics,
|
||||
deviceMetrics: DeviceMetrics,
|
||||
transition: Transition
|
||||
transition: ComponentTransition
|
||||
) -> CGFloat {
|
||||
let bottomInset: CGFloat = bottomInset + 8.0
|
||||
let bottomContainerInset: CGFloat = 0.0
|
||||
@ -377,8 +377,8 @@ final class ComposePollScreenComponent: Component {
|
||||
|
||||
if needsInputActivation {
|
||||
let inputNodeFrame = inputNodeFrame.offsetBy(dx: 0.0, dy: inputNodeHeight)
|
||||
Transition.immediate.setFrame(layer: inputMediaNode.layer, frame: inputNodeFrame)
|
||||
Transition.immediate.setFrame(layer: self.inputMediaNodeBackground, frame: inputNodeBackgroundFrame)
|
||||
ComponentTransition.immediate.setFrame(layer: inputMediaNode.layer, frame: inputNodeFrame)
|
||||
ComponentTransition.immediate.setFrame(layer: self.inputMediaNodeBackground, frame: inputNodeBackgroundFrame)
|
||||
}
|
||||
|
||||
if animateIn {
|
||||
@ -472,7 +472,7 @@ final class ComposePollScreenComponent: Component {
|
||||
return textInputStates
|
||||
}
|
||||
|
||||
func update(component: ComposePollScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: Transition) -> CGSize {
|
||||
func update(component: ComposePollScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: ComponentTransition) -> CGSize {
|
||||
self.isUpdating = true
|
||||
defer {
|
||||
self.isUpdating = false
|
||||
@ -622,7 +622,7 @@ final class ComposePollScreenComponent: Component {
|
||||
return
|
||||
}
|
||||
if !self.isUpdating {
|
||||
self.state?.updated(transition: Transition(transition))
|
||||
self.state?.updated(transition: ComponentTransition(transition))
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -1458,7 +1458,7 @@ final class ComposePollScreenComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: Transition) -> CGSize {
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: ComponentTransition) -> CGSize {
|
||||
return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -173,12 +173,12 @@ public final class ListComposePollOptionComponent: Component {
|
||||
self.layer.removeAnimation(forKey: "transform.scale")
|
||||
|
||||
if animateScale {
|
||||
let transition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut))
|
||||
let transition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut))
|
||||
transition.setScale(layer: self.layer, scale: topScale)
|
||||
}
|
||||
} else {
|
||||
if animateScale {
|
||||
let transition = Transition(animation: .none)
|
||||
let transition = ComponentTransition(animation: .none)
|
||||
transition.setScale(layer: self.layer, scale: 1.0)
|
||||
|
||||
self.layer.animateScale(from: topScale, to: maxScale, duration: 0.13, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, removeOnCompletion: false, completion: { [weak self] _ in
|
||||
@ -202,7 +202,7 @@ public final class ListComposePollOptionComponent: Component {
|
||||
self.action?()
|
||||
}
|
||||
|
||||
func update(size: CGSize, theme: PresentationTheme, isSelected: Bool, transition: Transition) {
|
||||
func update(size: CGSize, theme: PresentationTheme, isSelected: Bool, transition: ComponentTransition) {
|
||||
let checkLayer: CheckLayer
|
||||
if let current = self.checkLayer {
|
||||
checkLayer = current
|
||||
@ -291,7 +291,7 @@ public final class ListComposePollOptionComponent: Component {
|
||||
}
|
||||
}
|
||||
|
||||
func update(component: ListComposePollOptionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(component: ListComposePollOptionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
self.isUpdating = true
|
||||
defer {
|
||||
self.isUpdating = false
|
||||
@ -455,12 +455,12 @@ public final class ListComposePollOptionComponent: Component {
|
||||
)
|
||||
let modeSelectorFrame = CGRect(origin: CGPoint(x: size.width - 4.0 - modeSelectorSize.width, y: floor((size.height - modeSelectorSize.height) * 0.5)), size: modeSelectorSize)
|
||||
if let modeSelectorView = modeSelector.view as? PlainButtonComponent.View {
|
||||
let alphaTransition: Transition = .easeInOut(duration: 0.2)
|
||||
let alphaTransition: ComponentTransition = .easeInOut(duration: 0.2)
|
||||
|
||||
if modeSelectorView.superview == nil {
|
||||
self.addSubview(modeSelectorView)
|
||||
Transition.immediate.setAlpha(view: modeSelectorView, alpha: 0.0)
|
||||
Transition.immediate.setScale(view: modeSelectorView, scale: 0.001)
|
||||
ComponentTransition.immediate.setAlpha(view: modeSelectorView, alpha: 0.0)
|
||||
ComponentTransition.immediate.setScale(view: modeSelectorView, scale: 0.001)
|
||||
}
|
||||
|
||||
if playAnimation, let animationView = modeSelectorView.contentView as? LottieComponent.View {
|
||||
@ -481,7 +481,7 @@ public final class ListComposePollOptionComponent: Component {
|
||||
self.modeSelector = nil
|
||||
if let modeSelectorView = modeSelector.view {
|
||||
if !transition.animation.isImmediate {
|
||||
let alphaTransition: Transition = .easeInOut(duration: 0.2)
|
||||
let alphaTransition: ComponentTransition = .easeInOut(duration: 0.2)
|
||||
alphaTransition.setAlpha(view: modeSelectorView, alpha: 0.0, completion: { [weak modeSelectorView] _ in
|
||||
modeSelectorView?.removeFromSuperview()
|
||||
})
|
||||
@ -497,7 +497,7 @@ public final class ListComposePollOptionComponent: Component {
|
||||
return size
|
||||
}
|
||||
|
||||
public func updateCustomPlaceholder(value: String, size: CGSize, transition: Transition) {
|
||||
public func updateCustomPlaceholder(value: String, size: CGSize, transition: ComponentTransition) {
|
||||
guard let component = self.component else {
|
||||
return
|
||||
}
|
||||
@ -554,7 +554,7 @@ public final class ListComposePollOptionComponent: 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)
|
||||
}
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ final class ContactsControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
|
||||
)
|
||||
|
||||
let navigationBarSize = self.navigationBarView.update(
|
||||
transition: Transition(transition),
|
||||
transition: ComponentTransition(transition),
|
||||
component: AnyComponent(ChatListNavigationBar(
|
||||
context: self.context,
|
||||
theme: self.presentationData.theme,
|
||||
@ -420,7 +420,7 @@ final class ContactsControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
|
||||
}
|
||||
|
||||
if let navigationBarComponentView = self.navigationBarView.view as? ChatListNavigationBar.View {
|
||||
navigationBarComponentView.applyScroll(offset: offset, allowAvatarsExpansion: false, transition: Transition(transition))
|
||||
navigationBarComponentView.applyScroll(offset: offset, allowAvatarsExpansion: false, transition: ComponentTransition(transition))
|
||||
}
|
||||
}
|
||||
|
||||
@ -450,7 +450,7 @@ final class ContactsControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
|
||||
|
||||
if let navigationBarComponentView = self.navigationBarView.view as? ChatListNavigationBar.View {
|
||||
navigationBarComponentView.deferScrollApplication = false
|
||||
navigationBarComponentView.applyCurrentScroll(transition: Transition(transition))
|
||||
navigationBarComponentView.applyCurrentScroll(transition: ComponentTransition(transition))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1131,7 +1131,7 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
|
||||
lineWidth: 1.33,
|
||||
inactiveLineWidth: 1.33
|
||||
),
|
||||
transition: animated ? Transition(animation: .curve(duration: 0.25, curve: .easeInOut)) : .immediate
|
||||
transition: animated ? ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut)) : .immediate
|
||||
)
|
||||
|
||||
if strongSelf.avatarTapRecognizer == nil {
|
||||
|
@ -635,7 +635,7 @@ final class ContextSourceContainer: ASDisplayNode {
|
||||
return TabSelectorComponent.Item(id: source.id, title: source.title)
|
||||
}
|
||||
let tabSelectorSize = tabSelector.update(
|
||||
transition: Transition(transition),
|
||||
transition: ComponentTransition(transition),
|
||||
component: AnyComponent(TabSelectorComponent(
|
||||
colors: TabSelectorComponent.Colors(
|
||||
foreground: presentationData.theme.contextMenu.primaryColor.withMultipliedAlpha(0.8),
|
||||
@ -678,7 +678,7 @@ final class ContextSourceContainer: ASDisplayNode {
|
||||
}
|
||||
|
||||
let closeButtonSize = closeButton.update(
|
||||
transition: Transition(transition),
|
||||
transition: ComponentTransition(transition),
|
||||
component: AnyComponent(PlainButtonComponent(
|
||||
content: AnyComponent(
|
||||
CloseButtonComponent(
|
||||
|
@ -1990,12 +1990,6 @@ extension CGRect: AnyValueProviding {
|
||||
}
|
||||
}
|
||||
|
||||
extension CATransform3D: Equatable {
|
||||
public static func ==(lhs: CATransform3D, rhs: CATransform3D) -> Bool {
|
||||
return CATransform3DEqualToTransform(lhs, rhs)
|
||||
}
|
||||
}
|
||||
|
||||
extension CATransform3D: AnyValueProviding {
|
||||
func interpolate(with other: CATransform3D, fraction: CGFloat) -> CATransform3D {
|
||||
return CATransform3D(
|
||||
@ -2025,7 +2019,7 @@ extension CATransform3D: AnyValueProviding {
|
||||
stringValue: { "\(self)" },
|
||||
isEqual: { other in
|
||||
if let otherValue = other.value as? CATransform3D {
|
||||
return self == otherValue
|
||||
return CATransform3DEqualToTransform(self, otherValue)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
@ -2112,7 +2106,7 @@ final class ControlledTransitionProperty {
|
||||
return "MyCustomAnimation_\(Unmanaged.passUnretained(self).toOpaque())"
|
||||
}()
|
||||
|
||||
init<T: Equatable>(layer: CALayer, path: String, fromValue: T, toValue: T, completion: ((Bool) -> Void)?) where T: AnyValueProviding {
|
||||
init<T>(layer: CALayer, path: String, fromValue: T, toValue: T, completion: ((Bool) -> Void)?) where T: AnyValueProviding {
|
||||
self.layer = layer
|
||||
self.path = path
|
||||
self.fromValue = fromValue.anyValue
|
||||
@ -2333,7 +2327,7 @@ public final class ControlledTransition {
|
||||
}
|
||||
|
||||
public func updateTransform(layer: CALayer, transform: CATransform3D, completion: ((Bool) -> Void)?) {
|
||||
if layer.transform == transform {
|
||||
if CATransform3DEqualToTransform(layer.transform, transform) {
|
||||
return
|
||||
}
|
||||
let fromValue: CATransform3D
|
||||
|
@ -15,7 +15,7 @@ public struct KeyShortcut: Hashable {
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(self.input)
|
||||
hasher.combine(self.modifiers)
|
||||
hasher.combine(self.modifiers.rawValue)
|
||||
}
|
||||
|
||||
public static func ==(lhs: KeyShortcut, rhs: KeyShortcut) -> Bool {
|
||||
@ -23,12 +23,6 @@ public struct KeyShortcut: Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
extension UIKeyModifierFlags: Hashable {
|
||||
public var hashValue: Int {
|
||||
return self.rawValue
|
||||
}
|
||||
}
|
||||
|
||||
extension KeyShortcut {
|
||||
var uiKeyCommand: UIKeyCommand {
|
||||
let command = UIKeyCommand(input: self.input, modifierFlags: self.modifiers, action: #selector(KeyShortcutsController.handleKeyCommand(_:)), discoverabilityTitle: self.title)
|
||||
|
@ -306,7 +306,7 @@ private class ColorSliderComponent: Component {
|
||||
return View(frame: CGRect())
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
view.updated = self.updated
|
||||
return view.updateLayout(size: availableSize, leftColor: self.leftColor, rightColor: self.rightColor, currentColor: self.currentColor, value: self.value)
|
||||
}
|
||||
@ -456,7 +456,7 @@ private class ColorFieldComponent: Component {
|
||||
return View(frame: CGRect())
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
view.updated = self.updated
|
||||
return view.updateLayout(size: availableSize, component: self)
|
||||
}
|
||||
@ -548,7 +548,7 @@ private class ColorPreviewComponent: Component {
|
||||
return View(frame: CGRect())
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
return view.updateLayout(size: availableSize, color: self.color)
|
||||
}
|
||||
}
|
||||
@ -724,7 +724,7 @@ final class ColorGridComponent: Component {
|
||||
return View(frame: CGRect())
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
view.selected = self.selected
|
||||
return view.updateLayout(size: availableSize, selectedColor: self.color)
|
||||
}
|
||||
@ -935,7 +935,7 @@ final class ColorSpectrumComponent: Component {
|
||||
return View(frame: CGRect())
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
view.selected = self.selected
|
||||
return view.updateLayout(size: availableSize, selectedColor: self.color)
|
||||
}
|
||||
@ -1533,7 +1533,7 @@ private class SegmentedControlComponent: Component {
|
||||
preconditionFailure()
|
||||
}
|
||||
|
||||
func update(component: SegmentedControlComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
func update(component: SegmentedControlComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
self.node.items = component.values.map { SegmentedControlItem(title: $0) }
|
||||
self.node.selectedIndex = component.selectedIndex
|
||||
let selectionChanged = component.selectionChanged
|
||||
@ -1556,7 +1556,7 @@ private class SegmentedControlComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
return view.update(component: self, availableSize: availableSize, transition: transition)
|
||||
}
|
||||
}
|
||||
@ -1748,7 +1748,7 @@ final class ColorSwatchComponent: Component {
|
||||
self.contentView.layer.animateScale(from: 1.0, to: 0.01, duration: 0.3)
|
||||
}
|
||||
|
||||
func update(component: ColorSwatchComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(component: ColorSwatchComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
self.component = component
|
||||
let contentSize: CGSize
|
||||
if case .pallete = component.type {
|
||||
@ -1850,7 +1850,7 @@ final class ColorSwatchComponent: 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)
|
||||
}
|
||||
}
|
||||
|
@ -811,7 +811,7 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView {
|
||||
break
|
||||
}
|
||||
|
||||
let transition = Transition.easeInOut(duration: 0.2)
|
||||
let transition = ComponentTransition.easeInOut(duration: 0.2)
|
||||
if isTrappedInBin, let binView = self.bin.view {
|
||||
if !selectedEntityView.isTrappedInBin {
|
||||
let refs = [
|
||||
@ -908,7 +908,7 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView {
|
||||
self.bringSubviewToFront(binView)
|
||||
}
|
||||
binView.frame = binFrame
|
||||
Transition.easeInOut(duration: 0.2).setAlpha(view: binView, alpha: location != nil ? 1.0 : 0.0, delay: location == nil && wasOpened ? 0.4 : 0.0)
|
||||
ComponentTransition.easeInOut(duration: 0.2).setAlpha(view: binView, alpha: location != nil ? 1.0 : 0.0, delay: location == nil && wasOpened ? 0.4 : 0.0)
|
||||
}
|
||||
return isOpened
|
||||
}
|
||||
@ -1176,7 +1176,7 @@ private final class EntityBinComponent: Component {
|
||||
}
|
||||
|
||||
private var wasOpened = false
|
||||
func update(component: EntityBinComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(component: EntityBinComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
self.component = component
|
||||
self.state = state
|
||||
|
||||
@ -1221,7 +1221,7 @@ private final class EntityBinComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ public class DrawingReactionEntityView: DrawingStickerEntityView {
|
||||
reactionContextNode.updateLayout(size: availableSize, insets: insets, anchorRect: anchorRect, centerAligned: true, isCoveredByInput: false, isAnimatingOut: false, transition: transition)
|
||||
}
|
||||
|
||||
let reactionContextNodeTransition: Transition = .immediate
|
||||
let reactionContextNodeTransition: ComponentTransition = .immediate
|
||||
let reactionContextNode: ReactionContextNode
|
||||
reactionContextNode = ReactionContextNode(
|
||||
context: self.context,
|
||||
|
@ -416,7 +416,7 @@ private final class BlurredGradientComponent: Component {
|
||||
private var gradientMask = UIImageView()
|
||||
private var gradientForeground = SimpleGradientLayer()
|
||||
|
||||
public func update(component: BlurredGradientComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
public func update(component: BlurredGradientComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
self.component = component
|
||||
|
||||
self.isUserInteractionEnabled = false
|
||||
@ -452,7 +452,7 @@ private final class BlurredGradientComponent: Component {
|
||||
return View(color: nil, enableBlur: true)
|
||||
}
|
||||
|
||||
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, transition: transition)
|
||||
}
|
||||
}
|
||||
@ -1303,12 +1303,12 @@ private final class DrawingScreenComponent: CombinedComponent {
|
||||
)
|
||||
context.add(textSettings
|
||||
.position(CGPoint(x: context.availableSize.width / 2.0, y: context.availableSize.height - environment.safeInsets.bottom - textSettings.size.height / 2.0 - 89.0 - additionalBottomInset))
|
||||
.appear(Transition.Appear({ _, view, transition in
|
||||
.appear(ComponentTransition.Appear({ _, view, transition in
|
||||
if let view = view as? TextSettingsComponent.View, !transition.animation.isImmediate {
|
||||
view.animateIn()
|
||||
}
|
||||
}))
|
||||
.disappear(Transition.Disappear({ view, transition, completion in
|
||||
.disappear(ComponentTransition.Disappear({ view, transition, completion in
|
||||
if let view = view as? TextSettingsComponent.View, !transition.animation.isImmediate {
|
||||
view.animateOut(completion: completion)
|
||||
} else {
|
||||
@ -1353,11 +1353,11 @@ private final class DrawingScreenComponent: CombinedComponent {
|
||||
)
|
||||
context.add(swatch1Button
|
||||
.position(CGPoint(x: offsetX, y: context.availableSize.height - environment.safeInsets.bottom - swatch1Button.size.height / 2.0 - 57.0 - additionalBottomInset))
|
||||
.appear(Transition.Appear { _, view, transition in
|
||||
.appear(ComponentTransition.Appear { _, view, transition in
|
||||
transition.animateScale(view: view, from: 0.1, to: 1.0)
|
||||
transition.animateAlpha(view: view, from: 0.0, to: 1.0)
|
||||
})
|
||||
.disappear(Transition.Disappear { view, transition, completion in
|
||||
.disappear(ComponentTransition.Disappear { view, transition, completion in
|
||||
transition.setScale(view: view, scale: 0.1)
|
||||
transition.setAlpha(view: view, alpha: 0.0, completion: { _ in
|
||||
completion()
|
||||
@ -1381,11 +1381,11 @@ private final class DrawingScreenComponent: CombinedComponent {
|
||||
)
|
||||
context.add(swatch2Button
|
||||
.position(CGPoint(x: offsetX, y: context.availableSize.height - environment.safeInsets.bottom - swatch2Button.size.height / 2.0 - 57.0 - additionalBottomInset))
|
||||
.appear(Transition.Appear { _, view, transition in
|
||||
.appear(ComponentTransition.Appear { _, view, transition in
|
||||
transition.animateScale(view: view, from: 0.1, to: 1.0, delay: 0.025)
|
||||
transition.animateAlpha(view: view, from: 0.0, to: 1.0, delay: 0.025)
|
||||
})
|
||||
.disappear(Transition.Disappear { view, transition, completion in
|
||||
.disappear(ComponentTransition.Disappear { view, transition, completion in
|
||||
transition.setScale(view: view, scale: 0.1)
|
||||
transition.setAlpha(view: view, alpha: 0.0, completion: { _ in
|
||||
completion()
|
||||
@ -1409,11 +1409,11 @@ private final class DrawingScreenComponent: CombinedComponent {
|
||||
)
|
||||
context.add(swatch3Button
|
||||
.position(CGPoint(x: offsetX, y: context.availableSize.height - environment.safeInsets.bottom - swatch3Button.size.height / 2.0 - 57.0 - additionalBottomInset))
|
||||
.appear(Transition.Appear { _, view, transition in
|
||||
.appear(ComponentTransition.Appear { _, view, transition in
|
||||
transition.animateScale(view: view, from: 0.1, to: 1.0, delay: 0.05)
|
||||
transition.animateAlpha(view: view, from: 0.0, to: 1.0, delay: 0.05)
|
||||
})
|
||||
.disappear(Transition.Disappear { view, transition, completion in
|
||||
.disappear(ComponentTransition.Disappear { view, transition, completion in
|
||||
transition.setScale(view: view, scale: 0.1)
|
||||
transition.setAlpha(view: view, alpha: 0.0, completion: { _ in
|
||||
completion()
|
||||
@ -1437,11 +1437,11 @@ private final class DrawingScreenComponent: CombinedComponent {
|
||||
)
|
||||
context.add(swatch4Button
|
||||
.position(CGPoint(x: offsetX, y: context.availableSize.height - environment.safeInsets.bottom - swatch4Button.size.height / 2.0 - 57.0 - additionalBottomInset))
|
||||
.appear(Transition.Appear { _, view, transition in
|
||||
.appear(ComponentTransition.Appear { _, view, transition in
|
||||
transition.animateScale(view: view, from: 0.1, to: 1.0, delay: 0.075)
|
||||
transition.animateAlpha(view: view, from: 0.0, to: 1.0, delay: 0.075)
|
||||
})
|
||||
.disappear(Transition.Disappear { view, transition, completion in
|
||||
.disappear(ComponentTransition.Disappear { view, transition, completion in
|
||||
transition.setScale(view: view, scale: 0.1)
|
||||
transition.setAlpha(view: view, alpha: 0.0, completion: { _ in
|
||||
completion()
|
||||
@ -1465,11 +1465,11 @@ private final class DrawingScreenComponent: CombinedComponent {
|
||||
)
|
||||
context.add(swatch5Button
|
||||
.position(CGPoint(x: offsetX, y: context.availableSize.height - environment.safeInsets.bottom - swatch5Button.size.height / 2.0 - 57.0 - additionalBottomInset))
|
||||
.appear(Transition.Appear { _, view, transition in
|
||||
.appear(ComponentTransition.Appear { _, view, transition in
|
||||
transition.animateScale(view: view, from: 0.1, to: 1.0, delay: 0.1)
|
||||
transition.animateAlpha(view: view, from: 0.0, to: 1.0, delay: 0.1)
|
||||
})
|
||||
.disappear(Transition.Disappear { view, transition, completion in
|
||||
.disappear(ComponentTransition.Disappear { view, transition, completion in
|
||||
transition.setScale(view: view, scale: 0.1)
|
||||
transition.setAlpha(view: view, alpha: 0.0, completion: { _ in
|
||||
completion()
|
||||
@ -1494,11 +1494,11 @@ private final class DrawingScreenComponent: CombinedComponent {
|
||||
)
|
||||
context.add(swatch6Button
|
||||
.position(CGPoint(x: offsetX, y: context.availableSize.height - environment.safeInsets.bottom - swatch6Button.size.height / 2.0 - 57.0 - additionalBottomInset))
|
||||
.appear(Transition.Appear { _, view, transition in
|
||||
.appear(ComponentTransition.Appear { _, view, transition in
|
||||
transition.animateScale(view: view, from: 0.1, to: 1.0, delay: 0.125)
|
||||
transition.animateAlpha(view: view, from: 0.0, to: 1.0, delay: 0.125)
|
||||
})
|
||||
.disappear(Transition.Disappear { view, transition, completion in
|
||||
.disappear(ComponentTransition.Disappear { view, transition, completion in
|
||||
transition.setScale(view: view, scale: 0.1)
|
||||
transition.setAlpha(view: view, alpha: 0.0, completion: { _ in
|
||||
completion()
|
||||
@ -1522,11 +1522,11 @@ private final class DrawingScreenComponent: CombinedComponent {
|
||||
)
|
||||
context.add(swatch7Button
|
||||
.position(CGPoint(x: offsetX, y: context.availableSize.height - environment.safeInsets.bottom - swatch7Button.size.height / 2.0 - 57.0 - additionalBottomInset))
|
||||
.appear(Transition.Appear { _, view, transition in
|
||||
.appear(ComponentTransition.Appear { _, view, transition in
|
||||
transition.animateScale(view: view, from: 0.1, to: 1.0, delay: 0.15)
|
||||
transition.animateAlpha(view: view, from: 0.0, to: 1.0, delay: 0.15)
|
||||
})
|
||||
.disappear(Transition.Disappear { view, transition, completion in
|
||||
.disappear(ComponentTransition.Disappear { view, transition, completion in
|
||||
transition.setScale(view: view, scale: 0.1)
|
||||
transition.setAlpha(view: view, alpha: 0.0, completion: { _ in
|
||||
completion()
|
||||
@ -1550,11 +1550,11 @@ private final class DrawingScreenComponent: CombinedComponent {
|
||||
)
|
||||
context.add(swatch8Button
|
||||
.position(CGPoint(x: offsetX, y: context.availableSize.height - environment.safeInsets.bottom - swatch7Button.size.height / 2.0 - 57.0 - additionalBottomInset))
|
||||
.appear(Transition.Appear { _, view, transition in
|
||||
.appear(ComponentTransition.Appear { _, view, transition in
|
||||
transition.animateScale(view: view, from: 0.1, to: 1.0, delay: 0.175)
|
||||
transition.animateAlpha(view: view, from: 0.0, to: 1.0, delay: 0.175)
|
||||
})
|
||||
.disappear(Transition.Disappear { view, transition, completion in
|
||||
.disappear(ComponentTransition.Disappear { view, transition, completion in
|
||||
transition.setScale(view: view, scale: 0.1)
|
||||
transition.setAlpha(view: view, alpha: 0.0, completion: { _ in
|
||||
completion()
|
||||
@ -1592,12 +1592,12 @@ private final class DrawingScreenComponent: CombinedComponent {
|
||||
)
|
||||
context.add(tools
|
||||
.position(CGPoint(x: context.availableSize.width / 2.0, y: context.availableSize.height - environment.safeInsets.bottom - tools.size.height / 2.0 - 78.0 - additionalBottomInset))
|
||||
.appear(Transition.Appear({ _, view, transition in
|
||||
.appear(ComponentTransition.Appear({ _, view, transition in
|
||||
if let view = view as? ToolsComponent.View, !transition.animation.isImmediate {
|
||||
view.animateIn(completion: {})
|
||||
}
|
||||
}))
|
||||
.disappear(Transition.Disappear({ view, transition, completion in
|
||||
.disappear(ComponentTransition.Disappear({ view, transition, completion in
|
||||
if let view = view as? ToolsComponent.View, !transition.animation.isImmediate {
|
||||
view.animateOut(completion: completion)
|
||||
} else {
|
||||
@ -2012,13 +2012,13 @@ private final class DrawingScreenComponent: CombinedComponent {
|
||||
}
|
||||
context.add(doneButton
|
||||
.position(doneButtonPosition)
|
||||
.appear(Transition.Appear { _, view, transition in
|
||||
.appear(ComponentTransition.Appear { _, view, transition in
|
||||
transition.animateScale(view: view, from: 0.1, to: 1.0)
|
||||
transition.animateAlpha(view: view, from: 0.0, to: 1.0)
|
||||
|
||||
transition.animatePosition(view: view, from: CGPoint(x: 12.0, y: 0.0), to: CGPoint(), additive: true)
|
||||
})
|
||||
.disappear(Transition.Disappear { view, transition, completion in
|
||||
.disappear(ComponentTransition.Disappear { view, transition, completion in
|
||||
transition.setScale(view: view, scale: 0.1)
|
||||
transition.setAlpha(view: view, alpha: 0.0, completion: { _ in
|
||||
completion()
|
||||
@ -2614,13 +2614,13 @@ public class DrawingScreen: ViewController, TGPhotoDrawingInterfaceController, U
|
||||
return result
|
||||
}
|
||||
|
||||
func requestUpdate(transition: Transition = .immediate) {
|
||||
func requestUpdate(transition: ComponentTransition = .immediate) {
|
||||
if let (layout, orientation) = self.validLayout {
|
||||
self.containerLayoutUpdated(layout: layout, orientation: orientation, transition: transition)
|
||||
}
|
||||
}
|
||||
|
||||
func containerLayoutUpdated(layout: ContainerViewLayout, orientation: UIInterfaceOrientation?, forceUpdate: Bool = false, animateOut: Bool = false, transition: Transition) {
|
||||
func containerLayoutUpdated(layout: ContainerViewLayout, orientation: UIInterfaceOrientation?, forceUpdate: Bool = false, animateOut: Bool = false, transition: ComponentTransition) {
|
||||
guard let controller = self.controller else {
|
||||
return
|
||||
}
|
||||
@ -2922,7 +2922,7 @@ public class DrawingScreen: ViewController, TGPhotoDrawingInterfaceController, U
|
||||
override public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
||||
super.containerLayoutUpdated(layout, transition: transition)
|
||||
|
||||
(self.displayNode as! Node).containerLayoutUpdated(layout: layout, orientation: self.orientation, transition: Transition(transition))
|
||||
(self.displayNode as! Node).containerLayoutUpdated(layout: layout, orientation: self.orientation, transition: ComponentTransition(transition))
|
||||
}
|
||||
|
||||
public func adapterContainerLayoutUpdatedSize(_ size: CGSize, intrinsicInsets: UIEdgeInsets, safeInsets: UIEdgeInsets, statusBarHeight: CGFloat, inputHeight: CGFloat, orientation: UIInterfaceOrientation, isRegular: Bool, animated: Bool) {
|
||||
@ -3534,7 +3534,7 @@ public final class DrawingToolsInteraction {
|
||||
}
|
||||
}
|
||||
|
||||
public func containerLayoutUpdated(layout: ContainerViewLayout, transition: Transition) {
|
||||
public func containerLayoutUpdated(layout: ContainerViewLayout, transition: ComponentTransition) {
|
||||
self.validLayout = layout
|
||||
|
||||
guard self.isActive else {
|
||||
|
@ -1045,7 +1045,7 @@ public final class DrawingView: UIView, UIGestureRecognizerDelegate, UIPencilInt
|
||||
}
|
||||
|
||||
func setBrushSizePreview(_ size: CGFloat?) {
|
||||
let transition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut))
|
||||
let transition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut))
|
||||
if let size = size {
|
||||
let minLineWidth = max(1.0, max(self.frame.width, self.frame.height) * 0.002)
|
||||
let maxLineWidth = max(10.0, max(self.frame.width, self.frame.height) * 0.07)
|
||||
|
@ -181,7 +181,7 @@ final class ModeAndSizeComponent: Component {
|
||||
self.backgroundNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3)
|
||||
}
|
||||
|
||||
func update(component: ModeAndSizeComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
func update(component: ModeAndSizeComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
self.component = component
|
||||
|
||||
self.updated = component.sizeUpdated
|
||||
@ -259,7 +259,7 @@ final class ModeAndSizeComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
return view.update(component: self, availableSize: availableSize, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ final class TextAlignmentComponent: Component {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func update(component: TextAlignmentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(component: TextAlignmentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
let height = 2.0 - UIScreenPixel
|
||||
let spacing: CGFloat = 3.0 + UIScreenPixel
|
||||
let long = 21.0
|
||||
@ -175,7 +175,7 @@ final class TextAlignmentComponent: 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)
|
||||
}
|
||||
}
|
||||
@ -228,7 +228,7 @@ final class TextFontComponent: Component {
|
||||
}
|
||||
}
|
||||
|
||||
func update(component: TextFontComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(component: TextFontComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
self.component = component
|
||||
|
||||
if self.icon.contents == nil {
|
||||
@ -281,7 +281,7 @@ final class TextFontComponent: 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)
|
||||
}
|
||||
}
|
||||
@ -530,7 +530,7 @@ final class TextSettingsComponent: CombinedComponent {
|
||||
)
|
||||
context.add(styleButton
|
||||
.position(CGPoint(x: offset + styleButton.size.width / 2.0, y: context.availableSize.height / 2.0))
|
||||
.update(Transition.Update { _, view, transition in
|
||||
.update(ComponentTransition.Update { _, view, transition in
|
||||
if let snapshot = view.snapshotView(afterScreenUpdates: false) {
|
||||
transition.setAlpha(view: snapshot, alpha: 0.0, completion: { [weak snapshot] _ in
|
||||
snapshot?.removeFromSuperview()
|
||||
@ -749,7 +749,7 @@ public final class TextSizeSliderComponent: Component {
|
||||
return true
|
||||
}
|
||||
|
||||
func updateLayout(size: CGSize, component: TextSizeSliderComponent, transition: Transition) -> CGSize {
|
||||
func updateLayout(size: CGSize, component: TextSizeSliderComponent, transition: ComponentTransition) -> CGSize {
|
||||
self.component = component
|
||||
|
||||
let previousSize = self.validSize
|
||||
@ -797,7 +797,7 @@ public final class TextSizeSliderComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
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 {
|
||||
view.updated = self.updated
|
||||
view.released = self.released
|
||||
return view.updateLayout(size: availableSize, component: self, transition: transition)
|
||||
|
@ -295,7 +295,7 @@ final class ToolsComponent: Component {
|
||||
}
|
||||
|
||||
func animateOut(completion: @escaping () -> Void) {
|
||||
let transition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut))
|
||||
let transition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut))
|
||||
var delay = 0.0
|
||||
for i in 0 ..< self.toolViews.count {
|
||||
let view = self.toolViews[i]
|
||||
@ -306,7 +306,7 @@ final class ToolsComponent: Component {
|
||||
}
|
||||
}
|
||||
|
||||
func update(component: ToolsComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(component: ToolsComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
self.component = component
|
||||
|
||||
if self.toolViews.isEmpty {
|
||||
@ -467,7 +467,7 @@ final class ToolsComponent: 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)
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class GeneralLinesChartController: BaseLinesChartController {
|
||||
|
||||
private var prevoiusHorizontalStrideInterval: Int = 1
|
||||
|
||||
private (set) var chartLines: [LinesChartRenderer.LineData] = []
|
||||
private(set) var chartLines: [LinesChartRenderer.LineData] = []
|
||||
|
||||
override public init(chartsCollection: ChartsCollection) {
|
||||
self.initialChartCollection = chartsCollection
|
||||
|
@ -25,7 +25,7 @@ class BarsComponentController: GeneralChartComponentController {
|
||||
let previewBarsChartRenderer: BarChartRenderer
|
||||
private(set) var barsWidth: CGFloat = 1
|
||||
|
||||
private (set) var chartBars: BarChartRenderer.BarsData = .blank
|
||||
private(set) var chartBars: BarChartRenderer.BarsData = .blank
|
||||
|
||||
private var step: Bool
|
||||
|
||||
|
@ -16,7 +16,7 @@ import UIKit
|
||||
private let milionsScale = "M"
|
||||
private let thousandsScale = "K"
|
||||
|
||||
class ScalesNumberFormatter: NumberFormatter {
|
||||
class ScalesNumberFormatter: NumberFormatter, @unchecked Sendable {
|
||||
override func string(from number: NSNumber) -> String? {
|
||||
let value = number.doubleValue
|
||||
let pow = log10(value)
|
||||
@ -36,7 +36,7 @@ class ScalesNumberFormatter: NumberFormatter {
|
||||
}
|
||||
}
|
||||
|
||||
class TonNumberFormatter: NumberFormatter {
|
||||
class TonNumberFormatter: NumberFormatter, @unchecked Sendable {
|
||||
override func string(from number: NSNumber) -> String? {
|
||||
var balanceText = "\(number.intValue)"
|
||||
let decimalSeparator = self.decimalSeparator ?? "."
|
||||
|
@ -94,7 +94,7 @@ class ChartVisibilityView: UIView {
|
||||
}
|
||||
}
|
||||
|
||||
private (set) var selectedItems: [Bool] = []
|
||||
private(set) var selectedItems: [Bool] = []
|
||||
var isExpanded: Bool = true {
|
||||
didSet {
|
||||
invalidateIntrinsicContentSize()
|
||||
|
@ -457,7 +457,7 @@ final class HashtagSearchControllerNode: ASDisplayNode, ASGestureRecognizerDeleg
|
||||
var topInset: CGFloat = insets.top - 89.0
|
||||
if let state = self.globalStorySearchState {
|
||||
let componentView: ComponentView<Empty>
|
||||
var panelTransition = Transition(transition)
|
||||
var panelTransition = ComponentTransition(transition)
|
||||
if let current = self.globalStorySearchComponentView {
|
||||
componentView = current
|
||||
} else {
|
||||
|
@ -143,7 +143,7 @@ final class HashtagSearchNavigationContentNode: NavigationBarContentNode {
|
||||
items.append(TabSelectorComponent.Item(id: AnyHashable(2), title: self.strings.HashtagSearch_PublicPosts))
|
||||
|
||||
let tabSelectorSize = self.tabSelector.update(
|
||||
transition: Transition(transition),
|
||||
transition: ComponentTransition(transition),
|
||||
component: AnyComponent(TabSelectorComponent(
|
||||
colors: TabSelectorComponent.Colors(
|
||||
foreground: self.theme.list.itemSecondaryTextColor,
|
||||
|
@ -212,7 +212,7 @@ final class InstantPageDetailsArrowNode : ASDisplayNode {
|
||||
self.setNeedsDisplay()
|
||||
}
|
||||
}
|
||||
private (set) var open: Bool
|
||||
private(set) var open: Bool
|
||||
|
||||
private var progress: CGFloat = 0.0
|
||||
private var targetProgress: CGFloat?
|
||||
|
@ -57,7 +57,7 @@ public final class ItemListControllerSegmentedTitleView: UIView {
|
||||
self.update(transition: .immediate)
|
||||
}
|
||||
|
||||
private func update(transition: Transition) {
|
||||
private func update(transition: ComponentTransition) {
|
||||
guard let size = self.validLayout else {
|
||||
return
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ final class ItemListControllerTabsContentNode: NavigationBarContentNode {
|
||||
}
|
||||
|
||||
let tabSelectorSize = self.tabSelector.update(
|
||||
transition: Transition(transition),
|
||||
transition: ComponentTransition(transition),
|
||||
component: AnyComponent(TabSelectorComponent(
|
||||
colors: TabSelectorComponent.Colors(
|
||||
foreground: self.theme.list.itemSecondaryTextColor,
|
||||
|
@ -297,7 +297,7 @@ final class JoinLinkPreviewPeerContentNode: ASDisplayNode, ShareContentContainer
|
||||
let animationRenderer = self.context.animationRenderer
|
||||
|
||||
let avatarIcon: ComponentView<Empty>
|
||||
var avatarIconTransition = Transition(transition)
|
||||
var avatarIconTransition = ComponentTransition(transition)
|
||||
if let current = self.avatarIcon {
|
||||
avatarIcon = current
|
||||
} else {
|
||||
|
@ -610,8 +610,16 @@ public final class LegacyPaintStickersContext: NSObject, TGPhotoPaintStickersCon
|
||||
}
|
||||
}
|
||||
|
||||
#if swift(>=6.0)
|
||||
extension SolidRoundedButtonView: @retroactive TGPhotoSolidRoundedButtonView {
|
||||
public func updateWidth(_ width: CGFloat) {
|
||||
let _ = self.updateLayout(width: width, transition: .immediate)
|
||||
}
|
||||
}
|
||||
#else
|
||||
extension SolidRoundedButtonView: TGPhotoSolidRoundedButtonView {
|
||||
public func updateWidth(_ width: CGFloat) {
|
||||
let _ = self.updateLayout(width: width, transition: .immediate)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -369,7 +369,7 @@ public final class ListMessageFileItemNode: ListMessageNode {
|
||||
private var absoluteLocation: (CGRect, CGSize)?
|
||||
|
||||
private var context: AccountContext?
|
||||
private (set) var message: Message?
|
||||
private(set) var message: Message?
|
||||
|
||||
private var appliedItem: ListMessageItem?
|
||||
private var layoutParams: ListViewItemLayoutParams?
|
||||
|
@ -126,7 +126,67 @@ private func generateProximityDim(size: CGSize) -> UIImage {
|
||||
})!
|
||||
}
|
||||
|
||||
public final class LocationMapNode: ASDisplayNode, MKMapViewDelegate {
|
||||
protocol MKMapViewDelegateTarget: AnyObject {
|
||||
func mapView(_ mapView: MKMapView, regionWillChangeAnimated animated: Bool)
|
||||
func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool)
|
||||
func mapView(_ mapView: MKMapView, didUpdate userLocation: MKUserLocation)
|
||||
func mapView(_ mapView: MKMapView, didFailToLocateUserWithError error: Error)
|
||||
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView?
|
||||
func mapView(_ mapView: MKMapView, didAdd views: [MKAnnotationView])
|
||||
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView)
|
||||
func mapView(_ mapView: MKMapView, didDeselect view: MKAnnotationView)
|
||||
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer
|
||||
}
|
||||
|
||||
private final class MKMapViewDelegateImpl: NSObject, MKMapViewDelegate {
|
||||
private weak var target: MKMapViewDelegateTarget?
|
||||
|
||||
init(target: MKMapViewDelegateTarget) {
|
||||
self.target = target
|
||||
|
||||
super.init()
|
||||
}
|
||||
|
||||
func mapView(_ mapView: MKMapView, regionWillChangeAnimated animated: Bool) {
|
||||
self.target?.mapView(mapView, regionWillChangeAnimated: animated)
|
||||
}
|
||||
|
||||
func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) {
|
||||
self.target?.mapView(mapView, regionDidChangeAnimated: animated)
|
||||
}
|
||||
|
||||
func mapView(_ mapView: MKMapView, didUpdate userLocation: MKUserLocation) {
|
||||
self.target?.mapView(mapView, didUpdate: userLocation)
|
||||
}
|
||||
|
||||
func mapView(_ mapView: MKMapView, didFailToLocateUserWithError error: Error) {
|
||||
self.target?.mapView(mapView, didFailToLocateUserWithError: error)
|
||||
}
|
||||
|
||||
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
|
||||
return self.target?.mapView(mapView, viewFor: annotation)
|
||||
}
|
||||
|
||||
func mapView(_ mapView: MKMapView, didAdd views: [MKAnnotationView]) {
|
||||
self.target?.mapView(mapView, didAdd: views)
|
||||
}
|
||||
|
||||
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
|
||||
self.target?.mapView(mapView, didSelect: view)
|
||||
}
|
||||
|
||||
func mapView(_ mapView: MKMapView, didDeselect view: MKAnnotationView) {
|
||||
self.target?.mapView(mapView, didDeselect: view)
|
||||
}
|
||||
|
||||
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
|
||||
return self.target?.mapView(mapView, rendererFor: overlay) ?? MKOverlayRenderer()
|
||||
}
|
||||
}
|
||||
|
||||
public final class LocationMapNode: ASDisplayNode, MKMapViewDelegateTarget {
|
||||
private var delegateImpl: MKMapViewDelegateImpl?
|
||||
|
||||
public static let defaultMapSpan = MKCoordinateSpan(latitudeDelta: 0.016, longitudeDelta: 0.016)
|
||||
public static let viewMapSpan = MKCoordinateSpan(latitudeDelta: 0.008, longitudeDelta: 0.008)
|
||||
|
||||
@ -256,7 +316,10 @@ public final class LocationMapNode: ASDisplayNode, MKMapViewDelegate {
|
||||
return self?.disableHorizontalTransitionGesture == true
|
||||
}
|
||||
|
||||
self.mapView?.delegate = self
|
||||
let delegateImpl = MKMapViewDelegateImpl(target: self)
|
||||
self.delegateImpl = delegateImpl
|
||||
|
||||
self.mapView?.delegate = delegateImpl
|
||||
self.mapView?.mapType = self.mapMode.mapType
|
||||
self.mapView?.isRotateEnabled = self.isRotateEnabled
|
||||
self.mapView?.showsUserLocation = true
|
||||
|
@ -69,19 +69,19 @@ private enum LocationPickerEntry: Comparable, Identifiable {
|
||||
static func ==(lhs: LocationPickerEntry, rhs: LocationPickerEntry) -> Bool {
|
||||
switch lhs {
|
||||
case let .city(lhsTheme, lhsTitle, lhsSubtitle, lhsVenue, lhsQueryId, lhsResultId, lhsCoordinate, lhsName, lhsAddress):
|
||||
if case let .city(rhsTheme, rhsTitle, rhsSubtitle, rhsVenue, rhsQueryId, rhsResultId, rhsCoordinate, rhsName, rhsAddress) = rhs, lhsTheme === rhsTheme, lhsTitle == rhsTitle, lhsSubtitle == rhsSubtitle, lhsVenue?.venue?.id == rhsVenue?.venue?.id, lhsQueryId == rhsQueryId && lhsResultId == rhsResultId, lhsCoordinate == rhsCoordinate, lhsName == rhsName, lhsAddress == rhsAddress {
|
||||
if case let .city(rhsTheme, rhsTitle, rhsSubtitle, rhsVenue, rhsQueryId, rhsResultId, rhsCoordinate, rhsName, rhsAddress) = rhs, lhsTheme === rhsTheme, lhsTitle == rhsTitle, lhsSubtitle == rhsSubtitle, lhsVenue?.venue?.id == rhsVenue?.venue?.id, lhsQueryId == rhsQueryId && lhsResultId == rhsResultId, locationCoordinatesAreEqual(lhsCoordinate, rhsCoordinate), lhsName == rhsName, lhsAddress == rhsAddress {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .location(lhsTheme, lhsTitle, lhsSubtitle, lhsVenue, lhsQueryId, lhsResultId, lhsCoordinate, lhsName, lhsAddress, lhsIsTop):
|
||||
if case let .location(rhsTheme, rhsTitle, rhsSubtitle, rhsVenue, rhsQueryId, rhsResultId, rhsCoordinate, rhsName, rhsAddress, rhsIsTop) = rhs, lhsTheme === rhsTheme, lhsTitle == rhsTitle, lhsSubtitle == rhsSubtitle, lhsVenue?.venue?.id == rhsVenue?.venue?.id, lhsQueryId == rhsQueryId && lhsResultId == rhsResultId, lhsCoordinate == rhsCoordinate, lhsName == rhsName, lhsAddress == rhsAddress, lhsIsTop == rhsIsTop {
|
||||
if case let .location(rhsTheme, rhsTitle, rhsSubtitle, rhsVenue, rhsQueryId, rhsResultId, rhsCoordinate, rhsName, rhsAddress, rhsIsTop) = rhs, lhsTheme === rhsTheme, lhsTitle == rhsTitle, lhsSubtitle == rhsSubtitle, lhsVenue?.venue?.id == rhsVenue?.venue?.id, lhsQueryId == rhsQueryId && lhsResultId == rhsResultId, locationCoordinatesAreEqual(lhsCoordinate, rhsCoordinate), lhsName == rhsName, lhsAddress == rhsAddress, lhsIsTop == rhsIsTop {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .liveLocation(lhsTheme, lhsTitle, lhsSubtitle, lhsCoordinate):
|
||||
if case let .liveLocation(rhsTheme, rhsTitle, rhsSubtitle, rhsCoordinate) = rhs, lhsTheme === rhsTheme, lhsTitle == rhsTitle, lhsSubtitle == rhsSubtitle, lhsCoordinate == rhsCoordinate {
|
||||
if case let .liveLocation(rhsTheme, rhsTitle, rhsSubtitle, rhsCoordinate) = rhs, lhsTheme === rhsTheme, lhsTitle == rhsTitle, lhsSubtitle == rhsSubtitle, locationCoordinatesAreEqual(lhsCoordinate, rhsCoordinate) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
@ -246,7 +246,7 @@ enum LocationPickerLocation: Equatable {
|
||||
return false
|
||||
}
|
||||
case let .location(lhsCoordinate, lhsAddress):
|
||||
if case let .location(rhsCoordinate, rhsAddress) = rhs, lhsCoordinate == rhsCoordinate, lhsAddress == rhsAddress {
|
||||
if case let .location(rhsCoordinate, rhsAddress) = rhs, locationCoordinatesAreEqual(lhsCoordinate, rhsCoordinate), lhsAddress == rhsAddress {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
@ -544,7 +544,9 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM
|
||||
let foundVenues: Signal<([(TelegramMediaMap, String)], Int64, CLLocation)?, NoError> = .single(nil)
|
||||
|> then(
|
||||
self.searchVenuesPromise.get()
|
||||
|> distinctUntilChanged
|
||||
|> distinctUntilChanged(isEqual: { lhs, rhs in
|
||||
return locationCoordinatesAreEqual(lhs, rhs)
|
||||
})
|
||||
|> mapToSignal { coordinate -> Signal<([(TelegramMediaMap, String)], Int64, CLLocation)?, NoError> in
|
||||
if let coordinate = coordinate {
|
||||
return (.single(nil)
|
||||
@ -726,7 +728,7 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM
|
||||
case .none, .venue:
|
||||
updateMap = true
|
||||
case let .location(previousCoordinate, _):
|
||||
if previousCoordinate != coordinate {
|
||||
if !locationCoordinatesAreEqual(previousCoordinate, coordinate) {
|
||||
updateMap = true
|
||||
}
|
||||
default:
|
||||
|
@ -24,12 +24,20 @@ extension MKMapRect {
|
||||
}
|
||||
}
|
||||
|
||||
extension CLLocationCoordinate2D: Equatable {
|
||||
|
||||
public func locationCoordinatesAreEqual(_ lhs: CLLocationCoordinate2D?, _ rhs: CLLocationCoordinate2D?) -> Bool {
|
||||
if let lhs, let rhs {
|
||||
return lhs.isEqual(to: rhs)
|
||||
} else if (lhs == nil) != (rhs == nil) {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
public func ==(lhs: CLLocationCoordinate2D, rhs: CLLocationCoordinate2D) -> Bool {
|
||||
return lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude
|
||||
extension CLLocationCoordinate2D {
|
||||
func isEqual(to other: CLLocationCoordinate2D) -> Bool {
|
||||
return self.latitude == other.latitude && self.longitude == other.longitude
|
||||
}
|
||||
}
|
||||
|
||||
public func nearbyVenues(context: AccountContext, story: Bool = false, latitude: Double, longitude: Double, query: String? = nil) -> Signal<ChatContextResultCollection?, NoError> {
|
||||
|
@ -213,6 +213,35 @@ public enum LocationViewLocation: Equatable {
|
||||
case user
|
||||
case coordinate(CLLocationCoordinate2D, Bool)
|
||||
case custom
|
||||
|
||||
public static func ==(lhs: LocationViewLocation, rhs: LocationViewLocation) -> Bool {
|
||||
switch lhs {
|
||||
case .initial:
|
||||
if case .initial = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case .user:
|
||||
if case .user = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .coordinate(lhsCoordinate, lhsValue):
|
||||
if case let .coordinate(rhsCoordinate, rhsValue) = rhs, locationCoordinatesAreEqual(lhsCoordinate, rhsCoordinate), lhsValue == rhsValue {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case .custom:
|
||||
if case .custom = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct LocationViewState {
|
||||
@ -617,7 +646,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
||||
strongSelf.headerNode.mapNode.setMapCenter(coordinate: location.coordinate, span: LocationMapNode.viewMapSpan, animated: previousState != nil)
|
||||
}
|
||||
case let .coordinate(coordinate, defaultSpan):
|
||||
if let previousState = previousState, case let .coordinate(previousCoordinate, _) = previousState.selectedLocation, previousCoordinate == coordinate {
|
||||
if let previousState = previousState, case let .coordinate(previousCoordinate, _) = previousState.selectedLocation, locationCoordinatesAreEqual(previousCoordinate, coordinate) {
|
||||
} else {
|
||||
strongSelf.headerNode.mapNode.setMapCenter(coordinate: coordinate, span: defaultSpan ? LocationMapNode.defaultMapSpan : LocationMapNode.viewMapSpan, animated: true)
|
||||
}
|
||||
|
@ -629,7 +629,7 @@ final class MediaPickerSelectedListNode: ASDisplayNode, ASScrollViewDelegate, AS
|
||||
for (_, backgroundNode) in strongSelf.backgroundNodes {
|
||||
backgroundNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25, delay: 0.1)
|
||||
if strongSelf.isExternalPreview {
|
||||
Transition.immediate.setScale(layer: backgroundNode.layer, scale: 0.001)
|
||||
ComponentTransition.immediate.setScale(layer: backgroundNode.layer, scale: 0.001)
|
||||
transition.updateTransformScale(layer: backgroundNode.layer, scale: 1.0)
|
||||
}
|
||||
}
|
||||
@ -719,7 +719,7 @@ final class MediaPickerSelectedListNode: ASDisplayNode, ASScrollViewDelegate, AS
|
||||
}
|
||||
}
|
||||
|
||||
func animateOutOnSend(transition: Transition) {
|
||||
func animateOutOnSend(transition: ComponentTransition) {
|
||||
transition.setAlpha(view: self.view, alpha: 0.0)
|
||||
}
|
||||
|
||||
@ -1133,15 +1133,15 @@ final class MediaPickerSelectedListNode: ASDisplayNode, ASScrollViewDelegate, AS
|
||||
}
|
||||
}
|
||||
|
||||
func animateIn(transition: Transition) {
|
||||
func animateIn(transition: ComponentTransition) {
|
||||
self.animateIn(transition: transition.containedViewLayoutTransition, initiated: {}, completion: {})
|
||||
}
|
||||
|
||||
func animateOut(transition: Transition) {
|
||||
func animateOut(transition: ComponentTransition) {
|
||||
self.animateOut(transition: transition.containedViewLayoutTransition, completion: {})
|
||||
}
|
||||
|
||||
func update(containerSize: CGSize, transition: Transition) -> CGSize {
|
||||
func update(containerSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
if var validLayout = self.validLayout {
|
||||
validLayout.size = containerSize
|
||||
self.validLayout = validLayout
|
||||
|
@ -73,7 +73,7 @@ public final class ScrollComponent<ChildEnvironment: Equatable>: Component {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func update(component: ScrollComponent<ChildEnvironment>, availableSize: CGSize, state: EmptyComponentState, environment: Environment<ChildEnvironment>, transition: Transition) -> CGSize {
|
||||
func update(component: ScrollComponent<ChildEnvironment>, availableSize: CGSize, state: EmptyComponentState, environment: Environment<ChildEnvironment>, transition: ComponentTransition) -> CGSize {
|
||||
let contentSize = self.contentView.update(
|
||||
transition: transition,
|
||||
component: component.content,
|
||||
@ -96,7 +96,7 @@ public final class ScrollComponent<ChildEnvironment: Equatable>: Component {
|
||||
return View(frame: CGRect())
|
||||
}
|
||||
|
||||
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<ChildEnvironment>, transition: Transition) -> CGSize {
|
||||
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<ChildEnvironment>, transition: ComponentTransition) -> CGSize {
|
||||
return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -1504,7 +1504,7 @@ public final class PeerInfoAvatarListContainerNode: ASDisplayNode {
|
||||
self.updateItems(size: size, transition: transition, stripTransition: transition)
|
||||
|
||||
if let storyParams = self.storyParams {
|
||||
var indicatorTransition = Transition(transition)
|
||||
var indicatorTransition = ComponentTransition(transition)
|
||||
let expandedStorySetIndicator: ComponentView<Empty>
|
||||
if let current = self.expandedStorySetIndicator {
|
||||
expandedStorySetIndicator = current
|
||||
|
@ -14,6 +14,18 @@ import SearchUI
|
||||
import ChatListSearchItemHeader
|
||||
import ContactsPeerItem
|
||||
|
||||
#if swift(>=6.0)
|
||||
extension NavigationBarSearchContentNode: @retroactive ItemListControllerSearchNavigationContentNode {
|
||||
public func activate() {
|
||||
}
|
||||
|
||||
public func deactivate() {
|
||||
}
|
||||
|
||||
public func setQueryUpdated(_ f: @escaping (String) -> Void) {
|
||||
}
|
||||
}
|
||||
#else
|
||||
extension NavigationBarSearchContentNode: ItemListControllerSearchNavigationContentNode {
|
||||
public func activate() {
|
||||
}
|
||||
@ -24,6 +36,7 @@ extension NavigationBarSearchContentNode: ItemListControllerSearchNavigationCont
|
||||
public func setQueryUpdated(_ f: @escaping (String) -> Void) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
final class OldChannelsSearchItem: ItemListControllerSearch {
|
||||
let context: AccountContext
|
||||
|
@ -55,7 +55,7 @@ final class AppIconsDemoComponent: Component {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
public func update(component: AppIconsDemoComponent, availableSize: CGSize, environment: Environment<DemoPageEnvironment>, transition: Transition) -> CGSize {
|
||||
public func update(component: AppIconsDemoComponent, availableSize: CGSize, environment: Environment<DemoPageEnvironment>, transition: ComponentTransition) -> CGSize {
|
||||
let isDisplaying = environment[DemoPageEnvironment.self].isDisplaying
|
||||
|
||||
self.component = component
|
||||
@ -173,7 +173,7 @@ final class AppIconsDemoComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<DemoPageEnvironment>, transition: Transition) -> CGSize {
|
||||
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<DemoPageEnvironment>, transition: ComponentTransition) -> CGSize {
|
||||
return view.update(component: self, availableSize: availableSize, environment: environment, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ final class BadgeLabelView: UIView {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func update(value: Int32, isFirst: Bool, isLast: Bool, transition: Transition) {
|
||||
func update(value: Int32, isFirst: Bool, isLast: Bool, transition: ComponentTransition) {
|
||||
let previousValue = self.currentValue
|
||||
self.currentValue = value
|
||||
|
||||
@ -98,7 +98,7 @@ final class BadgeLabelView: UIView {
|
||||
}
|
||||
}
|
||||
|
||||
func update(value: String, transition: Transition) -> CGSize {
|
||||
func update(value: String, transition: ComponentTransition) -> CGSize {
|
||||
if value.contains(" ") {
|
||||
for (_, view) in self.itemViews {
|
||||
view.isHidden = true
|
||||
|
@ -80,7 +80,7 @@ public final class BoostHeaderBackgroundComponent: Component {
|
||||
}
|
||||
}
|
||||
|
||||
func update(component: BoostHeaderBackgroundComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
func update(component: BoostHeaderBackgroundComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
self.sceneView.bounds = CGRect(origin: .zero, size: CGSize(width: availableSize.width * 2.0, height: availableSize.height))
|
||||
if self.sceneView.superview == self {
|
||||
self.sceneView.center = CGPoint(x: availableSize.width / 2.0, y: availableSize.height / 2.0)
|
||||
@ -96,7 +96,7 @@ public final class BoostHeaderBackgroundComponent: 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, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ private final class HeaderComponent: Component {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func update(component: HeaderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(component: HeaderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
self.component = component
|
||||
self.state = state
|
||||
|
||||
@ -95,7 +95,7 @@ private final class HeaderComponent: Component {
|
||||
return View(frame: CGRect())
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ final class CreateGiveawayFooterItemNode: ItemListControllerFooterItemNode {
|
||||
|
||||
let panelFrame = CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - totalPanelHeight), size: CGSize(width: layout.size.width, height: panelHeight))
|
||||
|
||||
var buttonTransition: Transition = .easeInOut(duration: 0.2)
|
||||
var buttonTransition: ComponentTransition = .easeInOut(duration: 0.2)
|
||||
if !hadLayout {
|
||||
buttonTransition = .immediate
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ class EmojiHeaderComponent: Component {
|
||||
self.containerView = nil
|
||||
}
|
||||
|
||||
func update(component: EmojiHeaderComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
func update(component: EmojiHeaderComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
self.hasIdleAnimations = component.hasIdleAnimations
|
||||
|
||||
let size = self.statusView.update(
|
||||
@ -168,7 +168,7 @@ class EmojiHeaderComponent: Component {
|
||||
return View(frame: CGRect())
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
return view.update(component: self, availableSize: availableSize, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public final class PageIndicatorComponent: Component {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
public func update(component: PageIndicatorComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
public func update(component: PageIndicatorComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
let isFirstTime = self.component == nil
|
||||
self.component = component
|
||||
|
||||
@ -75,7 +75,7 @@ public final class PageIndicatorComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
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, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -475,7 +475,7 @@ final class PhoneDemoComponent: Component {
|
||||
self.playbackStatusDisposable?.dispose()
|
||||
}
|
||||
|
||||
public func update(component: PhoneDemoComponent, availableSize: CGSize, environment: Environment<DemoPageEnvironment>, transition: Transition) -> CGSize {
|
||||
public func update(component: PhoneDemoComponent, availableSize: CGSize, environment: Environment<DemoPageEnvironment>, transition: ComponentTransition) -> CGSize {
|
||||
self.component = component
|
||||
|
||||
self.containerView.frame = CGRect(origin: .zero, size: availableSize)
|
||||
@ -614,7 +614,7 @@ final class PhoneDemoComponent: Component {
|
||||
return View()
|
||||
}
|
||||
|
||||
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<DemoPageEnvironment>, transition: Transition) -> CGSize {
|
||||
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<DemoPageEnvironment>, transition: ComponentTransition) -> CGSize {
|
||||
return view.update(component: self, availableSize: availableSize, environment: environment, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -861,11 +861,11 @@ private final class SheetContent: CombinedComponent {
|
||||
)
|
||||
context.add(alternateText
|
||||
.position(CGPoint(x: context.availableSize.width / 2.0, y: contentSize.height + alternateText.size.height / 2.0))
|
||||
.appear(Transition.Appear({ _, view, transition in
|
||||
.appear(ComponentTransition.Appear({ _, view, transition in
|
||||
transition.animatePosition(view: view, from: CGPoint(x: 0.0, y: 64.0), to: .zero, additive: true)
|
||||
transition.animateAlpha(view: view, from: 0.0, to: 1.0)
|
||||
}))
|
||||
.disappear(Transition.Disappear({ view, transition, completion in
|
||||
.disappear(ComponentTransition.Disappear({ view, transition, completion in
|
||||
view.superview?.sendSubviewToBack(view)
|
||||
transition.animatePosition(view: view, from: .zero, to: CGPoint(x: 0.0, y: -64.0), additive: true)
|
||||
transition.setAlpha(view: view, alpha: 0.0, completion: { _ in
|
||||
@ -887,11 +887,11 @@ private final class SheetContent: CombinedComponent {
|
||||
)
|
||||
context.add(text
|
||||
.position(CGPoint(x: context.availableSize.width / 2.0, y: contentSize.height + text.size.height / 2.0))
|
||||
.appear(Transition.Appear({ _, view, transition in
|
||||
.appear(ComponentTransition.Appear({ _, view, transition in
|
||||
transition.animatePosition(view: view, from: CGPoint(x: 0.0, y: 64.0), to: .zero, additive: true)
|
||||
transition.animateAlpha(view: view, from: 0.0, to: 1.0)
|
||||
}))
|
||||
.disappear(Transition.Disappear({ view, transition, completion in
|
||||
.disappear(ComponentTransition.Disappear({ view, transition, completion in
|
||||
view.superview?.sendSubviewToBack(view)
|
||||
transition.animatePosition(view: view, from: .zero, to: CGPoint(x: 0.0, y: -64.0), additive: true)
|
||||
transition.setAlpha(view: view, alpha: 0.0, completion: { _ in
|
||||
@ -1792,7 +1792,7 @@ public class PremiumBoostLevelsScreen: ViewController {
|
||||
self.controller?.updateModalStyleOverlayTransitionFactor(0.0, transition: positionTransition)
|
||||
}
|
||||
|
||||
func requestLayout(transition: Transition) {
|
||||
func requestLayout(transition: ComponentTransition) {
|
||||
guard let layout = self.currentLayout else {
|
||||
return
|
||||
}
|
||||
@ -1800,7 +1800,7 @@ public class PremiumBoostLevelsScreen: ViewController {
|
||||
}
|
||||
|
||||
private var dismissOffset: CGFloat?
|
||||
func containerLayoutUpdated(layout: ContainerViewLayout, forceUpdate: Bool = false, transition: Transition) {
|
||||
func containerLayoutUpdated(layout: ContainerViewLayout, forceUpdate: Bool = false, transition: ComponentTransition) {
|
||||
guard !self.isDismissing else {
|
||||
return
|
||||
}
|
||||
@ -1897,7 +1897,7 @@ public class PremiumBoostLevelsScreen: ViewController {
|
||||
}
|
||||
|
||||
private var boostState: InternalBoostState.DisplayData?
|
||||
func updated(transition: Transition, forceUpdate: Bool = false) {
|
||||
func updated(transition: ComponentTransition, forceUpdate: Bool = false) {
|
||||
guard let controller = self.controller else {
|
||||
return
|
||||
}
|
||||
@ -2165,24 +2165,24 @@ public class PremiumBoostLevelsScreen: ViewController {
|
||||
let initialVelocity: CGFloat = distance.isZero ? 0.0 : abs(velocity.y / distance)
|
||||
let transition = ContainedViewLayoutTransition.animated(duration: 0.45, curve: .customSpring(damping: 124.0, initialVelocity: initialVelocity))
|
||||
|
||||
self.containerLayoutUpdated(layout: layout, transition: Transition(transition))
|
||||
self.containerLayoutUpdated(layout: layout, transition: ComponentTransition(transition))
|
||||
} else {
|
||||
self.isExpanded = true
|
||||
|
||||
self.containerLayoutUpdated(layout: layout, transition: Transition(.animated(duration: 0.3, curve: .easeInOut)))
|
||||
self.containerLayoutUpdated(layout: layout, transition: ComponentTransition(.animated(duration: 0.3, curve: .easeInOut)))
|
||||
}
|
||||
} else if scrollView != nil, (velocity.y < -300.0 || offset < topInset / 2.0) {
|
||||
let initialVelocity: CGFloat = offset.isZero ? 0.0 : abs(velocity.y / offset)
|
||||
let transition = ContainedViewLayoutTransition.animated(duration: 0.45, curve: .customSpring(damping: 124.0, initialVelocity: initialVelocity))
|
||||
self.isExpanded = true
|
||||
|
||||
self.containerLayoutUpdated(layout: layout, transition: Transition(transition))
|
||||
self.containerLayoutUpdated(layout: layout, transition: ComponentTransition(transition))
|
||||
} else {
|
||||
if let scrollView = scrollView {
|
||||
scrollView.setContentOffset(CGPoint(x: 0.0, y: -scrollView.contentInset.top), animated: false)
|
||||
}
|
||||
|
||||
self.containerLayoutUpdated(layout: layout, transition: Transition(.animated(duration: 0.3, curve: .easeInOut)))
|
||||
self.containerLayoutUpdated(layout: layout, transition: ComponentTransition(.animated(duration: 0.3, curve: .easeInOut)))
|
||||
}
|
||||
|
||||
if !dismissing {
|
||||
@ -2195,7 +2195,7 @@ public class PremiumBoostLevelsScreen: ViewController {
|
||||
case .cancelled:
|
||||
self.panGestureArguments = nil
|
||||
|
||||
self.containerLayoutUpdated(layout: layout, transition: Transition(.animated(duration: 0.3, curve: .easeInOut)))
|
||||
self.containerLayoutUpdated(layout: layout, transition: ComponentTransition(.animated(duration: 0.3, curve: .easeInOut)))
|
||||
default:
|
||||
break
|
||||
}
|
||||
@ -2220,7 +2220,7 @@ public class PremiumBoostLevelsScreen: ViewController {
|
||||
guard let layout = self.currentLayout else {
|
||||
return
|
||||
}
|
||||
self.containerLayoutUpdated(layout: layout, transition: Transition(transition))
|
||||
self.containerLayoutUpdated(layout: layout, transition: ComponentTransition(transition))
|
||||
}
|
||||
|
||||
private var currentMyBoostCount: Int32 = 0
|
||||
@ -2560,7 +2560,7 @@ public class PremiumBoostLevelsScreen: ViewController {
|
||||
self.currentLayout = layout
|
||||
super.containerLayoutUpdated(layout, transition: transition)
|
||||
|
||||
self.node.containerLayoutUpdated(layout: layout, transition: Transition(transition))
|
||||
self.node.containerLayoutUpdated(layout: layout, transition: ComponentTransition(transition))
|
||||
}
|
||||
}
|
||||
|
||||
@ -2614,7 +2614,7 @@ private final class FooterComponent: Component {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func update(component: FooterComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(component: FooterComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
self.component = component
|
||||
self.state = state
|
||||
|
||||
@ -2677,7 +2677,7 @@ private final class FooterComponent: Component {
|
||||
return View(frame: CGRect())
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -495,7 +495,7 @@ class PremiumCoinComponent: Component {
|
||||
node.addAnimation(springAnimation, forKey: "rotate")
|
||||
}
|
||||
|
||||
func update(component: PremiumCoinComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
func update(component: PremiumCoinComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
self.sceneView.bounds = CGRect(origin: .zero, size: CGSize(width: availableSize.width * 2.0, height: availableSize.height * 2.0))
|
||||
if self.sceneView.superview == self {
|
||||
self.sceneView.center = CGPoint(x: availableSize.width / 2.0, y: availableSize.height / 2.0)
|
||||
@ -511,7 +511,7 @@ class PremiumCoinComponent: Component {
|
||||
return View(frame: CGRect(), isIntro: self.isIntro)
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
return view.update(component: self, availableSize: availableSize, transition: transition)
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public final class PremiumGradientBackgroundComponent: Component {
|
||||
}
|
||||
|
||||
|
||||
func update(component: PremiumGradientBackgroundComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(component: PremiumGradientBackgroundComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
self.clipLayer.frame = CGRect(origin: .zero, size: CGSize(width: availableSize.width, height: availableSize.height + 10.0))
|
||||
self.gradientLayer.frame = CGRect(origin: .zero, size: availableSize)
|
||||
|
||||
@ -149,7 +149,7 @@ public final class PremiumGradientBackgroundComponent: 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)
|
||||
}
|
||||
}
|
||||
@ -371,7 +371,7 @@ final class DemoPagerComponent: Component {
|
||||
self.ignoreContentOffsetChange = false
|
||||
}
|
||||
|
||||
func update(component: DemoPagerComponent, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
func update(component: DemoPagerComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
|
||||
var validIds: [AnyHashable] = []
|
||||
|
||||
component.nextAction?.connect { [weak self] in
|
||||
@ -473,7 +473,7 @@ final class DemoPagerComponent: Component {
|
||||
return View(frame: CGRect())
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
return view.update(component: self, availableSize: availableSize, transition: transition)
|
||||
}
|
||||
}
|
||||
@ -666,7 +666,7 @@ private final class DemoSheetContent: CombinedComponent {
|
||||
strongSelf.isPremium = isPremium
|
||||
strongSelf.promoConfiguration = promoConfiguration
|
||||
if !reactions.isEmpty && !stickers.isEmpty {
|
||||
strongSelf.updated(transition: Transition(.immediate).withUserData(DemoAnimateInTransition()))
|
||||
strongSelf.updated(transition: ComponentTransition(.immediate).withUserData(DemoAnimateInTransition()))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -1102,7 +1102,7 @@ private final class PeerCellComponent: Component {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func update(component: PeerCellComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(component: PeerCellComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
self.component = component
|
||||
self.state = state
|
||||
|
||||
@ -1148,7 +1148,7 @@ private final class PeerCellComponent: Component {
|
||||
return View(frame: CGRect())
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
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)
|
||||
}
|
||||
}
|
||||
@ -1183,7 +1183,7 @@ private final class DustComponent: Component {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func update(component: DustComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(component: DustComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
self.component = component
|
||||
self.state = state
|
||||
|
||||
@ -1198,7 +1198,7 @@ private final class DustComponent: Component {
|
||||
return View(frame: CGRect())
|
||||
}
|
||||
|
||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -1046,7 +1046,7 @@ final class SectionGroupComponent: Component {
|
||||
}
|
||||
}
|
||||
|
||||
func update(component: SectionGroupComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
func update(component: SectionGroupComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
let sideInset: CGFloat = 16.0
|
||||
|
||||
self.backgroundColor = component.backgroundColor
|
||||
@ -1153,7 +1153,7 @@ final class SectionGroupComponent: 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)
|
||||
}
|
||||
}
|
||||
@ -3594,7 +3594,7 @@ private final class PremiumIntroScreenComponent: CombinedComponent {
|
||||
context.add(bottomPanel
|
||||
.position(CGPoint(x: context.availableSize.width / 2.0, y: context.availableSize.height - bottomPanel.size.height / 2.0))
|
||||
.opacity(bottomPanelAlpha)
|
||||
.disappear(Transition.Disappear { view, transition, completion in
|
||||
.disappear(ComponentTransition.Disappear { view, transition, completion in
|
||||
if case .none = transition.animation {
|
||||
completion()
|
||||
return
|
||||
@ -3607,7 +3607,7 @@ private final class PremiumIntroScreenComponent: CombinedComponent {
|
||||
context.add(bottomSeparator
|
||||
.position(CGPoint(x: context.availableSize.width / 2.0, y: context.availableSize.height - bottomPanel.size.height))
|
||||
.opacity(bottomPanelAlpha)
|
||||
.disappear(Transition.Disappear { view, transition, completion in
|
||||
.disappear(ComponentTransition.Disappear { view, transition, completion in
|
||||
if case .none = transition.animation {
|
||||
completion()
|
||||
return
|
||||
@ -3619,7 +3619,7 @@ private final class PremiumIntroScreenComponent: CombinedComponent {
|
||||
)
|
||||
context.add(button
|
||||
.position(CGPoint(x: context.availableSize.width / 2.0, y: context.availableSize.height - bottomPanel.size.height + bottomPanelPadding + button.size.height / 2.0))
|
||||
.disappear(Transition.Disappear { view, transition, completion in
|
||||
.disappear(ComponentTransition.Disappear { view, transition, completion in
|
||||
if case .none = transition.animation {
|
||||
completion()
|
||||
return
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user