diff --git a/Telegram/Telegram-iOS/DefaultAppIcon.xcassets/AppIconLLC.appiconset/BlueIconIpad.png b/Telegram/Telegram-iOS/DefaultAppIcon.xcassets/AppIconLLC.appiconset/BlueIconIpad.png deleted file mode 100644 index 5eaf0bab23..0000000000 Binary files a/Telegram/Telegram-iOS/DefaultAppIcon.xcassets/AppIconLLC.appiconset/BlueIconIpad.png and /dev/null differ diff --git a/Telegram/Telegram-iOS/DefaultAppIcon.xcassets/AppIconLLC.appiconset/Contents.json b/Telegram/Telegram-iOS/DefaultAppIcon.xcassets/AppIconLLC.appiconset/Contents.json index 00dd28927f..4d65457087 100644 --- a/Telegram/Telegram-iOS/DefaultAppIcon.xcassets/AppIconLLC.appiconset/Contents.json +++ b/Telegram/Telegram-iOS/DefaultAppIcon.xcassets/AppIconLLC.appiconset/Contents.json @@ -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 } -} \ No newline at end of file +} diff --git a/Tests/LottieMetalTest/SoftwareLottieRenderer/PublicHeaders/SoftwareLottieRenderer/SoftwareLottieRenderer.h b/Tests/LottieMetalTest/SoftwareLottieRenderer/PublicHeaders/SoftwareLottieRenderer/SoftwareLottieRenderer.h index acdb6cbdfe..960b2d3450 100644 --- a/Tests/LottieMetalTest/SoftwareLottieRenderer/PublicHeaders/SoftwareLottieRenderer/SoftwareLottieRenderer.h +++ b/Tests/LottieMetalTest/SoftwareLottieRenderer/PublicHeaders/SoftwareLottieRenderer/SoftwareLottieRenderer.h @@ -18,8 +18,8 @@ CGRect getPathNativeBoundingBox(CGPathRef _Nonnull path); - (instancetype _Nullable)initWithData:(NSData * _Nonnull)data; -- (void)setFrame:(NSInteger)index; -- (UIImage * _Nullable)renderForSize:(CGSize)size useReferenceRendering:(bool)useReferenceRendering; +- (void)setFrame:(CGFloat)index; +- (UIImage * _Nullable)renderForSize:(CGSize)size useReferenceRendering:(bool)useReferenceRendering canUseMoreMemory:(bool)canUseMoreMemory skipImageGeneration:(bool)skipImageGeneration; @end diff --git a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/CoreGraphicsCanvasImpl.h b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/CoreGraphicsCanvasImpl.h index 0f4a32be04..571f5199d4 100644 --- a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/CoreGraphicsCanvasImpl.h +++ b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/CoreGraphicsCanvasImpl.h @@ -1,5 +1,5 @@ -#ifndef CoreGraphicsCanvasImpl_h -#define CoreGraphicsCanvasImpl_h +#ifndef CoreGraphicsCoreGraphicsCanvasImpl_h +#define CoreGraphicsCoreGraphicsCanvasImpl_h #include @@ -7,7 +7,9 @@ namespace lottie { -class CanvasImpl: public Canvas { +class CoreGraphicsCanvasImpl: public Canvas { +class Layer; + public: class Image { public: @@ -20,54 +22,39 @@ public: }; public: - CanvasImpl(int width, int height); - CanvasImpl(CGContextRef context, int width, int height); - virtual ~CanvasImpl(); - - virtual int width() const override; - virtual int height() const override; - - std::shared_ptr makeLayer(int width, int height) override; + CoreGraphicsCanvasImpl(int width, int height); + virtual ~CoreGraphicsCanvasImpl(); virtual void saveState() override; virtual void restoreState() override; virtual void fillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, lottie::Color const &color) override; virtual void linearGradientFillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override; - virtual void radialGradientFillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) override; + virtual void radialGradientFillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, Gradient const &gradient, Vector2D const ¢er, float radius) override; virtual void strokePath(CanvasPathEnumerator const &enumeratePath, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, lottie::Color const &color) override; virtual void linearGradientStrokePath(CanvasPathEnumerator const &enumeratePath, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override; virtual void radialGradientStrokePath(CanvasPathEnumerator const &enumeratePath, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) override; - virtual void fill(lottie::CGRect const &rect, lottie::Color const &fillColor) override; - virtual void setBlendMode(BlendMode blendMode) override; - virtual void setAlpha(float alpha) override; + virtual void clip(CGRect const &rect) override; virtual void concatenate(lottie::Transform2D const &transform) override; - virtual std::shared_ptr makeImage() const; - virtual void draw(std::shared_ptr const &other, lottie::CGRect const &rect) override; + virtual std::shared_ptr makeImage(); - CGContextRef nativeContext() const { - return _context; - } + virtual bool pushLayer(CGRect const &rect, float alpha, std::optional maskMode) override; + virtual void popLayer() override; - std::vector &backingData() { - return _backingData; - } + std::vector &backingData(); + int bytesPerRow(); - int bytesPerRow() { - return _bytesPerRow; - } +private: + std::shared_ptr ¤tLayer(); private: int _width = 0; int _height = 0; - int _bytesPerRow = 0; - std::vector _backingData; - CGContextRef _context = nil; CGContextRef _topContext = nil; - CGLayerRef _layer = nil; + std::vector> _layerStack; }; } diff --git a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/CoreGraphicsCanvasImpl.mm b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/CoreGraphicsCanvasImpl.mm index 069155a98e..96288db99d 100644 --- a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/CoreGraphicsCanvasImpl.mm +++ b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/CoreGraphicsCanvasImpl.mm @@ -62,116 +62,136 @@ bool addEnumeratedPath(CGContextRef context, CanvasPathEnumerator const &enumera } -CanvasImpl::Image::Image(::CGImageRef image) { +class CoreGraphicsCanvasImpl::Layer { +public: + struct Composition { + CGRect rect; + float alpha; + Transform2D transform; + std::optional maskMode; + + Composition(CGRect rect_, float alpha_, Transform2D transform_, std::optional maskMode_) : + rect(rect_), alpha(alpha_), transform(transform_), maskMode(maskMode_) { + } + }; + +public: + explicit Layer(int width, int height, std::optional composition) { + _width = width; + _height = height; + _composition = composition; + + _bytesPerRow = alignUp(width * 4, 16); + _backingData.resize(_bytesPerRow * _height); + memset(_backingData.data(), 0, _backingData.size()); + + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGBitmapInfo bitmapInfo = kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst; + _context = CGBitmapContextCreate(_backingData.data(), _width, _height, 8, _bytesPerRow, colorSpace, bitmapInfo); + CFRelease(colorSpace); + + CGContextClearRect(_context, CGRectMake(0.0, 0.0, _width, _height)); + } + + ~Layer() { + CGContextRelease(_context); + } + + CGContextRef context() const { + return _context; + } + + std::optional composition() const { + return _composition; + } + + std::shared_ptr makeImage() { + ::CGImageRef nativeImage = CGBitmapContextCreateImage(_context); + if (nativeImage) { + auto image = std::make_shared(nativeImage); + CFRelease(nativeImage); + return image; + } else { + return nil; + } + } + +public: + CGContextRef _context = nil; + int _width = 0; + int _height = 0; + int _bytesPerRow = 0; + std::vector _backingData; + + std::optional _composition; +}; + +CoreGraphicsCanvasImpl::Image::Image(::CGImageRef image) { _image = CGImageRetain(image); } -CanvasImpl::Image::~Image() { +CoreGraphicsCanvasImpl::Image::~Image() { CFRelease(_image); } -::CGImageRef CanvasImpl::Image::nativeImage() const { +::CGImageRef CoreGraphicsCanvasImpl::Image::nativeImage() const { return _image; } -CanvasImpl::CanvasImpl(int width, int height) { - _width = width; - _height = height; - _bytesPerRow = alignUp(width * 4, 16); - _backingData.resize(_bytesPerRow * _height); - memset(_backingData.data(), 0, _backingData.size()); - - CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); - - CGBitmapInfo bitmapInfo = kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst; - _context = CGBitmapContextCreate(_backingData.data(), _width, _height, 8, _bytesPerRow, colorSpace, bitmapInfo); - - CGContextClearRect(_context, CGRectMake(0.0, 0.0, _width, _height)); - - //CGContextSetInterpolationQuality(_context, kCGInterpolationLow); - //CGContextSetAllowsAntialiasing(_context, true); - //CGContextSetShouldAntialias(_context, true); - - CFRelease(colorSpace); - - _topContext = CGContextRetain(_context); +CoreGraphicsCanvasImpl::CoreGraphicsCanvasImpl(int width, int height) : +_width(width), +_height(height) { + _layerStack.push_back(std::make_shared(width, height, std::nullopt)); } -CanvasImpl::CanvasImpl(CGContextRef context, int width, int height) { - _topContext = CGContextRetain(context); - _layer = CGLayerCreateWithContext(context, CGSizeMake(width, height), nil); - _context = CGContextRetain(CGLayerGetContext(_layer)); - _width = width; - _height = height; +CoreGraphicsCanvasImpl::~CoreGraphicsCanvasImpl() { } -CanvasImpl::~CanvasImpl() { - CFRelease(_context); - if (_topContext) { - CFRelease(_topContext); - } - if (_layer) { - CFRelease(_layer); - } +void CoreGraphicsCanvasImpl::saveState() { + CGContextSaveGState(currentLayer()->context()); } -int CanvasImpl::width() const { - return _width; +void CoreGraphicsCanvasImpl::restoreState() { + CGContextRestoreGState(currentLayer()->context()); } -int CanvasImpl::height() const { - return _height; -} - -std::shared_ptr CanvasImpl::makeLayer(int width, int height) { - return std::make_shared(_topContext, width, height); -} - -void CanvasImpl::saveState() { - CGContextSaveGState(_context); -} - -void CanvasImpl::restoreState() { - CGContextRestoreGState(_context); -} - -void CanvasImpl::fillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, lottie::Color const &color) { - if (!addEnumeratedPath(_context, enumeratePath)) { +void CoreGraphicsCanvasImpl::fillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, lottie::Color const &color) { + if (!addEnumeratedPath(currentLayer()->context(), enumeratePath)) { return; } CGFloat components[4] = { color.r, color.g, color.b, color.a }; - CGColorRef nativeColor = CGColorCreate(CGBitmapContextGetColorSpace(_topContext), components); - CGContextSetFillColorWithColor(_context, nativeColor); + CGColorRef nativeColor = CGColorCreate(CGBitmapContextGetColorSpace(currentLayer()->context()), components); + CGContextSetFillColorWithColor(currentLayer()->context(), nativeColor); CFRelease(nativeColor); switch (fillRule) { case lottie::FillRule::EvenOdd: { - CGContextEOFillPath(_context); + CGContextEOFillPath(currentLayer()->context()); break; } default: { - CGContextFillPath(_context); + CGContextFillPath(currentLayer()->context()); break; } } } -void CanvasImpl::linearGradientFillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) { - CGContextSaveGState(_context); +void CoreGraphicsCanvasImpl::linearGradientFillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) { + CGContextSaveGState(currentLayer()->context()); - if (!addEnumeratedPath(_context, enumeratePath)) { - CGContextRestoreGState(_context); + if (!addEnumeratedPath(currentLayer()->context(), enumeratePath)) { + CGContextRestoreGState(currentLayer()->context()); return; } switch (fillRule) { case lottie::FillRule::EvenOdd: { - CGContextEOClip(_context); + CGContextEOClip(currentLayer()->context()); break; } default: { - CGContextClip(_context); + CGContextClip(currentLayer()->context()); break; } } @@ -193,31 +213,31 @@ void CanvasImpl::linearGradientFillPath(CanvasPathEnumerator const &enumeratePat locations.push_back(location); } - CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), locations.data(), locations.size()); + CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(currentLayer()->context()), components.data(), locations.data(), locations.size()); if (nativeGradient) { - CGContextDrawLinearGradient(_context, nativeGradient, CGPointMake(start.x, start.y), CGPointMake(end.x, end.y), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation); + CGContextDrawLinearGradient(currentLayer()->context(), nativeGradient, CGPointMake(start.x, start.y), CGPointMake(end.x, end.y), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation); CFRelease(nativeGradient); } - CGContextResetClip(_context); - CGContextRestoreGState(_context); + CGContextResetClip(currentLayer()->context()); + CGContextRestoreGState(currentLayer()->context()); } -void CanvasImpl::radialGradientFillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) { - CGContextSaveGState(_context); +void CoreGraphicsCanvasImpl::radialGradientFillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, Gradient const &gradient, Vector2D const ¢er, float radius) { + CGContextSaveGState(currentLayer()->context()); - if (!addEnumeratedPath(_context, enumeratePath)) { - CGContextRestoreGState(_context); + if (!addEnumeratedPath(currentLayer()->context(), enumeratePath)) { + CGContextRestoreGState(currentLayer()->context()); return; } switch (fillRule) { case lottie::FillRule::EvenOdd: { - CGContextEOClip(_context); + CGContextEOClip(currentLayer()->context()); break; } default: { - CGContextClip(_context); + CGContextClip(currentLayer()->context()); break; } } @@ -239,62 +259,62 @@ void CanvasImpl::radialGradientFillPath(CanvasPathEnumerator const &enumeratePat locations.push_back(location); } - CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), locations.data(), locations.size()); + CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(currentLayer()->context()), components.data(), locations.data(), locations.size()); if (nativeGradient) { - CGContextDrawRadialGradient(_context, nativeGradient, CGPointMake(startCenter.x, startCenter.y), startRadius, CGPointMake(endCenter.x, endCenter.y), endRadius, kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation); + CGContextDrawRadialGradient(currentLayer()->context(), nativeGradient, CGPointMake(center.x, center.y), 0.0, CGPointMake(center.x, center.y), radius, kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation); CFRelease(nativeGradient); } - CGContextResetClip(_context); - CGContextRestoreGState(_context); + CGContextResetClip(currentLayer()->context()); + CGContextRestoreGState(currentLayer()->context()); } -void CanvasImpl::strokePath(CanvasPathEnumerator const &enumeratePath, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, lottie::Color const &color) { - if (!addEnumeratedPath(_context, enumeratePath)) { +void CoreGraphicsCanvasImpl::strokePath(CanvasPathEnumerator const &enumeratePath, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, lottie::Color const &color) { + if (!addEnumeratedPath(currentLayer()->context(), enumeratePath)) { return; } CGFloat components[4] = { color.r, color.g, color.b, color.a }; - CGColorRef nativeColor = CGColorCreate(CGBitmapContextGetColorSpace(_topContext), components); - CGContextSetStrokeColorWithColor(_context, nativeColor); + CGColorRef nativeColor = CGColorCreate(CGBitmapContextGetColorSpace(currentLayer()->context()), components); + CGContextSetStrokeColorWithColor(currentLayer()->context(), nativeColor); CFRelease(nativeColor); - CGContextSetLineWidth(_context, lineWidth); + CGContextSetLineWidth(currentLayer()->context(), lineWidth); switch (lineJoin) { case lottie::LineJoin::Miter: { - CGContextSetLineJoin(_context, kCGLineJoinMiter); + CGContextSetLineJoin(currentLayer()->context(), kCGLineJoinMiter); break; } case lottie::LineJoin::Round: { - CGContextSetLineJoin(_context, kCGLineJoinRound); + CGContextSetLineJoin(currentLayer()->context(), kCGLineJoinRound); break; } case lottie::LineJoin::Bevel: { - CGContextSetLineJoin(_context, kCGLineJoinBevel); + CGContextSetLineJoin(currentLayer()->context(), kCGLineJoinBevel); break; } default: { - CGContextSetLineJoin(_context, kCGLineJoinBevel); + CGContextSetLineJoin(currentLayer()->context(), kCGLineJoinBevel); break; } } switch (lineCap) { case lottie::LineCap::Butt: { - CGContextSetLineCap(_context, kCGLineCapButt); + CGContextSetLineCap(currentLayer()->context(), kCGLineCapButt); break; } case lottie::LineCap::Round: { - CGContextSetLineCap(_context, kCGLineCapRound); + CGContextSetLineCap(currentLayer()->context(), kCGLineCapRound); break; } case lottie::LineCap::Square: { - CGContextSetLineCap(_context, kCGLineCapSquare); + CGContextSetLineCap(currentLayer()->context(), kCGLineCapSquare); break; } default: { - CGContextSetLineCap(_context, kCGLineCapSquare); + CGContextSetLineCap(currentLayer()->context(), kCGLineCapSquare); break; } } @@ -304,54 +324,54 @@ void CanvasImpl::strokePath(CanvasPathEnumerator const &enumeratePath, float lin for (const auto value : dashPattern) { mappedDashPattern.push_back(value); } - CGContextSetLineDash(_context, dashPhase, mappedDashPattern.data(), mappedDashPattern.size()); + CGContextSetLineDash(currentLayer()->context(), dashPhase, mappedDashPattern.data(), mappedDashPattern.size()); } - CGContextStrokePath(_context); + CGContextStrokePath(currentLayer()->context()); } -void CanvasImpl::linearGradientStrokePath(CanvasPathEnumerator const &enumeratePath, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) { - CGContextSaveGState(_context); - if (!addEnumeratedPath(_context, enumeratePath)) { - CGContextRestoreGState(_context); +void CoreGraphicsCanvasImpl::linearGradientStrokePath(CanvasPathEnumerator const &enumeratePath, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) { + CGContextSaveGState(currentLayer()->context()); + if (!addEnumeratedPath(currentLayer()->context(), enumeratePath)) { + CGContextRestoreGState(currentLayer()->context()); return; } - CGContextSetLineWidth(_context, lineWidth); + CGContextSetLineWidth(currentLayer()->context(), lineWidth); switch (lineJoin) { case lottie::LineJoin::Miter: { - CGContextSetLineJoin(_context, kCGLineJoinMiter); + CGContextSetLineJoin(currentLayer()->context(), kCGLineJoinMiter); break; } case lottie::LineJoin::Round: { - CGContextSetLineJoin(_context, kCGLineJoinRound); + CGContextSetLineJoin(currentLayer()->context(), kCGLineJoinRound); break; } case lottie::LineJoin::Bevel: { - CGContextSetLineJoin(_context, kCGLineJoinBevel); + CGContextSetLineJoin(currentLayer()->context(), kCGLineJoinBevel); break; } default: { - CGContextSetLineJoin(_context, kCGLineJoinBevel); + CGContextSetLineJoin(currentLayer()->context(), kCGLineJoinBevel); break; } } switch (lineCap) { case lottie::LineCap::Butt: { - CGContextSetLineCap(_context, kCGLineCapButt); + CGContextSetLineCap(currentLayer()->context(), kCGLineCapButt); break; } case lottie::LineCap::Round: { - CGContextSetLineCap(_context, kCGLineCapRound); + CGContextSetLineCap(currentLayer()->context(), kCGLineCapRound); break; } case lottie::LineCap::Square: { - CGContextSetLineCap(_context, kCGLineCapSquare); + CGContextSetLineCap(currentLayer()->context(), kCGLineCapSquare); break; } default: { - CGContextSetLineCap(_context, kCGLineCapSquare); + CGContextSetLineCap(currentLayer()->context(), kCGLineCapSquare); break; } } @@ -361,11 +381,11 @@ void CanvasImpl::linearGradientStrokePath(CanvasPathEnumerator const &enumerateP for (const auto value : dashPattern) { mappedDashPattern.push_back(value); } - CGContextSetLineDash(_context, dashPhase, mappedDashPattern.data(), mappedDashPattern.size()); + CGContextSetLineDash(currentLayer()->context(), dashPhase, mappedDashPattern.data(), mappedDashPattern.size()); } - CGContextReplacePathWithStrokedPath(_context); - CGContextClip(_context); + CGContextReplacePathWithStrokedPath(currentLayer()->context()); + CGContextClip(currentLayer()->context()); std::vector components; components.reserve(gradient.colors().size() + 4); @@ -384,59 +404,59 @@ void CanvasImpl::linearGradientStrokePath(CanvasPathEnumerator const &enumerateP locations.push_back(location); } - CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), locations.data(), locations.size()); + CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(currentLayer()->context()), components.data(), locations.data(), locations.size()); if (nativeGradient) { - CGContextDrawLinearGradient(_context, nativeGradient, CGPointMake(start.x, start.y), CGPointMake(end.x, end.y), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation); + CGContextDrawLinearGradient(currentLayer()->context(), nativeGradient, CGPointMake(start.x, start.y), CGPointMake(end.x, end.y), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation); CFRelease(nativeGradient); } - CGContextResetClip(_context); - CGContextRestoreGState(_context); + CGContextResetClip(currentLayer()->context()); + CGContextRestoreGState(currentLayer()->context()); } -void CanvasImpl::radialGradientStrokePath(CanvasPathEnumerator const &enumeratePath, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) { - CGContextSaveGState(_context); - if (!addEnumeratedPath(_context, enumeratePath)) { - CGContextRestoreGState(_context); +void CoreGraphicsCanvasImpl::radialGradientStrokePath(CanvasPathEnumerator const &enumeratePath, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) { + CGContextSaveGState(currentLayer()->context()); + if (!addEnumeratedPath(currentLayer()->context(), enumeratePath)) { + CGContextRestoreGState(currentLayer()->context()); return; } - CGContextSetLineWidth(_context, lineWidth); + CGContextSetLineWidth(currentLayer()->context(), lineWidth); switch (lineJoin) { case lottie::LineJoin::Miter: { - CGContextSetLineJoin(_context, kCGLineJoinMiter); + CGContextSetLineJoin(currentLayer()->context(), kCGLineJoinMiter); break; } case lottie::LineJoin::Round: { - CGContextSetLineJoin(_context, kCGLineJoinRound); + CGContextSetLineJoin(currentLayer()->context(), kCGLineJoinRound); break; } case lottie::LineJoin::Bevel: { - CGContextSetLineJoin(_context, kCGLineJoinBevel); + CGContextSetLineJoin(currentLayer()->context(), kCGLineJoinBevel); break; } default: { - CGContextSetLineJoin(_context, kCGLineJoinBevel); + CGContextSetLineJoin(currentLayer()->context(), kCGLineJoinBevel); break; } } switch (lineCap) { case lottie::LineCap::Butt: { - CGContextSetLineCap(_context, kCGLineCapButt); + CGContextSetLineCap(currentLayer()->context(), kCGLineCapButt); break; } case lottie::LineCap::Round: { - CGContextSetLineCap(_context, kCGLineCapRound); + CGContextSetLineCap(currentLayer()->context(), kCGLineCapRound); break; } case lottie::LineCap::Square: { - CGContextSetLineCap(_context, kCGLineCapSquare); + CGContextSetLineCap(currentLayer()->context(), kCGLineCapSquare); break; } default: { - CGContextSetLineCap(_context, kCGLineCapSquare); + CGContextSetLineCap(currentLayer()->context(), kCGLineCapSquare); break; } } @@ -446,11 +466,11 @@ void CanvasImpl::radialGradientStrokePath(CanvasPathEnumerator const &enumerateP for (const auto value : dashPattern) { mappedDashPattern.push_back(value); } - CGContextSetLineDash(_context, dashPhase, mappedDashPattern.data(), mappedDashPattern.size()); + CGContextSetLineDash(currentLayer()->context(), dashPhase, mappedDashPattern.data(), mappedDashPattern.size()); } - CGContextReplacePathWithStrokedPath(_context); - CGContextClip(_context); + CGContextReplacePathWithStrokedPath(currentLayer()->context()); + CGContextClip(currentLayer()->context()); std::vector components; components.reserve(gradient.colors().size() + 4); @@ -469,72 +489,93 @@ void CanvasImpl::radialGradientStrokePath(CanvasPathEnumerator const &enumerateP locations.push_back(location); } - CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), locations.data(), locations.size()); + CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(currentLayer()->context()), components.data(), locations.data(), locations.size()); if (nativeGradient) { - CGContextDrawRadialGradient(_context, nativeGradient, CGPointMake(startCenter.x, startCenter.y), startRadius, CGPointMake(endCenter.x, endCenter.y), endRadius, kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation); + CGContextDrawRadialGradient(currentLayer()->context(), nativeGradient, CGPointMake(startCenter.x, startCenter.y), startRadius, CGPointMake(endCenter.x, endCenter.y), endRadius, kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation); CFRelease(nativeGradient); } - CGContextResetClip(_context); - CGContextRestoreGState(_context); + CGContextResetClip(currentLayer()->context()); + CGContextRestoreGState(currentLayer()->context()); } -void CanvasImpl::fill(lottie::CGRect const &rect, lottie::Color const &fillColor) { - CGFloat components[4] = { fillColor.r, fillColor.g, fillColor.b, fillColor.a }; - CGColorRef nativeColor = CGColorCreate(CGBitmapContextGetColorSpace(_topContext), components); - CGContextSetFillColorWithColor(_context, nativeColor); - CFRelease(nativeColor); +void CoreGraphicsCanvasImpl::clip(CGRect const &rect) { + CGContextClipToRect(currentLayer()->context(), CGRectMake(rect.x, rect.y, rect.width, rect.height)); +} + +void CoreGraphicsCanvasImpl::concatenate(lottie::Transform2D const &transform) { + CGContextConcatCTM(currentLayer()->context(), CATransform3DGetAffineTransform(nativeTransform(transform))); +} + +std::shared_ptr CoreGraphicsCanvasImpl::makeImage() { + return currentLayer()->makeImage(); +} + +bool CoreGraphicsCanvasImpl::pushLayer(CGRect const &rect, float alpha, std::optional maskMode) { + auto currentTransform = fromNativeTransform(CATransform3DMakeAffineTransform(CGContextGetCTM(currentLayer()->context()))); - CGContextFillRect(_context, CGRectMake(rect.x, rect.y, rect.width, rect.height)); -} - -void CanvasImpl::setBlendMode(BlendMode blendMode) { - ::CGBlendMode nativeMode = kCGBlendModeNormal; - switch (blendMode) { - case BlendMode::Normal: { - nativeMode = kCGBlendModeNormal; - break; - } - case BlendMode::DestinationIn: { - nativeMode = kCGBlendModeDestinationIn; - break; - } - case BlendMode::DestinationOut: { - nativeMode = kCGBlendModeDestinationOut; - break; - } - } - CGContextSetBlendMode(_context, nativeMode); -} - -void CanvasImpl::setAlpha(float alpha) { - CGContextSetAlpha(_context, alpha); -} - -void CanvasImpl::concatenate(lottie::Transform2D const &transform) { - CGContextConcatCTM(_context, CATransform3DGetAffineTransform(nativeTransform(transform))); -} - -std::shared_ptr CanvasImpl::makeImage() const { - ::CGImageRef nativeImage = CGBitmapContextCreateImage(_context); - if (nativeImage) { - auto image = std::make_shared(nativeImage); - CFRelease(nativeImage); - return image; + CGRect globalRect(0.0f, 0.0f, 0.0f, 0.0f); + if (rect == CGRect::veryLarge()) { + globalRect = CGRect(0.0f, 0.0f, (float)_width, (float)_height); } else { - return nil; + CGRect transformedRect = rect.applyingTransform(currentTransform); + + CGRect integralTransformedRect( + std::floor(transformedRect.x), + std::floor(transformedRect.y), + std::ceil(transformedRect.width + transformedRect.x - floor(transformedRect.x)), + std::ceil(transformedRect.height + transformedRect.y - floor(transformedRect.y)) + ); + globalRect = integralTransformedRect.intersection(CGRect(0.0, 0.0, (CGFloat)_width, (CGFloat)_height)); + } + if (globalRect.width <= 0.0f || globalRect.height <= 0.0f) { + return false; + } + + _layerStack.push_back(std::make_shared(globalRect.width, globalRect.height, Layer::Composition(globalRect, alpha, currentTransform, maskMode))); + concatenate(Transform2D::identity().translated(Vector2D(-globalRect.x, -globalRect.y))); + concatenate(currentTransform); + + return true; +} + +void CoreGraphicsCanvasImpl::popLayer() { + auto layer = _layerStack[_layerStack.size() - 1]; + _layerStack.pop_back(); + + if (const auto composition = layer->composition()) { + saveState(); + concatenate(composition->transform.inverted()); + + CGContextSetAlpha(currentLayer()->context(), composition->alpha); + + if (composition->maskMode) { + switch (composition->maskMode.value()) { + case Canvas::MaskMode::Normal: { + CGContextSetBlendMode(currentLayer()->context(), kCGBlendModeDestinationIn); + break; + } + case Canvas::MaskMode::Inverse: { + CGContextSetBlendMode(currentLayer()->context(), kCGBlendModeDestinationOut); + break; + } + default: { + break; + } + } + } + + auto image = layer->makeImage(); + CGContextDrawImage(currentLayer()->context(), CGRectMake(composition->rect.x, composition->rect.y, composition->rect.width, composition->rect.height), ((CoreGraphicsCanvasImpl::Image *)image.get())->nativeImage()); + CGContextSetAlpha(currentLayer()->context(), 1.0); + CGContextSetBlendMode(currentLayer()->context(), kCGBlendModeNormal); + + restoreState(); } } -void CanvasImpl::draw(std::shared_ptr const &other, lottie::CGRect const &rect) { - CanvasImpl *impl = (CanvasImpl *)other.get(); - if (impl->_layer) { - CGContextDrawLayerInRect(_context, CGRectMake(rect.x, rect.y, rect.width, rect.height), impl->_layer); - } else { - auto image = impl->makeImage(); - CGContextDrawImage(_context, CGRectMake(rect.x, rect.y, rect.width, rect.height), ((CanvasImpl::Image *)image.get())->nativeImage()); - } +std::shared_ptr &CoreGraphicsCanvasImpl::currentLayer() { + return _layerStack[_layerStack.size() - 1]; } } - diff --git a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SkiaCanvasImpl.cpp b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SkiaCanvasImpl.cpp index cb7bc72879..d659821a79 100644 --- a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SkiaCanvasImpl.cpp +++ b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SkiaCanvasImpl.cpp @@ -17,6 +17,8 @@ #include "include/effects/SkDashPathEffect.h" #include "include/effects/SkGradientShader.h" +#include + namespace lottie { namespace { @@ -50,8 +52,7 @@ void skPath(CanvasPathEnumerator const &enumeratePath, SkPath &nativePath) { } -SkiaCanvasImpl::SkiaCanvasImpl(int width, int height) : -_width(width), _height(height) { +SkiaCanvasImpl::SkiaCanvasImpl(int width, int height) { int bytesPerRow = width * 4; _pixelData = malloc(bytesPerRow * height); _ownsPixelData = true; @@ -90,18 +91,6 @@ SkiaCanvasImpl::~SkiaCanvasImpl() { } } -int SkiaCanvasImpl::width() const { - return _width; -} - -int SkiaCanvasImpl::height() const { - return _height; -} - -std::shared_ptr SkiaCanvasImpl::makeLayer(int width, int height) { - return std::make_shared(width, height); -} - void SkiaCanvasImpl::saveState() { _canvas->save(); } @@ -113,9 +102,7 @@ void SkiaCanvasImpl::restoreState() { void SkiaCanvasImpl::fillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, lottie::Color const &color) { SkPaint paint; paint.setColor(skColor(color)); - paint.setAlphaf(_alpha); paint.setAntiAlias(true); - paint.setBlendMode(_blendMode); SkPath nativePath; skPath(enumeratePath, nativePath); @@ -127,7 +114,6 @@ void SkiaCanvasImpl::fillPath(CanvasPathEnumerator const &enumeratePath, lottie: void SkiaCanvasImpl::linearGradientFillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, lottie::Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) { SkPaint paint; paint.setAntiAlias(true); - paint.setBlendMode(_blendMode); paint.setDither(false); paint.setStyle(SkPaint::Style::kFill_Style); @@ -138,7 +124,7 @@ void SkiaCanvasImpl::linearGradientFillPath(CanvasPathEnumerator const &enumerat std::vector colors; for (const auto &color : gradient.colors()) { - colors.push_back(skColor(Color(color.r, color.g, color.b, color.a * _alpha))); + colors.push_back(skColor(Color(color.r, color.g, color.b, color.a))); } std::vector locations; @@ -146,7 +132,7 @@ void SkiaCanvasImpl::linearGradientFillPath(CanvasPathEnumerator const &enumerat locations.push_back(location); } - paint.setShader(SkGradientShader::MakeLinear(linearPoints, colors.data(), locations.data(), (int)colors.size(), SkTileMode::kMirror)); + paint.setShader(SkGradientShader::MakeLinear(linearPoints, colors.data(), locations.data(), (int)colors.size(), SkTileMode::kClamp)); SkPath nativePath; skPath(enumeratePath, nativePath); @@ -155,16 +141,14 @@ void SkiaCanvasImpl::linearGradientFillPath(CanvasPathEnumerator const &enumerat _canvas->drawPath(nativePath, paint); } -void SkiaCanvasImpl::radialGradientFillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, lottie::Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) { +void SkiaCanvasImpl::radialGradientFillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, lottie::Gradient const &gradient, Vector2D const ¢er, float radius) { SkPaint paint; paint.setAntiAlias(true); - paint.setBlendMode(_blendMode); - paint.setDither(false); paint.setStyle(SkPaint::Style::kFill_Style); std::vector colors; for (const auto &color : gradient.colors()) { - colors.push_back(skColor(Color(color.r, color.g, color.b, color.a * _alpha))); + colors.push_back(skColor(Color(color.r, color.g, color.b, color.a))); } std::vector locations; @@ -172,7 +156,7 @@ void SkiaCanvasImpl::radialGradientFillPath(CanvasPathEnumerator const &enumerat locations.push_back(location); } - paint.setShader(SkGradientShader::MakeRadial(SkPoint::Make(startCenter.x, startCenter.y), endRadius, colors.data(), locations.data(), (int)colors.size(), SkTileMode::kMirror)); + paint.setShader(SkGradientShader::MakeRadial(SkPoint::Make(center.x, center.y), radius, colors.data(), locations.data(), (int)colors.size(), SkTileMode::kClamp)); SkPath nativePath; skPath(enumeratePath, nativePath); @@ -182,11 +166,12 @@ void SkiaCanvasImpl::radialGradientFillPath(CanvasPathEnumerator const &enumerat } void SkiaCanvasImpl::strokePath(CanvasPathEnumerator const &enumeratePath, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, lottie::Color const &color) { + if (lineWidth <= FLT_EPSILON) { + return; + } SkPaint paint; paint.setAntiAlias(true); - paint.setBlendMode(_blendMode); paint.setColor(skColor(color)); - paint.setAlphaf(_alpha); paint.setStyle(SkPaint::Style::kStroke_Style); paint.setStrokeWidth(lineWidth); @@ -234,6 +219,9 @@ void SkiaCanvasImpl::strokePath(CanvasPathEnumerator const &enumeratePath, float for (auto value : dashPattern) { intervals.push_back(value); } + if (intervals.size() == 1) { + intervals.push_back(intervals[0]); + } paint.setPathEffect(SkDashPathEffect::Make(intervals.data(), (int)intervals.size(), dashPhase)); } @@ -251,39 +239,8 @@ void SkiaCanvasImpl::radialGradientStrokePath(CanvasPathEnumerator const &enumer assert(false); } -void SkiaCanvasImpl::fill(lottie::CGRect const &rect, lottie::Color const &fillColor) { - SkPaint paint; - paint.setAntiAlias(true); - paint.setColor(skColor(fillColor)); - paint.setAlphaf(_alpha); - paint.setBlendMode(_blendMode); - - _canvas->drawRect(SkRect::MakeXYWH(rect.x, rect.y, rect.width, rect.height), paint); -} - -void SkiaCanvasImpl::setBlendMode(BlendMode blendMode) { - switch (blendMode) { - case BlendMode::Normal: { - _blendMode = SkBlendMode::kSrcOver; - break; - } - case BlendMode::DestinationIn: { - _blendMode = SkBlendMode::kDstIn; - break; - } - case BlendMode::DestinationOut: { - _blendMode = SkBlendMode::kDstOut; - break; - } - default: { - _blendMode = SkBlendMode::kSrcOver; - break; - } - } -} - -void SkiaCanvasImpl::setAlpha(float alpha) { - _alpha = alpha; +void SkiaCanvasImpl::clip(CGRect const &rect) { + _canvas->clipRect(SkRect::MakeXYWH(rect.x, rect.y, rect.width, rect.height), true); } void SkiaCanvasImpl::concatenate(lottie::Transform2D const &transform) { @@ -297,13 +254,32 @@ void SkiaCanvasImpl::concatenate(lottie::Transform2D const &transform) { _canvas->concat(matrix); } -void SkiaCanvasImpl::draw(std::shared_ptr const &other, lottie::CGRect const &rect) { - SkiaCanvasImpl *impl = (SkiaCanvasImpl *)other.get(); - auto image = impl->surface()->makeImageSnapshot(); +bool SkiaCanvasImpl::pushLayer(CGRect const &rect, float alpha, std::optional maskMode) { SkPaint paint; - paint.setBlendMode(_blendMode); - paint.setAlphaf(_alpha); - _canvas->drawImageRect(image.get(), SkRect::MakeXYWH(rect.x, rect.y, rect.width, rect.height), SkSamplingOptions(SkFilterMode::kLinear), &paint); + paint.setAntiAlias(true); + paint.setAlphaf(alpha); + if (maskMode) { + switch (maskMode.value()) { + case Canvas::MaskMode::Normal: { + paint.setBlendMode(SkBlendMode::kDstIn); + break; + } + case Canvas::MaskMode::Inverse: { + paint.setBlendMode(SkBlendMode::kDstOut); + break; + } + default: { + break; + } + } + } + + _canvas->saveLayer(SkRect::MakeXYWH(rect.x, rect.y, rect.width, rect.height), &paint); + return true; +} + +void SkiaCanvasImpl::popLayer() { + _canvas->restore(); } void SkiaCanvasImpl::flush() { diff --git a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SkiaCanvasImpl.h b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SkiaCanvasImpl.h index 6d7a2f35ef..ea8ddec7d6 100644 --- a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SkiaCanvasImpl.h +++ b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SkiaCanvasImpl.h @@ -14,29 +14,21 @@ public: SkiaCanvasImpl(int width, int height, int bytesPerRow, void *pixelData); virtual ~SkiaCanvasImpl(); - virtual int width() const override; - virtual int height() const override; - - virtual std::shared_ptr makeLayer(int width, int height) override; - virtual void saveState() override; virtual void restoreState() override; virtual void fillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, lottie::Color const &color) override; virtual void linearGradientFillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, lottie::Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override; - virtual void radialGradientFillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, lottie::Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) override; + virtual void radialGradientFillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, lottie::Gradient const &gradient, Vector2D const ¢er, float radius) override; virtual void strokePath(CanvasPathEnumerator const &enumeratePath, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, lottie::Color const &color) override; virtual void linearGradientStrokePath(CanvasPathEnumerator const &enumeratePath, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override; virtual void radialGradientStrokePath(CanvasPathEnumerator const &enumeratePath, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) override; - virtual void fill(lottie::CGRect const &rect, lottie::Color const &fillColor) override; - - virtual void setBlendMode(BlendMode blendMode) override; - - virtual void setAlpha(float alpha) override; + virtual void clip(CGRect const &rect) override; virtual void concatenate(lottie::Transform2D const &transform) override; - virtual void draw(std::shared_ptr const &other, lottie::CGRect const &rect) override; + virtual bool pushLayer(CGRect const &rect, float alpha, std::optional maskMode) override; + virtual void popLayer() override; void flush(); sk_sp surface() const; @@ -44,12 +36,8 @@ public: private: void *_pixelData = nullptr; bool _ownsPixelData = false; - int _width = 0; - int _height = 0; sk_sp _surface; SkCanvas *_canvas = nullptr; - SkBlendMode _blendMode = SkBlendMode::kSrcOver; - double _alpha = 1.0; }; } diff --git a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SoftwareLottieRenderer.mm b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SoftwareLottieRenderer.mm index 8476ccd457..43a8b83412 100644 --- a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SoftwareLottieRenderer.mm +++ b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SoftwareLottieRenderer.mm @@ -53,102 +53,66 @@ CGRect getPathNativeBoundingBox(CGPathRef _Nonnull path) { return CGSizeMake(size.x, size.y); } -- (void)setFrame:(NSInteger)index { - _renderer->setFrame((int)index); +- (void)setFrame:(CGFloat)index { + _renderer->setFrame((float)index); } -- (UIImage * _Nullable)renderForSize:(CGSize)size useReferenceRendering:(bool)useReferenceRendering { +- (UIImage * _Nullable)renderForSize:(CGSize)size useReferenceRendering:(bool)useReferenceRendering canUseMoreMemory:(bool)canUseMoreMemory skipImageGeneration:(bool)skipImageGeneration { std::shared_ptr renderNode = _renderer->renderNode(); if (!renderNode) { return nil; } + lottie::CanvasRenderer::Configuration configuration; + configuration.canUseMoreMemory = canUseMoreMemory; + //configuration.canUseMoreMemory = true; + //configuration.disableGroupTransparency = true; + if (useReferenceRendering) { - auto context = std::make_shared((int)size.width, (int)size.height); + auto context = std::make_shared((int)size.width, (int)size.height); - _canvasRenderer->render(_renderer, context, lottie::Vector2D(size.width, size.height)); + _canvasRenderer->render(_renderer, context, lottie::Vector2D(size.width, size.height), configuration); auto image = context->makeImage(); - return [[UIImage alloc] initWithCGImage:std::static_pointer_cast(image)->nativeImage()]; + return [[UIImage alloc] initWithCGImage:std::static_pointer_cast(image)->nativeImage()]; } else { if ((int64_t)"" > 0) { - /*auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul((int)size.width, (int)size.height)); - - int bytesPerRow = ((int)size.width) * 4; - void *pixelData = malloc(bytesPerRow * (int)size.height); - - sk_sp surface2 = SkSurfaces::WrapPixels( - SkImageInfo::MakeN32Premul((int)size.width, (int)size.height), - pixelData, - bytesPerRow, - nullptr - ); - - SkCanvas *canvas = surface->getCanvas(); - - SkPaint paint; - paint.setAntiAlias(true); - SkPath path; - path.moveTo(124, 108); - path.lineTo(172, 24); - path.addCircle(50, 50, 30); - path.moveTo(36, 148); - path.quadTo(66, 188, 120, 136); - canvas->drawPath(path, paint); - paint.setStyle(SkPaint::kStroke_Style); - paint.setColor(SK_ColorBLUE); - paint.setStrokeWidth(3); - canvas->drawPath(path, paint); - - CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); - CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host; - - CGContextRef targetContext = CGBitmapContextCreate(pixelData, (int)size.width, (int)size.height, 8, bytesPerRow, colorSpace, bitmapInfo); - CGColorSpaceRelease(colorSpace); - - CGImageRef bitmapImage = CGBitmapContextCreateImage(targetContext); - UIImage *image = [[UIImage alloc] initWithCGImage:bitmapImage scale:1.0f orientation:UIImageOrientationDownMirrored]; - CGImageRelease(bitmapImage); - - CGContextRelease(targetContext); - - free(pixelData); - - return image;*/ - int bytesPerRow = ((int)size.width) * 4; void *pixelData = malloc(bytesPerRow * (int)size.height); auto context = std::make_shared((int)size.width, (int)size.height, bytesPerRow, pixelData); - _canvasRenderer->render(_renderer, context, lottie::Vector2D(size.width, size.height)); - + _canvasRenderer->render(_renderer, context, lottie::Vector2D(size.width, size.height), configuration); context->flush(); - vImage_Buffer src; - src.data = (void *)pixelData; - src.width = (int)size.width; - src.height = (int)size.height; - src.rowBytes = bytesPerRow; - - uint8_t permuteMap[4] = {2, 1, 0, 3}; - vImagePermuteChannels_ARGB8888(&src, &src, permuteMap, kvImageDoNotTile); - - CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); - CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host; - - CGContextRef targetContext = CGBitmapContextCreate(pixelData, (int)size.width, (int)size.height, 8, bytesPerRow, colorSpace, bitmapInfo); - CGColorSpaceRelease(colorSpace); - - CGImageRef bitmapImage = CGBitmapContextCreateImage(targetContext); - UIImage *image = [[UIImage alloc] initWithCGImage:bitmapImage scale:1.0f orientation:UIImageOrientationDownMirrored]; - CGImageRelease(bitmapImage); - - CGContextRelease(targetContext); - - free(pixelData); - - return image; + if (skipImageGeneration) { + free(pixelData); + } else { + vImage_Buffer src; + src.data = (void *)pixelData; + src.width = (int)size.width; + src.height = (int)size.height; + src.rowBytes = bytesPerRow; + + uint8_t permuteMap[4] = {2, 1, 0, 3}; + vImagePermuteChannels_ARGB8888(&src, &src, permuteMap, kvImageDoNotTile); + + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host; + + CGContextRef targetContext = CGBitmapContextCreate(pixelData, (int)size.width, (int)size.height, 8, bytesPerRow, colorSpace, bitmapInfo); + CGColorSpaceRelease(colorSpace); + + CGImageRef bitmapImage = CGBitmapContextCreateImage(targetContext); + UIImage *image = [[UIImage alloc] initWithCGImage:bitmapImage scale:1.0f orientation:UIImageOrientationDownMirrored]; + CGImageRelease(bitmapImage); + + CGContextRelease(targetContext); + + free(pixelData); + + return image; + } } else if ((int64_t)"" < 0) { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ @@ -158,7 +122,7 @@ CGRect getPathNativeBoundingBox(CGPathRef _Nonnull path) { int bytesPerRow = ((int)size.width) * 4; auto context = std::make_shared((int)size.width, (int)size.height, bytesPerRow); - _canvasRenderer->render(_renderer, context, lottie::Vector2D(size.width, size.height)); + _canvasRenderer->render(_renderer, context, lottie::Vector2D(size.width, size.height), configuration); context->flush(); @@ -177,7 +141,7 @@ CGRect getPathNativeBoundingBox(CGPathRef _Nonnull path) { return image; } else { auto context = std::make_shared((int)size.width, (int)size.height); - _canvasRenderer->render(_renderer, context, lottie::Vector2D(size.width, size.height)); + _canvasRenderer->render(_renderer, context, lottie::Vector2D(size.width, size.height), configuration); return nil; } diff --git a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/ThorVGCanvasImpl.cpp b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/ThorVGCanvasImpl.cpp index 1094b33ea6..30b64828b6 100644 --- a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/ThorVGCanvasImpl.cpp +++ b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/ThorVGCanvasImpl.cpp @@ -49,7 +49,7 @@ void ThorVGCanvasImpl::initializeOnce() { } ThorVGCanvasImpl::ThorVGCanvasImpl(int width, int height, int bytesPerRow) : -_width(width), _height(height), _transform(lottie::Transform2D::identity()) { +_transform(lottie::Transform2D::identity()) { _canvas = tvg::SwCanvas::gen(); _bytesPerRow = bytesPerRow; @@ -63,18 +63,6 @@ _width(width), _height(height), _transform(lottie::Transform2D::identity()) { ThorVGCanvasImpl::~ThorVGCanvasImpl() { } -int ThorVGCanvasImpl::width() const { - return _width; -} - -int ThorVGCanvasImpl::height() const { - return _height; -} - -std::shared_ptr ThorVGCanvasImpl::makeLayer(int width, int height) { - return std::make_shared(width, height, width * 4); -} - void ThorVGCanvasImpl::saveState() { _stateStack.push_back(_transform); } @@ -94,7 +82,7 @@ void ThorVGCanvasImpl::fillPath(CanvasPathEnumerator const &enumeratePath, lotti shape->transform(tvgTransform(_transform)); - shape->fill((int)(color.r * 255.0), (int)(color.g * 255.0), (int)(color.b * 255.0), (int)(color.a * _alpha * 255.0)); + shape->fill((int)(color.r * 255.0), (int)(color.g * 255.0), (int)(color.b * 255.0), (int)(color.a * 255.0)); shape->fill(fillRule == lottie::FillRule::EvenOdd ? tvg::FillRule::EvenOdd : tvg::FillRule::Winding); _canvas->push(std::move(shape)); @@ -117,7 +105,7 @@ void ThorVGCanvasImpl::linearGradientFillPath(CanvasPathEnumerator const &enumer colorStop.r = (int)(color.r * 255.0); colorStop.g = (int)(color.g * 255.0); colorStop.b = (int)(color.b * 255.0); - colorStop.a = (int)(color.a * _alpha * 255.0); + colorStop.a = (int)(color.a * 255.0); colors.push_back(colorStop); } fill->colorStops(colors.data(), (uint32_t)colors.size()); @@ -128,14 +116,14 @@ void ThorVGCanvasImpl::linearGradientFillPath(CanvasPathEnumerator const &enumer _canvas->push(std::move(shape)); } -void ThorVGCanvasImpl::radialGradientFillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) { +void ThorVGCanvasImpl::radialGradientFillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, Gradient const &gradient, Vector2D const ¢er, float radius) { auto shape = tvg::Shape::gen(); tvgPath(enumeratePath, shape.get()); shape->transform(tvgTransform(_transform)); auto fill = tvg::RadialGradient::gen(); - fill->radial(startCenter.x, startCenter.y, endRadius); + fill->radial(center.x, center.y, radius); std::vector colors; for (size_t i = 0; i < gradient.colors().size(); i++) { @@ -145,7 +133,7 @@ void ThorVGCanvasImpl::radialGradientFillPath(CanvasPathEnumerator const &enumer colorStop.r = (int)(color.r * 255.0); colorStop.g = (int)(color.g * 255.0); colorStop.b = (int)(color.b * 255.0); - colorStop.a = (int)(color.a * _alpha * 255.0); + colorStop.a = (int)(color.a * 255.0); colors.push_back(colorStop); } fill->colorStops(colors.data(), (uint32_t)colors.size()); @@ -162,7 +150,7 @@ void ThorVGCanvasImpl::strokePath(CanvasPathEnumerator const &enumeratePath, flo shape->transform(tvgTransform(_transform)); - shape->strokeFill((int)(color.r * 255.0), (int)(color.g * 255.0), (int)(color.b * 255.0), (int)(color.a * _alpha * 255.0)); + shape->strokeFill((int)(color.r * 255.0), (int)(color.g * 255.0), (int)(color.b * 255.0), (int)(color.a * 255.0)); shape->strokeWidth(lineWidth); switch (lineJoin) { @@ -222,59 +210,8 @@ void ThorVGCanvasImpl::linearGradientStrokePath(CanvasPathEnumerator const &enum void ThorVGCanvasImpl::radialGradientStrokePath(CanvasPathEnumerator const &enumeratePath, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) { } -void ThorVGCanvasImpl::fill(lottie::CGRect const &rect, lottie::Color const &fillColor) { - auto shape = tvg::Shape::gen(); - shape->appendRect(rect.x, rect.y, rect.width, rect.height, 0.0f, 0.0f); - - shape->transform(tvgTransform(_transform)); - - shape->fill((int)(fillColor.r * 255.0), (int)(fillColor.g * 255.0), (int)(fillColor.b * 255.0), (int)(fillColor.a * _alpha * 255.0)); - - _canvas->push(std::move(shape)); -} - -void ThorVGCanvasImpl::setBlendMode(BlendMode blendMode) { - /*switch (blendMode) { - case CGBlendMode::Normal: { - _blendMode = SkBlendMode::kSrcOver; - break; - } - case CGBlendMode::DestinationIn: { - _blendMode = SkBlendMode::kDstIn; - break; - } - case CGBlendMode::DestinationOut: { - _blendMode = SkBlendMode::kDstOut; - break; - } - default: { - _blendMode = SkBlendMode::kSrcOver; - break; - } - }*/ -} - -void ThorVGCanvasImpl::setAlpha(float alpha) { - _alpha = alpha; -} - void ThorVGCanvasImpl::concatenate(lottie::Transform2D const &transform) { _transform = transform * _transform; - /*_canvas->concat(SkM44( - transform.m11, transform.m21, transform.m31, transform.m41, - transform.m12, transform.m22, transform.m32, transform.m42, - transform.m13, transform.m23, transform.m33, transform.m43, - transform.m14, transform.m24, transform.m34, transform.m44 - ));*/ -} - -void ThorVGCanvasImpl::draw(std::shared_ptr const &other, lottie::CGRect const &rect) { - /*ThorVGCanvasImpl *impl = (ThorVGCanvasImpl *)other.get(); - auto image = impl->surface()->makeImageSnapshot(); - SkPaint paint; - paint.setBlendMode(_blendMode); - paint.setAlphaf(_alpha); - _canvas->drawImageRect(image.get(), SkRect::MakeXYWH(rect.x, rect.y, rect.width, rect.height), SkSamplingOptions(SkFilterMode::kLinear), &paint);*/ } void ThorVGCanvasImpl::flush() { diff --git a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/ThorVGCanvasImpl.h b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/ThorVGCanvasImpl.h index 10cc56489b..9b20b6344e 100644 --- a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/ThorVGCanvasImpl.h +++ b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/ThorVGCanvasImpl.h @@ -14,30 +14,18 @@ public: ThorVGCanvasImpl(int width, int height, int bytesPerRow); virtual ~ThorVGCanvasImpl(); - virtual int width() const override; - virtual int height() const override; - - virtual std::shared_ptr makeLayer(int width, int height) override; - virtual void saveState() override; virtual void restoreState() override; virtual void fillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, lottie::Color const &color) override; virtual void linearGradientFillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, lottie::Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override; - virtual void radialGradientFillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, lottie::Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) override; + virtual void radialGradientFillPath(CanvasPathEnumerator const &enumeratePath, lottie::FillRule fillRule, lottie::Gradient const &gradient, Vector2D const ¢er, float radius) override; virtual void strokePath(CanvasPathEnumerator const &enumeratePath, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, lottie::Color const &color) override; virtual void linearGradientStrokePath(CanvasPathEnumerator const &enumeratePath, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override; virtual void radialGradientStrokePath(CanvasPathEnumerator const &enumeratePath, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) override; - virtual void fill(lottie::CGRect const &rect, lottie::Color const &fillColor) override; - - virtual void setBlendMode(BlendMode blendMode) override; - - virtual void setAlpha(float alpha) override; virtual void concatenate(lottie::Transform2D const &transform) override; - virtual void draw(std::shared_ptr const &other, lottie::CGRect const &rect) override; - uint32_t *backingData() { return _backingData; } @@ -49,11 +37,8 @@ public: void flush(); private: - int _width = 0; - int _height = 0; std::unique_ptr _canvas; - float _alpha = 1.0; lottie::Transform2D _transform; std::vector _stateStack; int _bytesPerRow = 0; diff --git a/Tests/LottieMetalTest/Sources/CompareToReferenceRendering.swift b/Tests/LottieMetalTest/Sources/CompareToReferenceRendering.swift index 2d7babbfed..78d3ef49c4 100644 --- a/Tests/LottieMetalTest/Sources/CompareToReferenceRendering.swift +++ b/Tests/LottieMetalTest/Sources/CompareToReferenceRendering.swift @@ -10,17 +10,26 @@ import SoftwareLottieRenderer import LottieSwift @available(iOS 13.0, *) -func areImagesEqual(_ lhs: UIImage, _ rhs: UIImage) -> UIImage? { +func areImagesEqual(_ lhs: UIImage, _ rhs: UIImage, allowedDifference: Double) -> (UIImage?, UIImage) { let lhsBuffer = try! vImage_Buffer(cgImage: lhs.cgImage!) let rhsBuffer = try! vImage_Buffer(cgImage: rhs.cgImage!) + let deltaBuffer = try! vImage_Buffer(cgImage: lhs.cgImage!) + defer { + lhsBuffer.free() + rhsBuffer.free() + deltaBuffer.free() + } - let maxDifferenceCount = Int((Double(Int(lhs.size.width) * Int(lhs.size.height)) * 0.01)) + memset(deltaBuffer.data, 0, Int(deltaBuffer.height) * deltaBuffer.rowBytes) + + let maxDifferenceCount = Int((Double(Int(lhs.size.width) * Int(lhs.size.height)) * allowedDifference)) var foundDifferenceCount = 0 outer: for y in 0 ..< Int(lhs.size.height) { let lhsRowPixels = lhsBuffer.data.assumingMemoryBound(to: UInt8.self).advanced(by: y * lhsBuffer.rowBytes) let rhsRowPixels = rhsBuffer.data.assumingMemoryBound(to: UInt8.self).advanced(by: y * lhsBuffer.rowBytes) + let deltaRowPixels = deltaBuffer.data.assumingMemoryBound(to: UInt8.self).advanced(by: y * lhsBuffer.rowBytes) for x in 0 ..< Int(lhs.size.width) { let lhs0 = lhsRowPixels.advanced(by: x * 4 + 0).pointee @@ -36,32 +45,30 @@ func areImagesEqual(_ lhs: UIImage, _ rhs: UIImage) -> UIImage? { let maxDiff = 25 if abs(Int(lhs0) - Int(rhs0)) > maxDiff || abs(Int(lhs1) - Int(rhs1)) > maxDiff || abs(Int(lhs2) - Int(rhs2)) > maxDiff || abs(Int(lhs3) - Int(rhs3)) > maxDiff { - /*if false { - lhsRowPixels.advanced(by: x * 4 + 0).pointee = 255 - lhsRowPixels.advanced(by: x * 4 + 1).pointee = 0 - lhsRowPixels.advanced(by: x * 4 + 2).pointee = 0 - lhsRowPixels.advanced(by: x * 4 + 3).pointee = 255 - }*/ + deltaRowPixels.advanced(by: x * 4 + 0).pointee = 255 + deltaRowPixels.advanced(by: x * 4 + 1).pointee = 0 + deltaRowPixels.advanced(by: x * 4 + 2).pointee = 0 + deltaRowPixels.advanced(by: x * 4 + 3).pointee = 255 foundDifferenceCount += 1 } } } - lhsBuffer.free() - rhsBuffer.free() + let colorSpace = Unmanaged.passRetained(lhs.cgImage!.colorSpace!) + let deltaImage = try! deltaBuffer.createCGImage(format: vImage_CGImageFormat(bitsPerComponent: 8, bitsPerPixel: 32, colorSpace: colorSpace, bitmapInfo: lhs.cgImage!.bitmapInfo, version: 0, decode: nil, renderingIntent: .defaultIntent), flags: .doNotTile) if foundDifferenceCount > maxDifferenceCount { - let colorSpace = Unmanaged.passRetained(lhs.cgImage!.colorSpace!) let diffImage = try! lhsBuffer.createCGImage(format: vImage_CGImageFormat(bitsPerComponent: 8, bitsPerPixel: 32, colorSpace: colorSpace, bitmapInfo: lhs.cgImage!.bitmapInfo, version: 0, decode: nil, renderingIntent: .defaultIntent), flags: .doNotTile) - return UIImage(cgImage: diffImage) + + return (UIImage(cgImage: diffImage), UIImage(cgImage: deltaImage)) } else { - return nil + return (nil, UIImage(cgImage: deltaImage)) } } @available(iOS 13.0, *) -func processDrawAnimation(baseCachePath: String, path: String, name: String, size: CGSize, alwaysDraw: Bool, useNonReferenceRendering: Bool, updateImage: @escaping (UIImage?, UIImage?) -> Void) async -> Bool { +func processDrawAnimation(baseCachePath: String, path: String, name: String, size: CGSize, allowedDifference: Double, alwaysDraw: Bool, useNonReferenceRendering: Bool, updateImage: @escaping (UIImage?, UIImage?, UIImage?) -> Void) async -> Bool { guard let data = try? Data(contentsOf: URL(fileURLWithPath: path)) else { print("Could not load \(path)") return false @@ -84,17 +91,19 @@ func processDrawAnimation(baseCachePath: String, path: String, name: String, siz let referenceImageData = try! Data(contentsOf: URL(fileURLWithPath: cacheFolderPath + "/frame\(frameIndex)")) let referenceImage = decompressImageFrame(data: referenceImageData) - renderer.setFrame(frameIndex) - let image = renderer.render(for: size, useReferenceRendering: !useNonReferenceRendering)! + renderer.setFrame(CGFloat(frameIndex)) + let image = renderer.render(for: size, useReferenceRendering: !useNonReferenceRendering, canUseMoreMemory: false, skipImageGeneration: false)! - if !useNonReferenceRendering, let diffImage = areImagesEqual(image, referenceImage) { - updateImage(diffImage, referenceImage) + let (diffImage, deltaImage) = areImagesEqual(image, referenceImage, allowedDifference: allowedDifference) + + if !useNonReferenceRendering, let diffImage { + updateImage(diffImage, referenceImage, deltaImage) print("Mismatch in frame \(frameIndex)") return false } else { if alwaysDraw { - updateImage(image, referenceImage) + updateImage(image, referenceImage, diffImage) } return true } @@ -279,6 +288,43 @@ func decompressImageFrame(data: Data) -> UIImage { return decodeImageQOI(data)! } +final class ReferenceLottieAnimationItem { + private let referenceAnimation: Animation + private let referenceLayer: MainThreadAnimationLayer + let frameCount: Int + + init?(path: String) { + guard let referenceAnimation = Animation.filepath(path) else { + return nil + } + self.referenceAnimation = referenceAnimation + + self.referenceLayer = MainThreadAnimationLayer(animation: referenceAnimation, imageProvider: BlankImageProvider(), textProvider: DefaultTextProvider(), fontProvider: DefaultFontProvider()) + self.referenceLayer.position = referenceAnimation.bounds.center + self.referenceLayer.isOpaque = false + self.referenceLayer.backgroundColor = nil + + self.frameCount = Int(referenceAnimation.endFrame - referenceAnimation.startFrame) + } + + func setFrame(index: Int) { + self.referenceLayer.currentFrame = self.referenceAnimation.startFrame + CGFloat(index) + self.referenceLayer.displayUpdate() + } + + func makeImage(width: Int, height: Int) -> UIImage? { + let size = CGSize(width: CGFloat(width), height: CGFloat(width)) + + let referenceContext = ImageContext(width: width, height: height) + referenceContext.context.clear(CGRect(origin: CGPoint(), size: size)) + referenceContext.context.scaleBy(x: size.width / CGFloat(self.referenceAnimation.width), y: size.height / CGFloat(self.referenceAnimation.height)) + + referenceLayer.render(in: referenceContext.context) + + return referenceContext.makeImage() + } +} + @MainActor func cacheReferenceAnimation(baseCachePath: String, width: Int, path: String, name: String) -> String { let targetFolderPath = cacheReferenceFolderPath(baseCachePath: baseCachePath, width: width, name: name) @@ -286,34 +332,19 @@ func cacheReferenceAnimation(baseCachePath: String, width: Int, path: String, na return targetFolderPath } - guard let referenceAnimation = Animation.filepath(path) else { - preconditionFailure("Could not parse reference animation at \(path)") + guard let referenceItem = ReferenceLottieAnimationItem(path: path) else { + preconditionFailure("Could not load reference animation at \(path)") } - let referenceLayer = MainThreadAnimationLayer(animation: referenceAnimation, imageProvider: BlankImageProvider(), textProvider: DefaultTextProvider(), fontProvider: DefaultFontProvider()) let cacheFolderPath = NSTemporaryDirectory() + "\(UInt64.random(in: 0 ... UInt64.max))" let _ = try? FileManager.default.createDirectory(atPath: cacheFolderPath, withIntermediateDirectories: true) - let frameCount = Int(referenceAnimation.endFrame - referenceAnimation.startFrame) - - let size = CGSize(width: CGFloat(width), height: CGFloat(width)) - - for i in 0 ..< min(100000, frameCount) { - let frameIndex = i % frameCount + for i in 0 ..< min(100000, referenceItem.frameCount) { + let frameIndex = i % referenceItem.frameCount - referenceLayer.currentFrame = CGFloat(frameIndex) - referenceLayer.displayUpdate() - referenceLayer.position = referenceAnimation.bounds.center + referenceItem.setFrame(index: frameIndex) - referenceLayer.isOpaque = false - referenceLayer.backgroundColor = nil - let referenceContext = ImageContext(width: width, height: width) - referenceContext.context.clear(CGRect(origin: CGPoint(), size: size)) - referenceContext.context.scaleBy(x: size.width / CGFloat(referenceAnimation.width), y: size.height / CGFloat(referenceAnimation.height)) - - referenceLayer.render(in: referenceContext.context) - - let referenceImage = referenceContext.makeImage() + let referenceImage = referenceItem.makeImage(width: width, height: width)! try! compressImageFrame(image: referenceImage).write(to: URL(fileURLWithPath: cacheFolderPath + "/frame\(i)")) } diff --git a/Tests/LottieMetalTest/Sources/ViewController.swift b/Tests/LottieMetalTest/Sources/ViewController.swift index 0bd665e3a9..4db3e67960 100644 --- a/Tests/LottieMetalTest/Sources/ViewController.swift +++ b/Tests/LottieMetalTest/Sources/ViewController.swift @@ -13,6 +13,7 @@ private final class ReferenceCompareTest { private let view: UIView private let imageView = UIImageView() private let referenceImageView = UIImageView() + private let deltaImageView = UIImageView() init(view: UIView, testNonReference: Bool) { lottieSwift_getPathNativeBoundingBox = { path in @@ -37,6 +38,12 @@ private final class ReferenceCompareTest { self.referenceImageView.backgroundColor = self.view.backgroundColor self.referenceImageView.transform = CGAffineTransform.init(scaleX: 1.0, y: -1.0) + self.view.addSubview(self.deltaImageView) + self.deltaImageView.layer.magnificationFilter = .nearest + self.deltaImageView.frame = CGRect(origin: CGPoint(x: 10.0, y: topInset + 256.0 + 1.0 + 256.0 + 1.0), size: CGSize(width: 256.0, height: 256.0)) + self.deltaImageView.backgroundColor = self.view.backgroundColor + self.deltaImageView.transform = CGAffineTransform.init(scaleX: 1.0, y: -1.0) + let bundlePath = Bundle.main.path(forResource: "TestDataBundle", ofType: "bundle")! Task.detached { @@ -67,6 +74,9 @@ private final class ReferenceCompareTest { "1391391008142393350.json": 1024 ] + let allowedDifferences: [String: Double] = [ + "1258816259754165.json": 0.04 + ] let defaultSize = 128 let baseCachePath = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true).path + "/frame-cache" @@ -78,7 +88,7 @@ private final class ReferenceCompareTest { } var continueFromName: String? - //continueFromName = "5089561049196134821.json" + //continueFromName = "1258816259754165.json" let _ = await processAnimationFolderAsync(basePath: bundlePath, path: "", stopOnFailure: !testNonReference, process: { path, name, alwaysDraw in if let continueFromNameValue = continueFromName { @@ -91,10 +101,11 @@ private final class ReferenceCompareTest { let size = sizeMapping[name] ?? defaultSize - let result = await processDrawAnimation(baseCachePath: baseCachePath, path: path, name: name, size: CGSize(width: size, height: size), alwaysDraw: alwaysDraw, useNonReferenceRendering: testNonReference, updateImage: { image, referenceImage in + let result = await processDrawAnimation(baseCachePath: baseCachePath, path: path, name: name, size: CGSize(width: size, height: size), allowedDifference: allowedDifferences[name] ?? 0.01, alwaysDraw: alwaysDraw, useNonReferenceRendering: testNonReference, updateImage: { image, referenceImage, differenceImage in DispatchQueue.main.async { self.imageView.image = image self.referenceImageView.image = referenceImage + self.deltaImageView.image = differenceImage } }) return result @@ -103,6 +114,139 @@ private final class ReferenceCompareTest { } } +@available(iOS 13.0, *) +private final class ManualReferenceCompareTest { + private final class Item { + let renderer: SoftwareLottieRenderer + let referenceRenderer: ReferenceLottieAnimationItem + + init(renderer: SoftwareLottieRenderer, referenceRenderer: ReferenceLottieAnimationItem) { + self.renderer = renderer + self.referenceRenderer = referenceRenderer + } + } + + private let view: UIView + private let imageView = UIImageView() + private let referenceImageView = UIImageView() + private let labelView = UILabel() + + private let renderSize: CGSize + private let testNonReference: Bool + + private let fileList: [(filePath: String, fileName: String)] + private var currentFileIndex: Int = 0 + private var currentItem: Item? + + private var frameDisplayLink: SharedDisplayLinkDriver.Link? + + init(view: UIView) { + self.testNonReference = true + + self.currentFileIndex = 0 + + lottieSwift_getPathNativeBoundingBox = { path in + return getPathNativeBoundingBox(path) + } + + let bundlePath = Bundle.main.path(forResource: "TestDataBundle", ofType: "bundle")! + self.fileList = buildAnimationFolderItems(basePath: bundlePath, path: "") + + self.renderSize = CGSize(width: 256.0, height: 256.0) + + self.view = view + self.view.backgroundColor = .white + + self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.tapGesture(_:)))) + + let topInset: CGFloat = 50.0 + + self.view.addSubview(self.imageView) + self.imageView.layer.magnificationFilter = .nearest + self.imageView.frame = CGRect(origin: CGPoint(x: 10.0, y: topInset), size: CGSize(width: 256.0, height: 256.0)) + self.imageView.backgroundColor = self.view.backgroundColor + self.imageView.transform = CGAffineTransform.init(scaleX: 1.0, y: -1.0) + + self.view.addSubview(self.referenceImageView) + self.referenceImageView.layer.magnificationFilter = .nearest + self.referenceImageView.frame = CGRect(origin: CGPoint(x: 10.0, y: topInset + 256.0 + 1.0), size: CGSize(width: 256.0, height: 256.0)) + self.referenceImageView.backgroundColor = self.view.backgroundColor + self.referenceImageView.transform = CGAffineTransform.init(scaleX: 1.0, y: -1.0) + + self.view.addSubview(self.labelView) + + self.updateCurrentAnimation() + } + + @objc private func tapGesture(_ recognizer: UITapGestureRecognizer) { + if case .ended = recognizer.state { + if recognizer.location(in: self.view).x <= self.view.bounds.width * 0.5 { + if self.currentFileIndex != 0 { + self.currentFileIndex = self.currentFileIndex - 1 + } + } else { + self.currentFileIndex = (self.currentFileIndex + 1) % self.fileList.count + } + self.updateCurrentAnimation() + } + } + + private func updateCurrentAnimation() { + self.imageView.image = nil + self.referenceImageView.image = nil + self.currentItem = nil + + self.labelView.text = "\(self.currentFileIndex + 1) / \(self.fileList.count)" + self.labelView.sizeToFit() + self.labelView.center = CGPoint(x: self.view.bounds.midX, y: self.view.bounds.height - 10.0 - self.labelView.bounds.height) + + self.frameDisplayLink?.invalidate() + self.frameDisplayLink = nil + + let (filePath, _) = self.fileList[self.currentFileIndex] + + guard let data = try? Data(contentsOf: URL(fileURLWithPath: filePath)) else { + print("Could not load \(filePath)") + return + } + guard let renderer = SoftwareLottieRenderer(data: data) else { + print("Could not load animation at \(filePath)") + return + } + guard let referenceRenderer = ReferenceLottieAnimationItem(path: filePath) else { + print("Could not load reference animation at \(filePath)") + return + } + + let currentItem = Item(renderer: renderer, referenceRenderer: referenceRenderer) + self.currentItem = currentItem + + var animationTime = 0.0 + let secondsPerFrame = 1.0 / Double(renderer.framesPerSecond) + + let frameDisplayLink = SharedDisplayLinkDriver.shared.add(framesPerSecond: .max, { [weak self] deltaTime in + guard let self, let currentItem = self.currentItem else { + return + } + + var frameIndex = animationTime / secondsPerFrame + frameIndex = frameIndex.truncatingRemainder(dividingBy: Double(currentItem.renderer.frameCount)) + + currentItem.renderer.setFrame(frameIndex) + let image = currentItem.renderer.render(for: self.renderSize, useReferenceRendering: !self.testNonReference, canUseMoreMemory: false, skipImageGeneration: false)! + self.imageView.image = image + + currentItem.referenceRenderer.setFrame(index: Int(frameIndex)) + let referenceImage = currentItem.referenceRenderer.makeImage(width: Int(self.renderSize.width), height: Int(self.renderSize.height))! + self.referenceImageView.image = referenceImage + + animationTime += deltaTime + }) + self.frameDisplayLink = frameDisplayLink + frameDisplayLink.isPaused = false + } +} + public final class ViewController: UIViewController { private var link: SharedDisplayLinkDriver.Link? private var test: AnyObject? @@ -115,13 +259,17 @@ public final class ViewController: UIViewController { let bundlePath = Bundle.main.path(forResource: "TestDataBundle", ofType: "bundle")! let filePath = bundlePath + "/fire.json" - let performanceFrameSize = 512 + let performanceFrameSize = 128 self.view.layer.addSublayer(MetalEngine.shared.rootLayer) if !"".isEmpty { if #available(iOS 13.0, *) { - self.test = ReferenceCompareTest(view: self.view, testNonReference: true) + self.test = ReferenceCompareTest(view: self.view, testNonReference: false) + } + } else if "".isEmpty { + if #available(iOS 13.0, *) { + self.test = ManualReferenceCompareTest(view: self.view) } } else if !"".isEmpty { /*let cachedAnimation = cacheLottieMetalAnimation(path: filePath)! @@ -160,8 +308,8 @@ public final class ViewController: UIViewController { var numUpdates: Int = 0 var frameIndex = 0 while true { - animationRenderer.setFrame(frameIndex) - let _ = animationRenderer.render(for: CGSize(width: CGFloat(performanceFrameSize), height: CGFloat(performanceFrameSize)), useReferenceRendering: false) + animationRenderer.setFrame(CGFloat(frameIndex)) + let _ = animationRenderer.render(for: CGSize(width: CGFloat(performanceFrameSize), height: CGFloat(performanceFrameSize)), useReferenceRendering: false, canUseMoreMemory: true, skipImageGeneration: true) frameIndex = (frameIndex + 1) % animationRenderer.frameCount numUpdates += 1 let timestamp = CFAbsoluteTimeGetCurrent() diff --git a/Tests/LottieMetalTest/skia/BUILD b/Tests/LottieMetalTest/skia/BUILD index 2444ddde2c..540ec8688e 100644 --- a/Tests/LottieMetalTest/skia/BUILD +++ b/Tests/LottieMetalTest/skia/BUILD @@ -3,12 +3,18 @@ load("@build_bazel_rules_apple//apple:apple.bzl", "apple_dynamic_framework_import", ) +framework_imports = select({ + "@build_bazel_rules_apple//apple:ios_arm64": glob([ + "device/libskia.framework/**" + ]), + "//build-system:ios_sim_arm64": glob([ + "simulator/libskia.framework/**" + ]) +}) apple_dynamic_framework_import( name = "libskia", - framework_imports = glob([ - "libskia.framework/**" - ]), + framework_imports = framework_imports, visibility = ["//visibility:public"], ) diff --git a/Tests/LottieMetalTest/skia/libskia.framework/Info.plist b/Tests/LottieMetalTest/skia/simulator/libskia.framework/Info.plist similarity index 100% rename from Tests/LottieMetalTest/skia/libskia.framework/Info.plist rename to Tests/LottieMetalTest/skia/simulator/libskia.framework/Info.plist diff --git a/Tests/LottieMetalTest/skia/libskia.framework/libskia b/Tests/LottieMetalTest/skia/simulator/libskia.framework/libskia similarity index 100% rename from Tests/LottieMetalTest/skia/libskia.framework/libskia rename to Tests/LottieMetalTest/skia/simulator/libskia.framework/libskia diff --git a/submodules/AccountContext/Sources/PresentationCallManager.swift b/submodules/AccountContext/Sources/PresentationCallManager.swift index ef5cd03b33..c232006fb2 100644 --- a/submodules/AccountContext/Sources/PresentationCallManager.swift +++ b/submodules/AccountContext/Sources/PresentationCallManager.swift @@ -419,6 +419,8 @@ public protocol PresentationGroupCall: AnyObject { var memberEvents: Signal { get } var reconnectedAsEvents: Signal { get } + var onMutedSpeechActivityDetected: ((Bool) -> Void)? { get set } + func toggleScheduledSubscription(_ subscribe: Bool) func schedule(timestamp: Int32) func startScheduled() diff --git a/submodules/AttachmentTextInputPanelNode/Sources/AttachmentTextInputActionButtonsNode.swift b/submodules/AttachmentTextInputPanelNode/Sources/AttachmentTextInputActionButtonsNode.swift index 045e0a6459..16b413b6ae 100644 --- a/submodules/AttachmentTextInputPanelNode/Sources/AttachmentTextInputActionButtonsNode.swift +++ b/submodules/AttachmentTextInputPanelNode/Sources/AttachmentTextInputActionButtonsNode.swift @@ -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) } } diff --git a/submodules/AttachmentUI/Sources/AttachmentPanel.swift b/submodules/AttachmentUI/Sources/AttachmentPanel.swift index 00a9cc0bea..920159407f 100644 --- a/submodules/AttachmentUI/Sources/AttachmentPanel.swift +++ b/submodules/AttachmentUI/Sources/AttachmentPanel.swift @@ -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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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 } diff --git a/submodules/AudioBlob/BUILD b/submodules/AudioBlob/BUILD index 72c69fa1aa..dc0d2ee1d4 100644 --- a/submodules/AudioBlob/BUILD +++ b/submodules/AudioBlob/BUILD @@ -10,9 +10,11 @@ swift_library( "-warnings-as-errors", ], deps = [ - "//submodules/AsyncDisplayKit:AsyncDisplayKit", - "//submodules/Display:Display", - "//submodules/LegacyComponents:LegacyComponents", + "//submodules/AsyncDisplayKit", + "//submodules/Display", + "//submodules/LegacyComponents", + "//submodules/MetalEngine", + "//submodules/TelegramUI/Components/Calls/CallScreen", ], visibility = [ "//visibility:public", diff --git a/submodules/AudioBlob/Sources/BlobView.swift b/submodules/AudioBlob/Sources/BlobView.swift index c1b287fbe5..f4418ed1e8 100644 --- a/submodules/AudioBlob/Sources/BlobView.swift +++ b/submodules/AudioBlob/Sources/BlobView.swift @@ -3,6 +3,8 @@ import UIKit import AsyncDisplayKit import Display import LegacyComponents +import CallScreen +import MetalEngine public final class VoiceBlobNode: ASDisplayNode { public init( @@ -36,9 +38,7 @@ public final class VoiceBlobNode: ASDisplayNode { } public final class VoiceBlobView: UIView, TGModernConversationInputMicButtonDecoration { - private let smallBlob: BlobNode - private let mediumBlob: BlobNode - private let bigBlob: BlobNode + private let blobsLayer: CallBlobsLayer private let maxLevel: CGFloat @@ -65,7 +65,7 @@ public final class VoiceBlobView: UIView, TGModernConversationInputMicButtonDeco ) { self.maxLevel = maxLevel - self.smallBlob = BlobNode( + /*self.smallBlob = BlobNode( pointsCount: 8, minRandomness: 0.1, maxRandomness: 0.5, @@ -97,7 +97,9 @@ public final class VoiceBlobView: UIView, TGModernConversationInputMicButtonDeco maxScale: bigBlobRange.max, scaleSpeed: 0.2, isCircle: false - ) + )*/ + + self.blobsLayer = CallBlobsLayer(colors: [UIColor.white, UIColor.white.withAlphaComponent(0.3), UIColor.white.withAlphaComponent(0.15)]) var updateInHierarchy: ((Bool) -> Void)? self.hierarchyTrackingNode = HierarchyTrackingNode({ value in @@ -108,18 +110,21 @@ public final class VoiceBlobView: UIView, TGModernConversationInputMicButtonDeco self.addSubnode(self.hierarchyTrackingNode) - self.addSubnode(self.bigBlob) + /*self.addSubnode(self.bigBlob) self.addSubnode(self.mediumBlob) - self.addSubnode(self.smallBlob) + self.addSubnode(self.smallBlob)*/ - displayLinkAnimator = ConstantDisplayLinkAnimator() { [weak self] in + self.layer.addSublayer(self.blobsLayer) + + self.displayLinkAnimator = ConstantDisplayLinkAnimator() { [weak self] in guard let strongSelf = self else { return } strongSelf.presentationAudioLevel = strongSelf.presentationAudioLevel * 0.9 + strongSelf.audioLevel * 0.1 + strongSelf.updateAudioLevel() - strongSelf.smallBlob.level = strongSelf.presentationAudioLevel + /*strongSelf.smallBlob.level = strongSelf.presentationAudioLevel strongSelf.mediumBlob.level = strongSelf.presentationAudioLevel - strongSelf.bigBlob.level = strongSelf.presentationAudioLevel + strongSelf.bigBlob.level = strongSelf.presentationAudioLevel*/ } updateInHierarchy = { [weak self] value in @@ -138,12 +143,20 @@ public final class VoiceBlobView: UIView, TGModernConversationInputMicButtonDeco } public func setColor(_ color: UIColor, animated: Bool) { + let transition: ContainedViewLayoutTransition + if animated { + transition = .animated(duration: 0.2, curve: .easeInOut) + } else { + transition = .immediate + } + transition.updateTintColor(layer: self.blobsLayer, color: color) + if let isManuallyInHierarchy = self.isManuallyInHierarchy, !isManuallyInHierarchy { return } - smallBlob.setColor(color, animated: animated) + /*smallBlob.setColor(color, animated: animated) mediumBlob.setColor(color.withAlphaComponent(0.3), animated: animated) - bigBlob.setColor(color.withAlphaComponent(0.15), animated: animated) + bigBlob.setColor(color.withAlphaComponent(0.15), animated: animated)*/ } public func updateLevel(_ level: CGFloat) { @@ -153,9 +166,9 @@ public final class VoiceBlobView: UIView, TGModernConversationInputMicButtonDeco public func updateLevel(_ level: CGFloat, immediately: Bool = false) { let normalizedLevel = min(1, max(level / maxLevel, 0)) - smallBlob.updateSpeedLevel(to: normalizedLevel) + /*smallBlob.updateSpeedLevel(to: normalizedLevel) mediumBlob.updateSpeedLevel(to: normalizedLevel) - bigBlob.updateSpeedLevel(to: normalizedLevel) + bigBlob.updateSpeedLevel(to: normalizedLevel)*/ audioLevel = normalizedLevel if immediately { @@ -163,6 +176,13 @@ public final class VoiceBlobView: UIView, TGModernConversationInputMicButtonDeco } } + private func updateAudioLevel() { + let additionalAvatarScale = CGFloat(max(0.0, min(self.presentationAudioLevel * 18.0, 5.0)) * 0.05) + let blobAmplificationFactor: CGFloat = 2.0 + let blobScale = 1.0 + additionalAvatarScale * blobAmplificationFactor + self.blobsLayer.transform = CATransform3DMakeScale(blobScale, blobScale, 1.0) + } + public func startAnimating() { self.startAnimating(immediately: false) } @@ -171,13 +191,13 @@ public final class VoiceBlobView: UIView, TGModernConversationInputMicButtonDeco guard !isAnimating else { return } isAnimating = true - if !immediately { + /*if !immediately { mediumBlob.layer.animateScale(from: 0.75, to: 1, duration: 0.35, removeOnCompletion: false) bigBlob.layer.animateScale(from: 0.75, to: 1, duration: 0.35, removeOnCompletion: false) } else { mediumBlob.layer.removeAllAnimations() bigBlob.layer.removeAllAnimations() - } + }*/ updateBlobsState() @@ -192,8 +212,8 @@ public final class VoiceBlobView: UIView, TGModernConversationInputMicButtonDeco guard isAnimating else { return } isAnimating = false - mediumBlob.layer.animateScale(from: 1.0, to: 0.75, duration: duration, removeOnCompletion: false) - bigBlob.layer.animateScale(from: 1.0, to: 0.75, duration: duration, removeOnCompletion: false) + /*mediumBlob.layer.animateScale(from: 1.0, to: 0.75, duration: duration, removeOnCompletion: false) + bigBlob.layer.animateScale(from: 1.0, to: 0.75, duration: duration, removeOnCompletion: false)*/ updateBlobsState() @@ -201,7 +221,7 @@ public final class VoiceBlobView: UIView, TGModernConversationInputMicButtonDeco } private func updateBlobsState() { - if self.isAnimating { + /*if self.isAnimating { if self.smallBlob.frame.size != .zero { smallBlob.startAnimating() mediumBlob.startAnimating() @@ -211,15 +231,19 @@ public final class VoiceBlobView: UIView, TGModernConversationInputMicButtonDeco smallBlob.stopAnimating() mediumBlob.stopAnimating() bigBlob.stopAnimating() - } + }*/ } override public func layoutSubviews() { super.layoutSubviews() - self.smallBlob.frame = bounds + /*self.smallBlob.frame = bounds self.mediumBlob.frame = bounds - self.bigBlob.frame = bounds + self.bigBlob.frame = bounds*/ + + let blobsFrame = bounds.insetBy(dx: floor(bounds.width * 0.12), dy: floor(bounds.height * 0.12)) + self.blobsLayer.position = blobsFrame.center + self.blobsLayer.bounds = CGRect(origin: CGPoint(), size: blobsFrame.size) self.updateBlobsState() } diff --git a/submodules/AvatarNode/Sources/AvatarNode.swift b/submodules/AvatarNode/Sources/AvatarNode.swift index 937be9432c..3c0704b3f8 100644 --- a/submodules/AvatarNode/Sources/AvatarNode.swift +++ b/submodules/AvatarNode/Sources/AvatarNode.swift @@ -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 } diff --git a/submodules/BrowserUI/Sources/BrowserContent.swift b/submodules/BrowserUI/Sources/BrowserContent.swift index 3609d87116..8f5f863582 100644 --- a/submodules/BrowserUI/Sources/BrowserContent.swift +++ b/submodules/BrowserUI/Sources/BrowserContent.swift @@ -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 diff --git a/submodules/BrowserUI/Sources/BrowserInstantPageContent.swift b/submodules/BrowserUI/Sources/BrowserInstantPageContent.swift index d3a781b7e4..e000456868 100644 --- a/submodules/BrowserUI/Sources/BrowserInstantPageContent.swift +++ b/submodules/BrowserUI/Sources/BrowserInstantPageContent.swift @@ -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) { // // } // diff --git a/submodules/BrowserUI/Sources/BrowserNavigationBarComponent.swift b/submodules/BrowserUI/Sources/BrowserNavigationBarComponent.swift index 3476e0de77..7e20575261 100644 --- a/submodules/BrowserUI/Sources/BrowserNavigationBarComponent.swift +++ b/submodules/BrowserUI/Sources/BrowserNavigationBarComponent.swift @@ -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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/BrowserUI/Sources/BrowserScreen.swift b/submodules/BrowserUI/Sources/BrowserScreen.swift index 5108eaa2e4..71dbde446a 100644 --- a/submodules/BrowserUI/Sources/BrowserScreen.swift +++ b/submodules/BrowserUI/Sources/BrowserScreen.swift @@ -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)) } } diff --git a/submodules/BrowserUI/Sources/BrowserSearchBarComponent.swift b/submodules/BrowserUI/Sources/BrowserSearchBarComponent.swift index df776d64d2..c49fa13540 100644 --- a/submodules/BrowserUI/Sources/BrowserSearchBarComponent.swift +++ b/submodules/BrowserUI/Sources/BrowserSearchBarComponent.swift @@ -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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/BrowserUI/Sources/BrowserToolbarComponent.swift b/submodules/BrowserUI/Sources/BrowserToolbarComponent.swift index 00a8c2c039..afe73f5737 100644 --- a/submodules/BrowserUI/Sources/BrowserToolbarComponent.swift +++ b/submodules/BrowserUI/Sources/BrowserToolbarComponent.swift @@ -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() }) diff --git a/submodules/BrowserUI/Sources/BrowserWebContent.swift b/submodules/BrowserUI/Sources/BrowserWebContent.swift index 06b57d7a71..9f227afc8b 100644 --- a/submodules/BrowserUI/Sources/BrowserWebContent.swift +++ b/submodules/BrowserUI/Sources/BrowserWebContent.swift @@ -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 { diff --git a/submodules/CalendarMessageScreen/Sources/CalendarMessageScreen.swift b/submodules/CalendarMessageScreen/Sources/CalendarMessageScreen.swift index 078503777c..991e2bea6d 100644 --- a/submodules/CalendarMessageScreen/Sources/CalendarMessageScreen.swift +++ b/submodules/CalendarMessageScreen/Sources/CalendarMessageScreen.swift @@ -404,7 +404,7 @@ private final class DayComponent: Component { self.action?() } - func update(component: DayComponent, availableSize: CGSize, environment: Environment, transition: Transition) -> CGSize { + func update(component: DayComponent, availableSize: CGSize, environment: Environment, 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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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 diff --git a/submodules/ChatListUI/Sources/ChatListContainerItemNode.swift b/submodules/ChatListUI/Sources/ChatListContainerItemNode.swift index 4d9d6eadac..c28d06df04 100644 --- a/submodules/ChatListUI/Sources/ChatListContainerItemNode.swift +++ b/submodules/ChatListUI/Sources/ChatListContainerItemNode.swift @@ -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 { diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index d1e8f5ac17..c144f273da 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -898,7 +898,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 ))) diff --git a/submodules/ChatListUI/Sources/ChatListControllerNode.swift b/submodules/ChatListUI/Sources/ChatListControllerNode.swift index 254d87e596..b561ba8d89 100644 --- a/submodules/ChatListUI/Sources/ChatListControllerNode.swift +++ b/submodules/ChatListUI/Sources/ChatListControllerNode.swift @@ -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))) } } diff --git a/submodules/ChatListUI/Sources/ChatListEmptyNode.swift b/submodules/ChatListUI/Sources/ChatListEmptyNode.swift index b57a74f469..c8c78b3c3f 100644 --- a/submodules/ChatListUI/Sources/ChatListEmptyNode.swift +++ b/submodules/ChatListUI/Sources/ChatListEmptyNode.swift @@ -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, diff --git a/submodules/ChatListUI/Sources/Node/ChatListItem.swift b/submodules/ChatListUI/Sources/Node/ChatListItem.swift index 3d4d0dde25..7a663626b2 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListItem.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListItem.swift @@ -318,7 +318,7 @@ private final class ChatListItemTagListComponent: Component { preconditionFailure() } - func update(component: ChatListItemTagListComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ChatListItemTagListComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/ChatPresentationInterfaceState/Sources/ChatPresentationInterfaceState.swift b/submodules/ChatPresentationInterfaceState/Sources/ChatPresentationInterfaceState.swift index 15849fc8fa..0152458b2c 100644 --- a/submodules/ChatPresentationInterfaceState/Sources/ChatPresentationInterfaceState.swift +++ b/submodules/ChatPresentationInterfaceState/Sources/ChatPresentationInterfaceState.swift @@ -1265,7 +1265,15 @@ public func canSendMessagesToChat(_ state: ChatPresentationInterfaceState) -> Bo return false } } else if case .customChatContents = state.chatLocation { - return true + if case let .customChatContents(contents) = state.subject { + if case .hashTagSearch = contents.kind { + return false + } else { + return true + } + } else { + return true + } } else { return false } diff --git a/submodules/ChatSendMessageActionUI/Sources/ChatSendMessageContextScreen.swift b/submodules/ChatSendMessageActionUI/Sources/ChatSendMessageContextScreen.swift index f0ad22f2c8..93890722b8 100644 --- a/submodules/ChatSendMessageActionUI/Sources/ChatSendMessageContextScreen.swift +++ b/submodules/ChatSendMessageActionUI/Sources/ChatSendMessageContextScreen.swift @@ -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, transition: Transition) -> CGSize { + func update(component: ChatSendMessageContextScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/ChatSendMessageActionUI/Sources/MessageItemView.swift b/submodules/ChatSendMessageActionUI/Sources/MessageItemView.swift index 2666df9e8e..8948d8e2ef 100644 --- a/submodules/ChatSendMessageActionUI/Sources/MessageItemView.swift +++ b/submodules/ChatSendMessageActionUI/Sources/MessageItemView.swift @@ -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, transition: Transition) -> CGSize { + func update(component: ChatSendMessageScreenEffectIcon, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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 diff --git a/submodules/ChatSendMessageActionUI/Sources/SendButton.swift b/submodules/ChatSendMessageActionUI/Sources/SendButton.swift index 160cadb066..74ca91380d 100644 --- a/submodules/ChatSendMessageActionUI/Sources/SendButton.swift +++ b/submodules/ChatSendMessageActionUI/Sources/SendButton.swift @@ -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) } diff --git a/submodules/ComponentFlow/Source/Base/ChildComponentTransitions.swift b/submodules/ComponentFlow/Source/Base/ChildComponentTransitions.swift index 6871454b3b..043415132b 100644 --- a/submodules/ComponentFlow/Source/Base/ChildComponentTransitions.swift +++ b/submodules/ComponentFlow/Source/Base/ChildComponentTransitions.swift @@ -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)) diff --git a/submodules/ComponentFlow/Source/Base/CombinedComponent.swift b/submodules/ComponentFlow/Source/Base/CombinedComponent.swift index 04df0fd8ce..4f43d6cff3 100644 --- a/submodules/ComponentFlow/Source/Base/CombinedComponent.swift +++ b/submodules/ComponentFlow/Source/Base/CombinedComponent.swift @@ -6,7 +6,7 @@ private func updateChildAnyComponent( component: AnyComponent, view: UIView, availableSize: CGSize, - transition: Transition + transition: ComponentTransition ) -> _UpdatedChildComponent { let parentContext = _AnyCombinedComponentContext.current @@ -85,7 +85,7 @@ public final class _ConcreteChildComponent: _AnyChildC return .direct(self.directId) } - public func update(component: ComponentType, @EnvironmentBuilder environment: () -> Environment, availableSize: CGSize, transition: Transition) -> _UpdatedChildComponent { + public func update(component: ComponentType, @EnvironmentBuilder environment: () -> Environment, 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: _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: _AnyChildCompone return .direct(self.directId) } - func update(component: AnyComponent, @EnvironmentBuilder environment: () -> Environment, availableSize: CGSize, transition: Transition) -> _UpdatedChildComponent { + func update(component: AnyComponent, @EnvironmentBuilder environment: () -> Environment, 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: _AnyChildCompone } public extension _EnvironmentChildComponent where EnvironmentType == Empty { - func update(component: AnyComponent, availableSize: CGSize, transition: Transition) -> _UpdatedChildComponent { + func update(component: AnyComponent, availableSize: CGSize, transition: ComponentTransition) -> _UpdatedChildComponent { return self.update(component: component, environment: {}, availableSize: availableSize, transition: transition) } } public extension _EnvironmentChildComponent { - func update(_ component: ComponentType, @EnvironmentBuilder environment: () -> Environment, availableSize: CGSize, transition: Transition) -> _UpdatedChildComponent where ComponentType.EnvironmentType == EnvironmentType { + func update(_ component: ComponentType, @EnvironmentBuilder environment: () -> Environment, availableSize: CGSize, transition: ComponentTransition) -> _UpdatedChildComponent where ComponentType.EnvironmentType == EnvironmentType { return self.update(component: AnyComponent(component), environment: environment, availableSize: availableSize, transition: transition) } - func update(_ component: ComponentType, @EnvironmentBuilder environment: () -> Environment, availableSize: CGSize, transition: Transition) -> _UpdatedChildComponent where ComponentType.EnvironmentType == EnvironmentType, EnvironmentType == Empty { + func update(_ component: ComponentType, @EnvironmentBuilder environment: () -> Environment, 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: _AnyChild self.id = id } - public func update(component: AnyComponent, @EnvironmentBuilder environment: () -> Environment, availableSize: CGSize, transition: Transition) -> _UpdatedChildComponent { + public func update(component: AnyComponent, @EnvironmentBuilder environment: () -> Environment, 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: _AnyChild } public extension _EnvironmentChildComponentFromMap where EnvironmentType == Empty { - func update(component: AnyComponent, availableSize: CGSize, transition: Transition) -> _UpdatedChildComponent { + func update(component: AnyComponent, availableSize: CGSize, transition: ComponentTransition) -> _UpdatedChildComponent { return self.update(component: component, environment: {}, availableSize: availableSize, transition: transition) } } @@ -393,7 +393,7 @@ public final class CombinedComponentContext { 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 { @@ -408,7 +408,7 @@ public final class CombinedComponentContext { 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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: State, environment: Environment, 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]] { diff --git a/submodules/ComponentFlow/Source/Base/Component.swift b/submodules/ComponentFlow/Source/Base/Component.swift index fabce5cf5c..69e0627fec 100644 --- a/submodules/ComponentFlow/Source/Base/Component.swift +++ b/submodules/ComponentFlow/Source/Base/Component.swift @@ -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, transition: Transition) -> CGSize + func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize } public extension Component { @@ -139,7 +139,7 @@ public extension Component { return ComponentContext(component: self, environment: Environment(), 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, transition: transition) @@ -191,7 +191,7 @@ public class AnyComponent: _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, transition: transition) } diff --git a/submodules/ComponentFlow/Source/Base/Transition.swift b/submodules/ComponentFlow/Source/Base/Transition.swift index 6ed046685d..227a314ad1 100644 --- a/submodules/ComponentFlow/Source/Base/Transition.swift +++ b/submodules/ComponentFlow/Source/Base/Transition.swift @@ -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, diff --git a/submodules/ComponentFlow/Source/Components/Button.swift b/submodules/ComponentFlow/Source/Components/Button.swift index 41211e34ba..c599f0ee6c 100644 --- a/submodules/ComponentFlow/Source/Components/Button.swift +++ b/submodules/ComponentFlow/Source/Components/Button.swift @@ -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, transition: Transition) -> CGSize { + func update(component: Button, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/ComponentFlow/Source/Components/Circle.swift b/submodules/ComponentFlow/Source/Components/Circle.swift index cb770423f0..d999fec87f 100644 --- a/submodules/ComponentFlow/Source/Components/Circle.swift +++ b/submodules/ComponentFlow/Source/Components/Circle.swift @@ -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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/ComponentFlow/Source/Components/Image.swift b/submodules/ComponentFlow/Source/Components/Image.swift index dfc4d34ecc..78475c942f 100644 --- a/submodules/ComponentFlow/Source/Components/Image.swift +++ b/submodules/ComponentFlow/Source/Components/Image.swift @@ -44,7 +44,7 @@ public final class Image: Component { preconditionFailure() } - func update(component: Image, availableSize: CGSize, environment: Environment, transition: Transition) -> CGSize { + func update(component: Image, availableSize: CGSize, environment: Environment, 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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, environment: environment, transition: transition) } } diff --git a/submodules/ComponentFlow/Source/Components/List.swift b/submodules/ComponentFlow/Source/Components/List.swift index 2b8601496f..e3a29376e2 100644 --- a/submodules/ComponentFlow/Source/Components/List.swift +++ b/submodules/ComponentFlow/Source/Components/List.swift @@ -12,9 +12,9 @@ public final class List: CombinedComponent { private let items: [AnyComponentWithIdentity] private let direction: Direction private let centerAlignment: Bool - private let appear: Transition.Appear + private let appear: ComponentTransition.Appear - public init(_ items: [AnyComponentWithIdentity], direction: Direction = .vertical, centerAlignment: Bool = false, appear: Transition.Appear = .default()) { + public init(_ items: [AnyComponentWithIdentity], direction: Direction = .vertical, centerAlignment: Bool = false, appear: ComponentTransition.Appear = .default()) { self.items = items self.direction = direction self.centerAlignment = centerAlignment diff --git a/submodules/ComponentFlow/Source/Components/Rectangle.swift b/submodules/ComponentFlow/Source/Components/Rectangle.swift index 8eaf0971e4..bed1e004b9 100644 --- a/submodules/ComponentFlow/Source/Components/Rectangle.swift +++ b/submodules/ComponentFlow/Source/Components/Rectangle.swift @@ -53,7 +53,7 @@ public final class Rectangle: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { var size = availableSize if let width = self.width { size.width = min(size.width, width) diff --git a/submodules/ComponentFlow/Source/Components/RoundedRectangle.swift b/submodules/ComponentFlow/Source/Components/RoundedRectangle.swift index 275772854a..2c6777b076 100644 --- a/submodules/ComponentFlow/Source/Components/RoundedRectangle.swift +++ b/submodules/ComponentFlow/Source/Components/RoundedRectangle.swift @@ -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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/ComponentFlow/Source/Components/Text.swift b/submodules/ComponentFlow/Source/Components/Text.swift index 394d59f19c..b364de1224 100644 --- a/submodules/ComponentFlow/Source/Components/Text.swift +++ b/submodules/ComponentFlow/Source/Components/Text.swift @@ -95,7 +95,7 @@ public final class Text: Component { return View() } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize) } } diff --git a/submodules/ComponentFlow/Source/Host/ComponentHostView.swift b/submodules/ComponentFlow/Source/Host/ComponentHostView.swift index cdc4a7c3ab..ad99b99cf1 100644 --- a/submodules/ComponentFlow/Source/Host/ComponentHostView.swift +++ b/submodules/ComponentFlow/Source/Host/ComponentHostView.swift @@ -37,13 +37,13 @@ public final class ComponentHostView: UIView { fatalError("init(coder:) has not been implemented") } - public func update(transition: Transition, component: AnyComponent, @EnvironmentBuilder environment: () -> Environment, forceUpdate: Bool = false, containerSize: CGSize) -> CGSize { + public func update(transition: ComponentTransition, component: AnyComponent, @EnvironmentBuilder environment: () -> Environment, 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, maybeEnvironment: () -> Environment, updateEnvironment: Bool, forceUpdate: Bool, containerSize: CGSize) -> CGSize { + private func _update(transition: ComponentTransition, component: AnyComponent, maybeEnvironment: () -> Environment, updateEnvironment: Bool, forceUpdate: Bool, containerSize: CGSize) -> CGSize { precondition(!self.isUpdating) self.isUpdating = true @@ -150,13 +150,13 @@ public final class ComponentView { fatalError("init(coder:) has not been implemented") } - public func update(transition: Transition, component: AnyComponent, @EnvironmentBuilder environment: () -> Environment, forceUpdate: Bool = false, containerSize: CGSize) -> CGSize { + public func update(transition: ComponentTransition, component: AnyComponent, @EnvironmentBuilder environment: () -> Environment, 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) -> CGSize? { + public func updateEnvironment(transition: ComponentTransition, @EnvironmentBuilder environment: () -> Environment) -> CGSize? { guard let currentComponent = self.currentComponent, let currentContainerSize = self.currentContainerSize else { return nil } @@ -165,7 +165,7 @@ public final class ComponentView { return size } - private func _update(transition: Transition, component: AnyComponent, maybeEnvironment: () -> Environment, updateEnvironment: Bool, forceUpdate: Bool, containerSize: CGSize) -> CGSize { + private func _update(transition: ComponentTransition, component: AnyComponent, maybeEnvironment: () -> Environment, updateEnvironment: Bool, forceUpdate: Bool, containerSize: CGSize) -> CGSize { precondition(!self.isUpdating) self.isUpdating = true diff --git a/submodules/Components/ActivityIndicatorComponent/Sources/ActivityIndicatorComponent.swift b/submodules/Components/ActivityIndicatorComponent/Sources/ActivityIndicatorComponent.swift index 27311afa4a..263929fd42 100644 --- a/submodules/Components/ActivityIndicatorComponent/Sources/ActivityIndicatorComponent.swift +++ b/submodules/Components/ActivityIndicatorComponent/Sources/ActivityIndicatorComponent.swift @@ -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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/Components/AnimatedStickerComponent/Sources/AnimatedStickerComponent.swift b/submodules/Components/AnimatedStickerComponent/Sources/AnimatedStickerComponent.swift index ef150762f1..84dd63706c 100644 --- a/submodules/Components/AnimatedStickerComponent/Sources/AnimatedStickerComponent.swift +++ b/submodules/Components/AnimatedStickerComponent/Sources/AnimatedStickerComponent.swift @@ -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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/Components/BalancedTextComponent/Sources/BalancedTextComponent.swift b/submodules/Components/BalancedTextComponent/Sources/BalancedTextComponent.swift index 14802b61aa..0d7dd99769 100644 --- a/submodules/Components/BalancedTextComponent/Sources/BalancedTextComponent.swift +++ b/submodules/Components/BalancedTextComponent/Sources/BalancedTextComponent.swift @@ -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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/Components/BlurredBackgroundComponent/Sources/BlurredBackgroundComponent.swift b/submodules/Components/BlurredBackgroundComponent/Sources/BlurredBackgroundComponent.swift index 2b7d46cd69..8849f4785f 100644 --- a/submodules/Components/BlurredBackgroundComponent/Sources/BlurredBackgroundComponent.swift +++ b/submodules/Components/BlurredBackgroundComponent/Sources/BlurredBackgroundComponent.swift @@ -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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/Components/BundleIconComponent/Sources/BundleIconComponent.swift b/submodules/Components/BundleIconComponent/Sources/BundleIconComponent.swift index e055375462..d6165246af 100644 --- a/submodules/Components/BundleIconComponent/Sources/BundleIconComponent.swift +++ b/submodules/Components/BundleIconComponent/Sources/BundleIconComponent.swift @@ -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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/Components/ComponentDisplayAdapters/Sources/ComponentDisplayAdapters.swift b/submodules/Components/ComponentDisplayAdapters/Sources/ComponentDisplayAdapters.swift index 33adade5ab..942f79628f 100644 --- a/submodules/Components/ComponentDisplayAdapters/Sources/ComponentDisplayAdapters.swift +++ b/submodules/Components/ComponentDisplayAdapters/Sources/ComponentDisplayAdapters.swift @@ -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))) } } diff --git a/submodules/Components/Forms/CreditCardInputComponent/Sources/CreditCardInputComponent.swift b/submodules/Components/Forms/CreditCardInputComponent/Sources/CreditCardInputComponent.swift index cc36130746..22a3613d8b 100644 --- a/submodules/Components/Forms/CreditCardInputComponent/Sources/CreditCardInputComponent.swift +++ b/submodules/Components/Forms/CreditCardInputComponent/Sources/CreditCardInputComponent.swift @@ -133,7 +133,7 @@ public final class CreditCardInputComponent: Component { } } - func update(component: CreditCardInputComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: CreditCardInputComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/Components/Forms/PrefixSectionGroupComponent/Sources/PrefixSectionGroupComponent.swift b/submodules/Components/Forms/PrefixSectionGroupComponent/Sources/PrefixSectionGroupComponent.swift index f0c86926b1..b4e355a19e 100644 --- a/submodules/Components/Forms/PrefixSectionGroupComponent/Sources/PrefixSectionGroupComponent.swift +++ b/submodules/Components/Forms/PrefixSectionGroupComponent/Sources/PrefixSectionGroupComponent.swift @@ -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, transition: Transition) -> CGSize { + func update(component: PrefixSectionGroupComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/Components/Forms/TextInputComponent/Sources/TextInputComponent.swift b/submodules/Components/Forms/TextInputComponent/Sources/TextInputComponent.swift index b1d14eacf4..1e4f6adfbd 100644 --- a/submodules/Components/Forms/TextInputComponent/Sources/TextInputComponent.swift +++ b/submodules/Components/Forms/TextInputComponent/Sources/TextInputComponent.swift @@ -58,7 +58,7 @@ public final class TextInputComponent: Component { self.component?.updated(self.text ?? "") } - func update(component: TextInputComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: TextInputComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/Components/LottieAnimationComponent/Sources/LottieAnimationComponent.swift b/submodules/Components/LottieAnimationComponent/Sources/LottieAnimationComponent.swift index 03743f5b6b..b13b4e4e92 100644 --- a/submodules/Components/LottieAnimationComponent/Sources/LottieAnimationComponent.swift +++ b/submodules/Components/LottieAnimationComponent/Sources/LottieAnimationComponent.swift @@ -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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/Components/MultilineTextComponent/Sources/MultilineTextComponent.swift b/submodules/Components/MultilineTextComponent/Sources/MultilineTextComponent.swift index c6d8bd169b..4a1f588656 100644 --- a/submodules/Components/MultilineTextComponent/Sources/MultilineTextComponent.swift +++ b/submodules/Components/MultilineTextComponent/Sources/MultilineTextComponent.swift @@ -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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/Components/MultilineTextWithEntitiesComponent/Sources/MultilineTextWithEntitiesComponent.swift b/submodules/Components/MultilineTextWithEntitiesComponent/Sources/MultilineTextWithEntitiesComponent.swift index 082666d28c..a0f9198def 100644 --- a/submodules/Components/MultilineTextWithEntitiesComponent/Sources/MultilineTextWithEntitiesComponent.swift +++ b/submodules/Components/MultilineTextWithEntitiesComponent/Sources/MultilineTextWithEntitiesComponent.swift @@ -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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/Components/PagerComponent/Sources/PagerComponent.swift b/submodules/Components/PagerComponent/Sources/PagerComponent.swift index 7eb6f184d3..de0f925063 100644 --- a/submodules/Components/PagerComponent/Sources/PagerComponent.swift +++ b/submodules/Components/PagerComponent/Sources/PagerComponent.swift @@ -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: Equatabl public let contentAccessoryRightButtons: [AnyComponentWithIdentity] 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: Equatabl contentAccessoryRightButtons: [AnyComponentWithIdentity], 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>? 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>?, 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? - private let topPanelVisibilityFractionUpdated = ActionSlot<(CGFloat, Transition)>() + private let topPanelVisibilityFractionUpdated = ActionSlot<(CGFloat, ComponentTransition)>() private var topPanelView: ComponentHostView>? - private let bottomPanelVisibilityFractionUpdated = ActionSlot<(CGFloat, Transition)>() + private let bottomPanelVisibilityFractionUpdated = ActionSlot<(CGFloat, ComponentTransition)>() private var bottomPanelView: ComponentHostView>? private var topPanelHeight: CGFloat? @@ -440,9 +440,9 @@ public final class PagerComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: PagerComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/Components/ProgressIndicatorComponent/Sources/ProgressIndicatorComponent.swift b/submodules/Components/ProgressIndicatorComponent/Sources/ProgressIndicatorComponent.swift index e16c981130..fe9bea837c 100644 --- a/submodules/Components/ProgressIndicatorComponent/Sources/ProgressIndicatorComponent.swift +++ b/submodules/Components/ProgressIndicatorComponent/Sources/ProgressIndicatorComponent.swift @@ -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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/Components/SheetComponent/Sources/SheetComponent.swift b/submodules/Components/SheetComponent/Sources/SheetComponent.swift index 83030931d6..3912465594 100644 --- a/submodules/Components/SheetComponent/Sources/SheetComponent.swift +++ b/submodules/Components/SheetComponent/Sources/SheetComponent.swift @@ -302,7 +302,7 @@ public final class SheetComponent: Component { private var currentHasInputHeight = false private var currentAvailableSize: CGSize? - func update(component: SheetComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: SheetComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/Components/SolidRoundedButtonComponent/Sources/SolidRoundedButtonComponent.swift b/submodules/Components/SolidRoundedButtonComponent/Sources/SolidRoundedButtonComponent.swift index 9bfdef86f6..aa65028e56 100644 --- a/submodules/Components/SolidRoundedButtonComponent/Sources/SolidRoundedButtonComponent.swift +++ b/submodules/Components/SolidRoundedButtonComponent/Sources/SolidRoundedButtonComponent.swift @@ -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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/Components/UndoPanelComponent/Sources/UndoPanelComponent.swift b/submodules/Components/UndoPanelComponent/Sources/UndoPanelComponent.swift index e662d0f3c5..7a2b5beab2 100644 --- a/submodules/Components/UndoPanelComponent/Sources/UndoPanelComponent.swift +++ b/submodules/Components/UndoPanelComponent/Sources/UndoPanelComponent.swift @@ -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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/Components/UndoPanelComponent/Sources/UndoPanelContainerComponent.swift b/submodules/Components/UndoPanelComponent/Sources/UndoPanelContainerComponent.swift index ec7eb73d5c..d14fe8ffdc 100644 --- a/submodules/Components/UndoPanelComponent/Sources/UndoPanelContainerComponent.swift +++ b/submodules/Components/UndoPanelComponent/Sources/UndoPanelContainerComponent.swift @@ -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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, transition: transition) } } diff --git a/submodules/Components/ViewControllerComponent/Sources/ViewControllerComponent.swift b/submodules/Components/ViewControllerComponent/Sources/ViewControllerComponent.swift index d86b99280a..cc205210cc 100644 --- a/submodules/Components/ViewControllerComponent/Sources/ViewControllerComponent.swift +++ b/submodules/Components/ViewControllerComponent/Sources/ViewControllerComponent.swift @@ -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, transition: Transition) { + func updateComponent(component: AnyComponent, 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, transition: Transition) { + public func updateComponent(component: AnyComponent, transition: ComponentTransition) { self.node.updateComponent(component: component, transition: transition) } } diff --git a/submodules/ComposePollUI/Sources/ComposePollScreen.swift b/submodules/ComposePollUI/Sources/ComposePollScreen.swift index f8366a68d0..526009e4c6 100644 --- a/submodules/ComposePollUI/Sources/ComposePollScreen.swift +++ b/submodules/ComposePollUI/Sources/ComposePollScreen.swift @@ -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, transition: Transition) -> CGSize { + func update(component: ComposePollScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/ComposePollUI/Sources/ListComposePollOptionComponent.swift b/submodules/ComposePollUI/Sources/ListComposePollOptionComponent.swift index 42998dbb3a..4aba30339b 100644 --- a/submodules/ComposePollUI/Sources/ListComposePollOptionComponent.swift +++ b/submodules/ComposePollUI/Sources/ListComposePollOptionComponent.swift @@ -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, transition: Transition) -> CGSize { + func update(component: ListComposePollOptionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/ContactListUI/Sources/ContactsControllerNode.swift b/submodules/ContactListUI/Sources/ContactsControllerNode.swift index a56ad6c048..96ad694372 100644 --- a/submodules/ContactListUI/Sources/ContactsControllerNode.swift +++ b/submodules/ContactListUI/Sources/ContactsControllerNode.swift @@ -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)) } } diff --git a/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift b/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift index 4fb300ce21..663fca5d61 100644 --- a/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift +++ b/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift @@ -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 { diff --git a/submodules/ContextUI/Sources/ContextSourceContainer.swift b/submodules/ContextUI/Sources/ContextSourceContainer.swift index 9c41f964a2..ee940e2e49 100644 --- a/submodules/ContextUI/Sources/ContextSourceContainer.swift +++ b/submodules/ContextUI/Sources/ContextSourceContainer.swift @@ -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( diff --git a/submodules/Display/Source/ContainedViewLayoutTransition.swift b/submodules/Display/Source/ContainedViewLayoutTransition.swift index e19e7f694a..5e0f529ccc 100644 --- a/submodules/Display/Source/ContainedViewLayoutTransition.swift +++ b/submodules/Display/Source/ContainedViewLayoutTransition.swift @@ -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(layer: CALayer, path: String, fromValue: T, toValue: T, completion: ((Bool) -> Void)?) where T: AnyValueProviding { + init(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 diff --git a/submodules/Display/Source/KeyShortcut.swift b/submodules/Display/Source/KeyShortcut.swift index a0883b547c..8997ee43b1 100644 --- a/submodules/Display/Source/KeyShortcut.swift +++ b/submodules/Display/Source/KeyShortcut.swift @@ -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) diff --git a/submodules/DrawingUI/Sources/ColorPickerScreen.swift b/submodules/DrawingUI/Sources/ColorPickerScreen.swift index 6b79a8f536..d7eb09b353 100644 --- a/submodules/DrawingUI/Sources/ColorPickerScreen.swift +++ b/submodules/DrawingUI/Sources/ColorPickerScreen.swift @@ -306,7 +306,7 @@ private class ColorSliderComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + func update(component: ColorSwatchComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/DrawingUI/Sources/DrawingEntitiesView.swift b/submodules/DrawingUI/Sources/DrawingEntitiesView.swift index 575a953841..908fc04883 100644 --- a/submodules/DrawingUI/Sources/DrawingEntitiesView.swift +++ b/submodules/DrawingUI/Sources/DrawingEntitiesView.swift @@ -824,7 +824,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 = [ @@ -921,7 +921,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 } @@ -1189,7 +1189,7 @@ private final class EntityBinComponent: Component { } private var wasOpened = false - func update(component: EntityBinComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EntityBinComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -1234,7 +1234,7 @@ private final class EntityBinComponent: Component { return View() } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/DrawingUI/Sources/DrawingReactionView.swift b/submodules/DrawingUI/Sources/DrawingReactionView.swift index 959c3525c7..34148e1fb8 100644 --- a/submodules/DrawingUI/Sources/DrawingReactionView.swift +++ b/submodules/DrawingUI/Sources/DrawingReactionView.swift @@ -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, diff --git a/submodules/DrawingUI/Sources/DrawingScreen.swift b/submodules/DrawingUI/Sources/DrawingScreen.swift index 43431fefcd..996d598852 100644 --- a/submodules/DrawingUI/Sources/DrawingScreen.swift +++ b/submodules/DrawingUI/Sources/DrawingScreen.swift @@ -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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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) { @@ -3531,7 +3531,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 { diff --git a/submodules/DrawingUI/Sources/DrawingView.swift b/submodules/DrawingUI/Sources/DrawingView.swift index aed105e3c9..e18098d9e7 100644 --- a/submodules/DrawingUI/Sources/DrawingView.swift +++ b/submodules/DrawingUI/Sources/DrawingView.swift @@ -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) diff --git a/submodules/DrawingUI/Sources/ModeAndSizeComponent.swift b/submodules/DrawingUI/Sources/ModeAndSizeComponent.swift index 15a0e4025d..a8822e5230 100644 --- a/submodules/DrawingUI/Sources/ModeAndSizeComponent.swift +++ b/submodules/DrawingUI/Sources/ModeAndSizeComponent.swift @@ -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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/DrawingUI/Sources/TextSettingsComponent.swift b/submodules/DrawingUI/Sources/TextSettingsComponent.swift index 099be3521e..801ab0a750 100644 --- a/submodules/DrawingUI/Sources/TextSettingsComponent.swift +++ b/submodules/DrawingUI/Sources/TextSettingsComponent.swift @@ -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, transition: Transition) -> CGSize { + func update(component: TextAlignmentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + func update(component: TextFontComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { view.updated = self.updated view.released = self.released return view.updateLayout(size: availableSize, component: self, transition: transition) diff --git a/submodules/DrawingUI/Sources/ToolsComponent.swift b/submodules/DrawingUI/Sources/ToolsComponent.swift index b3f88ca268..47ffcd0fe0 100644 --- a/submodules/DrawingUI/Sources/ToolsComponent.swift +++ b/submodules/DrawingUI/Sources/ToolsComponent.swift @@ -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, transition: Transition) -> CGSize { + func update(component: ToolsComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/GraphCore/Sources/Charts/Controllers/BaseChartController.swift b/submodules/GraphCore/Sources/Charts/Controllers/BaseChartController.swift index f24cbb0325..8ecceb12ed 100644 --- a/submodules/GraphCore/Sources/Charts/Controllers/BaseChartController.swift +++ b/submodules/GraphCore/Sources/Charts/Controllers/BaseChartController.swift @@ -72,6 +72,18 @@ enum BaseConstants { return numberFormatter }() + static let starNumberFormatter: NumberFormatter = { + let numberFormatter = NumberFormatter() + numberFormatter.allowsFloats = true + numberFormatter.numberStyle = .decimal + numberFormatter.usesGroupingSeparator = true + numberFormatter.groupingSeparator = " " + numberFormatter.minimumIntegerDigits = 1 + numberFormatter.minimumFractionDigits = 0 + numberFormatter.maximumFractionDigits = 2 + return numberFormatter + }() + static let detailsNumberFormatter: NumberFormatter = { let detailsNumberFormatter = NumberFormatter() detailsNumberFormatter.allowsFloats = false diff --git a/submodules/GraphCore/Sources/Charts/Controllers/Lines/GeneralLinesChartController.swift b/submodules/GraphCore/Sources/Charts/Controllers/Lines/GeneralLinesChartController.swift index 8676271315..4da43fc1a0 100644 --- a/submodules/GraphCore/Sources/Charts/Controllers/Lines/GeneralLinesChartController.swift +++ b/submodules/GraphCore/Sources/Charts/Controllers/Lines/GeneralLinesChartController.swift @@ -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 diff --git a/submodules/GraphCore/Sources/Charts/Controllers/Stacked Bars/BarsComponentController.swift b/submodules/GraphCore/Sources/Charts/Controllers/Stacked Bars/BarsComponentController.swift index 227bb0d9d9..cf9bd1260a 100644 --- a/submodules/GraphCore/Sources/Charts/Controllers/Stacked Bars/BarsComponentController.swift +++ b/submodules/GraphCore/Sources/Charts/Controllers/Stacked Bars/BarsComponentController.swift @@ -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 diff --git a/submodules/GraphCore/Sources/Charts/Controllers/Stacked Bars/StackedBarsChartController.swift b/submodules/GraphCore/Sources/Charts/Controllers/Stacked Bars/StackedBarsChartController.swift index 0ac4feb20d..613e946a42 100644 --- a/submodules/GraphCore/Sources/Charts/Controllers/Stacked Bars/StackedBarsChartController.swift +++ b/submodules/GraphCore/Sources/Charts/Controllers/Stacked Bars/StackedBarsChartController.swift @@ -13,7 +13,23 @@ import Cocoa import UIKit #endif +public enum GraphCurrency : String { + case xtr = "XTR" + case ton = "TON" + + var formatter: NumberFormatter { + switch self { + case .xtr: + return BaseConstants.starNumberFormatter + case .ton: + return BaseConstants.tonNumberFormatter + } + } +} + public class StackedBarsChartController: BaseChartController { + + let barsController: BarsComponentController let zoomedBarsController: BarsComponentController @@ -23,12 +39,12 @@ public class StackedBarsChartController: BaseChartController { } } - public init(chartsCollection: ChartsCollection, isCrypto: Bool = false, rate: Double = 1.0) { + public init(chartsCollection: ChartsCollection, currency: GraphCurrency? = nil, drawCurrency:((CGContext, UIColor, CGPoint)->Void)? = nil, rate: Double = 1.0) { let horizontalScalesRenderer = HorizontalScalesRenderer() let verticalScalesRenderer = VerticalScalesRenderer() var secondaryScalesRenderer: VerticalScalesRenderer? - if isCrypto { - verticalScalesRenderer.isCrypto = true + if let _ = currency { + verticalScalesRenderer.drawCurrency = drawCurrency secondaryScalesRenderer = VerticalScalesRenderer() secondaryScalesRenderer?.isRightAligned = true } @@ -38,10 +54,10 @@ public class StackedBarsChartController: BaseChartController { verticalScalesRenderer: verticalScalesRenderer, secondaryScalesRenderer: secondaryScalesRenderer, previewBarsChartRenderer: BarChartRenderer()) - if isCrypto { + if let currency { barsController.conversionRate = rate - barsController.verticalLimitsNumberFormatter = BaseConstants.tonNumberFormatter - barsController.detailsNumberFormatter = BaseConstants.tonNumberFormatter + barsController.verticalLimitsNumberFormatter = currency.formatter + barsController.detailsNumberFormatter = currency.formatter } zoomedBarsController = BarsComponentController(isZoomed: true, mainBarsRenderer: BarChartRenderer(), diff --git a/submodules/GraphCore/Sources/Charts/Renderes/VerticalScalesRenderer.swift b/submodules/GraphCore/Sources/Charts/Renderes/VerticalScalesRenderer.swift index 2245bd62b3..fa11122d14 100644 --- a/submodules/GraphCore/Sources/Charts/Renderes/VerticalScalesRenderer.swift +++ b/submodules/GraphCore/Sources/Charts/Renderes/VerticalScalesRenderer.swift @@ -9,7 +9,7 @@ import Foundation #if os(macOS) import Cocoa -typealias UIColor = NSColor +public typealias UIColor = NSColor #else import UIKit #endif @@ -26,7 +26,7 @@ class VerticalScalesRenderer: BaseChartRenderer { var axisXWidth: CGFloat = GView.oneDevicePixel var isRightAligned: Bool = false - var isCrypto: Bool = false + var drawCurrency:((CGContext, UIColor, CGPoint)->Void)? var horizontalLinesColor: GColor = .black { didSet { @@ -122,45 +122,6 @@ class VerticalScalesRenderer: BaseChartRenderer { context.strokeLineSegments(between: lineSegments) } - func drawTonSymbol(context: CGContext, color: UIColor, at point: CGPoint) { - let width: CGFloat = 8.0 - let height: CGFloat = 7.5 - let cornerRadius: CGFloat = 0.5 - - let topPoint = CGPoint(x: point.x + width / 2, y: point.y) - let bottomPoint = CGPoint(x: point.x + width / 2, y: point.y + height) - let leftTopPoint = CGPoint(x: point.x, y: point.y) - let rightTopPoint = CGPoint(x: point.x + width, y: point.y) - - context.saveGState() - - context.beginPath() - context.move(to: CGPoint(x: leftTopPoint.x + cornerRadius, y: leftTopPoint.y)) - - context.addArc(tangent1End: leftTopPoint, tangent2End: bottomPoint, radius: cornerRadius) - context.addLine(to: CGPoint(x: bottomPoint.x, y: bottomPoint.y - cornerRadius + GView.oneDevicePixel)) - - context.move(to: CGPoint(x: rightTopPoint.x - cornerRadius, y: rightTopPoint.y)) - context.addArc(tangent1End: rightTopPoint, tangent2End: bottomPoint, radius: cornerRadius) - context.addLine(to: CGPoint(x: bottomPoint.x, y: bottomPoint.y - cornerRadius + GView.oneDevicePixel)) - - context.move(to: CGPoint(x: leftTopPoint.x + cornerRadius, y: leftTopPoint.y)) - context.addLine(to: CGPoint(x: rightTopPoint.x - cornerRadius, y: rightTopPoint.y)) - - context.move(to: topPoint) - context.addLine(to: CGPoint(x: bottomPoint.x, y: bottomPoint.y - 1.0)) - - context.setLineWidth(1.0) - context.setLineCap(.round) - context.setFillColor(UIColor.clear.cgColor) - context.setStrokeColor(color.withAlphaComponent(1.0).cgColor) - - context.setAlpha(color.alphaValue) - context.strokePath() - - context.restoreGState() - } - func drawVerticalLabels(_ labels: [LinesChartLabel], attributes: [NSAttributedString.Key: Any]) { if isRightAligned { for label in labels { @@ -176,9 +137,9 @@ class VerticalScalesRenderer: BaseChartRenderer { let textNode = LabelNode.layoutText(attributedString, bounds.size) var xOffset = 0.0 - if self.isCrypto { + if let drawCurrency { xOffset += 11.0 - drawTonSymbol(context: context, color: attributes[.foregroundColor] as? UIColor ?? .black, at: CGPoint(x: chartFrame.minX, y: y + 4.0)) + drawCurrency(context, attributes[.foregroundColor] as? UIColor ?? .black, CGPoint(x: chartFrame.minX, y: y + 4.0)) } textNode.1.draw(CGRect(origin: CGPoint(x: chartFrame.minX + xOffset, y: y), size: textNode.0.size), in: context, backingScaleFactor: deviceScale) diff --git a/submodules/GraphCore/Sources/Helpers/ScalesNumberFormatter.swift b/submodules/GraphCore/Sources/Helpers/ScalesNumberFormatter.swift index fa25137fd7..19f18334aa 100644 --- a/submodules/GraphCore/Sources/Helpers/ScalesNumberFormatter.swift +++ b/submodules/GraphCore/Sources/Helpers/ScalesNumberFormatter.swift @@ -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 ?? "." @@ -60,3 +60,5 @@ class TonNumberFormatter: NumberFormatter { return balanceText } } + + diff --git a/submodules/GraphCore/Sources/Helpers/UIColor+Utils.swift b/submodules/GraphCore/Sources/Helpers/UIColor+Utils.swift index fde53f46be..a25a87b2c8 100644 --- a/submodules/GraphCore/Sources/Helpers/UIColor+Utils.swift +++ b/submodules/GraphCore/Sources/Helpers/UIColor+Utils.swift @@ -21,7 +21,7 @@ func makeCIColor(color: GColor) -> CIColor { #endif } -extension GColor { +public extension GColor { var redValue: CGFloat{ return makeCIColor(color: self).red } var greenValue: CGFloat{ return makeCIColor(color: self).green } var blueValue: CGFloat{ return makeCIColor(color: self).blue } diff --git a/submodules/GraphCore/Sources/Helpers/UIView+Extensions.swift b/submodules/GraphCore/Sources/Helpers/UIView+Extensions.swift index ef76b00fcb..ccc57a1258 100644 --- a/submodules/GraphCore/Sources/Helpers/UIView+Extensions.swift +++ b/submodules/GraphCore/Sources/Helpers/UIView+Extensions.swift @@ -20,6 +20,6 @@ public typealias GView = UIView #endif -extension GView { +public extension GView { static let oneDevicePixel: CGFloat = (1.0 / max(2, min(1, deviceScale))) } diff --git a/submodules/GraphUI/Sources/ChartNode.swift b/submodules/GraphUI/Sources/ChartNode.swift index ae351ac01a..c8fec06e72 100644 --- a/submodules/GraphUI/Sources/ChartNode.swift +++ b/submodules/GraphUI/Sources/ChartNode.swift @@ -87,7 +87,7 @@ public func createChartController(_ data: String, type: ChartType, rate: Double controller = StackedBarsChartController(chartsCollection: collection) controller.isZoomable = false case .currency: - controller = StackedBarsChartController(chartsCollection: collection, isCrypto: true, rate: rate) + controller = StackedBarsChartController(chartsCollection: collection, currency: .ton, rate: rate) controller.isZoomable = false case .step: controller = StepBarsChartController(chartsCollection: collection) diff --git a/submodules/GraphUI/Sources/ChartVisibilityView.swift b/submodules/GraphUI/Sources/ChartVisibilityView.swift index fc110df0fa..30927d7803 100644 --- a/submodules/GraphUI/Sources/ChartVisibilityView.swift +++ b/submodules/GraphUI/Sources/ChartVisibilityView.swift @@ -94,7 +94,7 @@ class ChartVisibilityView: UIView { } } - private (set) var selectedItems: [Bool] = [] + private(set) var selectedItems: [Bool] = [] var isExpanded: Bool = true { didSet { invalidateIntrinsicContentSize() diff --git a/submodules/HashtagSearchUI/Sources/HashtagSearchControllerNode.swift b/submodules/HashtagSearchUI/Sources/HashtagSearchControllerNode.swift index 54f77a019c..2970d7386b 100644 --- a/submodules/HashtagSearchUI/Sources/HashtagSearchControllerNode.swift +++ b/submodules/HashtagSearchUI/Sources/HashtagSearchControllerNode.swift @@ -457,7 +457,7 @@ final class HashtagSearchControllerNode: ASDisplayNode, ASGestureRecognizerDeleg var topInset: CGFloat = insets.top - 89.0 if let state = self.globalStorySearchState { let componentView: ComponentView - var panelTransition = Transition(transition) + var panelTransition = ComponentTransition(transition) if let current = self.globalStorySearchComponentView { componentView = current } else { diff --git a/submodules/HashtagSearchUI/Sources/HashtagSearchNavigationContentNode.swift b/submodules/HashtagSearchUI/Sources/HashtagSearchNavigationContentNode.swift index 2bbfab6224..33eb723ab7 100644 --- a/submodules/HashtagSearchUI/Sources/HashtagSearchNavigationContentNode.swift +++ b/submodules/HashtagSearchUI/Sources/HashtagSearchNavigationContentNode.swift @@ -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, diff --git a/submodules/InstantPageUI/Sources/InstantPageDetailsNode.swift b/submodules/InstantPageUI/Sources/InstantPageDetailsNode.swift index ccb2c59081..38fff01023 100644 --- a/submodules/InstantPageUI/Sources/InstantPageDetailsNode.swift +++ b/submodules/InstantPageUI/Sources/InstantPageDetailsNode.swift @@ -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? diff --git a/submodules/ItemListUI/Sources/ItemListControllerSegmentedTitleView.swift b/submodules/ItemListUI/Sources/ItemListControllerSegmentedTitleView.swift index 4af1edb6f2..a74a317d8e 100644 --- a/submodules/ItemListUI/Sources/ItemListControllerSegmentedTitleView.swift +++ b/submodules/ItemListUI/Sources/ItemListControllerSegmentedTitleView.swift @@ -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 } diff --git a/submodules/ItemListUI/Sources/ItemListControllerTabsContentNode.swift b/submodules/ItemListUI/Sources/ItemListControllerTabsContentNode.swift index e409a0e4d4..c629bd0b4e 100644 --- a/submodules/ItemListUI/Sources/ItemListControllerTabsContentNode.swift +++ b/submodules/ItemListUI/Sources/ItemListControllerTabsContentNode.swift @@ -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, diff --git a/submodules/JoinLinkPreviewUI/Sources/JoinLinkPreviewPeerContentNode.swift b/submodules/JoinLinkPreviewUI/Sources/JoinLinkPreviewPeerContentNode.swift index 756cd33f56..60b8ea8e4c 100644 --- a/submodules/JoinLinkPreviewUI/Sources/JoinLinkPreviewPeerContentNode.swift +++ b/submodules/JoinLinkPreviewUI/Sources/JoinLinkPreviewPeerContentNode.swift @@ -297,7 +297,7 @@ final class JoinLinkPreviewPeerContentNode: ASDisplayNode, ShareContentContainer let animationRenderer = self.context.animationRenderer let avatarIcon: ComponentView - var avatarIconTransition = Transition(transition) + var avatarIconTransition = ComponentTransition(transition) if let current = self.avatarIcon { avatarIcon = current } else { diff --git a/submodules/LegacyMediaPickerUI/Sources/LegacyPaintStickersContext.swift b/submodules/LegacyMediaPickerUI/Sources/LegacyPaintStickersContext.swift index 6cabd1f33b..e66f0238e5 100644 --- a/submodules/LegacyMediaPickerUI/Sources/LegacyPaintStickersContext.swift +++ b/submodules/LegacyMediaPickerUI/Sources/LegacyPaintStickersContext.swift @@ -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 diff --git a/submodules/ListMessageItem/Sources/ListMessageFileItemNode.swift b/submodules/ListMessageItem/Sources/ListMessageFileItemNode.swift index 279b22527e..f226d6ac75 100644 --- a/submodules/ListMessageItem/Sources/ListMessageFileItemNode.swift +++ b/submodules/ListMessageItem/Sources/ListMessageFileItemNode.swift @@ -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? diff --git a/submodules/LocationUI/Sources/LocationMapNode.swift b/submodules/LocationUI/Sources/LocationMapNode.swift index 1f9601b028..e2aa9886b9 100644 --- a/submodules/LocationUI/Sources/LocationMapNode.swift +++ b/submodules/LocationUI/Sources/LocationMapNode.swift @@ -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 diff --git a/submodules/LocationUI/Sources/LocationPickerControllerNode.swift b/submodules/LocationUI/Sources/LocationPickerControllerNode.swift index 6a676d2e0a..3cd747948b 100644 --- a/submodules/LocationUI/Sources/LocationPickerControllerNode.swift +++ b/submodules/LocationUI/Sources/LocationPickerControllerNode.swift @@ -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: diff --git a/submodules/LocationUI/Sources/LocationUtils.swift b/submodules/LocationUI/Sources/LocationUtils.swift index d9403a30d5..df5d59f89d 100644 --- a/submodules/LocationUI/Sources/LocationUtils.swift +++ b/submodules/LocationUI/Sources/LocationUtils.swift @@ -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 { diff --git a/submodules/LocationUI/Sources/LocationViewControllerNode.swift b/submodules/LocationUI/Sources/LocationViewControllerNode.swift index fb26971572..b7c93634a2 100644 --- a/submodules/LocationUI/Sources/LocationViewControllerNode.swift +++ b/submodules/LocationUI/Sources/LocationViewControllerNode.swift @@ -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) } diff --git a/submodules/LottieCpp/lottiecpp b/submodules/LottieCpp/lottiecpp index d32a4afe5e..2b10b84f62 160000 --- a/submodules/LottieCpp/lottiecpp +++ b/submodules/LottieCpp/lottiecpp @@ -1 +1 @@ -Subproject commit d32a4afe5e196ab22a9e11b9b0318091f10e2707 +Subproject commit 2b10b84f626c66288366f0ad2d6af2a396ec454e diff --git a/submodules/MediaPickerUI/Sources/MediaPickerSelectedListNode.swift b/submodules/MediaPickerUI/Sources/MediaPickerSelectedListNode.swift index ae408cd4ed..67a90fdbb2 100644 --- a/submodules/MediaPickerUI/Sources/MediaPickerSelectedListNode.swift +++ b/submodules/MediaPickerUI/Sources/MediaPickerSelectedListNode.swift @@ -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 diff --git a/submodules/PaymentMethodUI/Sources/PaymentCardEntryScreen.swift b/submodules/PaymentMethodUI/Sources/PaymentCardEntryScreen.swift index 79f2aa5dd8..01f2c45453 100644 --- a/submodules/PaymentMethodUI/Sources/PaymentCardEntryScreen.swift +++ b/submodules/PaymentMethodUI/Sources/PaymentCardEntryScreen.swift @@ -73,7 +73,7 @@ public final class ScrollComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: ScrollComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ScrollComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let contentSize = self.contentView.update( transition: transition, component: component.content, @@ -96,7 +96,7 @@ public final class ScrollComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift b/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift index e2fd087322..3a5f259483 100644 --- a/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift +++ b/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift @@ -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 if let current = self.expandedStorySetIndicator { expandedStorySetIndicator = current diff --git a/submodules/PremiumUI/Sources/AppIconsDemoComponent.swift b/submodules/PremiumUI/Sources/AppIconsDemoComponent.swift index 7c0fb63798..ba86b82245 100644 --- a/submodules/PremiumUI/Sources/AppIconsDemoComponent.swift +++ b/submodules/PremiumUI/Sources/AppIconsDemoComponent.swift @@ -55,7 +55,7 @@ final class AppIconsDemoComponent: Component { fatalError("init(coder:) has not been implemented") } - public func update(component: AppIconsDemoComponent, availableSize: CGSize, environment: Environment, transition: Transition) -> CGSize { + public func update(component: AppIconsDemoComponent, availableSize: CGSize, environment: Environment, 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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, environment: environment, transition: transition) } } diff --git a/submodules/PremiumUI/Sources/BadgeLabelView.swift b/submodules/PremiumUI/Sources/BadgeLabelView.swift index 3d7be34fdb..6e24d18396 100644 --- a/submodules/PremiumUI/Sources/BadgeLabelView.swift +++ b/submodules/PremiumUI/Sources/BadgeLabelView.swift @@ -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 diff --git a/submodules/PremiumUI/Sources/BoostHeaderBackgroundComponent.swift b/submodules/PremiumUI/Sources/BoostHeaderBackgroundComponent.swift index 566228e5e4..82ebab8dcc 100644 --- a/submodules/PremiumUI/Sources/BoostHeaderBackgroundComponent.swift +++ b/submodules/PremiumUI/Sources/BoostHeaderBackgroundComponent.swift @@ -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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/PremiumUI/Sources/BusinessPageComponent.swift b/submodules/PremiumUI/Sources/BusinessPageComponent.swift index fba7895323..c89b4a0a08 100644 --- a/submodules/PremiumUI/Sources/BusinessPageComponent.swift +++ b/submodules/PremiumUI/Sources/BusinessPageComponent.swift @@ -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, transition: Transition) -> CGSize { + func update(component: HeaderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/PremiumUI/Sources/CreateGiveawayFooterItem.swift b/submodules/PremiumUI/Sources/CreateGiveawayFooterItem.swift index 291d4d357d..066dfb3536 100644 --- a/submodules/PremiumUI/Sources/CreateGiveawayFooterItem.swift +++ b/submodules/PremiumUI/Sources/CreateGiveawayFooterItem.swift @@ -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 } diff --git a/submodules/PremiumUI/Sources/EmojiHeaderComponent.swift b/submodules/PremiumUI/Sources/EmojiHeaderComponent.swift index 765be52fb3..80b3dbd10f 100644 --- a/submodules/PremiumUI/Sources/EmojiHeaderComponent.swift +++ b/submodules/PremiumUI/Sources/EmojiHeaderComponent.swift @@ -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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/PremiumUI/Sources/PageIndicatorComponent.swift b/submodules/PremiumUI/Sources/PageIndicatorComponent.swift index 1e5497a529..34ea6a940b 100644 --- a/submodules/PremiumUI/Sources/PageIndicatorComponent.swift +++ b/submodules/PremiumUI/Sources/PageIndicatorComponent.swift @@ -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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/PremiumUI/Sources/PhoneDemoComponent.swift b/submodules/PremiumUI/Sources/PhoneDemoComponent.swift index d65a427ff3..34b2ff7a8e 100644 --- a/submodules/PremiumUI/Sources/PhoneDemoComponent.swift +++ b/submodules/PremiumUI/Sources/PhoneDemoComponent.swift @@ -475,7 +475,7 @@ final class PhoneDemoComponent: Component { self.playbackStatusDisposable?.dispose() } - public func update(component: PhoneDemoComponent, availableSize: CGSize, environment: Environment, transition: Transition) -> CGSize { + public func update(component: PhoneDemoComponent, availableSize: CGSize, environment: Environment, 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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, environment: environment, transition: transition) } } diff --git a/submodules/PremiumUI/Sources/PremiumBoostLevelsScreen.swift b/submodules/PremiumUI/Sources/PremiumBoostLevelsScreen.swift index f41ee7c974..b1a7eb0963 100644 --- a/submodules/PremiumUI/Sources/PremiumBoostLevelsScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumBoostLevelsScreen.swift @@ -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, transition: Transition) -> CGSize { + func update(component: FooterComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/PremiumUI/Sources/PremiumCoinComponent.swift b/submodules/PremiumUI/Sources/PremiumCoinComponent.swift index 84a156e022..4d8c4e0bb3 100644 --- a/submodules/PremiumUI/Sources/PremiumCoinComponent.swift +++ b/submodules/PremiumUI/Sources/PremiumCoinComponent.swift @@ -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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/PremiumUI/Sources/PremiumDemoScreen.swift b/submodules/PremiumUI/Sources/PremiumDemoScreen.swift index 91671972a0..0618416cfd 100644 --- a/submodules/PremiumUI/Sources/PremiumDemoScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumDemoScreen.swift @@ -69,7 +69,7 @@ public final class PremiumGradientBackgroundComponent: Component { } - func update(component: PremiumGradientBackgroundComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: PremiumGradientBackgroundComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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())) } }) } diff --git a/submodules/PremiumUI/Sources/PremiumGiftCodeScreen.swift b/submodules/PremiumUI/Sources/PremiumGiftCodeScreen.swift index 8869e2d91d..33aad00749 100644 --- a/submodules/PremiumUI/Sources/PremiumGiftCodeScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumGiftCodeScreen.swift @@ -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, transition: Transition) -> CGSize { + func update(component: PeerCellComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + func update(component: DustComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, 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, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/PremiumUI/Sources/PremiumIntroScreen.swift b/submodules/PremiumUI/Sources/PremiumIntroScreen.swift index db05bcd226..1c33b2729f 100644 --- a/submodules/PremiumUI/Sources/PremiumIntroScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumIntroScreen.swift @@ -1055,7 +1055,7 @@ final class SectionGroupComponent: Component { } } - func update(component: SectionGroupComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: SectionGroupComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let sideInset: CGFloat = 16.0 self.backgroundColor = component.backgroundColor @@ -1162,7 +1162,7 @@ final class SectionGroupComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -3603,7 +3603,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 @@ -3616,7 +3616,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 @@ -3628,7 +3628,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 diff --git a/submodules/PremiumUI/Sources/PremiumLimitScreen.swift b/submodules/PremiumUI/Sources/PremiumLimitScreen.swift index 81cb2778cb..034163beb3 100644 --- a/submodules/PremiumUI/Sources/PremiumLimitScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumLimitScreen.swift @@ -307,7 +307,7 @@ public class PremiumLimitDisplayComponent: Component { } if let badgeText = component.badgeText { - let transition: Transition = .easeInOut(duration: from != nil ? 0.3 : 0.5) + let transition: ComponentTransition = .easeInOut(duration: from != nil ? 0.3 : 0.5) var frameTransition = transition if from == nil { frameTransition = frameTransition.withAnimation(.none) @@ -318,7 +318,7 @@ public class PremiumLimitDisplayComponent: Component { } var previousAvailableSize: CGSize? - func update(component: PremiumLimitDisplayComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: PremiumLimitDisplayComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { self.component = component self.inactiveBackground.backgroundColor = component.inactiveColor.cgColor self.activeBackground.backgroundColor = component.activeColors.last?.cgColor @@ -493,7 +493,7 @@ public class PremiumLimitDisplayComponent: Component { } } - var progressTransition: Transition = .immediate + var progressTransition: ComponentTransition = .immediate if !transition.animation.isImmediate { progressTransition = .easeInOut(duration: 0.5) } @@ -738,7 +738,7 @@ public class PremiumLimitDisplayComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } @@ -1427,7 +1427,7 @@ private final class LimitSheetContent: CombinedComponent { ] } - var limitTransition: Transition = .immediate + var limitTransition: ComponentTransition = .immediate if boostUpdated { limitTransition = .easeInOut(duration: 0.35) } @@ -1513,11 +1513,11 @@ private final class LimitSheetContent: CombinedComponent { context.add(textChild .position(CGPoint(x: context.availableSize.width / 2.0, y: textOffset)) - .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 @@ -1532,11 +1532,11 @@ private final class LimitSheetContent: CombinedComponent { context.add(alternateTextChild .position(CGPoint(x: context.availableSize.width / 2.0, y: textOffset)) - .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 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 completion() @@ -1938,7 +1938,7 @@ public final class BoostIconComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: BoostIconComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BoostIconComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -1986,7 +1986,7 @@ public final class BoostIconComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/PremiumUI/Sources/PremiumLimitsListScreen.swift b/submodules/PremiumUI/Sources/PremiumLimitsListScreen.swift index 3c5ae8f075..21f3233b3f 100644 --- a/submodules/PremiumUI/Sources/PremiumLimitsListScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumLimitsListScreen.swift @@ -175,7 +175,7 @@ public class PremiumLimitsListScreen: ViewController { strongSelf.isPremium = isPremium strongSelf.promoConfiguration = promoConfiguration if !stickers.isEmpty { - strongSelf.updated(transition: Transition(.immediate).withUserData(DemoAnimateInTransition())) + strongSelf.updated(transition: ComponentTransition(.immediate).withUserData(DemoAnimateInTransition())) } }) } @@ -265,7 +265,7 @@ public class PremiumLimitsListScreen: ViewController { } private var dismissOffset: CGFloat? - func containerLayoutUpdated(layout: ContainerViewLayout, transition: Transition) { + func containerLayoutUpdated(layout: ContainerViewLayout, transition: ComponentTransition) { self.currentLayout = layout self.dim.frame = CGRect(origin: CGPoint(x: 0.0, y: -layout.size.height), size: CGSize(width: layout.size.width, height: layout.size.height * 3.0)) @@ -356,7 +356,7 @@ public class PremiumLimitsListScreen: ViewController { } private var indexPosition: CGFloat? - func updated(transition: Transition) { + func updated(transition: ComponentTransition) { guard let controller = self.controller else { return } @@ -1320,11 +1320,11 @@ public class PremiumLimitsListScreen: 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) { if velocity.y > -2200.0 && velocity.y < -300.0, let listNode = listNode { @@ -1337,7 +1337,7 @@ public class PremiumLimitsListScreen: ViewController { 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 listNode = listNode { listNode.scroller.setContentOffset(CGPoint(), animated: false) @@ -1345,7 +1345,7 @@ public class PremiumLimitsListScreen: ViewController { 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 { @@ -1358,7 +1358,7 @@ public class PremiumLimitsListScreen: 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 } @@ -1383,7 +1383,7 @@ public class PremiumLimitsListScreen: ViewController { guard let layout = self.currentLayout else { return } - self.containerLayoutUpdated(layout: layout, transition: Transition(transition)) + self.containerLayoutUpdated(layout: layout, transition: ComponentTransition(transition)) } } @@ -1471,7 +1471,7 @@ public class PremiumLimitsListScreen: 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)) } } diff --git a/submodules/PremiumUI/Sources/PremiumOptionComponent.swift b/submodules/PremiumUI/Sources/PremiumOptionComponent.swift index 23ec27e787..df785dff42 100644 --- a/submodules/PremiumUI/Sources/PremiumOptionComponent.swift +++ b/submodules/PremiumUI/Sources/PremiumOptionComponent.swift @@ -322,7 +322,7 @@ private final class CheckComponent: Component { } - func update(component: CheckComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: CheckComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { self.checkLayer.setSelected(component.selected, animated: true) self.checkLayer.theme = component.theme.checkNodeTheme @@ -334,7 +334,7 @@ private final class CheckComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/PremiumUI/Sources/ReplaceBoostScreen.swift b/submodules/PremiumUI/Sources/ReplaceBoostScreen.swift index fdf4c6fb87..95cf1a7e15 100644 --- a/submodules/PremiumUI/Sources/ReplaceBoostScreen.swift +++ b/submodules/PremiumUI/Sources/ReplaceBoostScreen.swift @@ -458,7 +458,7 @@ public class ReplaceBoostScreen: ViewController { self.controller?.updateModalStyleOverlayTransitionFactor(0.0, transition: positionTransition) } - func containerLayoutUpdated(layout: ContainerViewLayout, navigationHeight: CGFloat, transition: Transition) { + func containerLayoutUpdated(layout: ContainerViewLayout, navigationHeight: CGFloat, transition: ComponentTransition) { let hadLayout = self.currentLayout != nil self.currentLayout = (layout, navigationHeight) @@ -761,11 +761,11 @@ public class ReplaceBoostScreen: 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, navigationHeight: navigationHeight, transition: Transition(transition)) + self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(transition)) } else { self.isExpanded = true - self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: Transition(.animated(duration: 0.3, curve: .easeInOut))) + self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(.animated(duration: 0.3, curve: .easeInOut))) } } else if (velocity.y < -300.0 || offset < topInset / 2.0) { if velocity.y > -2200.0 && velocity.y < -300.0, let listNode = listNode { @@ -778,7 +778,7 @@ public class ReplaceBoostScreen: ViewController { let transition = ContainedViewLayoutTransition.animated(duration: 0.45, curve: .customSpring(damping: 124.0, initialVelocity: initialVelocity)) self.isExpanded = true - self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: Transition(transition)) + self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(transition)) } else { if let listNode = listNode { listNode.scroller.setContentOffset(CGPoint(), animated: false) @@ -786,7 +786,7 @@ public class ReplaceBoostScreen: ViewController { scrollView.setContentOffset(CGPoint(x: 0.0, y: -scrollView.contentInset.top), animated: false) } - self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: Transition(.animated(duration: 0.3, curve: .easeInOut))) + self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(.animated(duration: 0.3, curve: .easeInOut))) } if !dismissing { @@ -801,7 +801,7 @@ public class ReplaceBoostScreen: ViewController { case .cancelled: self.panGestureArguments = nil - self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: Transition(.animated(duration: 0.3, curve: .easeInOut))) + self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(.animated(duration: 0.3, curve: .easeInOut))) self.updateFooterAlpha() default: @@ -818,7 +818,7 @@ public class ReplaceBoostScreen: ViewController { guard let (layout, navigationHeight) = self.currentLayout else { return } - self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: Transition(transition)) + self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(transition)) } } @@ -985,7 +985,7 @@ public class ReplaceBoostScreen: ViewController { let navigationHeight: CGFloat = 56.0 - self.node.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: Transition(transition)) + self.node.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(transition)) } } @@ -1031,7 +1031,7 @@ private final class FooterView: UIView { let panelFrame = CGRect(origin: CGPoint(x: 0.0, y: size.height - totalPanelHeight), size: CGSize(width: size.width, height: panelHeight)) - var buttonTransition: Transition = .easeInOut(duration: 0.2) + var buttonTransition: ComponentTransition = .easeInOut(duration: 0.2) if !hadLayout { buttonTransition = .immediate } @@ -1091,7 +1091,7 @@ private final class FooterView: UIView { return panelHeight } - func updateBackgroundAlpha(_ alpha: CGFloat, transition: Transition) { + func updateBackgroundAlpha(_ alpha: CGFloat, transition: ComponentTransition) { transition.setAlpha(view: self.backgroundNode.view, alpha: alpha) transition.setAlpha(view: self.separatorView, alpha: alpha) } @@ -1210,7 +1210,7 @@ private final class ReplaceBoostHeaderComponent: Component { } private var badgeImage: UIImage? - func update(component: ReplaceBoostHeaderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ReplaceBoostHeaderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -1305,7 +1305,7 @@ private final class ReplaceBoostHeaderComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/PremiumUI/Sources/StickersCarouselComponent.swift b/submodules/PremiumUI/Sources/StickersCarouselComponent.swift index 45dfae0797..4b12336fea 100644 --- a/submodules/PremiumUI/Sources/StickersCarouselComponent.swift +++ b/submodules/PremiumUI/Sources/StickersCarouselComponent.swift @@ -45,7 +45,7 @@ final class StickersCarouselComponent: Component { private var component: StickersCarouselComponent? private var node: StickersCarouselNode? - public func update(component: StickersCarouselComponent, availableSize: CGSize, environment: Environment, transition: Transition) -> CGSize { + public func update(component: StickersCarouselComponent, availableSize: CGSize, environment: Environment, transition: ComponentTransition) -> CGSize { let isDisplaying = environment[DemoPageEnvironment.self].isDisplaying if self.node == nil && !component.stickers.isEmpty { @@ -79,7 +79,7 @@ final class StickersCarouselComponent: Component { return View() } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, environment: environment, transition: transition) } } diff --git a/submodules/PremiumUI/Sources/StoriesPageComponent.swift b/submodules/PremiumUI/Sources/StoriesPageComponent.swift index 6b37edbcfb..396da5f2b1 100644 --- a/submodules/PremiumUI/Sources/StoriesPageComponent.swift +++ b/submodules/PremiumUI/Sources/StoriesPageComponent.swift @@ -57,7 +57,7 @@ private final class AvatarComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: AvatarComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: AvatarComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -106,7 +106,7 @@ private final class AvatarComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/ReactionSelectionNode/Sources/ReactionContextNode.swift b/submodules/ReactionSelectionNode/Sources/ReactionContextNode.swift index 3183090123..a944093f1e 100644 --- a/submodules/ReactionSelectionNode/Sources/ReactionContextNode.swift +++ b/submodules/ReactionSelectionNode/Sources/ReactionContextNode.swift @@ -701,11 +701,11 @@ public final class ReactionContextNode: ASDisplayNode, ASScrollViewDelegate { strongSelf.updateEmojiContent(emojiContent) if let reactionSelectionComponentHost = strongSelf.reactionSelectionComponentHost, let componentView = reactionSelectionComponentHost.view { - var emojiTransition: Transition = .immediate + var emojiTransition: ComponentTransition = .immediate if let scheduledEmojiContentAnimationHint = strongSelf.scheduledEmojiContentAnimationHint { strongSelf.scheduledEmojiContentAnimationHint = nil let contentAnimation = scheduledEmojiContentAnimationHint - emojiTransition = Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(contentAnimation) + emojiTransition = ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(contentAnimation) } var hideTopPanel = false @@ -1375,7 +1375,7 @@ public final class ReactionContextNode: ASDisplayNode, ASScrollViewDelegate { if (self.isExpanded || (self.reactionSelectionComponentHost != nil && !self.isCollapsing)), let _ = self.getEmojiContent, !self.reactionsLocked { let reactionSelectionComponentHost: ComponentView - var componentTransition = Transition(transition) + var componentTransition = ComponentTransition(transition) if let current = self.reactionSelectionComponentHost { reactionSelectionComponentHost = current } else { @@ -1390,7 +1390,7 @@ public final class ReactionContextNode: ASDisplayNode, ASScrollViewDelegate { if let scheduledEmojiContentAnimationHint = self.scheduledEmojiContentAnimationHint { self.scheduledEmojiContentAnimationHint = nil let contentAnimation = scheduledEmojiContentAnimationHint - componentTransition = Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(contentAnimation) + componentTransition = ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(contentAnimation) } var hideTopPanel = false @@ -1478,7 +1478,7 @@ public final class ReactionContextNode: ASDisplayNode, ASScrollViewDelegate { animationOffsetY += 46.0 + 54.0 - 4.0 } - Transition(transition).animateBoundsOrigin(view: mirrorContentClippingView, from: CGPoint(x: 0.0, y: animationOffsetY), to: CGPoint(), additive: true, completion: { [weak mirrorContentClippingView] _ in + ComponentTransition(transition).animateBoundsOrigin(view: mirrorContentClippingView, from: CGPoint(x: 0.0, y: animationOffsetY), to: CGPoint(), additive: true, completion: { [weak mirrorContentClippingView] _ in mirrorContentClippingView?.clipsToBounds = true }) } diff --git a/submodules/ScreenCaptureDetection/Sources/ScreenCaptureDetection.swift b/submodules/ScreenCaptureDetection/Sources/ScreenCaptureDetection.swift index 167c304955..f23aaf60bb 100644 --- a/submodules/ScreenCaptureDetection/Sources/ScreenCaptureDetection.swift +++ b/submodules/ScreenCaptureDetection/Sources/ScreenCaptureDetection.swift @@ -98,7 +98,7 @@ public final class ScreenCaptureDetectionManager { } var value = value #if DEBUG - value = false + value = !"".isEmpty #endif strongSelf.isRecordingActive = value if value { diff --git a/submodules/ShareController/Sources/ShareControllerNode.swift b/submodules/ShareController/Sources/ShareControllerNode.swift index abec599e04..831a1c509a 100644 --- a/submodules/ShareController/Sources/ShareControllerNode.swift +++ b/submodules/ShareController/Sources/ShareControllerNode.swift @@ -1043,8 +1043,8 @@ final class ShareControllerNode: ViewControllerTracingNode, ASScrollViewDelegate private func contentNodeDidBeginDragging() { if let contentInfoView = self.contentInfoView, contentInfoView.alpha != 0.0 { - Transition.easeInOut(duration: 0.2).setAlpha(view: contentInfoView, alpha: 0.0) - Transition.easeInOut(duration: 0.2).setScale(view: contentInfoView, scale: 0.5) + ComponentTransition.easeInOut(duration: 0.2).setAlpha(view: contentInfoView, alpha: 0.0) + ComponentTransition.easeInOut(duration: 0.2).setScale(view: contentInfoView, scale: 0.5) } } @@ -1350,8 +1350,8 @@ final class ShareControllerNode: ViewControllerTracingNode, ASScrollViewDelegate self.animatingOut = true if let contentInfoView = self.contentInfoView, contentInfoView.alpha != 0.0 { - Transition.easeInOut(duration: 0.2).setAlpha(view: contentInfoView, alpha: 0.0) - Transition.easeInOut(duration: 0.2).setScale(view: contentInfoView, scale: 0.5) + ComponentTransition.easeInOut(duration: 0.2).setAlpha(view: contentInfoView, alpha: 0.0) + ComponentTransition.easeInOut(duration: 0.2).setScale(view: contentInfoView, scale: 0.5) } if self.contentNode != nil { diff --git a/submodules/SparseItemGrid/Sources/SparseItemGridScrollingArea.swift b/submodules/SparseItemGrid/Sources/SparseItemGridScrollingArea.swift index a27fad04d5..b8068314b5 100644 --- a/submodules/SparseItemGrid/Sources/SparseItemGridScrollingArea.swift +++ b/submodules/SparseItemGrid/Sources/SparseItemGridScrollingArea.swift @@ -51,7 +51,7 @@ public final class MultilineText: Component { preconditionFailure() } - func update(component: MultilineText, availableSize: CGSize, environment: Environment, transition: Transition) -> CGSize { + func update(component: MultilineText, availableSize: CGSize, environment: Environment, transition: ComponentTransition) -> CGSize { self.text.attributedText = NSAttributedString(string: component.text, font: component.font, textColor: component.color, paragraphAlignment: nil) let textSize = self.text.updateLayout(availableSize) transition.setFrame(view: self.text.view, frame: CGRect(origin: CGPoint(), size: textSize)) @@ -64,7 +64,7 @@ public final class MultilineText: Component { return View() } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, environment: environment, transition: transition) } } @@ -97,7 +97,7 @@ public final class LottieAnimationComponent: Component { preconditionFailure() } - func update(component: LottieAnimationComponent, availableSize: CGSize, environment: Environment, transition: Transition) -> CGSize { + func update(component: LottieAnimationComponent, availableSize: CGSize, environment: Environment, transition: ComponentTransition) -> CGSize { if self.currentName != component.name { self.currentName = component.name @@ -126,7 +126,7 @@ public final class LottieAnimationComponent: Component { return View() } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, environment: environment, transition: transition) } } @@ -184,7 +184,7 @@ private final class ScrollingTooltipAnimationComponent: Component { self.animator = animator } - func update(component: ScrollingTooltipAnimationComponent, availableSize: CGSize, environment: Environment, transition: Transition) -> CGSize { + func update(component: ScrollingTooltipAnimationComponent, availableSize: CGSize, environment: Environment, transition: ComponentTransition) -> CGSize { return CGSize(width: 32.0, height: 32.0) } @@ -249,7 +249,7 @@ private final class ScrollingTooltipAnimationComponent: Component { return View() } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, environment: environment, transition: transition) } } @@ -324,7 +324,7 @@ public final class TooltipComponent: Component { preconditionFailure() } - func update(component: TooltipComponent, availableSize: CGSize, environment: Environment, transition: Transition) -> CGSize { + func update(component: TooltipComponent, availableSize: CGSize, environment: Environment, transition: ComponentTransition) -> CGSize { let insets = UIEdgeInsets(top: 8.0, left: 8.0, bottom: 8.0, right: 8.0) let spacing: CGFloat = 8.0 @@ -400,7 +400,7 @@ public final class TooltipComponent: Component { return View() } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, environment: environment, transition: transition) } } @@ -437,7 +437,7 @@ private final class RoundedRectangle: Component { preconditionFailure() } - func update(component: RoundedRectangle, availableSize: CGSize, environment: Environment, transition: Transition) -> CGSize { + func update(component: RoundedRectangle, availableSize: CGSize, environment: Environment, transition: ComponentTransition) -> CGSize { let shadowInset: CGFloat = 0.0 let diameter = min(availableSize.width, availableSize.height) @@ -476,7 +476,7 @@ private final class RoundedRectangle: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, environment: environment, transition: transition) } } @@ -514,7 +514,7 @@ private final class ShadowRoundedRectangle: Component { preconditionFailure() } - func update(component: ShadowRoundedRectangle, availableSize: CGSize, environment: Environment, transition: Transition) -> CGSize { + func update(component: ShadowRoundedRectangle, availableSize: CGSize, environment: Environment, transition: ComponentTransition) -> CGSize { let diameter = min(availableSize.width, availableSize.height) var updated = false @@ -551,7 +551,7 @@ private final class ShadowRoundedRectangle: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, environment: environment, transition: transition) } } @@ -702,7 +702,7 @@ public final class RollingText: Component { return View() } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize) } } @@ -1218,12 +1218,12 @@ public final class SparseItemGridScrollingArea: ASDisplayNode { } let lineIndicatorSize = CGSize(width: (self.isDragging || self.lineTooltip != nil) ? 6.0 : 3.0, height: scrollIndicatorHeight) - let mappedTransition: Transition + let mappedTransition: ComponentTransition switch transition { case .immediate: mappedTransition = .immediate case let .animated(duration, _): - mappedTransition = Transition(animation: .curve(duration: duration, curve: .easeInOut)) + mappedTransition = ComponentTransition(animation: .curve(duration: duration, curve: .easeInOut)) } let _ = self.lineIndicator.update( transition: mappedTransition, diff --git a/submodules/StatisticsUI/Sources/BoostHeaderItem.swift b/submodules/StatisticsUI/Sources/BoostHeaderItem.swift index 5b70e642fc..34f192ec51 100644 --- a/submodules/StatisticsUI/Sources/BoostHeaderItem.swift +++ b/submodules/StatisticsUI/Sources/BoostHeaderItem.swift @@ -206,7 +206,7 @@ final class BoostHeaderItemNode: ItemListControllerHeaderItemNode { if let hostView = self.hostView { let size = hostView.update( - transition: Transition(transition), + transition: ComponentTransition(transition), component: component, environment: {}, containerSize: containerSize diff --git a/submodules/StatisticsUI/Sources/StatsMessageItem.swift b/submodules/StatisticsUI/Sources/StatsMessageItem.swift index 64323ad58d..564c4c2d06 100644 --- a/submodules/StatisticsUI/Sources/StatsMessageItem.swift +++ b/submodules/StatisticsUI/Sources/StatsMessageItem.swift @@ -649,7 +649,7 @@ final class StatsMessageItemNode: ListViewItemNode, ItemListItemNode { let indicatorSize = CGSize(width: imageSize.width - lineWidth * 4.0, height: imageSize.height - lineWidth * 4.0) let storyIndicator: ComponentView - let indicatorTransition: Transition = .immediate + let indicatorTransition: ComponentTransition = .immediate if let current = strongSelf.storyIndicator { storyIndicator = current } else { diff --git a/submodules/TelegramCallsUI/Sources/CallControllerNodeV2.swift b/submodules/TelegramCallsUI/Sources/CallControllerNodeV2.swift index 4b55901252..934725f543 100644 --- a/submodules/TelegramCallsUI/Sources/CallControllerNodeV2.swift +++ b/submodules/TelegramCallsUI/Sources/CallControllerNodeV2.swift @@ -716,7 +716,7 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP interfaceOrientation: layout.metrics.orientation ?? .portrait, screenCornerRadius: layout.deviceMetrics.screenCornerRadius, state: callScreenState, - transition: Transition(transition) + transition: ComponentTransition(transition) ) } } diff --git a/submodules/TelegramCallsUI/Sources/Components/AnimatedCounterView.swift b/submodules/TelegramCallsUI/Sources/Components/AnimatedCounterView.swift index 8ebe446403..3327eb027e 100644 --- a/submodules/TelegramCallsUI/Sources/Components/AnimatedCounterView.swift +++ b/submodules/TelegramCallsUI/Sources/Components/AnimatedCounterView.swift @@ -43,7 +43,7 @@ public final class AnimatedCountView: UIView { self.updateFrames() } - func updateFrames(transition: ComponentFlow.Transition? = nil) { + func updateFrames(transition: ComponentFlow.ComponentTransition? = nil) { let subtitleHeight: CGFloat = subtitleLabel.intrinsicContentSize.height let subtitleFrame = CGRect(x: bounds.midX - subtitleLabel.intrinsicContentSize.width / 2 - 10, y: self.countLabel.attributedText?.length == 0 ? bounds.midY - subtitleHeight / 2 : bounds.height - subtitleHeight, width: subtitleLabel.intrinsicContentSize.width + 20, height: subtitleHeight) if let transition { diff --git a/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift b/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift index a70300baee..35877a0bd4 100644 --- a/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift +++ b/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift @@ -196,7 +196,7 @@ public final class MediaStreamComponent: CombinedComponent { func toggleDisplayUI() { self.displayUI = !self.displayUI - self.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .easeInOut))) + self.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .easeInOut))) } func cancelScheduledDismissUI() { @@ -224,7 +224,7 @@ public final class MediaStreamComponent: CombinedComponent { if interactive { self.updated(transition: .immediate) } else { - self.updated(transition: Transition(animation: .curve(duration: 0.25, curve: .easeInOut))) + self.updated(transition: ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut))) } } } @@ -1552,7 +1552,7 @@ private final class StreamTitleComponent: Component { } } - func update(component: StreamTitleComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: StreamTitleComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { let liveIndicatorWidth: CGFloat = self.liveIndicatorView.desiredWidth let liveIndicatorHeight: CGFloat = 20.0 @@ -1686,7 +1686,7 @@ private final class StreamTitleComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } @@ -2024,7 +2024,7 @@ final class RoundGradientButtonComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: RoundGradientButtonComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: RoundGradientButtonComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.iconView.image = component.image ?? component.icon.flatMap { UIImage(bundleImageName: $0) } let gradientColors: [CGColor] if component.gradientColors.count == 1 { @@ -2062,7 +2062,7 @@ final class RoundGradientButtonComponent: Component { View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramCallsUI/Sources/Components/MediaStreamVideoComponent.swift b/submodules/TelegramCallsUI/Sources/Components/MediaStreamVideoComponent.swift index f5ec2f8209..2debd4072b 100644 --- a/submodules/TelegramCallsUI/Sources/Components/MediaStreamVideoComponent.swift +++ b/submodules/TelegramCallsUI/Sources/Components/MediaStreamVideoComponent.swift @@ -193,7 +193,7 @@ final class MediaStreamVideoComponent: Component { } } - private func updateVideoStalled(isStalled: Bool, transition: Transition?) { + private func updateVideoStalled(isStalled: Bool, transition: ComponentTransition?) { if isStalled { guard let component = self.component else { return } @@ -282,7 +282,7 @@ final class MediaStreamVideoComponent: Component { } } - func update(component: MediaStreamVideoComponent, availableSize: CGSize, state: State, transition: Transition) -> CGSize { + func update(component: MediaStreamVideoComponent, availableSize: CGSize, state: State, transition: ComponentTransition) -> CGSize { self.state = state self.component = component self.onVideoPlaybackChange = component.onVideoPlaybackLiveChange @@ -459,7 +459,7 @@ final class MediaStreamVideoComponent: Component { let videoSize: CGSize let videoCornerRadius: CGFloat = component.isFullscreen ? 0 : 10 - let videoFrameUpdateTransition: Transition + let videoFrameUpdateTransition: ComponentTransition if self.wasFullscreen != component.isFullscreen { videoFrameUpdateTransition = transition } else { @@ -551,7 +551,7 @@ final class MediaStreamVideoComponent: Component { if loadingBlurView.frame == .zero { loadingBlurView.frame = loadingBlurViewFrame } else { - // Using Transition.setFrame on UIVisualEffectView causes instant update of sublayers + // Using ComponentTransition.setFrame on UIVisualEffectView causes instant update of sublayers switch videoFrameUpdateTransition.animation { case let .curve(duration, curve): UIView.animate(withDuration: duration, delay: 0, options: curve.containedViewLayoutTransitionCurve.viewAnimationOptions, animations: { [self] in @@ -741,7 +741,7 @@ final class MediaStreamVideoComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, transition: transition) } } diff --git a/submodules/TelegramCallsUI/Sources/Components/ParticipantsComponent.swift b/submodules/TelegramCallsUI/Sources/Components/ParticipantsComponent.swift index 29e1b9d25e..185dda5c48 100644 --- a/submodules/TelegramCallsUI/Sources/Components/ParticipantsComponent.swift +++ b/submodules/TelegramCallsUI/Sources/Components/ParticipantsComponent.swift @@ -43,7 +43,7 @@ final class ParticipantsComponent: Component { View(frame: .zero) } - func update(view: View, availableSize: CGSize, state: ComponentFlow.EmptyComponentState, environment: ComponentFlow.Environment, transition: ComponentFlow.Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: ComponentFlow.EmptyComponentState, environment: ComponentFlow.Environment, transition: ComponentFlow.ComponentTransition) -> CGSize { view.counter.update( countString: self.count > 0 ? presentationStringsFormattedNumber(Int32(count), ",") : "", subtitle: self.showsSubtitle ? (self.count > 0 ? self.strings.LiveStream_Watching.lowercased() : self.strings.LiveStream_NoViewers.lowercased()) : "", diff --git a/submodules/TelegramCallsUI/Sources/Components/StreamSheetComponent.swift b/submodules/TelegramCallsUI/Sources/Components/StreamSheetComponent.swift index 54b037d457..9f568732b9 100644 --- a/submodules/TelegramCallsUI/Sources/Components/StreamSheetComponent.swift +++ b/submodules/TelegramCallsUI/Sources/Components/StreamSheetComponent.swift @@ -106,7 +106,7 @@ final class StreamSheetComponent: CombinedComponent { return false } - func update(component: StreamSheetComponent, availableSize: CGSize, state: State, transition: Transition) -> CGSize { + func update(component: StreamSheetComponent, availableSize: CGSize, state: State, transition: ComponentTransition) -> CGSize { return availableSize } @@ -202,7 +202,7 @@ final class SheetBackgroundComponent: Component { class View: UIView { private let backgroundView = UIView() - func update(availableSize: CGSize, color: UIColor, cornerRadius: CGFloat, offset: CGFloat, transition: Transition) { + func update(availableSize: CGSize, color: UIColor, cornerRadius: CGFloat, offset: CGFloat, transition: ComponentTransition) { if backgroundView.superview == nil { self.addSubview(backgroundView) } @@ -262,7 +262,7 @@ final class SheetBackgroundComponent: Component { self.offset = offset } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { view.update(availableSize: availableSize, color: color, cornerRadius: radius, offset: offset, transition: transition) return availableSize } diff --git a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift index ed0b1e120e..e80e972eba 100644 --- a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift +++ b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift @@ -853,6 +853,8 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { public let isStream: Bool + public var onMutedSpeechActivityDetected: ((Bool) -> Void)? + init( accountContext: AccountContext, audioSession: ManagedAudioSession, @@ -1674,8 +1676,14 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { strongSelf.requestCall(movingFromBroadcastToRtc: false) } } - }, outgoingAudioBitrateKbit: outgoingAudioBitrateKbit, videoContentType: self.isVideoEnabled ? .generic : .none, enableNoiseSuppression: false, disableAudioInput: self.isStream, preferX264: self.accountContext.sharedContext.immediateExperimentalUISettings.preferredVideoCodec == "H264", logPath: allocateCallLogPath(account: self.account) - )) + }, outgoingAudioBitrateKbit: outgoingAudioBitrateKbit, videoContentType: self.isVideoEnabled ? .generic : .none, enableNoiseSuppression: false, disableAudioInput: self.isStream, preferX264: self.accountContext.sharedContext.immediateExperimentalUISettings.preferredVideoCodec == "H264", logPath: allocateCallLogPath(account: self.account), onMutedSpeechActivityDetected: { [weak self] value in + Queue.mainQueue().async { + guard let strongSelf = self else { + return + } + strongSelf.onMutedSpeechActivityDetected?(value) + } + })) } self.genericCallContext = genericCallContext @@ -2967,7 +2975,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { self.hasScreencast = true - let screencastCallContext = OngoingGroupCallContext(audioSessionActive: .single(true), video: self.screencastCapturer, requestMediaChannelDescriptions: { _, _ in EmptyDisposable }, rejoinNeeded: { }, outgoingAudioBitrateKbit: nil, videoContentType: .screencast, enableNoiseSuppression: false, disableAudioInput: true, preferX264: false, logPath: "") + let screencastCallContext = OngoingGroupCallContext(audioSessionActive: .single(true), video: self.screencastCapturer, requestMediaChannelDescriptions: { _, _ in EmptyDisposable }, rejoinNeeded: { }, outgoingAudioBitrateKbit: nil, videoContentType: .screencast, enableNoiseSuppression: false, disableAudioInput: true, preferX264: false, logPath: "", onMutedSpeechActivityDetected: { _ in }) self.screencastCallContext = screencastCallContext self.screencastJoinDisposable.set((screencastCallContext.joinPayload diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift index e21733c55b..9bd0f391da 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift @@ -2452,6 +2452,24 @@ public final class VoiceChatControllerImpl: ViewController, VoiceChatController } }) } + + var lastTimestamp = 0.0 + self.call.onMutedSpeechActivityDetected = { [weak self] value in + Queue.mainQueue().async { + guard let self, value else { + return + } + let timestamp = CFAbsoluteTimeGetCurrent() + if lastTimestamp + 1000.0 < timestamp { + lastTimestamp = timestamp + + //TODO:localize + self.presentUndoOverlay(content: .info(title: nil, text: "Your microphone is muted.", timeout: nil, customUndoText: nil), action: { _ in + return false + }) + } + } + } } deinit { diff --git a/submodules/TelegramCore/Sources/Statistics/StarsRevenueStatistics.swift b/submodules/TelegramCore/Sources/Statistics/StarsRevenueStatistics.swift index 28e0cdaa28..b8af085132 100644 --- a/submodules/TelegramCore/Sources/Statistics/StarsRevenueStatistics.swift +++ b/submodules/TelegramCore/Sources/Statistics/StarsRevenueStatistics.swift @@ -6,10 +6,10 @@ import MtProtoKit public struct StarsRevenueStats: Equatable { public struct Balances: Equatable { - public let canWithdraw: Bool public let currentBalance: Int64 public let availableBalance: Int64 public let overallRevenue: Int64 + public let withdrawEnabled: Bool } public let revenueGraph: StatsGraph @@ -59,7 +59,7 @@ extension StarsRevenueStats.Balances { init(apiStarsRevenueStatus: Api.StarsRevenueStatus) { switch apiStarsRevenueStatus { case let .starsRevenueStatus(flags, currentBalance, availableBalance, overallRevenue): - self.init(canWithdraw: (flags & (1 << 0)) != 0, currentBalance: currentBalance, availableBalance: availableBalance, overallRevenue: overallRevenue) + self.init(currentBalance: currentBalance, availableBalance: availableBalance, overallRevenue: overallRevenue, withdrawEnabled: ((flags & (1 << 0)) != 0)) } } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/StoryListContext.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/StoryListContext.swift index 7dc1bc5711..241197c745 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/StoryListContext.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/StoryListContext.swift @@ -565,7 +565,7 @@ public struct StoryListContextState: Equatable { public var isCached: Bool public var hasCache: Bool public var allEntityFiles: [MediaId: TelegramMediaFile] - + public var isLoading: Bool public init( peerReference: PeerReference?, items: [Item], @@ -574,7 +574,8 @@ public struct StoryListContextState: Equatable { loadMoreToken: AnyHashable?, isCached: Bool, hasCache: Bool, - allEntityFiles: [MediaId: TelegramMediaFile] + allEntityFiles: [MediaId: TelegramMediaFile], + isLoading: Bool ) { self.peerReference = peerReference self.items = items @@ -584,6 +585,7 @@ public struct StoryListContextState: Equatable { self.isCached = isCached self.hasCache = hasCache self.allEntityFiles = allEntityFiles + self.isLoading = isLoading } } @@ -625,7 +627,7 @@ public final class PeerStoryListContext: StoryListContext { self.peerId = peerId self.isArchived = isArchived - self.stateValue = State(peerReference: nil, items: [], pinnedIds: Set(), totalCount: 0, loadMoreToken: AnyHashable(0 as Int), isCached: true, hasCache: false, allEntityFiles: [:]) + self.stateValue = State(peerReference: nil, items: [], pinnedIds: Set(), totalCount: 0, loadMoreToken: AnyHashable(0 as Int), isCached: true, hasCache: false, allEntityFiles: [:], isLoading: false) let _ = (account.postbox.transaction { transaction -> (PeerReference?, [State.Item], [Int32], Int, [MediaId: TelegramMediaFile], Bool) in let key = ValueBoxKey(length: 8 + 1) @@ -714,7 +716,7 @@ public final class PeerStoryListContext: StoryListContext { return } - var updatedState = State(peerReference: peerReference, items: items, pinnedIds: Set(pinnedIds), totalCount: totalCount, loadMoreToken: AnyHashable(0 as Int), isCached: true, hasCache: hasCache, allEntityFiles: allEntityFiles) + var updatedState = State(peerReference: peerReference, items: items, pinnedIds: Set(pinnedIds), totalCount: totalCount, loadMoreToken: AnyHashable(0 as Int), isCached: true, hasCache: hasCache, allEntityFiles: allEntityFiles, isLoading: false) updatedState.items.sort(by: { lhs, rhs in let lhsPinned = updatedState.pinnedIds.contains(lhs.storyItem.id) let rhsPinned = updatedState.pinnedIds.contains(rhs.storyItem.id) @@ -1280,7 +1282,11 @@ public final class SearchStoryListContext: StoryListContext { return self.statePromise.get() } - private var isLoadingMore: Bool = false + private var isLoadingMore: Bool = false { + didSet { + self.stateValue.isLoading = isLoadingMore + } + } private var requestDisposable: Disposable? private var updatesDisposable: Disposable? @@ -1292,7 +1298,7 @@ public final class SearchStoryListContext: StoryListContext { self.account = account self.source = source - self.stateValue = State(peerReference: nil, items: [], pinnedIds: Set(), totalCount: 0, loadMoreToken: AnyHashable(""), isCached: false, hasCache: false, allEntityFiles: [:]) + self.stateValue = State(peerReference: nil, items: [], pinnedIds: Set(), totalCount: 0, loadMoreToken: AnyHashable(""), isCached: false, hasCache: false, allEntityFiles: [:], isLoading: false) self.statePromise.set(.single(self.stateValue)) self.loadMore(completion: nil) diff --git a/submodules/TelegramUI/Components/ActionPanelComponent/Sources/ActionPanelComponent.swift b/submodules/TelegramUI/Components/ActionPanelComponent/Sources/ActionPanelComponent.swift index 2e946f37db..988c96b31f 100644 --- a/submodules/TelegramUI/Components/ActionPanelComponent/Sources/ActionPanelComponent.swift +++ b/submodules/TelegramUI/Components/ActionPanelComponent/Sources/ActionPanelComponent.swift @@ -126,7 +126,7 @@ public final class ActionPanelComponent: Component { return super.hitTest(point, with: event) } - func update(component: ActionPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ActionPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme self.component = component @@ -185,7 +185,7 @@ public final class ActionPanelComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/AdminUserActionsSheet/Sources/AdminUserActionsPeerComponent.swift b/submodules/TelegramUI/Components/AdminUserActionsSheet/Sources/AdminUserActionsPeerComponent.swift index 47fa71b51f..c6759c8c06 100644 --- a/submodules/TelegramUI/Components/AdminUserActionsSheet/Sources/AdminUserActionsPeerComponent.swift +++ b/submodules/TelegramUI/Components/AdminUserActionsSheet/Sources/AdminUserActionsPeerComponent.swift @@ -135,7 +135,7 @@ final class AdminUserActionsPeerComponent: Component { component.action(peer) } - func update(component: AdminUserActionsPeerComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: AdminUserActionsPeerComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme var hasSelectionUpdated = false @@ -270,7 +270,7 @@ final class AdminUserActionsPeerComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/AdminUserActionsSheet/Sources/AdminUserActionsSheet.swift b/submodules/TelegramUI/Components/AdminUserActionsSheet/Sources/AdminUserActionsSheet.swift index 150c207776..b85e764df7 100644 --- a/submodules/TelegramUI/Components/AdminUserActionsSheet/Sources/AdminUserActionsSheet.swift +++ b/submodules/TelegramUI/Components/AdminUserActionsSheet/Sources/AdminUserActionsSheet.swift @@ -435,7 +435,7 @@ private final class AdminUserActionsSheetComponent: Component { ) } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { guard let environment = self.environment, let controller = environment.controller(), let itemLayout = self.itemLayout else { return } @@ -497,7 +497,7 @@ private final class AdminUserActionsSheetComponent: Component { } } - func update(component: AdminUserActionsSheetComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: AdminUserActionsSheetComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -859,7 +859,7 @@ private final class AdminUserActionsSheetComponent: Component { self.optionBanSelectedPeers = selectedPeers } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .easeInOut))) } )))) } @@ -1400,7 +1400,7 @@ private final class AdminUserActionsSheetComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -1524,7 +1524,7 @@ private final class OptionSectionExpandIndicatorComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: OptionSectionExpandIndicatorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: OptionSectionExpandIndicatorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let countArrowSpacing: CGFloat = 1.0 let iconCountSpacing: CGFloat = 1.0 @@ -1578,7 +1578,7 @@ private final class OptionSectionExpandIndicatorComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -1627,7 +1627,7 @@ private final class MediaSectionExpandIndicatorComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: MediaSectionExpandIndicatorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: MediaSectionExpandIndicatorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let titleArrowSpacing: CGFloat = 1.0 if self.arrowView.image == nil { @@ -1669,7 +1669,7 @@ private final class MediaSectionExpandIndicatorComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -1728,7 +1728,7 @@ private final class OptionsSectionFooterComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: OptionsSectionFooterComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: OptionsSectionFooterComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { if self.arrowView.image == nil { self.arrowView.image = PresentationResourcesItemList.expandSmallDownArrowImage(component.theme) } @@ -1761,7 +1761,7 @@ private final class OptionsSectionFooterComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/AdminUserActionsSheet/Sources/RecentActionsSettingsSheet.swift b/submodules/TelegramUI/Components/AdminUserActionsSheet/Sources/RecentActionsSettingsSheet.swift index 2a3c17d32a..b6a138bce9 100644 --- a/submodules/TelegramUI/Components/AdminUserActionsSheet/Sources/RecentActionsSettingsSheet.swift +++ b/submodules/TelegramUI/Components/AdminUserActionsSheet/Sources/RecentActionsSettingsSheet.swift @@ -369,7 +369,7 @@ private final class RecentActionsSettingsSheetComponent: Component { ) } - private func updateScrolling(isFirstTime: Bool = false, transition: Transition) { + private func updateScrolling(isFirstTime: Bool = false, transition: ComponentTransition) { guard let environment = self.environment, let controller = environment.controller(), let itemLayout = self.itemLayout else { return } @@ -438,7 +438,7 @@ private final class RecentActionsSettingsSheetComponent: Component { } } - func update(component: RecentActionsSettingsSheetComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: RecentActionsSettingsSheetComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -775,7 +775,7 @@ private final class RecentActionsSettingsSheetComponent: Component { self.selectedAdmins.insert(peer.id) } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.35, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.35, curve: .easeInOut))) } )))) } @@ -792,7 +792,7 @@ private final class RecentActionsSettingsSheetComponent: Component { self.selectedAdmins.removeAll() } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.35, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.35, curve: .easeInOut))) } adminsSectionItems.append(AnyComponentWithIdentity(id: adminsSectionItems.count, component: AnyComponent(ListActionItemComponent( theme: environment.theme, @@ -944,7 +944,7 @@ private final class RecentActionsSettingsSheetComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -1051,7 +1051,7 @@ private final class MediaSectionExpandIndicatorComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: MediaSectionExpandIndicatorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: MediaSectionExpandIndicatorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let titleArrowSpacing: CGFloat = 1.0 if self.arrowView.image == nil { @@ -1093,7 +1093,7 @@ private final class MediaSectionExpandIndicatorComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Ads/AdsReportScreen/Sources/AdsReportScreen.swift b/submodules/TelegramUI/Components/Ads/AdsReportScreen/Sources/AdsReportScreen.swift index cb1bcc02fb..17359fffd5 100644 --- a/submodules/TelegramUI/Components/Ads/AdsReportScreen/Sources/AdsReportScreen.swift +++ b/submodules/TelegramUI/Components/Ads/AdsReportScreen/Sources/AdsReportScreen.swift @@ -256,7 +256,7 @@ private final class SheetContent: CombinedComponent { let openMore: () -> Void let complete: (ReportResult) -> Void let dismiss: () -> Void - let update: (Transition) -> Void + let update: (ComponentTransition) -> Void init( context: AccountContext, @@ -268,7 +268,7 @@ private final class SheetContent: CombinedComponent { openMore: @escaping () -> Void, complete: @escaping (ReportResult) -> Void, dismiss: @escaping () -> Void, - update: @escaping (Transition) -> Void + update: @escaping (ComponentTransition) -> Void ) { self.context = context self.peerId = peerId @@ -659,7 +659,7 @@ public final class AdsReportScreen: ViewControllerComponentContainer { private final class NavigationContainer: UIView, UIGestureRecognizerDelegate { - var requestUpdate: ((Transition) -> Void)? + var requestUpdate: ((ComponentTransition) -> Void)? var requestPop: (() -> Void)? var transitionFraction: CGFloat = 0.0 @@ -772,10 +772,10 @@ final class NavigationStackComponent: Component { var index: Int var itemId: AnyHashable var itemView: ItemView - var itemTransition: Transition + var itemTransition: ComponentTransition var itemSize: CGSize - init(index: Int, itemId: AnyHashable, itemView: ItemView, itemTransition: Transition, itemSize: CGSize) { + init(index: Int, itemId: AnyHashable, itemView: ItemView, itemTransition: ComponentTransition, itemSize: CGSize) { self.index = index self.itemId = itemId self.itemView = itemView @@ -815,7 +815,7 @@ final class NavigationStackComponent: Component { preconditionFailure() } - func update(component: NavigationStackComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: NavigationStackComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -945,7 +945,7 @@ final class NavigationStackComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/AnimatedCounterComponent/Sources/AnimatedCounterComponent.swift b/submodules/TelegramUI/Components/AnimatedCounterComponent/Sources/AnimatedCounterComponent.swift index 8f77f6976a..2a8375e443 100644 --- a/submodules/TelegramUI/Components/AnimatedCounterComponent/Sources/AnimatedCounterComponent.swift +++ b/submodules/TelegramUI/Components/AnimatedCounterComponent/Sources/AnimatedCounterComponent.swift @@ -61,7 +61,7 @@ final class AnimatedCounterItemComponent: Component { preconditionFailure() } - func update(component: AnimatedCounterItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: AnimatedCounterItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousNumericValue = self.component?.numericValue self.component = component @@ -92,7 +92,7 @@ final class AnimatedCounterItemComponent: Component { let offsetY: CGFloat = size.height * 0.6 * (previousNumericValue < component.numericValue ? -1.0 : 1.0) - let subTransition = Transition(animation: .curve(duration: 0.16, curve: .easeInOut)) + let subTransition = ComponentTransition(animation: .curve(duration: 0.16, curve: .easeInOut)) subTransition.animatePosition(view: self.contentView, from: CGPoint(x: 0.0, y: offsetY), to: CGPoint(), additive: true) subTransition.animateAlpha(view: self.contentView, from: 0.0, to: 1.0) @@ -111,7 +111,7 @@ final class AnimatedCounterItemComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -188,7 +188,7 @@ public final class AnimatedCounterComponent: Component { preconditionFailure() } - func update(component: AnimatedCounterComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: AnimatedCounterComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let spaceWidth: CGFloat if let measuredSpaceWidth = self.measuredSpaceWidth, let previousComponent = self.component, previousComponent.font.pointSize == component.font.pointSize { spaceWidth = measuredSpaceWidth @@ -273,7 +273,7 @@ public final class AnimatedCounterComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/AnimatedTextComponent/Sources/AnimatedTextComponent.swift b/submodules/TelegramUI/Components/AnimatedTextComponent/Sources/AnimatedTextComponent.swift index d30ca5dcb4..5c3a6f0546 100644 --- a/submodules/TelegramUI/Components/AnimatedTextComponent/Sources/AnimatedTextComponent.swift +++ b/submodules/TelegramUI/Components/AnimatedTextComponent/Sources/AnimatedTextComponent.swift @@ -68,7 +68,7 @@ public final class AnimatedTextComponent: Component { preconditionFailure() } - func update(component: AnimatedTextComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: AnimatedTextComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -190,7 +190,7 @@ public final class AnimatedTextComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/AudioTranscriptionButtonComponent/Sources/AudioTranscriptionButtonComponent.swift b/submodules/TelegramUI/Components/AudioTranscriptionButtonComponent/Sources/AudioTranscriptionButtonComponent.swift index 3696b9ffea..0433cbae59 100644 --- a/submodules/TelegramUI/Components/AudioTranscriptionButtonComponent/Sources/AudioTranscriptionButtonComponent.swift +++ b/submodules/TelegramUI/Components/AudioTranscriptionButtonComponent/Sources/AudioTranscriptionButtonComponent.swift @@ -99,7 +99,7 @@ public final class AudioTranscriptionButtonComponent: Component { self.component?.pressed() } - func update(component: AudioTranscriptionButtonComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: AudioTranscriptionButtonComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { let size = CGSize(width: 30.0, height: 30.0) let foregroundColor: UIColor @@ -273,7 +273,7 @@ public final class AudioTranscriptionButtonComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/TelegramUI/Components/AudioTranscriptionPendingIndicatorComponent/Sources/AudioTranscriptionPendingIndicatorComponent.swift b/submodules/TelegramUI/Components/AudioTranscriptionPendingIndicatorComponent/Sources/AudioTranscriptionPendingIndicatorComponent.swift index e45f38fbbb..a4427eef43 100644 --- a/submodules/TelegramUI/Components/AudioTranscriptionPendingIndicatorComponent/Sources/AudioTranscriptionPendingIndicatorComponent.swift +++ b/submodules/TelegramUI/Components/AudioTranscriptionPendingIndicatorComponent/Sources/AudioTranscriptionPendingIndicatorComponent.swift @@ -63,7 +63,7 @@ public final class AudioTranscriptionPendingIndicatorComponent: Component { } } - func update(component: AudioTranscriptionPendingIndicatorComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: AudioTranscriptionPendingIndicatorComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { let dotSize: CGFloat = 2.0 let spacing: CGFloat = 3.0 @@ -95,7 +95,7 @@ public final class AudioTranscriptionPendingIndicatorComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } @@ -134,7 +134,7 @@ public final class AudioTranscriptionPendingLottieIndicatorComponent: Component fatalError("init(coder:) has not been implemented") } - func update(component: AudioTranscriptionPendingLottieIndicatorComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: AudioTranscriptionPendingLottieIndicatorComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { let originalSize = CGSize(width: 48.0, height: 66.0) let animationSize = originalSize.aspectFitted(CGSize(width: 15.0, height: 100.0)) let _ = self.animationView.update( @@ -171,7 +171,7 @@ public final class AudioTranscriptionPendingLottieIndicatorComponent: Component return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/TelegramUI/Components/AudioWaveformComponent/Sources/AudioWaveformComponent.swift b/submodules/TelegramUI/Components/AudioWaveformComponent/Sources/AudioWaveformComponent.swift index 2eb94f5e3f..d1f84dd356 100644 --- a/submodules/TelegramUI/Components/AudioWaveformComponent/Sources/AudioWaveformComponent.swift +++ b/submodules/TelegramUI/Components/AudioWaveformComponent/Sources/AudioWaveformComponent.swift @@ -364,7 +364,7 @@ public final class AudioWaveformComponent: Component { } } - func update(component: AudioWaveformComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: AudioWaveformComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { let size = CGSize(width: availableSize.width, height: availableSize.height) if self.validSize != size || self.component != component { @@ -650,7 +650,7 @@ public final class AudioWaveformComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarEditorScreen.swift b/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarEditorScreen.swift index 563cd08d21..9e19fb46b4 100644 --- a/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarEditorScreen.swift +++ b/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarEditorScreen.swift @@ -686,7 +686,7 @@ final class AvatarEditorScreenComponent: Component { self.endEditing(true) if let state = self.state, state.expanded { state.expanded = false - state.updated(transition: Transition(animation: .curve(duration: 0.45, curve: .spring))) + state.updated(transition: ComponentTransition(animation: .curve(duration: 0.45, curve: .spring))) } } }, @@ -817,7 +817,7 @@ final class AvatarEditorScreenComponent: Component { self.endEditing(true) if let state = self.state, state.expanded { state.expanded = false - state.updated(transition: Transition(animation: .curve(duration: 0.45, curve: .spring))) + state.updated(transition: ComponentTransition(animation: .curve(duration: 0.45, curve: .spring))) } } }, @@ -839,7 +839,7 @@ final class AvatarEditorScreenComponent: Component { private var isExpanded = false - func update(component: AvatarEditorScreenComponent, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + func update(component: AvatarEditorScreenComponent, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -983,7 +983,7 @@ final class AvatarEditorScreenComponent: Component { emojiView.ensureSearchUnfocused() } state.expanded = !state.expanded - state.updated(transition: Transition(animation: .curve(duration: 0.35, curve: .spring))) + state.updated(transition: ComponentTransition(animation: .curve(duration: 0.35, curve: .spring))) } } ) @@ -1491,7 +1491,7 @@ final class AvatarEditorScreenComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarPreviewComponent.swift b/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarPreviewComponent.swift index 3fe58e72e3..cc76d661fb 100644 --- a/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarPreviewComponent.swift +++ b/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarPreviewComponent.swift @@ -93,7 +93,7 @@ final class AvatarPreviewComponent: Component { self.component?.tapped() } - func update(component: AvatarPreviewComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: AvatarPreviewComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousBackground = self.component?.background let hadFile = self.component?.file != nil @@ -220,7 +220,7 @@ final class AvatarPreviewComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/BackgroundColorComponent.swift b/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/BackgroundColorComponent.swift index d56e398b9e..169030cb08 100644 --- a/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/BackgroundColorComponent.swift +++ b/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/BackgroundColorComponent.swift @@ -63,7 +63,7 @@ final class BackgroundColorComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: BackgroundColorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BackgroundColorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -125,7 +125,7 @@ final class BackgroundColorComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -242,7 +242,7 @@ final class BackgroundSwatchComponent: Component { super.cancelTracking(with: event) } - func update(component: BackgroundSwatchComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BackgroundSwatchComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousBackground = self.component?.background self.component = component @@ -313,7 +313,7 @@ final class BackgroundSwatchComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/ColorPickerComponent.swift b/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/ColorPickerComponent.swift index 73de5e8819..100c74d727 100644 --- a/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/ColorPickerComponent.swift +++ b/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/ColorPickerComponent.swift @@ -395,7 +395,7 @@ final class ColorPickerComponent: Component { } private var component: ColorPickerComponent? - func update(component: ColorPickerComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: ColorPickerComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { let themeChanged = self.component?.theme !== component.theme let previousIsVisible = self.component?.isVisible ?? false self.component = component @@ -448,7 +448,7 @@ final class ColorPickerComponent: Component { return View(theme: self.theme, strings: self.strings) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/TelegramUI/Components/BackButtonComponent/Sources/BackButtonComponent.swift b/submodules/TelegramUI/Components/BackButtonComponent/Sources/BackButtonComponent.swift index 88379e4199..2838a44c68 100644 --- a/submodules/TelegramUI/Components/BackButtonComponent/Sources/BackButtonComponent.swift +++ b/submodules/TelegramUI/Components/BackButtonComponent/Sources/BackButtonComponent.swift @@ -67,7 +67,7 @@ public final class BackButtonComponent: Component { return super.hitTest(point, with: event) } - func update(component: BackButtonComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BackButtonComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let sideInset: CGFloat = 4.0 let titleSize = self.title.update( @@ -97,7 +97,7 @@ public final class BackButtonComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/BottomButtonPanelComponent/Sources/BottomButtonPanelComponent.swift b/submodules/TelegramUI/Components/BottomButtonPanelComponent/Sources/BottomButtonPanelComponent.swift index 004611ea4d..4e56d8d03f 100644 --- a/submodules/TelegramUI/Components/BottomButtonPanelComponent/Sources/BottomButtonPanelComponent.swift +++ b/submodules/TelegramUI/Components/BottomButtonPanelComponent/Sources/BottomButtonPanelComponent.swift @@ -71,7 +71,7 @@ public final class BottomButtonPanelComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: BottomButtonPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BottomButtonPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme self.component = component @@ -142,7 +142,7 @@ public final class BottomButtonPanelComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ButtonComponent/Sources/ButtonComponent.swift b/submodules/TelegramUI/Components/ButtonComponent/Sources/ButtonComponent.swift index f23ba40ed2..f3c401fcbb 100644 --- a/submodules/TelegramUI/Components/ButtonComponent/Sources/ButtonComponent.swift +++ b/submodules/TelegramUI/Components/ButtonComponent/Sources/ButtonComponent.swift @@ -52,7 +52,7 @@ public final class ButtonBadgeComponent: Component { fatalError("init(coder:) has not been implemented") } - public func update(component: ButtonBadgeComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(component: ButtonBadgeComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let height: CGFloat switch component.style { case .round: @@ -100,7 +100,7 @@ public final class ButtonBadgeComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -187,7 +187,7 @@ public final class ButtonTextContentComponent: Component { return super.hitTest(point, with: event) } - func update(component: ButtonTextContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ButtonTextContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousBadge = self.component?.badge self.component = component @@ -324,7 +324,7 @@ public final class ButtonTextContentComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -447,7 +447,7 @@ public final class ButtonComponent: Component { return super.hitTest(point, with: event) } - func update(component: ButtonComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ButtonComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.componentState = state @@ -546,7 +546,7 @@ public final class ButtonComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/Metal/CallScreenShaders.metal b/submodules/TelegramUI/Components/Calls/CallScreen/Metal/CallScreenShaders.metal index 1402203f29..c850eeada5 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/Metal/CallScreenShaders.metal +++ b/submodules/TelegramUI/Components/Calls/CallScreen/Metal/CallScreenShaders.metal @@ -230,10 +230,10 @@ vertex BlobVertexOut callBlobVertex( } fragment half4 callBlobFragment( - BlobVertexOut in [[stage_in]] + BlobVertexOut in [[stage_in]], + const device float4 &color [[ buffer(0) ]] ) { - half alpha = 0.35; - return half4(1.0 * alpha, 1.0 * alpha, 1.0 * alpha, alpha); + return half4(color.r * color.a, color.g * color.a, color.b * color.a, color.a); } kernel void videoBiPlanarToRGBA( diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/AvatarLayer.swift b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/AvatarLayer.swift index d08c25a5fc..0164a3f800 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/AvatarLayer.swift +++ b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/AvatarLayer.swift @@ -71,7 +71,7 @@ final class AvatarLayer: SimpleLayer { } } - func update(size: CGSize, isExpanded: Bool, cornerRadius: CGFloat, transition: Transition) { + func update(size: CGSize, isExpanded: Bool, cornerRadius: CGFloat, transition: ComponentTransition) { let params = Params(size: size, cornerRadius: cornerRadius, isExpanded: isExpanded) if self.params == params { return diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/ButtonGroupView.swift b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/ButtonGroupView.swift index 73c36b48ce..4c731b68f8 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/ButtonGroupView.swift +++ b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/ButtonGroupView.swift @@ -86,7 +86,7 @@ final class ButtonGroupView: OverlayMaskContainerView { return result } - func update(size: CGSize, insets: UIEdgeInsets, minWidth: CGFloat, controlsHidden: Bool, displayClose: Bool, strings: PresentationStrings, buttons: [Button], notices: [Notice], transition: Transition) -> CGFloat { + func update(size: CGSize, insets: UIEdgeInsets, minWidth: CGFloat, controlsHidden: Bool, displayClose: Bool, strings: PresentationStrings, buttons: [Button], notices: [Notice], transition: ComponentTransition) -> CGFloat { self.buttons = buttons let buttonSize: CGFloat = 56.0 @@ -284,7 +284,7 @@ final class ButtonGroupView: OverlayMaskContainerView { button.action() } - Transition.immediate.setScale(view: buttonView, scale: 0.001) + ComponentTransition.immediate.setScale(view: buttonView, scale: 0.001) buttonView.alpha = 0.0 transition.setScale(view: buttonView, scale: 1.0) } diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/CallBackgroundLayer.swift b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/CallBackgroundLayer.swift index 26ffbe4832..c1673251fd 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/CallBackgroundLayer.swift +++ b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/CallBackgroundLayer.swift @@ -170,7 +170,7 @@ final class CallBackgroundLayer: MetalEngineSubjectLayer, MetalEngineSubject { fatalError("init(coder:) has not been implemented") } - func update(stateIndex: Int, isEnergySavingEnabled: Bool, transition: Transition) { + func update(stateIndex: Int, isEnergySavingEnabled: Bool, transition: ComponentTransition) { self.isEnergySavingEnabled = isEnergySavingEnabled if self.stateIndex != stateIndex { diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/CallBlobsLayer.swift b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/CallBlobsLayer.swift index 337334e6b3..1fcba0be18 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/CallBlobsLayer.swift +++ b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/CallBlobsLayer.swift @@ -7,10 +7,13 @@ public final class CallBlobsLayer: MetalEngineSubjectLayer, MetalEngineSubject { public var internalData: MetalEngineSubjectInternalData? private struct Blob { + var color: SIMD4 var points: [Float] var nextPoints: [Float] - init(count: Int) { + init(count: Int, color: SIMD4) { + self.color = color + self.points = (0 ..< count).map { _ in Float.random(in: 0.0 ... 1.0) } @@ -71,7 +74,7 @@ public final class CallBlobsLayer: MetalEngineSubjectLayer, MetalEngineSubject { private var displayLinkSubscription: SharedDisplayLinkDriver.Link? - override public init() { + public init(colors: [UIColor] = [UIColor(white: 1.0, alpha: 0.35), UIColor(white: 1.0, alpha: 0.35)]) { super.init() self.didEnterHierarchy = { [weak self] in @@ -100,8 +103,14 @@ public final class CallBlobsLayer: MetalEngineSubjectLayer, MetalEngineSubject { } self.isOpaque = false - self.blobs = (0 ..< 2).map { _ in - Blob(count: 8) + self.blobs = colors.reversed().map { color in + var r: CGFloat = 0.0 + var g: CGFloat = 0.0 + var b: CGFloat = 0.0 + var a: CGFloat = 0.0 + color.getRed(&r, green: &g, blue: &b, alpha: &a) + + return Blob(count: 8, color: SIMD4(Float(r), Float(g), Float(b), Float(a))) } } @@ -137,6 +146,9 @@ public final class CallBlobsLayer: MetalEngineSubjectLayer, MetalEngineSubject { encoder.setVertexBytes(&points, length: MemoryLayout.size * points.count, index: 1) encoder.setVertexBytes(&count, length: MemoryLayout.size, index: 2) + var color = blobs[i].color + encoder.setFragmentBytes(&color, length: MemoryLayout.size * 4, index: 0) + encoder.drawPrimitives(type: .triangle, vertexStart: 0, vertexCount: 3 * 8 * points.count) } }) diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/CloseButtonView.swift b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/CloseButtonView.swift index 110814ead6..78212265b4 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/CloseButtonView.swift +++ b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/CloseButtonView.swift @@ -88,13 +88,13 @@ final class CloseButtonView: HighlightTrackingButton, OverlayMaskContainerViewPr if highlighted { self.layer.removeAnimation(forKey: "sublayerTransform") - let transition = Transition(animation: .curve(duration: 0.15, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.15, curve: .easeInOut)) transition.setScale(layer: self.layer, scale: topScale) } else { let t = self.layer.presentation()?.transform ?? layer.transform let currentScale = sqrt((t.m11 * t.m11) + (t.m12 * t.m12) + (t.m13 * t.m13)) - let transition = Transition(animation: .none) + let transition = ComponentTransition(animation: .none) transition.setScale(layer: self.layer, scale: 1.0) self.layer.animateScale(from: currentScale, to: maxScale, duration: 0.13, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, removeOnCompletion: false, completion: { [weak self] completed in @@ -149,7 +149,7 @@ final class CloseButtonView: HighlightTrackingButton, OverlayMaskContainerViewPr }) } - func update(text: String, size: CGSize, transition: Transition) { + func update(text: String, size: CGSize, transition: ComponentTransition) { let params = Params(text: text, size: size) if self.params == params { return @@ -158,7 +158,7 @@ final class CloseButtonView: HighlightTrackingButton, OverlayMaskContainerViewPr self.update(params: params, transition: transition) } - private func update(params: Params, transition: Transition) { + private func update(params: Params, transition: ComponentTransition) { let fillFraction: CGFloat = CGFloat(self.fillTime / self.duration) let sideInset: CGFloat = 12.0 diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/ContentOverlayButton.swift b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/ContentOverlayButton.swift index ac1ea32db8..2a0752f4de 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/ContentOverlayButton.swift +++ b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/ContentOverlayButton.swift @@ -66,13 +66,13 @@ final class ContentOverlayButton: HighlightTrackingButton, OverlayMaskContainerV if highlighted { self.layer.removeAnimation(forKey: "sublayerTransform") - let transition = Transition(animation: .curve(duration: 0.15, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.15, curve: .easeInOut)) transition.setScale(layer: self.layer, scale: topScale) } else { let t = self.layer.presentation()?.transform ?? layer.transform let currentScale = sqrt((t.m11 * t.m11) + (t.m12 * t.m12) + (t.m13 * t.m13)) - let transition = Transition(animation: .none) + let transition = ComponentTransition(animation: .none) transition.setScale(layer: self.layer, scale: 1.0) self.layer.animateScale(from: currentScale, to: maxScale, duration: 0.13, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, removeOnCompletion: false, completion: { [weak self] completed in @@ -95,7 +95,7 @@ final class ContentOverlayButton: HighlightTrackingButton, OverlayMaskContainerV self.action?() } - func update(size: CGSize, image: UIImage?, isSelected: Bool, isDestructive: Bool, isEnabled: Bool, title: String, transition: Transition) { + func update(size: CGSize, image: UIImage?, isSelected: Bool, isDestructive: Bool, isEnabled: Bool, title: String, transition: ComponentTransition) { let contentParams = ContentParams(size: size, image: image, isSelected: isSelected, isDestructive: isDestructive, isEnabled: isEnabled) if self.contentParams != contentParams { self.contentParams = contentParams @@ -110,7 +110,7 @@ final class ContentOverlayButton: HighlightTrackingButton, OverlayMaskContainerV self.textView.frame = CGRect(origin: CGPoint(x: floor((size.width - textSize.width) * 0.5), y: size.height + 4.0), size: textSize) } - private func updateContent(contentParams: ContentParams, transition: Transition) { + private func updateContent(contentParams: ContentParams, transition: ComponentTransition) { let image = generateImage(contentParams.size, rotatedContext: { size, context in context.clear(CGRect(origin: CGPoint(), size: size)) diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/EmojiExpandedInfoView.swift b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/EmojiExpandedInfoView.swift index f2b0ffd7ec..13b0d2346b 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/EmojiExpandedInfoView.swift +++ b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/EmojiExpandedInfoView.swift @@ -84,13 +84,13 @@ final class EmojiExpandedInfoView: OverlayMaskContainerView { if highlighted { self.actionButton.layer.removeAnimation(forKey: "sublayerTransform") - let transition = Transition(animation: .curve(duration: 0.15, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.15, curve: .easeInOut)) transition.setScale(layer: self.actionButton.layer, scale: topScale) } else { let t = self.actionButton.layer.presentation()?.transform ?? layer.transform let currentScale = sqrt((t.m11 * t.m11) + (t.m12 * t.m12) + (t.m13 * t.m13)) - let transition = Transition(animation: .none) + let transition = ComponentTransition(animation: .none) transition.setScale(layer: self.actionButton.layer, scale: 1.0) self.actionButton.layer.animateScale(from: currentScale, to: maxScale, duration: 0.13, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, removeOnCompletion: false, completion: { [weak self] completed in @@ -129,7 +129,7 @@ final class EmojiExpandedInfoView: OverlayMaskContainerView { return nil } - func update(width: CGFloat, transition: Transition) -> CGSize { + func update(width: CGFloat, transition: ComponentTransition) -> CGSize { let params = Params(width: width) if let currentLayout = self.currentLayout, currentLayout.params == params { return currentLayout.size @@ -139,7 +139,7 @@ final class EmojiExpandedInfoView: OverlayMaskContainerView { return size } - private func update(params: Params, transition: Transition) -> CGSize { + private func update(params: Params, transition: ComponentTransition) -> CGSize { let buttonHeight: CGFloat = 56.0 let titleSize = self.titleView.update(string: self.title, fontSize: 16.0, fontWeight: 0.3, alignment: .center, color: .white, constrainedWidth: params.width - 16.0 * 2.0, transition: transition) diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/KeyEmojiView.swift b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/KeyEmojiView.swift index 2e50530470..557c56a4d1 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/KeyEmojiView.swift +++ b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/KeyEmojiView.swift @@ -55,13 +55,13 @@ final class KeyEmojiView: HighlightTrackingButton { if highlighted { self.layer.removeAnimation(forKey: "opacity") self.layer.removeAnimation(forKey: "transform") - let transition = Transition(animation: .curve(duration: 0.15, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.15, curve: .easeInOut)) transition.setScale(layer: self.layer, scale: topScale) } else { let t = self.layer.presentation()?.transform ?? layer.transform let currentScale = sqrt((t.m11 * t.m11) + (t.m12 * t.m12) + (t.m13 * t.m13)) - let transition = Transition(animation: .none) + let transition = ComponentTransition(animation: .none) transition.setScale(layer: self.layer, scale: 1.0) self.layer.animateScale(from: currentScale, to: maxScale, duration: 0.13, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, removeOnCompletion: false, completion: { [weak self] completed in @@ -97,7 +97,7 @@ final class KeyEmojiView: HighlightTrackingButton { } } - func update(isExpanded: Bool, transition: Transition) -> CGSize { + func update(isExpanded: Bool, transition: ComponentTransition) -> CGSize { let params = Params(isExpanded: isExpanded) if let currentLayout = self.currentLayout, currentLayout.params == params { return currentLayout.size @@ -108,7 +108,7 @@ final class KeyEmojiView: HighlightTrackingButton { return size } - private func update(params: Params, transition: Transition) -> CGSize { + private func update(params: Params, transition: ComponentTransition) -> CGSize { let itemSpacing: CGFloat = 3.0 var height: CGFloat = 0.0 @@ -131,7 +131,7 @@ final class KeyEmojiView: HighlightTrackingButton { } } -func generateParabollicMotionKeyframes(from sourcePoint: CGPoint, to targetPosition: CGPoint, elevation: CGFloat, duration: Double, curve: Transition.Animation.Curve, reverse: Bool) -> [CGPoint] { +func generateParabollicMotionKeyframes(from sourcePoint: CGPoint, to targetPosition: CGPoint, elevation: CGFloat, duration: Double, curve: ComponentTransition.Animation.Curve, reverse: Bool) -> [CGPoint] { let midPoint = CGPoint(x: (sourcePoint.x + targetPosition.x) / 2.0, y: sourcePoint.y - elevation) let x1 = sourcePoint.x diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/NoticeView.swift b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/NoticeView.swift index d307040fac..1e8d7c0964 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/NoticeView.swift +++ b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/NoticeView.swift @@ -61,7 +61,7 @@ final class NoticeView: OverlayMaskContainerView { self.layer.animateScale(from: 1.0, to: 0.001, duration: 0.2, removeOnCompletion: false) } - func update(icon: String, text: String, constrainedWidth: CGFloat, transition: Transition) -> CGSize { + func update(icon: String, text: String, constrainedWidth: CGFloat, transition: ComponentTransition) -> CGSize { let sideInset: CGFloat = 12.0 let verticalInset: CGFloat = 6.0 let iconSpacing: CGFloat = -3.0 diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/PrivateCallPictureInPictureView.swift b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/PrivateCallPictureInPictureView.swift index b5a52fd67f..8973b2cc14 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/PrivateCallPictureInPictureView.swift +++ b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/PrivateCallPictureInPictureView.swift @@ -166,11 +166,11 @@ final class PrivateCallPictureInPictureView: UIView { let animationDuration = CATransaction.animationDuration() let timingFunction = CATransaction.animationTimingFunction() - let mappedTransition: Transition + let mappedTransition: ComponentTransition if self.sampleBufferView.bounds.isEmpty { mappedTransition = .immediate } else if animationDuration > 0.0 && !CATransaction.disableActions() { - let mappedCurve: Transition.Animation.Curve + let mappedCurve: ComponentTransition.Animation.Curve if let timingFunction { var controlPoint0: [Float] = [0.0, 0.0] var controlPoint1: [Float] = [0.0, 0.0] @@ -182,7 +182,7 @@ final class PrivateCallPictureInPictureView: UIView { } else { mappedCurve = .easeInOut } - mappedTransition = Transition(animation: .curve( + mappedTransition = ComponentTransition(animation: .curve( duration: animationDuration, curve: mappedCurve )) diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/RatingView.swift b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/RatingView.swift index 6b54934313..4443881a26 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/RatingView.swift +++ b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/RatingView.swift @@ -55,7 +55,7 @@ final class RatingView: OverlayMaskContainerView { self.layer.animateScale(from: 1.0, to: 0.001, duration: 0.2, removeOnCompletion: false) } - func update(text: String, constrainedWidth: CGFloat, transition: Transition) -> CGSize { + func update(text: String, constrainedWidth: CGFloat, transition: ComponentTransition) -> CGSize { let sideInset: CGFloat = 12.0 let verticalInset: CGFloat = 6.0 diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/RoundedCornersView.swift b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/RoundedCornersView.swift index af64a8b1a0..f6fe5c68c6 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/RoundedCornersView.swift +++ b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/RoundedCornersView.swift @@ -59,7 +59,7 @@ final class RoundedCornersView: UIImageView { self.layer.cornerRadius = 0.0 } - func update(cornerRadius: CGFloat, transition: Transition) { + func update(cornerRadius: CGFloat, transition: ComponentTransition) { if self.currentCornerRadius == cornerRadius { return } diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/StatusView.swift b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/StatusView.swift index 30f287c191..26569c3b61 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/StatusView.swift +++ b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/StatusView.swift @@ -257,7 +257,7 @@ final class StatusView: UIView { self.activeDurationTimer?.invalidate() } - func update(strings: PresentationStrings, state: State, transition: Transition) -> CGSize { + func update(strings: PresentationStrings, state: State, transition: ComponentTransition) -> CGSize { if let layoutState = self.layoutState, layoutState.strings === strings, layoutState.state == state { return layoutState.size } @@ -302,7 +302,7 @@ final class StatusView: UIView { } } - private func updateInternal(strings: PresentationStrings, state: State, transition: Transition) -> CGSize { + private func updateInternal(strings: PresentationStrings, state: State, transition: ComponentTransition) -> CGSize { let textString: String var needsDots = false var monospacedDigits = false diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/TitleView.swift b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/TitleView.swift index 59a938b578..9d94c24a1d 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/TitleView.swift +++ b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/TitleView.swift @@ -43,7 +43,7 @@ final class TextView: UIView { return super.action(for: layer, forKey: event) } - func update(string: String, fontSize: CGFloat, fontWeight: CGFloat, monospacedDigits: Bool = false, alignment: NSTextAlignment = .natural, color: UIColor, constrainedWidth: CGFloat, transition: Transition) -> CGSize { + func update(string: String, fontSize: CGFloat, fontWeight: CGFloat, monospacedDigits: Bool = false, alignment: NSTextAlignment = .natural, color: UIColor, constrainedWidth: CGFloat, transition: ComponentTransition) -> CGSize { let params = Params(string: string, fontSize: fontSize, fontWeight: fontWeight, monospacedDigits: monospacedDigits, alignment: alignment, constrainedWidth: constrainedWidth) if let layoutState = self.layoutState, layoutState.params == params { return layoutState.size diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/VideoContainerView.swift b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/VideoContainerView.swift index 4a55077b85..8a18633c71 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/VideoContainerView.swift +++ b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/VideoContainerView.swift @@ -50,7 +50,7 @@ private final class VideoContainerLayer: SimpleLayer { fatalError("init(coder:) has not been implemented") } - func update(size: CGSize, transition: Transition) { + func update(size: CGSize, transition: ComponentTransition) { transition.setFrame(layer: self.contentsLayer, frame: CGRect(origin: CGPoint(), size: size)) } } @@ -268,13 +268,13 @@ final class VideoContainerView: HighlightTrackingButton { if highlightedState { self.videoContainerLayer.removeAnimation(forKey: "sublayerTransform") - let transition = Transition(animation: .curve(duration: 0.15, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.15, curve: .easeInOut)) transition.setSublayerTransform(layer: self.videoContainerLayer, transform: CATransform3DMakeScale(topScale, topScale, 1.0)) } else { let t = self.videoContainerLayer.presentation()?.sublayerTransform ?? self.videoContainerLayer.sublayerTransform let currentScale = sqrt((t.m11 * t.m11) + (t.m12 * t.m12) + (t.m13 * t.m13)) - let transition = Transition(animation: .none) + let transition = ComponentTransition(animation: .none) transition.setSublayerTransform(layer: self.videoContainerLayer, transform: CATransform3DIdentity) self.videoContainerLayer.animateSublayerScale(from: currentScale, to: maxScale, duration: 0.13, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, removeOnCompletion: false, completion: { [weak self] completed in @@ -462,14 +462,14 @@ final class VideoContainerView: HighlightTrackingButton { self.dragPositionAnimatorLink = nil } - private func update(transition: Transition) { + private func update(transition: ComponentTransition) { guard let params = self.params else { return } self.update(previousParams: params, params: params, transition: transition) } - func update(size: CGSize, insets: UIEdgeInsets, interfaceOrientation: UIInterfaceOrientation, cornerRadius: CGFloat, controlsHidden: Bool, isMinimized: Bool, isAnimatedOut: Bool, transition: Transition) { + func update(size: CGSize, insets: UIEdgeInsets, interfaceOrientation: UIInterfaceOrientation, cornerRadius: CGFloat, controlsHidden: Bool, isMinimized: Bool, isAnimatedOut: Bool, transition: ComponentTransition) { let params = Params(size: size, insets: insets, interfaceOrientation: interfaceOrientation, cornerRadius: cornerRadius, controlsHidden: controlsHidden, isMinimized: isMinimized, isAnimatedOut: isAnimatedOut) if self.params == params { return @@ -548,7 +548,7 @@ final class VideoContainerView: HighlightTrackingButton { ) } - private func update(previousParams: Params?, params: Params, transition: Transition) { + private func update(previousParams: Params?, params: Params, transition: ComponentTransition) { guard let videoMetrics = self.videoMetrics else { return } @@ -613,7 +613,7 @@ final class VideoContainerView: HighlightTrackingButton { animateFlipDisappearingVideo = disappearingVideoLayer disappearingVideoLayer.videoLayer.blurredLayer.removeFromSuperlayer() } else { - let alphaTransition: Transition = .easeInOut(duration: 0.2) + let alphaTransition: ComponentTransition = .easeInOut(duration: 0.2) let disappearingVideoLayerValue = disappearingVideoLayer.videoLayer alphaTransition.setAlpha(layer: disappearingVideoLayerValue, alpha: 0.0, completion: { [weak self, weak disappearingVideoLayerValue] _ in guard let self, let disappearingVideoLayerValue else { @@ -758,7 +758,7 @@ final class VideoContainerView: HighlightTrackingButton { transition.setPosition(layer: disappearingVideoLayer.videoLayer, position: videoFrame.center) transition.setPosition(layer: disappearingVideoLayer.videoLayer.blurredLayer, position: videoFrame.center) - let alphaTransition: Transition = .easeInOut(duration: 0.2) + let alphaTransition: ComponentTransition = .easeInOut(duration: 0.2) let disappearingVideoLayerValue = disappearingVideoLayer.videoLayer alphaTransition.setAlpha(layer: disappearingVideoLayerValue, alpha: 0.0, completion: { [weak disappearingVideoLayerValue] _ in disappearingVideoLayerValue?.removeFromSuperlayer() diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/VideoShadowsView.swift b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/VideoShadowsView.swift index 11cec5dbdf..30d6f34de8 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/VideoShadowsView.swift +++ b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/VideoShadowsView.swift @@ -12,6 +12,6 @@ final class VideoShadowsView: UIView { fatalError("init(coder:) has not been implemented") } - func update(size: CGSize, transition: Transition) { + func update(size: CGSize, transition: ComponentTransition) { } } diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/PrivateCallScreen.swift b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/PrivateCallScreen.swift index 1ae4c05e38..28fcc277ad 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/PrivateCallScreen.swift +++ b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/PrivateCallScreen.swift @@ -470,7 +470,7 @@ public final class PrivateCallScreen: OverlayMaskContainerView, AVPictureInPictu } } - public func update(size: CGSize, insets: UIEdgeInsets, interfaceOrientation: UIInterfaceOrientation, screenCornerRadius: CGFloat, state: State, transition: Transition) { + public func update(size: CGSize, insets: UIEdgeInsets, interfaceOrientation: UIInterfaceOrientation, screenCornerRadius: CGFloat, state: State, transition: ComponentTransition) { let params = Params(size: size, insets: insets, interfaceOrientation: interfaceOrientation, screenCornerRadius: screenCornerRadius, state: state) if self.params == params { return @@ -576,20 +576,20 @@ public final class PrivateCallScreen: OverlayMaskContainerView, AVPictureInPictu self.updateInternal(params: params, transition: transition) } - private func update(transition: Transition) { + private func update(transition: ComponentTransition) { guard let params = self.params else { return } self.updateInternal(params: params, transition: transition) } - private func updateInternal(params: Params, transition: Transition) { + private func updateInternal(params: Params, transition: ComponentTransition) { self.isUpdating = true defer { self.isUpdating = false } - let genericAlphaTransition: Transition + let genericAlphaTransition: ComponentTransition switch transition.animation { case .none: genericAlphaTransition = .immediate @@ -780,7 +780,7 @@ public final class PrivateCallScreen: OverlayMaskContainerView, AVPictureInPictu if self.isEmojiKeyExpanded { let emojiExpandedInfoView: EmojiExpandedInfoView var emojiExpandedInfoTransition = transition - let alphaTransition: Transition + let alphaTransition: ComponentTransition if let current = self.emojiExpandedInfoView { emojiExpandedInfoView = current alphaTransition = genericAlphaTransition @@ -795,7 +795,7 @@ public final class PrivateCallScreen: OverlayMaskContainerView, AVPictureInPictu emojiExpandedInfoView = EmojiExpandedInfoView(title: params.state.strings.Call_EncryptedAlertTitle, text: params.state.strings.Call_EncryptedAlertText(params.state.shortName).string) self.emojiExpandedInfoView = emojiExpandedInfoView emojiExpandedInfoView.alpha = 0.0 - Transition.immediate.setScale(view: emojiExpandedInfoView, scale: 0.5) + ComponentTransition.immediate.setScale(view: emojiExpandedInfoView, scale: 0.5) emojiExpandedInfoView.layer.anchorPoint = CGPoint(x: 0.5, y: 0.1) if let emojiView = self.emojiView { self.insertSubview(emojiExpandedInfoView, belowSubview: emojiView) @@ -825,7 +825,7 @@ public final class PrivateCallScreen: OverlayMaskContainerView, AVPictureInPictu if let emojiExpandedInfoView = self.emojiExpandedInfoView { self.emojiExpandedInfoView = nil - let alphaTransition: Transition + let alphaTransition: ComponentTransition if !genericAlphaTransition.animation.isImmediate { alphaTransition = genericAlphaTransition.withAnimation(.curve(duration: 0.1, curve: .easeInOut)) } else { @@ -1038,8 +1038,8 @@ public final class PrivateCallScreen: OverlayMaskContainerView, AVPictureInPictu videoContainerView.blurredContainerLayer.bounds = self.avatarTransformLayer.bounds videoContainerView.blurredContainerLayer.opacity = 0.0 videoContainerView.update(size: self.avatarTransformLayer.bounds.size, insets: minimizedVideoInsets, interfaceOrientation: params.interfaceOrientation, cornerRadius: self.avatarLayer.params?.cornerRadius ?? 0.0, controlsHidden: currentAreControlsHidden, isMinimized: false, isAnimatedOut: true, transition: .immediate) - Transition.immediate.setScale(view: videoContainerView, scale: self.currentAvatarAudioScale) - Transition.immediate.setScale(view: self.videoContainerBackgroundView, scale: self.currentAvatarAudioScale) + ComponentTransition.immediate.setScale(view: videoContainerView, scale: self.currentAvatarAudioScale) + ComponentTransition.immediate.setScale(view: self.videoContainerBackgroundView, scale: self.currentAvatarAudioScale) } else { videoContainerView.layer.position = expandedVideoFrame.center videoContainerView.layer.bounds = CGRect(origin: CGPoint(), size: expandedVideoFrame.size) @@ -1059,7 +1059,7 @@ public final class PrivateCallScreen: OverlayMaskContainerView, AVPictureInPictu videoContainerTransition.setScale(layer: videoContainerView.blurredContainerLayer, scale: 1.0) videoContainerView.update(size: expandedVideoFrame.size, insets: minimizedVideoInsets, interfaceOrientation: params.interfaceOrientation, cornerRadius: params.screenCornerRadius, controlsHidden: currentAreControlsHidden, isMinimized: i != 0, isAnimatedOut: false, transition: videoContainerTransition) - let alphaTransition: Transition + let alphaTransition: ComponentTransition switch transition.animation { case .none: alphaTransition = .immediate @@ -1091,7 +1091,7 @@ public final class PrivateCallScreen: OverlayMaskContainerView, AVPictureInPictu removedVideoContainerIndices.append(i) if self.videoContainerViews.count == 1 || (i == 0 && !havePrimaryVideo) { - let alphaTransition: Transition = genericAlphaTransition + let alphaTransition: ComponentTransition = genericAlphaTransition videoContainerView.update(size: avatarFrame.size, insets: minimizedVideoInsets, interfaceOrientation: params.interfaceOrientation, cornerRadius: avatarCornerRadius, controlsHidden: currentAreControlsHidden, isMinimized: false, isAnimatedOut: true, transition: transition) transition.setPosition(layer: videoContainerView.blurredContainerLayer, position: avatarFrame.center) @@ -1284,7 +1284,7 @@ public final class PrivateCallScreen: OverlayMaskContainerView, AVPictureInPictu if !transition.animation.isImmediate { transition.setPosition(view: previousStatusView, position: CGPoint(x: previousStatusView.center.x, y: previousStatusView.center.y - 5.0)) transition.setScale(view: previousStatusView, scale: 0.5) - Transition.easeInOut(duration: 0.1).setAlpha(view: previousStatusView, alpha: 0.0, completion: { [weak previousStatusView] _ in + ComponentTransition.easeInOut(duration: 0.1).setAlpha(view: previousStatusView, alpha: 0.0, completion: { [weak previousStatusView] _ in previousStatusView?.removeFromSuperview() }) } else { @@ -1331,7 +1331,7 @@ public final class PrivateCallScreen: OverlayMaskContainerView, AVPictureInPictu if !transition.animation.isImmediate { transition.animatePosition(view: self.statusView, from: CGPoint(x: 0.0, y: 5.0), to: CGPoint(), additive: true) transition.animateScale(view: self.statusView, from: 0.5, to: 1.0) - Transition.easeInOut(duration: 0.15).animateAlpha(view: self.statusView, from: 0.0, to: 1.0) + ComponentTransition.easeInOut(duration: 0.15).animateAlpha(view: self.statusView, from: 0.0, to: 1.0) } } else { transition.setFrame(view: self.statusView, frame: statusFrame) @@ -1358,7 +1358,7 @@ public final class PrivateCallScreen: OverlayMaskContainerView, AVPictureInPictu if weakSignalView.bounds.isEmpty { weakSignalView.frame = weakSignalFrame if !transition.animation.isImmediate { - Transition.immediate.setScale(view: weakSignalView, scale: 0.001) + ComponentTransition.immediate.setScale(view: weakSignalView, scale: 0.001) weakSignalView.alpha = 0.0 transition.setScaleWithSpring(view: weakSignalView, scale: 1.0) transition.setAlpha(view: weakSignalView, alpha: 1.0) diff --git a/submodules/TelegramUI/Components/CameraButtonComponent/Sources/CameraButtonComponent.swift b/submodules/TelegramUI/Components/CameraButtonComponent/Sources/CameraButtonComponent.swift index 326dd92882..c7345f74f1 100644 --- a/submodules/TelegramUI/Components/CameraButtonComponent/Sources/CameraButtonComponent.swift +++ b/submodules/TelegramUI/Components/CameraButtonComponent/Sources/CameraButtonComponent.swift @@ -73,7 +73,7 @@ public final class CameraButton: Component { } } - private func updateScale(transition: Transition) { + private func updateScale(transition: ComponentTransition) { guard let component = self.component else { return } @@ -147,7 +147,7 @@ public final class CameraButton: Component { super.cancelTracking(with: event) } - func update(component: CameraButton, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: CameraButton, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { if let currentId = self.component?.content.id, currentId != component.content.id { let previousContentView = self.contentView @@ -200,7 +200,7 @@ public final class CameraButton: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/CameraScreen/Sources/CameraScreen.swift b/submodules/TelegramUI/Components/CameraScreen/Sources/CameraScreen.swift index 3051825902..55084110b9 100644 --- a/submodules/TelegramUI/Components/CameraScreen/Sources/CameraScreen.swift +++ b/submodules/TelegramUI/Components/CameraScreen/Sources/CameraScreen.swift @@ -2235,7 +2235,7 @@ public class CameraScreen: ViewController { self.cameraIsActive = false self.requestUpdateLayout(hasAppeared: self.hasAppeared, transition: .immediate) - let transition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut)) if let view = self.componentHost.findTaggedView(tag: cancelButtonTag) { view.layer.animateScale(from: 1.0, to: 0.1, duration: 0.2) transition.setAlpha(view: view, alpha: 0.0) @@ -2313,7 +2313,7 @@ public class CameraScreen: ViewController { self.cameraIsActive = true self.requestUpdateLayout(hasAppeared: self.hasAppeared, transition: .immediate) - let transition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut)) if let view = self.componentHost.findTaggedView(tag: cancelButtonTag) { view.layer.animateScale(from: 0.1, to: 1.0, duration: 0.2) transition.setAlpha(view: view, alpha: 1.0) @@ -2466,14 +2466,14 @@ public class CameraScreen: ViewController { return result } - func requestUpdateLayout(hasAppeared: Bool, transition: Transition) { + func requestUpdateLayout(hasAppeared: Bool, transition: ComponentTransition) { if let layout = self.validLayout { self.containerLayoutUpdated(layout: layout, forceUpdate: true, hasAppeared: hasAppeared, transition: transition) } } fileprivate var hasAppeared = false - func containerLayoutUpdated(layout: ContainerViewLayout, forceUpdate: Bool = false, hasAppeared: Bool = false, transition: Transition) { + func containerLayoutUpdated(layout: ContainerViewLayout, forceUpdate: Bool = false, hasAppeared: Bool = false, transition: ComponentTransition) { guard let controller = self.controller else { return } @@ -2808,7 +2808,7 @@ public class CameraScreen: ViewController { public var isEmbedded = false - fileprivate func updateCameraState(_ f: (CameraState) -> CameraState, transition: Transition) { + fileprivate func updateCameraState(_ f: (CameraState) -> CameraState, transition: ComponentTransition) { self.node.cameraState = f(self.node.cameraState) self.node.requestUpdateLayout(hasAppeared: self.node.hasAppeared, transition: transition) } @@ -3211,7 +3211,7 @@ public class CameraScreen: ViewController { super.containerLayoutUpdated(layout, transition: transition) if !self.isDismissed { - (self.displayNode as! Node).containerLayoutUpdated(layout: layout, transition: Transition(transition)) + (self.displayNode as! Node).containerLayoutUpdated(layout: layout, transition: ComponentTransition(transition)) } } } @@ -3284,7 +3284,7 @@ private final class DualIconComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: DualIconComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: DualIconComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -3302,7 +3302,7 @@ private final class DualIconComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/CameraScreen/Sources/CaptureControlsComponent.swift b/submodules/TelegramUI/Components/CameraScreen/Sources/CaptureControlsComponent.swift index fcd1b04b8d..eb5b47c728 100644 --- a/submodules/TelegramUI/Components/CameraScreen/Sources/CaptureControlsComponent.swift +++ b/submodules/TelegramUI/Components/CameraScreen/Sources/CaptureControlsComponent.swift @@ -35,8 +35,8 @@ private final class ShutterButtonContentComponent: Component { let shutterState: ShutterButtonState let blobState: ShutterBlobView.BlobState let highlightedAction: ActionSlot - let updateOffsetX: ActionSlot<(CGFloat, Transition)> - let updateOffsetY: ActionSlot<(CGFloat, Transition)> + let updateOffsetX: ActionSlot<(CGFloat, ComponentTransition)> + let updateOffsetY: ActionSlot<(CGFloat, ComponentTransition)> init( isTablet: Bool, @@ -45,8 +45,8 @@ private final class ShutterButtonContentComponent: Component { shutterState: ShutterButtonState, blobState: ShutterBlobView.BlobState, highlightedAction: ActionSlot, - updateOffsetX: ActionSlot<(CGFloat, Transition)>, - updateOffsetY: ActionSlot<(CGFloat, Transition)> + updateOffsetX: ActionSlot<(CGFloat, ComponentTransition)>, + updateOffsetY: ActionSlot<(CGFloat, ComponentTransition)> ) { self.isTablet = isTablet self.hasAppeared = hasAppeared @@ -106,11 +106,11 @@ private final class ShutterButtonContentComponent: Component { return } let scale: CGFloat = isHighlighted ? 0.8 : 1.0 - let transition = Transition(animation: .curve(duration: 0.3, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.3, curve: .easeInOut)) transition.setTransform(view: blobView, transform: CATransform3DMakeScale(scale, scale, 1.0)) } - func update(component: ShutterButtonContentComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: ShutterButtonContentComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { self.component = component if component.hasAppeared && self.blobView == nil { @@ -245,7 +245,7 @@ private final class ShutterButtonContentComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } @@ -325,7 +325,7 @@ final class FlipButtonContentComponent: Component { self.darkIcon.add(darkAnimation, forKey: "transform.rotation.z") } - func update(component: FlipButtonContentComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: FlipButtonContentComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { self.component = component component.action.connect { [weak self] _ in @@ -353,7 +353,7 @@ final class FlipButtonContentComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } @@ -404,7 +404,7 @@ final class LockContentComponent: Component { preconditionFailure() } - func update(component: LockContentComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: LockContentComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { self.component = component let size = CGSize(width: 30.0, height: 30.0) @@ -428,7 +428,7 @@ final class LockContentComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } @@ -599,8 +599,8 @@ final class CaptureControlsComponent: Component { private let leftGuide = SimpleLayer() private let rightGuide = SimpleLayer() - private let shutterUpdateOffsetX = ActionSlot<(CGFloat, Transition)>() - private let shutterUpdateOffsetY = ActionSlot<(CGFloat, Transition)>() + private let shutterUpdateOffsetX = ActionSlot<(CGFloat, ComponentTransition)>() + private let shutterUpdateOffsetY = ActionSlot<(CGFloat, ComponentTransition)>() private let shutterHightlightedAction = ActionSlot() @@ -697,13 +697,13 @@ final class CaptureControlsComponent: Component { private var shutterOffsetX: CGFloat = 0.0 private var shutterOffsetY: CGFloat = 0.0 - private func updateShutterOffsetX(_ offsetX: CGFloat, transition: Transition) { + private func updateShutterOffsetX(_ offsetX: CGFloat, transition: ComponentTransition) { self.shutterOffsetX = offsetX self.shutterUpdateOffsetX.invoke((offsetX, transition)) self.state?.updated(transition: transition) } - private func updateShutterOffsetY(_ offsetY: CGFloat, transition: Transition) { + private func updateShutterOffsetY(_ offsetY: CGFloat, transition: ComponentTransition) { self.shutterOffsetY = offsetY self.shutterUpdateOffsetY.invoke((offsetY, transition)) self.state?.updated(transition: transition) @@ -720,8 +720,8 @@ final class CaptureControlsComponent: Component { return bandingStart + (1.0 - (1.0 / ((bandedOffset * coefficient / range) + 1.0))) * range } - var scheduledXOffsetUpdate: (CGFloat, Transition)? - var scheduledYOffsetUpdate: (CGFloat, Transition)? + var scheduledXOffsetUpdate: (CGFloat, ComponentTransition)? + var scheduledYOffsetUpdate: (CGFloat, ComponentTransition)? let previousPanBlobState = self.panBlobState let location = gestureRecognizer.location(in: self) @@ -766,7 +766,7 @@ final class CaptureControlsComponent: Component { self.panBlobState = .video isBanding = true } - var transition: Transition = .immediate + var transition: ComponentTransition = .immediate if let wasBanding = self.wasBanding, wasBanding != isBanding { //self.hapticFeedback.impact(.light) transition = .spring(duration: 0.35) @@ -824,7 +824,7 @@ final class CaptureControlsComponent: Component { self.panBlobState = .video isBanding = true } - var transition: Transition = .immediate + var transition: ComponentTransition = .immediate if let wasBanding = self.wasBanding, wasBanding != isBanding { //self.hapticFeedback.impact(.light) transition = .spring(duration: 0.35) @@ -857,7 +857,7 @@ final class CaptureControlsComponent: Component { } private var animatedOut = false - func animateOutToEditor(transition: Transition) { + func animateOutToEditor(transition: ComponentTransition) { self.animatedOut = true if let view = self.galleryButtonView.view { @@ -876,7 +876,7 @@ final class CaptureControlsComponent: Component { } } - func animateInFromEditor(transition: Transition) { + func animateInFromEditor(transition: ComponentTransition) { self.animatedOut = false if let view = self.galleryButtonView.view { @@ -895,7 +895,7 @@ final class CaptureControlsComponent: Component { } } - func update(component: CaptureControlsComponent, state: State, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: CaptureControlsComponent, state: State, availableSize: CGSize, transition: ComponentTransition) -> CGSize { let previousShutterState = self.component?.shutterState ?? .generic self.component = component self.state = state @@ -1227,7 +1227,7 @@ final class CaptureControlsComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, state: state, availableSize: availableSize, transition: transition) } } diff --git a/submodules/TelegramUI/Components/CameraScreen/Sources/FlashTintControlComponent.swift b/submodules/TelegramUI/Components/CameraScreen/Sources/FlashTintControlComponent.swift index 55287c4c53..78c06465d2 100644 --- a/submodules/TelegramUI/Components/CameraScreen/Sources/FlashTintControlComponent.swift +++ b/submodules/TelegramUI/Components/CameraScreen/Sources/FlashTintControlComponent.swift @@ -80,7 +80,7 @@ private final class FlashColorComponent: Component { super.cancelTracking(with: event) } - func update(component: FlashColorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: FlashColorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let contentSize = CGSize(width: 30.0, height: 30.0) self.contentView.frame = CGRect(origin: .zero, size: contentSize) @@ -131,7 +131,7 @@ private final class FlashColorComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -208,7 +208,7 @@ final class FlashTintControlComponent: Component { self.component?.dismiss() } - func update(component: FlashTintControlComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: FlashTintControlComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let isFirstTime = self.component == nil self.component = component @@ -319,7 +319,7 @@ final class FlashTintControlComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -374,7 +374,7 @@ private final class SliderView: UIView { fatalError("init(coder:) has not been implemented") } - private func updateValue(transition: Transition = .immediate) { + private func updateValue(transition: ComponentTransition = .immediate) { let width = self.frame.width let range = self.maxValue - self.minValue diff --git a/submodules/TelegramUI/Components/CameraScreen/Sources/ModeComponent.swift b/submodules/TelegramUI/Components/CameraScreen/Sources/ModeComponent.swift index 001b3a2221..cd4a2a6104 100644 --- a/submodules/TelegramUI/Components/CameraScreen/Sources/ModeComponent.swift +++ b/submodules/TelegramUI/Components/CameraScreen/Sources/ModeComponent.swift @@ -128,21 +128,21 @@ final class ModeComponent: Component { } private var animatedOut = false - func animateOutToEditor(transition: Transition) { + func animateOutToEditor(transition: ComponentTransition) { self.animatedOut = true transition.setAlpha(view: self.containerView, alpha: 0.0) transition.setSublayerTransform(view: self.containerView, transform: CATransform3DMakeTranslation(0.0, -buttonSize.height, 0.0)) } - func animateInFromEditor(transition: Transition) { + func animateInFromEditor(transition: ComponentTransition) { self.animatedOut = false transition.setAlpha(view: self.containerView, alpha: 1.0) transition.setSublayerTransform(view: self.containerView, transform: CATransform3DIdentity) } - func update(component: ModeComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: ModeComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { self.component = component let isTablet = component.isTablet @@ -207,7 +207,7 @@ final class ModeComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } @@ -246,7 +246,7 @@ final class HintLabelComponent: Component { preconditionFailure() } - func update(component: HintLabelComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: HintLabelComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { let previousComponent = self.component self.component = component @@ -293,7 +293,7 @@ final class HintLabelComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/TelegramUI/Components/CameraScreen/Sources/PlaceholderComponent.swift b/submodules/TelegramUI/Components/CameraScreen/Sources/PlaceholderComponent.swift index bb9055cd3f..1fb49b88dc 100644 --- a/submodules/TelegramUI/Components/CameraScreen/Sources/PlaceholderComponent.swift +++ b/submodules/TelegramUI/Components/CameraScreen/Sources/PlaceholderComponent.swift @@ -61,7 +61,7 @@ final class PlaceholderComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: PlaceholderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: PlaceholderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -216,7 +216,7 @@ final class PlaceholderComponent: Component { return View() } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/CameraScreen/Sources/ShutterBlobView.swift b/submodules/TelegramUI/Components/CameraScreen/Sources/ShutterBlobView.swift index a72251da55..094fe890b5 100644 --- a/submodules/TelegramUI/Components/CameraScreen/Sources/ShutterBlobView.swift +++ b/submodules/TelegramUI/Components/CameraScreen/Sources/ShutterBlobView.swift @@ -8,11 +8,11 @@ import MetalImageView private final class PropertyAnimation { let from: T let to: T - let animation: Transition.Animation + let animation: ComponentTransition.Animation let startTimestamp: Double private let interpolator: (Interpolatable, Interpolatable, CGFloat) -> Interpolatable - init(fromValue: T, toValue: T, animation: Transition.Animation, startTimestamp: Double) { + init(fromValue: T, toValue: T, animation: ComponentTransition.Animation, startTimestamp: Double) { self.from = fromValue self.to = toValue self.animation = animation @@ -41,7 +41,7 @@ private final class AnimatableProperty { self.presentationValue = value } - func update(value: T, transition: Transition = .immediate) { + func update(value: T, transition: ComponentTransition = .immediate) { let currentTimestamp = CACurrentMediaTime() if case .none = transition.animation { if let animation = self.animation, case let .curve(duration, curve) = animation.animation { @@ -295,7 +295,7 @@ final class ShutterBlobView: UIView { self.displayLink?.invalidate() } - func updateState(_ state: BlobState, tintColor: UIColor, transition: Transition = .immediate) { + func updateState(_ state: BlobState, tintColor: UIColor, transition: ComponentTransition = .immediate) { guard self.state != state else { return } @@ -310,7 +310,7 @@ final class ShutterBlobView: UIView { self.tick() } - func updatePrimaryOffsetX(_ offset: CGFloat, transition: Transition = .immediate) { + func updatePrimaryOffsetX(_ offset: CGFloat, transition: ComponentTransition = .immediate) { guard self.frame.height > 0.0 else { return } @@ -320,7 +320,7 @@ final class ShutterBlobView: UIView { self.tick() } - func updatePrimaryOffsetY(_ offset: CGFloat, transition: Transition = .immediate) { + func updatePrimaryOffsetY(_ offset: CGFloat, transition: ComponentTransition = .immediate) { guard self.frame.height > 0.0 else { return } @@ -330,7 +330,7 @@ final class ShutterBlobView: UIView { self.tick() } - func updateSecondaryOffsetX(_ offset: CGFloat, transition: Transition = .immediate) { + func updateSecondaryOffsetX(_ offset: CGFloat, transition: ComponentTransition = .immediate) { guard self.frame.height > 0.0 else { return } @@ -340,7 +340,7 @@ final class ShutterBlobView: UIView { self.tick() } - func updateSecondaryOffsetY(_ offset: CGFloat, transition: Transition = .immediate) { + func updateSecondaryOffsetY(_ offset: CGFloat, transition: ComponentTransition = .immediate) { guard self.frame.height > 0.0 else { return } diff --git a/submodules/TelegramUI/Components/CameraScreen/Sources/ZoomComponent.swift b/submodules/TelegramUI/Components/CameraScreen/Sources/ZoomComponent.swift index a1499a7dc7..6c5b759e3b 100644 --- a/submodules/TelegramUI/Components/CameraScreen/Sources/ZoomComponent.swift +++ b/submodules/TelegramUI/Components/CameraScreen/Sources/ZoomComponent.swift @@ -113,7 +113,7 @@ final class ZoomComponent: Component { self.backgroundView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3) } - func update(component: ZoomComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: ZoomComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { self.component = component let sideInset: CGFloat = 3.0 @@ -166,7 +166,7 @@ final class ZoomComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Chat/ChatAvatarNavigationNode/Sources/ChatAvatarNavigationNode.swift b/submodules/TelegramUI/Components/Chat/ChatAvatarNavigationNode/Sources/ChatAvatarNavigationNode.swift index 66b4bfd8f7..1917457a40 100644 --- a/submodules/TelegramUI/Components/Chat/ChatAvatarNavigationNode/Sources/ChatAvatarNavigationNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatAvatarNavigationNode/Sources/ChatAvatarNavigationNode.swift @@ -210,7 +210,7 @@ public final class ChatAvatarNavigationNode: ASDisplayNode { } let _ = avatarStoryView.update( - transition: Transition(transition), + transition: ComponentTransition(transition), component: AnyComponent(AvatarStoryIndicatorComponent( hasUnseen: storyData.hasUnseen, hasUnseenCloseFriendsItems: storyData.hasUnseenCloseFriends, diff --git a/submodules/TelegramUI/Components/Chat/ChatEmptyNode/Sources/ChatEmptyNode.swift b/submodules/TelegramUI/Components/Chat/ChatEmptyNode/Sources/ChatEmptyNode.swift index ac62e628a6..d4388e4be2 100644 --- a/submodules/TelegramUI/Components/Chat/ChatEmptyNode/Sources/ChatEmptyNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatEmptyNode/Sources/ChatEmptyNode.swift @@ -904,12 +904,12 @@ private final class ChatEmptyNodeCloudChatContent: ASDisplayNode, ChatEmptyNodeC linkTextButton.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: linkTextButton.layer, scale: topScale) } } else { if animateScale { - let transition = Transition(animation: .none) + let transition = ComponentTransition(animation: .none) transition.setScale(layer: linkTextButton.layer, scale: 1.0) linkTextButton.layer.animateScale(from: topScale, to: maxScale, duration: 0.13, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, removeOnCompletion: false, completion: { [weak linkTextButton] _ in @@ -1469,12 +1469,12 @@ private final class EmptyAttachedDescriptionNode: HighlightTrackingButtonNode { 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 diff --git a/submodules/TelegramUI/Components/Chat/ChatInlineSearchResultsListComponent/Sources/ChatInlineSearchResultsListComponent.swift b/submodules/TelegramUI/Components/Chat/ChatInlineSearchResultsListComponent/Sources/ChatInlineSearchResultsListComponent.swift index aeac7b18fb..802c7ee155 100644 --- a/submodules/TelegramUI/Components/Chat/ChatInlineSearchResultsListComponent/Sources/ChatInlineSearchResultsListComponent.swift +++ b/submodules/TelegramUI/Components/Chat/ChatInlineSearchResultsListComponent/Sources/ChatInlineSearchResultsListComponent.swift @@ -303,7 +303,7 @@ public final class ChatInlineSearchResultsListComponent: Component { } } - func update(component: ChatInlineSearchResultsListComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ChatInlineSearchResultsListComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -871,7 +871,7 @@ public final class ChatInlineSearchResultsListComponent: Component { } } - let fadeTransition = Transition.easeInOut(duration: 0.25) + let fadeTransition = ComponentTransition.easeInOut(duration: 0.25) if component.showEmptyResults, let appliedContentsState = self.appliedContentsState, appliedContentsState.entries.isEmpty, case let .search(query, _) = component.contents, !query.isEmpty { let sideInset: CGFloat = 44.0 let emptyAnimationHeight = 148.0 @@ -984,7 +984,7 @@ public final class ChatInlineSearchResultsListComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveFileNode/Sources/ChatMessageInteractiveFileNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveFileNode/Sources/ChatMessageInteractiveFileNode.swift index 930e9591d5..57e01782a4 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveFileNode/Sources/ChatMessageInteractiveFileNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveFileNode/Sources/ChatMessageInteractiveFileNode.swift @@ -1262,7 +1262,7 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode { } let waveformView: ComponentHostView - let waveformTransition: Transition + let waveformTransition: ComponentTransition if let current = strongSelf.waveformView { waveformView = current switch animation.transition { diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageJoinedChannelBubbleContentNode/Sources/ChatMessageJoinedChannelBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageJoinedChannelBubbleContentNode/Sources/ChatMessageJoinedChannelBubbleContentNode.swift index fc3c136f6f..0455a1c4a5 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageJoinedChannelBubbleContentNode/Sources/ChatMessageJoinedChannelBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageJoinedChannelBubbleContentNode/Sources/ChatMessageJoinedChannelBubbleContentNode.swift @@ -660,10 +660,10 @@ private final class ChannelItemComponent: Component { if highlighted { self.contextContainer.layer.removeAnimation(forKey: "sublayerTransform") - let transition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut)) transition.setScale(layer: self.contextContainer.layer, scale: topScale) } else { - let transition = Transition(animation: .none) + let transition = ComponentTransition(animation: .none) transition.setScale(layer: self.contextContainer.layer, scale: 1.0) self.contextContainer.layer.animateScale(from: topScale, to: 1.0, duration: 0.2, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, removeOnCompletion: false) @@ -691,7 +691,7 @@ private final class ChannelItemComponent: Component { } } - func update(component: ChannelItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ChannelItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousComponent = self.component self.component = component self.state = state @@ -880,7 +880,7 @@ private final class ChannelItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -1024,7 +1024,7 @@ final class ChannelListPanelComponent: Component { } } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { guard let component = self.component, let itemLayout = self.itemLayout else { return } @@ -1123,7 +1123,7 @@ final class ChannelListPanelComponent: Component { } } - func update(component: ChannelListPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ChannelListPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let itemLayout = ItemLayout( @@ -1159,7 +1159,7 @@ final class ChannelListPanelComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Chat/ChatOverscrollControl/Sources/ChatOverscrollControl.swift b/submodules/TelegramUI/Components/Chat/ChatOverscrollControl/Sources/ChatOverscrollControl.swift index 629a1bcea3..031d172426 100644 --- a/submodules/TelegramUI/Components/Chat/ChatOverscrollControl/Sources/ChatOverscrollControl.swift +++ b/submodules/TelegramUI/Components/Chat/ChatOverscrollControl/Sources/ChatOverscrollControl.swift @@ -41,7 +41,7 @@ final class BlurredRoundedRectangle: Component { preconditionFailure() } - func update(component: BlurredRoundedRectangle, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: BlurredRoundedRectangle, availableSize: CGSize, transition: ComponentTransition) -> CGSize { transition.setFrame(view: self.background.view, frame: CGRect(origin: CGPoint(), size: availableSize)) self.background.updateColor(color: component.color, transition: .immediate) self.background.update(size: availableSize, cornerRadius: min(availableSize.width, availableSize.height) / 2.0, transition: .immediate) @@ -54,7 +54,7 @@ final class BlurredRoundedRectangle: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } @@ -96,7 +96,7 @@ final class RadialProgressComponent: Component { preconditionFailure() } - func update(component: RadialProgressComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: RadialProgressComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { func draw(context: CGContext) { let diameter = availableSize.width @@ -168,7 +168,7 @@ final class RadialProgressComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } @@ -277,7 +277,7 @@ final class CheckComponent: Component { } } - func update(component: CheckComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: CheckComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { if let currentValue = self.currentValue, currentValue != component.value, case .curve = transition.animation { self.animator?.invalidate() @@ -310,7 +310,7 @@ final class CheckComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } @@ -513,7 +513,7 @@ final class AvatarComponent: Component { preconditionFailure() } - func update(component: AvatarComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: AvatarComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { self.avatarContainer.frame = CGRect(origin: CGPoint(), size: availableSize) let theme = component.context.sharedContext.currentPresentationData.with({ $0 }).theme @@ -643,7 +643,7 @@ final class AvatarComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } @@ -729,7 +729,7 @@ private final class WallpaperBlurComponent: Component { preconditionFailure() } - func update(component: WallpaperBlurComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: WallpaperBlurComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { transition.setFrame(view: self.background.view, frame: CGRect(origin: CGPoint(), size: availableSize)) self.background.update(rect: component.rect, within: component.withinSize, color: component.color, wallpaperNode: component.wallpaperNode, transition: .immediate) @@ -741,7 +741,7 @@ private final class WallpaperBlurComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } @@ -900,7 +900,7 @@ final class OverscrollContentsComponent: Component { preconditionFailure() } - func update(component: OverscrollContentsComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: OverscrollContentsComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { if let _ = component.peer { self.avatarView.isHidden = false self.checkView.isHidden = true @@ -1034,7 +1034,7 @@ final class OverscrollContentsComponent: Component { let checkSize: CGFloat = 56.0 self.checkView.frame = CGRect(origin: CGPoint(x: floor(-checkSize / 2.0), y: floor(-checkSize / 2.0)), size: CGSize(width: checkSize, height: checkSize)) let _ = self.checkView.update( - transition: Transition(animation: transformTransition.isAnimated ? .curve(duration: 0.2, curve: .easeInOut) : .none), + transition: ComponentTransition(animation: transformTransition.isAnimated ? .curve(duration: 0.2, curve: .easeInOut) : .none), component: AnyComponent(CheckComponent( color: component.foregroundColor, lineWidth: 3.0, @@ -1046,7 +1046,7 @@ final class OverscrollContentsComponent: Component { if let peer = component.peer { let _ = self.avatarView.update( - transition: Transition(animation: transformTransition.isAnimated ? .curve(duration: 0.2, curve: .easeInOut) : .none), + transition: ComponentTransition(animation: transformTransition.isAnimated ? .curve(duration: 0.2, curve: .easeInOut) : .none), component: AnyComponent(AvatarComponent( context: component.context, peer: peer, @@ -1081,7 +1081,7 @@ final class OverscrollContentsComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Chat/ChatSendAudioMessageContextPreview/Sources/ChatSendAudioMessageContextPreview.swift b/submodules/TelegramUI/Components/Chat/ChatSendAudioMessageContextPreview/Sources/ChatSendAudioMessageContextPreview.swift index 9e280a161b..5e9888ffd8 100644 --- a/submodules/TelegramUI/Components/Chat/ChatSendAudioMessageContextPreview/Sources/ChatSendAudioMessageContextPreview.swift +++ b/submodules/TelegramUI/Components/Chat/ChatSendAudioMessageContextPreview/Sources/ChatSendAudioMessageContextPreview.swift @@ -67,21 +67,21 @@ public final class ChatSendContactMessageContextPreview: UIView, ChatSendMessage deinit { } - public func animateIn(transition: Transition) { + public func animateIn(transition: ComponentTransition) { transition.animateAlpha(view: self.messagesContainer, from: 0.0, to: 1.0) transition.animateScale(view: self.messagesContainer, from: 0.001, to: 1.0) } - public func animateOut(transition: Transition) { + public func animateOut(transition: ComponentTransition) { transition.setAlpha(view: self.messagesContainer, alpha: 0.0) transition.setScale(view: self.messagesContainer, scale: 0.001) } - public func animateOutOnSend(transition: Transition) { + public func animateOutOnSend(transition: ComponentTransition) { transition.setAlpha(view: self.messagesContainer, alpha: 0.0) } - public func update(containerSize: CGSize, transition: Transition) -> CGSize { + public func update(containerSize: CGSize, transition: ComponentTransition) -> CGSize { var contactsMedia: [TelegramMediaContact] = [] for peer in self.contactPeers { switch peer { @@ -241,21 +241,21 @@ public final class ChatSendAudioMessageContextPreview: UIView, ChatSendMessageCo deinit { } - public func animateIn(transition: Transition) { + public func animateIn(transition: ComponentTransition) { transition.animateAlpha(view: self.messagesContainer, from: 0.0, to: 1.0) transition.animateScale(view: self.messagesContainer, from: 0.001, to: 1.0) } - public func animateOut(transition: Transition) { + public func animateOut(transition: ComponentTransition) { transition.setAlpha(view: self.messagesContainer, alpha: 0.0) transition.setScale(view: self.messagesContainer, scale: 0.001) } - public func animateOutOnSend(transition: Transition) { + public func animateOutOnSend(transition: ComponentTransition) { transition.setAlpha(view: self.messagesContainer, alpha: 0.0) } - public func update(containerSize: CGSize, transition: Transition) -> CGSize { + public func update(containerSize: CGSize, transition: ComponentTransition) -> CGSize { let voiceAttributes: [TelegramMediaFileAttribute] = [.Audio(isVoice: true, duration: 23, title: nil, performer: nil, waveform: self.waveform.makeBitstream())] let voiceMedia = TelegramMediaFile(fileId: MediaId(namespace: 0, id: 0), partialReference: nil, resource: LocalFileMediaResource(fileId: 0), previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "audio/ogg", size: 0, attributes: voiceAttributes) @@ -375,21 +375,21 @@ public final class ChatSendGroupMediaMessageContextPreview: UIView, ChatSendMess deinit { } - public func animateIn(transition: Transition) { + public func animateIn(transition: ComponentTransition) { transition.animateAlpha(view: self.messagesContainer, from: 0.0, to: 1.0) transition.animateScale(view: self.messagesContainer, from: 0.001, to: 1.0) } - public func animateOut(transition: Transition) { + public func animateOut(transition: ComponentTransition) { transition.setAlpha(view: self.messagesContainer, alpha: 0.0) transition.setScale(view: self.messagesContainer, scale: 0.001) } - public func animateOutOnSend(transition: Transition) { + public func animateOutOnSend(transition: ComponentTransition) { transition.setAlpha(view: self.messagesContainer, alpha: 0.0) } - public func update(containerSize: CGSize, transition: Transition) -> CGSize { + public func update(containerSize: CGSize, transition: ComponentTransition) -> CGSize { let presentationData = self.context.sharedContext.currentPresentationData.with { $0 } let chatPresentationData: ChatPresentationData diff --git a/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift b/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift index 56612ab51f..8bd90fd45c 100644 --- a/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift +++ b/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift @@ -419,7 +419,7 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode { private var currentState: (width: CGFloat, leftInset: CGFloat, rightInset: CGFloat, bottomInset: CGFloat, standardInputHeight: CGFloat, inputHeight: CGFloat, maximumHeight: CGFloat, inputPanelHeight: CGFloat, interfaceState: ChatPresentationInterfaceState, layoutMetrics: LayoutMetrics, deviceMetrics: DeviceMetrics, isVisible: Bool, isExpanded: Bool)? private var scheduledContentAnimationHint: EmojiPagerContentComponent.ContentAnimation? - private var scheduledInnerTransition: Transition? + private var scheduledInnerTransition: ComponentTransition? private var gifMode: GifPagerContentComponent.Subject? { didSet { @@ -1586,7 +1586,7 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode { } } - var transition: Transition = .immediate + var transition: ComponentTransition = .immediate var useAnimation = false if let pagerView = strongSelf.entityKeyboardView.componentView as? EntityKeyboardComponent.View, let centralId = pagerView.centralId { @@ -1605,7 +1605,7 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode { } else { contentAnimation = EmojiPagerContentComponent.ContentAnimation(type: .generic) } - transition = Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(contentAnimation) + transition = ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(contentAnimation) } strongSelf.currentInputData = strongSelf.processInputData(inputData: inputData) strongSelf.performLayout(transition: transition) @@ -1741,7 +1741,7 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode { self.isMarkInputCollapsed = true } - private func performLayout(transition: Transition) { + private func performLayout(transition: ComponentTransition) { guard let (width, leftInset, rightInset, bottomInset, standardInputHeight, inputHeight, maximumHeight, inputPanelHeight, interfaceState, layoutMetrics, deviceMetrics, isVisible, isExpanded) = self.currentState else { return } @@ -1759,12 +1759,12 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode { public override func updateLayout(width: CGFloat, leftInset: CGFloat, rightInset: CGFloat, bottomInset: CGFloat, standardInputHeight: CGFloat, inputHeight: CGFloat, maximumHeight: CGFloat, inputPanelHeight: CGFloat, transition: ContainedViewLayoutTransition, interfaceState: ChatPresentationInterfaceState, layoutMetrics: LayoutMetrics, deviceMetrics: DeviceMetrics, isVisible: Bool, isExpanded: Bool) -> (CGFloat, CGFloat) { self.currentState = (width, leftInset, rightInset, bottomInset, standardInputHeight, inputHeight, maximumHeight, inputPanelHeight, interfaceState, layoutMetrics, deviceMetrics, isVisible, isExpanded) - let innerTransition: Transition + let innerTransition: ComponentTransition if let scheduledInnerTransition = self.scheduledInnerTransition { self.scheduledInnerTransition = nil innerTransition = scheduledInnerTransition } else { - innerTransition = Transition(transition) + innerTransition = ComponentTransition(transition) } let wasMarkedInputCollapsed = self.isMarkInputCollapsed @@ -2093,7 +2093,7 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode { guard let strongSelf = self else { return } - strongSelf.performLayout(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + strongSelf.performLayout(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) }) if self.context.sharedContext.currentStickerSettings.with({ $0 }).dynamicPackOrder { diff --git a/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/ActionListItemComponent.swift b/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/ActionListItemComponent.swift index 9e4fa31343..76319deaf6 100644 --- a/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/ActionListItemComponent.swift +++ b/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/ActionListItemComponent.swift @@ -118,7 +118,7 @@ final class ActionListItemComponent: Component { component.action() } - func update(component: ActionListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ActionListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme if self.component?.iconName != component.iconName { @@ -190,7 +190,7 @@ final class ActionListItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/ChatFolderLinkHeaderComponent.swift b/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/ChatFolderLinkHeaderComponent.swift index b58d9105de..68da9ab767 100644 --- a/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/ChatFolderLinkHeaderComponent.swift +++ b/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/ChatFolderLinkHeaderComponent.swift @@ -45,7 +45,7 @@ final class BadgeComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: BadgeComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BadgeComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let height: CGFloat = 20.0 let contentInset: CGFloat = 10.0 @@ -77,7 +77,7 @@ final class BadgeComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -141,7 +141,7 @@ final class ChatFolderLinkHeaderComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: ChatFolderLinkHeaderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ChatFolderLinkHeaderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme self.component = component @@ -317,7 +317,7 @@ final class ChatFolderLinkHeaderComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/ChatFolderLinkPreviewScreen.swift b/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/ChatFolderLinkPreviewScreen.swift index 976c1e491b..6567f48f58 100644 --- a/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/ChatFolderLinkPreviewScreen.swift +++ b/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/ChatFolderLinkPreviewScreen.swift @@ -248,7 +248,7 @@ private final class ChatFolderLinkPreviewScreenComponent: Component { } } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { guard let environment = self.environment, let controller = environment.controller(), let itemLayout = self.itemLayout else { return } @@ -312,7 +312,7 @@ private final class ChatFolderLinkPreviewScreenComponent: Component { } } - func update(component: ChatFolderLinkPreviewScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ChatFolderLinkPreviewScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let animationHint = transition.userData(AnimationHint.self) var contentTransition = transition @@ -623,7 +623,7 @@ private final class ChatFolderLinkPreviewScreenComponent: Component { if let self, let component = self.component { self.linkListItems.removeAll(where: { $0.link == link.link }) - self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .easeInOut))) let context = component.context let _ = (context.engine.peers.editChatFolderLink(filterId: folderId, link: link, title: nil, peerIds: nil, revoke: true) @@ -728,7 +728,7 @@ private final class ChatFolderLinkPreviewScreenComponent: Component { } else { self.selectedItems.insert(peer.id) } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .easeInOut))) } else if linkContents.alreadyMemberPeerIds.contains(peer.id) { let presentationData = component.context.sharedContext.currentPresentationData.with { $0 } let text: String @@ -744,7 +744,7 @@ private final class ChatFolderLinkPreviewScreenComponent: Component { } else { self.selectedItems.insert(peer.id) } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .easeInOut))) } } )), @@ -886,7 +886,7 @@ private final class ChatFolderLinkPreviewScreenComponent: Component { self.selectedItems.insert(peerId) } } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .easeInOut))) } )), environment: {}, @@ -1371,7 +1371,7 @@ private final class ChatFolderLinkPreviewScreenComponent: Component { } self.linkListItems.insert(link, at: 0) - self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .easeInOut))) let navigationController = controller.navigationController controller.push(folderInviteLinkListController(context: component.context, filterId: folderId, title: title, allPeerIds: peers.map(\.id), currentInvitation: link, linkUpdated: { [weak self] updatedLink in @@ -1389,7 +1389,7 @@ private final class ChatFolderLinkPreviewScreenComponent: Component { self.linkListItems.insert(updatedLink, at: 0) } } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .easeInOut))) }, presentController: { [weak navigationController] c in (navigationController?.topViewController as? ViewController)?.present(c, in: .window(.root)) })) @@ -1471,7 +1471,7 @@ private final class ChatFolderLinkPreviewScreenComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/LinkListItemComponent.swift b/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/LinkListItemComponent.swift index ae5ece266c..ceafa4284c 100644 --- a/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/LinkListItemComponent.swift +++ b/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/LinkListItemComponent.swift @@ -139,11 +139,11 @@ final class LinkListItemComponent: Component { } self.isExtractedToContextMenu = value - let mappedTransition: Transition + let mappedTransition: ComponentTransition if value { - mappedTransition = Transition(transition) + mappedTransition = ComponentTransition(transition) } else { - mappedTransition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut)) + mappedTransition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut)) } self.state?.updated(transition: mappedTransition) } @@ -198,7 +198,7 @@ final class LinkListItemComponent: Component { component.action(component.link) } - func update(component: LinkListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: LinkListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme self.component = component @@ -323,7 +323,7 @@ final class LinkListItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/PeerListItemComponent.swift b/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/PeerListItemComponent.swift index 10f12a5634..79c65a9ef1 100644 --- a/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/PeerListItemComponent.swift +++ b/submodules/TelegramUI/Components/ChatFolderLinkPreviewScreen/Sources/PeerListItemComponent.swift @@ -127,7 +127,7 @@ final class PeerListItemComponent: Component { component.action(peer) } - func update(component: PeerListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: PeerListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme var hasSelectionUpdated = false @@ -306,7 +306,7 @@ final class PeerListItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ChatListHeaderComponent/Sources/ChatListHeaderComponent.swift b/submodules/TelegramUI/Components/ChatListHeaderComponent/Sources/ChatListHeaderComponent.swift index c030552d5e..732557021e 100644 --- a/submodules/TelegramUI/Components/ChatListHeaderComponent/Sources/ChatListHeaderComponent.swift +++ b/submodules/TelegramUI/Components/ChatListHeaderComponent/Sources/ChatListHeaderComponent.swift @@ -55,7 +55,7 @@ public final class HeaderNetworkStatusComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: HeaderNetworkStatusComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: HeaderNetworkStatusComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.state = state return availableSize @@ -66,7 +66,7 @@ public final class HeaderNetworkStatusComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -266,7 +266,7 @@ public final class ChatListHeaderComponent: Component { self.onPressed() } - func update(title: String, theme: PresentationTheme, availableSize: CGSize, transition: Transition) -> CGSize { + func update(title: String, theme: PresentationTheme, availableSize: CGSize, transition: ComponentTransition) -> CGSize { let titleText = NSAttributedString(string: title, font: Font.regular(17.0), textColor: theme.rootController.navigationBar.accentTextColor) let titleTextUpdated = self.titleView.attributedText != titleText self.titleView.attributedText = titleText @@ -380,7 +380,7 @@ public final class ChatListHeaderComponent: Component { return nil } - func updateContentOffsetFraction(contentOffsetFraction: CGFloat, transition: Transition) { + func updateContentOffsetFraction(contentOffsetFraction: CGFloat, transition: ComponentTransition) { if self.contentOffsetFraction == contentOffsetFraction { return } @@ -393,7 +393,7 @@ public final class ChatListHeaderComponent: Component { transition.setSublayerTransform(view: self.titleOffsetContainer, transform: transform) } - func updateNavigationTransitionAsPrevious(nextView: ContentView, fraction: CGFloat, transition: Transition, completion: @escaping () -> Void) { + func updateNavigationTransitionAsPrevious(nextView: ContentView, fraction: CGFloat, transition: ComponentTransition, completion: @escaping () -> Void) { transition.setBounds(view: self.leftButtonOffsetContainer, bounds: CGRect(origin: CGPoint(x: fraction * self.bounds.width * 0.5, y: 0.0), size: self.leftButtonOffsetContainer.bounds.size), completion: { _ in completion() }) @@ -417,7 +417,7 @@ public final class ChatListHeaderComponent: Component { } } - func updateNavigationTransitionAsNext(previousView: ContentView, storyPeerListView: StoryPeerListComponent.View?, fraction: CGFloat, transition: Transition, completion: @escaping () -> Void) { + func updateNavigationTransitionAsNext(previousView: ContentView, storyPeerListView: StoryPeerListComponent.View?, fraction: CGFloat, transition: ComponentTransition, completion: @escaping () -> Void) { transition.setBounds(view: self.titleOffsetContainer, bounds: CGRect(origin: CGPoint(x: -(1.0 - fraction) * self.bounds.width, y: 0.0), size: self.titleOffsetContainer.bounds.size), completion: { _ in completion() }) @@ -447,7 +447,7 @@ public final class ChatListHeaderComponent: Component { } } - func updateNavigationTransitionAsPreviousInplace(nextView: ContentView, fraction: CGFloat, transition: Transition, completion: @escaping () -> Void) { + func updateNavigationTransitionAsPreviousInplace(nextView: ContentView, fraction: CGFloat, transition: ComponentTransition, completion: @escaping () -> Void) { transition.setBounds(view: self.leftButtonOffsetContainer, bounds: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: self.leftButtonOffsetContainer.bounds.size), completion: { _ in }) transition.setAlpha(view: self.leftButtonOffsetContainer, alpha: pow(1.0 - fraction, 2.0)) @@ -464,7 +464,7 @@ public final class ChatListHeaderComponent: Component { transition.setAlpha(view: self.titleOffsetContainer, alpha: pow(1.0 - fraction, 2.0)) } - func updateNavigationTransitionAsNextInplace(previousView: ContentView, fraction: CGFloat, transition: Transition, completion: @escaping () -> Void) { + func updateNavigationTransitionAsNextInplace(previousView: ContentView, fraction: CGFloat, transition: ComponentTransition, completion: @escaping () -> Void) { transition.setBounds(view: self.titleOffsetContainer, bounds: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: self.titleOffsetContainer.bounds.size), completion: { _ in completion() }) @@ -479,7 +479,7 @@ public final class ChatListHeaderComponent: Component { } } - func update(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, content: Content, backTitle: String?, sideInset: CGFloat, sideContentWidth: CGFloat, sideContentFraction: CGFloat, size: CGSize, transition: Transition) { + func update(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, content: Content, backTitle: String?, sideInset: CGFloat, sideContentWidth: CGFloat, sideContentFraction: CGFloat, size: CGSize, transition: ComponentTransition) { transition.setPosition(view: self.titleOffsetContainer, position: CGPoint(x: size.width * 0.5, y: size.height * 0.5)) transition.setBounds(view: self.titleOffsetContainer, bounds: CGRect(origin: self.titleOffsetContainer.bounds.origin, size: size)) @@ -838,10 +838,10 @@ public final class ChatListHeaderComponent: Component { return defaultResult } - private func updateContentStoryOffsets(transition: Transition) { + private func updateContentStoryOffsets(transition: ComponentTransition) { } - func update(component: ChatListHeaderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ChatListHeaderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.state = state let previousComponent = self.component @@ -1108,7 +1108,7 @@ public final class ChatListHeaderComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -1206,7 +1206,7 @@ public final class NavigationButtonComponent: Component { self.component?.pressed(self) } - func update(component: NavigationButtonComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: NavigationButtonComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let theme = environment[NavigationButtonComponentEnvironment.self].value.theme @@ -1356,7 +1356,7 @@ public final class NavigationButtonComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ChatListHeaderComponent/Sources/ChatListNavigationBar.swift b/submodules/TelegramUI/Components/ChatListHeaderComponent/Sources/ChatListNavigationBar.swift index d59b4fe772..549c6fb4fd 100644 --- a/submodules/TelegramUI/Components/ChatListHeaderComponent/Sources/ChatListNavigationBar.swift +++ b/submodules/TelegramUI/Components/ChatListHeaderComponent/Sources/ChatListNavigationBar.swift @@ -219,13 +219,13 @@ public final class ChatListNavigationBar: Component { return result } - public func applyCurrentScroll(transition: Transition) { + public func applyCurrentScroll(transition: ComponentTransition) { if let rawScrollOffset = self.rawScrollOffset, self.hasDeferredScrollOffset { self.applyScroll(offset: rawScrollOffset, allowAvatarsExpansion: self.currentAllowAvatarsExpansion, transition: transition) } } - public func applyScroll(offset: CGFloat, allowAvatarsExpansion: Bool, forceUpdate: Bool = false, transition: Transition) { + public func applyScroll(offset: CGFloat, allowAvatarsExpansion: Bool, forceUpdate: Bool = false, transition: ComponentTransition) { let transition = transition self.rawScrollOffset = offset @@ -574,7 +574,7 @@ public final class ChatListNavigationBar: Component { } } - func update(component: ChatListNavigationBar, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ChatListNavigationBar, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme var uploadProgressUpdated = false @@ -638,7 +638,7 @@ public final class ChatListNavigationBar: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ChatListTitleView/Sources/ChatListTitleView.swift b/submodules/TelegramUI/Components/ChatListTitleView/Sources/ChatListTitleView.swift index d12b91bf48..7c8a20b0b8 100644 --- a/submodules/TelegramUI/Components/ChatListTitleView/Sources/ChatListTitleView.swift +++ b/submodules/TelegramUI/Components/ChatListTitleView/Sources/ChatListTitleView.swift @@ -141,9 +141,9 @@ public final class ChatListTitleView: UIView, NavigationBarTitleView, Navigation statusContent = .animation(content: .customEmoji(fileId: emoji.fileId), size: CGSize(width: 22.0, height: 22.0), placeholderColor: self.theme.list.mediaPlaceholderColor, themeColor: self.theme.list.itemAccentColor, loopMode: .count(2)) } - var titleCredibilityIconTransition: Transition + var titleCredibilityIconTransition: ComponentTransition if animateStatusTransition { - titleCredibilityIconTransition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut)) + titleCredibilityIconTransition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut)) } else { titleCredibilityIconTransition = .immediate } @@ -383,7 +383,7 @@ public final class ChatListTitleView: UIView, NavigationBarTitleView, Navigation statusContent = .animation(content: .customEmoji(fileId: emoji.fileId), size: CGSize(width: 22.0, height: 22.0), placeholderColor: self.theme.list.mediaPlaceholderColor, themeColor: self.theme.list.itemAccentColor, loopMode: .count(2)) } - var titleCredibilityIconTransition = Transition(transition) + var titleCredibilityIconTransition = ComponentTransition(transition) let titleCredibilityIconView: ComponentHostView if let current = self.titleCredibilityIconView { titleCredibilityIconView = current diff --git a/submodules/TelegramUI/Components/ChatTitleView/Sources/ChatTitleView.swift b/submodules/TelegramUI/Components/ChatTitleView/Sources/ChatTitleView.swift index 05a06fd996..d8474a2073 100644 --- a/submodules/TelegramUI/Components/ChatTitleView/Sources/ChatTitleView.swift +++ b/submodules/TelegramUI/Components/ChatTitleView/Sources/ChatTitleView.swift @@ -1108,7 +1108,7 @@ public final class ChatTitleComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: ChatTitleComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ChatTitleComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let contentView: ChatTitleView @@ -1157,7 +1157,7 @@ public final class ChatTitleComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ContextReferenceButtonComponent/Sources/ContextReferenceButtonComponent.swift b/submodules/TelegramUI/Components/ContextReferenceButtonComponent/Sources/ContextReferenceButtonComponent.swift index 08c88c2379..f7bb1bd344 100644 --- a/submodules/TelegramUI/Components/ContextReferenceButtonComponent/Sources/ContextReferenceButtonComponent.swift +++ b/submodules/TelegramUI/Components/ContextReferenceButtonComponent/Sources/ContextReferenceButtonComponent.swift @@ -82,7 +82,7 @@ public final class ContextReferenceButtonComponent: Component { self.component?.action(self, nil) } - public func update(component: ContextReferenceButtonComponent, availableSize: CGSize, transition: Transition) -> CGSize { + public func update(component: ContextReferenceButtonComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { self.component = component let componentSize = self.componentView.update( @@ -118,7 +118,7 @@ public final class ContextReferenceButtonComponent: Component { return View() } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/TelegramUI/Components/DynamicCornerRadiusView/Sources/DynamicCornerRadiusView.swift b/submodules/TelegramUI/Components/DynamicCornerRadiusView/Sources/DynamicCornerRadiusView.swift index 531a3bb4a8..3227496f7d 100644 --- a/submodules/TelegramUI/Components/DynamicCornerRadiusView/Sources/DynamicCornerRadiusView.swift +++ b/submodules/TelegramUI/Components/DynamicCornerRadiusView/Sources/DynamicCornerRadiusView.swift @@ -67,7 +67,7 @@ open class DynamicCornerRadiusView: UIView { fatalError("init(coder:) has not been implemented") } - public func update(size: CGSize, corners: Corners, transition: Transition) { + public func update(size: CGSize, corners: Corners, transition: ComponentTransition) { let params = Params(size: size, corners: corners) if self.params == params { return @@ -76,13 +76,13 @@ open class DynamicCornerRadiusView: UIView { self.update(params: params, transition: transition) } - public func updateColor(color: UIColor, transition: Transition) { + public func updateColor(color: UIColor, transition: ComponentTransition) { if let shapeLayer = self.layer as? CAShapeLayer { transition.setShapeLayerFillColor(layer: shapeLayer, color: color) } } - private func update(params: Params, transition: Transition) { + private func update(params: Params, transition: ComponentTransition) { if let shapeLayer = self.layer as? CAShapeLayer { transition.setShapeLayerPath(layer: shapeLayer, path: generatePath(size: params.size, corners: params.corners)) } diff --git a/submodules/TelegramUI/Components/EmojiActionIconComponent/Sources/EmojiActionIconComponent.swift b/submodules/TelegramUI/Components/EmojiActionIconComponent/Sources/EmojiActionIconComponent.swift index 6bee0832ad..e0194d4178 100644 --- a/submodules/TelegramUI/Components/EmojiActionIconComponent/Sources/EmojiActionIconComponent.swift +++ b/submodules/TelegramUI/Components/EmojiActionIconComponent/Sources/EmojiActionIconComponent.swift @@ -43,7 +43,7 @@ public final class EmojiActionIconComponent: Component { public final class View: UIView { private var icon: ComponentView? - func update(component: EmojiActionIconComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EmojiActionIconComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let size = CGSize(width: 24.0, height: 24.0) var iconSize = size @@ -109,7 +109,7 @@ public final class EmojiActionIconComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/EmojiStatusComponent/Sources/EmojiStatusComponent.swift b/submodules/TelegramUI/Components/EmojiStatusComponent/Sources/EmojiStatusComponent.swift index 158931012b..b8a2912289 100644 --- a/submodules/TelegramUI/Components/EmojiStatusComponent/Sources/EmojiStatusComponent.swift +++ b/submodules/TelegramUI/Components/EmojiStatusComponent/Sources/EmojiStatusComponent.swift @@ -239,7 +239,7 @@ public final class EmojiStatusComponent: Component { } } - func update(component: EmojiStatusComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EmojiStatusComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let availableSize = component.size ?? availableSize self.state = state @@ -645,7 +645,7 @@ public final class EmojiStatusComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/EmojiStatusSelectionComponent/Sources/EmojiStatusPreviewScreen.swift b/submodules/TelegramUI/Components/EmojiStatusSelectionComponent/Sources/EmojiStatusPreviewScreen.swift index c9d0fcd28f..48e767cecf 100644 --- a/submodules/TelegramUI/Components/EmojiStatusSelectionComponent/Sources/EmojiStatusPreviewScreen.swift +++ b/submodules/TelegramUI/Components/EmojiStatusSelectionComponent/Sources/EmojiStatusPreviewScreen.swift @@ -57,7 +57,7 @@ private final class ContextMenuActionItem: Component, ContextMenuItemWithAction fatalError("init(coder:) has not been implemented") } - func update(component: ContextMenuActionItem, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ContextMenuActionItem, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let contextEnvironment = environment[EnvironmentType.self].value let sideInset: CGFloat = 16.0 @@ -87,7 +87,7 @@ private final class ContextMenuActionItem: Component, ContextMenuItemWithAction return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -263,14 +263,14 @@ private final class ContextMenuActionsComponent: Component { return self } - func update(component: ContextMenuActionsComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ContextMenuActionsComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let availableItemSize = availableSize var itemsSize = CGSize() var validIds = Set() - var currentItems: [(id: AnyHashable, itemFrame: CGRect, itemTransition: Transition)] = [] + var currentItems: [(id: AnyHashable, itemFrame: CGRect, itemTransition: ComponentTransition)] = [] for i in 0 ..< component.items.count { let item = component.items[i] validIds.insert(item.id) @@ -339,7 +339,7 @@ private final class ContextMenuActionsComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -419,7 +419,7 @@ private final class TimeSelectionControlComponent: Component { @objc private func datePickerUpdated() { } - func update(component: TimeSelectionControlComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: TimeSelectionControlComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { if self.component?.theme !== component.theme { UILabel.setDateLabel(component.theme.list.itemPrimaryTextColor) @@ -521,7 +521,7 @@ private final class TimeSelectionControlComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -629,14 +629,14 @@ final class EmojiStatusPreviewScreenComponent: Component { switch self.currentState { case .menu: self.currentState = .timeSelection - self.state?.updated(transition: Transition(animation: .curve(duration: 0.5, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.5, curve: .spring))) case .timeSelection: self.currentState = .menu - self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) } } - func update(component: EmojiStatusPreviewScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EmojiStatusPreviewScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -858,7 +858,7 @@ final class EmojiStatusPreviewScreenComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/EmojiStatusSelectionComponent/Sources/EmojiStatusSelectionComponent.swift b/submodules/TelegramUI/Components/EmojiStatusSelectionComponent/Sources/EmojiStatusSelectionComponent.swift index 5fca0d36fc..9b437cf096 100644 --- a/submodules/TelegramUI/Components/EmojiStatusSelectionComponent/Sources/EmojiStatusSelectionComponent.swift +++ b/submodules/TelegramUI/Components/EmojiStatusSelectionComponent/Sources/EmojiStatusSelectionComponent.swift @@ -67,7 +67,7 @@ public final class EmojiStatusSelectionComponent: Component { public let color: UIColor? public let hideTopPanel: Bool public let disableTopPanel: Bool - public let hideTopPanelUpdated: (Bool, Transition) -> Void + public let hideTopPanelUpdated: (Bool, ComponentTransition) -> Void public init( theme: PresentationTheme, @@ -79,7 +79,7 @@ public final class EmojiStatusSelectionComponent: Component { separatorColor: UIColor, hideTopPanel: Bool, disableTopPanel: Bool, - hideTopPanelUpdated: @escaping (Bool, Transition) -> Void + hideTopPanelUpdated: @escaping (Bool, ComponentTransition) -> Void ) { self.theme = theme self.strings = strings @@ -156,7 +156,7 @@ public final class EmojiStatusSelectionComponent: Component { deinit { } - func update(component: EmojiStatusSelectionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EmojiStatusSelectionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.backgroundColor = component.backgroundColor let panelBackgroundColor = component.backgroundColor.withMultipliedAlpha(0.85) self.panelBackgroundView.updateColor(color: panelBackgroundColor, transition: .immediate) @@ -249,7 +249,7 @@ public final class EmojiStatusSelectionComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -736,7 +736,7 @@ public final class EmojiStatusSelectionController: ViewController { self.emojiSearchDisposable.dispose() } - private func refreshLayout(transition: Transition) { + private func refreshLayout(transition: ComponentTransition) { guard let layout = self.validLayout else { return } @@ -968,7 +968,7 @@ public final class EmojiStatusSelectionController: ViewController { }, fromBackground: fromBackground) } - func containerLayoutUpdated(layout: ContainerViewLayout, transition: Transition) { + func containerLayoutUpdated(layout: ContainerViewLayout, transition: ComponentTransition) { self.validLayout = layout var transition = transition @@ -1001,7 +1001,7 @@ public final class EmojiStatusSelectionController: ViewController { if let scheduledEmojiContentAnimationHint = self.scheduledEmojiContentAnimationHint { self.scheduledEmojiContentAnimationHint = nil let contentAnimation = scheduledEmojiContentAnimationHint - transition = Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(contentAnimation) + transition = ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(contentAnimation) } var componentWidth = layout.size.width - sideInset * 2.0 @@ -1154,7 +1154,7 @@ public final class EmojiStatusSelectionController: ViewController { if let current = self.previewScreenView { previewScreenView = current } else { - previewScreenTransition = Transition(animation: .none) + previewScreenTransition = ComponentTransition(animation: .none) if let emojiView = self.componentHost.findTaggedView(tag: EmojiPagerContentComponent.Tag(id: AnyHashable("emoji"))) as? EmojiPagerContentComponent.View, let sourceLayer = emojiView.layerForItem(groupId: previewItem.groupId, item: previewItem.item) { previewScreenTransition = previewScreenTransition.withUserData(EmojiStatusPreviewScreenComponent.TransitionAnimation( transitionType: .animateIn(sourceLayer: sourceLayer) @@ -1493,7 +1493,7 @@ public final class EmojiStatusSelectionController: ViewController { override public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) { super.containerLayoutUpdated(layout, transition: transition) - (self.displayNode as! Node).containerLayoutUpdated(layout: layout, transition: Transition(transition)) + (self.displayNode as! Node).containerLayoutUpdated(layout: layout, transition: ComponentTransition(transition)) } } diff --git a/submodules/TelegramUI/Components/EmojiSuggestionsComponent/Sources/EmojiSuggestionsComponent.swift b/submodules/TelegramUI/Components/EmojiSuggestionsComponent/Sources/EmojiSuggestionsComponent.swift index 348ce54803..6a21882f2b 100644 --- a/submodules/TelegramUI/Components/EmojiSuggestionsComponent/Sources/EmojiSuggestionsComponent.swift +++ b/submodules/TelegramUI/Components/EmojiSuggestionsComponent/Sources/EmojiSuggestionsComponent.swift @@ -390,7 +390,7 @@ public final class EmojiSuggestionsComponent: Component { //self.blurView.shadowPath = path } - func update(component: EmojiSuggestionsComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EmojiSuggestionsComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let height: CGFloat = 54.0 if self.component?.theme.backgroundColor != component.theme.backgroundColor { @@ -434,7 +434,7 @@ public final class EmojiSuggestionsComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/EmojiTextAttachmentView/Sources/EmojiTextAttachmentView.swift b/submodules/TelegramUI/Components/EmojiTextAttachmentView/Sources/EmojiTextAttachmentView.swift index 80801a2828..803ff11124 100644 --- a/submodules/TelegramUI/Components/EmojiTextAttachmentView/Sources/EmojiTextAttachmentView.swift +++ b/submodules/TelegramUI/Components/EmojiTextAttachmentView/Sources/EmojiTextAttachmentView.swift @@ -374,7 +374,7 @@ public final class InlineStickerItemLayer: MultiAnimationRenderTarget { } } if let customColor { - Transition.immediate.setTintColor(layer: mirrorLayer, color: customColor) + ComponentTransition.immediate.setTintColor(layer: mirrorLayer, color: customColor) } else { self.layerTintColor = nil } @@ -482,7 +482,7 @@ public final class InlineStickerItemLayer: MultiAnimationRenderTarget { return nullAction } - public func updateTintColor(contentTintColor: UIColor?, dynamicColor: UIColor?, transition: Transition) { + public func updateTintColor(contentTintColor: UIColor?, dynamicColor: UIColor?, transition: ComponentTransition) { self._contentTintColor = contentTintColor self._dynamicColor = dynamicColor diff --git a/submodules/TelegramUI/Components/EmptyStateIndicatorComponent/Sources/EmptyStateIndicatorComponent.swift b/submodules/TelegramUI/Components/EmptyStateIndicatorComponent/Sources/EmptyStateIndicatorComponent.swift index 11a58b0a01..a977743330 100644 --- a/submodules/TelegramUI/Components/EmptyStateIndicatorComponent/Sources/EmptyStateIndicatorComponent.swift +++ b/submodules/TelegramUI/Components/EmptyStateIndicatorComponent/Sources/EmptyStateIndicatorComponent.swift @@ -90,7 +90,7 @@ public final class EmptyStateIndicatorComponent: Component { preconditionFailure() } - public func update(component: EmptyStateIndicatorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(component: EmptyStateIndicatorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.componentState = state @@ -266,7 +266,7 @@ public final class EmptyStateIndicatorComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiKeyboardItemLayer.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiKeyboardItemLayer.swift index 19ee0562ae..7824028732 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiKeyboardItemLayer.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiKeyboardItemLayer.swift @@ -400,7 +400,7 @@ public final class EmojiKeyboardItemLayer: MultiAnimationRenderTarget { } func update( - transition: Transition, + transition: ComponentTransition, size: CGSize, badge: Badge?, blurredBadgeColor: UIColor, diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift index 00c9b967c5..db64a3829f 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift @@ -129,7 +129,7 @@ public protocol EmojiContentPeekBehavior: AnyObject { public protocol EmojiCustomContentView: UIView { var tintContainerView: UIView { get } - func update(theme: PresentationTheme, strings: PresentationStrings, useOpaqueTheme: Bool, availableSize: CGSize, transition: Transition) -> CGSize + func update(theme: PresentationTheme, strings: PresentationStrings, useOpaqueTheme: Bool, availableSize: CGSize, transition: ComponentTransition) -> CGSize } public final class EmojiPagerContentComponent: Component { @@ -238,7 +238,7 @@ public final class EmojiPagerContentComponent: Component { public let presentController: (ViewController) -> Void public let presentGlobalOverlayController: (ViewController) -> Void public let navigationController: () -> NavigationController? - public let requestUpdate: (Transition) -> Void + public let requestUpdate: (ComponentTransition) -> Void public let updateSearchQuery: (EmojiPagerContentComponent.SearchQuery?) -> Void public let updateScrollingToItemGroup: () -> Void public let externalCancel: (() -> Void)? @@ -268,7 +268,7 @@ public final class EmojiPagerContentComponent: Component { presentController: @escaping (ViewController) -> Void, presentGlobalOverlayController: @escaping (ViewController) -> Void, navigationController: @escaping () -> NavigationController?, - requestUpdate: @escaping (Transition) -> Void, + requestUpdate: @escaping (ComponentTransition) -> Void, updateSearchQuery: @escaping (SearchQuery?) -> Void, updateScrollingToItemGroup: @escaping () -> Void, externalCancel: (() -> Void)? = nil, @@ -1387,7 +1387,7 @@ public final class EmojiPagerContentComponent: Component { private var isUpdating: Bool = false private var pagerEnvironment: PagerComponentChildEnvironment? private var keyboardChildEnvironment: EntityKeyboardChildEnvironment? - private var activeItemUpdated: ActionSlot<(AnyHashable, AnyHashable?, Transition)>? + private var activeItemUpdated: ActionSlot<(AnyHashable, AnyHashable?, ComponentTransition)>? private var itemLayout: ItemLayout? private var contextFocusItemKey: EmojiKeyboardItemLayer.Key? @@ -2779,7 +2779,7 @@ public final class EmojiPagerContentComponent: Component { itemLayer.cloneLayer = currentLongPressLayer itemLayer.isHidden = true - let transition = Transition(animation: .curve(duration: longPressDuration, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: longPressDuration, curve: .easeInOut)) transition.setScale(layer: currentLongPressLayer, scale: 1.85) } @@ -2806,13 +2806,13 @@ public final class EmojiPagerContentComponent: Component { self.longPressItem = nil if let itemLayer = self.visibleItemLayers[itemKey] { - let transition = Transition(animation: .curve(duration: 0.3, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.3, curve: .spring)) transition.setScale(layer: itemLayer, scale: 1.0) if let currentLongPressLayer = self.currentLongPressLayer { self.currentLongPressLayer = nil - let transition = Transition(animation: .curve(duration: 0.3, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.3, curve: .spring)) transition.setScale(layer: currentLongPressLayer, scale: 1.0, completion: { [weak itemLayer, weak currentLongPressLayer] _ in itemLayer?.isHidden = false currentLongPressLayer?.removeFromSuperlayer() @@ -2841,13 +2841,13 @@ public final class EmojiPagerContentComponent: Component { } } else { if let itemLayer = self.visibleItemLayers[itemKey] { - let transition = Transition(animation: .curve(duration: 0.3, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.3, curve: .spring)) transition.setScale(layer: itemLayer, scale: 1.0) if let currentLongPressLayer = self.currentLongPressLayer { self.currentLongPressLayer = nil - let transition = Transition(animation: .curve(duration: 0.3, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.3, curve: .spring)) transition.setScale(layer: currentLongPressLayer, scale: 1.0, completion: { [weak itemLayer, weak currentLongPressLayer] _ in itemLayer?.isHidden = false currentLongPressLayer?.removeFromSuperlayer() @@ -2856,7 +2856,7 @@ public final class EmojiPagerContentComponent: Component { } else if let currentLongPressLayer = self.currentLongPressLayer { self.currentLongPressLayer = nil - let transition = Transition(animation: .curve(duration: 0.3, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.3, curve: .spring)) transition.setScale(layer: currentLongPressLayer, scale: 1.0, completion: { [weak currentLongPressLayer] _ in currentLongPressLayer?.removeFromSuperlayer() }) @@ -2970,7 +2970,7 @@ public final class EmojiPagerContentComponent: Component { self.component?.inputInteractionHolder.inputInteraction?.scrollingStickersGridPromise.set(false) } - private func updateScrollingOffset(isReset: Bool, transition: Transition) { + private func updateScrollingOffset(isReset: Bool, transition: ComponentTransition) { guard let component = self.component else { return } @@ -3014,7 +3014,7 @@ public final class EmojiPagerContentComponent: Component { } private func snapScrollingOffsetToInsets() { - let transition = Transition(animation: .curve(duration: 0.4, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)) var currentBounds = self.scrollView.bounds currentBounds.origin.y = self.snappedContentOffset(proposedOffset: currentBounds.minY) @@ -3023,7 +3023,7 @@ public final class EmojiPagerContentComponent: Component { self.updateScrollingOffset(isReset: false, transition: transition) } - private func updateVisibleItems(transition: Transition, attemptSynchronousLoads: Bool, previousItemPositions: [VisualItemKey: CGPoint]?, previousAbsoluteItemPositions: [VisualItemKey: CGPoint]? = nil, updatedItemPositions: [VisualItemKey: CGPoint]?, hintDisappearingGroupFrame: (groupId: AnyHashable, frame: CGRect)? = nil) { + private func updateVisibleItems(transition: ComponentTransition, attemptSynchronousLoads: Bool, previousItemPositions: [VisualItemKey: CGPoint]?, previousAbsoluteItemPositions: [VisualItemKey: CGPoint]? = nil, updatedItemPositions: [VisualItemKey: CGPoint]?, hintDisappearingGroupFrame: (groupId: AnyHashable, frame: CGRect)? = nil) { guard let component = self.component, let pagerEnvironment = self.pagerEnvironment, let keyboardChildEnvironment = self.keyboardChildEnvironment, let itemLayout = self.itemLayout else { return } @@ -3971,10 +3971,10 @@ public final class EmojiPagerContentComponent: Component { private func expandGroup(groupId: AnyHashable) { self.expandedGroupIds.insert(groupId) - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(ContentAnimation(type: .groupExpanded(id: groupId)))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(ContentAnimation(type: .groupExpanded(id: groupId)))) } - public func pagerUpdateBackground(backgroundFrame: CGRect, topPanelHeight: CGFloat, transition: Transition) { + public func pagerUpdateBackground(backgroundFrame: CGRect, topPanelHeight: CGFloat, transition: ComponentTransition) { guard let component = self.component, let keyboardChildEnvironment = self.keyboardChildEnvironment, let pagerEnvironment = self.pagerEnvironment else { return } @@ -4055,7 +4055,7 @@ public final class EmojiPagerContentComponent: Component { } } - func update(component: EmojiPagerContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EmojiPagerContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -4580,16 +4580,16 @@ public final class EmojiPagerContentComponent: Component { if !isFirstResponder { strongSelf.component?.inputInteractionHolder.inputInteraction?.requestUpdate( - Transition(animation: .curve(duration: 0.4, curve: .spring))) + ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } else { DispatchQueue.main.async { self?.component?.inputInteractionHolder.inputInteraction?.requestUpdate( - Transition(animation: .curve(duration: 0.4, curve: .spring))) + ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } } if !strongSelf.isUpdating { - strongSelf.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + strongSelf.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } } }, updateQuery: { [weak self] query in @@ -4789,7 +4789,7 @@ public final class EmojiPagerContentComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchContent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchContent.swift index e8fb0bd8c9..1820835356 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchContent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchContent.swift @@ -166,7 +166,7 @@ public final class EmojiSearchContent: ASDisplayNode, EntitySearchContainerNode self.onCancel?() } else { self.itemGroups.removeAll(where: { $0.groupId == groupId }) - self.update(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(EmojiPagerContentComponent.ContentAnimation(type: .groupRemoved(id: groupId)))) + self.update(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(EmojiPagerContentComponent.ContentAnimation(type: .groupRemoved(id: groupId)))) } } }, @@ -441,17 +441,17 @@ public final class EmojiSearchContent: ASDisplayNode, EntitySearchContainerNode self.dataDisposable?.dispose() } - private func update(transition: Transition) { + private func update(transition: ComponentTransition) { if let params = self.params { self.update(size: params.size, leftInset: params.leftInset, rightInset: params.rightInset, bottomInset: params.bottomInset, inputHeight: params.inputHeight, deviceMetrics: params.deviceMetrics, transition: transition) } } public func updateLayout(size: CGSize, leftInset: CGFloat, rightInset: CGFloat, bottomInset: CGFloat, inputHeight: CGFloat, deviceMetrics: DeviceMetrics, transition: ContainedViewLayoutTransition) { - self.update(size: size, leftInset: leftInset, rightInset: rightInset, bottomInset: bottomInset, inputHeight: inputHeight, deviceMetrics: deviceMetrics, transition: Transition(transition)) + self.update(size: size, leftInset: leftInset, rightInset: rightInset, bottomInset: bottomInset, inputHeight: inputHeight, deviceMetrics: deviceMetrics, transition: ComponentTransition(transition)) } - private func update(size: CGSize, leftInset: CGFloat, rightInset: CGFloat, bottomInset: CGFloat, inputHeight: CGFloat, deviceMetrics: DeviceMetrics, transition: Transition) { + private func update(size: CGSize, leftInset: CGFloat, rightInset: CGFloat, bottomInset: CGFloat, inputHeight: CGFloat, deviceMetrics: DeviceMetrics, transition: ComponentTransition) { self.backgroundColor = self.presentationData.theme.list.plainBackgroundColor let params = Params(size: size, leftInset: leftInset, rightInset: rightInset, bottomInset: bottomInset, inputHeight: inputHeight, deviceMetrics: deviceMetrics) diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchHeaderView.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchHeaderView.swift index 272fb06789..5eb70b2d57 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchHeaderView.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchHeaderView.swift @@ -340,7 +340,7 @@ public final class EmojiSearchHeaderView: UIView, UITextFieldDelegate { self.updateQuery(.text(value: text, language: inputLanguage)) } - private func update(transition: Transition) { + private func update(transition: ComponentTransition) { guard let params = self.params else { return } @@ -348,7 +348,7 @@ public final class EmojiSearchHeaderView: UIView, UITextFieldDelegate { self.update(context: params.context, theme: params.theme, forceNeedsVibrancy: params.forceNeedsVibrancy, strings: params.strings, text: params.text, useOpaqueTheme: params.useOpaqueTheme, isActive: params.isActive, size: params.size, canFocus: params.canFocus, searchCategories: params.searchCategories, searchState: params.searchState, transition: transition) } - public func update(context: AccountContext, theme: PresentationTheme, forceNeedsVibrancy: Bool, strings: PresentationStrings, text: String, useOpaqueTheme: Bool, isActive: Bool, size: CGSize, canFocus: Bool, searchCategories: EmojiSearchCategories?, searchState: EmojiPagerContentComponent.SearchState, transition: Transition) { + public func update(context: AccountContext, theme: PresentationTheme, forceNeedsVibrancy: Bool, strings: PresentationStrings, text: String, useOpaqueTheme: Bool, isActive: Bool, size: CGSize, canFocus: Bool, searchCategories: EmojiSearchCategories?, searchState: EmojiPagerContentComponent.SearchState, transition: ComponentTransition) { let textInputState: EmojiSearchSearchBarComponent.TextInputState if let textField = self.textField { textInputState = .active(hasText: !(textField.text ?? "").isEmpty) @@ -517,7 +517,7 @@ public final class EmojiSearchHeaderView: UIView, UITextFieldDelegate { if shouldChangeActivation { if let term { - self.update(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.update(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) self.updateQuery(.category(value: term)) self.activated(false) diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchSearchBarComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchSearchBarComponent.swift index 9b9b67c1ea..3c53dd5497 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchSearchBarComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchSearchBarComponent.swift @@ -383,7 +383,7 @@ final class EmojiSearchSearchBarComponent: Component { } } } else { - let transition = Transition(animation: .curve(duration: 0.4, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)) transition.setBoundsOrigin(view: self.scrollView, origin: CGPoint()) self.updateScrolling(transition: transition, fromScrolling: false) //self.scrollView.setContentOffset(CGPoint(), animated: true) @@ -402,7 +402,7 @@ final class EmojiSearchSearchBarComponent: Component { if self.selectedItem != nil { self.selectedItem = nil - let transition = Transition(animation: .curve(duration: 0.4, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)) transition.setBoundsOrigin(view: self.scrollView, origin: CGPoint()) self.updateScrolling(transition: transition, fromScrolling: false) @@ -438,7 +438,7 @@ final class EmojiSearchSearchBarComponent: Component { return (itemLayout.itemStartX - itemLayout.textSpacing) + visibleBounds.minX } - private func updateScrolling(transition: Transition, fromScrolling: Bool) { + private func updateScrolling(transition: ComponentTransition, fromScrolling: Bool) { guard let component = self.component, let itemLayout = self.itemLayout else { return } @@ -600,8 +600,8 @@ final class EmojiSearchSearchBarComponent: Component { self.selectedItemBackground.opacity = 1.0 self.selectedItemTintBackground.opacity = 1.0 - Transition.immediate.setScale(layer: self.selectedItemBackground, scale: 1.0) - Transition.immediate.setScale(layer: self.selectedItemTintBackground, scale: 1.0) + ComponentTransition.immediate.setScale(layer: self.selectedItemBackground, scale: 1.0) + ComponentTransition.immediate.setScale(layer: self.selectedItemTintBackground, scale: 1.0) if !transition.animation.isImmediate { self.selectedItemBackground.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) @@ -616,8 +616,8 @@ final class EmojiSearchSearchBarComponent: Component { transition.setPosition(layer: self.selectedItemTintBackground, position: selectionFrame.center) if case let .curve(duration, _) = transition.animation { - Transition.immediate.setScale(layer: self.selectedItemBackground, scale: 1.0) - Transition.immediate.setScale(layer: self.selectedItemTintBackground, scale: 1.0) + ComponentTransition.immediate.setScale(layer: self.selectedItemBackground, scale: 1.0) + ComponentTransition.immediate.setScale(layer: self.selectedItemTintBackground, scale: 1.0) self.selectedItemBackground.animateKeyframes(values: [1.0 as NSNumber, 0.75 as NSNumber, 1.0 as NSNumber], duration: duration, keyPath: "transform.scale") self.selectedItemTintBackground.animateKeyframes(values: [1.0 as NSNumber, 0.75 as NSNumber, 1.0 as NSNumber], duration: duration, keyPath: "transform.scale") @@ -644,7 +644,7 @@ final class EmojiSearchSearchBarComponent: Component { transition.setBounds(view: self.tintTextContainerView, bounds: CGRect(origin: CGPoint(x: textOffset, y: 0.0), size: scrollBounds.size)) } - func update(component: EmojiSearchSearchBarComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EmojiSearchSearchBarComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.componentState = state @@ -731,7 +731,7 @@ final class EmojiSearchSearchBarComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchStatusComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchStatusComponent.swift index 4b498d229b..6d4e813427 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchStatusComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchStatusComponent.swift @@ -430,7 +430,7 @@ final class EmojiSearchStatusComponent: Component { } } - func update(component: EmojiSearchStatusComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EmojiSearchStatusComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let displaySize = CGSize(width: availableSize.width * UIScreenScale, height: availableSize.height * UIScreenScale) @@ -791,7 +791,7 @@ final class EmojiSearchStatusComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmptySearchResultsView.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmptySearchResultsView.swift index 466c430e8d..b7d109e741 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmptySearchResultsView.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmptySearchResultsView.swift @@ -33,7 +33,7 @@ final class EmptySearchResultsView: UIView { fatalError("init(coder:) has not been implemented") } - func update(context: AccountContext, theme: PresentationTheme, useOpaqueTheme: Bool, text: String, file: TelegramMediaFile?, size: CGSize, searchInitiallyHidden: Bool, transition: Transition) { + func update(context: AccountContext, theme: PresentationTheme, useOpaqueTheme: Bool, text: String, file: TelegramMediaFile?, size: CGSize, searchInitiallyHidden: Bool, transition: ComponentTransition) { let titleColor: UIColor if useOpaqueTheme { titleColor = theme.chat.inputMediaPanel.panelContentOpaqueSearchOverlayColor diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboard.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboard.swift index 50ec90989c..f88507b953 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboard.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboard.swift @@ -15,13 +15,13 @@ public final class EntityKeyboardChildEnvironment: Equatable { public let theme: PresentationTheme public let strings: PresentationStrings public let isContentInFocus: Bool - public let getContentActiveItemUpdated: (AnyHashable) -> ActionSlot<(AnyHashable, AnyHashable?, Transition)>? + public let getContentActiveItemUpdated: (AnyHashable) -> ActionSlot<(AnyHashable, AnyHashable?, ComponentTransition)>? public init( theme: PresentationTheme, strings: PresentationStrings, isContentInFocus: Bool, - getContentActiveItemUpdated: @escaping (AnyHashable) -> ActionSlot<(AnyHashable, AnyHashable?, Transition)>? + getContentActiveItemUpdated: @escaping (AnyHashable) -> ActionSlot<(AnyHashable, AnyHashable?, ComponentTransition)>? ) { self.theme = theme self.strings = strings @@ -107,10 +107,10 @@ public final class EntityKeyboardComponent: Component { public let externalTopPanelContainer: PagerExternalTopPanelContainer? public let externalBottomPanelContainer: PagerExternalTopPanelContainer? public let displayTopPanelBackground: DisplayTopPanelBackground - public let topPanelExtensionUpdated: (CGFloat, Transition) -> Void - public let topPanelScrollingOffset: (CGFloat, Transition) -> Void - public let hideInputUpdated: (Bool, Bool, Transition) -> Void - public let hideTopPanelUpdated: (Bool, Transition) -> Void + public let topPanelExtensionUpdated: (CGFloat, ComponentTransition) -> Void + public let topPanelScrollingOffset: (CGFloat, ComponentTransition) -> Void + public let hideInputUpdated: (Bool, Bool, ComponentTransition) -> Void + public let hideTopPanelUpdated: (Bool, ComponentTransition) -> Void public let switchToTextInput: () -> Void public let switchToGifSubject: (GifPagerContentComponent.Subject) -> Void public let reorderItems: (ReorderCategory, [EntityKeyboardTopPanelComponent.Item]) -> Void @@ -142,10 +142,10 @@ public final class EntityKeyboardComponent: Component { externalTopPanelContainer: PagerExternalTopPanelContainer?, externalBottomPanelContainer: PagerExternalTopPanelContainer?, displayTopPanelBackground: DisplayTopPanelBackground, - topPanelExtensionUpdated: @escaping (CGFloat, Transition) -> Void, - topPanelScrollingOffset: @escaping (CGFloat, Transition) -> Void, - hideInputUpdated: @escaping (Bool, Bool, Transition) -> Void, - hideTopPanelUpdated: @escaping (Bool, Transition) -> Void, + topPanelExtensionUpdated: @escaping (CGFloat, ComponentTransition) -> Void, + topPanelScrollingOffset: @escaping (CGFloat, ComponentTransition) -> Void, + hideInputUpdated: @escaping (Bool, Bool, ComponentTransition) -> Void, + hideTopPanelUpdated: @escaping (Bool, ComponentTransition) -> Void, switchToTextInput: @escaping () -> Void, switchToGifSubject: @escaping (GifPagerContentComponent.Subject) -> Void, reorderItems: @escaping (ReorderCategory, [EntityKeyboardTopPanelComponent.Item]) -> Void, @@ -306,7 +306,7 @@ public final class EntityKeyboardComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: EntityKeyboardComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EntityKeyboardComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.state = state var contents: [AnyComponentWithIdentity<(EntityKeyboardChildEnvironment, PagerComponentChildEnvironment)>] = [] @@ -315,9 +315,9 @@ public final class EntityKeyboardComponent: Component { var contentAccessoryLeftButtons: [AnyComponentWithIdentity] = [] var contentAccessoryRightButtons: [AnyComponentWithIdentity] = [] - let gifsContentItemIdUpdated = ActionSlot<(AnyHashable, AnyHashable?, Transition)>() - let stickersContentItemIdUpdated = ActionSlot<(AnyHashable, AnyHashable?, Transition)>() - let masksContentItemIdUpdated = ActionSlot<(AnyHashable, AnyHashable?, Transition)>() + let gifsContentItemIdUpdated = ActionSlot<(AnyHashable, AnyHashable?, ComponentTransition)>() + let stickersContentItemIdUpdated = ActionSlot<(AnyHashable, AnyHashable?, ComponentTransition)>() + let masksContentItemIdUpdated = ActionSlot<(AnyHashable, AnyHashable?, ComponentTransition)>() if transition.userData(MarkInputCollapsed.self) != nil { self.searchComponent = nil @@ -565,7 +565,7 @@ public final class EntityKeyboardComponent: Component { let deleteBackwards = component.emojiContent?.inputInteractionHolder.inputInteraction?.deleteBackwards - let emojiContentItemIdUpdated = ActionSlot<(AnyHashable, AnyHashable?, Transition)>() + let emojiContentItemIdUpdated = ActionSlot<(AnyHashable, AnyHashable?, ComponentTransition)>() if let emojiContent = component.emojiContent { contents.append(AnyComponentWithIdentity(id: "emoji", component: AnyComponent(emojiContent))) var topEmojiItems: [EntityKeyboardTopPanelComponent.Item] = [] @@ -851,7 +851,7 @@ public final class EntityKeyboardComponent: Component { return availableSize } - private func topPanelExtensionUpdated(height: CGFloat, transition: Transition) { + private func topPanelExtensionUpdated(height: CGFloat, transition: ComponentTransition) { guard let component = self.component else { return } @@ -863,7 +863,7 @@ public final class EntityKeyboardComponent: Component { } } - private func topPanelScrollingOffset(offset: CGFloat, transition: Transition) { + private func topPanelScrollingOffset(offset: CGFloat, transition: ComponentTransition) { guard let component = self.component else { return } @@ -875,7 +875,7 @@ public final class EntityKeyboardComponent: Component { } } - private func isTopPanelExpandedUpdated(isExpanded: Bool, transition: Transition) { + private func isTopPanelExpandedUpdated(isExpanded: Bool, transition: ComponentTransition) { if self.isTopPanelExpanded != isExpanded { self.isTopPanelExpanded = isExpanded } @@ -887,7 +887,7 @@ public final class EntityKeyboardComponent: Component { component.hideInputUpdated(self.isTopPanelExpanded, false, transition) } - private func isTopPanelHiddenUpdated(isTopPanelHidden: Bool, transition: Transition) { + private func isTopPanelHiddenUpdated(isTopPanelHidden: Bool, transition: ComponentTransition) { if self.isTopPanelHidden != isTopPanelHidden { self.isTopPanelHidden = isTopPanelHidden } @@ -938,7 +938,7 @@ public final class EntityKeyboardComponent: Component { ) } - component.hideInputUpdated(true, true, Transition(animation: .curve(duration: 0.3, curve: .spring))) + component.hideInputUpdated(true, true, ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) } } @@ -963,7 +963,7 @@ public final class EntityKeyboardComponent: Component { } ) } - component.hideInputUpdated(true, true, Transition(animation: .curve(duration: 0.3, curve: .spring))) + component.hideInputUpdated(true, true, ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) } private func closeSearch() { @@ -974,8 +974,8 @@ public final class EntityKeyboardComponent: Component { return } self.searchComponent = nil - //self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) - component.hideInputUpdated(false, false, Transition(animation: .curve(duration: 0.4, curve: .spring))) + //self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) + component.hideInputUpdated(false, false, ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } public func scrollToItemGroup(contentId: String, groupId: AnyHashable, subgroupId: Int32?, animated: Bool = true) { @@ -1003,7 +1003,7 @@ public final class EntityKeyboardComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardBottomPanelComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardBottomPanelComponent.swift index 369dfc812d..73390b8127 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardBottomPanelComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardBottomPanelComponent.swift @@ -65,7 +65,7 @@ private final class BottomPanelIconComponent: Component { } } - func update(component: BottomPanelIconComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BottomPanelIconComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { if self.component?.title != component.title { let text = NSAttributedString(string: component.title, font: Font.medium(15.0), textColor: .white) let textBounds = text.boundingRect(with: CGSize(width: 120.0, height: 100.0), options: .usesLineFragmentOrigin, context: nil) @@ -106,7 +106,7 @@ private final class BottomPanelIconComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -184,7 +184,7 @@ final class EntityKeyboardBottomPanelComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: EntityKeyboardBottomPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EntityKeyboardBottomPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { if self.component?.theme !== component.theme { self.separatorView.backgroundColor = component.theme.chat.inputMediaPanel.panelSeparatorColor self.backgroundView.updateColor(color: component.theme.chat.inputPanel.panelBackgroundColor.withMultipliedAlpha(1.0), transition: .immediate) @@ -309,7 +309,7 @@ final class EntityKeyboardBottomPanelComponent: Component { } var validIconIds: [AnyHashable] = [] - var iconInfos: [AnyHashable: (size: CGSize, transition: Transition)] = [:] + var iconInfos: [AnyHashable: (size: CGSize, transition: ComponentTransition)] = [:] var iconTotalSize = CGSize() let iconSpacing: CGFloat = 4.0 @@ -411,7 +411,7 @@ final class EntityKeyboardBottomPanelComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardTopContainerPanelComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardTopContainerPanelComponent.swift index 0d65cbf0a2..a8e4fae508 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardTopContainerPanelComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardTopContainerPanelComponent.swift @@ -9,13 +9,13 @@ import Postbox public final class EntityKeyboardTopContainerPanelEnvironment: Equatable { let isContentInFocus: Bool - let visibilityFractionUpdated: ActionSlot<(CGFloat, Transition)> - let isExpandedUpdated: (Bool, Transition) -> Void + let visibilityFractionUpdated: ActionSlot<(CGFloat, ComponentTransition)> + let isExpandedUpdated: (Bool, ComponentTransition) -> Void init( isContentInFocus: Bool, - visibilityFractionUpdated: ActionSlot<(CGFloat, Transition)>, - isExpandedUpdated: @escaping (Bool, Transition) -> Void + visibilityFractionUpdated: ActionSlot<(CGFloat, ComponentTransition)>, + isExpandedUpdated: @escaping (Bool, ComponentTransition) -> Void ) { self.isContentInFocus = isContentInFocus self.visibilityFractionUpdated = visibilityFractionUpdated @@ -66,7 +66,7 @@ final class EntityKeyboardTopContainerPanelComponent: Component { private final class PanelView { let view = ComponentHostView() - let visibilityFractionUpdated = ActionSlot<(CGFloat, Transition)>() + let visibilityFractionUpdated = ActionSlot<(CGFloat, ComponentTransition)>() var isExpanded: Bool = false } @@ -93,7 +93,7 @@ final class EntityKeyboardTopContainerPanelComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: EntityKeyboardTopContainerPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EntityKeyboardTopContainerPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let intrinsicHeight: CGFloat = 34.0 let height = intrinsicHeight @@ -245,7 +245,7 @@ final class EntityKeyboardTopContainerPanelComponent: Component { return CGSize(width: availableSize.width, height: height) } - private func updateVisibilityFraction(value: CGFloat, transition: Transition) { + private func updateVisibilityFraction(value: CGFloat, transition: ComponentTransition) { if self.visibilityFraction == value { return } @@ -257,7 +257,7 @@ final class EntityKeyboardTopContainerPanelComponent: Component { } } - private func panelIsExpandedUpdated(id: AnyHashable, isExpanded: Bool, transition: Transition) { + private func panelIsExpandedUpdated(id: AnyHashable, isExpanded: Bool, transition: ComponentTransition) { guard let panelView = self.panelViews[id] else { return } @@ -306,7 +306,7 @@ final class EntityKeyboardTopContainerPanelComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardTopPanelComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardTopPanelComponent.swift index 236588fff2..28dada2af5 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardTopPanelComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardTopPanelComponent.swift @@ -106,7 +106,7 @@ final class EntityKeyboardAnimationTopPanelComponent: Component { } } - func update(component: EntityKeyboardAnimationTopPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EntityKeyboardAnimationTopPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let itemEnvironment = environment[EntityKeyboardTopPanelItemEnvironment.self].value @@ -262,7 +262,7 @@ final class EntityKeyboardAnimationTopPanelComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -347,7 +347,7 @@ final class EntityKeyboardIconTopPanelComponent: Component { } } - func update(component: EntityKeyboardIconTopPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EntityKeyboardIconTopPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let itemEnvironment = environment[EntityKeyboardTopPanelItemEnvironment.self].value if self.component?.icon != component.icon { @@ -471,7 +471,7 @@ final class EntityKeyboardIconTopPanelComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -541,7 +541,7 @@ final class EntityKeyboardAvatarTopPanelComponent: Component { } } - func update(component: EntityKeyboardAvatarTopPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EntityKeyboardAvatarTopPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let itemEnvironment = environment[EntityKeyboardTopPanelItemEnvironment.self].value self.avatarNode.setPeer(context: component.context, theme: component.theme, peer: component.peer) @@ -602,7 +602,7 @@ final class EntityKeyboardAvatarTopPanelComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -746,7 +746,7 @@ final class EntityKeyboardStaticStickersPanelComponent: Component { self.updateVisibleItems(transition: .immediate, animateAppearingItems: true) } - private func updateVisibleItems(transition: Transition, animateAppearingItems: Bool) { + private func updateVisibleItems(transition: ComponentTransition, animateAppearingItems: Bool) { guard let component = self.component, let itemEnvironment = self.itemEnvironment, let itemLayout = self.itemLayout else { return } @@ -854,7 +854,7 @@ final class EntityKeyboardStaticStickersPanelComponent: Component { } } - func update(component: EntityKeyboardStaticStickersPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EntityKeyboardStaticStickersPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let itemEnvironment = environment[EntityKeyboardTopPanelItemEnvironment.self].value var scrollToItem: AnyHashable? @@ -943,7 +943,7 @@ final class EntityKeyboardStaticStickersPanelComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -1210,7 +1210,7 @@ public final class EntityKeyboardTopPanelComponent: Component { let containerSideInset: CGFloat let defaultActiveItemId: AnyHashable? let forceActiveItemId: AnyHashable? - let activeContentItemIdUpdated: ActionSlot<(AnyHashable, AnyHashable?, Transition)> + let activeContentItemIdUpdated: ActionSlot<(AnyHashable, AnyHashable?, ComponentTransition)> let activeContentItemMapping: [AnyHashable: AnyHashable] let reorderItems: ([Item]) -> Void @@ -1222,7 +1222,7 @@ public final class EntityKeyboardTopPanelComponent: Component { containerSideInset: CGFloat, defaultActiveItemId: AnyHashable? = nil, forceActiveItemId: AnyHashable? = nil, - activeContentItemIdUpdated: ActionSlot<(AnyHashable, AnyHashable?, Transition)>, + activeContentItemIdUpdated: ActionSlot<(AnyHashable, AnyHashable?, ComponentTransition)>, activeContentItemMapping: [AnyHashable: AnyHashable] = [:], reorderItems: @escaping ([Item]) -> Void ) { @@ -1637,7 +1637,7 @@ public final class EntityKeyboardTopPanelComponent: Component { guard let environment = strongSelf.environment else { return } - environment.isExpandedUpdated(false, Transition(animation: .curve(duration: 0.3, curve: .spring))) + environment.isExpandedUpdated(false, ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) }, queue: .mainQueue()) self.draggingStoppedTimer?.start() } @@ -1651,7 +1651,7 @@ public final class EntityKeyboardTopPanelComponent: Component { guard let environment = self.environment else { return } - environment.isExpandedUpdated(true, Transition(animation: .curve(duration: 0.3, curve: .spring))) + environment.isExpandedUpdated(true, ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) } } } @@ -1734,7 +1734,7 @@ public final class EntityKeyboardTopPanelComponent: Component { if self.didReorderItems { self.component?.reorderItems(self.items) } - //self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) + //self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) } private func updateReordering(offset: CGFloat) { @@ -1760,7 +1760,7 @@ public final class EntityKeyboardTopPanelComponent: Component { self.reorderingHapticFeedback.tap() } self.didReorderItems = true - self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) } break } @@ -1795,7 +1795,7 @@ public final class EntityKeyboardTopPanelComponent: Component { } } - private func updateVisibleItems(attemptSynchronousLoads: Bool, transition: Transition) { + private func updateVisibleItems(attemptSynchronousLoads: Bool, transition: ComponentTransition) { guard let itemLayout = self.itemLayout else { return } @@ -1865,7 +1865,7 @@ public final class EntityKeyboardTopPanelComponent: Component { } } - func update(component: EntityKeyboardTopPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EntityKeyboardTopPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { if self.component?.theme !== component.theme || self.component?.customTintColor != component.customTintColor { if let customTintColor = component.customTintColor { self.highlightedIconBackgroundView.backgroundColor = customTintColor.withAlphaComponent(0.1) @@ -2115,7 +2115,7 @@ public final class EntityKeyboardTopPanelComponent: Component { return CGSize(width: availableSize.width, height: height) } - private func visibilityFractionUpdated(value: CGFloat, transition: Transition) { + private func visibilityFractionUpdated(value: CGFloat, transition: ComponentTransition) { if self.visibilityFraction == value { return } @@ -2133,7 +2133,7 @@ public final class EntityKeyboardTopPanelComponent: Component { } } - private func activeContentItemIdUpdated(itemId: AnyHashable, subcontentItemId: AnyHashable?, transition: Transition) { + private func activeContentItemIdUpdated(itemId: AnyHashable, subcontentItemId: AnyHashable?, transition: ComponentTransition) { guard let component = self.component, let itemLayout = self.itemLayout else { return } @@ -2145,7 +2145,7 @@ public final class EntityKeyboardTopPanelComponent: Component { let _ = component let _ = itemLayout - 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 component = self.component, let itemLayout = self.itemLayout { for i in 0 ..< component.items.count { @@ -2199,7 +2199,7 @@ public final class EntityKeyboardTopPanelComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntitySearchContentComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntitySearchContentComponent.swift index 5068066d1c..05ba06d5b9 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntitySearchContentComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntitySearchContentComponent.swift @@ -137,7 +137,7 @@ final class EntitySearchContentComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: EntitySearchContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EntitySearchContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let containerNode: EntitySearchContainerNode? if let current = self.containerNode { containerNode = current @@ -174,7 +174,7 @@ final class EntitySearchContentComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/GifPagerContentComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/GifPagerContentComponent.swift index c4943a46a7..3269639803 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/GifPagerContentComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/GifPagerContentComponent.swift @@ -762,7 +762,7 @@ public final class GifPagerContentComponent: Component { self.snapScrollingOffsetToInsets() } - private func updateScrollingOffset(transition: Transition) { + private func updateScrollingOffset(transition: ComponentTransition) { let isInteracting = self.scrollView.isDragging || self.scrollView.isDecelerating if let previousScrollingOffsetValue = self.previousScrollingOffset { let currentBounds = self.scrollView.bounds @@ -808,7 +808,7 @@ public final class GifPagerContentComponent: Component { } private func snapScrollingOffsetToInsets() { - let transition = Transition(animation: .curve(duration: 0.4, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)) var currentBounds = self.scrollView.bounds currentBounds.origin.y = self.snappedContentOffset(proposedOffset: currentBounds.minY) @@ -818,7 +818,7 @@ public final class GifPagerContentComponent: Component { self.updateVisibleItems(attemptSynchronousLoads: false, transition: transition, fromScrolling: true) } - private func updateVisibleItems(attemptSynchronousLoads: Bool, transition: Transition, fromScrolling: Bool) { + private func updateVisibleItems(attemptSynchronousLoads: Bool, transition: ComponentTransition, fromScrolling: Bool) { guard let component = self.component, let itemLayout = self.itemLayout else { return } @@ -853,7 +853,7 @@ public final class GifPagerContentComponent: Component { let itemFrame = itemLayout.frame(at: index).offsetBy(dx: 0.0, dy: searchInset) - var itemTransition: Transition = transition + var itemTransition: ComponentTransition = transition var updateItemLayerPlaceholder = false let itemLayer: ItemLayer @@ -972,7 +972,7 @@ public final class GifPagerContentComponent: Component { } } - public func pagerUpdateBackground(backgroundFrame: CGRect, topPanelHeight: CGFloat, transition: Transition) { + public func pagerUpdateBackground(backgroundFrame: CGRect, topPanelHeight: CGFloat, transition: ComponentTransition) { guard let theme = self.theme else { return } @@ -1009,7 +1009,7 @@ public final class GifPagerContentComponent: Component { } } - func update(component: GifPagerContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: GifPagerContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { var contentReset = false if let previousComponent = self.component, previousComponent.subject != component.subject { contentReset = true @@ -1129,7 +1129,7 @@ public final class GifPagerContentComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/GroupEmbeddedView.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/GroupEmbeddedView.swift index 4721e8897f..9fba3ea8fd 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/GroupEmbeddedView.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/GroupEmbeddedView.swift @@ -104,7 +104,7 @@ final class GroupEmbeddedView: UIScrollView, UIScrollViewDelegate, PagerExpandab } } - private func updateVisibleItems(transition: Transition, attemptSynchronousLoad: Bool) { + private func updateVisibleItems(transition: ComponentTransition, attemptSynchronousLoad: Bool) { guard let context = self.context, let theme = self.theme, let itemLayout = self.itemLayout, let items = self.items, let cache = self.cache, let renderer = self.renderer else { return } diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/PremiumBadgeView.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/PremiumBadgeView.swift index 6e0a0497d2..d2d5c1f6c7 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/PremiumBadgeView.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/PremiumBadgeView.swift @@ -46,7 +46,7 @@ final class PremiumBadgeView: UIView { fatalError("init(coder:) has not been implemented") } - func update(transition: Transition, badge: EmojiKeyboardItemLayer.Badge, backgroundColor: UIColor, size: CGSize) { + func update(transition: ComponentTransition, badge: EmojiKeyboardItemLayer.Badge, backgroundColor: UIColor, size: CGSize) { if self.badge != badge { self.badge = badge diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/WarpView.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/WarpView.swift index 7ccea1a793..592ff50847 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/WarpView.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/WarpView.swift @@ -27,7 +27,7 @@ final class WarpView: UIView { fatalError("init(coder:) has not been implemented") } - func update(containerSize: CGSize, rect: CGRect, transition: Transition) { + func update(containerSize: CGSize, rect: CGRect, transition: ComponentTransition) { transition.setFrame(view: self.cloneView.view, frame: CGRect(origin: CGPoint(x: -rect.minX, y: -rect.minY), size: CGSize(width: containerSize.width, height: containerSize.height))) } } @@ -68,7 +68,7 @@ final class WarpView: UIView { fatalError("init(coder:) has not been implemented") } - func update(size: CGSize, topInset: CGFloat, warpHeight: CGFloat, theme: PresentationTheme, transition: Transition) { + func update(size: CGSize, topInset: CGFloat, warpHeight: CGFloat, theme: PresentationTheme, transition: ComponentTransition) { transition.setFrame(view: self.contentView, frame: CGRect(origin: CGPoint(), size: size)) let allItemsHeight = warpHeight * 0.5 diff --git a/submodules/TelegramUI/Components/ForumCreateTopicScreen/Sources/ForumCreateTopicScreen.swift b/submodules/TelegramUI/Components/ForumCreateTopicScreen/Sources/ForumCreateTopicScreen.swift index e7d812db0e..ffb5fa4e49 100644 --- a/submodules/TelegramUI/Components/ForumCreateTopicScreen/Sources/ForumCreateTopicScreen.swift +++ b/submodules/TelegramUI/Components/ForumCreateTopicScreen/Sources/ForumCreateTopicScreen.swift @@ -159,7 +159,7 @@ private final class TitleFieldComponent: Component { return true } - func update(component: TitleFieldComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: TitleFieldComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.textField.textColor = component.textColor self.textField.text = component.text self.textField.font = Font.regular(17.0) @@ -237,7 +237,7 @@ private final class TitleFieldComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -322,7 +322,7 @@ private final class TopicIconSelectionComponent: Component { deinit { } - func update(component: TopicIconSelectionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: TopicIconSelectionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.backgroundColor = component.backgroundColor let panelBackgroundColor = component.backgroundColor.withMultipliedAlpha(0.85) self.panelBackgroundView.updateColor(color: panelBackgroundColor, transition: .immediate) @@ -402,7 +402,7 @@ private final class TopicIconSelectionComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/LegacyMessageInputPanel/Sources/LegacyMessageInputPanel.swift b/submodules/TelegramUI/Components/LegacyMessageInputPanel/Sources/LegacyMessageInputPanel.swift index a3d855082c..70f131dbfb 100644 --- a/submodules/TelegramUI/Components/LegacyMessageInputPanel/Sources/LegacyMessageInputPanel.swift +++ b/submodules/TelegramUI/Components/LegacyMessageInputPanel/Sources/LegacyMessageInputPanel.swift @@ -95,7 +95,7 @@ public class LegacyMessageInputPanelNode: ASDisplayNode, TGCaptionPanelView { } public func animate(_ view: UIView, frame: CGRect) { - let transition = Transition.spring(duration: 0.4) + let transition = ComponentTransition.spring(duration: 0.4) transition.setFrame(view: view, frame: frame) } @@ -198,7 +198,7 @@ public class LegacyMessageInputPanelNode: ASDisplayNode, TGCaptionPanelView { self.inputPanel.parentState = self.state let inputPanelSize = self.inputPanel.update( - transition: Transition(transition), + transition: ComponentTransition(transition), component: AnyComponent( MessageInputPanelComponent( externalState: self.inputPanelExternalState, diff --git a/submodules/TelegramUI/Components/ListActionItemComponent/Sources/ListActionItemComponent.swift b/submodules/TelegramUI/Components/ListActionItemComponent/Sources/ListActionItemComponent.swift index 12ca89591c..c149d857f3 100644 --- a/submodules/TelegramUI/Components/ListActionItemComponent/Sources/ListActionItemComponent.swift +++ b/submodules/TelegramUI/Components/ListActionItemComponent/Sources/ListActionItemComponent.swift @@ -213,12 +213,12 @@ public final class ListActionItemComponent: 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 @@ -242,7 +242,7 @@ public final class ListActionItemComponent: 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 @@ -328,14 +328,14 @@ public final class ListActionItemComponent: Component { return result } - func update(component: ListActionItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ListActionItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousComponent = self.component self.component = component let themeUpdated = component.theme !== previousComponent?.theme var customAccessorySize: CGSize? - var customAccessoryTransition: Transition = transition + var customAccessoryTransition: ComponentTransition = transition var contentLeftInset: CGFloat = 16.0 let contentRightInset: CGFloat @@ -808,7 +808,7 @@ public final class ListActionItemComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ListItemComponentAdaptor/Sources/ListItemComponentAdaptor.swift b/submodules/TelegramUI/Components/ListItemComponentAdaptor/Sources/ListItemComponentAdaptor.swift index ba4e12d70e..0b9af02a61 100644 --- a/submodules/TelegramUI/Components/ListItemComponentAdaptor/Sources/ListItemComponentAdaptor.swift +++ b/submodules/TelegramUI/Components/ListItemComponentAdaptor/Sources/ListItemComponentAdaptor.swift @@ -48,7 +48,7 @@ public final class ListItemComponentAdaptor: Component { public final class View: UIView { private var itemNode: ListViewItemNode? - func update(component: ListItemComponentAdaptor, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ListItemComponentAdaptor, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let item = component.itemImpl() if let itemNode = self.itemNode { @@ -125,7 +125,7 @@ public final class ListItemComponentAdaptor: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ListItemSliderSelectorComponent/Sources/ListItemSliderSelectorComponent.swift b/submodules/TelegramUI/Components/ListItemSliderSelectorComponent/Sources/ListItemSliderSelectorComponent.swift index 0d7e103007..c92687fbe5 100644 --- a/submodules/TelegramUI/Components/ListItemSliderSelectorComponent/Sources/ListItemSliderSelectorComponent.swift +++ b/submodules/TelegramUI/Components/ListItemSliderSelectorComponent/Sources/ListItemSliderSelectorComponent.swift @@ -70,7 +70,7 @@ public final class ListItemSliderSelectorComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: ListItemSliderSelectorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ListItemSliderSelectorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -205,7 +205,7 @@ public final class ListItemSliderSelectorComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ListItemSwipeOptionContainer/Sources/ListItemSwipeOptionContainer.swift b/submodules/TelegramUI/Components/ListItemSwipeOptionContainer/Sources/ListItemSwipeOptionContainer.swift index eeec875a32..a32dfa93de 100644 --- a/submodules/TelegramUI/Components/ListItemSwipeOptionContainer/Sources/ListItemSwipeOptionContainer.swift +++ b/submodules/TelegramUI/Components/ListItemSwipeOptionContainer/Sources/ListItemSwipeOptionContainer.swift @@ -177,7 +177,7 @@ open class ListItemSwipeOptionContainer: UIView, UIGestureRecognizerDelegate { isExpanded: Bool, extendedWidth: CGFloat, sideInset: CGFloat, - transition: Transition, + transition: ComponentTransition, additive: Bool, revealFactor: CGFloat, animateIconMovement: Bool @@ -342,13 +342,13 @@ open class ListItemSwipeOptionContainer: UIView, UIGestureRecognizerDelegate { return CGSize(width: maxWidth * CGFloat(self.optionViews.count), height: constrainedSize.height) } - public func updateRevealOffset(offset: CGFloat, sideInset: CGFloat, transition: Transition) { + public func updateRevealOffset(offset: CGFloat, sideInset: CGFloat, transition: ComponentTransition) { self.revealOffset = offset self.sideInset = sideInset self.updateNodesLayout(transition: transition) } - private func updateNodesLayout(transition: Transition) { + private func updateNodesLayout(transition: ComponentTransition) { let size = self.bounds.size if size.width.isLessThanOrEqualTo(0.0) || self.optionViews.isEmpty { return @@ -480,7 +480,7 @@ open class ListItemSwipeOptionContainer: UIView, UIGestureRecognizerDelegate { private var allowAnyDirection: Bool = false - public var updateRevealOffset: ((CGFloat, Transition) -> Void)? + public var updateRevealOffset: ((CGFloat, ComponentTransition) -> Void)? public var revealOptionsInteractivelyOpened: (() -> Void)? public var revealOptionsInteractivelyClosed: (() -> Void)? public var revealOptionSelected: ((Option, Bool) -> Void)? @@ -779,7 +779,7 @@ open class ListItemSwipeOptionContainer: UIView, UIGestureRecognizerDelegate { } } - open func updateRevealOffsetInternal(offset: CGFloat, transition: Transition, completion: (() -> Void)? = nil) { + open func updateRevealOffsetInternal(offset: CGFloat, transition: ComponentTransition, completion: (() -> Void)? = nil) { self.revealOffset = offset guard let (size, leftInset, rightInset) = self.validLayout else { return @@ -856,7 +856,7 @@ open class ListItemSwipeOptionContainer: UIView, UIGestureRecognizerDelegate { if !self.revealOffset.isZero { self.recognizer?.becomeCancelled() } - let transition: Transition + let transition: ComponentTransition if animated { transition = .spring(duration: 0.3) } else { diff --git a/submodules/TelegramUI/Components/ListMultilineTextFieldItemComponent/Sources/ListMultilineTextFieldItemComponent.swift b/submodules/TelegramUI/Components/ListMultilineTextFieldItemComponent/Sources/ListMultilineTextFieldItemComponent.swift index 1a9ccf535f..0cfdd563cf 100644 --- a/submodules/TelegramUI/Components/ListMultilineTextFieldItemComponent/Sources/ListMultilineTextFieldItemComponent.swift +++ b/submodules/TelegramUI/Components/ListMultilineTextFieldItemComponent/Sources/ListMultilineTextFieldItemComponent.swift @@ -52,7 +52,7 @@ public final class ListMultilineTextFieldItemComponent: Component { public let updated: ((String) -> Void)? public let returnKeyAction: (() -> Void)? public let backspaceKeyAction: (() -> Void)? - public let textUpdateTransition: Transition + public let textUpdateTransition: ComponentTransition public let tag: AnyObject? public init( @@ -72,7 +72,7 @@ public final class ListMultilineTextFieldItemComponent: Component { updated: ((String) -> Void)? = nil, returnKeyAction: (() -> Void)? = nil, backspaceKeyAction: (() -> Void)? = nil, - textUpdateTransition: Transition = .immediate, + textUpdateTransition: ComponentTransition = .immediate, tag: AnyObject? = nil ) { self.externalState = externalState @@ -203,7 +203,7 @@ public final class ListMultilineTextFieldItemComponent: Component { } } - func update(component: ListMultilineTextFieldItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ListMultilineTextFieldItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -377,7 +377,7 @@ public final class ListMultilineTextFieldItemComponent: 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 } @@ -427,7 +427,7 @@ public final class ListMultilineTextFieldItemComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ListSectionComponent/Sources/ListSectionComponent.swift b/submodules/TelegramUI/Components/ListSectionComponent/Sources/ListSectionComponent.swift index e2727290a0..b8092ada4f 100644 --- a/submodules/TelegramUI/Components/ListSectionComponent/Sources/ListSectionComponent.swift +++ b/submodules/TelegramUI/Components/ListSectionComponent/Sources/ListSectionComponent.swift @@ -29,9 +29,9 @@ public final class ListSectionContentView: UIView { public let id: AnyHashable public let itemView: ItemView public let size: CGSize - public let transition: Transition + public let transition: ComponentTransition - public init(id: AnyHashable, itemView: ItemView, size: CGSize, transition: Transition) { + public init(id: AnyHashable, itemView: ItemView, size: CGSize, transition: ComponentTransition) { self.id = id self.itemView = itemView self.size = size @@ -109,7 +109,7 @@ public final class ListSectionContentView: UIView { self.highlightedItemId = itemId if configuration.extendsItemHighlightToSection { - let transition: Transition + let transition: ComponentTransition let backgroundColor: UIColor if itemId != nil { transition = .immediate @@ -122,15 +122,15 @@ public final class ListSectionContentView: UIView { self.externalContentBackgroundView.updateColor(color: backgroundColor, transition: transition) } else { if let previousHighlightedItemId, let previousItemView = self.itemViews[previousHighlightedItemId] { - Transition.easeInOut(duration: 0.2).setBackgroundColor(layer: previousItemView.highlightLayer, color: .clear) + ComponentTransition.easeInOut(duration: 0.2).setBackgroundColor(layer: previousItemView.highlightLayer, color: .clear) } if let itemId, let itemView = self.itemViews[itemId] { - Transition.immediate.setBackgroundColor(layer: itemView.highlightLayer, color: configuration.theme.list.itemHighlightedBackgroundColor) + ComponentTransition.immediate.setBackgroundColor(layer: itemView.highlightLayer, color: configuration.theme.list.itemHighlightedBackgroundColor) } } } - public func update(configuration: Configuration, width: CGFloat, leftInset: CGFloat, readyItems: [ReadyItem], transition: Transition) -> UpdateResult { + public func update(configuration: Configuration, width: CGFloat, leftInset: CGFloat, readyItems: [ReadyItem], transition: ComponentTransition) -> UpdateResult { self.configuration = configuration switch configuration.background { @@ -376,7 +376,7 @@ public final class ListSectionComponent: Component { return self.contentView.itemViews[id]?.contents.view } - func update(component: ListSectionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ListSectionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let headerSideInset: CGFloat = 16.0 @@ -511,7 +511,7 @@ public final class ListSectionComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -576,7 +576,7 @@ public final class ListSubSectionComponent: Component { return self.contentView.itemViews[id]?.contents.view } - func update(component: ListSubSectionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ListSubSectionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component var contentHeight: CGFloat = 0.0 @@ -642,7 +642,7 @@ public final class ListSubSectionComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ListTextFieldItemComponent/Sources/ListTextFieldItemComponent.swift b/submodules/TelegramUI/Components/ListTextFieldItemComponent/Sources/ListTextFieldItemComponent.swift index 3f6e7c4265..9a67b39016 100644 --- a/submodules/TelegramUI/Components/ListTextFieldItemComponent/Sources/ListTextFieldItemComponent.swift +++ b/submodules/TelegramUI/Components/ListTextFieldItemComponent/Sources/ListTextFieldItemComponent.swift @@ -144,7 +144,7 @@ public final class ListTextFieldItemComponent: Component { return false } - func update(component: ListTextFieldItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ListTextFieldItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -248,7 +248,7 @@ public final class ListTextFieldItemComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/LottieComponent/Sources/LottieComponent.swift b/submodules/TelegramUI/Components/LottieComponent/Sources/LottieComponent.swift index 28b991d616..5fdf32e458 100644 --- a/submodules/TelegramUI/Components/LottieComponent/Sources/LottieComponent.swift +++ b/submodules/TelegramUI/Components/LottieComponent/Sources/LottieComponent.swift @@ -408,7 +408,7 @@ public final class LottieComponent: Component { } } - func update(component: LottieComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: LottieComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousComponent = self.component self.component = component @@ -470,7 +470,7 @@ public final class LottieComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/AdjustmentsComponent.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/AdjustmentsComponent.swift index bc3c5a6c00..69a75e3123 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/AdjustmentsComponent.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/AdjustmentsComponent.swift @@ -88,7 +88,7 @@ final class AdjustmentSliderComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: AdjustmentSliderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: AdjustmentSliderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -104,7 +104,7 @@ final class AdjustmentSliderComponent: Component { } } isTrackingUpdated(isTracking) - let transition: Transition + let transition: ComponentTransition if isTracking { transition = .immediate } else { @@ -219,7 +219,7 @@ final class AdjustmentSliderComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -276,7 +276,7 @@ final class AdjustmentsComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: AdjustmentsComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: AdjustmentsComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -289,7 +289,7 @@ final class AdjustmentsComponent: Component { let tool = component.tools[i] if tool.key != trackingTool && i < self.toolViews.count { if let view = self.toolViews[i].view { - let transition: Transition + let transition: ComponentTransition if isTracking { transition = .immediate } else { @@ -381,7 +381,7 @@ final class AdjustmentsComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -440,7 +440,7 @@ final class AdjustmentsScreenComponent: Component { } } - func update(component: AdjustmentsScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: AdjustmentsScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -452,7 +452,7 @@ final class AdjustmentsScreenComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/BlurComponent.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/BlurComponent.swift index cc3918ba74..6164834f2e 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/BlurComponent.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/BlurComponent.swift @@ -52,7 +52,7 @@ private final class BlurModeComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: BlurModeComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BlurModeComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -108,7 +108,7 @@ private final class BlurModeComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -186,7 +186,7 @@ final class BlurComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: BlurComponent, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + func update(component: BlurComponent, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state state.value = component.value @@ -302,7 +302,7 @@ final class BlurComponent: Component { component.isTrackingUpdated(isTracking) if let self { - let transition: Transition + let transition: ComponentTransition if isTracking { transition = .immediate } else { @@ -391,7 +391,7 @@ final class BlurComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -751,7 +751,7 @@ final class BlurScreenComponent: Component { return true } - func update(component: BlurScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BlurScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -852,7 +852,7 @@ final class BlurScreenComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/CreateLinkScreen.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/CreateLinkScreen.swift index a094676e31..62f8048c6f 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/CreateLinkScreen.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/CreateLinkScreen.swift @@ -699,7 +699,7 @@ private final class LinkFieldComponent: Component { self.textField.becomeFirstResponder() } - func update(component: LinkFieldComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: LinkFieldComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.textField.textColor = component.textColor self.textField.text = component.text self.textField.font = Font.regular(17.0) @@ -750,7 +750,7 @@ private final class LinkFieldComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -856,7 +856,7 @@ private final class LinkPreviewComponent: Component { } } - func update(component: LinkPreviewComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: LinkPreviewComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme self.component = component self.state = state @@ -948,7 +948,7 @@ private final class LinkPreviewComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/CurvesComponent.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/CurvesComponent.swift index 27e38ffde6..924459dc45 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/CurvesComponent.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/CurvesComponent.swift @@ -26,7 +26,7 @@ private class HistogramView: UIView { fatalError("init(coder:) has not been implemented") } - func updateSize(size: CGSize, histogramBins: MediaEditorHistogram.HistogramBins?, color: UIColor, transition: Transition) { + func updateSize(size: CGSize, histogramBins: MediaEditorHistogram.HistogramBins?, color: UIColor, transition: ComponentTransition) { guard self.size != size || self.color != color || self.histogramBins != histogramBins else { return } @@ -36,7 +36,7 @@ private class HistogramView: UIView { self.update(transition: transition) } - func update(transition: Transition) { + func update(transition: ComponentTransition) { guard let size = self.size, let histogramBins = self.histogramBins, histogramBins.count > 0, let color = self.color else { self.shapeLayer.path = nil return @@ -141,7 +141,7 @@ final class CurvesComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: CurvesComponent, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + func update(component: CurvesComponent, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -159,7 +159,7 @@ final class CurvesComponent: Component { ), action: { [weak state] in state?.section = .all - state?.updated(transition: Transition(animation: .curve(duration: 0.2, curve: .easeInOut))) + state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut))) } ) ), @@ -187,7 +187,7 @@ final class CurvesComponent: Component { ), action: { [weak state] in state?.section = .red - state?.updated(transition: Transition(animation: .curve(duration: 0.2, curve: .easeInOut))) + state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut))) } ) ), @@ -215,7 +215,7 @@ final class CurvesComponent: Component { ), action: { [weak state] in state?.section = .green - state?.updated(transition: Transition(animation: .curve(duration: 0.2, curve: .easeInOut))) + state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut))) } ) ), @@ -243,7 +243,7 @@ final class CurvesComponent: Component { ), action: { [weak state] in state?.section = .blue - state?.updated(transition: Transition(animation: .curve(duration: 0.2, curve: .easeInOut))) + state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut))) } ) ), @@ -288,7 +288,7 @@ final class CurvesComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -505,7 +505,7 @@ final class CurvesScreenComponent: Component { } } - func update(component: CurvesScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: CurvesScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -730,7 +730,7 @@ final class CurvesScreenComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/FlipButtonContentComponent.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/FlipButtonContentComponent.swift index ae34bafa02..3947ddd1b1 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/FlipButtonContentComponent.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/FlipButtonContentComponent.swift @@ -61,7 +61,7 @@ final class FlipButtonContentComponent: Component { self.icon.add(animation, forKey: "transform.rotation.z") } - func update(component: FlipButtonContentComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: FlipButtonContentComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { self.component = component let size = CGSize(width: 48.0, height: 48.0) @@ -82,7 +82,7 @@ final class FlipButtonContentComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaCutoutScreen.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaCutoutScreen.swift index 10987de836..c43796108e 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaCutoutScreen.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaCutoutScreen.swift @@ -182,7 +182,7 @@ private final class MediaCutoutScreenComponent: Component { overlayAlpha = 0.0 backgroundAlpha = 1.0 } - let transition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut)) transition.setAlpha(view: overlayView, alpha: overlayAlpha) transition.setAlpha(view: backgroundView, alpha: backgroundAlpha) } @@ -270,7 +270,7 @@ private final class MediaCutoutScreenComponent: Component { return result } - func update(component: MediaCutoutScreenComponent, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + func update(component: MediaCutoutScreenComponent, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { let environment = environment[ViewControllerComponentContainer.Environment.self].value self.environment = environment @@ -458,7 +458,7 @@ private final class MediaCutoutScreenComponent: Component { return View() } - public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -520,7 +520,7 @@ final class MediaCutoutScreen: ViewController { return result } - func requestLayout(transition: Transition) { + func requestLayout(transition: ComponentTransition) { if let layout = self.validLayout { self.containerLayoutUpdated(layout: layout, forceUpdate: true, transition: transition) @@ -530,7 +530,7 @@ final class MediaCutoutScreen: ViewController { } } - func containerLayoutUpdated(layout: ContainerViewLayout, forceUpdate: Bool = false, animateOut: Bool = false, transition: Transition) { + func containerLayoutUpdated(layout: ContainerViewLayout, forceUpdate: Bool = false, animateOut: Bool = false, transition: ComponentTransition) { guard let controller = self.controller else { return } @@ -692,6 +692,6 @@ final class MediaCutoutScreen: ViewController { override func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) { super.containerLayoutUpdated(layout, transition: transition) - (self.displayNode as! Node).containerLayoutUpdated(layout: layout, transition: Transition(transition)) + (self.displayNode as! Node).containerLayoutUpdated(layout: layout, transition: ComponentTransition(transition)) } } diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift index 917324e44d..99dd44808b 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift @@ -442,7 +442,7 @@ final class MediaEditorScreenComponent: Component { }, requestLayout: { [weak self] transition in if let self { - (self.environment?.controller() as? MediaEditorScreen)?.node.requestLayout(forceUpdate: true, transition: Transition(transition)) + (self.environment?.controller() as? MediaEditorScreen)?.node.requestLayout(forceUpdate: true, transition: ComponentTransition(transition)) } } ) @@ -556,7 +556,7 @@ final class MediaEditorScreenComponent: Component { func animateOut(to source: TransitionAnimationSource) { self.isDismissed = true - let transition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut)) if let view = self.cancelButton.view { transition.setAlpha(view: view, alpha: 0.0) transition.setScale(view: view, scale: 0.1) @@ -642,7 +642,7 @@ final class MediaEditorScreenComponent: Component { } } - func animateOutToTool(inPlace: Bool, transition: Transition) { + func animateOutToTool(inPlace: Bool, transition: ComponentTransition) { if let view = self.cancelButton.view { view.alpha = 0.0 } @@ -671,7 +671,7 @@ final class MediaEditorScreenComponent: Component { } } - func animateInFromTool(inPlace: Bool, transition: Transition) { + func animateInFromTool(inPlace: Bool, transition: ComponentTransition) { if let view = self.cancelButton.view { view.alpha = 1.0 } @@ -715,7 +715,7 @@ final class MediaEditorScreenComponent: Component { return inputText } - func update(component: MediaEditorScreenComponent, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + func update(component: MediaEditorScreenComponent, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { guard !self.isDismissed else { return availableSize } @@ -1398,7 +1398,7 @@ final class MediaEditorScreenComponent: Component { } keyboardHeight = inputHeight - let fadeTransition = Transition(animation: .curve(duration: 0.3, curve: .easeInOut)) + let fadeTransition = ComponentTransition(animation: .curve(duration: 0.3, curve: .easeInOut)) if self.inputPanelExternalState.isEditing { fadeTransition.setAlpha(view: self.fadeView, alpha: 1.0) } else { @@ -2396,7 +2396,7 @@ final class MediaEditorScreenComponent: Component { return View() } - public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -2543,7 +2543,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate private var stickerCutoutStatusDisposable: Disposable? fileprivate var isCutout = false - private (set) var hasAnyChanges = false + private(set) var hasAnyChanges = false private var playbackPositionDisposable: Disposable? @@ -3906,7 +3906,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate if let view = self.componentHost.view as? MediaEditorScreenComponent.View { view.animateOut(to: .camera) } - let transition = Transition(animation: .curve(duration: 0.25, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut)) transition.setAlpha(view: self.previewContainerView, alpha: 0.0, completion: { _ in completion() }) @@ -3933,7 +3933,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate func animateOutToTool(tool: MediaEditorScreenComponent.DrawingScreenType, inPlace: Bool = false) { self.isDisplayingTool = tool - let transition: Transition = .easeInOut(duration: 0.2) + let transition: ComponentTransition = .easeInOut(duration: 0.2) if let view = self.componentHost.view as? MediaEditorScreenComponent.View { view.animateOutToTool(inPlace: inPlace, transition: transition) } @@ -3943,7 +3943,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate func animateInFromTool(inPlace: Bool = false) { self.isDisplayingTool = nil - let transition: Transition = .easeInOut(duration: 0.2) + let transition: ComponentTransition = .easeInOut(duration: 0.2) if let view = self.componentHost.view as? MediaEditorScreenComponent.View { view.animateInFromTool(inPlace: inPlace, transition: transition) } @@ -4588,7 +4588,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate return result } - func requestUpdate(hasAppeared: Bool = false, transition: Transition = .immediate) { + func requestUpdate(hasAppeared: Bool = false, transition: ComponentTransition = .immediate) { if let layout = self.validLayout { self.containerLayoutUpdated(layout: layout, hasAppeared: hasAppeared, transition: transition) } @@ -4649,14 +4649,14 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate private var previousDrawingData: Data? private var previousDrawingEntities: [DrawingEntity]? - func requestLayout(forceUpdate: Bool, transition: Transition) { + func requestLayout(forceUpdate: Bool, transition: ComponentTransition) { guard let layout = self.validLayout else { return } self.containerLayoutUpdated(layout: layout, forceUpdate: forceUpdate, hasAppeared: self.hasAppeared, transition: transition) } - func containerLayoutUpdated(layout: ContainerViewLayout, forceUpdate: Bool = false, hasAppeared: Bool = false, transition: Transition) { + func containerLayoutUpdated(layout: ContainerViewLayout, forceUpdate: Bool = false, hasAppeared: Bool = false, transition: ComponentTransition) { guard let controller = self.controller, !self.isDismissed else { return } @@ -7304,7 +7304,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate override public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) { super.containerLayoutUpdated(layout, transition: transition) - (self.displayNode as! Node).containerLayoutUpdated(layout: layout, transition: Transition(transition)) + (self.displayNode as! Node).containerLayoutUpdated(layout: layout, transition: ComponentTransition(transition)) } @available(iOSApplicationExtension 11.0, iOS 11.0, *) @@ -7615,7 +7615,7 @@ private final class ToolValueComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: ToolValueComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ToolValueComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousValue = self.component?.value self.component = component self.state = state @@ -7682,7 +7682,7 @@ private final class ToolValueComponent: Component { return View() } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -7734,7 +7734,7 @@ public final class BlurredGradientComponent: Component { private var gradientBackground = SimpleLayer() 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 @@ -7780,7 +7780,7 @@ public final class BlurredGradientComponent: Component { return View(color: nil, enableBlur: true) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaToolsScreen.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaToolsScreen.swift index 2336fce88b..1f94f2ff04 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaToolsScreen.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaToolsScreen.swift @@ -72,7 +72,7 @@ private final class ToolIconComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: ToolIconComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ToolIconComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -115,7 +115,7 @@ private final class ToolIconComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -333,7 +333,7 @@ private final class MediaToolsScreenComponent: Component { self.state?.updated() } - func update(component: MediaToolsScreenComponent, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + func update(component: MediaToolsScreenComponent, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { let environment = environment[ViewControllerComponentContainer.Environment.self].value self.environment = environment @@ -576,7 +576,7 @@ private final class MediaToolsScreenComponent: Component { var needsHistogram = false let screenSize: CGSize let optionsSize: CGSize - let optionsTransition: Transition = sectionChanged ? .immediate : transition + let optionsTransition: ComponentTransition = sectionChanged ? .immediate : transition switch component.section { case .adjustments: self.curvesState = nil @@ -688,7 +688,7 @@ private final class MediaToolsScreenComponent: Component { }, isTrackingUpdated: { [weak self] isTracking in if let self { - let transition: Transition + let transition: ComponentTransition if isTracking { transition = .immediate } else { @@ -746,7 +746,7 @@ private final class MediaToolsScreenComponent: Component { }, isTrackingUpdated: { [weak self] isTracking in if let self { - let transition: Transition + let transition: ComponentTransition if isTracking { transition = .immediate } else { @@ -798,7 +798,7 @@ private final class MediaToolsScreenComponent: Component { }, isTrackingUpdated: { [weak self] isTracking in if let self { - let transition: Transition + let transition: ComponentTransition if isTracking { transition = .immediate } else { @@ -833,7 +833,7 @@ private final class MediaToolsScreenComponent: Component { }, isTrackingUpdated: { [weak self] isTracking in if let self { - let transition: Transition + let transition: ComponentTransition if isTracking { transition = .immediate } else { @@ -948,7 +948,7 @@ private final class MediaToolsScreenComponent: Component { return View() } - public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -1003,7 +1003,7 @@ public final class MediaToolsScreen: ViewController { } } - func containerLayoutUpdated(layout: ContainerViewLayout, forceUpdate: Bool = false, animateOut: Bool = false, transition: Transition) { + func containerLayoutUpdated(layout: ContainerViewLayout, forceUpdate: Bool = false, animateOut: Bool = false, transition: ComponentTransition) { guard let controller = self.controller else { return } @@ -1064,7 +1064,7 @@ public final class MediaToolsScreen: ViewController { } } if let layout = self.validLayout { - self.containerLayoutUpdated(layout: layout, transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) + self.containerLayoutUpdated(layout: layout, transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) } } } @@ -1142,6 +1142,6 @@ public final class MediaToolsScreen: ViewController { override public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) { super.containerLayoutUpdated(layout, transition: transition) - (self.displayNode as! Node).containerLayoutUpdated(layout: layout, transition: Transition(transition)) + (self.displayNode as! Node).containerLayoutUpdated(layout: layout, transition: ComponentTransition(transition)) } } diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/SaveProgressScreen.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/SaveProgressScreen.swift index 123591de92..2c67a1c6df 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/SaveProgressScreen.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/SaveProgressScreen.swift @@ -70,7 +70,7 @@ private final class ProgressComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: ProgressComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ProgressComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -146,7 +146,7 @@ private final class ProgressComponent: Component { return View() } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -182,7 +182,7 @@ private final class BannerComponent: Component { private var component: BannerComponent? private weak var state: EmptyComponentState? - func update(component: BannerComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BannerComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -235,7 +235,7 @@ private final class BannerComponent: Component { return View() } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -308,7 +308,7 @@ public final class SaveProgressScreenComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: SaveProgressScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: SaveProgressScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let environment = environment[ViewControllerComponentContainer.Environment.self].value self.environment = environment @@ -378,7 +378,7 @@ public final class SaveProgressScreenComponent: Component { return View() } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -429,7 +429,7 @@ public final class SaveProgressScreen: ViewController { } } - func containerLayoutUpdated(layout: ContainerViewLayout, transition: Transition) { + func containerLayoutUpdated(layout: ContainerViewLayout, transition: ComponentTransition) { guard let controller = self.controller else { return } @@ -572,6 +572,6 @@ public final class SaveProgressScreen: ViewController { super.containerLayoutUpdated(layout, transition: transition) - (self.displayNode as! Node).containerLayoutUpdated(layout: layout, transition: Transition(transition)) + (self.displayNode as! Node).containerLayoutUpdated(layout: layout, transition: ComponentTransition(transition)) } } diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/StoryPreviewComponent.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/StoryPreviewComponent.swift index 70d1f620d2..572a04dd49 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/StoryPreviewComponent.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/StoryPreviewComponent.swift @@ -46,7 +46,7 @@ private final class AvatarComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: AvatarComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: AvatarComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -68,7 +68,7 @@ private final class AvatarComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -151,7 +151,7 @@ final class StoryPreviewComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: StoryPreviewComponent, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoryPreviewComponent, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -319,7 +319,7 @@ final class StoryPreviewComponent: Component { return View() } - public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/TintComponent.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/TintComponent.swift index 77be65864f..0f6a0afce0 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/TintComponent.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/TintComponent.swift @@ -56,7 +56,7 @@ private final class TintColorComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: TintColorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: TintColorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -94,7 +94,7 @@ private final class TintColorComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -176,7 +176,7 @@ final class TintComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: TintComponent, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + func update(component: TintComponent, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state state.shadowsValue = component.shadowsValue @@ -314,7 +314,7 @@ final class TintComponent: Component { component.isTrackingUpdated(isTracking) if let self { - let transition: Transition + let transition: ComponentTransition if isTracking { transition = .immediate } else { @@ -403,7 +403,7 @@ final class TintComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/MediaScrubberComponent/Sources/MediaScrubberComponent.swift b/submodules/TelegramUI/Components/MediaScrubberComponent/Sources/MediaScrubberComponent.swift index aa0a996ba5..c08a62d34e 100644 --- a/submodules/TelegramUI/Components/MediaScrubberComponent/Sources/MediaScrubberComponent.swift +++ b/submodules/TelegramUI/Components/MediaScrubberComponent/Sources/MediaScrubberComponent.swift @@ -313,7 +313,7 @@ public final class MediaScrubberComponent: Component { if let offset = self.mainAudioTrackOffset { position += offset } - let transition: Transition = .immediate + let transition: ComponentTransition = .immediate switch gestureRecognizer.state { case .began, .changed: self.isPanningCursor = true @@ -379,7 +379,7 @@ public final class MediaScrubberComponent: Component { self.cursorView.frame = cursorFrame(size: scrubberSize, height: self.effectiveCursorHeight, position: updatedPosition, duration: self.trimDuration) } - public func update(component: MediaScrubberComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(component: MediaScrubberComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let isFirstTime = self.component == nil self.component = component self.state = state @@ -392,7 +392,7 @@ public final class MediaScrubberComponent: Component { } var totalHeight: CGFloat = 0.0 - var trackLayout: [Int32: (CGRect, Transition, Bool)] = [:] + var trackLayout: [Int32: (CGRect, ComponentTransition, Bool)] = [:] if !component.tracks.contains(where: { $0.id == self.selectedTrackId }) { self.selectedTrackId = component.tracks.first(where: { $0.isMain })?.id ?? 0 @@ -636,7 +636,7 @@ public final class MediaScrubberComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: State, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -664,7 +664,7 @@ private class TrackView: UIView, UIScrollViewDelegate, UIGestureRecognizerDelega var onSelection: (Int32) -> Void = { _ in } var offsetUpdated: (Double, Bool) -> Void = { _, _ in } - var updated: (Transition) -> Void = { _ in } + var updated: (ComponentTransition) -> Void = { _ in } private(set) var isDragging = false private var ignoreScrollUpdates = false @@ -797,7 +797,7 @@ private class TrackView: UIView, UIScrollViewDelegate, UIGestureRecognizerDelega func updateOpaqueEdges( left: CGFloat, right: CGFloat, - transition: Transition + transition: ComponentTransition ) { self.leftOpaqueEdge = left self.rightOpaqueEdge = right @@ -814,7 +814,7 @@ private class TrackView: UIView, UIScrollViewDelegate, UIGestureRecognizerDelega private func updateThumbnailContainers( scrubberSize: CGSize, availableSize: CGSize, - transition: Transition + transition: ComponentTransition ) { let containerLeftEdge: CGFloat = self.leftOpaqueEdge ?? 0.0 let containerRightEdge: CGFloat = self.rightOpaqueEdge ?? availableSize.width @@ -831,7 +831,7 @@ private class TrackView: UIView, UIScrollViewDelegate, UIGestureRecognizerDelega isSelected: Bool, availableSize: CGSize, duration: Double, - transition: Transition + transition: ComponentTransition ) -> CGSize { let previousParams = self.params self.params = (track, isSelected, availableSize, duration) @@ -1171,7 +1171,7 @@ private class TrimView: UIView { var isHollow = false var trimUpdated: (Double, Double, Bool, Bool) -> Void = { _, _, _, _ in } - var updated: (Transition) -> Void = { _ in } + var updated: (ComponentTransition) -> Void = { _ in } override init(frame: CGRect) { super.init(frame: .zero) @@ -1233,7 +1233,7 @@ private class TrimView: UIView { let startValue = max(0.0, min(params.duration - duration, params.startPosition + delta * params.duration)) let endValue = startValue + duration - var transition: Transition = .immediate + var transition: ComponentTransition = .immediate switch gestureRecognizer.state { case .began, .changed: self.isPanningTrimHandle = true @@ -1273,7 +1273,7 @@ private class TrimView: UIView { endValue -= delta } - var transition: Transition = .immediate + var transition: ComponentTransition = .immediate switch gestureRecognizer.state { case .began, .changed: self.isPanningTrimHandle = true @@ -1311,7 +1311,7 @@ private class TrimView: UIView { startValue += delta } - var transition: Transition = .immediate + var transition: ComponentTransition = .immediate switch gestureRecognizer.state { case .began, .changed: self.isPanningTrimHandle = true @@ -1350,7 +1350,7 @@ private class TrimView: UIView { position: Double, minDuration: Double, maxDuration: Double, - transition: Transition + transition: ComponentTransition ) -> (leftHandleFrame: CGRect, rightHandleFrame: CGRect) { let isFirstTime = self.params == nil self.params = (scrubberSize, duration, startPosition, endPosition, position, minDuration, maxDuration) diff --git a/submodules/TelegramUI/Components/MessageInputActionButtonComponent/Sources/MessageInputActionButtonComponent.swift b/submodules/TelegramUI/Components/MessageInputActionButtonComponent/Sources/MessageInputActionButtonComponent.swift index 874c3d3d1e..e521dabde9 100644 --- a/submodules/TelegramUI/Components/MessageInputActionButtonComponent/Sources/MessageInputActionButtonComponent.swift +++ b/submodules/TelegramUI/Components/MessageInputActionButtonComponent/Sources/MessageInputActionButtonComponent.swift @@ -278,7 +278,7 @@ public final class MessageInputActionButtonComponent: Component { let scale: CGFloat = highlighted ? 0.6 : 1.0 - let transition = Transition(animation: .curve(duration: highlighted ? 0.5 : 0.3, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: highlighted ? 0.5 : 0.3, curve: .spring)) transition.setSublayerTransform(view: self, transform: CATransform3DMakeScale(scale, scale, 1.0)) } @@ -310,7 +310,7 @@ public final class MessageInputActionButtonComponent: Component { component.action(component.mode, .up, false) } - func update(component: MessageInputActionButtonComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: MessageInputActionButtonComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousComponent = self.component self.component = component self.componentState = state @@ -321,7 +321,7 @@ public final class MessageInputActionButtonComponent: Component { var transition = transition if transition.animation.isImmediate, let previousComponent, case .like = previousComponent.mode, case .like = component.mode, previousComponent.mode != component.mode, !isFirstTimeForStory { - transition = Transition(animation: .curve(duration: 0.25, curve: .easeInOut)) + transition = ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut)) } self.containerNode.isUserInteractionEnabled = component.longPressAction != nil @@ -661,7 +661,7 @@ public final class MessageInputActionButtonComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/ContextResultPanelComponent.swift b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/ContextResultPanelComponent.swift index 6d096bf69e..f1a70122bd 100644 --- a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/ContextResultPanelComponent.swift +++ b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/ContextResultPanelComponent.swift @@ -159,13 +159,13 @@ final class ContextResultPanelComponent: Component { fatalError("init(coder:) has not been implemented") } - func animateIn(transition: Transition) { + func animateIn(transition: ComponentTransition) { let offset = self.scrollView.contentOffset.y * -1.0 + 10.0 - Transition.immediate.setBoundsOrigin(view: self, origin: CGPoint(x: 0.0, y: -offset)) + ComponentTransition.immediate.setBoundsOrigin(view: self, origin: CGPoint(x: 0.0, y: -offset)) transition.setBoundsOrigin(view: self, origin: CGPoint(x: 0.0, y: 0.0)) } - func animateOut(transition: Transition, completion: @escaping () -> Void) { + func animateOut(transition: ComponentTransition, completion: @escaping () -> Void) { let offset = self.scrollView.contentOffset.y * -1.0 + 10.0 self.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false) transition.setBoundsOrigin(view: self, origin: CGPoint(x: 0.0, y: -offset), completion: { _ in @@ -179,7 +179,7 @@ final class ContextResultPanelComponent: Component { } } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { guard let component = self.component, let itemLayout = self.itemLayout else { return } @@ -273,7 +273,7 @@ final class ContextResultPanelComponent: Component { self.backgroundView.update(size: backgroundSize, cornerRadius: 11.0, transition: transition.containedViewLayoutTransition) } - func update(component: ContextResultPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ContextResultPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { var transition = transition let previousComponent = self.component self.component = component @@ -352,7 +352,7 @@ final class ContextResultPanelComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MediaPreviewPanelComponent.swift b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MediaPreviewPanelComponent.swift index f31ebd0b05..30281224ca 100644 --- a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MediaPreviewPanelComponent.swift +++ b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MediaPreviewPanelComponent.swift @@ -188,7 +188,7 @@ public final class MediaPreviewPanelComponent: Component { self.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25) } - public func animateOut(transition: Transition, completion: @escaping () -> Void) { + public func animateOut(transition: ComponentTransition, completion: @escaping () -> Void) { let vibrancyContainer = self.vibrancyContainer transition.setAlpha(view: vibrancyContainer, alpha: 0.0, completion: { [weak vibrancyContainer] _ in vibrancyContainer?.removeFromSuperview() @@ -230,7 +230,7 @@ public final class MediaPreviewPanelComponent: Component { } } - func update(component: MediaPreviewPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: MediaPreviewPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { if self.component == nil, case let .audio(audio) = component.mediaPreview { self.timerTextValue = textForDuration(seconds: audio.duration) } @@ -353,7 +353,7 @@ public final class MediaPreviewPanelComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MediaRecordingPanelComponent.swift b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MediaRecordingPanelComponent.swift index dd438fe314..c557d0997f 100644 --- a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MediaRecordingPanelComponent.swift +++ b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MediaRecordingPanelComponent.swift @@ -185,7 +185,7 @@ public final class MediaRecordingPanelComponent: Component { self.vibrancyCancelContainerView.layer.animatePosition(from: CGPoint(x: self.bounds.width, y: 0.0), to: CGPoint(), duration: 0.4, timingFunction: kCAMediaTimingFunctionSpring, additive: true) } - public func animateOut(transition: Transition, dismissRecording: Bool, completion: @escaping () -> Void) { + public func animateOut(transition: ComponentTransition, dismissRecording: Bool, completion: @escaping () -> Void) { guard let component = self.component else { completion() return @@ -201,7 +201,7 @@ public final class MediaRecordingPanelComponent: Component { if let indicatorView = self.indicator.view as? LottieComponent.View { indicatorView.playOnce(completion: { [weak indicatorView] in if let indicatorView { - let transition = Transition(animation: .curve(duration: 0.3, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.3, curve: .spring)) transition.setScale(view: indicatorView, scale: 0.001) } @@ -238,7 +238,7 @@ public final class MediaRecordingPanelComponent: Component { component.cancelAction() } - func update(component: MediaRecordingPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: MediaRecordingPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousComponent = self.component self.component = component self.state = state @@ -488,7 +488,7 @@ public final class MediaRecordingPanelComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift index 16102b6251..3c678b4622 100644 --- a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift +++ b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift @@ -702,7 +702,7 @@ public final class MessageInputPanelComponent: Component { return result } - func update(component: MessageInputPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: MessageInputPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousPlaceholder = self.component?.placeholder var insets = UIEdgeInsets(top: 14.0, left: 9.0, bottom: 6.0, right: 41.0) @@ -823,7 +823,7 @@ public final class MessageInputPanelComponent: Component { } } - let placeholderTransition: Transition = (previousPlaceholder != nil && previousPlaceholder != component.placeholder) ? Transition(animation: .curve(duration: 0.3, curve: .spring)) : .immediate + let placeholderTransition: ComponentTransition = (previousPlaceholder != nil && previousPlaceholder != component.placeholder) ? ComponentTransition(animation: .curve(duration: 0.3, curve: .spring)) : .immediate let placeholderSize = self.placeholder.update( transition: placeholderTransition, component: AnyComponent(AnimatedTextComponent( @@ -1292,7 +1292,7 @@ public final class MessageInputPanelComponent: Component { guard let self, let deleteMediaPreviewButtonView else { return } - let transition = Transition(animation: .curve(duration: 0.3, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.3, curve: .spring)) transition.setAlpha(view: deleteMediaPreviewButtonView, alpha: 0.0, completion: { [weak deleteMediaPreviewButtonView] _ in deleteMediaPreviewButtonView?.removeFromSuperview() }) @@ -1404,7 +1404,7 @@ public final class MessageInputPanelComponent: Component { self.currentMediaInputIsVoice = !self.currentMediaInputIsVoice self.hapticFeedback.impact(.medium) - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) }, updateMediaCancelFraction: { [weak self] mediaCancelFraction in guard let self else { @@ -1787,7 +1787,7 @@ public final class MessageInputPanelComponent: Component { attachmentButtonView.isHidden = true } mediaRecordingPanelView.animateOut(transition: transition, dismissRecording: wasRecordingDismissed, completion: { [weak self, weak mediaRecordingPanelView] in - let transition = Transition(animation: .curve(duration: 0.3, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.3, curve: .spring)) if let mediaRecordingPanelView = mediaRecordingPanelView { transition.setAlpha(view: mediaRecordingPanelView, alpha: 0.0, completion: { [weak mediaRecordingPanelView] _ in @@ -2166,7 +2166,7 @@ public final class MessageInputPanelComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/StickersResultPanelComponent.swift b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/StickersResultPanelComponent.swift index 18a6803502..ac6dfffa8e 100644 --- a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/StickersResultPanelComponent.swift +++ b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/StickersResultPanelComponent.swift @@ -335,13 +335,13 @@ final class StickersResultPanelComponent: Component { } } - func animateIn(transition: Transition) { + func animateIn(transition: ComponentTransition) { let offset = self.scrollView.contentOffset.y * -1.0 + 10.0 - Transition.immediate.setBoundsOrigin(view: self, origin: CGPoint(x: 0.0, y: -offset)) + ComponentTransition.immediate.setBoundsOrigin(view: self, origin: CGPoint(x: 0.0, y: -offset)) transition.setBoundsOrigin(view: self, origin: CGPoint(x: 0.0, y: 0.0)) } - func animateOut(transition: Transition, completion: @escaping () -> Void) { + func animateOut(transition: ComponentTransition, completion: @escaping () -> Void) { let offset = self.scrollView.contentOffset.y * -1.0 + 10.0 self.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false) transition.setBoundsOrigin(view: self, origin: CGPoint(x: 0.0, y: -offset), completion: { _ in @@ -355,7 +355,7 @@ final class StickersResultPanelComponent: Component { } } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { guard let component = self.component, let itemLayout = self.itemLayout else { return } @@ -422,7 +422,7 @@ final class StickersResultPanelComponent: Component { self.backgroundView.update(size: backgroundSize, cornerRadius: 11.0, transition: transition.containedViewLayoutTransition) } - func update(component: StickersResultPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StickersResultPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { //let itemUpdated = self.component?.results != component.results self.component = component @@ -495,7 +495,7 @@ final class StickersResultPanelComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/TimeoutContentComponent.swift b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/TimeoutContentComponent.swift index c8c854e20e..f6a139855e 100644 --- a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/TimeoutContentComponent.swift +++ b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/TimeoutContentComponent.swift @@ -59,7 +59,7 @@ public final class TimeoutContentComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: TimeoutContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: TimeoutContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousComponent = self.component self.component = component self.state = state @@ -120,7 +120,7 @@ public final class TimeoutContentComponent: Component { self.foreground.bounds = CGRect(origin: .zero, size: size) self.foreground.center = CGPoint(x: size.width / 2.0, y: size.height / 2.0) - let foregroundTransition: Transition = updated ? .easeInOut(duration: 0.2) : transition + let foregroundTransition: ComponentTransition = updated ? .easeInOut(duration: 0.2) : transition foregroundTransition.setScale(view: self.foreground, scale: component.isSelected ? 1.0 : 0.001) return size @@ -131,7 +131,7 @@ public final class TimeoutContentComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/NavigationSearchComponent/Sources/NavigationSearchComponent.swift b/submodules/TelegramUI/Components/NavigationSearchComponent/Sources/NavigationSearchComponent.swift index 6f311df38d..ded0329816 100644 --- a/submodules/TelegramUI/Components/NavigationSearchComponent/Sources/NavigationSearchComponent.swift +++ b/submodules/TelegramUI/Components/NavigationSearchComponent/Sources/NavigationSearchComponent.swift @@ -167,7 +167,7 @@ public final class NavigationSearchComponent: Component { } } - func update(component: NavigationSearchComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: NavigationSearchComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousComponent = self.component self.component = component @@ -332,7 +332,7 @@ public final class NavigationSearchComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/OptionButtonComponent/Sources/OptionButtonComponent.swift b/submodules/TelegramUI/Components/OptionButtonComponent/Sources/OptionButtonComponent.swift index d8c3b8e963..7d6679745a 100644 --- a/submodules/TelegramUI/Components/OptionButtonComponent/Sources/OptionButtonComponent.swift +++ b/submodules/TelegramUI/Components/OptionButtonComponent/Sources/OptionButtonComponent.swift @@ -64,7 +64,7 @@ public final class OptionButtonComponent: Component { guard let self else { return } - let transition = Transition(animation: .curve(duration: 0.25, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut)) let scale: CGFloat = highlighed ? 0.8 : 1.0 transition.setSublayerTransform(view: self, transform: CATransform3DMakeScale(scale, scale, 1.0)) } @@ -85,7 +85,7 @@ public final class OptionButtonComponent: Component { component.action() } - func update(component: OptionButtonComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: OptionButtonComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousComponent = self.component self.component = component @@ -135,7 +135,7 @@ public final class OptionButtonComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/PeerAllowedReactionsScreen/Sources/EmojiListInputComponent.swift b/submodules/TelegramUI/Components/PeerAllowedReactionsScreen/Sources/EmojiListInputComponent.swift index df49f1a264..44cef176da 100644 --- a/submodules/TelegramUI/Components/PeerAllowedReactionsScreen/Sources/EmojiListInputComponent.swift +++ b/submodules/TelegramUI/Components/PeerAllowedReactionsScreen/Sources/EmojiListInputComponent.swift @@ -164,7 +164,7 @@ final class EmojiListInputComponent: Component { } } - func update(component: EmojiListInputComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EmojiListInputComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let verticalInset: CGFloat = 12.0 let placeholderSpacing: CGFloat = 6.0 @@ -339,7 +339,7 @@ final class EmojiListInputComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/PeerAllowedReactionsScreen/Sources/EmojiSelectionComponent.swift b/submodules/TelegramUI/Components/PeerAllowedReactionsScreen/Sources/EmojiSelectionComponent.swift index 0fa2c00af1..eca6988d5e 100644 --- a/submodules/TelegramUI/Components/PeerAllowedReactionsScreen/Sources/EmojiSelectionComponent.swift +++ b/submodules/TelegramUI/Components/PeerAllowedReactionsScreen/Sources/EmojiSelectionComponent.swift @@ -152,13 +152,13 @@ public final class EmojiSelectionComponent: Component { deinit { } - public func internalRequestUpdate(transition: Transition) { + public func internalRequestUpdate(transition: ComponentTransition) { if let keyboardComponentView = self.keyboardView.view as? EntityKeyboardComponent.View { keyboardComponentView.state?.updated(transition: transition) } } - func update(component: EmojiSelectionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EmojiSelectionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.backgroundColor = component.backgroundColor let panelBackgroundColor = component.backgroundColor.withMultipliedAlpha(0.85) self.panelBackgroundView.updateColor(color: panelBackgroundColor, transition: .immediate) @@ -318,7 +318,7 @@ public final class EmojiSelectionComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/PeerAllowedReactionsScreen/Sources/ListSwitchItemComponent.swift b/submodules/TelegramUI/Components/PeerAllowedReactionsScreen/Sources/ListSwitchItemComponent.swift index 5bc2a48642..8a079687ea 100644 --- a/submodules/TelegramUI/Components/PeerAllowedReactionsScreen/Sources/ListSwitchItemComponent.swift +++ b/submodules/TelegramUI/Components/PeerAllowedReactionsScreen/Sources/ListSwitchItemComponent.swift @@ -52,7 +52,7 @@ final class ListSwitchItemComponent: Component { preconditionFailure() } - func update(component: ListSwitchItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ListSwitchItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -110,7 +110,7 @@ final class ListSwitchItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/PeerAllowedReactionsScreen/Sources/PeerAllowedReactionsScreen.swift b/submodules/TelegramUI/Components/PeerAllowedReactionsScreen/Sources/PeerAllowedReactionsScreen.swift index d131341e7c..746a4ca950 100644 --- a/submodules/TelegramUI/Components/PeerAllowedReactionsScreen/Sources/PeerAllowedReactionsScreen.swift +++ b/submodules/TelegramUI/Components/PeerAllowedReactionsScreen/Sources/PeerAllowedReactionsScreen.swift @@ -185,7 +185,7 @@ final class PeerAllowedReactionsScreenComponent: Component { self.updateScrolling(transition: .immediate) } - 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 { @@ -328,7 +328,7 @@ final class PeerAllowedReactionsScreenComponent: Component { self.environment?.controller()?.push(statsController) } - func update(component: PeerAllowedReactionsScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: PeerAllowedReactionsScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -1099,7 +1099,7 @@ final class PeerAllowedReactionsScreenComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoChatListPaneNode/Sources/PeerInfoChatListPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoChatListPaneNode/Sources/PeerInfoChatListPaneNode.swift index c3333137e2..a5b113f78b 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoChatListPaneNode/Sources/PeerInfoChatListPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoChatListPaneNode/Sources/PeerInfoChatListPaneNode.swift @@ -440,7 +440,7 @@ public final class PeerInfoChatListPaneNode: ASDisplayNode, PeerInfoPaneNode, AS chatController.displayNode.layer.allowsGroupOpacity = true if transition.isAnimated { - Transition.easeInOut(duration: 0.2).setAlpha(layer: chatController.displayNode.layer, alpha: 1.0) + ComponentTransition.easeInOut(duration: 0.2).setAlpha(layer: chatController.displayNode.layer, alpha: 1.0) } if self.searchNavigationContentNode?.contentNode !== contentNode { diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoCoverComponent/Sources/PeerInfoCoverComponent.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoCoverComponent/Sources/PeerInfoCoverComponent.swift index 855a87fe75..b41f278d4e 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoCoverComponent/Sources/PeerInfoCoverComponent.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoCoverComponent/Sources/PeerInfoCoverComponent.swift @@ -235,7 +235,7 @@ public final class PeerInfoCoverComponent: Component { } } - func update(component: PeerInfoCoverComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: PeerInfoCoverComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { if self.component?.peer?.profileBackgroundEmojiId != component.peer?.profileBackgroundEmojiId { if let profileBackgroundEmojiId = component.peer?.profileBackgroundEmojiId, profileBackgroundEmojiId != 0 { if self.patternContentsTarget == nil { @@ -412,7 +412,7 @@ public final class PeerInfoCoverComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoAvatarTransformContainerNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoAvatarTransformContainerNode.swift index ce140b8747..1d61323f75 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoAvatarTransformContainerNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoAvatarTransformContainerNode.swift @@ -137,7 +137,7 @@ final class PeerInfoAvatarTransformContainerNode: ASDisplayNode { lineWidth: 3.0, inactiveLineWidth: 1.5, forceRoundedRect: isForum - ), transition: Transition(transition)) + ), transition: ComponentTransition(transition)) } @objc private func tapGesture(_ recognizer: UITapGestureRecognizer) { diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift index 4e0574cab9..15b5abe989 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift @@ -795,7 +795,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { } let iconSize = self.titleCredibilityIconView.update( - transition: Transition(navigationTransition), + transition: ComponentTransition(navigationTransition), component: AnyComponent(EmojiStatusComponent( context: self.context, animationCache: self.animationCache, @@ -851,7 +851,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { containerSize: CGSize(width: 34.0, height: 34.0) ) let expandedIconSize = self.titleExpandedCredibilityIconView.update( - transition: Transition(navigationTransition), + transition: ComponentTransition(navigationTransition), component: AnyComponent(EmojiStatusComponent( context: self.context, animationCache: self.animationCache, @@ -903,7 +903,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { } let iconSize = self.titleVerifiedIconView.update( - transition: Transition(navigationTransition), + transition: ComponentTransition(navigationTransition), component: AnyComponent(EmojiStatusComponent( context: self.context, animationCache: self.animationCache, @@ -918,7 +918,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { containerSize: CGSize(width: 34.0, height: 34.0) ) let expandedIconSize = self.titleExpandedVerifiedIconView.update( - transition: Transition(navigationTransition), + transition: ComponentTransition(navigationTransition), component: AnyComponent(EmojiStatusComponent( context: self.context, animationCache: self.animationCache, @@ -2115,7 +2115,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { } let backgroundCoverSize = self.backgroundCover.update( - transition: Transition(transition), + transition: ComponentTransition(transition), component: AnyComponent(PeerInfoCoverComponent( context: self.context, peer: peer.flatMap(EnginePeer.init), diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoStoryGridScreen/Sources/PeerInfoStoryGridScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoStoryGridScreen/Sources/PeerInfoStoryGridScreen.swift index 579cfd04dd..e9fccb53a3 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoStoryGridScreen/Sources/PeerInfoStoryGridScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoStoryGridScreen/Sources/PeerInfoStoryGridScreen.swift @@ -306,7 +306,7 @@ final class PeerInfoStoryGridScreenComponent: Component { } private var isUpdating = false - func update(component: PeerInfoStoryGridScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: PeerInfoStoryGridScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -517,7 +517,7 @@ final class PeerInfoStoryGridScreenComponent: Component { self.selectedCount = selectedIds.count if applyState { - 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.environment?.controller() as? PeerInfoStoryGridScreen)?.updateTitle() }) @@ -548,7 +548,7 @@ final class PeerInfoStoryGridScreenComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoStoryGridScreen/Sources/StorySearchGridScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoStoryGridScreen/Sources/StorySearchGridScreen.swift index c78ed84d60..7d8dcc4205 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoStoryGridScreen/Sources/StorySearchGridScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoStoryGridScreen/Sources/StorySearchGridScreen.swift @@ -69,7 +69,7 @@ final class StorySearchGridScreenComponent: Component { } private var isUpdating = false - func update(component: StorySearchGridScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StorySearchGridScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -167,7 +167,7 @@ final class StorySearchGridScreenComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift index 1b93670460..3b308bd400 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift @@ -40,6 +40,7 @@ import CoreLocation import Geocoding import ItemListUI import MultilineTextComponent +import LocationUI private let mediaBadgeBackgroundColor = UIColor(white: 0.0, alpha: 0.6) private let mediaBadgeTextColor = UIColor.white @@ -970,7 +971,7 @@ private final class ItemTransitionView: UIView { fatalError("init(coder:) has not been implemented") } - func update(state: StoryContainerScreen.TransitionState, transition: Transition) { + func update(state: StoryContainerScreen.TransitionState, transition: ComponentTransition) { let size = state.sourceSize.interpolate(to: state.destinationSize, amount: state.progress) if let copyDurationLayer = self.copyDurationLayer, let durationLayerBottomLeftPosition = self.durationLayerBottomLeftPosition { @@ -1398,7 +1399,7 @@ private final class StorySearchHeaderComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: StorySearchHeaderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StorySearchHeaderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { if self.component?.theme !== component.theme { self.backgroundColor = component.theme.chatList.sectionHeaderFillColor } @@ -1436,7 +1437,7 @@ private final class StorySearchHeaderComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -1776,7 +1777,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr ) if let blurLayer = foundItem?.blurLayer { - let transition = Transition(animation: .curve(duration: 0.25, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut)) transition.setAlpha(layer: blurLayer, alpha: 0.0) } } @@ -1803,7 +1804,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr } if let foundItemLayer { if let blurLayer = foundItem?.blurLayer { - let transition = Transition(animation: .curve(duration: 0.25, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut)) transition.setAlpha(layer: blurLayer, alpha: 1.0) } @@ -2266,7 +2267,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr mapNode.mapNode.setMapCenter(coordinate: locationCoordinate, 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 { mapNode.mapNode.setMapCenter( coordinate: coordinate, @@ -2988,7 +2989,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr itemLayer.isHidden = itemHidden if let blurLayer = itemValue.blurLayer { - let transition = Transition.immediate + let transition = ComponentTransition.immediate if itemHidden { transition.setAlpha(layer: blurLayer, alpha: 0.0) } else { @@ -3143,7 +3144,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr self.searchHeader = searchHeader } let searchHeaderSize = searchHeader.update( - transition: Transition(transition), + transition: ComponentTransition(transition), component: AnyComponent(StorySearchHeaderComponent( theme: self.presentationData.theme, strings: self.presentationData.strings, @@ -3215,7 +3216,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr var bottomInset = bottomInset if self.isProfileEmbedded, let selectedIds = self.itemInteraction.selectedIds, self.canManageStories, case let .peer(peerId, _, isArchived) = self.scope { let selectionPanel: ComponentView - var selectionPanelTransition = Transition(transition) + var selectionPanelTransition = ComponentTransition(transition) if let current = self.selectionPanel { selectionPanel = current } else { @@ -3351,7 +3352,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr if case let .peer(_, _, isArchived) = self.scope, let items = self.items, items.items.isEmpty, items.count == 0 { let emptyStateView: ComponentView - var emptyStateTransition = Transition(transition) + var emptyStateTransition = ComponentTransition(transition) if let current = self.emptyStateView { emptyStateView = current } else { @@ -3412,13 +3413,13 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr } if self.didUpdateItemsOnce { - Transition(animation: .curve(duration: 0.2, curve: .easeInOut)).setBackgroundColor(view: self.view, color: backgroundColor) + ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut)).setBackgroundColor(view: self.view, color: backgroundColor) } else { self.view.backgroundColor = backgroundColor } } else { if let emptyStateView = self.emptyStateView { - let subTransition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut)) + let subTransition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut)) self.emptyStateView = nil if let emptyStateComponentView = emptyStateView.view { @@ -3772,7 +3773,7 @@ private final class BottomActionsPanelComponent: Component { } - func update(component: BottomActionsPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BottomActionsPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme self.component = component @@ -3877,7 +3878,7 @@ private final class BottomActionsPanelComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/PeerManagement/OldChannelsController/Sources/OldChannelsSearch.swift b/submodules/TelegramUI/Components/PeerManagement/OldChannelsController/Sources/OldChannelsSearch.swift index cb679ae79e..c042a08088 100644 --- a/submodules/TelegramUI/Components/PeerManagement/OldChannelsController/Sources/OldChannelsSearch.swift +++ b/submodules/TelegramUI/Components/PeerManagement/OldChannelsController/Sources/OldChannelsSearch.swift @@ -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 diff --git a/submodules/TelegramUI/Components/PlainButtonComponent/Sources/PlainButtonComponent.swift b/submodules/TelegramUI/Components/PlainButtonComponent/Sources/PlainButtonComponent.swift index 74a091362b..8e941d1105 100644 --- a/submodules/TelegramUI/Components/PlainButtonComponent/Sources/PlainButtonComponent.swift +++ b/submodules/TelegramUI/Components/PlainButtonComponent/Sources/PlainButtonComponent.swift @@ -130,7 +130,7 @@ public final class PlainButtonComponent: Component { self.contentContainer.alpha = 0.7 } 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.contentContainer.layer, scale: topScale) } } else { @@ -140,7 +140,7 @@ public final class PlainButtonComponent: Component { } if animateScale { - let transition = Transition(animation: .none) + let transition = ComponentTransition(animation: .none) transition.setScale(layer: self.contentContainer.layer, scale: 1.0) self.contentContainer.layer.animateScale(from: topScale, to: maxScale, duration: 0.13, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, removeOnCompletion: false, completion: { [weak self] _ in @@ -188,7 +188,7 @@ public final class PlainButtonComponent: Component { return nil } - func update(component: PlainButtonComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: PlainButtonComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.componentState = state @@ -294,7 +294,7 @@ public final class PlainButtonComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Premium/PremiumStarComponent/Sources/GiftAvatarComponent.swift b/submodules/TelegramUI/Components/Premium/PremiumStarComponent/Sources/GiftAvatarComponent.swift index 42472817e7..338b5441bf 100644 --- a/submodules/TelegramUI/Components/Premium/PremiumStarComponent/Sources/GiftAvatarComponent.swift +++ b/submodules/TelegramUI/Components/Premium/PremiumStarComponent/Sources/GiftAvatarComponent.swift @@ -307,7 +307,7 @@ public final class GiftAvatarComponent: Component { } } - func update(component: GiftAvatarComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: GiftAvatarComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { self.component = component self.setup() @@ -492,7 +492,7 @@ public final class GiftAvatarComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Premium/PremiumStarComponent/Sources/PremiumStarComponent.swift b/submodules/TelegramUI/Components/Premium/PremiumStarComponent/Sources/PremiumStarComponent.swift index 5460e41b6c..495541776b 100644 --- a/submodules/TelegramUI/Components/Premium/PremiumStarComponent/Sources/PremiumStarComponent.swift +++ b/submodules/TelegramUI/Components/Premium/PremiumStarComponent/Sources/PremiumStarComponent.swift @@ -656,7 +656,7 @@ public final class PremiumStarComponent: Component { node.addAnimation(springAnimation, forKey: "rotate") } - func update(component: PremiumStarComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: PremiumStarComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { self.component = component self.setup() @@ -680,7 +680,7 @@ public final class PremiumStarComponent: Component { return View(frame: CGRect(), isIntro: self.isIntro) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/TelegramUI/Components/PremiumPeerShortcutComponent/Sources/PremiumPeerShortcutComponent.swift b/submodules/TelegramUI/Components/PremiumPeerShortcutComponent/Sources/PremiumPeerShortcutComponent.swift index f65f1d3060..65694c3c57 100644 --- a/submodules/TelegramUI/Components/PremiumPeerShortcutComponent/Sources/PremiumPeerShortcutComponent.swift +++ b/submodules/TelegramUI/Components/PremiumPeerShortcutComponent/Sources/PremiumPeerShortcutComponent.swift @@ -56,7 +56,7 @@ public final class PremiumPeerShortcutComponent: Component { fatalError("init(coder:) has not been implemented") } - public func update(component: PremiumPeerShortcutComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(component: PremiumPeerShortcutComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -100,7 +100,7 @@ public final class PremiumPeerShortcutComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/SavedMessages/SavedMessagesScreen/Sources/SavedMessagesScreen.swift b/submodules/TelegramUI/Components/SavedMessages/SavedMessagesScreen/Sources/SavedMessagesScreen.swift index 9fd1b3bdab..45de9284bf 100644 --- a/submodules/TelegramUI/Components/SavedMessages/SavedMessagesScreen/Sources/SavedMessagesScreen.swift +++ b/submodules/TelegramUI/Components/SavedMessages/SavedMessagesScreen/Sources/SavedMessagesScreen.swift @@ -42,7 +42,7 @@ private final class SavedMessagesScreenComponent: Component { deinit { } - func update(component: SavedMessagesScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: SavedMessagesScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let environment = environment[ViewControllerComponentContainer.Environment.self].value let themeUpdated = self.environment?.theme !== environment.theme @@ -63,7 +63,7 @@ private final class SavedMessagesScreenComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ScrollComponent/Sources/ScrollComponent.swift b/submodules/TelegramUI/Components/ScrollComponent/Sources/ScrollComponent.swift index 9f4cb768d6..a868bbb53c 100644 --- a/submodules/TelegramUI/Components/ScrollComponent/Sources/ScrollComponent.swift +++ b/submodules/TelegramUI/Components/ScrollComponent/Sources/ScrollComponent.swift @@ -108,7 +108,7 @@ public final class ScrollComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: ScrollComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ScrollComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let contentSize = self.contentView.update( transition: transition, component: component.content, @@ -144,7 +144,7 @@ public final class ScrollComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/SendInviteLinkScreen/Sources/PeerListItemComponent.swift b/submodules/TelegramUI/Components/SendInviteLinkScreen/Sources/PeerListItemComponent.swift index 55e3f10ea6..bf0e0b0cd1 100644 --- a/submodules/TelegramUI/Components/SendInviteLinkScreen/Sources/PeerListItemComponent.swift +++ b/submodules/TelegramUI/Components/SendInviteLinkScreen/Sources/PeerListItemComponent.swift @@ -153,7 +153,7 @@ final class PeerListItemComponent: Component { component.action(peer) } - func update(component: PeerListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: PeerListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme var hasSelectionUpdated = false @@ -367,7 +367,7 @@ final class PeerListItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/SendInviteLinkScreen/Sources/SendInviteLinkScreen.swift b/submodules/TelegramUI/Components/SendInviteLinkScreen/Sources/SendInviteLinkScreen.swift index b75ef97dde..9cbdf82a8a 100644 --- a/submodules/TelegramUI/Components/SendInviteLinkScreen/Sources/SendInviteLinkScreen.swift +++ b/submodules/TelegramUI/Components/SendInviteLinkScreen/Sources/SendInviteLinkScreen.swift @@ -222,7 +222,7 @@ private final class SendInviteLinkScreenComponent: Component { } } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { guard let environment = self.environment, let controller = environment.controller(), let itemLayout = self.itemLayout else { return } @@ -266,7 +266,7 @@ private final class SendInviteLinkScreenComponent: Component { } } - func update(component: SendInviteLinkScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: SendInviteLinkScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let environment = environment[ViewControllerComponentContainer.Environment.self].value let themeUpdated = self.environment?.theme !== environment.theme @@ -785,7 +785,7 @@ private final class SendInviteLinkScreenComponent: Component { } else { self.selectedItems.insert(peer.id) } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .easeInOut))) } )), environment: {}, @@ -942,7 +942,7 @@ private final class SendInviteLinkScreenComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/ArchiveInfoScreen/Sources/ArchiveInfoContentComponent.swift b/submodules/TelegramUI/Components/Settings/ArchiveInfoScreen/Sources/ArchiveInfoContentComponent.swift index 023da0812a..bcc480988f 100644 --- a/submodules/TelegramUI/Components/Settings/ArchiveInfoScreen/Sources/ArchiveInfoContentComponent.swift +++ b/submodules/TelegramUI/Components/Settings/ArchiveInfoScreen/Sources/ArchiveInfoContentComponent.swift @@ -100,7 +100,7 @@ public final class ArchiveInfoContentComponent: Component { } } - func update(component: ArchiveInfoContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ArchiveInfoContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let sideInset: CGFloat = 16.0 @@ -326,7 +326,7 @@ public final class ArchiveInfoContentComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/ArchiveInfoScreen/Sources/ArchiveInfoScreen.swift b/submodules/TelegramUI/Components/Settings/ArchiveInfoScreen/Sources/ArchiveInfoScreen.swift index 59df7851f9..0bee05ace1 100644 --- a/submodules/TelegramUI/Components/Settings/ArchiveInfoScreen/Sources/ArchiveInfoScreen.swift +++ b/submodules/TelegramUI/Components/Settings/ArchiveInfoScreen/Sources/ArchiveInfoScreen.swift @@ -46,7 +46,7 @@ private final class ArchiveInfoSheetContentComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: ArchiveInfoSheetContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ArchiveInfoSheetContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let environment = environment[EnvironmentType.self].value @@ -122,7 +122,7 @@ private final class ArchiveInfoSheetContentComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -169,7 +169,7 @@ private final class ArchiveInfoScreenComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: ArchiveInfoScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ArchiveInfoScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let environment = environment[ViewControllerComponentContainer.Environment.self].value @@ -250,7 +250,7 @@ private final class ArchiveInfoScreenComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/AutomaticBusinessMessageListItemComponent.swift b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/AutomaticBusinessMessageListItemComponent.swift index 97ce5455f1..13114175db 100644 --- a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/AutomaticBusinessMessageListItemComponent.swift +++ b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/AutomaticBusinessMessageListItemComponent.swift @@ -96,7 +96,7 @@ final class GreetingMessageListItemComponent: Component { self.component?.action?() } - func update(component: GreetingMessageListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: GreetingMessageListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousComponent = self.component self.component = component self.componentState = state @@ -318,7 +318,7 @@ final class GreetingMessageListItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/AutomaticBusinessMessageSetupScreen.swift b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/AutomaticBusinessMessageSetupScreen.swift index 44d712798c..928ff7ce80 100644 --- a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/AutomaticBusinessMessageSetupScreen.swift +++ b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/AutomaticBusinessMessageSetupScreen.swift @@ -302,7 +302,7 @@ final class AutomaticBusinessMessageSetupScreenComponent: Component { } var scrolledUp = true - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { let navigationRevealOffsetY: CGFloat = 0.0 let navigationAlphaDistance: CGFloat = 16.0 @@ -574,7 +574,7 @@ final class AutomaticBusinessMessageSetupScreenComponent: Component { } } - func update(component: AutomaticBusinessMessageSetupScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: AutomaticBusinessMessageSetupScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -675,7 +675,7 @@ final class AutomaticBusinessMessageSetupScreenComponent: Component { self.component = component self.state = state - let alphaTransition: Transition = transition.animation.isImmediate ? transition : transition.withAnimation(.curve(duration: 0.25, curve: .easeInOut)) + let alphaTransition: ComponentTransition = transition.animation.isImmediate ? transition : transition.withAnimation(.curve(duration: 0.25, curve: .easeInOut)) if themeUpdated { self.backgroundColor = environment.theme.list.blocksBackgroundColor @@ -1536,7 +1536,7 @@ final class AutomaticBusinessMessageSetupScreenComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/BottomPanelComponent.swift b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/BottomPanelComponent.swift index 2dd0f3bae7..75f84dc8b1 100644 --- a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/BottomPanelComponent.swift +++ b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/BottomPanelComponent.swift @@ -55,7 +55,7 @@ final class BottomPanelComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: BottomPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BottomPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousComponent = self.component self.component = component self.componentState = state @@ -111,7 +111,7 @@ final class BottomPanelComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/BusinessLinkListItemComponent.swift b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/BusinessLinkListItemComponent.swift index 892f133f75..16d7b4488f 100644 --- a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/BusinessLinkListItemComponent.swift +++ b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/BusinessLinkListItemComponent.swift @@ -136,11 +136,11 @@ final class BusinessLinkListItemComponent: Component { } self.isExtractedToContextMenu = value - let mappedTransition: Transition + let mappedTransition: ComponentTransition if value { - mappedTransition = Transition(transition) + mappedTransition = ComponentTransition(transition) } else { - mappedTransition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut)) + mappedTransition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut)) } self.componentState?.updated(transition: mappedTransition) } @@ -162,7 +162,7 @@ final class BusinessLinkListItemComponent: Component { self.component?.action() } - func update(component: BusinessLinkListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BusinessLinkListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousComponent = self.component let _ = previousComponent @@ -334,7 +334,7 @@ final class BusinessLinkListItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/BusinessLinksSetupScreen.swift b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/BusinessLinksSetupScreen.swift index 86ea07efa8..e615cfd1eb 100644 --- a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/BusinessLinksSetupScreen.swift +++ b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/BusinessLinksSetupScreen.swift @@ -115,7 +115,7 @@ final class BusinessLinksSetupScreenComponent: Component { } var scrolledUp = true - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { let navigationRevealOffsetY: CGFloat = 0.0 let navigationAlphaDistance: CGFloat = 16.0 @@ -259,7 +259,7 @@ final class BusinessLinksSetupScreenComponent: Component { environment.controller()?.present(ShareController(context: component.context, subject: .url(link.url), showInChat: nil, externalShare: false, immediateExternalShare: false), in: .window(.root)) } - func update(component: BusinessLinksSetupScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BusinessLinksSetupScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -293,7 +293,7 @@ final class BusinessLinksSetupScreenComponent: Component { self.component = component self.state = state - let alphaTransition: Transition + let alphaTransition: ComponentTransition if !transition.animation.isImmediate { alphaTransition = .easeInOut(duration: 0.25) } else { @@ -653,7 +653,7 @@ final class BusinessLinksSetupScreenComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/QuickReplyEmptyStateComponent.swift b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/QuickReplyEmptyStateComponent.swift index 4582101ed6..cfd8eb14a2 100644 --- a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/QuickReplyEmptyStateComponent.swift +++ b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/QuickReplyEmptyStateComponent.swift @@ -57,7 +57,7 @@ final class QuickReplyEmptyStateComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: QuickReplyEmptyStateComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: QuickReplyEmptyStateComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousComponent = self.component self.component = component self.componentState = state @@ -180,7 +180,7 @@ final class QuickReplyEmptyStateComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/QuickReplySetupScreen.swift b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/QuickReplySetupScreen.swift index f2ebe3a305..b4c4009b35 100644 --- a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/QuickReplySetupScreen.swift +++ b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/QuickReplySetupScreen.swift @@ -389,7 +389,7 @@ final class QuickReplySetupScreenComponent: Component { } } - func update(size: CGSize, insets: UIEdgeInsets, transition: Transition) { + func update(size: CGSize, insets: UIEdgeInsets, transition: ComponentTransition) { let (listViewDuration, listViewCurve) = listViewAnimationDurationAndCurve(transition: transition.containedViewLayoutTransition) self.transaction( deleteIndices: [], @@ -723,7 +723,7 @@ final class QuickReplySetupScreenComponent: Component { insets: UIEdgeInsets, statusBarHeight: CGFloat, isModal: Bool, - transition: Transition, + transition: ComponentTransition, deferScrollApplication: Bool ) -> CGFloat { var rightButtons: [AnyComponentWithIdentity] = [] @@ -849,7 +849,7 @@ final class QuickReplySetupScreenComponent: Component { } } - private func updateNavigationScrolling(navigationHeight: CGFloat, transition: Transition) { + private func updateNavigationScrolling(navigationHeight: CGFloat, transition: ComponentTransition) { var mainOffset: CGFloat if let shortcutMessageList = self.shortcutMessageList, !shortcutMessageList.items.isEmpty { if let contentListNode = self.contentListNode { @@ -888,7 +888,7 @@ final class QuickReplySetupScreenComponent: Component { } } - func update(component: QuickReplySetupScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: QuickReplySetupScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -919,7 +919,7 @@ final class QuickReplySetupScreenComponent: Component { self.component = component self.state = state - let alphaTransition: Transition = transition.animation.isImmediate ? transition : transition.withAnimation(.curve(duration: 0.25, curve: .easeInOut)) + let alphaTransition: ComponentTransition = transition.animation.isImmediate ? transition : transition.withAnimation(.curve(duration: 0.25, curve: .easeInOut)) let _ = alphaTransition if themeUpdated { @@ -1271,7 +1271,7 @@ final class QuickReplySetupScreenComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/BirthdayPickerScreen/Sources/BirthdayPickerComponent.swift b/submodules/TelegramUI/Components/Settings/BirthdayPickerScreen/Sources/BirthdayPickerComponent.swift index 527dbd8f57..44a581ee4f 100644 --- a/submodules/TelegramUI/Components/Settings/BirthdayPickerScreen/Sources/BirthdayPickerComponent.swift +++ b/submodules/TelegramUI/Components/Settings/BirthdayPickerScreen/Sources/BirthdayPickerComponent.swift @@ -79,7 +79,7 @@ public final class BirthdayPickerComponent: Component { preconditionFailure() } - func update(component: BirthdayPickerComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BirthdayPickerComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let isFirstTime = self.component == nil self.component = component self.componentState = state @@ -239,7 +239,7 @@ public final class BirthdayPickerComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/BirthdayPickerScreen/Sources/BirthdayPickerContentComponent.swift b/submodules/TelegramUI/Components/Settings/BirthdayPickerScreen/Sources/BirthdayPickerContentComponent.swift index d4e311d8a0..16ed898dd4 100644 --- a/submodules/TelegramUI/Components/Settings/BirthdayPickerScreen/Sources/BirthdayPickerContentComponent.swift +++ b/submodules/TelegramUI/Components/Settings/BirthdayPickerScreen/Sources/BirthdayPickerContentComponent.swift @@ -83,7 +83,7 @@ public final class BirthdayPickerContentComponent: Component { } } - func update(component: BirthdayPickerContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BirthdayPickerContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -226,7 +226,7 @@ public final class BirthdayPickerContentComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/BirthdayPickerScreen/Sources/BirthdayPickerScreen.swift b/submodules/TelegramUI/Components/Settings/BirthdayPickerScreen/Sources/BirthdayPickerScreen.swift index ac5ec472d0..f3de37cbbe 100644 --- a/submodules/TelegramUI/Components/Settings/BirthdayPickerScreen/Sources/BirthdayPickerScreen.swift +++ b/submodules/TelegramUI/Components/Settings/BirthdayPickerScreen/Sources/BirthdayPickerScreen.swift @@ -53,7 +53,7 @@ private final class BirthdayPickerSheetContentComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: BirthdayPickerSheetContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BirthdayPickerSheetContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let environment = environment[EnvironmentType.self].value @@ -157,7 +157,7 @@ private final class BirthdayPickerSheetContentComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -205,7 +205,7 @@ private final class BirthdayPickerScreenComponent: Component { } private var didAppear = false - func update(component: BirthdayPickerScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BirthdayPickerScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let environment = environment[ViewControllerComponentContainer.Environment.self].value @@ -291,7 +291,7 @@ private final class BirthdayPickerScreenComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/BoostLevelIconComponent/Sources/BoostLevelIconComponent.swift b/submodules/TelegramUI/Components/Settings/BoostLevelIconComponent/Sources/BoostLevelIconComponent.swift index 5f8d9d42d9..81ec76f944 100644 --- a/submodules/TelegramUI/Components/Settings/BoostLevelIconComponent/Sources/BoostLevelIconComponent.swift +++ b/submodules/TelegramUI/Components/Settings/BoostLevelIconComponent/Sources/BoostLevelIconComponent.swift @@ -80,7 +80,7 @@ public final class BoostLevelIconComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: BoostLevelIconComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BoostLevelIconComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { if self.component != component { self.imageView.image = generateDisclosureActionBoostLevelBadgeImage(text: component.strings.Channel_Appearance_BoostLevel("\(component.level)").string) } @@ -99,7 +99,7 @@ public final class BoostLevelIconComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/BusinessHoursSetupScreen/Sources/BusinessDaySetupScreen.swift b/submodules/TelegramUI/Components/Settings/BusinessHoursSetupScreen/Sources/BusinessDaySetupScreen.swift index 35689013c9..66fbf35d6b 100644 --- a/submodules/TelegramUI/Components/Settings/BusinessHoursSetupScreen/Sources/BusinessDaySetupScreen.swift +++ b/submodules/TelegramUI/Components/Settings/BusinessHoursSetupScreen/Sources/BusinessDaySetupScreen.swift @@ -144,7 +144,7 @@ final class BusinessDaySetupScreenComponent: Component { } var scrolledUp = true - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { let navigationRevealOffsetY: CGFloat = 0.0 let navigationAlphaDistance: CGFloat = 16.0 @@ -233,7 +233,7 @@ final class BusinessDaySetupScreenComponent: Component { } } - func update(component: BusinessDaySetupScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BusinessDaySetupScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -483,7 +483,7 @@ final class BusinessDaySetupScreenComponent: Component { if let rangeSectionView = rangeSection.view { if !transition.animation.isImmediate { - Transition.easeInOut(duration: 0.2).setAlpha(view: rangeSectionView, alpha: 0.0, completion: { [weak rangeSectionView] _ in + ComponentTransition.easeInOut(duration: 0.2).setAlpha(view: rangeSectionView, alpha: 0.0, completion: { [weak rangeSectionView] _ in rangeSectionView?.removeFromSuperview() }) transition.setScale(view: rangeSectionView, scale: 0.001) @@ -616,7 +616,7 @@ final class BusinessDaySetupScreenComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/BusinessHoursSetupScreen/Sources/BusinessHoursSetupScreen.swift b/submodules/TelegramUI/Components/Settings/BusinessHoursSetupScreen/Sources/BusinessHoursSetupScreen.swift index 7166538490..f1b2d19657 100644 --- a/submodules/TelegramUI/Components/Settings/BusinessHoursSetupScreen/Sources/BusinessHoursSetupScreen.swift +++ b/submodules/TelegramUI/Components/Settings/BusinessHoursSetupScreen/Sources/BusinessHoursSetupScreen.swift @@ -339,7 +339,7 @@ final class BusinessHoursSetupScreenComponent: Component { } var scrolledUp = true - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { let navigationRevealOffsetY: CGFloat = 0.0 let navigationAlphaDistance: CGFloat = 16.0 @@ -368,7 +368,7 @@ final class BusinessHoursSetupScreenComponent: Component { } } - func update(component: BusinessHoursSetupScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BusinessHoursSetupScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -817,7 +817,7 @@ final class BusinessHoursSetupScreenComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/BusinessIntroSetupScreen/Sources/BusinessIntroSetupScreen.swift b/submodules/TelegramUI/Components/Settings/BusinessIntroSetupScreen/Sources/BusinessIntroSetupScreen.swift index 439834ef2f..679b12f004 100644 --- a/submodules/TelegramUI/Components/Settings/BusinessIntroSetupScreen/Sources/BusinessIntroSetupScreen.swift +++ b/submodules/TelegramUI/Components/Settings/BusinessIntroSetupScreen/Sources/BusinessIntroSetupScreen.swift @@ -219,7 +219,7 @@ final class BusinessIntroSetupScreenComponent: Component { } private var scrolledUp = true - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { let navigationRevealOffsetY: CGFloat = 0.0 let navigationAlphaDistance: CGFloat = 16.0 @@ -255,7 +255,7 @@ final class BusinessIntroSetupScreenComponent: Component { } } - func update(component: BusinessIntroSetupScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BusinessIntroSetupScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -690,7 +690,7 @@ final class BusinessIntroSetupScreenComponent: Component { self.component = component self.state = state - let alphaTransition: Transition + let alphaTransition: ComponentTransition if !transition.animation.isImmediate { alphaTransition = .easeInOut(duration: 0.25) } else { @@ -1156,7 +1156,7 @@ final class BusinessIntroSetupScreenComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/BusinessIntroSetupScreen/Sources/ChatIntroItemComponent.swift b/submodules/TelegramUI/Components/Settings/BusinessIntroSetupScreen/Sources/ChatIntroItemComponent.swift index b6b2de5752..f84b0ddd68 100644 --- a/submodules/TelegramUI/Components/Settings/BusinessIntroSetupScreen/Sources/ChatIntroItemComponent.swift +++ b/submodules/TelegramUI/Components/Settings/BusinessIntroSetupScreen/Sources/ChatIntroItemComponent.swift @@ -77,7 +77,7 @@ final class ChatIntroItemComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: ChatIntroItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ChatIntroItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.componentState = state @@ -156,7 +156,7 @@ final class ChatIntroItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/BusinessLocationSetupScreen/Sources/BusinessLocationSetupScreen.swift b/submodules/TelegramUI/Components/Settings/BusinessLocationSetupScreen/Sources/BusinessLocationSetupScreen.swift index 752d571ea5..4d9fe5574c 100644 --- a/submodules/TelegramUI/Components/Settings/BusinessLocationSetupScreen/Sources/BusinessLocationSetupScreen.swift +++ b/submodules/TelegramUI/Components/Settings/BusinessLocationSetupScreen/Sources/BusinessLocationSetupScreen.swift @@ -147,7 +147,7 @@ final class BusinessLocationSetupScreenComponent: Component { } var scrolledUp = true - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { let navigationRevealOffsetY: CGFloat = 0.0 let navigationAlphaDistance: CGFloat = 16.0 @@ -263,7 +263,7 @@ final class BusinessLocationSetupScreenComponent: Component { environment.controller()?.dismiss() } - func update(component: BusinessLocationSetupScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BusinessLocationSetupScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -286,7 +286,7 @@ final class BusinessLocationSetupScreenComponent: Component { self.component = component self.state = state - let alphaTransition: Transition + let alphaTransition: ComponentTransition if !transition.animation.isImmediate { alphaTransition = .easeInOut(duration: 0.25) } else { @@ -623,7 +623,7 @@ final class BusinessLocationSetupScreenComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/BusinessLocationSetupScreen/Sources/MapPreviewComponent.swift b/submodules/TelegramUI/Components/Settings/BusinessLocationSetupScreen/Sources/MapPreviewComponent.swift index 9e887c6279..b48375c117 100644 --- a/submodules/TelegramUI/Components/Settings/BusinessLocationSetupScreen/Sources/MapPreviewComponent.swift +++ b/submodules/TelegramUI/Components/Settings/BusinessLocationSetupScreen/Sources/MapPreviewComponent.swift @@ -84,7 +84,7 @@ final class MapPreviewComponent: Component { self.component?.action?() } - func update(component: MapPreviewComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: MapPreviewComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousComponent = self.component self.component = component self.componentState = state @@ -133,7 +133,7 @@ final class MapPreviewComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/Sources/BusinessRecipientListScreen.swift b/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/Sources/BusinessRecipientListScreen.swift index 7f82689d75..4ae6b6e02a 100644 --- a/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/Sources/BusinessRecipientListScreen.swift +++ b/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/Sources/BusinessRecipientListScreen.swift @@ -141,7 +141,7 @@ final class BusinessRecipientListScreenComponent: Component { } var scrolledUp = true - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { let navigationRevealOffsetY: CGFloat = 0.0 let navigationAlphaDistance: CGFloat = 16.0 @@ -348,7 +348,7 @@ final class BusinessRecipientListScreenComponent: Component { environment.controller()?.push(controller) } - func update(component: BusinessRecipientListScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: BusinessRecipientListScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -646,7 +646,7 @@ final class BusinessRecipientListScreenComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/Sources/ChatbotSearchResultItemComponent.swift b/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/Sources/ChatbotSearchResultItemComponent.swift index c9b085c8ed..7ac100863b 100644 --- a/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/Sources/ChatbotSearchResultItemComponent.swift +++ b/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/Sources/ChatbotSearchResultItemComponent.swift @@ -84,7 +84,7 @@ final class ChatbotSearchResultItemComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: ChatbotSearchResultItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ChatbotSearchResultItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -136,7 +136,7 @@ final class ChatbotSearchResultItemComponent: Component { if let addButtonView = addButton.view { if !transition.animation.isImmediate { transition.setScale(view: addButtonView, scale: 0.001) - Transition.easeInOut(duration: 0.2).setAlpha(view: addButtonView, alpha: 0.0, completion: { [weak addButtonView] _ in + ComponentTransition.easeInOut(duration: 0.2).setAlpha(view: addButtonView, alpha: 0.0, completion: { [weak addButtonView] _ in addButtonView?.removeFromSuperview() }) } else { @@ -186,7 +186,7 @@ final class ChatbotSearchResultItemComponent: Component { if let removeButtonView = removeButton.view { if !transition.animation.isImmediate { transition.setScale(view: removeButtonView, scale: 0.001) - Transition.easeInOut(duration: 0.2).setAlpha(view: removeButtonView, alpha: 0.0, completion: { [weak removeButtonView] _ in + ComponentTransition.easeInOut(duration: 0.2).setAlpha(view: removeButtonView, alpha: 0.0, completion: { [weak removeButtonView] _ in removeButtonView?.removeFromSuperview() }) } else { @@ -330,7 +330,7 @@ final class ChatbotSearchResultItemComponent: Component { self.addSubview(addButtonView) if !transition.animation.isImmediate { transition.animateScale(view: addButtonView, from: 0.001, to: 1.0) - Transition.easeInOut(duration: 0.2).animateAlpha(view: addButtonView, from: 0.0, to: 1.0) + ComponentTransition.easeInOut(duration: 0.2).animateAlpha(view: addButtonView, from: 0.0, to: 1.0) } } addButtonTransition.setFrame(view: addButtonView, frame: addButtonFrame) @@ -346,7 +346,7 @@ final class ChatbotSearchResultItemComponent: Component { self.addSubview(removeButtonView) if !transition.animation.isImmediate { transition.animateScale(view: removeButtonView, from: 0.001, to: 1.0) - Transition.easeInOut(duration: 0.2).animateAlpha(view: removeButtonView, from: 0.0, to: 1.0) + ComponentTransition.easeInOut(duration: 0.2).animateAlpha(view: removeButtonView, from: 0.0, to: 1.0) } } removeButtonTransition.setFrame(view: removeButtonView, frame: removeButtonFrame) @@ -396,7 +396,7 @@ final class ChatbotSearchResultItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/Sources/ChatbotSetupScreen.swift b/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/Sources/ChatbotSetupScreen.swift index 4571ab2149..20e342ee4d 100644 --- a/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/Sources/ChatbotSetupScreen.swift +++ b/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/Sources/ChatbotSetupScreen.swift @@ -220,7 +220,7 @@ final class ChatbotSetupScreenComponent: Component { } var scrolledUp = true - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { let navigationRevealOffsetY: CGFloat = 0.0 let navigationAlphaDistance: CGFloat = 16.0 @@ -476,7 +476,7 @@ final class ChatbotSetupScreenComponent: Component { } } - func update(component: ChatbotSetupScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ChatbotSetupScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -1076,7 +1076,7 @@ final class ChatbotSetupScreenComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/CollectibleItemInfoScreen/Sources/CollectibleItemInfoScreen.swift b/submodules/TelegramUI/Components/Settings/CollectibleItemInfoScreen/Sources/CollectibleItemInfoScreen.swift index acbd3defb8..de5d8b52b9 100644 --- a/submodules/TelegramUI/Components/Settings/CollectibleItemInfoScreen/Sources/CollectibleItemInfoScreen.swift +++ b/submodules/TelegramUI/Components/Settings/CollectibleItemInfoScreen/Sources/CollectibleItemInfoScreen.swift @@ -66,7 +66,7 @@ private final class PeerBadgeComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: PeerBadgeComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: PeerBadgeComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let height: CGFloat = 32.0 let avatarPadding: CGFloat = 1.0 @@ -127,7 +127,7 @@ private final class PeerBadgeComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -178,7 +178,7 @@ private final class CollectibleItemInfoScreenContentComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: CollectibleItemInfoScreenContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: CollectibleItemInfoScreenContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let environment = environment[EnvironmentType.self].value @@ -562,7 +562,7 @@ private final class CollectibleItemInfoScreenContentComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -603,7 +603,7 @@ private final class CollectibleItemInfoScreenComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: CollectibleItemInfoScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: CollectibleItemInfoScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let environment = environment[ViewControllerComponentContainer.Environment.self].value @@ -672,7 +672,7 @@ private final class CollectibleItemInfoScreenComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/CollectibleItemInfoScreen/Sources/CollectibleItemInfoScreenContentComponent.swift b/submodules/TelegramUI/Components/Settings/CollectibleItemInfoScreen/Sources/CollectibleItemInfoScreenContentComponent.swift index 288cbffad0..0264c33d31 100644 --- a/submodules/TelegramUI/Components/Settings/CollectibleItemInfoScreen/Sources/CollectibleItemInfoScreenContentComponent.swift +++ b/submodules/TelegramUI/Components/Settings/CollectibleItemInfoScreen/Sources/CollectibleItemInfoScreenContentComponent.swift @@ -100,7 +100,7 @@ import TelegramCore } } - func update(component: CollectibleItemInfoScreenContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: CollectibleItemInfoScreenContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let sideInset: CGFloat = 16.0 @@ -326,7 +326,7 @@ import TelegramCore return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/NewSessionInfoScreen/Sources/NewSessionInfoContentComponent.swift b/submodules/TelegramUI/Components/Settings/NewSessionInfoScreen/Sources/NewSessionInfoContentComponent.swift index 4fbe57d7b6..01c73a85a4 100644 --- a/submodules/TelegramUI/Components/Settings/NewSessionInfoScreen/Sources/NewSessionInfoContentComponent.swift +++ b/submodules/TelegramUI/Components/Settings/NewSessionInfoScreen/Sources/NewSessionInfoContentComponent.swift @@ -91,7 +91,7 @@ public final class NewSessionInfoContentComponent: Component { } } - func update(component: NewSessionInfoContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: NewSessionInfoContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let sideInset: CGFloat = 16.0 @@ -238,7 +238,7 @@ public final class NewSessionInfoContentComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/NewSessionInfoScreen/Sources/NewSessionInfoScreen.swift b/submodules/TelegramUI/Components/Settings/NewSessionInfoScreen/Sources/NewSessionInfoScreen.swift index 6e87955080..82b71044a4 100644 --- a/submodules/TelegramUI/Components/Settings/NewSessionInfoScreen/Sources/NewSessionInfoScreen.swift +++ b/submodules/TelegramUI/Components/Settings/NewSessionInfoScreen/Sources/NewSessionInfoScreen.swift @@ -51,7 +51,7 @@ private final class NewSessionInfoSheetContentComponent: Component { self.timer?.invalidate() } - func update(component: NewSessionInfoSheetContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: NewSessionInfoSheetContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { if self.timer == nil { self.timer = Foundation.Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true, block: { [weak self] _ in guard let self else { @@ -158,7 +158,7 @@ private final class NewSessionInfoSheetContentComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -202,7 +202,7 @@ private final class NewSessionInfoScreenComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: NewSessionInfoScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: NewSessionInfoScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let environment = environment[ViewControllerComponentContainer.Environment.self].value @@ -270,7 +270,7 @@ private final class NewSessionInfoScreenComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/ChannelAppearanceScreen.swift b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/ChannelAppearanceScreen.swift index c7204300d0..2ca28c9923 100644 --- a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/ChannelAppearanceScreen.swift +++ b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/ChannelAppearanceScreen.swift @@ -320,7 +320,7 @@ final class ChannelAppearanceScreenComponent: Component { } var scrolledUp = true - 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 { @@ -803,7 +803,7 @@ final class ChannelAppearanceScreenComponent: Component { return false } - func update(component: ChannelAppearanceScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ChannelAppearanceScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -1862,7 +1862,7 @@ final class ChannelAppearanceScreenComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/EmojiPickerItem.swift b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/EmojiPickerItem.swift index a795370b00..ed4f8b15d0 100644 --- a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/EmojiPickerItem.swift +++ b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/EmojiPickerItem.swift @@ -307,7 +307,7 @@ private final class EmojiSelectionComponent: Component { deinit { } - func update(component: EmojiSelectionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: EmojiSelectionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.backgroundColor = component.backgroundColor let panelBackgroundColor = component.backgroundColor.withMultipliedAlpha(0.85) self.panelBackgroundView.updateColor(color: panelBackgroundColor, transition: .immediate) @@ -388,7 +388,7 @@ private final class EmojiSelectionComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorProfilePreviewItem.swift b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorProfilePreviewItem.swift index 1ce8589d64..346979e7e5 100644 --- a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorProfilePreviewItem.swift +++ b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorProfilePreviewItem.swift @@ -378,7 +378,7 @@ final class PeerNameColorProfilePreviewItemNode: ListViewItemNode { } let iconSize = CGSize(width: 34.0, height: 34.0) let _ = icon.update( - transition: Transition(animation.transition), + transition: ComponentTransition(animation.transition), component: AnyComponent(EmojiStatusComponent( context: item.context, animationCache: item.context.animationCache, diff --git a/submodules/TelegramUI/Components/Settings/PeerSelectionScreen/Sources/PeerSelectionScreen.swift b/submodules/TelegramUI/Components/Settings/PeerSelectionScreen/Sources/PeerSelectionScreen.swift index e83928a46d..c095335e97 100644 --- a/submodules/TelegramUI/Components/Settings/PeerSelectionScreen/Sources/PeerSelectionScreen.swift +++ b/submodules/TelegramUI/Components/Settings/PeerSelectionScreen/Sources/PeerSelectionScreen.swift @@ -156,7 +156,7 @@ final class PeerSelectionScreenComponent: Component { super.init() } - func update(size: CGSize, insets: UIEdgeInsets, transition: Transition) { + func update(size: CGSize, insets: UIEdgeInsets, transition: ComponentTransition) { let (listViewDuration, listViewCurve) = listViewAnimationDurationAndCurve(transition: transition.containedViewLayoutTransition) self.transaction( deleteIndices: [], @@ -267,7 +267,7 @@ final class PeerSelectionScreenComponent: Component { insets: UIEdgeInsets, statusBarHeight: CGFloat, isModal: Bool, - transition: Transition, + transition: ComponentTransition, deferScrollApplication: Bool ) -> CGFloat { let rightButtons: [AnyComponentWithIdentity] = [] @@ -362,7 +362,7 @@ final class PeerSelectionScreenComponent: Component { } } - private func updateNavigationScrolling(navigationHeight: CGFloat, transition: Transition) { + private func updateNavigationScrolling(navigationHeight: CGFloat, transition: ComponentTransition) { var mainOffset: CGFloat if let contentListNode = self.contentListNode { switch contentListNode.visibleContentOffset() { @@ -401,7 +401,7 @@ final class PeerSelectionScreenComponent: Component { } } - func update(component: PeerSelectionScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: PeerSelectionScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -435,7 +435,7 @@ final class PeerSelectionScreenComponent: Component { self.component = component self.state = state - let alphaTransition: Transition = transition.animation.isImmediate ? transition : transition.withAnimation(.curve(duration: 0.25, curve: .easeInOut)) + let alphaTransition: ComponentTransition = transition.animation.isImmediate ? transition : transition.withAnimation(.curve(duration: 0.25, curve: .easeInOut)) let _ = alphaTransition if themeUpdated { @@ -650,7 +650,7 @@ final class PeerSelectionScreenComponent: Component { } else { if let loadingView = self.loadingView { self.loadingView = nil - let removeTransition: Transition = .easeInOut(duration: 0.2) + let removeTransition: ComponentTransition = .easeInOut(duration: 0.2) removeTransition.setAlpha(view: loadingView, alpha: 0.0, completion: { [weak loadingView] _ in loadingView?.removeFromSuperview() }) @@ -683,7 +683,7 @@ final class PeerSelectionScreenComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/CategoryListItemComponent.swift b/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/CategoryListItemComponent.swift index b696a371ab..644c55a512 100644 --- a/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/CategoryListItemComponent.swift +++ b/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/CategoryListItemComponent.swift @@ -126,7 +126,7 @@ final class CategoryListItemComponent: Component { } } - func update(component: CategoryListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: CategoryListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme var hasSelectionUpdated = false @@ -324,7 +324,7 @@ final class CategoryListItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/CountriesMultiselectionScreen.swift b/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/CountriesMultiselectionScreen.swift index 1559896c2f..94ffc18a84 100644 --- a/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/CountriesMultiselectionScreen.swift +++ b/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/CountriesMultiselectionScreen.swift @@ -318,7 +318,7 @@ final class CountriesMultiselectionScreenComponent: Component { } } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { guard let component = self.component, let environment = self.environment, let itemLayout = self.itemLayout else { return } @@ -443,7 +443,7 @@ final class CountriesMultiselectionScreenComponent: Component { return } let update = { - let transition = Transition(animation: .curve(duration: 0.35, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.35, curve: .spring)) self.state?.updated(transition: transition) if self.searchStateContext != nil { @@ -526,7 +526,7 @@ final class CountriesMultiselectionScreenComponent: Component { self.visibleSectionHeaders.removeValue(forKey: id) } - let fadeTransition = Transition.easeInOut(duration: 0.25) + let fadeTransition = ComponentTransition.easeInOut(duration: 0.25) if let searchStateContext = self.searchStateContext, case let .countriesSearch(query) = searchStateContext.subject, let value = searchStateContext.stateValue, value.sections.isEmpty { let sideInset: CGFloat = 44.0 let emptyAnimationHeight = 148.0 @@ -624,7 +624,7 @@ final class CountriesMultiselectionScreenComponent: Component { } } - func update(component: CountriesMultiselectionScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: CountriesMultiselectionScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { guard !self.isDismissed else { return availableSize } @@ -740,7 +740,7 @@ final class CountriesMultiselectionScreenComponent: Component { if let countryId = tokenId.base as? String { self.selectedCountries.removeAll(where: { $0 == countryId }) } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.35, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.35, curve: .spring))) } )), environment: {}, @@ -759,7 +759,7 @@ final class CountriesMultiselectionScreenComponent: Component { } self.searchStateContext = searchStateContext if applyState { - self.state?.updated(transition: Transition(animation: .none).withUserData(AnimationHint(contentReloaded: true))) + self.state?.updated(transition: ComponentTransition(animation: .none).withUserData(AnimationHint(contentReloaded: true))) } }) applyState = true @@ -995,7 +995,7 @@ final class CountriesMultiselectionScreenComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/CountryListItemComponent.swift b/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/CountryListItemComponent.swift index 66d8648e20..2bb961b055 100644 --- a/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/CountryListItemComponent.swift +++ b/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/CountryListItemComponent.swift @@ -95,7 +95,7 @@ final class CountryListItemComponent: Component { component.action() } - func update(component: CountryListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: CountryListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme var hasSelectionUpdated = false @@ -219,7 +219,7 @@ final class CountryListItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/OptionListItemComponent.swift b/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/OptionListItemComponent.swift index 77bcb6a0c5..f5de0074c1 100644 --- a/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/OptionListItemComponent.swift +++ b/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/OptionListItemComponent.swift @@ -86,7 +86,7 @@ final class OptionListItemComponent: Component { // } } - func update(component: OptionListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: OptionListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme self.component = component @@ -151,7 +151,7 @@ final class OptionListItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/SectionHeaderComponent.swift b/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/SectionHeaderComponent.swift index a62d388824..6d3d883311 100644 --- a/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/SectionHeaderComponent.swift +++ b/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/SectionHeaderComponent.swift @@ -62,7 +62,7 @@ final class SectionHeaderComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: SectionHeaderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: SectionHeaderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme self.component = component @@ -158,7 +158,7 @@ final class SectionHeaderComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/ShareWithPeersScreen.swift b/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/ShareWithPeersScreen.swift index e1a3c4f228..3d3f992e12 100644 --- a/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/ShareWithPeersScreen.swift +++ b/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/ShareWithPeersScreen.swift @@ -508,7 +508,7 @@ final class ShareWithPeersScreenComponent: Component { } } } else { - let transition = Transition(animation: .curve(duration: 0.3, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.3, curve: .spring)) self.state?.updated(transition: transition) self.updateModalOverlayTransition(transition: transition) } @@ -682,7 +682,7 @@ final class ShareWithPeersScreenComponent: Component { } else { self.selectedPeers = self.selectedPeers.filter { !peerIds.contains($0) } } - let transition = Transition(animation: .curve(duration: 0.35, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.35, curve: .spring)) self.state?.updated(transition: transition) } @@ -804,7 +804,7 @@ final class ShareWithPeersScreenComponent: Component { }) } - private func updateModalOverlayTransition(transition: Transition) { + private func updateModalOverlayTransition(transition: ComponentTransition) { guard let component = self.component, let environment = self.environment, let itemLayout = self.itemLayout, !self.isDismissed else { return } @@ -837,7 +837,7 @@ final class ShareWithPeersScreenComponent: Component { } } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { guard let component = self.component, let environment = self.environment, let itemLayout = self.itemLayout else { return } @@ -978,7 +978,7 @@ final class ShareWithPeersScreenComponent: Component { if let self { self.selectedPeers = [] self.selectedGroups = [] - let transition = Transition(animation: .curve(duration: 0.35, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.35, curve: .spring)) self.state?.updated(transition: transition) } } @@ -1236,7 +1236,7 @@ final class ShareWithPeersScreenComponent: Component { controller.dismiss() } } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.35, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.35, curve: .spring))) }, secondaryAction: { [weak self] in guard let self, let environment = self.environment, let controller = environment.controller() as? ShareWithPeersScreen else { @@ -1433,7 +1433,7 @@ final class ShareWithPeersScreenComponent: Component { return } let update = { - let transition = Transition(animation: .curve(duration: 0.35, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.35, curve: .spring)) self.state?.updated(transition: transition) if self.searchStateContext != nil { @@ -1560,7 +1560,7 @@ final class ShareWithPeersScreenComponent: Component { } else { self.selectedOptions.remove(optionId) } - let transition = Transition(animation: .curve(duration: 0.35, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.35, curve: .spring)) self.state?.updated(transition: transition) self.presentOptionsTooltip(optionId: optionId) @@ -1696,7 +1696,7 @@ final class ShareWithPeersScreenComponent: Component { self.visibleSectionFooters.removeValue(forKey: id) } - let fadeTransition = Transition.easeInOut(duration: 0.25) + let fadeTransition = ComponentTransition.easeInOut(duration: 0.25) var searchQuery: String? var searchResultsAreEmpty = false @@ -1867,7 +1867,7 @@ final class ShareWithPeersScreenComponent: Component { } private var currentHasChannels: Bool? - func update(component: ShareWithPeersScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ShareWithPeersScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { guard !self.isDismissed else { return availableSize } @@ -2074,7 +2074,7 @@ final class ShareWithPeersScreenComponent: Component { if self.selectedCategories.isEmpty { self.selectedCategories.insert(.everyone) } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.35, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.35, curve: .spring))) }, isFocusedUpdated: { [weak self] isFocused in guard let self else { @@ -2118,7 +2118,7 @@ final class ShareWithPeersScreenComponent: Component { } self.searchStateContext = searchStateContext if applyState { - self.state?.updated(transition: Transition(animation: .none).withUserData(AnimationHint(contentReloaded: true))) + self.state?.updated(transition: ComponentTransition(animation: .none).withUserData(AnimationHint(contentReloaded: true))) } }) applyState = true @@ -2822,7 +2822,7 @@ final class ShareWithPeersScreenComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/SliderComponent/Sources/SliderComponent.swift b/submodules/TelegramUI/Components/SliderComponent/Sources/SliderComponent.swift index 52abc1f328..c8a0e106e4 100644 --- a/submodules/TelegramUI/Components/SliderComponent/Sources/SliderComponent.swift +++ b/submodules/TelegramUI/Components/SliderComponent/Sources/SliderComponent.swift @@ -66,7 +66,7 @@ public final class SliderComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: SliderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: SliderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -153,7 +153,7 @@ public final class SliderComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stars/StarsImageComponent/Sources/StarsImageComponent.swift b/submodules/TelegramUI/Components/Stars/StarsImageComponent/Sources/StarsImageComponent.swift index 8d50ea4156..367cf39620 100644 --- a/submodules/TelegramUI/Components/Stars/StarsImageComponent/Sources/StarsImageComponent.swift +++ b/submodules/TelegramUI/Components/Stars/StarsImageComponent/Sources/StarsImageComponent.swift @@ -306,7 +306,7 @@ public final class StarsImageComponent: Component { self.fetchDisposable.dispose() } - func update(component: StarsImageComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: StarsImageComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { self.component = component let smallParticlesView: StarsParticlesView @@ -487,7 +487,7 @@ public final class StarsImageComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stars/StarsPurchaseScreen/Sources/ItemLoadingComponent.swift b/submodules/TelegramUI/Components/Stars/StarsPurchaseScreen/Sources/ItemLoadingComponent.swift index 24905d0bf9..96600232dd 100644 --- a/submodules/TelegramUI/Components/Stars/StarsPurchaseScreen/Sources/ItemLoadingComponent.swift +++ b/submodules/TelegramUI/Components/Stars/StarsPurchaseScreen/Sources/ItemLoadingComponent.swift @@ -63,7 +63,7 @@ final class ItemLoadingComponent: Component { }) } - func update(component: ItemLoadingComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ItemLoadingComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let isFirstTime = self.component == nil self.component = component @@ -86,7 +86,7 @@ final class ItemLoadingComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stars/StarsPurchaseScreen/Sources/StarsPurchaseScreen.swift b/submodules/TelegramUI/Components/Stars/StarsPurchaseScreen/Sources/StarsPurchaseScreen.swift index 56175544ac..acb58ac31c 100644 --- a/submodules/TelegramUI/Components/Stars/StarsPurchaseScreen/Sources/StarsPurchaseScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsPurchaseScreen/Sources/StarsPurchaseScreen.swift @@ -61,7 +61,7 @@ private final class StarsPurchaseScreenContentComponent: CombinedComponent { let forceDark: Bool let products: [StarsProduct]? let expanded: Bool - let stateUpdated: (Transition) -> Void + let stateUpdated: (ComponentTransition) -> Void let buy: (StarsProduct) -> Void init( @@ -76,7 +76,7 @@ private final class StarsPurchaseScreenContentComponent: CombinedComponent { forceDark: Bool, products: [StarsProduct]?, expanded: Bool, - stateUpdated: @escaping (Transition) -> Void, + stateUpdated: @escaping (ComponentTransition) -> Void, buy: @escaping (StarsProduct) -> Void ) { self.context = context @@ -369,7 +369,7 @@ private final class StarsPurchaseScreenContentComponent: CombinedComponent { }, highlighting: .disabled, updateIsHighlighted: { view, isHighlighted in - let transition: Transition = .easeInOut(duration: 0.25) + let transition: ComponentTransition = .easeInOut(duration: 0.25) if let superview = view.superview { transition.setScale(view: superview, scale: isHighlighted ? 0.9 : 1.0) } diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsBalanceComponent.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsBalanceComponent.swift index 63ebc61c45..0fa42c61c0 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsBalanceComponent.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsBalanceComponent.swift @@ -84,7 +84,7 @@ final class StarsBalanceComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: StarsBalanceComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StarsBalanceComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let sideInset: CGFloat = 16.0 @@ -182,7 +182,7 @@ final class StarsBalanceComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsOverviewItemComponent.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsOverviewItemComponent.swift index 8de9595897..667fdf49d2 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsOverviewItemComponent.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsOverviewItemComponent.swift @@ -69,7 +69,7 @@ final class StarsOverviewItemComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: StarsOverviewItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StarsOverviewItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let sideInset: CGFloat = 16.0 @@ -145,7 +145,7 @@ final class StarsOverviewItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsStatisticsScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsStatisticsScreen.swift index 4e207ec526..a641cfa2b2 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsStatisticsScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsStatisticsScreen.swift @@ -204,7 +204,7 @@ final class StarsStatisticsScreenComponent: Component { } } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { let scrollBounds = self.scrollView.bounds let isLockedAtPanels = scrollBounds.maxY == self.scrollView.contentSize.height @@ -212,7 +212,7 @@ final class StarsStatisticsScreenComponent: Component { let topContentOffset = self.scrollView.contentOffset.y let navigationBackgroundAlpha = min(20.0, max(0.0, topContentOffset - 95.0)) / 20.0 - let animatedTransition = Transition(animation: .curve(duration: 0.18, curve: .easeInOut)) + let animatedTransition = ComponentTransition(animation: .curve(duration: 0.18, curve: .easeInOut)) animatedTransition.setAlpha(view: self.navigationBackgroundView, alpha: navigationBackgroundAlpha) animatedTransition.setAlpha(layer: self.navigationSeparatorLayerContainer, alpha: navigationBackgroundAlpha) @@ -234,7 +234,7 @@ final class StarsStatisticsScreenComponent: Component { } private var isUpdating = false - func update(component: StarsStatisticsScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StarsStatisticsScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -564,7 +564,7 @@ final class StarsStatisticsScreenComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionScreen.swift index d36bfdf6e4..4c24194971 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionScreen.swift @@ -1035,7 +1035,7 @@ private final class PeerCellComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: PeerCellComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: PeerCellComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -1081,7 +1081,7 @@ private final class PeerCellComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -1125,7 +1125,7 @@ private final class TransactionCellComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: TransactionCellComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: TransactionCellComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -1201,7 +1201,7 @@ private final class TransactionCellComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsListPanelComponent.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsListPanelComponent.swift index 2efc927a33..967de5034f 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsListPanelComponent.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsListPanelComponent.swift @@ -157,7 +157,7 @@ final class StarsTransactionsListPanelComponent: Component { cancelContextGestures(view: scrollView) } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { guard let component = self.component, let environment = self.environment, let itemLayout = self.itemLayout else { return } @@ -342,7 +342,7 @@ final class StarsTransactionsListPanelComponent: Component { } private var isUpdating = false - func update(component: StarsTransactionsListPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StarsTransactionsListPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -452,7 +452,7 @@ final class StarsTransactionsListPanelComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -530,7 +530,7 @@ private final class AvatarComponent: Component { self.fetchDisposable.dispose() } - func update(component: AvatarComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: AvatarComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -649,7 +649,7 @@ private final class AvatarComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsPanelContainerComponent.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsPanelContainerComponent.swift index 2311dd02f2..1c4f3a36f9 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsPanelContainerComponent.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsPanelContainerComponent.swift @@ -249,7 +249,7 @@ private final class StarsTransactionsHeaderComponent: Component { } } - func update(component: StarsTransactionsHeaderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StarsTransactionsHeaderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme self.component = component @@ -348,7 +348,7 @@ private final class StarsTransactionsHeaderComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -377,7 +377,7 @@ final class StarsTransactionsPanelContainerComponent: Component { let dateTimeFormat: PresentationDateTimeFormat let insets: UIEdgeInsets let items: [Item] - let currentPanelUpdated: (AnyHashable, Transition) -> Void + let currentPanelUpdated: (AnyHashable, ComponentTransition) -> Void init( theme: PresentationTheme, @@ -385,7 +385,7 @@ final class StarsTransactionsPanelContainerComponent: Component { dateTimeFormat: PresentationDateTimeFormat, insets: UIEdgeInsets, items: [Item], - currentPanelUpdated: @escaping (AnyHashable, Transition) -> Void + currentPanelUpdated: @escaping (AnyHashable, ComponentTransition) -> Void ) { self.theme = theme self.strings = strings @@ -561,7 +561,7 @@ final class StarsTransactionsPanelContainerComponent: Component { } self.transitionFraction = 0.0 - let transition = Transition(animation: .curve(duration: 0.35, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.35, curve: .spring)) if let currentId = self.currentId { self.state?.updated(transition: transition) component.currentPanelUpdated(currentId, transition) @@ -576,12 +576,12 @@ final class StarsTransactionsPanelContainerComponent: Component { } } - func updateNavigationMergeFactor(value: CGFloat, transition: Transition) { + func updateNavigationMergeFactor(value: CGFloat, transition: ComponentTransition) { transition.setAlpha(view: self.topPanelMergedBackgroundView, alpha: value) transition.setAlpha(view: self.topPanelBackgroundView, alpha: 1.0 - value) } - func update(component: StarsTransactionsPanelContainerComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StarsTransactionsPanelContainerComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let environment = environment[StarsTransactionsPanelContainerEnvironment.self].value let themeUpdated = self.component?.theme !== component.theme @@ -649,7 +649,7 @@ final class StarsTransactionsPanelContainerComponent: Component { } if component.items.contains(where: { $0.id == id }) { self.currentId = id - let transition = Transition(animation: .curve(duration: 0.35, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.35, curve: .spring)) self.state?.updated(transition: transition) component.currentPanelUpdated(id, transition) } @@ -799,7 +799,7 @@ final class StarsTransactionsPanelContainerComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift index 9cc7ed0496..ac1ceed20a 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift @@ -194,7 +194,7 @@ final class StarsTransactionsScreenComponent: Component { } } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { let scrollBounds = self.scrollView.bounds let isLockedAtPanels = scrollBounds.maxY == self.scrollView.contentSize.height @@ -214,7 +214,7 @@ final class StarsTransactionsScreenComponent: Component { let fraction = max(0.0, min(1.0, titleOffset / titleOffsetDelta)) titleScale = 1.0 - fraction * 0.36 - let headerTransition: Transition = .immediate + let headerTransition: ComponentTransition = .immediate if let starView = self.starView.view { let starPosition = CGPoint(x: self.scrollView.frame.width / 2.0, y: topInset + starView.bounds.height / 2.0 - 30.0 - titleOffset * titleScale) @@ -230,7 +230,7 @@ final class StarsTransactionsScreenComponent: Component { headerTransition.setScale(view: titleView, scale: titleScale) } - let animatedTransition = Transition(animation: .curve(duration: 0.18, curve: .easeInOut)) + let animatedTransition = ComponentTransition(animation: .curve(duration: 0.18, curve: .easeInOut)) animatedTransition.setAlpha(view: self.navigationBackgroundView, alpha: navigationBackgroundAlpha) animatedTransition.setAlpha(layer: self.navigationSeparatorLayerContainer, alpha: navigationBackgroundAlpha) @@ -264,7 +264,7 @@ final class StarsTransactionsScreenComponent: Component { } private var isUpdating = false - func update(component: StarsTransactionsScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StarsTransactionsScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -329,7 +329,7 @@ final class StarsTransactionsScreenComponent: Component { contentHeight += environment.statusBarHeight - let starTransition: Transition = .immediate + let starTransition: ComponentTransition = .immediate var topBackgroundColor = environment.theme.list.plainBackgroundColor let bottomBackgroundColor = environment.theme.list.blocksBackgroundColor @@ -683,7 +683,7 @@ final class StarsTransactionsScreenComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsWithdrawScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsWithdrawScreen.swift index eea5e3f5b4..9d3f986914 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsWithdrawScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsWithdrawScreen.swift @@ -615,7 +615,7 @@ private final class AmountFieldComponent: Component { self.textField.selectAll(nil) } - func update(component: AmountFieldComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: AmountFieldComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.textField.textColor = component.textColor if let value = component.value { self.textField.text = "\(value)" @@ -673,7 +673,7 @@ private final class AmountFieldComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/StickerPickerScreen/Sources/StickerPickerScreen.swift b/submodules/TelegramUI/Components/StickerPickerScreen/Sources/StickerPickerScreen.swift index cafaed742f..6b0addf939 100644 --- a/submodules/TelegramUI/Components/StickerPickerScreen/Sources/StickerPickerScreen.swift +++ b/submodules/TelegramUI/Components/StickerPickerScreen/Sources/StickerPickerScreen.swift @@ -237,7 +237,7 @@ private final class StickerSelectionComponent: Component { self.state?.updated(transition: .easeInOut(duration: 0.2)) } - func update(component: StickerSelectionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StickerSelectionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.backgroundColor = component.backgroundColor let panelBackgroundColor = component.backgroundColor.withMultipliedAlpha(0.85) self.panelBackgroundView.updateColor(color: panelBackgroundColor, transition: .immediate) @@ -421,7 +421,7 @@ private final class StickerSelectionComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -1667,7 +1667,7 @@ public class StickerPickerScreen: ViewController { controller.present(tooltipController, in: .window(.root)) } - func containerLayoutUpdated(layout: ContainerViewLayout, navigationHeight: CGFloat, transition: Transition) { + func containerLayoutUpdated(layout: ContainerViewLayout, navigationHeight: CGFloat, transition: ComponentTransition) { guard let controller = self.controller else { return } @@ -1760,11 +1760,11 @@ public class StickerPickerScreen: ViewController { transition.setFrame(view: self.containerView, frame: clipFrame) if let content = self.content { - var stickersTransition: Transition = transition + var stickersTransition: ComponentTransition = transition if let scheduledEmojiContentAnimationHint = self.scheduledEmojiContentAnimationHint { self.scheduledEmojiContentAnimationHint = nil let contentAnimation = scheduledEmojiContentAnimationHint - stickersTransition = Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(contentAnimation) + stickersTransition = ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(contentAnimation) } var contentSize = self.hostView.update( @@ -1986,18 +1986,18 @@ public class StickerPickerScreen: 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, navigationHeight: navigationHeight, transition: Transition(transition)) + self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(transition)) } else { self.isExpanded = true - self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: Transition(.animated(duration: 0.3, curve: .easeInOut))) + self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(.animated(duration: 0.3, curve: .easeInOut))) } } else if (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, navigationHeight: navigationHeight, transition: Transition(transition)) + self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(transition)) } else { if let listNode = listNode { listNode.scroller.setContentOffset(CGPoint(), animated: false) @@ -2005,7 +2005,7 @@ public class StickerPickerScreen: ViewController { scrollView.setContentOffset(CGPoint(x: 0.0, y: -scrollView.contentInset.top), animated: false) } - self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: Transition(.animated(duration: 0.3, curve: .easeInOut))) + self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(.animated(duration: 0.3, curve: .easeInOut))) } if !dismissing { @@ -2018,7 +2018,7 @@ public class StickerPickerScreen: ViewController { case .cancelled: self.panGestureArguments = nil - self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: Transition(.animated(duration: 0.3, curve: .easeInOut))) + self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(.animated(duration: 0.3, curve: .easeInOut))) default: break } @@ -2033,7 +2033,7 @@ public class StickerPickerScreen: ViewController { guard let (layout, navigationHeight) = self.currentLayout else { return } - self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: Transition(transition)) + self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(transition)) } } @@ -2132,7 +2132,7 @@ public class StickerPickerScreen: ViewController { let navigationHeight: CGFloat = 56.0 - self.node.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: Transition(transition)) + self.node.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(transition)) } } @@ -2201,7 +2201,7 @@ private final class InteractiveStickerButtonContent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: InteractiveStickerButtonContent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: InteractiveStickerButtonContent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.backgroundLayer.backgroundColor = UIColor(rgb: 0xffffff, alpha: 0.11).cgColor let iconSize = self.icon.update( @@ -2262,7 +2262,7 @@ private final class InteractiveStickerButtonContent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -2304,7 +2304,7 @@ private final class InteractiveReactionButtonContent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: InteractiveReactionButtonContent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: InteractiveReactionButtonContent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let bounds = CGRect(origin: .zero, size: CGSize(width: 54.0, height: 54.0)) let iconSize = self.icon.update( transition: .immediate, @@ -2332,7 +2332,7 @@ private final class InteractiveReactionButtonContent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -2377,7 +2377,7 @@ private final class RoundVideoButtonContent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: RoundVideoButtonContent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: RoundVideoButtonContent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.backgroundLayer.backgroundColor = UIColor(rgb: 0xffffff, alpha: 0.11).cgColor let bounds = CGRect(origin: .zero, size: CGSize(width: 54.0, height: 54.0)) @@ -2411,7 +2411,7 @@ private final class RoundVideoButtonContent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -2548,7 +2548,7 @@ final class StoryStickersContentView: UIView, EmojiCustomContentView { fatalError("init(coder:) has not been implemented") } - func update(theme: PresentationTheme, strings: PresentationStrings, useOpaqueTheme: Bool, availableSize: CGSize, transition: Transition) -> CGSize { + func update(theme: PresentationTheme, strings: PresentationStrings, useOpaqueTheme: Bool, availableSize: CGSize, transition: ComponentTransition) -> CGSize { let padding: CGFloat = 22.0 let size = self.container.update( transition: transition, diff --git a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataButtonComponent.swift b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataButtonComponent.swift index f88407b6f4..b6ad5a2756 100644 --- a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataButtonComponent.swift +++ b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataButtonComponent.swift @@ -95,7 +95,7 @@ final class DataButtonComponent: Component { component.action() } - func update(component: DataButtonComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: DataButtonComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme self.component = component @@ -133,7 +133,7 @@ final class DataButtonComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataCategoriesComponent.swift b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataCategoriesComponent.swift index 5faf537638..cacfe2e0bf 100644 --- a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataCategoriesComponent.swift +++ b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataCategoriesComponent.swift @@ -91,7 +91,7 @@ final class DataCategoriesComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: DataCategoriesComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: DataCategoriesComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -186,7 +186,7 @@ final class DataCategoriesComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataCategoryItemCompoment.swift b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataCategoryItemCompoment.swift index 0e7f6e926d..fe49ed2ee1 100644 --- a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataCategoryItemCompoment.swift +++ b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataCategoryItemCompoment.swift @@ -119,7 +119,7 @@ private final class SubItemComponent: Component { return result } - func update(component: SubItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: SubItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme || self.component?.isIncoming != component.isIncoming self.component = component @@ -230,7 +230,7 @@ private final class SubItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -368,7 +368,7 @@ final class DataCategoryItemComponent: Component { return result } - func update(component: DataCategoryItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: DataCategoryItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme || self.component?.category.color != component.category.color self.component = component @@ -605,7 +605,7 @@ final class DataCategoryItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataUsageScreen.swift b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataUsageScreen.swift index d26fa0d642..fcc7febb34 100644 --- a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataUsageScreen.swift +++ b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataUsageScreen.swift @@ -433,7 +433,7 @@ final class DataUsageScreenComponent: Component { func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { let scrollBounds = self.scrollView.bounds if let headerView = self.segmentedControlView.view, let navigationMetrics = self.navigationMetrics { @@ -445,7 +445,7 @@ final class DataUsageScreenComponent: Component { headerOffset = min(headerOffset, minOffset) - let animatedTransition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut)) + let animatedTransition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut)) let navigationBackgroundAlpha: CGFloat = abs(headerOffset - minOffset) < 4.0 ? 1.0 : 0.0 let navigationButtonAlpha: CGFloat = scrollBounds.minY >= navigationMetrics.navigationHeight ? 0.0 : 1.0 @@ -485,7 +485,7 @@ final class DataUsageScreenComponent: Component { } } - func update(component: DataUsageScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: DataUsageScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -690,7 +690,7 @@ final class DataUsageScreenComponent: Component { if transition.animation.isImmediate, let animationHint { switch animationHint.value { case .modeChanged, .clearedItems: - pieChartTransition = Transition(animation: .curve(duration: 0.4, curve: .spring)) + pieChartTransition = ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)) } } @@ -876,7 +876,7 @@ final class DataUsageScreenComponent: Component { var labelTransition = transition if labelTransition.animation.isImmediate, let animationHint, animationHint.value == .modeChanged { - labelTransition = Transition(animation: .curve(duration: 0.3, curve: .easeInOut)) + labelTransition = ComponentTransition(animation: .curve(duration: 0.3, curve: .easeInOut)) } let chartTotalLabelSize = self.chartTotalLabel.update( @@ -922,7 +922,7 @@ final class DataUsageScreenComponent: Component { return } self.selectedStats = id - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(value: .modeChanged))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(value: .modeChanged))) })), environment: {}, containerSize: CGSize(width: availableSize.width - sideInset * 2.0, height: 100.0) @@ -953,7 +953,7 @@ final class DataUsageScreenComponent: Component { } else { self.expandedCategories.insert(key) } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } )), environment: {}, @@ -1234,8 +1234,8 @@ final class DataUsageScreenComponent: Component { #endif self.allStats = StatsSet() - //self.state?.updated(transition: Transition(animation: .none).withUserData(AnimationHint(value: .clearedItems))) - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(value: .clearedItems))) + //self.state?.updated(transition: ComponentTransition(animation: .none).withUserData(AnimationHint(value: .clearedItems))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(value: .clearedItems))) } } @@ -1243,7 +1243,7 @@ final class DataUsageScreenComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/PieChartComponent.swift b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/PieChartComponent.swift index 4878d848c5..8392185a9a 100644 --- a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/PieChartComponent.swift +++ b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/PieChartComponent.swift @@ -114,7 +114,7 @@ private final class ChartSelectionTooltip: Component { preconditionFailure() } - func update(component: ChartSelectionTooltip, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ChartSelectionTooltip, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let sideInset: CGFloat = 10.0 let height: CGFloat = 24.0 @@ -155,7 +155,7 @@ private final class ChartSelectionTooltip: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -1292,11 +1292,11 @@ final class PieChartComponent: Component { } else { self.selectedKey = nil } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) } } - func update(component: PieChartComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: PieChartComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let dataUpdated = self.component?.chartData != component.chartData self.state = state @@ -1389,7 +1389,7 @@ final class PieChartComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/SegmentControlComponent.swift b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/SegmentControlComponent.swift index e6ff6db679..8a65b0887f 100644 --- a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/SegmentControlComponent.swift +++ b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/SegmentControlComponent.swift @@ -66,7 +66,7 @@ final class SegmentControlComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: SegmentControlComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: SegmentControlComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme self.component = component @@ -106,7 +106,7 @@ final class SegmentControlComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageCategoriesComponent.swift b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageCategoriesComponent.swift index 44056145f0..2643e14d8d 100644 --- a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageCategoriesComponent.swift +++ b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageCategoriesComponent.swift @@ -101,7 +101,7 @@ final class StorageCategoriesComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: StorageCategoriesComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StorageCategoriesComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -270,7 +270,7 @@ final class StorageCategoriesComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageCategoryItemCompoment.swift b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageCategoryItemCompoment.swift index 10e3360b82..d22a9711d8 100644 --- a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageCategoryItemCompoment.swift +++ b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageCategoryItemCompoment.swift @@ -165,7 +165,7 @@ final class StorageCategoryItemComponent: Component { return result } - func update(component: StorageCategoryItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StorageCategoryItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme || self.component?.category.color != component.category.color self.component = component @@ -409,7 +409,7 @@ final class StorageCategoryItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageFileListPanelComponent.swift b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageFileListPanelComponent.swift index 0c5fd3d39a..771c64a641 100644 --- a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageFileListPanelComponent.swift +++ b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageFileListPanelComponent.swift @@ -270,11 +270,11 @@ private final class FileListItemComponent: Component { } self.isExtractedToContextMenu = value - let mappedTransition: Transition + let mappedTransition: ComponentTransition if value { - mappedTransition = Transition(transition) + mappedTransition = ComponentTransition(transition) } else { - mappedTransition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut)) + mappedTransition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut)) } self.state?.updated(transition: mappedTransition) } @@ -329,7 +329,7 @@ private final class FileListItemComponent: Component { component.action(component.messageId) } - func update(component: FileListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: FileListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme var hasSelectionUpdated = false @@ -622,7 +622,7 @@ private final class FileListItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -799,7 +799,7 @@ final class StorageFileListPanelComponent: Component { cancelContextGestures(view: scrollView) } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { guard let component = self.component, let environment = self.environment, let items = component.items, let itemLayout = self.itemLayout else { return } @@ -1003,7 +1003,7 @@ final class StorageFileListPanelComponent: Component { } } - func update(component: StorageFileListPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StorageFileListPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let environment = environment[StorageUsagePanelEnvironment.self].value @@ -1069,7 +1069,7 @@ final class StorageFileListPanelComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageKeepSizeComponent.swift b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageKeepSizeComponent.swift index 783f1b1901..f59150b4d1 100644 --- a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageKeepSizeComponent.swift +++ b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageKeepSizeComponent.swift @@ -96,7 +96,7 @@ final class StorageKeepSizeComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: StorageKeepSizeComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StorageKeepSizeComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme self.component = component @@ -201,7 +201,7 @@ final class StorageKeepSizeComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageMediaGridPanelComponent.swift b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageMediaGridPanelComponent.swift index 7d61c393cd..1768007949 100644 --- a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageMediaGridPanelComponent.swift +++ b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageMediaGridPanelComponent.swift @@ -150,7 +150,7 @@ private final class MediaGridLayer: SimpleLayer { })?.cgImage } - func updateSelection(size: CGSize, selectionState: SelectionState, theme: PresentationTheme, transition: Transition) { + func updateSelection(size: CGSize, selectionState: SelectionState, theme: PresentationTheme, transition: ComponentTransition) { if self.size == size && self.selectionState == selectionState && self.theme === theme { return } @@ -535,7 +535,7 @@ final class StorageMediaGridPanelComponent: Component { } } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { guard let component = self.component, let environment = self.environment, let items = component.items, let itemLayout = self.itemLayout else { return } @@ -613,7 +613,7 @@ final class StorageMediaGridPanelComponent: Component { } } - func update(component: StorageMediaGridPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StorageMediaGridPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let environment = environment[StorageUsagePanelEnvironment.self].value @@ -657,7 +657,7 @@ final class StorageMediaGridPanelComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StoragePeerListPanelComponent.swift b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StoragePeerListPanelComponent.swift index 6e9f125649..0313c71a8d 100644 --- a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StoragePeerListPanelComponent.swift +++ b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StoragePeerListPanelComponent.swift @@ -152,11 +152,11 @@ private final class PeerListItemComponent: Component { } self.isExtractedToContextMenu = value - let mappedTransition: Transition + let mappedTransition: ComponentTransition if value { - mappedTransition = Transition(transition) + mappedTransition = ComponentTransition(transition) } else { - mappedTransition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut)) + mappedTransition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut)) } self.state?.updated(transition: mappedTransition) } @@ -211,7 +211,7 @@ private final class PeerListItemComponent: Component { component.action(peer) } - func update(component: PeerListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: PeerListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme var hasSelectionUpdated = false @@ -372,7 +372,7 @@ private final class PeerListItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -549,7 +549,7 @@ final class StoragePeerListPanelComponent: Component { cancelContextGestures(view: scrollView) } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { guard let component = self.component, let environment = self.environment, let items = component.items, let itemLayout = self.itemLayout else { return } @@ -635,7 +635,7 @@ final class StoragePeerListPanelComponent: Component { } } - func update(component: StoragePeerListPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoragePeerListPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let environment = environment[StorageUsagePanelEnvironment.self].value @@ -699,7 +699,7 @@ final class StoragePeerListPanelComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StoragePeerTypeItemComponent.swift b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StoragePeerTypeItemComponent.swift index 8e54180182..07c7c18676 100644 --- a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StoragePeerTypeItemComponent.swift +++ b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StoragePeerTypeItemComponent.swift @@ -140,7 +140,7 @@ final class StoragePeerTypeItemComponent: Component { } func setHasAssociatedMenu(_ hasAssociatedMenu: Bool) { - let transition: Transition + let transition: ComponentTransition if hasAssociatedMenu { transition = .immediate } else { @@ -152,7 +152,7 @@ final class StoragePeerTypeItemComponent: Component { transition.setAlpha(view: self.arrowIconView, alpha: hasAssociatedMenu ? 0.5 : 1.0) } - func update(component: StoragePeerTypeItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoragePeerTypeItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme let previousComponent = self.component @@ -283,7 +283,7 @@ final class StoragePeerTypeItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageUsagePanelContainerComponent.swift b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageUsagePanelContainerComponent.swift index f3edec47c6..6c50be3b61 100644 --- a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageUsagePanelContainerComponent.swift +++ b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageUsagePanelContainerComponent.swift @@ -217,7 +217,7 @@ private final class StorageUsageHeaderComponent: Component { } } - func update(component: StorageUsageHeaderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StorageUsageHeaderComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme self.component = component @@ -316,7 +316,7 @@ private final class StorageUsageHeaderComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -345,7 +345,7 @@ final class StorageUsagePanelContainerComponent: Component { let dateTimeFormat: PresentationDateTimeFormat let insets: UIEdgeInsets let items: [Item] - let currentPanelUpdated: (AnyHashable, Transition) -> Void + let currentPanelUpdated: (AnyHashable, ComponentTransition) -> Void init( theme: PresentationTheme, @@ -353,7 +353,7 @@ final class StorageUsagePanelContainerComponent: Component { dateTimeFormat: PresentationDateTimeFormat, insets: UIEdgeInsets, items: [Item], - currentPanelUpdated: @escaping (AnyHashable, Transition) -> Void + currentPanelUpdated: @escaping (AnyHashable, ComponentTransition) -> Void ) { self.theme = theme self.strings = strings @@ -529,7 +529,7 @@ final class StorageUsagePanelContainerComponent: Component { } self.transitionFraction = 0.0 - let transition = Transition(animation: .curve(duration: 0.35, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.35, curve: .spring)) if let currentId = self.currentId { self.state?.updated(transition: transition) component.currentPanelUpdated(currentId, transition) @@ -544,12 +544,12 @@ final class StorageUsagePanelContainerComponent: Component { } } - func updateNavigationMergeFactor(value: CGFloat, transition: Transition) { + func updateNavigationMergeFactor(value: CGFloat, transition: ComponentTransition) { transition.setAlpha(view: self.topPanelMergedBackgroundView, alpha: value) transition.setAlpha(view: self.topPanelBackgroundView, alpha: 1.0 - value) } - func update(component: StorageUsagePanelContainerComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StorageUsagePanelContainerComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let environment = environment[StorageUsagePanelContainerEnvironment.self].value let themeUpdated = self.component?.theme !== component.theme @@ -615,7 +615,7 @@ final class StorageUsagePanelContainerComponent: Component { } if component.items.contains(where: { $0.id == id }) { self.currentId = id - let transition = Transition(animation: .curve(duration: 0.35, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.35, curve: .spring)) self.state?.updated(transition: transition) component.currentPanelUpdated(id, transition) } @@ -763,7 +763,7 @@ final class StorageUsagePanelContainerComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageUsageScreen.swift b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageUsageScreen.swift index ae05a9c642..7e28e2598e 100644 --- a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageUsageScreen.swift +++ b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageUsageScreen.swift @@ -907,7 +907,7 @@ final class StorageUsageScreenComponent: Component { } } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { let scrollBounds = self.scrollView.bounds let isLockedAtPanels = scrollBounds.maxY == self.scrollView.contentSize.height @@ -921,7 +921,7 @@ final class StorageUsageScreenComponent: Component { headerOffset = min(headerOffset, minOffset) - let animatedTransition = Transition(animation: .curve(duration: 0.18, curve: .easeInOut)) + let animatedTransition = ComponentTransition(animation: .curve(duration: 0.18, curve: .easeInOut)) let navigationBackgroundAlpha: CGFloat = abs(headerOffset - minOffset) < 4.0 ? 1.0 : 0.0 animatedTransition.setAlpha(view: self.navigationBackgroundView, alpha: navigationBackgroundAlpha) @@ -971,7 +971,7 @@ final class StorageUsageScreenComponent: Component { ) } - func update(component: StorageUsageScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StorageUsageScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -1098,7 +1098,7 @@ final class StorageUsageScreenComponent: Component { if let animationHint { if case .firstStatsUpdate = animationHint.value { - let alphaTransition: Transition + let alphaTransition: ComponentTransition if environment.isVisible { alphaTransition = .easeInOut(duration: 0.25) } else { @@ -1147,7 +1147,7 @@ final class StorageUsageScreenComponent: Component { } if let aggregatedData = self.aggregatedData, !aggregatedData.isSelectingPeers { aggregatedData.isSelectingPeers = true - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } } ).minSize(CGSize(width: 16.0, height: environment.navigationHeight - environment.statusBarHeight))), @@ -1171,7 +1171,7 @@ final class StorageUsageScreenComponent: Component { } aggregatedData.isSelectingPeers = false aggregatedData.clearPeerSelection() - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } ).minSize(CGSize(width: 16.0, height: environment.navigationHeight - environment.statusBarHeight))), environment: {}, @@ -1397,7 +1397,7 @@ final class StorageUsageScreenComponent: Component { var pieChartTransition = transition if transition.animation.isImmediate, let animationHint, case .clearedItems = animationHint.value { - pieChartTransition = Transition(animation: .curve(duration: 0.4, curve: .spring)) + pieChartTransition = ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)) } let pieChartSize = self.pieChartView.update( @@ -1701,7 +1701,7 @@ final class StorageUsageScreenComponent: Component { aggregatedData.setIsCategorySelected(category: key, isSelected: true) } } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) }, toggleOtherExpanded: { [weak self] in guard let self else { @@ -1709,7 +1709,7 @@ final class StorageUsageScreenComponent: Component { } self.isOtherCategoryExpanded = !self.isOtherCategoryExpanded - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) }, clearAction: { [weak self] in guard let self else { @@ -1991,7 +1991,7 @@ final class StorageUsageScreenComponent: Component { if aggregatedData.isSelectingPeers { aggregatedData.togglePeerSelection(id: peer.id) - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } else { self.openPeer(peer: peer) } @@ -2056,7 +2056,7 @@ final class StorageUsageScreenComponent: Component { return } aggregatedData.togglePeerSelection(id: peer.id) - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) }) )) let items = ContextController.Items(content: .list(itemList)) @@ -2092,7 +2092,7 @@ final class StorageUsageScreenComponent: Component { return } aggregatedData.toggleMessageSelection(id: messageId) - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) }, contextAction: { [weak self] messageId, containerView, sourceRect, gesture in guard let self else { @@ -2119,7 +2119,7 @@ final class StorageUsageScreenComponent: Component { return } aggregatedData.toggleMessageSelection(id: messageId) - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) }, contextAction: { [weak self] messageId, containerView, gesture in guard let self else { @@ -2146,7 +2146,7 @@ final class StorageUsageScreenComponent: Component { return } aggregatedData.toggleMessageSelection(id: messageId) - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) }, contextAction: { [weak self] messageId, containerView, gesture in guard let self else { @@ -2252,7 +2252,7 @@ final class StorageUsageScreenComponent: Component { } if delay == 0.0 { - let animationTransition = Transition(animation: .curve(duration: 0.25, curve: .easeInOut)) + let animationTransition = ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut)) animationTransition.setAlpha(view: clearingNode.view, alpha: 0.0, completion: { [weak clearingNode] _ in clearingNode?.removeFromSupernode() }) @@ -2328,7 +2328,7 @@ final class StorageUsageScreenComponent: Component { if firstTime { self.aggregatedData = initialAggregatedData - self.state?.updated(transition: Transition(animation: .none).withUserData(AnimationHint(value: .firstStatsUpdate))) + self.state?.updated(transition: ComponentTransition(animation: .none).withUserData(AnimationHint(value: .firstStatsUpdate))) self.component?.ready.set(.single(true)) } @@ -2469,9 +2469,9 @@ final class StorageUsageScreenComponent: Component { self.isClearing = false if !firstTime { - self.state?.updated(transition: Transition(animation: .none).withUserData(AnimationHint(value: .clearedItems))) + self.state?.updated(transition: ComponentTransition(animation: .none).withUserData(AnimationHint(value: .clearedItems))) } else { - self.state?.updated(transition: Transition(animation: .none)) + self.state?.updated(transition: ComponentTransition(animation: .none)) } completion() @@ -2587,7 +2587,7 @@ final class StorageUsageScreenComponent: Component { return } aggregatedData.toggleMessageSelection(id: message.id) - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) }))) switch previewData { @@ -2691,7 +2691,7 @@ final class StorageUsageScreenComponent: Component { return } aggregatedData.toggleMessageSelection(id: message.id) - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) }) )) let items = ContextController.Items(content: .list(itemList)) @@ -3271,7 +3271,7 @@ final class StorageUsageScreenComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/AvatarStoryIndicatorComponent/Sources/AvatarStoryIndicatorComponent.swift b/submodules/TelegramUI/Components/Stories/AvatarStoryIndicatorComponent/Sources/AvatarStoryIndicatorComponent.swift index 5cd33daa87..a5a3a3db34 100644 --- a/submodules/TelegramUI/Components/Stories/AvatarStoryIndicatorComponent/Sources/AvatarStoryIndicatorComponent.swift +++ b/submodules/TelegramUI/Components/Stories/AvatarStoryIndicatorComponent/Sources/AvatarStoryIndicatorComponent.swift @@ -161,7 +161,7 @@ public final class AvatarStoryIndicatorComponent: Component { self.uploadProgressLayer.path = nil } - func updateAnimations(transition: Transition) { + func updateAnimations(transition: ComponentTransition) { guard let params = self.currentParams else { return } @@ -217,7 +217,7 @@ public final class AvatarStoryIndicatorComponent: Component { } } - func update(size: CGSize, radius: CGFloat, isRoundedRect: Bool, lineWidth: CGFloat, value: Value, transition: Transition) { + func update(size: CGSize, radius: CGFloat, isRoundedRect: Bool, lineWidth: CGFloat, value: Value, transition: ComponentTransition) { let params = Params( size: size, lineWidth: lineWidth, @@ -271,7 +271,7 @@ public final class AvatarStoryIndicatorComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: AvatarStoryIndicatorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: AvatarStoryIndicatorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -379,7 +379,7 @@ public final class AvatarStoryIndicatorComponent: Component { let indicatorFrame = CGRect(origin: CGPoint(x: (availableSize.width - imageDiameter) * 0.5, y: (availableSize.height - imageDiameter) * 0.5), size: CGSize(width: imageDiameter, height: imageDiameter)) transition.setFrame(view: self.indicatorView, frame: indicatorFrame) - let progressTransition = Transition(animation: .curve(duration: 0.3, curve: .easeInOut)) + let progressTransition = ComponentTransition(animation: .curve(duration: 0.3, curve: .easeInOut)) if let progress = component.progress, !component.isRoundedRect { let colorLayer: SimpleGradientLayer if let current = self.colorLayer { @@ -448,7 +448,7 @@ public final class AvatarStoryIndicatorComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/ForwardInfoPanelComponent/Sources/ForwardInfoPanelComponent.swift b/submodules/TelegramUI/Components/Stories/ForwardInfoPanelComponent/Sources/ForwardInfoPanelComponent.swift index 170788ca40..6191ae72ee 100644 --- a/submodules/TelegramUI/Components/Stories/ForwardInfoPanelComponent/Sources/ForwardInfoPanelComponent.swift +++ b/submodules/TelegramUI/Components/Stories/ForwardInfoPanelComponent/Sources/ForwardInfoPanelComponent.swift @@ -91,7 +91,7 @@ public final class ForwardInfoPanelComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: ForwardInfoPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ForwardInfoPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -202,7 +202,7 @@ public final class ForwardInfoPanelComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/PeerListItemComponent/Sources/PeerListItemComponent.swift b/submodules/TelegramUI/Components/Stories/PeerListItemComponent/Sources/PeerListItemComponent.swift index e32a2575a9..7c2d2b3aa8 100644 --- a/submodules/TelegramUI/Components/Stories/PeerListItemComponent/Sources/PeerListItemComponent.swift +++ b/submodules/TelegramUI/Components/Stories/PeerListItemComponent/Sources/PeerListItemComponent.swift @@ -410,11 +410,11 @@ public final class PeerListItemComponent: Component { } self.isExtractedToContextMenu = value - let mappedTransition: Transition + let mappedTransition: ComponentTransition if value { - mappedTransition = Transition(transition) + mappedTransition = ComponentTransition(transition) } else { - mappedTransition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut)) + mappedTransition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut)) } self.state?.updated(transition: mappedTransition) } @@ -522,7 +522,7 @@ public final class PeerListItemComponent: Component { self.imageNode?.isHidden = isPreviewing } - func update(component: PeerListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: PeerListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousComponent = self.component var synchronousLoad = false @@ -1134,7 +1134,7 @@ public final class PeerListItemComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/MediaNavigationStripComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/MediaNavigationStripComponent.swift index 1fad133d46..0fdf7b421f 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/MediaNavigationStripComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/MediaNavigationStripComponent.swift @@ -152,7 +152,7 @@ final class MediaNavigationStripComponent: Component { fatalError("init(coder:) has not been implemented") } - func updateCurrentItemProgress(value: CGFloat, isBuffering: Bool, transition: Transition) { + func updateCurrentItemProgress(value: CGFloat, isBuffering: Bool, transition: ComponentTransition) { guard let component = self.component else { return } @@ -170,7 +170,7 @@ final class MediaNavigationStripComponent: Component { } private var isTransitioning = false - func update(component: MediaNavigationStripComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: MediaNavigationStripComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousComponent = self.component self.component = component @@ -291,7 +291,7 @@ final class MediaNavigationStripComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryActionsComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryActionsComponent.swift index af11956e7c..958c24efe0 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryActionsComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryActionsComponent.swift @@ -63,7 +63,7 @@ public final class StoryActionsComponent: Component { let scale: CGFloat = highlighted ? 0.6 : 1.0 - let transition = Transition(animation: .curve(duration: highlighted ? 0.5 : 0.3, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: highlighted ? 0.5 : 0.3, curve: .spring)) transition.setSublayerTransform(view: self, transform: CATransform3DMakeScale(scale, scale, 1.0)) transition.setScale(view: self.maskBackgroundView, scale: scale) } @@ -81,7 +81,7 @@ public final class StoryActionsComponent: Component { self.action(item) } - func update(item: Item, size: CGSize, transition: Transition) { + func update(item: Item, size: CGSize, transition: ComponentTransition) { if self.item == item { return } @@ -125,7 +125,7 @@ public final class StoryActionsComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: StoryActionsComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoryActionsComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.componentState = state @@ -175,7 +175,7 @@ public final class StoryActionsComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryAuthorInfoComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryAuthorInfoComponent.swift index 3f3fe6dbcb..488a9953f8 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryAuthorInfoComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryAuthorInfoComponent.swift @@ -83,7 +83,7 @@ final class StoryAuthorInfoComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: StoryAuthorInfoComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoryAuthorInfoComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -281,7 +281,7 @@ final class StoryAuthorInfoComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryAvatarInfoComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryAvatarInfoComponent.swift index 86bf129c96..f3c2fa910e 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryAvatarInfoComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryAvatarInfoComponent.swift @@ -44,7 +44,7 @@ final class StoryAvatarInfoComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: StoryAvatarInfoComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoryAvatarInfoComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -66,7 +66,7 @@ final class StoryAvatarInfoComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift index 2be200e643..36f197cd49 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift @@ -629,7 +629,7 @@ private final class StoryContainerScreenComponent: Component { } self.itemSetPinchState = nil if !self.isUpdating { - self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) } } self.addGestureRecognizer(pinchRecognizer) @@ -788,7 +788,7 @@ private final class StoryContainerScreenComponent: Component { self.itemSetPanState = ItemSetPanState(fraction: 0.0, didBegin: true) if !updateImmediately { if !self.isUpdating { - self.state?.updated(transition: Transition(animation: .curve(duration: 0.25, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut))) } } } else { @@ -881,7 +881,7 @@ private final class StoryContainerScreenComponent: Component { itemSetPanState.fraction = 0.0 self.itemSetPanState = itemSetPanState - let transition = Transition(animation: .curve(duration: 0.4, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)) if !self.isUpdating { self.state?.updated(transition: transition) } @@ -926,14 +926,14 @@ private final class StoryContainerScreenComponent: Component { if self.itemSetPanState == nil { self.itemSetPanState = ItemSetPanState(fraction: 0.0, didBegin: false) if !self.isUpdating { - self.state?.updated(transition: Transition(animation: .curve(duration: 0.25, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut))) } } case .cancelled, .ended: if let itemSetPanState = self.itemSetPanState, !itemSetPanState.didBegin { self.itemSetPanState = nil if !self.isUpdating { - self.state?.updated(transition: Transition(animation: .curve(duration: 0.25, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut))) } } default: @@ -1079,7 +1079,7 @@ private final class StoryContainerScreenComponent: Component { if !self.dismissWithoutTransitionOut, let component = self.component, let stateValue = self.stateValue, let slice = stateValue.slice, let itemSetView = self.visibleItemSetViews[slice.peer.id], let itemSetComponentView = itemSetView.view.view as? StoryItemSetContainerComponent.View, let transitionOut = component.transitionOut(slice.peer.id, slice.item.storyItem.id) { self.state?.updated(transition: .immediate) - let transition = Transition(animation: .curve(duration: 0.25, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut)) transition.setAlpha(layer: self.backgroundLayer, alpha: 0.0) transition.setAlpha(view: self.backgroundEffectView, alpha: 0.0) @@ -1100,11 +1100,11 @@ private final class StoryContainerScreenComponent: Component { transitionOut.completed() } - let transition: Transition + let transition: ComponentTransition if self.dismissWithoutTransitionOut { - transition = Transition(animation: .curve(duration: 0.5, curve: .spring)) + transition = ComponentTransition(animation: .curve(duration: 0.5, curve: .spring)) } else { - transition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut)) + transition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut)) } self.isDismissedExlusively = true @@ -1240,7 +1240,7 @@ private final class StoryContainerScreenComponent: Component { self.environment?.controller()?.present(tooltipScreen, in: .current) } - func update(component: StoryContainerScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoryContainerScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { if self.didAnimateOut { return availableSize } @@ -1805,8 +1805,8 @@ private final class StoryContainerScreenComponent: Component { return targetTransform } - Transition.immediate.setTransform(view: itemSetComponentView, transform: faceTransform) - Transition.immediate.setTransform(layer: itemSetView.tintLayer, transform: faceTransform) + ComponentTransition.immediate.setTransform(view: itemSetComponentView, transform: faceTransform) + ComponentTransition.immediate.setTransform(layer: itemSetView.tintLayer, transform: faceTransform) if let previousRotationFraction = itemSetView.rotationFraction, !itemSetTransition.animation.isImmediate { let fromT = previousRotationFraction @@ -1929,7 +1929,7 @@ private final class StoryContainerScreenComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -1953,12 +1953,12 @@ public class StoryContainerScreen: ViewControllerComponentContainer { public final class TransitionView { public let makeView: () -> UIView - public let updateView: (UIView, TransitionState, Transition) -> Void + public let updateView: (UIView, TransitionState, ComponentTransition) -> Void public let insertCloneTransitionView: ((UIView) -> Void)? public init( makeView: @escaping () -> UIView, - updateView: @escaping (UIView, TransitionState, Transition) -> Void, + updateView: @escaping (UIView, TransitionState, ComponentTransition) -> Void, insertCloneTransitionView: ((UIView) -> Void)? ) { self.makeView = makeView diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContentCaptionComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContentCaptionComponent.swift index 4684dde0d0..2bfde6f260 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContentCaptionComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContentCaptionComponent.swift @@ -330,9 +330,9 @@ final class StoryContentCaptionComponent: Component { @objc private func tapGesture(_ recognizer: UITapGestureRecognizer) { if case .ended = recognizer.state { if self.isExpanded { - self.collapse(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.collapse(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } else { - self.expand(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.expand(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } } } @@ -352,7 +352,7 @@ final class StoryContentCaptionComponent: Component { } } - func expand(transition: Transition) { + func expand(transition: ComponentTransition) { self.ignoreScrolling = true if let textNode = self.expandedText.textNode?.textNode { var offset = textNode.frame.minY - 8.0 @@ -371,7 +371,7 @@ final class StoryContentCaptionComponent: Component { self.updateScrolling(transition: transition.withUserData(InternalTransitionHint(bounceScrolling: true))) } - func collapse(transition: Transition) { + func collapse(transition: ComponentTransition) { self.ignoreScrolling = true if transition.animation.isImmediate { @@ -391,7 +391,7 @@ final class StoryContentCaptionComponent: Component { self.textSelectionNode?.cancelSelection() } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { guard let component = self.component, let itemLayout = self.itemLayout else { return } @@ -501,12 +501,12 @@ final class StoryContentCaptionComponent: Component { self.expandedContentsBlocks.insert(blockIndex) } self.state?.updated(transition: .spring(duration: 0.4)) - self.expand(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.expand(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } else { - self.collapse(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.collapse(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } } else { - self.expand(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.expand(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } } } @@ -515,9 +515,9 @@ final class StoryContentCaptionComponent: Component { if component.externalState.isSelectingText { self.cancelTextSelection() } else if self.isExpanded { - self.collapse(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.collapse(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } else { - self.expand(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.expand(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } } } @@ -526,9 +526,9 @@ final class StoryContentCaptionComponent: Component { if component.externalState.isSelectingText { self.cancelTextSelection() } else if self.isExpanded { - self.collapse(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.collapse(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } else { - self.expand(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.expand(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } } } @@ -598,7 +598,7 @@ final class StoryContentCaptionComponent: Component { } } - func update(component: StoryContentCaptionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoryContentCaptionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -1041,7 +1041,7 @@ final class StoryContentCaptionComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryInteractionGuideComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryInteractionGuideComponent.swift index 62b24ccc46..8b0fcd0642 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryInteractionGuideComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryInteractionGuideComponent.swift @@ -91,7 +91,7 @@ final class StoryInteractionGuideComponent: Component { self.containerView.layer.animateScale(from: 1.0, to: 1.1, duration: 0.4, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false) } - func update(component: StoryInteractionGuideComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoryInteractionGuideComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -261,7 +261,7 @@ final class StoryInteractionGuideComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -337,7 +337,7 @@ private final class GuideItemComponent: Component { } private var isPlaying = false - func update(component: GuideItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: GuideItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let originX = availableSize.width / 2.0 - 120.0 @@ -444,7 +444,7 @@ private final class GuideItemComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemContentComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemContentComponent.swift index 2fab648f95..675210777b 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemContentComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemContentComponent.swift @@ -547,7 +547,7 @@ final class StoryItemContentComponent: Component { return nil } - private func updateOverlays(component: StoryItemContentComponent, size: CGSize, synchronousLoad: Bool, transition: Transition) { + private func updateOverlays(component: StoryItemContentComponent, size: CGSize, synchronousLoad: Bool, transition: ComponentTransition) { self.overlaysView.update( context: component.context, strings: component.strings, @@ -579,7 +579,7 @@ final class StoryItemContentComponent: Component { self.isSeeking = false } - func update(component: StoryItemContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoryItemContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousItem = self.component?.item self.component = component @@ -980,7 +980,7 @@ final class StoryItemContentComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemImageView.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemImageView.swift index 6200db9812..6e23b837d0 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemImageView.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemImageView.swift @@ -66,7 +66,7 @@ final class StoryItemImageView: UIView { } } - func update(context: AccountContext, strings: PresentationStrings, peer: EnginePeer, storyId: Int32, media: EngineMedia, size: CGSize, isCaptureProtected: Bool, attemptSynchronous: Bool, transition: Transition) { + func update(context: AccountContext, strings: PresentationStrings, peer: EnginePeer, storyId: Int32, media: EngineMedia, size: CGSize, isCaptureProtected: Bool, attemptSynchronous: Bool, transition: ComponentTransition) { self.backgroundColor = isCaptureProtected ? UIColor(rgb: 0x181818) : nil var dimensions: CGSize? @@ -296,7 +296,7 @@ final class CaptureProtectedInfoComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: CaptureProtectedInfoComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: CaptureProtectedInfoComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let iconSize = self.icon.update( transition: transition, component: AnyComponent(BundleIconComponent( @@ -367,7 +367,7 @@ final class CaptureProtectedInfoComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemLoadingEffectView.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemLoadingEffectView.swift index 07a8ef0dab..81f7a6d9d0 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemLoadingEffectView.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemLoadingEffectView.swift @@ -102,7 +102,7 @@ final class StoryItemLoadingEffectView: UIView { self.didPlayOnce = true } - func update(size: CGSize, transition: Transition) { + func update(size: CGSize, transition: ComponentTransition) { if self.backgroundView.bounds.size != size { self.backgroundView.layer.removeAllAnimations() diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemOverlaysView.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemOverlaysView.swift index 7f732455a0..7f7863caf7 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemOverlaysView.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemOverlaysView.swift @@ -262,10 +262,10 @@ final class StoryItemOverlaysView: UIView { } if highlighted { - let transition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut)) transition.setSublayerTransform(view: self, transform: CATransform3DMakeScale(0.9, 0.9, 1.0)) } else { - let transition: Transition = .immediate + let transition: ComponentTransition = .immediate transition.setSublayerTransform(view: self, transform: CATransform3DIdentity) var fromScale: Double = 0.9 if self.layer.animation(forKey: "sublayerTransform") != nil, let presentation = self.layer.presentation() { @@ -305,7 +305,7 @@ final class StoryItemOverlaysView: UIView { size: CGSize, isActive: Bool ) { - var transition = Transition(animation: .curve(duration: 0.18, curve: .easeInOut)) + var transition = ComponentTransition(animation: .curve(duration: 0.18, curve: .easeInOut)) if self.reaction == nil { transition = .immediate } @@ -559,7 +559,7 @@ final class StoryItemOverlaysView: UIView { isCaptureProtected: Bool, attemptSynchronous: Bool, isActive: Bool, - transition: Transition + transition: ComponentTransition ) { var nextId = 0 for mediaArea in story.mediaAreas { diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift index 17ef0ad48a..7ac6897657 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift @@ -647,7 +647,7 @@ public final class StoryItemSetContainerComponent: Component { }) } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } }) @@ -690,7 +690,7 @@ public final class StoryItemSetContainerComponent: Component { return } self.sendMessageContext.hasRecordedVideoPreview = true - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } self.component?.controller()?.present(videoRecorder, in: .window(.root)) @@ -703,7 +703,7 @@ public final class StoryItemSetContainerComponent: Component { let _ = previousVideoRecorderValue.dismissVideo() } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } }) } @@ -925,7 +925,7 @@ public final class StoryItemSetContainerComponent: Component { self.endEditing(true) } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.25, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut))) self.updateIsProgressPaused() } else if self.hasActiveDeactivateableInput() { Queue.mainQueue().justDispatch { @@ -937,7 +937,7 @@ public final class StoryItemSetContainerComponent: Component { for (id, visibleItem) in self.visibleItems { if visibleItem.contentContainerView.convert(visibleItem.contentContainerView.bounds, to: self).contains(point) { if id == component.slice.item.storyItem.id { - let transition = Transition(animation: .curve(duration: 0.4, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)) self.viewListDisplayState = .hidden self.isSearchActive = false @@ -956,7 +956,7 @@ public final class StoryItemSetContainerComponent: Component { if captionItem.externalState.isSelectingText { captionItemView.cancelTextSelection() } else { - captionItemView.collapse(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + captionItemView.collapse(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } } } else { @@ -1050,7 +1050,7 @@ public final class StoryItemSetContainerComponent: Component { } if !consumed { - let transition = Transition(animation: .curve(duration: 0.4, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)) self.viewListPanState = nil self.isCompletingViewListPan = true transition.attachAnimation(view: self, id: "isCompletingViewListPan", completion: { [weak self] completed in @@ -1196,16 +1196,16 @@ public final class StoryItemSetContainerComponent: Component { } } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } else if verticalPanState.accumulatedOffset < 0.0 && self.targetViewListDisplayStateIsFull { if verticalPanState.fraction <= -0.05 || velocity.y <= -80.0 { self.viewListDisplayState = .full } else { self.viewListDisplayState = .half } - self.state?.updated(transition: verticalPanState.accumulatedOffset == 0.0 ? .immediate : Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: verticalPanState.accumulatedOffset == 0.0 ? .immediate : ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } else { - self.state?.updated(transition: verticalPanState.accumulatedOffset == 0.0 ? .immediate : Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: verticalPanState.accumulatedOffset == 0.0 ? .immediate : ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } } else { if verticalPanState.fraction >= 0.3 || (verticalPanState.fraction >= 0.05 && velocity.y >= 150.0) { @@ -1220,14 +1220,14 @@ public final class StoryItemSetContainerComponent: Component { self.dismissAllTooltips() } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } } else { if let visibleItemView = self.visibleItems[component.slice.item.storyItem.id]?.view.view as? StoryItemContentComponent.View { visibleItemView.seekEnded() } if translation.y > 200.0 || (translation.y > 5.0 && velocity.y > 200.0) { - self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) self.component?.controller()?.dismiss() } else if translation.y < -200.0 || (translation.y < -100.0 && velocity.y < -100.0) { var displayViewLists = false @@ -1239,17 +1239,17 @@ public final class StoryItemSetContainerComponent: Component { if displayViewLists { self.viewListDisplayState = self.targetViewListDisplayStateIsFull ? .full : .half - self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) self.dismissAllTooltips() } else { - self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) if let activate = self.activateInputWhileDragging() { activate() } } } else { - self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) } } } @@ -1266,7 +1266,7 @@ public final class StoryItemSetContainerComponent: Component { if self.viewListDisplayState != .hidden { self.viewListDisplayState = .hidden self.isSearchActive = false - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) } else { component.close() } @@ -1419,7 +1419,7 @@ public final class StoryItemSetContainerComponent: Component { return .play } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { guard let component = self.component, let itemLayout = self.itemLayout else { return } @@ -1769,7 +1769,7 @@ public final class StoryItemSetContainerComponent: Component { self.updateScrolling(transition: .immediate) self.preparingToDisplayViewList = false - 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.dismissAllTooltips() } @@ -1939,7 +1939,7 @@ public final class StoryItemSetContainerComponent: Component { if displayViewLists { self.viewListDisplayState = .half - 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.dismissAllTooltips() @@ -1995,7 +1995,7 @@ public final class StoryItemSetContainerComponent: Component { if self.displayLikeReactions { self.displayLikeReactions = false - self.state?.updated(transition: Transition(animation: .curve(duration: 0.25, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut))) } inputPanelView.activateInput() @@ -2315,7 +2315,7 @@ public final class StoryItemSetContainerComponent: Component { ), .immediate) } - let transition = Transition(animation: .curve(duration: 0.3, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.3, curve: .spring)) for transitionViewImpl in transitionViewsImpl { transitionViewImpl.alpha = 1.0 @@ -2438,7 +2438,7 @@ public final class StoryItemSetContainerComponent: Component { ), .immediate) } - let transition = Transition(animation: .curve(duration: 0.3, curve: .spring)) + let transition = ComponentTransition(animation: .curve(duration: 0.3, curve: .spring)) for transitionViewImpl in transitionViewsImpl { transitionViewImpl.alpha = 1.0 @@ -2563,7 +2563,7 @@ public final class StoryItemSetContainerComponent: Component { } } - func update(component: StoryItemSetContainerComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoryItemSetContainerComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdatingComponent = true defer { self.isUpdatingComponent = false @@ -2628,7 +2628,7 @@ public final class StoryItemSetContainerComponent: Component { if let reactionContextNode = self.reactionContextNode { self.reactionContextNode = nil - let reactionTransition = Transition.immediate + let reactionTransition = ComponentTransition.immediate reactionTransition.setAlpha(view: reactionContextNode.view, alpha: 0.0, completion: { [weak reactionContextNode] _ in reactionContextNode?.view.removeFromSuperview() }) @@ -2930,7 +2930,7 @@ public final class StoryItemSetContainerComponent: Component { return } self.sendMessageContext.lockMediaRecording() - self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) }, stopAndPreviewMediaRecording: { [weak self] in guard let self else { @@ -3023,7 +3023,7 @@ public final class StoryItemSetContainerComponent: Component { controller.dismissed = { [weak self] _ in if let self { self.voiceMessagesRestrictedTooltipController = nil - self.state?.updated(transition: Transition(animation: .curve(duration: 0.2, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut))) } } component.presentController(controller, TooltipControllerPresentationArguments(sourceViewAndRect: { [weak self] in @@ -3033,7 +3033,7 @@ public final class StoryItemSetContainerComponent: Component { return nil })) self.voiceMessagesRestrictedTooltipController = controller - self.state?.updated(transition: Transition(animation: .curve(duration: 0.2, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut))) }, presentTextLengthLimitTooltip: nil, presentTextFormattingTooltip: nil, @@ -3334,7 +3334,7 @@ public final class StoryItemSetContainerComponent: Component { } self.viewListDisplayState = .hidden self.isSearchActive = false - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring))) }, expandViewStats: { }, @@ -3596,7 +3596,7 @@ public final class StoryItemSetContainerComponent: Component { self.viewListDisplayState = .half } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.5, curve: .spring))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.5, curve: .spring))) } }, controller: { [weak self] in @@ -3921,7 +3921,7 @@ public final class StoryItemSetContainerComponent: Component { if let storyPrivacyIcon { let privacyIcon: ComponentView - var privacyIconTransition: Transition = itemChanged ? .immediate : .easeInOut(duration: 0.2) + var privacyIconTransition: ComponentTransition = itemChanged ? .immediate : .easeInOut(duration: 0.2) if let current = self.privacyIcon { privacyIcon = current } else { @@ -4484,19 +4484,19 @@ public final class StoryItemSetContainerComponent: Component { guard let self else { return } - self.state?.updated(transition: Transition(transition)) + self.state?.updated(transition: ComponentTransition(transition)) }, requestLayout: { [weak self] transition in guard let self else { return } - self.state?.updated(transition: Transition(transition)) + self.state?.updated(transition: ComponentTransition(transition)) }, requestUpdateOverlayWantsToBeBelowKeyboard: { [weak self] transition in guard let self else { return } - self.state?.updated(transition: Transition(transition)) + self.state?.updated(transition: ComponentTransition(transition)) } ) reactionContextNode.displayTail = self.displayLikeReactions @@ -4537,13 +4537,13 @@ public final class StoryItemSetContainerComponent: Component { if component.slice.item.storyItem.myReaction == updateReaction.reaction { let _ = component.context.engine.messages.setStoryReaction(peerId: component.slice.effectivePeer.id, id: component.slice.item.storyItem.id, reaction: nil).startStandalone() self.displayLikeReactions = false - self.state?.updated(transition: Transition(animation: .curve(duration: 0.25, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut))) } else { if hasFirstResponder(self) { self.sendMessageContext.currentInputMode = .text self.endEditing(true) } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.25, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut))) self.waitingForReactionAnimateOutToLike = updateReaction.reaction let _ = component.context.engine.messages.setStoryReaction(peerId: component.slice.effectivePeer.id, id: component.slice.item.storyItem.id, reaction: updateReaction.reaction).startStandalone() @@ -4597,7 +4597,7 @@ public final class StoryItemSetContainerComponent: Component { self.sendMessageContext.currentInputMode = .text self.endEditing(true) } - self.state?.updated(transition: Transition(animation: .curve(duration: 0.25, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut))) var text = "" var messageAttributes: [MessageAttribute] = [] @@ -4781,7 +4781,7 @@ public final class StoryItemSetContainerComponent: Component { return } self.displayLikeReactions = false - self.state?.updated(transition: Transition(animation: .curve(duration: 0.25, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut))) } } } else { @@ -4797,7 +4797,7 @@ public final class StoryItemSetContainerComponent: Component { reactionContextNode.animateOut(to: reactionsAnchorRect, animatingOutToReaction: true) } } else { - let reactionTransition = Transition.easeInOut(duration: 0.25) + let reactionTransition = ComponentTransition.easeInOut(duration: 0.25) reactionTransition.setAlpha(view: reactionContextNode.view, alpha: 0.0, completion: { [weak reactionContextNode] _ in reactionContextNode?.view.removeFromSuperview() }) @@ -4836,13 +4836,13 @@ public final class StoryItemSetContainerComponent: Component { transition.setFrame(view: self.contentDimView, frame: CGRect(origin: CGPoint(), size: contentFrame.size)) if transition.animation.isImmediate && forceDimAnimation && self.topContentGradientView.alpha != topGradientAlpha { - Transition(animation: .curve(duration: 0.25, curve: .easeInOut)).setAlpha(view: self.topContentGradientView, alpha: topGradientAlpha) + ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut)).setAlpha(view: self.topContentGradientView, alpha: topGradientAlpha) } else { transition.setAlpha(view: self.topContentGradientView, alpha: topGradientAlpha) } if transition.animation.isImmediate && forceDimAnimation && self.contentDimView.alpha != dimAlpha { - Transition(animation: .curve(duration: 0.25, curve: .easeInOut)).setAlpha(view: self.contentDimView, alpha: dimAlpha) + ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut)).setAlpha(view: self.contentDimView, alpha: dimAlpha) } else { transition.setAlpha(view: self.contentDimView, alpha: dimAlpha) } @@ -5758,7 +5758,7 @@ public final class StoryItemSetContainerComponent: Component { self.displayLikeReactions = true self.tempReactionsGesture = gesture - self.state?.updated(transition: Transition(animation: .curve(duration: 0.25, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut))) self.updateIsProgressPaused() self.tempReactionsGesture = nil } @@ -6968,7 +6968,7 @@ public final class StoryItemSetContainerComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -7013,7 +7013,7 @@ final class ListContextExtractedContentSource: ContextExtractedContentSource { } -private func generateParabollicMotionKeyframes(from sourcePoint: CGPoint, to targetPosition: CGPoint, elevation: CGFloat, duration: Double, curve: Transition.Animation.Curve, reverse: Bool) -> [CGPoint] { +private func generateParabollicMotionKeyframes(from sourcePoint: CGPoint, to targetPosition: CGPoint, elevation: CGFloat, duration: Double, curve: ComponentTransition.Animation.Curve, reverse: Bool) -> [CGPoint] { let midPoint = CGPoint(x: (sourcePoint.x + targetPosition.x) / 2.0, y: sourcePoint.y - elevation) let x1 = sourcePoint.x diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift index 4833f9c4ba..f80d8ec604 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift @@ -199,7 +199,7 @@ final class StoryItemSetContainerSendMessage { }, requestLayout: { [weak self] transition in if let self { - self.view?.state?.updated(transition: Transition(transition)) + self.view?.state?.updated(transition: ComponentTransition(transition)) } } ) @@ -220,7 +220,7 @@ final class StoryItemSetContainerSendMessage { } } - func updateInputMediaNode(view: StoryItemSetContainerComponent.View, availableSize: CGSize, bottomInset: CGFloat, bottomContainerInset: CGFloat, inputHeight: CGFloat, effectiveInputHeight: CGFloat, metrics: LayoutMetrics, deviceMetrics: DeviceMetrics, transition: Transition) -> CGFloat { + func updateInputMediaNode(view: StoryItemSetContainerComponent.View, availableSize: CGSize, bottomInset: CGFloat, bottomContainerInset: CGFloat, inputHeight: CGFloat, effectiveInputHeight: CGFloat, metrics: LayoutMetrics, deviceMetrics: DeviceMetrics, transition: ComponentTransition) -> CGFloat { guard let context = self.context, let inputPanelView = view.inputPanel.view as? MessageInputPanelComponent.View else { return 0.0 } @@ -284,8 +284,8 @@ final class StoryItemSetContainerSendMessage { if self.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: inputNodeFrame) + ComponentTransition.immediate.setFrame(layer: inputMediaNode.layer, frame: inputNodeFrame) + ComponentTransition.immediate.setFrame(layer: self.inputMediaNodeBackground, frame: inputNodeFrame) } transition.setFrame(layer: inputMediaNode.layer, frame: inputNodeFrame) transition.setFrame(layer: self.inputMediaNodeBackground, frame: inputNodeFrame) @@ -584,12 +584,12 @@ final class StoryItemSetContainerSendMessage { let _ = enqueueMessages(account: component.context.account, peerId: peerId, messages: messages).start() - view.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) + view.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) } else if self.hasRecordedVideoPreview, let videoRecorderValue = self.videoRecorderValue { videoRecorderValue.send() self.hasRecordedVideoPreview = false self.videoRecorder.set(.single(nil)) - view.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) + view.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) } else { switch inputPanelView.getSendMessageInput() { case let .text(text): @@ -912,7 +912,7 @@ final class StoryItemSetContainerSendMessage { } self.hasRecordedVideoPreview = false - view.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) + view.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) } } }) @@ -940,13 +940,13 @@ final class StoryItemSetContainerSendMessage { component.context.account.postbox.mediaBox.storeResourceData(resource.id, data: data.compressedData) self.recordedAudioPreview = .audio(ChatRecordedMediaPreview.Audio(resource: resource, fileSize: Int32(data.compressedData.count), duration: Int32(data.duration), waveform: AudioWaveform(bitstream: waveform, bitsPerSample: 5))) - view.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) + view.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) } }) } else if let videoRecorderValue = self.videoRecorderValue { if videoRecorderValue.stopVideo() { self.hasRecordedVideoPreview = true - view.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) + view.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) } else { self.videoRecorder.set(.single(nil)) } @@ -957,12 +957,12 @@ final class StoryItemSetContainerSendMessage { if self.recordedAudioPreview != nil { self.recordedAudioPreview = nil self.wasRecordingDismissed = true - view.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) + view.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) } else if self.hasRecordedVideoPreview { self.videoRecorder.set(.single(nil)) self.hasRecordedVideoPreview = false self.wasRecordingDismissed = true - view.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) + view.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.3, curve: .spring))) } } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetViewListComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetViewListComponent.swift index 4693f3baf5..29ea4a4726 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetViewListComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetViewListComponent.swift @@ -431,7 +431,7 @@ final class StoryItemSetViewListComponent: Component { self.dismissInput?() } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { guard let component = self.component, let itemLayout = self.itemLayout else { return } @@ -860,7 +860,7 @@ final class StoryItemSetViewListComponent: Component { if applyState { //TODO:determine sync - self.state?.updated(transition: Transition.immediate.withUserData(PeerListItemComponent.TransitionHint(synchronousLoad: true))) + self.state?.updated(transition: ComponentTransition.immediate.withUserData(PeerListItemComponent.TransitionHint(synchronousLoad: true))) } var hasContent = false @@ -903,7 +903,7 @@ final class StoryItemSetViewListComponent: Component { } } - func update(component: StoryItemSetViewListComponent, availableSize: CGSize, visualHeight: CGFloat, sideInset: CGFloat, navigationHeight: CGFloat, navigationSearchPartHeight: CGFloat, isSearchActive: Bool, transition: Transition) { + func update(component: StoryItemSetViewListComponent, availableSize: CGSize, visualHeight: CGFloat, sideInset: CGFloat, navigationHeight: CGFloat, navigationSearchPartHeight: CGFloat, isSearchActive: Bool, transition: ComponentTransition) { let themeUpdated = self.component?.theme !== component.theme self.component = component @@ -1351,13 +1351,13 @@ final class StoryItemSetViewListComponent: Component { self.currentContentView?.sourceView(storyId: storyId) } - func animateIn(transition: Transition) { + func animateIn(transition: ComponentTransition) { let offset = self.bounds.height - self.navigationBarBackground.frame.minY - Transition.immediate.setBoundsOrigin(view: self, origin: CGPoint(x: 0.0, y: -offset)) + ComponentTransition.immediate.setBoundsOrigin(view: self, origin: CGPoint(x: 0.0, y: -offset)) transition.setBoundsOrigin(view: self, origin: CGPoint(x: 0.0, y: 0.0)) } - func animateOut(transition: Transition, completion: @escaping () -> Void) { + func animateOut(transition: ComponentTransition, completion: @escaping () -> Void) { let offset = self.bounds.height - self.navigationBarBackground.frame.minY transition.setBoundsOrigin(view: self, origin: CGPoint(x: 0.0, y: -offset), completion: { _ in completion() @@ -1459,14 +1459,14 @@ final class StoryItemSetViewListComponent: Component { let _ = self if let sourceView { - let transition = Transition(animation: .curve(duration: 0.25, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut)) transition.setAlpha(view: sourceView, alpha: 1.0) } } controller.present(contextController, in: .window(.root)) } - func update(component: StoryItemSetViewListComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoryItemSetViewListComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let themeUpdated = self.component?.theme !== component.theme self.component = component @@ -1586,7 +1586,7 @@ final class StoryItemSetViewListComponent: Component { var tabSelectorTransition = transition if transition.animation.isImmediate, self.tabSelector.view != nil { - tabSelectorTransition = Transition(animation: .curve(duration: 0.35, curve: .spring)) + tabSelectorTransition = ComponentTransition(animation: .curve(duration: 0.35, curve: .spring)) } let tabSelectorSize = self.tabSelector.update( transition: tabSelectorTransition, @@ -1901,7 +1901,7 @@ final class StoryItemSetViewListComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryPrivacyIconComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryPrivacyIconComponent.swift index e5a898bd93..0d61d90a46 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryPrivacyIconComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryPrivacyIconComponent.swift @@ -48,7 +48,7 @@ final class StoryPrivacyIconComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: StoryPrivacyIconComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoryPrivacyIconComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let previousPrivacy = self.component?.privacy self.component = component self.state = state @@ -133,7 +133,7 @@ final class StoryPrivacyIconComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/StoryFooterPanelComponent/Sources/StoryFooterPanelComponent.swift b/submodules/TelegramUI/Components/Stories/StoryFooterPanelComponent/Sources/StoryFooterPanelComponent.swift index 39d580dace..4c5d2bbb50 100644 --- a/submodules/TelegramUI/Components/Stories/StoryFooterPanelComponent/Sources/StoryFooterPanelComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryFooterPanelComponent/Sources/StoryFooterPanelComponent.swift @@ -252,7 +252,7 @@ public final class StoryFooterPanelComponent: Component { component.cancelUploadAction() } - func update(component: StoryFooterPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoryFooterPanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let isFirstTime = self.component == nil let previousComponent = self.component @@ -1046,7 +1046,7 @@ public final class StoryFooterPanelComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListComponent.swift b/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListComponent.swift index 0b79cb0ebb..3403978568 100644 --- a/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListComponent.swift @@ -564,7 +564,7 @@ public final class StoryPeerListComponent: Component { } } - private func updateScrolling(transition: Transition) { + private func updateScrolling(transition: ComponentTransition) { guard let component = self.component, let itemLayout = self.itemLayout else { return } @@ -604,9 +604,9 @@ public final class StoryPeerListComponent: Component { self.titleIconView = titleIconView } - var titleIconTransition: Transition + var titleIconTransition: ComponentTransition if animateStatusTransition { - titleIconTransition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut)) + titleIconTransition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut)) } else { titleIconTransition = .immediate } @@ -1479,7 +1479,7 @@ public final class StoryPeerListComponent: Component { return result } - func update(component: StoryPeerListComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoryPeerListComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { var transition = transition transition.animation = .none @@ -1681,7 +1681,7 @@ public final class StoryPeerListComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListItemComponent.swift b/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListItemComponent.swift index 1cea706b2c..b4a488ae51 100644 --- a/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListItemComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListItemComponent.swift @@ -196,7 +196,7 @@ private final class StoryProgressLayer: HierarchyTrackingLayer { self.uploadProgressLayer.path = nil } - func updateAnimations(transition: Transition) { + func updateAnimations(transition: ComponentTransition) { guard let params = self.currentParams else { return } @@ -276,7 +276,7 @@ private final class StoryProgressLayer: HierarchyTrackingLayer { } } - func update(size: CGSize, lineWidth: CGFloat, radius: CGFloat, value: Value, transition: Transition) { + func update(size: CGSize, lineWidth: CGFloat, radius: CGFloat, value: Value, transition: ComponentTransition) { let params = Params( size: size, lineWidth: lineWidth, @@ -346,7 +346,7 @@ public final class StoryPeerListItemComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(state: StoryContainerScreen.TransitionState, transition: Transition) { + func update(state: StoryContainerScreen.TransitionState, transition: ComponentTransition) { let size = state.sourceSize.interpolate(to: state.destinationSize, amount: state.progress) if let snapshotView = self.snapshotView { @@ -635,7 +635,7 @@ public final class StoryPeerListItemComponent: Component { self.avatarBackgroundView.alpha = isPreviewing ? 0.0 : 1.0 } - func update(component: StoryPeerListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoryPeerListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let size = availableSize let themeUpdated = self.component?.theme !== component.theme @@ -823,10 +823,10 @@ public final class StoryPeerListItemComponent: Component { } else if let mappedLeftCenter { avatarPath.addEllipse(in: CGRect(origin: CGPoint(), size: avatarSize).insetBy(dx: -indicatorLineSeenWidth * 1.4, dy: -indicatorLineSeenWidth * 1.4).offsetBy(dx: -abs(indicatorCenter.x - mappedLeftCenter.x), dy: -abs(indicatorCenter.y - mappedLeftCenter.y))) } - Transition.immediate.setShapeLayerPath(layer: self.avatarShapeLayer, path: avatarPath) + ComponentTransition.immediate.setShapeLayerPath(layer: self.avatarShapeLayer, path: avatarPath) - Transition.immediate.setShapeLayerPath(layer: self.indicatorShapeSeenLayer, path: calculateMergingCircleShape(center: indicatorCenter, leftCenter: mappedLeftCenter, rightCenter: mappedRightCenter, radius: indicatorRadius - indicatorLineUnseenWidth * 0.5, totalCount: component.totalCount, unseenCount: component.unseenCount, isSeen: true, segmentFraction: component.expandedAlphaFraction, rotationFraction: component.expandEffectFraction)) - Transition.immediate.setShapeLayerPath(layer: self.indicatorShapeUnseenLayer, path: calculateMergingCircleShape(center: indicatorCenter, leftCenter: mappedLeftCenter, rightCenter: mappedRightCenter, radius: indicatorRadius - indicatorLineUnseenWidth * 0.5, totalCount: component.totalCount, unseenCount: component.unseenCount, isSeen: false, segmentFraction: component.expandedAlphaFraction, rotationFraction: component.expandEffectFraction)) + ComponentTransition.immediate.setShapeLayerPath(layer: self.indicatorShapeSeenLayer, path: calculateMergingCircleShape(center: indicatorCenter, leftCenter: mappedLeftCenter, rightCenter: mappedRightCenter, radius: indicatorRadius - indicatorLineUnseenWidth * 0.5, totalCount: component.totalCount, unseenCount: component.unseenCount, isSeen: true, segmentFraction: component.expandedAlphaFraction, rotationFraction: component.expandEffectFraction)) + ComponentTransition.immediate.setShapeLayerPath(layer: self.indicatorShapeUnseenLayer, path: calculateMergingCircleShape(center: indicatorCenter, leftCenter: mappedLeftCenter, rightCenter: mappedRightCenter, radius: indicatorRadius - indicatorLineUnseenWidth * 0.5, totalCount: component.totalCount, unseenCount: component.unseenCount, isSeen: false, segmentFraction: component.expandedAlphaFraction, rotationFraction: component.expandEffectFraction)) let titleString: String if component.peer.id == component.context.account.peerId { @@ -908,7 +908,7 @@ public final class StoryPeerListItemComponent: Component { switch ringAnimation { case let .progress(progress): - let progressTransition: Transition + let progressTransition: ComponentTransition if abs(progress - 0.028) < 0.001 { progressTransition = .immediate } else { @@ -968,7 +968,7 @@ public final class StoryPeerListItemComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/TitleActivityIndicatorComponent.swift b/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/TitleActivityIndicatorComponent.swift index 01faaca5b8..4b6c0ac433 100644 --- a/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/TitleActivityIndicatorComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/TitleActivityIndicatorComponent.swift @@ -198,7 +198,7 @@ public final class TitleActivityIndicatorComponent: Component { } } - func update(component: TitleActivityIndicatorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: TitleActivityIndicatorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let isFirstTime = self.component == nil self.component = component let _ = isFirstTime @@ -219,7 +219,7 @@ public final class TitleActivityIndicatorComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/StoryQualityUpgradeSheetScreen/Sources/StoryQualityUpgradeSheetScreen.swift b/submodules/TelegramUI/Components/Stories/StoryQualityUpgradeSheetScreen/Sources/StoryQualityUpgradeSheetScreen.swift index 3db72ef093..024a40960a 100644 --- a/submodules/TelegramUI/Components/Stories/StoryQualityUpgradeSheetScreen/Sources/StoryQualityUpgradeSheetScreen.swift +++ b/submodules/TelegramUI/Components/Stories/StoryQualityUpgradeSheetScreen/Sources/StoryQualityUpgradeSheetScreen.swift @@ -107,7 +107,7 @@ private final class StoryQualityUpgradeSheetContentComponent: Component { deinit { } - func update(component: StoryQualityUpgradeSheetContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoryQualityUpgradeSheetContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -265,7 +265,7 @@ private final class StoryQualityUpgradeSheetContentComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -306,7 +306,7 @@ private final class StoryQualityUpgradeSheetScreenComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: StoryQualityUpgradeSheetScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoryQualityUpgradeSheetScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let environment = environment[ViewControllerComponentContainer.Environment.self].value @@ -379,7 +379,7 @@ private final class StoryQualityUpgradeSheetScreenComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/StorySetIndicatorComponent/Sources/StorySetIndicatorComponent.swift b/submodules/TelegramUI/Components/Stories/StorySetIndicatorComponent/Sources/StorySetIndicatorComponent.swift index d2082327c7..2ff507bc33 100644 --- a/submodules/TelegramUI/Components/Stories/StorySetIndicatorComponent/Sources/StorySetIndicatorComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StorySetIndicatorComponent/Sources/StorySetIndicatorComponent.swift @@ -344,10 +344,10 @@ public final class StorySetIndicatorComponent: Component { return } if highlighted { - let transition = Transition(animation: .curve(duration: 0.16, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.16, curve: .easeInOut)) transition.setSublayerTransform(view: self.button, transform: CATransform3DMakeScale(0.8, 0.8, 1.0)) } else { - let transition = Transition(animation: .curve(duration: 0.24, curve: .easeInOut)) + let transition = ComponentTransition(animation: .curve(duration: 0.24, curve: .easeInOut)) transition.setSublayerTransform(view: self.button, transform: CATransform3DIdentity) } } @@ -361,7 +361,7 @@ public final class StorySetIndicatorComponent: Component { self.component?.action() } - func update(component: StorySetIndicatorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StorySetIndicatorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -476,7 +476,7 @@ public final class StorySetIndicatorComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/StoryStealthModeSheetScreen/Sources/StoryStealthModeInfoContentComponent.swift b/submodules/TelegramUI/Components/Stories/StoryStealthModeSheetScreen/Sources/StoryStealthModeInfoContentComponent.swift index 38cbd156f7..dae2462be1 100644 --- a/submodules/TelegramUI/Components/Stories/StoryStealthModeSheetScreen/Sources/StoryStealthModeInfoContentComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryStealthModeSheetScreen/Sources/StoryStealthModeInfoContentComponent.swift @@ -111,7 +111,7 @@ public final class StoryStealthModeInfoContentComponent: Component { } } - func update(component: StoryStealthModeInfoContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoryStealthModeInfoContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let sideInset: CGFloat = 16.0 @@ -313,7 +313,7 @@ public final class StoryStealthModeInfoContentComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/Stories/StoryStealthModeSheetScreen/Sources/StoryStealthModeSheetScreen.swift b/submodules/TelegramUI/Components/Stories/StoryStealthModeSheetScreen/Sources/StoryStealthModeSheetScreen.swift index 61ea6561a8..ba418b1545 100644 --- a/submodules/TelegramUI/Components/Stories/StoryStealthModeSheetScreen/Sources/StoryStealthModeSheetScreen.swift +++ b/submodules/TelegramUI/Components/Stories/StoryStealthModeSheetScreen/Sources/StoryStealthModeSheetScreen.swift @@ -78,7 +78,7 @@ private final class StoryStealthModeSheetContentComponent: Component { private func displayCooldown() { if !self.showCooldownToast { self.showCooldownToast = true - self.state?.updated(transition: Transition(animation: .curve(duration: 0.25, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut))) } self.hideCooldownTimer?.invalidate() @@ -91,11 +91,11 @@ private final class StoryStealthModeSheetContentComponent: Component { self.showCooldownToast = false - self.state?.updated(transition: Transition(animation: .curve(duration: 0.25, curve: .easeInOut))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.25, curve: .easeInOut))) }) } - func update(component: StoryStealthModeSheetContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoryStealthModeSheetContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.state = state @@ -326,7 +326,7 @@ private final class StoryStealthModeSheetContentComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -385,7 +385,7 @@ private final class StoryStealthModeSheetScreenComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: StoryStealthModeSheetScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: StoryStealthModeSheetScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let environment = environment[ViewControllerComponentContainer.Environment.self].value @@ -461,7 +461,7 @@ private final class StoryStealthModeSheetScreenComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/SwitchComponent/Sources/SwitchComponent.swift b/submodules/TelegramUI/Components/SwitchComponent/Sources/SwitchComponent.swift index 305628999b..8858bdaecd 100644 --- a/submodules/TelegramUI/Components/SwitchComponent/Sources/SwitchComponent.swift +++ b/submodules/TelegramUI/Components/SwitchComponent/Sources/SwitchComponent.swift @@ -55,7 +55,7 @@ public final class SwitchComponent: Component { self.component?.valueUpdated(self.switchView.isOn) } - func update(component: SwitchComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: SwitchComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.switchView.tintColor = component.tintColor @@ -72,7 +72,7 @@ public final class SwitchComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/TabSelectorComponent/Sources/TabSelectorComponent.swift b/submodules/TelegramUI/Components/TabSelectorComponent/Sources/TabSelectorComponent.swift index d54666377c..2a2536c59c 100644 --- a/submodules/TelegramUI/Components/TabSelectorComponent/Sources/TabSelectorComponent.swift +++ b/submodules/TelegramUI/Components/TabSelectorComponent/Sources/TabSelectorComponent.swift @@ -114,7 +114,7 @@ public final class TabSelectorComponent: Component { deinit { } - func update(component: TabSelectorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: TabSelectorComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { let selectionColorUpdated = component.colors.selection != self.component?.colors.selection self.component = component @@ -285,7 +285,7 @@ public final class TabSelectorComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/TextFieldComponent/Sources/TextFieldComponent.swift b/submodules/TelegramUI/Components/TextFieldComponent/Sources/TextFieldComponent.swift index 3a9b6894a8..12a9161dfd 100644 --- a/submodules/TelegramUI/Components/TextFieldComponent/Sources/TextFieldComponent.swift +++ b/submodules/TelegramUI/Components/TextFieldComponent/Sources/TextFieldComponent.swift @@ -382,7 +382,7 @@ public final class TextFieldComponent: Component { self.updateEntities() if currentAttributedText != updatedAttributedText && !self.isUpdating { - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged))) } } @@ -402,7 +402,7 @@ public final class TextFieldComponent: Component { return state.insertText(text) } if !self.isUpdating { - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged))) } } @@ -415,7 +415,7 @@ public final class TextFieldComponent: Component { return TextFieldComponent.InputState(inputText: text, selectionRange: selectionRange) } if !self.isUpdating { - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged))) } } @@ -449,7 +449,7 @@ public final class TextFieldComponent: Component { } } if !self.isUpdating { - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged))) } component.paste(.text) return false @@ -522,7 +522,7 @@ public final class TextFieldComponent: Component { self.updateEntities() if !self.isUpdating { - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged))) } } @@ -551,7 +551,7 @@ public final class TextFieldComponent: Component { return } if !self.isUpdating { - self.state?.updated(transition: Transition(animation: .curve(duration: 0.5, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textFocusChanged(isFocused: true)))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.5, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textFocusChanged(isFocused: true)))) } if component.isOneLineWhenUnfocused { Queue.mainQueue().justDispatch { @@ -562,7 +562,7 @@ public final class TextFieldComponent: Component { public func chatInputTextNodeDidFinishEditing() { if !self.isUpdating { - self.state?.updated(transition: Transition(animation: .curve(duration: 0.5, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textFocusChanged(isFocused: false)))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.5, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textFocusChanged(isFocused: false)))) } } @@ -967,7 +967,7 @@ public final class TextFieldComponent: Component { return TextFieldComponent.InputState(inputText: string, selectionRange: string.length ..< string.length) } if updateState && !self.isUpdating { - self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged))) + self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged))) } } @@ -1050,7 +1050,7 @@ public final class TextFieldComponent: Component { if let spoilerView = self.spoilerView { if animated { - let transition = Transition.easeInOut(duration: 0.3) + let transition = ComponentTransition.easeInOut(duration: 0.3) if revealed { transition.setAlpha(view: spoilerView, alpha: 0.0) } else { @@ -1167,7 +1167,7 @@ public final class TextFieldComponent: Component { } } - public func updateEmojiSuggestion(transition: Transition) { + public func updateEmojiSuggestion(transition: ComponentTransition) { guard let component = self.component else { return } @@ -1253,7 +1253,7 @@ public final class TextFieldComponent: Component { return CGPoint(x: rightmostX, y: rightmostY) } - func update(component: TextFieldComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: TextFieldComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.isUpdating = true defer { self.isUpdating = false @@ -1411,7 +1411,7 @@ public final class TextFieldComponent: Component { let hasMoreThanOneLine = ellipsisFrame.maxY < self.textView.contentSize.height - 12.0 - let ellipsisTransition: Transition + let ellipsisTransition: ComponentTransition if isEditing { ellipsisTransition = .easeInOut(duration: 0.2) } else { @@ -1435,7 +1435,7 @@ public final class TextFieldComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ToastComponent/Sources/ToastContentComponent.swift b/submodules/TelegramUI/Components/ToastComponent/Sources/ToastContentComponent.swift index 3d355dcc88..96b8035f7b 100644 --- a/submodules/TelegramUI/Components/ToastComponent/Sources/ToastContentComponent.swift +++ b/submodules/TelegramUI/Components/ToastComponent/Sources/ToastContentComponent.swift @@ -51,7 +51,7 @@ public final class ToastContentComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: ToastContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ToastContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { var contentHeight: CGFloat = 0.0 let leftInset: CGFloat = 9.0 @@ -100,7 +100,7 @@ public final class ToastContentComponent: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/TokenListTextField/Sources/TokenListTextField.swift b/submodules/TelegramUI/Components/TokenListTextField/Sources/TokenListTextField.swift index d46862dac9..8212f089a5 100644 --- a/submodules/TelegramUI/Components/TokenListTextField/Sources/TokenListTextField.swift +++ b/submodules/TelegramUI/Components/TokenListTextField/Sources/TokenListTextField.swift @@ -163,7 +163,7 @@ public final class TokenListTextField: Component { } } - func update(component: TokenListTextField, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: TokenListTextField, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component self.componentState = state @@ -195,7 +195,7 @@ public final class TokenListTextField: Component { return } self.component?.isFocusedUpdated(self.tokenListNode?.isFocused ?? false) - self.componentState?.updated(transition: Transition(animation: .curve(duration: 0.35, curve: .spring))) + self.componentState?.updated(transition: ComponentTransition(animation: .curve(duration: 0.35, curve: .spring))) } tokenListNode.textUpdated = { [weak self] text in @@ -261,7 +261,7 @@ public final class TokenListTextField: Component { return View(frame: CGRect()) } - public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } diff --git a/submodules/TelegramUI/Components/VideoMessageCameraScreen/Sources/LoadingEffectView.swift b/submodules/TelegramUI/Components/VideoMessageCameraScreen/Sources/LoadingEffectView.swift index 09d0508eb6..565032002d 100644 --- a/submodules/TelegramUI/Components/VideoMessageCameraScreen/Sources/LoadingEffectView.swift +++ b/submodules/TelegramUI/Components/VideoMessageCameraScreen/Sources/LoadingEffectView.swift @@ -94,7 +94,7 @@ final class LoadingEffectView: UIView { self.borderGradientView.layer.add(animation, forKey: "shimmer") } - func update(size: CGSize, transition: Transition) { + func update(size: CGSize, transition: ComponentTransition) { if self.backgroundView.bounds.size != size { self.backgroundView.layer.removeAllAnimations() diff --git a/submodules/TelegramUI/Components/VideoMessageCameraScreen/Sources/VideoMessageCameraScreen.swift b/submodules/TelegramUI/Components/VideoMessageCameraScreen/Sources/VideoMessageCameraScreen.swift index 8438eaed7a..ffe0785437 100644 --- a/submodules/TelegramUI/Components/VideoMessageCameraScreen/Sources/VideoMessageCameraScreen.swift +++ b/submodules/TelegramUI/Components/VideoMessageCameraScreen/Sources/VideoMessageCameraScreen.swift @@ -1080,13 +1080,13 @@ public class VideoMessageCameraScreen: ViewController { }, transition: .easeInOut(duration: 0.2)) } - func requestUpdateLayout(transition: Transition) { + func requestUpdateLayout(transition: ComponentTransition) { if let layout = self.validLayout { self.containerLayoutUpdated(layout: layout, forceUpdate: true, transition: transition) } } - func containerLayoutUpdated(layout: ContainerViewLayout, forceUpdate: Bool = false, transition: Transition) { + func containerLayoutUpdated(layout: ContainerViewLayout, forceUpdate: Bool = false, transition: ComponentTransition) { guard let controller = self.controller else { return } @@ -1296,13 +1296,13 @@ public class VideoMessageCameraScreen: ViewController { return self.node.cameraState } - fileprivate func updateCameraState(_ f: (CameraState) -> CameraState, transition: Transition) { + fileprivate func updateCameraState(_ f: (CameraState) -> CameraState, transition: ComponentTransition) { self.node.cameraState = f(self.node.cameraState) self.node.requestUpdateLayout(transition: transition) self.durationValue.set(self.cameraState.duration) } - fileprivate func updatePreviewState(_ f: (PreviewState?) -> PreviewState?, transition: Transition) { + fileprivate func updatePreviewState(_ f: (PreviewState?) -> PreviewState?, transition: ComponentTransition) { self.node.previewState = f(self.node.previewState) self.node.requestUpdateLayout(transition: transition) } @@ -1736,7 +1736,7 @@ public class VideoMessageCameraScreen: ViewController { super.containerLayoutUpdated(layout, transition: transition) if !self.isDismissed { - (self.displayNode as! Node).containerLayoutUpdated(layout: layout, transition: Transition(transition)) + (self.displayNode as! Node).containerLayoutUpdated(layout: layout, transition: ComponentTransition(transition)) } } @@ -1842,7 +1842,7 @@ private final class VideoMessageSendMessageContextPreview: UIView, ChatSendMessa preconditionFailure() } - func animateIn(transition: Transition) { + func animateIn(transition: ComponentTransition) { self.addSubview(self.previewContainerContentView) guard let previewContainerContentParentView = self.previewContainerContentParentView else { @@ -1855,7 +1855,7 @@ private final class VideoMessageSendMessageContextPreview: UIView, ChatSendMessa transition.animatePosition(view: self.previewContainerContentView, from: CGPoint(x: fromFrame.midX - toFrame.midX, y: fromFrame.midY - toFrame.midY), to: CGPoint(), additive: true) } - func animateOut(transition: Transition) { + func animateOut(transition: ComponentTransition) { guard let previewContainerContentParentView = self.previewContainerContentParentView else { return } @@ -1873,7 +1873,7 @@ private final class VideoMessageSendMessageContextPreview: UIView, ChatSendMessa }) } - func animateOutOnSend(transition: Transition) { + func animateOutOnSend(transition: ComponentTransition) { guard let previewContainerContentParentView = self.previewContainerContentParentView else { return } @@ -1887,7 +1887,7 @@ private final class VideoMessageSendMessageContextPreview: UIView, ChatSendMessa previewContainerContentParentView.addSubview(self.previewContainerContentView) } - func update(containerSize: CGSize, transition: Transition) -> CGSize { + func update(containerSize: CGSize, transition: ComponentTransition) -> CGSize { return self.previewContainerContentView.bounds.size } } diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift index d8951af158..154c26a9d3 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift @@ -1747,7 +1747,16 @@ extension ChatControllerImpl { return } if let messageId = messageId { - if canSendMessagesToChat(strongSelf.presentationInterfaceState) { + let intrinsicCanSendMessagesHere = canSendMessagesToChat(strongSelf.presentationInterfaceState) + var canSendMessagesHere = intrinsicCanSendMessagesHere + if case .standard(.embedded) = strongSelf.presentationInterfaceState.mode { + canSendMessagesHere = false + } + if case .inline = strongSelf.presentationInterfaceState.mode { + canSendMessagesHere = false + } + + if canSendMessagesHere { let _ = strongSelf.presentVoiceMessageDiscardAlert(action: { if let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId) { strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState({ @@ -1771,11 +1780,18 @@ extension ChatControllerImpl { messageId: messageId, quote: nil ) + completion(.immediate, { guard let self else { return } - moveReplyMessageToAnotherChat(selfController: self, replySubject: replySubject) + if intrinsicCanSendMessagesHere { + if let peerId = self.chatLocation.peerId { + moveReplyToChat(selfController: self, peerId: peerId, threadId: self.chatLocation.threadId, replySubject: replySubject, completion: {}) + } + } else { + moveReplyMessageToAnotherChat(selfController: self, replySubject: replySubject) + } }) } } else { diff --git a/submodules/TelegramUI/Sources/Chat/ChatMessageActionOptions.swift b/submodules/TelegramUI/Sources/Chat/ChatMessageActionOptions.swift index 2a26689216..cd000238ec 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatMessageActionOptions.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatMessageActionOptions.swift @@ -617,73 +617,8 @@ func moveReplyMessageToAnotherChat(selfController: ChatControllerImpl, replySubj selfController.searchResultsController = nil strongController.dismiss() } else { - if let navigationController = selfController.navigationController as? NavigationController { - for controller in navigationController.viewControllers { - if let maybeChat = controller as? ChatControllerImpl { - if case .peer(peerId) = maybeChat.chatLocation { - var isChatPinnedMessages = false - if case .pinnedMessages = maybeChat.presentationInterfaceState.subject { - isChatPinnedMessages = true - } - if !isChatPinnedMessages { - maybeChat.updateChatPresentationInterfaceState(animated: false, interactive: true, { $0.updatedInterfaceState({ $0.withUpdatedReplyMessageSubject(replySubject).withoutSelectionState() }) }) - selfController.dismiss() - strongController.dismiss() - return - } - } - } - } - } - - let _ = (ChatInterfaceState.update(engine: selfController.context.engine, peerId: peerId, threadId: threadId, { currentState in - return currentState.withUpdatedReplyMessageSubject(replySubject) - }) - |> deliverOnMainQueue).startStandalone(completed: { [weak selfController] in - guard let selfController else { - return - } - let proceed: (ChatController) -> Void = { [weak selfController] chatController in - guard let selfController else { - return - } - selfController.updateChatPresentationInterfaceState(animated: false, interactive: true, { $0.updatedInterfaceState({ $0.withUpdatedReplyMessageSubject(nil).withUpdatedSendMessageEffect(nil).withoutSelectionState() }) }) - - let navigationController: NavigationController? - if let parentController = selfController.parentController { - navigationController = (parentController.navigationController as? NavigationController) - } else { - navigationController = selfController.effectiveNavigationController - } - - if let navigationController = navigationController { - var viewControllers = navigationController.viewControllers - if threadId != nil { - viewControllers.insert(chatController, at: viewControllers.count - 2) - } else { - viewControllers.insert(chatController, at: viewControllers.count - 1) - } - navigationController.setViewControllers(viewControllers, animated: false) - - selfController.controllerNavigationDisposable.set((chatController.ready.get() - |> SwiftSignalKit.filter { $0 } - |> take(1) - |> deliverOnMainQueue).startStrict(next: { [weak navigationController] _ in - viewControllers.removeAll(where: { $0 is PeerSelectionController }) - navigationController?.setViewControllers(viewControllers, animated: true) - })) - } - } - if let threadId = threadId { - let _ = (selfController.context.sharedContext.chatControllerForForumThread(context: selfController.context, peerId: peerId, threadId: threadId) - |> deliverOnMainQueue).startStandalone(next: { chatController in - proceed(chatController) - }) - } else { - let chatController = ChatControllerImpl(context: selfController.context, chatLocation: .peer(id: peerId)) - chatController.activateInput(type: .text) - proceed(chatController) - } + moveReplyToChat(selfController: selfController, peerId: peerId, threadId: threadId, replySubject: replySubject, completion: { [weak strongController] in + strongController?.dismiss() }) } } @@ -692,6 +627,86 @@ func moveReplyMessageToAnotherChat(selfController: ChatControllerImpl, replySubj }) } +func moveReplyToChat(selfController: ChatControllerImpl, peerId: EnginePeer.Id, threadId: Int64?, replySubject: ChatInterfaceState.ReplyMessageSubject, completion: @escaping () -> Void) { + if let navigationController = selfController.effectiveNavigationController { + for controller in navigationController.viewControllers { + if let maybeChat = controller as? ChatControllerImpl { + if case .peer(peerId) = maybeChat.chatLocation { + var isChatPinnedMessages = false + if case .pinnedMessages = maybeChat.presentationInterfaceState.subject { + isChatPinnedMessages = true + } + if !isChatPinnedMessages { + maybeChat.updateChatPresentationInterfaceState(animated: false, interactive: true, { $0.updatedInterfaceState({ $0.withUpdatedReplyMessageSubject(replySubject).withoutSelectionState() }) }) + + var viewControllers = navigationController.viewControllers + if let index = viewControllers.firstIndex(where: { $0 === maybeChat }), index != viewControllers.count - 1 { + viewControllers.removeSubrange((index + 1) ..< viewControllers.count) + navigationController.setViewControllers(viewControllers, animated: true) + } else { + selfController.dismiss() + } + + completion() + return + } + } + } + } + } + + let _ = (ChatInterfaceState.update(engine: selfController.context.engine, peerId: peerId, threadId: threadId, { currentState in + return currentState.withUpdatedReplyMessageSubject(replySubject) + }) + |> deliverOnMainQueue).startStandalone(completed: { [weak selfController] in + guard let selfController else { + return + } + let proceed: (ChatController) -> Void = { [weak selfController] chatController in + guard let selfController else { + return + } + selfController.updateChatPresentationInterfaceState(animated: false, interactive: true, { $0.updatedInterfaceState({ $0.withUpdatedReplyMessageSubject(nil).withUpdatedSendMessageEffect(nil).withoutSelectionState() }) }) + + let navigationController: NavigationController? + if let parentController = selfController.parentController { + navigationController = (parentController.navigationController as? NavigationController) + } else { + navigationController = selfController.effectiveNavigationController + } + + if let navigationController = navigationController { + var viewControllers = navigationController.viewControllers + if threadId != nil { + viewControllers.insert(chatController, at: viewControllers.count - 2) + } else { + viewControllers.insert(chatController, at: viewControllers.count - 1) + } + navigationController.setViewControllers(viewControllers, animated: false) + + selfController.controllerNavigationDisposable.set((chatController.ready.get() + |> SwiftSignalKit.filter { $0 } + |> take(1) + |> timeout(0.2, queue: .mainQueue(), alternate: .single(true)) + |> deliverOnMainQueue).startStrict(next: { [weak navigationController] _ in + viewControllers.removeAll(where: { $0 is PeerSelectionController }) + navigationController?.setViewControllers(viewControllers, animated: true) + })) + } + } + if let threadId = threadId { + let _ = (selfController.context.sharedContext.chatControllerForForumThread(context: selfController.context, peerId: peerId, threadId: threadId) + |> deliverOnMainQueue).startStandalone(next: { chatController in + proceed(chatController) + }) + } else { + let chatController = ChatControllerImpl(context: selfController.context, chatLocation: .peer(id: peerId)) + chatController.activateInput(type: .text) + proceed(chatController) + } + }) +} + private func chatLinkOptions(selfController: ChatControllerImpl, sourceNode: ASDisplayNode, getContextController: @escaping () -> ContextController?, replySelectionState: Promise) -> ContextController.Source? { guard let peerId = selfController.chatLocation.peerId else { return nil diff --git a/submodules/TelegramUI/Sources/ChatBusinessLinkTitlePanelNode.swift b/submodules/TelegramUI/Sources/ChatBusinessLinkTitlePanelNode.swift index b17db6edb0..4fe8585ec1 100644 --- a/submodules/TelegramUI/Sources/ChatBusinessLinkTitlePanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatBusinessLinkTitlePanelNode.swift @@ -69,7 +69,7 @@ private final class ChatBusinessLinkTitlePanelComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: ChatBusinessLinkTitlePanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ChatBusinessLinkTitlePanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let size = CGSize(width: availableSize.width, height: 40.0) @@ -140,7 +140,7 @@ private final class ChatBusinessLinkTitlePanelComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -210,7 +210,7 @@ final class ChatBusinessLinkTitlePanelNode: ChatTitleAccessoryPanelNode { transition.updateFrame(node: self.separatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: width, height: UIScreenPixel))) let contentSize = self.content.update( - transition: Transition(transition), + transition: ComponentTransition(transition), component: AnyComponent(ChatBusinessLinkTitlePanelComponent( context: self.context, theme: interfaceState.theme, diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index 88dc0f482a..985755bef6 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -2514,7 +2514,7 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate { let peerId = self.chatPresentationInterfaceState.chatLocation.peerId let inlineSearchResults: ComponentView - var inlineSearchResultsTransition = Transition(transition) + var inlineSearchResultsTransition = ComponentTransition(transition) if let current = self.inlineSearchResults { inlineSearchResults = current } else { diff --git a/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift b/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift index 932855e496..e5a53ffd22 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift @@ -282,7 +282,7 @@ private func canViewReadStats(message: Message, participantCount: Int?, isMessag func canReplyInChat(_ chatPresentationInterfaceState: ChatPresentationInterfaceState, accountPeerId: PeerId) -> Bool { if case let .customChatContents(contents) = chatPresentationInterfaceState.subject, case .hashTagSearch = contents.kind { - return false + return true } if case .customChatContents = chatPresentationInterfaceState.chatLocation { return true @@ -303,7 +303,7 @@ func canReplyInChat(_ chatPresentationInterfaceState: ChatPresentationInterfaceS } switch chatPresentationInterfaceState.mode { case .inline: - return false + return true case .standard(.embedded): return false default: @@ -905,15 +905,17 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState messageActions.editTags = Set() } - return (MessageContextMenuData( + let data = MessageContextMenuData( starStatus: stickerSaveStatus, - canReply: canReply && !isEmbeddedMode, + canReply: canReply, canPin: canPin && !isEmbeddedMode, canEdit: canEdit && !isEmbeddedMode, canSelect: canSelect && !isEmbeddedMode, resourceStatus: resourceStatus, messageActions: messageActions - ), updatingMessageMedia, infoSummaryData, appConfig, isMessageRead, messageViewsPrivacyTips, availableReactions, translationSettings, loggingSettings, notificationSoundList, accountPeer) + ) + + return (data, updatingMessageMedia, infoSummaryData, appConfig, isMessageRead, messageViewsPrivacyTips, availableReactions, translationSettings, loggingSettings, notificationSoundList, accountPeer) } return dataSignal diff --git a/submodules/TelegramUI/Sources/ChatManagingBotTitlePanelNode.swift b/submodules/TelegramUI/Sources/ChatManagingBotTitlePanelNode.swift index ca67940799..2a91e8555c 100644 --- a/submodules/TelegramUI/Sources/ChatManagingBotTitlePanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatManagingBotTitlePanelNode.swift @@ -90,7 +90,7 @@ private final class ChatManagingBotTitlePanelComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: ChatManagingBotTitlePanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(component: ChatManagingBotTitlePanelComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component let topInset: CGFloat = 6.0 @@ -243,7 +243,7 @@ private final class ChatManagingBotTitlePanelComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } @@ -396,7 +396,7 @@ final class ChatManagingBotTitlePanelNode: ChatTitleAccessoryPanelNode { if let managingBot = interfaceState.contactStatus?.managingBot { let contentSize = self.content.update( - transition: Transition(transition), + transition: ComponentTransition(transition), component: AnyComponent(ChatManagingBotTitlePanelComponent( context: self.context, theme: interfaceState.theme, diff --git a/submodules/TelegramUI/Sources/ChatPremiumRequiredInputPanelNode.swift b/submodules/TelegramUI/Sources/ChatPremiumRequiredInputPanelNode.swift index de6fe788e4..0add3d1da0 100644 --- a/submodules/TelegramUI/Sources/ChatPremiumRequiredInputPanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatPremiumRequiredInputPanelNode.swift @@ -78,13 +78,13 @@ final class ChatPremiumRequiredInputPanelNode: ChatInputPanelNode { return currentLayout.height } - let height = self.update(params: params, transition: Transition(transition)) + let height = self.update(params: params, transition: ComponentTransition(transition)) self.currentLayout = Layout(params: params, height: height) return height } - private func update(params: Params, transition: Transition) -> CGFloat { + private func update(params: Params, transition: ComponentTransition) -> CGFloat { let height: CGFloat if case .regular = params.metrics.widthClass { height = 49.0 diff --git a/submodules/TelegramUI/Sources/ChatRecordingPreviewInputPanelNode.swift b/submodules/TelegramUI/Sources/ChatRecordingPreviewInputPanelNode.swift index 6f11af4fe4..a6eec7554e 100644 --- a/submodules/TelegramUI/Sources/ChatRecordingPreviewInputPanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatRecordingPreviewInputPanelNode.swift @@ -20,8 +20,13 @@ import TelegramNotices import ComponentFlow import MediaScrubberComponent +#if swift(>=6.0) +extension AudioWaveformNode: @retroactive CustomMediaPlayerScrubbingForegroundNode { +} +#else extension AudioWaveformNode: CustomMediaPlayerScrubbingForegroundNode { } +#endif final class ChatRecordingPreviewViewForOverlayContent: UIView, ChatInputPanelViewForOverlayContent { let ignoreHit: (UIView, CGPoint) -> Bool diff --git a/submodules/TelegramUI/Sources/ChatSearchTitleAccessoryPanelNode.swift b/submodules/TelegramUI/Sources/ChatSearchTitleAccessoryPanelNode.swift index 3b9af15fca..1dbeb89377 100644 --- a/submodules/TelegramUI/Sources/ChatSearchTitleAccessoryPanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatSearchTitleAccessoryPanelNode.swift @@ -106,7 +106,7 @@ final class ChatSearchTitleAccessoryPanelNode: ChatTitleAccessoryPanelNode, Chat if highlighted { self.containerButton.alpha = 0.7 } else { - Transition.easeInOut(duration: 0.25).setAlpha(view: self.containerButton, alpha: 1.0) + ComponentTransition.easeInOut(duration: 0.25).setAlpha(view: self.containerButton, alpha: 1.0) } } } @@ -119,7 +119,7 @@ final class ChatSearchTitleAccessoryPanelNode: ChatTitleAccessoryPanelNode, Chat self.action() } - func update(theme: PresentationTheme, strings: PresentationStrings, height: CGFloat, isUnlock: Bool, transition: Transition) -> CGSize { + func update(theme: PresentationTheme, strings: PresentationStrings, height: CGFloat, isUnlock: Bool, transition: ComponentTransition) -> CGSize { let titleIconSpacing: CGFloat = 0.0 let titleIconSize = self.titleIcon.update( @@ -308,7 +308,7 @@ final class ChatSearchTitleAccessoryPanelNode: ChatTitleAccessoryPanelNode, Chat return super.hitTest(mappedPoint, with: event) } - func update(item: Item, isSelected: Bool, isLocked: Bool, theme: PresentationTheme, height: CGFloat, transition: Transition) -> CGSize { + func update(item: Item, isSelected: Bool, isLocked: Bool, theme: PresentationTheme, height: CGFloat, transition: ComponentTransition) -> CGSize { let spacing: CGFloat = 3.0 let contentsAlpha: CGFloat = isLocked ? 0.6 : 1.0 diff --git a/submodules/TelegramUI/Sources/ChatTagSearchInputPanelNode.swift b/submodules/TelegramUI/Sources/ChatTagSearchInputPanelNode.swift index 0e5eaa3c47..5834b2b0bf 100644 --- a/submodules/TelegramUI/Sources/ChatTagSearchInputPanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatTagSearchInputPanelNode.swift @@ -122,7 +122,7 @@ final class ChatTagSearchInputPanelNode: ChatInputPanelNode { return currentLayout.height } - let height = self.update(params: params, transition: Transition(transition)) + let height = self.update(params: params, transition: ComponentTransition(transition)) self.currentLayout = Layout(params: params, height: height) return height @@ -133,7 +133,7 @@ final class ChatTagSearchInputPanelNode: ChatInputPanelNode { self.tagMessageCount = (tag, count, nil) } - private func update(transition: Transition) { + private func update(transition: ComponentTransition) { if self.isUpdating { return } @@ -142,7 +142,7 @@ final class ChatTagSearchInputPanelNode: ChatInputPanelNode { } } - private func update(params: Params, transition: Transition) -> CGFloat { + private func update(params: Params, transition: ComponentTransition) -> CGFloat { self.isUpdating = true defer { self.isUpdating = false diff --git a/submodules/TelegramUI/Sources/ChatTextInputActionButtonsNode.swift b/submodules/TelegramUI/Sources/ChatTextInputActionButtonsNode.swift index da675ea763..318de27a4d 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputActionButtonsNode.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputActionButtonsNode.swift @@ -323,7 +323,7 @@ final class ChatTextInputActionButtonsNode: ASDisplayNode, ChatSendMessageAction } func makeCustomContents() -> UIView? { - if self.sendButtonHasApplyIcon { + if self.sendButtonHasApplyIcon || self.effectBadgeView != nil { let result = UIView() result.frame = self.bounds if let copyView = self.sendContainerNode.view.snapshotView(afterScreenUpdates: false) { diff --git a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift index c368cb1c7a..2b4cfbfc8f 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift @@ -2555,7 +2555,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch //transition.updateFrame(node: textInputNode, frame: textFieldFrame) textInputNode.frame = textFieldFrame textInputNode.updateLayout(size: textFieldFrame.size) - self.updateInputField(textInputFrame: textFieldFrame, transition: Transition(transition)) + self.updateInputField(textInputFrame: textFieldFrame, transition: ComponentTransition(transition)) if shouldUpdateLayout { textInputNode.layout() } @@ -3193,7 +3193,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch private var dismissedEmojiSuggestionPosition: EmojiSuggestionPosition? - private func updateInputField(textInputFrame: CGRect, transition: Transition) { + private func updateInputField(textInputFrame: CGRect, transition: ComponentTransition) { guard let textInputNode = self.textInputNode, let context = self.context else { return } diff --git a/submodules/TelegramUI/Sources/CommandChatInputContextPanelNode.swift b/submodules/TelegramUI/Sources/CommandChatInputContextPanelNode.swift index 6c309a0169..88d69874ba 100644 --- a/submodules/TelegramUI/Sources/CommandChatInputContextPanelNode.swift +++ b/submodules/TelegramUI/Sources/CommandChatInputContextPanelNode.swift @@ -275,7 +275,7 @@ final class CommandChatInputContextPanelNode: ChatInputContextPanelNode { private let listView: ListView private let listBackgroundView: UIView private var currentEntries: [CommandChatInputContextPanelEntry]? - private var contentOffsetChangeTransition: Transition? + private var contentOffsetChangeTransition: ComponentTransition? private var isAnimatingOut: Bool = false private var enqueuedTransitions: [(CommandChatInputContextPanelTransition, Bool)] = [] @@ -323,7 +323,7 @@ final class CommandChatInputContextPanelNode: ChatInputContextPanelNode { } } - let transition: Transition = self.contentOffsetChangeTransition ?? .immediate + let transition: ComponentTransition = self.contentOffsetChangeTransition ?? .immediate transition.setFrame(view: self.listBackgroundView, frame: CGRect(origin: CGPoint(x: 0.0, y: topItemOffset), size: CGSize(width: self.listView.bounds.width, height: self.listView.bounds.height + 1000.0))) } } @@ -503,7 +503,7 @@ final class CommandChatInputContextPanelNode: ChatInputContextPanelNode { let (duration, curve) = listViewAnimationDurationAndCurve(transition: transition) let updateSizeAndInsets = ListViewUpdateSizeAndInsets(size: size, insets: insets, duration: duration, curve: curve) - self.contentOffsetChangeTransition = Transition(transition) + self.contentOffsetChangeTransition = ComponentTransition(transition) self.listView.transaction(deleteIndices: [], insertIndicesAndItems: [], updateIndicesAndItems: [], options: [.Synchronous, .LowLatency], scrollToItem: nil, updateSizeAndInsets: updateSizeAndInsets, stationaryItemRange: nil, updateOpaqueState: nil, completion: { _ in }) diff --git a/submodules/TelegramUI/Sources/TelegramRootController.swift b/submodules/TelegramUI/Sources/TelegramRootController.swift index e7c20c4b00..1929dbf2a6 100644 --- a/submodules/TelegramUI/Sources/TelegramRootController.swift +++ b/submodules/TelegramUI/Sources/TelegramRootController.swift @@ -687,6 +687,10 @@ public final class TelegramRootController: NavigationController, TelegramRootCon } } -extension MediaEditorScreen.Result: MediaEditorScreenResult { - +#if swift(>=6.0) +extension MediaEditorScreen.Result: @retroactive MediaEditorScreenResult { } +#else +extension MediaEditorScreen.Result: MediaEditorScreenResult { +} +#endif diff --git a/submodules/TelegramVoip/Sources/GroupCallContext.swift b/submodules/TelegramVoip/Sources/GroupCallContext.swift index daefa3fa48..c673e528cb 100644 --- a/submodules/TelegramVoip/Sources/GroupCallContext.swift +++ b/submodules/TelegramVoip/Sources/GroupCallContext.swift @@ -463,7 +463,7 @@ public final class OngoingGroupCallContext { private let audioSessionActiveDisposable = MetaDisposable() - init(queue: Queue, inputDeviceId: String, outputDeviceId: String, audioSessionActive: Signal, video: OngoingCallVideoCapturer?, requestMediaChannelDescriptions: @escaping (Set, @escaping ([MediaChannelDescription]) -> Void) -> Disposable, rejoinNeeded: @escaping () -> Void, outgoingAudioBitrateKbit: Int32?, videoContentType: VideoContentType, enableNoiseSuppression: Bool, disableAudioInput: Bool, preferX264: Bool, logPath: String) { + init(queue: Queue, inputDeviceId: String, outputDeviceId: String, audioSessionActive: Signal, video: OngoingCallVideoCapturer?, requestMediaChannelDescriptions: @escaping (Set, @escaping ([MediaChannelDescription]) -> Void) -> Disposable, rejoinNeeded: @escaping () -> Void, outgoingAudioBitrateKbit: Int32?, videoContentType: VideoContentType, enableNoiseSuppression: Bool, disableAudioInput: Bool, preferX264: Bool, logPath: String, onMutedSpeechActivityDetected: @escaping (Bool) -> Void) { self.queue = queue #if os(iOS) @@ -576,6 +576,9 @@ public final class OngoingGroupCallContext { disableAudioInput: disableAudioInput, preferX264: preferX264, logPath: logPath, + onMutedSpeechActivityDetected: { value in + onMutedSpeechActivityDetected(value) + }, audioDevice: audioDevice ) #else @@ -669,7 +672,8 @@ public final class OngoingGroupCallContext { enableNoiseSuppression: enableNoiseSuppression, disableAudioInput: disableAudioInput, preferX264: preferX264, - logPath: logPath + logPath: logPath, + onMutedSpeechActivityDetected: { _ in } ) #endif @@ -1109,10 +1113,10 @@ public final class OngoingGroupCallContext { } } - public init(inputDeviceId: String = "", outputDeviceId: String = "", audioSessionActive: Signal, video: OngoingCallVideoCapturer?, requestMediaChannelDescriptions: @escaping (Set, @escaping ([MediaChannelDescription]) -> Void) -> Disposable, rejoinNeeded: @escaping () -> Void, outgoingAudioBitrateKbit: Int32?, videoContentType: VideoContentType, enableNoiseSuppression: Bool, disableAudioInput: Bool, preferX264: Bool, logPath: String) { + public init(inputDeviceId: String = "", outputDeviceId: String = "", audioSessionActive: Signal, video: OngoingCallVideoCapturer?, requestMediaChannelDescriptions: @escaping (Set, @escaping ([MediaChannelDescription]) -> Void) -> Disposable, rejoinNeeded: @escaping () -> Void, outgoingAudioBitrateKbit: Int32?, videoContentType: VideoContentType, enableNoiseSuppression: Bool, disableAudioInput: Bool, preferX264: Bool, logPath: String, onMutedSpeechActivityDetected: @escaping (Bool) -> Void) { let queue = self.queue self.impl = QueueLocalObject(queue: queue, generate: { - return Impl(queue: queue, inputDeviceId: inputDeviceId, outputDeviceId: outputDeviceId, audioSessionActive: audioSessionActive, video: video, requestMediaChannelDescriptions: requestMediaChannelDescriptions, rejoinNeeded: rejoinNeeded, outgoingAudioBitrateKbit: outgoingAudioBitrateKbit, videoContentType: videoContentType, enableNoiseSuppression: enableNoiseSuppression, disableAudioInput: disableAudioInput, preferX264: preferX264, logPath: logPath) + return Impl(queue: queue, inputDeviceId: inputDeviceId, outputDeviceId: outputDeviceId, audioSessionActive: audioSessionActive, video: video, requestMediaChannelDescriptions: requestMediaChannelDescriptions, rejoinNeeded: rejoinNeeded, outgoingAudioBitrateKbit: outgoingAudioBitrateKbit, videoContentType: videoContentType, enableNoiseSuppression: enableNoiseSuppression, disableAudioInput: disableAudioInput, preferX264: preferX264, logPath: logPath, onMutedSpeechActivityDetected: onMutedSpeechActivityDetected) }) } diff --git a/submodules/TgVoipWebrtc/PublicHeaders/TgVoipWebrtc/OngoingCallThreadLocalContext.h b/submodules/TgVoipWebrtc/PublicHeaders/TgVoipWebrtc/OngoingCallThreadLocalContext.h index d7b772dfd0..8b2c52d3cd 100644 --- a/submodules/TgVoipWebrtc/PublicHeaders/TgVoipWebrtc/OngoingCallThreadLocalContext.h +++ b/submodules/TgVoipWebrtc/PublicHeaders/TgVoipWebrtc/OngoingCallThreadLocalContext.h @@ -414,6 +414,7 @@ typedef NS_ENUM(int32_t, OngoingGroupCallRequestedVideoQuality) { disableAudioInput:(bool)disableAudioInput preferX264:(bool)preferX264 logPath:(NSString * _Nonnull)logPath +onMutedSpeechActivityDetected:(void (^ _Nullable)(bool))onMutedSpeechActivityDetected audioDevice:(SharedCallAudioDevice * _Nullable)audioDevice; - (void)stop; diff --git a/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm b/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm index 74f1f6f5a9..fe3df0061a 100644 --- a/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm +++ b/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm @@ -1669,6 +1669,8 @@ private: rtc::Thread *_currentAudioDeviceModuleThread; SharedCallAudioDevice * _audioDevice; + + void (^_onMutedSpeechActivityDetected)(bool); } @end @@ -1691,6 +1693,7 @@ private: disableAudioInput:(bool)disableAudioInput preferX264:(bool)preferX264 logPath:(NSString * _Nonnull)logPath +onMutedSpeechActivityDetected:(void (^ _Nullable)(bool))onMutedSpeechActivityDetected audioDevice:(SharedCallAudioDevice * _Nullable)audioDevice { self = [super init]; if (self != nil) { @@ -1703,6 +1706,8 @@ audioDevice:(SharedCallAudioDevice * _Nullable)audioDevice { _networkStateUpdated = [networkStateUpdated copy]; _videoCapturer = videoCapturer; + _onMutedSpeechActivityDetected = [onMutedSpeechActivityDetected copy]; + _audioDevice = audioDevice; std::shared_ptr> audioDeviceModule; if (_audioDevice) { @@ -1917,12 +1922,19 @@ audioDevice:(SharedCallAudioDevice * _Nullable)audioDevice { return std::make_shared(task); }, .minOutgoingVideoBitrateKbit = minOutgoingVideoBitrateKbit, - .createAudioDeviceModule = [weakSelf, queue, disableAudioInput, audioDeviceModule](webrtc::TaskQueueFactory *taskQueueFactory) -> rtc::scoped_refptr { + .createAudioDeviceModule = [weakSelf, queue, disableAudioInput, audioDeviceModule, onMutedSpeechActivityDetected = _onMutedSpeechActivityDetected](webrtc::TaskQueueFactory *taskQueueFactory) -> rtc::scoped_refptr { if (audioDeviceModule) { return audioDeviceModule->getSyncAssumingSameThread()->audioDeviceModule(); } else { rtc::Thread *audioDeviceModuleThread = rtc::Thread::Current(); auto resultModule = rtc::make_ref_counted(false, disableAudioInput, disableAudioInput ? 2 : 1); + if (resultModule) { + resultModule->mutedSpeechDetectionChanged = ^(bool value) { + if (onMutedSpeechActivityDetected) { + onMutedSpeechActivityDetected(value); + } + }; + } [queue dispatch:^{ __strong GroupCallThreadLocalContext *strongSelf = weakSelf; if (strongSelf) { @@ -1932,6 +1944,14 @@ audioDevice:(SharedCallAudioDevice * _Nullable)audioDevice { }]; return resultModule; } + }, + .onMutedSpeechActivityDetected = [weakSelf, queue](bool value) { + [queue dispatch:^{ + __strong GroupCallThreadLocalContext *strongSelf = weakSelf; + if (strongSelf && strongSelf->_onMutedSpeechActivityDetected) { + strongSelf->_onMutedSpeechActivityDetected(value); + } + }]; } })); } diff --git a/submodules/TgVoipWebrtc/tgcalls b/submodules/TgVoipWebrtc/tgcalls index 8721352f45..8344f8ca2a 160000 --- a/submodules/TgVoipWebrtc/tgcalls +++ b/submodules/TgVoipWebrtc/tgcalls @@ -1 +1 @@ -Subproject commit 8721352f452128adec41c254b8407a4cb18cbbeb +Subproject commit 8344f8ca2a043d0812743260c31a086a82190489 diff --git a/submodules/TooltipUI/Sources/TooltipScreen.swift b/submodules/TooltipUI/Sources/TooltipScreen.swift index 330aa3ea3b..3abe33c29a 100644 --- a/submodules/TooltipUI/Sources/TooltipScreen.swift +++ b/submodules/TooltipUI/Sources/TooltipScreen.swift @@ -792,7 +792,7 @@ private final class TooltipScreenNode: ViewControllerTracingNode { var avatarFrame = animationFrame if let icon, case let .peer(_, isStory) = icon, isStory { - let indicatorTransition: Transition = .immediate + let indicatorTransition: ComponentTransition = .immediate let avatarStoryIndicator: ComponentView if let current = self.avatarStoryIndicator { avatarStoryIndicator = current diff --git a/submodules/TranslateUI/Sources/PlayPauseIconComponent.swift b/submodules/TranslateUI/Sources/PlayPauseIconComponent.swift index ba94aa2efc..561a0feda1 100644 --- a/submodules/TranslateUI/Sources/PlayPauseIconComponent.swift +++ b/submodules/TranslateUI/Sources/PlayPauseIconComponent.swift @@ -93,7 +93,7 @@ final class PlayPauseIconComponent: Component { fatalError("init(coder:) has not been implemented") } - func update(component: PlayPauseIconComponent, availableSize: CGSize, transition: Transition) -> CGSize { + func update(component: PlayPauseIconComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { if self.component?.state != component.state { self.component = component @@ -114,7 +114,7 @@ final class PlayPauseIconComponent: Component { return View(frame: CGRect()) } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/TranslateUI/Sources/TranslateButtonComponent.swift b/submodules/TranslateUI/Sources/TranslateButtonComponent.swift index 7361ac70d6..bf431c92ac 100644 --- a/submodules/TranslateUI/Sources/TranslateButtonComponent.swift +++ b/submodules/TranslateUI/Sources/TranslateButtonComponent.swift @@ -151,7 +151,7 @@ final class TranslateButtonComponent: Component { } } - public func update(component: TranslateButtonComponent, availableSize: CGSize, transition: Transition) -> CGSize { + public func update(component: TranslateButtonComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize { self.component = component self.backgroundView.backgroundColor = component.theme.list.itemBlocksBackgroundColor @@ -177,7 +177,7 @@ final class TranslateButtonComponent: Component { return View() } - func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { return view.update(component: self, availableSize: availableSize, transition: transition) } } diff --git a/submodules/TranslateUI/Sources/TranslateScreen.swift b/submodules/TranslateUI/Sources/TranslateScreen.swift index 1cc8c69c9d..d8bafa44cd 100644 --- a/submodules/TranslateUI/Sources/TranslateScreen.swift +++ b/submodules/TranslateUI/Sources/TranslateScreen.swift @@ -641,7 +641,7 @@ public class TranslateScreen: ViewController { } } - func containerLayoutUpdated(layout: ContainerViewLayout, navigationHeight: CGFloat, transition: Transition) { + func containerLayoutUpdated(layout: ContainerViewLayout, navigationHeight: CGFloat, transition: ComponentTransition) { self.currentLayout = (layout, navigationHeight) if let controller = self.controller, let navigationBar = controller.navigationBar, navigationBar.view.superview !== self.wrappingView { @@ -928,11 +928,11 @@ public class TranslateScreen: 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, navigationHeight: navigationHeight, transition: Transition(transition)) + self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(transition)) } else { self.isExpanded = true - self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: Transition(.animated(duration: 0.3, curve: .easeInOut))) + self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(.animated(duration: 0.3, curve: .easeInOut))) } } else if (velocity.y < -300.0 || offset < topInset / 2.0) { if velocity.y > -2200.0 && velocity.y < -300.0, let listNode = listNode { @@ -945,7 +945,7 @@ public class TranslateScreen: ViewController { let transition = ContainedViewLayoutTransition.animated(duration: 0.45, curve: .customSpring(damping: 124.0, initialVelocity: initialVelocity)) self.isExpanded = true - self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: Transition(transition)) + self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(transition)) } else { if let listNode = listNode { listNode.scroller.setContentOffset(CGPoint(), animated: false) @@ -953,7 +953,7 @@ public class TranslateScreen: ViewController { scrollView.setContentOffset(CGPoint(x: 0.0, y: -scrollView.contentInset.top), animated: false) } - self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: Transition(.animated(duration: 0.3, curve: .easeInOut))) + self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(.animated(duration: 0.3, curve: .easeInOut))) } if !dismissing { @@ -966,7 +966,7 @@ public class TranslateScreen: ViewController { case .cancelled: self.panGestureArguments = nil - self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: Transition(.animated(duration: 0.3, curve: .easeInOut))) + self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(.animated(duration: 0.3, curve: .easeInOut))) default: break } @@ -981,7 +981,7 @@ public class TranslateScreen: ViewController { guard let (layout, navigationHeight) = self.currentLayout else { return } - self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: Transition(transition)) + self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(transition)) } } @@ -1163,6 +1163,6 @@ public class TranslateScreen: ViewController { let navigationHeight: CGFloat = 56.0 - self.node.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: Transition(transition)) + self.node.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(transition)) } }