mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
056f265511
commit
1d0f77fc3e
@ -14,6 +14,7 @@ public final class DrawingBubbleEntity: DrawingEntity, Codable {
|
||||
case size
|
||||
case rotation
|
||||
case tailPosition
|
||||
case renderImage
|
||||
}
|
||||
|
||||
enum DrawType: Codable {
|
||||
@ -67,6 +68,9 @@ public final class DrawingBubbleEntity: DrawingEntity, Codable {
|
||||
self.size = try container.decode(CGSize.self, forKey: .size)
|
||||
self.rotation = try container.decode(CGFloat.self, forKey: .rotation)
|
||||
self.tailPosition = try container.decode(CGPoint.self, forKey: .tailPosition)
|
||||
if let renderImageData = try? container.decodeIfPresent(Data.self, forKey: .renderImage) {
|
||||
self.renderImage = UIImage(data: renderImageData)
|
||||
}
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@ -80,6 +84,9 @@ public final class DrawingBubbleEntity: DrawingEntity, Codable {
|
||||
try container.encode(self.size, forKey: .size)
|
||||
try container.encode(self.rotation, forKey: .rotation)
|
||||
try container.encode(self.tailPosition, forKey: .tailPosition)
|
||||
if let renderImage, let data = renderImage.pngData() {
|
||||
try container.encode(data, forKey: .renderImage)
|
||||
}
|
||||
}
|
||||
|
||||
public func duplicate() -> DrawingEntity {
|
||||
@ -99,6 +106,7 @@ public final class DrawingBubbleEntity: DrawingEntity, Codable {
|
||||
}
|
||||
|
||||
public func prepareForRender() {
|
||||
self.renderImage = (self.currentEntityView as? DrawingBubbleEntityView)?.getRenderImage()
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,8 +142,8 @@ final class DrawingBubbleEntityView: DrawingEntityView {
|
||||
self.currentTailPosition = self.bubbleEntity.tailPosition
|
||||
self.shapeLayer.frame = self.bounds
|
||||
|
||||
let cornerRadius = max(10.0, max(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.066)
|
||||
let smallCornerRadius = max(5.0, max(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.016)
|
||||
let cornerRadius = max(10.0, max(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.045)
|
||||
let smallCornerRadius = max(5.0, max(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.01)
|
||||
let tailWidth = max(5.0, max(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.1)
|
||||
|
||||
self.shapeLayer.path = CGPath.bubble(in: CGRect(origin: .zero, size: size), cornerRadius: cornerRadius, smallCornerRadius: smallCornerRadius, tailPosition: self.bubbleEntity.tailPosition, tailWidth: tailWidth)
|
||||
@ -147,7 +155,7 @@ final class DrawingBubbleEntityView: DrawingEntityView {
|
||||
self.shapeLayer.strokeColor = UIColor.clear.cgColor
|
||||
case .stroke:
|
||||
let minLineWidth = max(10.0, max(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.01)
|
||||
let maxLineWidth = max(10.0, max(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.1)
|
||||
let maxLineWidth = max(10.0, max(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.05)
|
||||
let lineWidth = minLineWidth + (maxLineWidth - minLineWidth) * self.bubbleEntity.lineWidth
|
||||
|
||||
self.shapeLayer.fillColor = UIColor.clear.cgColor
|
||||
@ -207,6 +215,15 @@ final class DrawingBubbleEntityView: DrawingEntityView {
|
||||
selectionView.entityView = self
|
||||
return selectionView
|
||||
}
|
||||
|
||||
func getRenderImage() -> UIImage? {
|
||||
let rect = self.bounds
|
||||
UIGraphicsBeginImageContextWithOptions(rect.size, false, 1.0)
|
||||
self.drawHierarchy(in: rect, afterScreenUpdates: false)
|
||||
let image = UIGraphicsGetImageFromCurrentImageContext()
|
||||
UIGraphicsEndImageContext()
|
||||
return image
|
||||
}
|
||||
}
|
||||
|
||||
final class DrawingBubbleEntititySelectionView: DrawingEntitySelectionView, UIGestureRecognizerDelegate {
|
||||
|
@ -183,7 +183,7 @@ struct DrawingState: Equatable {
|
||||
.pen(DrawingToolState.BrushState(color: DrawingColor(rgb: 0xff453a), size: 0.2)),
|
||||
.arrow(DrawingToolState.BrushState(color: DrawingColor(rgb: 0xff8a00), size: 0.2)),
|
||||
.marker(DrawingToolState.BrushState(color: DrawingColor(rgb: 0xffd60a), size: 0.75)),
|
||||
.neon(DrawingToolState.BrushState(color: DrawingColor(rgb: 0x34ffab), size: 0.4)),
|
||||
.neon(DrawingToolState.BrushState(color: DrawingColor(rgb: 0x34c759), size: 0.4)),
|
||||
.eraser(DrawingToolState.EraserState(size: 0.5)),
|
||||
.blur(DrawingToolState.EraserState(size: 0.5))
|
||||
]
|
||||
@ -393,7 +393,8 @@ private final class DrawingScreenComponent: CombinedComponent {
|
||||
areUnicodeEmojiEnabled: true,
|
||||
areCustomEmojiEnabled: true,
|
||||
chatPeerId: context.account.peerId,
|
||||
hasSearch: false
|
||||
hasSearch: false,
|
||||
forceHasPremium: true
|
||||
)
|
||||
|
||||
let stickerItems = EmojiPagerContentComponent.stickerInputData(
|
||||
@ -404,7 +405,8 @@ private final class DrawingScreenComponent: CombinedComponent {
|
||||
stickerOrderedItemListCollectionIds: [Namespaces.OrderedItemList.CloudSavedStickers, Namespaces.OrderedItemList.CloudRecentStickers, Namespaces.OrderedItemList.CloudAllPremiumStickers],
|
||||
chatPeerId: context.account.peerId,
|
||||
hasSearch: false,
|
||||
hasTrending: true
|
||||
hasTrending: true,
|
||||
forceHasPremium: true
|
||||
)
|
||||
|
||||
let maskItems = EmojiPagerContentComponent.stickerInputData(
|
||||
@ -415,7 +417,8 @@ private final class DrawingScreenComponent: CombinedComponent {
|
||||
stickerOrderedItemListCollectionIds: [],
|
||||
chatPeerId: context.account.peerId,
|
||||
hasSearch: false,
|
||||
hasTrending: false
|
||||
hasTrending: false,
|
||||
forceHasPremium: true
|
||||
)
|
||||
|
||||
let signal = combineLatest(queue: .mainQueue(),
|
||||
@ -2232,7 +2235,13 @@ public class DrawingScreen: ViewController, TGPhotoDrawingInterfaceController {
|
||||
}
|
||||
|
||||
if shouldHaveInputView {
|
||||
let inputView = EntityInputView(context: self.context, isDark: true, areCustomEmojiEnabled: true)
|
||||
let inputView = EntityInputView(
|
||||
context: self.context,
|
||||
isDark: true,
|
||||
areCustomEmojiEnabled: true,
|
||||
hideBackground: true,
|
||||
forceHasPremium: true
|
||||
)
|
||||
inputView.insertText = { [weak entityView] text in
|
||||
entityView?.insertText(text)
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ public final class DrawingSimpleShapeEntity: DrawingEntity, Codable {
|
||||
case position
|
||||
case size
|
||||
case rotation
|
||||
case renderImage
|
||||
}
|
||||
|
||||
public enum ShapeType: Codable {
|
||||
@ -73,6 +74,9 @@ public final class DrawingSimpleShapeEntity: DrawingEntity, Codable {
|
||||
self.position = try container.decode(CGPoint.self, forKey: .position)
|
||||
self.size = try container.decode(CGSize.self, forKey: .size)
|
||||
self.rotation = try container.decode(CGFloat.self, forKey: .rotation)
|
||||
if let renderImageData = try? container.decodeIfPresent(Data.self, forKey: .renderImage) {
|
||||
self.renderImage = UIImage(data: renderImageData)
|
||||
}
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@ -86,6 +90,9 @@ public final class DrawingSimpleShapeEntity: DrawingEntity, Codable {
|
||||
try container.encode(self.position, forKey: .position)
|
||||
try container.encode(self.size, forKey: .size)
|
||||
try container.encode(self.rotation, forKey: .rotation)
|
||||
if let renderImage, let data = renderImage.pngData() {
|
||||
try container.encode(data, forKey: .renderImage)
|
||||
}
|
||||
}
|
||||
|
||||
public func duplicate() -> DrawingEntity {
|
||||
@ -105,6 +112,7 @@ public final class DrawingSimpleShapeEntity: DrawingEntity, Codable {
|
||||
}
|
||||
|
||||
public func prepareForRender() {
|
||||
self.renderImage = (self.currentEntityView as? DrawingSimpleShapeEntityView)?.getRenderImage()
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,13 +149,14 @@ final class DrawingSimpleShapeEntityView: DrawingEntityView {
|
||||
self.currentSize = size
|
||||
self.shapeLayer.frame = self.bounds
|
||||
|
||||
let rect = CGRect(origin: .zero, size: size).insetBy(dx: maxLineWidth * 0.5, dy: maxLineWidth * 0.5)
|
||||
switch shapeType {
|
||||
case .rectangle:
|
||||
self.shapeLayer.path = CGPath(rect: CGRect(origin: .zero, size: size), transform: nil)
|
||||
self.shapeLayer.path = CGPath(rect: rect, transform: nil)
|
||||
case .ellipse:
|
||||
self.shapeLayer.path = CGPath(ellipseIn: CGRect(origin: .zero, size: size), transform: nil)
|
||||
self.shapeLayer.path = CGPath(ellipseIn: rect, transform: nil)
|
||||
case .star:
|
||||
self.shapeLayer.path = CGPath.star(in: CGRect(origin: .zero, size: size), extrusion: size.width * 0.2, points: 5)
|
||||
self.shapeLayer.path = CGPath.star(in: rect, extrusion: size.width * 0.2, points: 5)
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,7 +166,7 @@ final class DrawingSimpleShapeEntityView: DrawingEntityView {
|
||||
self.shapeLayer.strokeColor = UIColor.clear.cgColor
|
||||
case .stroke:
|
||||
let minLineWidth = max(10.0, max(self.shapeEntity.referenceDrawingSize.width, self.shapeEntity.referenceDrawingSize.height) * 0.01)
|
||||
let maxLineWidth = max(10.0, max(self.shapeEntity.referenceDrawingSize.width, self.shapeEntity.referenceDrawingSize.height) * 0.1)
|
||||
let maxLineWidth = self.maxLineWidth
|
||||
let lineWidth = minLineWidth + (maxLineWidth - minLineWidth) * self.shapeEntity.lineWidth
|
||||
|
||||
self.shapeLayer.fillColor = UIColor.clear.cgColor
|
||||
@ -172,8 +181,8 @@ final class DrawingSimpleShapeEntityView: DrawingEntityView {
|
||||
return self.shapeLayer.lineWidth
|
||||
}
|
||||
|
||||
private var maxLineWidth: CGFloat {
|
||||
return max(10.0, max(self.shapeEntity.referenceDrawingSize.width, self.shapeEntity.referenceDrawingSize.height) * 0.1)
|
||||
fileprivate var maxLineWidth: CGFloat {
|
||||
return max(10.0, max(self.shapeEntity.referenceDrawingSize.width, self.shapeEntity.referenceDrawingSize.height) * 0.05)
|
||||
}
|
||||
|
||||
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
|
||||
@ -219,6 +228,19 @@ final class DrawingSimpleShapeEntityView: DrawingEntityView {
|
||||
selectionView.entityView = self
|
||||
return selectionView
|
||||
}
|
||||
|
||||
func getRenderImage() -> UIImage? {
|
||||
let rect = self.bounds
|
||||
UIGraphicsBeginImageContextWithOptions(rect.size, false, 1.0)
|
||||
self.drawHierarchy(in: rect, afterScreenUpdates: false)
|
||||
let image = UIGraphicsGetImageFromCurrentImageContext()
|
||||
UIGraphicsEndImageContext()
|
||||
return image
|
||||
}
|
||||
|
||||
override var selectionBounds: CGRect {
|
||||
return self.bounds.insetBy(dx: self.maxLineWidth * 0.5, dy: self.maxLineWidth * 0.5)
|
||||
}
|
||||
}
|
||||
|
||||
func gestureIsTracking(_ gestureRecognizer: UIPanGestureRecognizer) -> Bool {
|
||||
@ -447,10 +469,7 @@ final class DrawingSimpleShapeEntititySelectionView: DrawingEntitySelectionView,
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
var inset = self.selectionInset
|
||||
if let entityView = self.entityView as? DrawingSimpleShapeEntityView, let entity = entityView.entity as? DrawingSimpleShapeEntity, case .star = entity.shapeType {
|
||||
inset -= entityView.visualLineWidth / 2.0
|
||||
}
|
||||
let inset = self.selectionInset
|
||||
|
||||
let bounds = CGRect(origin: .zero, size: CGSize(width: entitySelectionViewHandleSize.width / self.scale, height: entitySelectionViewHandleSize.height / self.scale))
|
||||
let handleSize = CGSize(width: 9.0 / self.scale, height: 9.0 / self.scale)
|
||||
|
@ -52,6 +52,8 @@ public final class DrawingTextEntity: DrawingEntity, Codable {
|
||||
case width
|
||||
case scale
|
||||
case rotation
|
||||
case renderImage
|
||||
case renderSubEntities
|
||||
}
|
||||
|
||||
enum Style: Codable {
|
||||
@ -193,6 +195,9 @@ public final class DrawingTextEntity: DrawingEntity, Codable {
|
||||
self.width = try container.decode(CGFloat.self, forKey: .width)
|
||||
self.scale = try container.decode(CGFloat.self, forKey: .scale)
|
||||
self.rotation = try container.decode(CGFloat.self, forKey: .rotation)
|
||||
if let renderImageData = try? container.decodeIfPresent(Data.self, forKey: .renderImage) {
|
||||
self.renderImage = UIImage(data: renderImageData)
|
||||
}
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@ -218,6 +223,9 @@ public final class DrawingTextEntity: DrawingEntity, Codable {
|
||||
try container.encode(self.width, forKey: .width)
|
||||
try container.encode(self.scale, forKey: .scale)
|
||||
try container.encode(self.rotation, forKey: .rotation)
|
||||
if let renderImage, let data = renderImage.pngData() {
|
||||
try container.encode(data, forKey: .renderImage)
|
||||
}
|
||||
}
|
||||
|
||||
public func duplicate() -> DrawingEntity {
|
||||
@ -526,8 +534,8 @@ final class DrawingTextEntityView: DrawingEntityView, UITextViewDelegate {
|
||||
}
|
||||
|
||||
private var displayFontSize: CGFloat {
|
||||
let minFontSize = max(10.0, max(self.textEntity.referenceDrawingSize.width, self.textEntity.referenceDrawingSize.height) * 0.05)
|
||||
let maxFontSize = max(10.0, max(self.textEntity.referenceDrawingSize.width, self.textEntity.referenceDrawingSize.height) * 0.45)
|
||||
let minFontSize = max(10.0, max(self.textEntity.referenceDrawingSize.width, self.textEntity.referenceDrawingSize.height) * 0.025)
|
||||
let maxFontSize = max(10.0, max(self.textEntity.referenceDrawingSize.width, self.textEntity.referenceDrawingSize.height) * 0.25)
|
||||
let fontSize = minFontSize + (maxFontSize - minFontSize) * self.textEntity.fontSize
|
||||
return fontSize
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ public final class DrawingVectorEntity: DrawingEntity, Codable {
|
||||
case start
|
||||
case mid
|
||||
case end
|
||||
case renderImage
|
||||
}
|
||||
|
||||
public enum VectorType: Codable {
|
||||
@ -77,11 +78,12 @@ public final class DrawingVectorEntity: DrawingEntity, Codable {
|
||||
self.drawingSize = try container.decode(CGSize.self, forKey: .drawingSize)
|
||||
self.referenceDrawingSize = try container.decode(CGSize.self, forKey: .referenceDrawingSize)
|
||||
self.start = try container.decode(CGPoint.self, forKey: .start)
|
||||
|
||||
let mid = try container.decode(CGPoint.self, forKey: .mid)
|
||||
self.mid = (mid.x, mid.y)
|
||||
|
||||
self.end = try container.decode(CGPoint.self, forKey: .end)
|
||||
if let renderImageData = try? container.decodeIfPresent(Data.self, forKey: .renderImage) {
|
||||
self.renderImage = UIImage(data: renderImageData)
|
||||
}
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@ -95,6 +97,9 @@ public final class DrawingVectorEntity: DrawingEntity, Codable {
|
||||
try container.encode(self.start, forKey: .start)
|
||||
try container.encode(CGPoint(x: self.mid.0, y: self.mid.1), forKey: .mid)
|
||||
try container.encode(self.end, forKey: .end)
|
||||
if let renderImage, let data = renderImage.pngData() {
|
||||
try container.encode(data, forKey: .renderImage)
|
||||
}
|
||||
}
|
||||
|
||||
public func duplicate() -> DrawingEntity {
|
||||
@ -115,6 +120,7 @@ public final class DrawingVectorEntity: DrawingEntity, Codable {
|
||||
}
|
||||
|
||||
public func prepareForRender() {
|
||||
self.renderImage = (self.currentEntityView as? DrawingVectorEntityView)?.getRenderImage()
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,7 +154,7 @@ final class DrawingVectorEntityView: DrawingEntityView {
|
||||
self.bounds = CGRect(origin: .zero, size: self.vectorEntity.drawingSize)
|
||||
|
||||
let minLineWidth = max(10.0, max(self.vectorEntity.referenceDrawingSize.width, self.vectorEntity.referenceDrawingSize.height) * 0.01)
|
||||
let maxLineWidth = max(10.0, max(self.vectorEntity.referenceDrawingSize.width, self.vectorEntity.referenceDrawingSize.height) * 0.1)
|
||||
let maxLineWidth = max(10.0, max(self.vectorEntity.referenceDrawingSize.width, self.vectorEntity.referenceDrawingSize.height) * 0.05)
|
||||
let lineWidth = minLineWidth + (maxLineWidth - minLineWidth) * self.vectorEntity.lineWidth
|
||||
|
||||
self.shapeLayer.path = CGPath.curve(
|
||||
@ -206,6 +212,15 @@ final class DrawingVectorEntityView: DrawingEntityView {
|
||||
selectionView.entityView = self
|
||||
return selectionView
|
||||
}
|
||||
|
||||
func getRenderImage() -> UIImage? {
|
||||
let rect = self.bounds
|
||||
UIGraphicsBeginImageContextWithOptions(rect.size, false, 1.0)
|
||||
self.drawHierarchy(in: rect, afterScreenUpdates: false)
|
||||
let image = UIGraphicsGetImageFromCurrentImageContext()
|
||||
UIGraphicsEndImageContext()
|
||||
return image
|
||||
}
|
||||
}
|
||||
|
||||
private func midPointPositionFor(start: CGPoint, end: CGPoint, length: CGFloat, height: CGFloat) -> CGPoint {
|
||||
|
@ -276,20 +276,13 @@ class StickerPickerScreen: ViewController {
|
||||
deleteBackwards: nil,
|
||||
openStickerSettings: nil,
|
||||
openFeatured: nil,
|
||||
openSearch: {},
|
||||
openSearch: {
|
||||
},
|
||||
addGroupAction: { [weak self] groupId, isPremiumLocked in
|
||||
guard let strongSelf = self, let controller = strongSelf.controller, let collectionId = groupId.base as? ItemCollectionId else {
|
||||
return
|
||||
}
|
||||
let context = controller.context
|
||||
|
||||
if isPremiumLocked {
|
||||
// let controller = PremiumIntroScreen(context: context, source: .stickers)
|
||||
// controllerInteraction.navigationController()?.pushViewController(controller)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
let viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedStickerPacks)
|
||||
let _ = (context.account.postbox.combinedView(keys: [viewKey])
|
||||
|> take(1)
|
||||
@ -350,20 +343,26 @@ class StickerPickerScreen: ViewController {
|
||||
context.sharedContext.mainWindow?.presentInGlobalOverlay(actionSheet)
|
||||
}
|
||||
},
|
||||
pushController: { c in },
|
||||
presentController: { c in },
|
||||
presentGlobalOverlayController: { c in },
|
||||
pushController: { c in
|
||||
},
|
||||
presentController: { c in
|
||||
},
|
||||
presentGlobalOverlayController: { c in
|
||||
},
|
||||
navigationController: { [weak self] in
|
||||
return self?.controller?.navigationController as? NavigationController
|
||||
},
|
||||
requestUpdate: { _ in },
|
||||
updateSearchQuery: { _, _ in },
|
||||
requestUpdate: { _ in
|
||||
},
|
||||
updateSearchQuery: { _, _ in
|
||||
},
|
||||
chatPeerId: nil,
|
||||
peekBehavior: nil,
|
||||
customLayout: nil,
|
||||
externalBackground: nil,
|
||||
externalExpansionView: nil,
|
||||
useOpaqueTheme: false
|
||||
useOpaqueTheme: false,
|
||||
hideBackground: true
|
||||
)
|
||||
|
||||
content.masks?.inputInteractionHolder.inputInteraction = EmojiPagerContentComponent.InputInteraction(
|
||||
@ -383,13 +382,6 @@ class StickerPickerScreen: ViewController {
|
||||
return
|
||||
}
|
||||
let context = controller.context
|
||||
|
||||
if isPremiumLocked {
|
||||
// let controller = PremiumIntroScreen(context: context, source: .stickers)
|
||||
// controllerInteraction.navigationController()?.pushViewController(controller)
|
||||
return
|
||||
}
|
||||
|
||||
let viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedStickerPacks)
|
||||
let _ = (context.account.postbox.combinedView(keys: [viewKey])
|
||||
|> take(1)
|
||||
@ -425,20 +417,26 @@ class StickerPickerScreen: ViewController {
|
||||
},
|
||||
clearGroup: { _ in
|
||||
},
|
||||
pushController: { c in },
|
||||
presentController: { c in },
|
||||
presentGlobalOverlayController: { c in },
|
||||
pushController: { c in
|
||||
},
|
||||
presentController: { c in
|
||||
},
|
||||
presentGlobalOverlayController: { c in
|
||||
},
|
||||
navigationController: { [weak self] in
|
||||
return self?.controller?.navigationController as? NavigationController
|
||||
},
|
||||
requestUpdate: { _ in },
|
||||
updateSearchQuery: { _, _ in },
|
||||
requestUpdate: { _ in
|
||||
},
|
||||
updateSearchQuery: { _, _ in
|
||||
},
|
||||
chatPeerId: nil,
|
||||
peekBehavior: nil,
|
||||
customLayout: nil,
|
||||
externalBackground: nil,
|
||||
externalExpansionView: nil,
|
||||
useOpaqueTheme: false
|
||||
useOpaqueTheme: false,
|
||||
hideBackground: true
|
||||
)
|
||||
|
||||
content.stickers?.inputInteractionHolder.inputInteraction = EmojiPagerContentComponent.InputInteraction(
|
||||
@ -452,19 +450,13 @@ class StickerPickerScreen: ViewController {
|
||||
deleteBackwards: nil,
|
||||
openStickerSettings: nil,
|
||||
openFeatured: nil,
|
||||
openSearch: {},
|
||||
openSearch: {
|
||||
},
|
||||
addGroupAction: { [weak self] groupId, isPremiumLocked in
|
||||
guard let strongSelf = self, let controller = strongSelf.controller, let collectionId = groupId.base as? ItemCollectionId else {
|
||||
return
|
||||
}
|
||||
let context = controller.context
|
||||
|
||||
if isPremiumLocked {
|
||||
// let controller = PremiumIntroScreen(context: context, source: .stickers)
|
||||
// controllerInteraction.navigationController()?.pushViewController(controller)
|
||||
return
|
||||
}
|
||||
|
||||
let viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedStickerPacks)
|
||||
let _ = (context.account.postbox.combinedView(keys: [viewKey])
|
||||
|> take(1)
|
||||
@ -534,20 +526,26 @@ class StickerPickerScreen: ViewController {
|
||||
} else if groupId == AnyHashable("peerSpecific") {
|
||||
}
|
||||
},
|
||||
pushController: { c in },
|
||||
presentController: { c in },
|
||||
presentGlobalOverlayController: { c in },
|
||||
pushController: { c in
|
||||
},
|
||||
presentController: { c in
|
||||
},
|
||||
presentGlobalOverlayController: { c in
|
||||
},
|
||||
navigationController: { [weak self] in
|
||||
return self?.controller?.navigationController as? NavigationController
|
||||
},
|
||||
requestUpdate: { _ in },
|
||||
updateSearchQuery: { _, _ in },
|
||||
requestUpdate: { _ in
|
||||
},
|
||||
updateSearchQuery: { _, _ in
|
||||
},
|
||||
chatPeerId: nil,
|
||||
peekBehavior: nil,
|
||||
customLayout: nil,
|
||||
externalBackground: nil,
|
||||
externalExpansionView: nil,
|
||||
useOpaqueTheme: false
|
||||
useOpaqueTheme: false,
|
||||
hideBackground: true
|
||||
)
|
||||
|
||||
if let (layout, navigationHeight) = self.currentLayout {
|
||||
|
@ -288,7 +288,7 @@ final class TextFontComponent: Component {
|
||||
if view.superview == nil {
|
||||
self.scrollView.addSubview(view)
|
||||
}
|
||||
view.frame = CGRect(origin: CGPoint(x: contentWidth - 7.0, y: -7.0), size: alignmentSize)
|
||||
view.frame = CGRect(origin: CGPoint(x: contentWidth - 7.0, y: -6.0 - UIScreenPixel), size: alignmentSize)
|
||||
}
|
||||
|
||||
contentWidth += 36.0
|
||||
@ -464,8 +464,6 @@ final class TextSettingsComponent: CombinedComponent {
|
||||
let colorButton = Child(ColorSwatchComponent.self)
|
||||
let colorButtonTag = GenericComponentViewTag()
|
||||
|
||||
// let styleButton = Child(Button.self)
|
||||
// let alignmentButton = Child(Button.self)
|
||||
let keyboardButton = Child(Button.self)
|
||||
let font = Child(TextFontComponent.self)
|
||||
|
||||
@ -508,7 +506,7 @@ final class TextSettingsComponent: CombinedComponent {
|
||||
context.add(colorButton
|
||||
.position(CGPoint(x: colorButton.size.width / 2.0, y: context.availableSize.height / 2.0))
|
||||
)
|
||||
offset += 44.0
|
||||
offset += 32.0
|
||||
}
|
||||
|
||||
let styleImage: UIImage
|
||||
@ -525,7 +523,7 @@ final class TextSettingsComponent: CombinedComponent {
|
||||
|
||||
var fontAvailableWidth: CGFloat = context.availableSize.width
|
||||
if component.color != nil {
|
||||
fontAvailableWidth -= 88.0
|
||||
fontAvailableWidth -= 72.0
|
||||
}
|
||||
|
||||
let font = font.update(
|
||||
|
@ -1465,7 +1465,8 @@ public final class ReactionContextNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
effectContainerView: self.backgroundNode.vibrancyEffectView?.contentView
|
||||
),
|
||||
externalExpansionView: self.view,
|
||||
useOpaqueTheme: false
|
||||
useOpaqueTheme: false,
|
||||
hideBackground: false
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode {
|
||||
|
||||
let strings = context.sharedContext.currentPresentationData.with({ $0 }).strings
|
||||
|
||||
let stickerItems = EmojiPagerContentComponent.stickerInputData(context: context, animationCache: animationCache, animationRenderer: animationRenderer, stickerNamespaces: stickerNamespaces, stickerOrderedItemListCollectionIds: stickerOrderedItemListCollectionIds, chatPeerId: chatPeerId, hasSearch: true, hasTrending: true)
|
||||
let stickerItems = EmojiPagerContentComponent.stickerInputData(context: context, animationCache: animationCache, animationRenderer: animationRenderer, stickerNamespaces: stickerNamespaces, stickerOrderedItemListCollectionIds: stickerOrderedItemListCollectionIds, chatPeerId: chatPeerId, hasSearch: true, hasTrending: true, forceHasPremium: false)
|
||||
|
||||
let reactions: Signal<[String], NoError> = context.engine.data.subscribe(TelegramEngine.EngineData.Item.Configuration.App())
|
||||
|> map { appConfiguration -> [String] in
|
||||
@ -879,7 +879,8 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode {
|
||||
customLayout: nil,
|
||||
externalBackground: nil,
|
||||
externalExpansionView: nil,
|
||||
useOpaqueTheme: false
|
||||
useOpaqueTheme: false,
|
||||
hideBackground: false
|
||||
)
|
||||
|
||||
var stickerPeekBehavior: EmojiContentPeekBehaviorImpl?
|
||||
@ -1089,7 +1090,8 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode {
|
||||
customLayout: nil,
|
||||
externalBackground: nil,
|
||||
externalExpansionView: nil,
|
||||
useOpaqueTheme: false
|
||||
useOpaqueTheme: false,
|
||||
hideBackground: false
|
||||
)
|
||||
|
||||
self.inputDataDisposable = (combineLatest(queue: .mainQueue(),
|
||||
@ -1724,7 +1726,9 @@ public final class EntityInputView: UIInputView, AttachmentTextInputPanelInputVi
|
||||
public init(
|
||||
context: AccountContext,
|
||||
isDark: Bool,
|
||||
areCustomEmojiEnabled: Bool
|
||||
areCustomEmojiEnabled: Bool,
|
||||
hideBackground: Bool = false,
|
||||
forceHasPremium: Bool = false
|
||||
) {
|
||||
self.context = context
|
||||
|
||||
@ -1744,7 +1748,13 @@ public final class EntityInputView: UIInputView, AttachmentTextInputPanelInputVi
|
||||
|
||||
let inputInteraction = EmojiPagerContentComponent.InputInteraction(
|
||||
performItemAction: { [weak self] groupId, item, _, _, _, _ in
|
||||
let _ = (ChatEntityKeyboardInputNode.hasPremium(context: context, chatPeerId: nil, premiumIfSavedMessages: false) |> take(1) |> deliverOnMainQueue).start(next: { hasPremium in
|
||||
let hasPremium: Signal<Bool, NoError>
|
||||
if forceHasPremium {
|
||||
hasPremium = .single(true)
|
||||
} else {
|
||||
hasPremium = ChatEntityKeyboardInputNode.hasPremium(context: context, chatPeerId: nil, premiumIfSavedMessages: false) |> take(1) |> deliverOnMainQueue
|
||||
}
|
||||
let _ = hasPremium.start(next: { hasPremium in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
@ -1850,12 +1860,13 @@ public final class EntityInputView: UIInputView, AttachmentTextInputPanelInputVi
|
||||
customLayout: nil,
|
||||
externalBackground: nil,
|
||||
externalExpansionView: nil,
|
||||
useOpaqueTheme: false
|
||||
useOpaqueTheme: false,
|
||||
hideBackground: hideBackground
|
||||
)
|
||||
|
||||
let semaphore = DispatchSemaphore(value: 0)
|
||||
var emojiComponent: EmojiPagerContentComponent?
|
||||
let _ = EmojiPagerContentComponent.emojiInputData(context: context, animationCache: self.animationCache, animationRenderer: self.animationRenderer, isStandalone: true, isStatusSelection: false, isReactionSelection: false, isEmojiSelection: false, topReactionItems: [], areUnicodeEmojiEnabled: true, areCustomEmojiEnabled: areCustomEmojiEnabled, chatPeerId: nil).start(next: { value in
|
||||
let _ = EmojiPagerContentComponent.emojiInputData(context: context, animationCache: self.animationCache, animationRenderer: self.animationRenderer, isStandalone: true, isStatusSelection: false, isReactionSelection: false, isEmojiSelection: false, topReactionItems: [], areUnicodeEmojiEnabled: true, areCustomEmojiEnabled: areCustomEmojiEnabled, chatPeerId: nil, forceHasPremium: forceHasPremium).start(next: { value in
|
||||
emojiComponent = value
|
||||
semaphore.signal()
|
||||
})
|
||||
@ -1870,7 +1881,7 @@ public final class EntityInputView: UIInputView, AttachmentTextInputPanelInputVi
|
||||
gifs: nil,
|
||||
availableGifSearchEmojies: []
|
||||
),
|
||||
updatedInputData: EmojiPagerContentComponent.emojiInputData(context: context, animationCache: self.animationCache, animationRenderer: self.animationRenderer, isStandalone: true, isStatusSelection: false, isReactionSelection: false, isEmojiSelection: false, topReactionItems: [], areUnicodeEmojiEnabled: true, areCustomEmojiEnabled: areCustomEmojiEnabled, chatPeerId: nil) |> map { emojiComponent -> ChatEntityKeyboardInputNode.InputData in
|
||||
updatedInputData: EmojiPagerContentComponent.emojiInputData(context: context, animationCache: self.animationCache, animationRenderer: self.animationRenderer, isStandalone: true, isStatusSelection: false, isReactionSelection: false, isEmojiSelection: false, topReactionItems: [], areUnicodeEmojiEnabled: true, areCustomEmojiEnabled: areCustomEmojiEnabled, chatPeerId: nil, forceHasPremium: forceHasPremium) |> map { emojiComponent -> ChatEntityKeyboardInputNode.InputData in
|
||||
return ChatEntityKeyboardInputNode.InputData(
|
||||
emoji: emojiComponent,
|
||||
stickers: nil,
|
||||
|
@ -558,7 +558,8 @@ public final class EmojiStatusSelectionController: ViewController {
|
||||
customLayout: nil,
|
||||
externalBackground: nil,
|
||||
externalExpansionView: nil,
|
||||
useOpaqueTheme: true
|
||||
useOpaqueTheme: true,
|
||||
hideBackground: false
|
||||
)
|
||||
|
||||
strongSelf.refreshLayout(transition: .immediate)
|
||||
|
@ -2119,6 +2119,7 @@ public final class EmojiPagerContentComponent: Component {
|
||||
public let externalBackground: ExternalBackground?
|
||||
public weak var externalExpansionView: UIView?
|
||||
public let useOpaqueTheme: Bool
|
||||
public let hideBackground: Bool
|
||||
|
||||
public init(
|
||||
performItemAction: @escaping (AnyHashable, Item, UIView, CGRect, CALayer, Bool) -> Void,
|
||||
@ -2139,7 +2140,8 @@ public final class EmojiPagerContentComponent: Component {
|
||||
customLayout: CustomLayout?,
|
||||
externalBackground: ExternalBackground?,
|
||||
externalExpansionView: UIView?,
|
||||
useOpaqueTheme: Bool
|
||||
useOpaqueTheme: Bool,
|
||||
hideBackground: Bool
|
||||
) {
|
||||
self.performItemAction = performItemAction
|
||||
self.deleteBackwards = deleteBackwards
|
||||
@ -2160,6 +2162,7 @@ public final class EmojiPagerContentComponent: Component {
|
||||
self.externalBackground = externalBackground
|
||||
self.externalExpansionView = externalExpansionView
|
||||
self.useOpaqueTheme = useOpaqueTheme
|
||||
self.hideBackground = hideBackground
|
||||
}
|
||||
}
|
||||
|
||||
@ -5745,7 +5748,12 @@ public final class EmojiPagerContentComponent: Component {
|
||||
self.backgroundView.isHidden = false
|
||||
}
|
||||
|
||||
self.backgroundView.updateColor(color: keyboardChildEnvironment.theme.chat.inputMediaPanel.backgroundColor, enableBlur: true, forceKeepBlur: false, transition: transition.containedViewLayoutTransition)
|
||||
let hideBackground = component.inputInteractionHolder.inputInteraction?.hideBackground ?? false
|
||||
var backgroundColor = keyboardChildEnvironment.theme.chat.inputMediaPanel.backgroundColor
|
||||
if hideBackground {
|
||||
backgroundColor = backgroundColor.withAlphaComponent(0.01)
|
||||
}
|
||||
self.backgroundView.updateColor(color: backgroundColor, enableBlur: true, forceKeepBlur: false, transition: transition.containedViewLayoutTransition)
|
||||
transition.setFrame(view: self.backgroundView, frame: backgroundFrame)
|
||||
self.backgroundView.update(size: backgroundFrame.size, transition: transition.containedViewLayoutTransition)
|
||||
|
||||
@ -6311,7 +6319,8 @@ public final class EmojiPagerContentComponent: Component {
|
||||
topStatusTitle: String? = nil,
|
||||
topicTitle: String? = nil,
|
||||
topicColor: Int32? = nil,
|
||||
hasSearch: Bool = true
|
||||
hasSearch: Bool = true,
|
||||
forceHasPremium: Bool = false
|
||||
) -> Signal<EmojiPagerContentComponent, NoError> {
|
||||
let premiumConfiguration = PremiumConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 })
|
||||
let isPremiumDisabled = premiumConfiguration.isPremiumDisabled
|
||||
@ -6363,7 +6372,7 @@ public final class EmojiPagerContentComponent: Component {
|
||||
|
||||
let emojiItems: Signal<EmojiPagerContentComponent, NoError> = combineLatest(
|
||||
context.account.postbox.itemCollectionsView(orderedItemListCollectionIds: orderedItemListCollectionIds, namespaces: [Namespaces.ItemCollection.CloudEmojiPacks], aroundIndex: nil, count: 10000000),
|
||||
hasPremium(context: context, chatPeerId: chatPeerId, premiumIfSavedMessages: true),
|
||||
forceHasPremium ? .single(true) : hasPremium(context: context, chatPeerId: chatPeerId, premiumIfSavedMessages: true),
|
||||
context.account.viewTracker.featuredEmojiPacks(),
|
||||
availableReactions,
|
||||
iconStatusEmoji
|
||||
@ -7165,7 +7174,8 @@ public final class EmojiPagerContentComponent: Component {
|
||||
stickerOrderedItemListCollectionIds: [Int32],
|
||||
chatPeerId: EnginePeer.Id?,
|
||||
hasSearch: Bool,
|
||||
hasTrending: Bool
|
||||
hasTrending: Bool,
|
||||
forceHasPremium: Bool
|
||||
) -> Signal<EmojiPagerContentComponent, NoError> {
|
||||
let premiumConfiguration = PremiumConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 })
|
||||
let isPremiumDisabled = premiumConfiguration.isPremiumDisabled
|
||||
@ -7216,7 +7226,7 @@ public final class EmojiPagerContentComponent: Component {
|
||||
|
||||
return combineLatest(
|
||||
context.account.postbox.itemCollectionsView(orderedItemListCollectionIds: stickerOrderedItemListCollectionIds, namespaces: stickerNamespaces, aroundIndex: nil, count: 10000000),
|
||||
hasPremium(context: context, chatPeerId: chatPeerId, premiumIfSavedMessages: false),
|
||||
forceHasPremium ? .single(true) : hasPremium(context: context, chatPeerId: chatPeerId, premiumIfSavedMessages: false),
|
||||
hasTrending ? context.account.viewTracker.featuredStickerPacks() : .single([]),
|
||||
context.engine.data.get(TelegramEngine.EngineData.Item.ItemCache.Item(collectionId: Namespaces.CachedItemCollection.featuredStickersConfiguration, id: ValueBoxKey(length: 0))),
|
||||
ApplicationSpecificNotice.dismissedTrendingStickerPacks(accountManager: context.sharedContext.accountManager),
|
||||
|
@ -968,7 +968,8 @@ private final class ForumCreateTopicScreenComponent: CombinedComponent {
|
||||
customLayout: nil,
|
||||
externalBackground: nil,
|
||||
externalExpansionView: nil,
|
||||
useOpaqueTheme: true
|
||||
useOpaqueTheme: true,
|
||||
hideBackground: false
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user