Skip to content

Commit f4aaf08

Browse files
committed
Various fixes
1 parent 8180c08 commit f4aaf08

File tree

5 files changed

+57
-6
lines changed

5 files changed

+57
-6
lines changed

submodules/TelegramUI/Components/PremiumPeerShortcutComponent/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ swift_library(
1717
"//submodules/AvatarNode",
1818
"//submodules/Components/MultilineTextComponent",
1919
"//submodules/AccountContext",
20+
"//submodules/TelegramUI/Components/EmojiTextAttachmentView",
21+
"//submodules/TextFormat",
2022
],
2123
visibility = [
2224
"//visibility:public",

submodules/TelegramUI/Components/PremiumPeerShortcutComponent/Sources/PremiumPeerShortcutComponent.swift

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import TelegramPresentationData
77
import AccountContext
88
import AvatarNode
99
import MultilineTextComponent
10+
import EmojiTextAttachmentView
11+
import TextFormat
1012

1113
public final class PremiumPeerShortcutComponent: Component {
1214
let context: AccountContext
@@ -43,6 +45,7 @@ public final class PremiumPeerShortcutComponent: Component {
4345
private let backgroundView = UIView()
4446
private let avatarNode: AvatarNode
4547
private let text = ComponentView<Empty>()
48+
private var animationLayer: InlineStickerItemLayer?
4649

4750
private var component: PremiumPeerShortcutComponent?
4851
private weak var state: EmptyComponentState?
@@ -88,7 +91,7 @@ public final class PremiumPeerShortcutComponent: Component {
8891
containerSize: CGSize(width: availableSize.width - 50.0, height: availableSize.height)
8992
)
9093

91-
let size = CGSize(width: 30.0 + textSize.width + 20.0, height: 32.0)
94+
var size = CGSize(width: 30.0 + textSize.width + 20.0, height: 32.0)
9295
if let view = self.text.view {
9396
if view.superview == nil {
9497
self.addSubview(view)
@@ -97,6 +100,45 @@ public final class PremiumPeerShortcutComponent: Component {
97100
view.frame = textFrame
98101
}
99102

103+
if let icon = component.icon {
104+
let iconSize = CGSize(width: 20.0, height: 20.0)
105+
let iconSpacing: CGFloat = 2.0
106+
let animationLayer: InlineStickerItemLayer
107+
if let current = self.animationLayer {
108+
animationLayer = current
109+
} else {
110+
let emoji = ChatTextInputTextCustomEmojiAttribute(
111+
interactivelySelectedFromPackId: nil,
112+
fileId: icon.fileId.id,
113+
file: icon
114+
)
115+
animationLayer = InlineStickerItemLayer(
116+
context: .account(component.context),
117+
userLocation: .other,
118+
attemptSynchronousLoad: false,
119+
emoji: emoji,
120+
file: icon,
121+
cache: component.context.animationCache,
122+
renderer: component.context.animationRenderer,
123+
unique: true,
124+
placeholderColor: component.theme.list.mediaPlaceholderColor,
125+
pointSize: CGSize(width: 20.0, height: 20.0),
126+
loopCount: 1
127+
)
128+
animationLayer.isVisibleForAnimations = true
129+
if icon.isCustomTemplateEmoji {
130+
animationLayer.dynamicColor = component.theme.actionSheet.controlAccentColor
131+
}
132+
self.layer.addSublayer(animationLayer)
133+
self.animationLayer = animationLayer
134+
}
135+
animationLayer.frame = CGRect(origin: CGPoint(x: size.width - 7.0, y: floorToScreenPixels((size.height - iconSize.height) / 2.0)), size: iconSize)
136+
size.width += iconSize.width + iconSpacing
137+
} else if let animationLayer = self.animationLayer {
138+
self.animationLayer = nil
139+
animationLayer.removeFromSuperlayer()
140+
}
141+
100142
self.backgroundView.frame = CGRect(origin: .zero, size: size)
101143

102144
return size

submodules/WebUI/Sources/WebAppController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
772772
if controller.isFullscreen {
773773
customInsets.top = layout.statusBarHeight ?? 0.0
774774
}
775-
if layout.intrinsicInsets.bottom > 44.0 {
775+
if layout.intrinsicInsets.bottom > 44.0 || (layout.inputHeight ?? 0.0) > 0.0 {
776776
customInsets.bottom = 0.0
777777
} else {
778778
customInsets.bottom = layout.intrinsicInsets.bottom

submodules/WebUI/Sources/WebAppMessagePreviewScreen.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ private final class SheetContent: CombinedComponent {
158158
case let .auto(textValue, entitiesValue, _):
159159
text = textValue
160160
entities = entitiesValue
161+
if let content = reference.content {
162+
media = [content]
163+
}
161164
case let .text(textValue, entitiesValue, disableUrlPreview, previewParameters, _):
162165
text = textValue
163166
entities = entitiesValue

submodules/WebUI/Sources/WebAppSetEmojiStatusScreen.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ private final class SheetContent: CombinedComponent {
172172
component: PremiumPeerShortcutComponent(
173173
context: component.context,
174174
theme: theme,
175-
peer: component.accountPeer
175+
peer: component.accountPeer,
176+
icon: component.file
176177
),
177178
availableSize: CGSize(width: context.availableSize.width - 32.0, height: context.availableSize.height),
178179
transition: .immediate
@@ -272,7 +273,8 @@ private final class WebAppSetEmojiStatusSheetComponent: CombinedComponent {
272273
file: context.component.file,
273274
dismiss: {
274275
animateOut.invoke(Action { _ in
275-
if let controller = controller() {
276+
if let controller = controller() as? WebAppSetEmojiStatusScreen {
277+
controller.complete(result: false)
276278
controller.dismiss(completion: nil)
277279
}
278280
})
@@ -293,12 +295,14 @@ private final class WebAppSetEmojiStatusSheetComponent: CombinedComponent {
293295
dismiss: { animated in
294296
if animated {
295297
animateOut.invoke(Action { _ in
296-
if let controller = controller() {
298+
if let controller = controller() as? WebAppSetEmojiStatusScreen {
299+
controller.complete(result: false)
297300
controller.dismiss(completion: nil)
298301
}
299302
})
300303
} else {
301-
if let controller = controller() {
304+
if let controller = controller() as? WebAppSetEmojiStatusScreen {
305+
controller.complete(result: false)
302306
controller.dismiss(completion: nil)
303307
}
304308
}

0 commit comments

Comments
 (0)