From 6085c40c0866e27239f171875c85e973faaf1c9e Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Mon, 18 Sep 2023 16:37:49 +0400 Subject: [PATCH] Various fixes --- .../Sources/StickerPickerScreen.swift | 4 +-- .../Sources/PremiumLimitScreen.swift | 30 ++++++++++++++++--- .../PremiumUI/Sources/RollingCountLabel.swift | 21 ++++++------- .../Sources/ChannelStatsController.swift | 2 +- 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/submodules/DrawingUI/Sources/StickerPickerScreen.swift b/submodules/DrawingUI/Sources/StickerPickerScreen.swift index 5d22cd40e1..f4b5779500 100644 --- a/submodules/DrawingUI/Sources/StickerPickerScreen.swift +++ b/submodules/DrawingUI/Sources/StickerPickerScreen.swift @@ -2357,7 +2357,7 @@ final class StoryStickersContentView: UIView, EmojiCustomContentView { component: AnyComponent( InteractiveStickerButtonContent( theme: theme, - title: "LOCATION", + title: strings.MediaEditor_AddLocationShort, iconName: "Chat/Attach Menu/Location", useOpaqueTheme: useOpaqueTheme, tintContainerView: self.tintContainerView @@ -2380,7 +2380,7 @@ final class StoryStickersContentView: UIView, EmojiCustomContentView { component: AnyComponent( InteractiveStickerButtonContent( theme: theme, - title: "AUDIO", + title: strings.MediaEditor_AddAudio, iconName: "Media Editor/Audio", useOpaqueTheme: useOpaqueTheme, tintContainerView: self.tintContainerView diff --git a/submodules/PremiumUI/Sources/PremiumLimitScreen.swift b/submodules/PremiumUI/Sources/PremiumLimitScreen.swift index 1ef267367b..45f83b2c50 100644 --- a/submodules/PremiumUI/Sources/PremiumLimitScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumLimitScreen.swift @@ -279,6 +279,7 @@ public class PremiumLimitDisplayComponent: Component { private let badgeForeground: SimpleLayer private let badgeIcon: UIImageView private let badgeCountLabel: RollingLabel + private let countMaskView = UIImageView() private let hapticFeedback = HapticFeedback() @@ -309,11 +310,12 @@ public class PremiumLimitDisplayComponent: Component { self.badgeIcon = UIImageView() self.badgeIcon.contentMode = .center - + self.badgeCountLabel = RollingLabel() self.badgeCountLabel.font = Font.with(size: 24.0, design: .round, weight: .semibold, traits: []) self.badgeCountLabel.textColor = .white self.badgeCountLabel.configure(with: "0") + self.badgeCountLabel.mask = self.countMaskView super.init(frame: frame) @@ -327,6 +329,24 @@ public class PremiumLimitDisplayComponent: Component { self.badgeView.addSubview(self.badgeIcon) self.badgeView.addSubview(self.badgeCountLabel) + self.countMaskView.contentMode = .scaleToFill + self.countMaskView.image = generateImage(CGSize(width: 2.0, height: 48.0), rotatedContext: { size, context in + let bounds = CGRect(origin: .zero, size: size) + context.clear(bounds) + + let colorsArray: [CGColor] = [ + UIColor(rgb: 0xffffff, alpha: 0.0).cgColor, + UIColor(rgb: 0xffffff).cgColor, + UIColor(rgb: 0xffffff).cgColor, + UIColor(rgb: 0xffffff, alpha: 0.0).cgColor, + UIColor(rgb: 0xffffff, alpha: 0.0).cgColor + ] + var locations: [CGFloat] = [0.0, 0.11, 0.46, 0.57, 1.0] + let gradient = CGGradient(colorsSpace: deviceColorSpace, colors: colorsArray as CFArray, locations: &locations)! + + context.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: CGPoint(x: 0.0, y: size.height), options: CGGradientDrawingOptions()) + }) + self.isUserInteractionEnabled = false } @@ -360,7 +380,7 @@ public class PremiumLimitDisplayComponent: Component { Queue.mainQueue().after(0.5, { let bounceAnimation = CABasicAnimation(keyPath: "transform.rotation.z") bounceAnimation.fromValue = -0.26 as NSNumber - bounceAnimation.toValue = 0.035 as NSNumber + bounceAnimation.toValue = 0.04 as NSNumber bounceAnimation.duration = 0.2 bounceAnimation.fillMode = .forwards bounceAnimation.timingFunction = CAMediaTimingFunction(name: .easeOut) @@ -374,7 +394,7 @@ public class PremiumLimitDisplayComponent: Component { Queue.mainQueue().after(0.2) { let returnAnimation = CABasicAnimation(keyPath: "transform.rotation.z") - returnAnimation.fromValue = 0.035 as NSNumber + returnAnimation.fromValue = 0.04 as NSNumber returnAnimation.toValue = 0.0 as NSNumber returnAnimation.duration = 0.15 returnAnimation.fillMode = .forwards @@ -390,7 +410,7 @@ public class PremiumLimitDisplayComponent: Component { } if let badgeText = component.badgeText { - self.badgeCountLabel.configure(with: badgeText, duration: from != nil ? 0.3 : 0.5) + self.badgeCountLabel.configure(with: badgeText, increment: from != nil, duration: from != nil ? 0.3 : 0.5) } } @@ -671,6 +691,7 @@ public class PremiumLimitDisplayComponent: Component { self.badgeIcon.frame = CGRect(x: 10.0, y: 9.0, width: 30.0, height: 30.0) self.badgeCountLabel.frame = CGRect(x: badgeFullSize.width - countWidth - 11.0, y: 10.0, width: countWidth, height: 48.0) + self.countMaskView.frame = CGRect(x: 0.0, y: 0.0, width: countWidth, height: 48.0) if component.isPremiumDisabled { if !self.didPlayAppearanceAnimation { @@ -1425,6 +1446,7 @@ private final class LimitSheetContent: CombinedComponent { transition.animateAlpha(view: view, from: 0.0, to: 1.0) })) .disappear(Transition.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 completion() diff --git a/submodules/PremiumUI/Sources/RollingCountLabel.swift b/submodules/PremiumUI/Sources/RollingCountLabel.swift index 5191a5e775..8bb1b143f7 100644 --- a/submodules/PremiumUI/Sources/RollingCountLabel.swift +++ b/submodules/PremiumUI/Sources/RollingCountLabel.swift @@ -37,20 +37,16 @@ open class RollingLabel: UILabel { self.suffix = suffix } - func configure(with string: String, duration: Double = 0.9) { + func configure(with string: String, increment: Bool = false, duration: Double = 0.0) { self.fullText = string self.clean() self.setupSubviews() self.text = " " - self.animate(duration: duration) + self.animate(increment: increment, duration: duration) } - - private func animate(ascending: Bool = true, duration: Double) { - self.createAnimations(ascending: ascending, duration: duration) - } - + private func clean() { self.text = nil self.subviews.forEach { $0.removeFromSuperview() } @@ -167,11 +163,12 @@ open class RollingLabel: UILabel { } } - private func createAnimations(ascending: Bool, duration: Double) { + private func animate(ascending: Bool = true, increment: Bool, duration: Double) { var offset: CFTimeInterval = 0.0 - for scrollLayer in scrollLayers { + for scrollLayer in self.scrollLayers { let maxY = scrollLayer.sublayers?.last?.frame.origin.y ?? 0.0 + let height = scrollLayer.sublayers?.last?.frame.size.height ?? 0.0 let animation = CABasicAnimation(keyPath: "sublayerTransform.translation.y") animation.duration = duration + offset @@ -179,7 +176,11 @@ open class RollingLabel: UILabel { let verticalOffset = 20.0 if ascending { - animation.fromValue = maxY + verticalOffset + if increment { + animation.fromValue = height + verticalOffset + } else { + animation.fromValue = maxY + verticalOffset + } animation.toValue = 0 } else { animation.fromValue = 0 diff --git a/submodules/StatisticsUI/Sources/ChannelStatsController.swift b/submodules/StatisticsUI/Sources/ChannelStatsController.swift index dfbc1976c9..73cc9d19a0 100644 --- a/submodules/StatisticsUI/Sources/ChannelStatsController.swift +++ b/submodules/StatisticsUI/Sources/ChannelStatsController.swift @@ -474,7 +474,7 @@ private enum StatsEntry: ItemListNodeEntry { }) case let .booster(_, _, dateTimeFormat, peer, expires): let expiresValue = stringForFullDate(timestamp: expires, strings: presentationData.strings, dateTimeFormat: dateTimeFormat) - return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: presentationData.nameDisplayOrder, context: arguments.context, peer: peer, presence: nil, text: .text(presentationData.strings.Stats_Boosts_ExpiresOn(expiresValue).string, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), switchValue: nil, enabled: true, selectable: true, sectionId: self.section, action: { + return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: presentationData.nameDisplayOrder, context: arguments.context, peer: peer, presence: nil, text: .text(presentationData.strings.Stats_Boosts_ExpiresOn(expiresValue).string, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), switchValue: nil, enabled: true, selectable: peer.id != arguments.context.account.peerId, sectionId: self.section, action: { arguments.openPeer(peer) }, setPeerIdWithRevealedOptions: { _, _ in }, removePeer: { _ in }) case let .boostersExpand(theme, title):