Various fixes

This commit is contained in:
Ilya Laktyushin 2022-12-18 23:39:03 +04:00
parent 056f265511
commit 1d0f77fc3e
12 changed files with 176 additions and 88 deletions

View File

@ -14,6 +14,7 @@ public final class DrawingBubbleEntity: DrawingEntity, Codable {
case size case size
case rotation case rotation
case tailPosition case tailPosition
case renderImage
} }
enum DrawType: Codable { enum DrawType: Codable {
@ -67,6 +68,9 @@ public final class DrawingBubbleEntity: DrawingEntity, Codable {
self.size = try container.decode(CGSize.self, forKey: .size) self.size = try container.decode(CGSize.self, forKey: .size)
self.rotation = try container.decode(CGFloat.self, forKey: .rotation) self.rotation = try container.decode(CGFloat.self, forKey: .rotation)
self.tailPosition = try container.decode(CGPoint.self, forKey: .tailPosition) 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 { 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.size, forKey: .size)
try container.encode(self.rotation, forKey: .rotation) try container.encode(self.rotation, forKey: .rotation)
try container.encode(self.tailPosition, forKey: .tailPosition) try container.encode(self.tailPosition, forKey: .tailPosition)
if let renderImage, let data = renderImage.pngData() {
try container.encode(data, forKey: .renderImage)
}
} }
public func duplicate() -> DrawingEntity { public func duplicate() -> DrawingEntity {
@ -99,6 +106,7 @@ public final class DrawingBubbleEntity: DrawingEntity, Codable {
} }
public func prepareForRender() { public func prepareForRender() {
self.renderImage = (self.currentEntityView as? DrawingBubbleEntityView)?.getRenderImage()
} }
} }
@ -134,8 +142,8 @@ final class DrawingBubbleEntityView: DrawingEntityView {
self.currentTailPosition = self.bubbleEntity.tailPosition self.currentTailPosition = self.bubbleEntity.tailPosition
self.shapeLayer.frame = self.bounds self.shapeLayer.frame = self.bounds
let cornerRadius = max(10.0, max(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.066) 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.016) 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) 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) 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 self.shapeLayer.strokeColor = UIColor.clear.cgColor
case .stroke: case .stroke:
let minLineWidth = max(10.0, max(self.bubbleEntity.referenceDrawingSize.width, self.bubbleEntity.referenceDrawingSize.height) * 0.01) 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 let lineWidth = minLineWidth + (maxLineWidth - minLineWidth) * self.bubbleEntity.lineWidth
self.shapeLayer.fillColor = UIColor.clear.cgColor self.shapeLayer.fillColor = UIColor.clear.cgColor
@ -207,6 +215,15 @@ final class DrawingBubbleEntityView: DrawingEntityView {
selectionView.entityView = self selectionView.entityView = self
return selectionView 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 { final class DrawingBubbleEntititySelectionView: DrawingEntitySelectionView, UIGestureRecognizerDelegate {

View File

@ -183,7 +183,7 @@ struct DrawingState: Equatable {
.pen(DrawingToolState.BrushState(color: DrawingColor(rgb: 0xff453a), size: 0.2)), .pen(DrawingToolState.BrushState(color: DrawingColor(rgb: 0xff453a), size: 0.2)),
.arrow(DrawingToolState.BrushState(color: DrawingColor(rgb: 0xff8a00), size: 0.2)), .arrow(DrawingToolState.BrushState(color: DrawingColor(rgb: 0xff8a00), size: 0.2)),
.marker(DrawingToolState.BrushState(color: DrawingColor(rgb: 0xffd60a), size: 0.75)), .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)), .eraser(DrawingToolState.EraserState(size: 0.5)),
.blur(DrawingToolState.EraserState(size: 0.5)) .blur(DrawingToolState.EraserState(size: 0.5))
] ]
@ -393,7 +393,8 @@ private final class DrawingScreenComponent: CombinedComponent {
areUnicodeEmojiEnabled: true, areUnicodeEmojiEnabled: true,
areCustomEmojiEnabled: true, areCustomEmojiEnabled: true,
chatPeerId: context.account.peerId, chatPeerId: context.account.peerId,
hasSearch: false hasSearch: false,
forceHasPremium: true
) )
let stickerItems = EmojiPagerContentComponent.stickerInputData( let stickerItems = EmojiPagerContentComponent.stickerInputData(
@ -404,7 +405,8 @@ private final class DrawingScreenComponent: CombinedComponent {
stickerOrderedItemListCollectionIds: [Namespaces.OrderedItemList.CloudSavedStickers, Namespaces.OrderedItemList.CloudRecentStickers, Namespaces.OrderedItemList.CloudAllPremiumStickers], stickerOrderedItemListCollectionIds: [Namespaces.OrderedItemList.CloudSavedStickers, Namespaces.OrderedItemList.CloudRecentStickers, Namespaces.OrderedItemList.CloudAllPremiumStickers],
chatPeerId: context.account.peerId, chatPeerId: context.account.peerId,
hasSearch: false, hasSearch: false,
hasTrending: true hasTrending: true,
forceHasPremium: true
) )
let maskItems = EmojiPagerContentComponent.stickerInputData( let maskItems = EmojiPagerContentComponent.stickerInputData(
@ -415,7 +417,8 @@ private final class DrawingScreenComponent: CombinedComponent {
stickerOrderedItemListCollectionIds: [], stickerOrderedItemListCollectionIds: [],
chatPeerId: context.account.peerId, chatPeerId: context.account.peerId,
hasSearch: false, hasSearch: false,
hasTrending: false hasTrending: false,
forceHasPremium: true
) )
let signal = combineLatest(queue: .mainQueue(), let signal = combineLatest(queue: .mainQueue(),
@ -2232,7 +2235,13 @@ public class DrawingScreen: ViewController, TGPhotoDrawingInterfaceController {
} }
if shouldHaveInputView { 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 inputView.insertText = { [weak entityView] text in
entityView?.insertText(text) entityView?.insertText(text)
} }

View File

@ -14,6 +14,7 @@ public final class DrawingSimpleShapeEntity: DrawingEntity, Codable {
case position case position
case size case size
case rotation case rotation
case renderImage
} }
public enum ShapeType: Codable { public enum ShapeType: Codable {
@ -73,6 +74,9 @@ public final class DrawingSimpleShapeEntity: DrawingEntity, Codable {
self.position = try container.decode(CGPoint.self, forKey: .position) self.position = try container.decode(CGPoint.self, forKey: .position)
self.size = try container.decode(CGSize.self, forKey: .size) self.size = try container.decode(CGSize.self, forKey: .size)
self.rotation = try container.decode(CGFloat.self, forKey: .rotation) 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 { 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.position, forKey: .position)
try container.encode(self.size, forKey: .size) try container.encode(self.size, forKey: .size)
try container.encode(self.rotation, forKey: .rotation) try container.encode(self.rotation, forKey: .rotation)
if let renderImage, let data = renderImage.pngData() {
try container.encode(data, forKey: .renderImage)
}
} }
public func duplicate() -> DrawingEntity { public func duplicate() -> DrawingEntity {
@ -105,6 +112,7 @@ public final class DrawingSimpleShapeEntity: DrawingEntity, Codable {
} }
public func prepareForRender() { public func prepareForRender() {
self.renderImage = (self.currentEntityView as? DrawingSimpleShapeEntityView)?.getRenderImage()
} }
} }
@ -141,13 +149,14 @@ final class DrawingSimpleShapeEntityView: DrawingEntityView {
self.currentSize = size self.currentSize = size
self.shapeLayer.frame = self.bounds self.shapeLayer.frame = self.bounds
let rect = CGRect(origin: .zero, size: size).insetBy(dx: maxLineWidth * 0.5, dy: maxLineWidth * 0.5)
switch shapeType { switch shapeType {
case .rectangle: case .rectangle:
self.shapeLayer.path = CGPath(rect: CGRect(origin: .zero, size: size), transform: nil) self.shapeLayer.path = CGPath(rect: rect, transform: nil)
case .ellipse: case .ellipse:
self.shapeLayer.path = CGPath(ellipseIn: CGRect(origin: .zero, size: size), transform: nil) self.shapeLayer.path = CGPath(ellipseIn: rect, transform: nil)
case .star: 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 self.shapeLayer.strokeColor = UIColor.clear.cgColor
case .stroke: case .stroke:
let minLineWidth = max(10.0, max(self.shapeEntity.referenceDrawingSize.width, self.shapeEntity.referenceDrawingSize.height) * 0.01) 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 let lineWidth = minLineWidth + (maxLineWidth - minLineWidth) * self.shapeEntity.lineWidth
self.shapeLayer.fillColor = UIColor.clear.cgColor self.shapeLayer.fillColor = UIColor.clear.cgColor
@ -172,8 +181,8 @@ final class DrawingSimpleShapeEntityView: DrawingEntityView {
return self.shapeLayer.lineWidth return self.shapeLayer.lineWidth
} }
private var maxLineWidth: CGFloat { fileprivate var maxLineWidth: CGFloat {
return max(10.0, max(self.shapeEntity.referenceDrawingSize.width, self.shapeEntity.referenceDrawingSize.height) * 0.1) 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 { override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
@ -219,6 +228,19 @@ final class DrawingSimpleShapeEntityView: DrawingEntityView {
selectionView.entityView = self selectionView.entityView = self
return selectionView 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 { func gestureIsTracking(_ gestureRecognizer: UIPanGestureRecognizer) -> Bool {
@ -447,10 +469,7 @@ final class DrawingSimpleShapeEntititySelectionView: DrawingEntitySelectionView,
} }
override func layoutSubviews() { override func layoutSubviews() {
var inset = self.selectionInset let 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 bounds = CGRect(origin: .zero, size: CGSize(width: entitySelectionViewHandleSize.width / self.scale, height: entitySelectionViewHandleSize.height / self.scale)) 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) let handleSize = CGSize(width: 9.0 / self.scale, height: 9.0 / self.scale)

View File

@ -52,6 +52,8 @@ public final class DrawingTextEntity: DrawingEntity, Codable {
case width case width
case scale case scale
case rotation case rotation
case renderImage
case renderSubEntities
} }
enum Style: Codable { enum Style: Codable {
@ -193,6 +195,9 @@ public final class DrawingTextEntity: DrawingEntity, Codable {
self.width = try container.decode(CGFloat.self, forKey: .width) self.width = try container.decode(CGFloat.self, forKey: .width)
self.scale = try container.decode(CGFloat.self, forKey: .scale) self.scale = try container.decode(CGFloat.self, forKey: .scale)
self.rotation = try container.decode(CGFloat.self, forKey: .rotation) 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 { 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.width, forKey: .width)
try container.encode(self.scale, forKey: .scale) try container.encode(self.scale, forKey: .scale)
try container.encode(self.rotation, forKey: .rotation) try container.encode(self.rotation, forKey: .rotation)
if let renderImage, let data = renderImage.pngData() {
try container.encode(data, forKey: .renderImage)
}
} }
public func duplicate() -> DrawingEntity { public func duplicate() -> DrawingEntity {
@ -526,8 +534,8 @@ final class DrawingTextEntityView: DrawingEntityView, UITextViewDelegate {
} }
private var displayFontSize: CGFloat { private var displayFontSize: CGFloat {
let minFontSize = max(10.0, max(self.textEntity.referenceDrawingSize.width, self.textEntity.referenceDrawingSize.height) * 0.05) 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.45) let maxFontSize = max(10.0, max(self.textEntity.referenceDrawingSize.width, self.textEntity.referenceDrawingSize.height) * 0.25)
let fontSize = minFontSize + (maxFontSize - minFontSize) * self.textEntity.fontSize let fontSize = minFontSize + (maxFontSize - minFontSize) * self.textEntity.fontSize
return fontSize return fontSize
} }

View File

@ -14,6 +14,7 @@ public final class DrawingVectorEntity: DrawingEntity, Codable {
case start case start
case mid case mid
case end case end
case renderImage
} }
public enum VectorType: Codable { public enum VectorType: Codable {
@ -77,11 +78,12 @@ public final class DrawingVectorEntity: DrawingEntity, Codable {
self.drawingSize = try container.decode(CGSize.self, forKey: .drawingSize) self.drawingSize = try container.decode(CGSize.self, forKey: .drawingSize)
self.referenceDrawingSize = try container.decode(CGSize.self, forKey: .referenceDrawingSize) self.referenceDrawingSize = try container.decode(CGSize.self, forKey: .referenceDrawingSize)
self.start = try container.decode(CGPoint.self, forKey: .start) self.start = try container.decode(CGPoint.self, forKey: .start)
let mid = try container.decode(CGPoint.self, forKey: .mid) let mid = try container.decode(CGPoint.self, forKey: .mid)
self.mid = (mid.x, mid.y) self.mid = (mid.x, mid.y)
self.end = try container.decode(CGPoint.self, forKey: .end) 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 { 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(self.start, forKey: .start)
try container.encode(CGPoint(x: self.mid.0, y: self.mid.1), forKey: .mid) try container.encode(CGPoint(x: self.mid.0, y: self.mid.1), forKey: .mid)
try container.encode(self.end, forKey: .end) try container.encode(self.end, forKey: .end)
if let renderImage, let data = renderImage.pngData() {
try container.encode(data, forKey: .renderImage)
}
} }
public func duplicate() -> DrawingEntity { public func duplicate() -> DrawingEntity {
@ -115,6 +120,7 @@ public final class DrawingVectorEntity: DrawingEntity, Codable {
} }
public func prepareForRender() { 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) 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 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 let lineWidth = minLineWidth + (maxLineWidth - minLineWidth) * self.vectorEntity.lineWidth
self.shapeLayer.path = CGPath.curve( self.shapeLayer.path = CGPath.curve(
@ -206,6 +212,15 @@ final class DrawingVectorEntityView: DrawingEntityView {
selectionView.entityView = self selectionView.entityView = self
return selectionView 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 { private func midPointPositionFor(start: CGPoint, end: CGPoint, length: CGFloat, height: CGFloat) -> CGPoint {

View File

@ -276,20 +276,13 @@ class StickerPickerScreen: ViewController {
deleteBackwards: nil, deleteBackwards: nil,
openStickerSettings: nil, openStickerSettings: nil,
openFeatured: nil, openFeatured: nil,
openSearch: {}, openSearch: {
},
addGroupAction: { [weak self] groupId, isPremiumLocked in addGroupAction: { [weak self] groupId, isPremiumLocked in
guard let strongSelf = self, let controller = strongSelf.controller, let collectionId = groupId.base as? ItemCollectionId else { guard let strongSelf = self, let controller = strongSelf.controller, let collectionId = groupId.base as? ItemCollectionId else {
return return
} }
let context = controller.context 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 viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedStickerPacks)
let _ = (context.account.postbox.combinedView(keys: [viewKey]) let _ = (context.account.postbox.combinedView(keys: [viewKey])
|> take(1) |> take(1)
@ -350,20 +343,26 @@ class StickerPickerScreen: ViewController {
context.sharedContext.mainWindow?.presentInGlobalOverlay(actionSheet) context.sharedContext.mainWindow?.presentInGlobalOverlay(actionSheet)
} }
}, },
pushController: { c in }, pushController: { c in
presentController: { c in }, },
presentGlobalOverlayController: { c in }, presentController: { c in
},
presentGlobalOverlayController: { c in
},
navigationController: { [weak self] in navigationController: { [weak self] in
return self?.controller?.navigationController as? NavigationController return self?.controller?.navigationController as? NavigationController
}, },
requestUpdate: { _ in }, requestUpdate: { _ in
updateSearchQuery: { _, _ in }, },
updateSearchQuery: { _, _ in
},
chatPeerId: nil, chatPeerId: nil,
peekBehavior: nil, peekBehavior: nil,
customLayout: nil, customLayout: nil,
externalBackground: nil, externalBackground: nil,
externalExpansionView: nil, externalExpansionView: nil,
useOpaqueTheme: false useOpaqueTheme: false,
hideBackground: true
) )
content.masks?.inputInteractionHolder.inputInteraction = EmojiPagerContentComponent.InputInteraction( content.masks?.inputInteractionHolder.inputInteraction = EmojiPagerContentComponent.InputInteraction(
@ -383,13 +382,6 @@ class StickerPickerScreen: ViewController {
return return
} }
let context = controller.context 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 viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedStickerPacks)
let _ = (context.account.postbox.combinedView(keys: [viewKey]) let _ = (context.account.postbox.combinedView(keys: [viewKey])
|> take(1) |> take(1)
@ -425,20 +417,26 @@ class StickerPickerScreen: ViewController {
}, },
clearGroup: { _ in clearGroup: { _ in
}, },
pushController: { c in }, pushController: { c in
presentController: { c in }, },
presentGlobalOverlayController: { c in }, presentController: { c in
},
presentGlobalOverlayController: { c in
},
navigationController: { [weak self] in navigationController: { [weak self] in
return self?.controller?.navigationController as? NavigationController return self?.controller?.navigationController as? NavigationController
}, },
requestUpdate: { _ in }, requestUpdate: { _ in
updateSearchQuery: { _, _ in }, },
updateSearchQuery: { _, _ in
},
chatPeerId: nil, chatPeerId: nil,
peekBehavior: nil, peekBehavior: nil,
customLayout: nil, customLayout: nil,
externalBackground: nil, externalBackground: nil,
externalExpansionView: nil, externalExpansionView: nil,
useOpaqueTheme: false useOpaqueTheme: false,
hideBackground: true
) )
content.stickers?.inputInteractionHolder.inputInteraction = EmojiPagerContentComponent.InputInteraction( content.stickers?.inputInteractionHolder.inputInteraction = EmojiPagerContentComponent.InputInteraction(
@ -452,19 +450,13 @@ class StickerPickerScreen: ViewController {
deleteBackwards: nil, deleteBackwards: nil,
openStickerSettings: nil, openStickerSettings: nil,
openFeatured: nil, openFeatured: nil,
openSearch: {}, openSearch: {
},
addGroupAction: { [weak self] groupId, isPremiumLocked in addGroupAction: { [weak self] groupId, isPremiumLocked in
guard let strongSelf = self, let controller = strongSelf.controller, let collectionId = groupId.base as? ItemCollectionId else { guard let strongSelf = self, let controller = strongSelf.controller, let collectionId = groupId.base as? ItemCollectionId else {
return return
} }
let context = controller.context 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 viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedStickerPacks)
let _ = (context.account.postbox.combinedView(keys: [viewKey]) let _ = (context.account.postbox.combinedView(keys: [viewKey])
|> take(1) |> take(1)
@ -534,20 +526,26 @@ class StickerPickerScreen: ViewController {
} else if groupId == AnyHashable("peerSpecific") { } else if groupId == AnyHashable("peerSpecific") {
} }
}, },
pushController: { c in }, pushController: { c in
presentController: { c in }, },
presentGlobalOverlayController: { c in }, presentController: { c in
},
presentGlobalOverlayController: { c in
},
navigationController: { [weak self] in navigationController: { [weak self] in
return self?.controller?.navigationController as? NavigationController return self?.controller?.navigationController as? NavigationController
}, },
requestUpdate: { _ in }, requestUpdate: { _ in
updateSearchQuery: { _, _ in }, },
updateSearchQuery: { _, _ in
},
chatPeerId: nil, chatPeerId: nil,
peekBehavior: nil, peekBehavior: nil,
customLayout: nil, customLayout: nil,
externalBackground: nil, externalBackground: nil,
externalExpansionView: nil, externalExpansionView: nil,
useOpaqueTheme: false useOpaqueTheme: false,
hideBackground: true
) )
if let (layout, navigationHeight) = self.currentLayout { if let (layout, navigationHeight) = self.currentLayout {

View File

@ -288,7 +288,7 @@ final class TextFontComponent: Component {
if view.superview == nil { if view.superview == nil {
self.scrollView.addSubview(view) 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 contentWidth += 36.0
@ -464,8 +464,6 @@ final class TextSettingsComponent: CombinedComponent {
let colorButton = Child(ColorSwatchComponent.self) let colorButton = Child(ColorSwatchComponent.self)
let colorButtonTag = GenericComponentViewTag() let colorButtonTag = GenericComponentViewTag()
// let styleButton = Child(Button.self)
// let alignmentButton = Child(Button.self)
let keyboardButton = Child(Button.self) let keyboardButton = Child(Button.self)
let font = Child(TextFontComponent.self) let font = Child(TextFontComponent.self)
@ -508,7 +506,7 @@ final class TextSettingsComponent: CombinedComponent {
context.add(colorButton context.add(colorButton
.position(CGPoint(x: colorButton.size.width / 2.0, y: context.availableSize.height / 2.0)) .position(CGPoint(x: colorButton.size.width / 2.0, y: context.availableSize.height / 2.0))
) )
offset += 44.0 offset += 32.0
} }
let styleImage: UIImage let styleImage: UIImage
@ -525,7 +523,7 @@ final class TextSettingsComponent: CombinedComponent {
var fontAvailableWidth: CGFloat = context.availableSize.width var fontAvailableWidth: CGFloat = context.availableSize.width
if component.color != nil { if component.color != nil {
fontAvailableWidth -= 88.0 fontAvailableWidth -= 72.0
} }
let font = font.update( let font = font.update(

View File

@ -1465,7 +1465,8 @@ public final class ReactionContextNode: ASDisplayNode, UIScrollViewDelegate {
effectContainerView: self.backgroundNode.vibrancyEffectView?.contentView effectContainerView: self.backgroundNode.vibrancyEffectView?.contentView
), ),
externalExpansionView: self.view, externalExpansionView: self.view,
useOpaqueTheme: false useOpaqueTheme: false,
hideBackground: false
) )
} }

View File

@ -113,7 +113,7 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode {
let strings = context.sharedContext.currentPresentationData.with({ $0 }).strings 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()) let reactions: Signal<[String], NoError> = context.engine.data.subscribe(TelegramEngine.EngineData.Item.Configuration.App())
|> map { appConfiguration -> [String] in |> map { appConfiguration -> [String] in
@ -879,7 +879,8 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode {
customLayout: nil, customLayout: nil,
externalBackground: nil, externalBackground: nil,
externalExpansionView: nil, externalExpansionView: nil,
useOpaqueTheme: false useOpaqueTheme: false,
hideBackground: false
) )
var stickerPeekBehavior: EmojiContentPeekBehaviorImpl? var stickerPeekBehavior: EmojiContentPeekBehaviorImpl?
@ -1089,7 +1090,8 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode {
customLayout: nil, customLayout: nil,
externalBackground: nil, externalBackground: nil,
externalExpansionView: nil, externalExpansionView: nil,
useOpaqueTheme: false useOpaqueTheme: false,
hideBackground: false
) )
self.inputDataDisposable = (combineLatest(queue: .mainQueue(), self.inputDataDisposable = (combineLatest(queue: .mainQueue(),
@ -1724,7 +1726,9 @@ public final class EntityInputView: UIInputView, AttachmentTextInputPanelInputVi
public init( public init(
context: AccountContext, context: AccountContext,
isDark: Bool, isDark: Bool,
areCustomEmojiEnabled: Bool areCustomEmojiEnabled: Bool,
hideBackground: Bool = false,
forceHasPremium: Bool = false
) { ) {
self.context = context self.context = context
@ -1744,7 +1748,13 @@ public final class EntityInputView: UIInputView, AttachmentTextInputPanelInputVi
let inputInteraction = EmojiPagerContentComponent.InputInteraction( let inputInteraction = EmojiPagerContentComponent.InputInteraction(
performItemAction: { [weak self] groupId, item, _, _, _, _ in 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 { guard let strongSelf = self else {
return return
} }
@ -1850,12 +1860,13 @@ public final class EntityInputView: UIInputView, AttachmentTextInputPanelInputVi
customLayout: nil, customLayout: nil,
externalBackground: nil, externalBackground: nil,
externalExpansionView: nil, externalExpansionView: nil,
useOpaqueTheme: false useOpaqueTheme: false,
hideBackground: hideBackground
) )
let semaphore = DispatchSemaphore(value: 0) let semaphore = DispatchSemaphore(value: 0)
var emojiComponent: EmojiPagerContentComponent? 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 emojiComponent = value
semaphore.signal() semaphore.signal()
}) })
@ -1870,7 +1881,7 @@ public final class EntityInputView: UIInputView, AttachmentTextInputPanelInputVi
gifs: nil, gifs: nil,
availableGifSearchEmojies: [] 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( return ChatEntityKeyboardInputNode.InputData(
emoji: emojiComponent, emoji: emojiComponent,
stickers: nil, stickers: nil,

View File

@ -558,7 +558,8 @@ public final class EmojiStatusSelectionController: ViewController {
customLayout: nil, customLayout: nil,
externalBackground: nil, externalBackground: nil,
externalExpansionView: nil, externalExpansionView: nil,
useOpaqueTheme: true useOpaqueTheme: true,
hideBackground: false
) )
strongSelf.refreshLayout(transition: .immediate) strongSelf.refreshLayout(transition: .immediate)

View File

@ -2119,6 +2119,7 @@ public final class EmojiPagerContentComponent: Component {
public let externalBackground: ExternalBackground? public let externalBackground: ExternalBackground?
public weak var externalExpansionView: UIView? public weak var externalExpansionView: UIView?
public let useOpaqueTheme: Bool public let useOpaqueTheme: Bool
public let hideBackground: Bool
public init( public init(
performItemAction: @escaping (AnyHashable, Item, UIView, CGRect, CALayer, Bool) -> Void, performItemAction: @escaping (AnyHashable, Item, UIView, CGRect, CALayer, Bool) -> Void,
@ -2139,7 +2140,8 @@ public final class EmojiPagerContentComponent: Component {
customLayout: CustomLayout?, customLayout: CustomLayout?,
externalBackground: ExternalBackground?, externalBackground: ExternalBackground?,
externalExpansionView: UIView?, externalExpansionView: UIView?,
useOpaqueTheme: Bool useOpaqueTheme: Bool,
hideBackground: Bool
) { ) {
self.performItemAction = performItemAction self.performItemAction = performItemAction
self.deleteBackwards = deleteBackwards self.deleteBackwards = deleteBackwards
@ -2160,6 +2162,7 @@ public final class EmojiPagerContentComponent: Component {
self.externalBackground = externalBackground self.externalBackground = externalBackground
self.externalExpansionView = externalExpansionView self.externalExpansionView = externalExpansionView
self.useOpaqueTheme = useOpaqueTheme self.useOpaqueTheme = useOpaqueTheme
self.hideBackground = hideBackground
} }
} }
@ -5745,7 +5748,12 @@ public final class EmojiPagerContentComponent: Component {
self.backgroundView.isHidden = false 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) transition.setFrame(view: self.backgroundView, frame: backgroundFrame)
self.backgroundView.update(size: backgroundFrame.size, transition: transition.containedViewLayoutTransition) self.backgroundView.update(size: backgroundFrame.size, transition: transition.containedViewLayoutTransition)
@ -6311,7 +6319,8 @@ public final class EmojiPagerContentComponent: Component {
topStatusTitle: String? = nil, topStatusTitle: String? = nil,
topicTitle: String? = nil, topicTitle: String? = nil,
topicColor: Int32? = nil, topicColor: Int32? = nil,
hasSearch: Bool = true hasSearch: Bool = true,
forceHasPremium: Bool = false
) -> Signal<EmojiPagerContentComponent, NoError> { ) -> Signal<EmojiPagerContentComponent, NoError> {
let premiumConfiguration = PremiumConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 }) let premiumConfiguration = PremiumConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 })
let isPremiumDisabled = premiumConfiguration.isPremiumDisabled let isPremiumDisabled = premiumConfiguration.isPremiumDisabled
@ -6363,7 +6372,7 @@ public final class EmojiPagerContentComponent: Component {
let emojiItems: Signal<EmojiPagerContentComponent, NoError> = combineLatest( let emojiItems: Signal<EmojiPagerContentComponent, NoError> = combineLatest(
context.account.postbox.itemCollectionsView(orderedItemListCollectionIds: orderedItemListCollectionIds, namespaces: [Namespaces.ItemCollection.CloudEmojiPacks], aroundIndex: nil, count: 10000000), 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(), context.account.viewTracker.featuredEmojiPacks(),
availableReactions, availableReactions,
iconStatusEmoji iconStatusEmoji
@ -7165,7 +7174,8 @@ public final class EmojiPagerContentComponent: Component {
stickerOrderedItemListCollectionIds: [Int32], stickerOrderedItemListCollectionIds: [Int32],
chatPeerId: EnginePeer.Id?, chatPeerId: EnginePeer.Id?,
hasSearch: Bool, hasSearch: Bool,
hasTrending: Bool hasTrending: Bool,
forceHasPremium: Bool
) -> Signal<EmojiPagerContentComponent, NoError> { ) -> Signal<EmojiPagerContentComponent, NoError> {
let premiumConfiguration = PremiumConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 }) let premiumConfiguration = PremiumConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 })
let isPremiumDisabled = premiumConfiguration.isPremiumDisabled let isPremiumDisabled = premiumConfiguration.isPremiumDisabled
@ -7216,7 +7226,7 @@ public final class EmojiPagerContentComponent: Component {
return combineLatest( return combineLatest(
context.account.postbox.itemCollectionsView(orderedItemListCollectionIds: stickerOrderedItemListCollectionIds, namespaces: stickerNamespaces, aroundIndex: nil, count: 10000000), 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([]), hasTrending ? context.account.viewTracker.featuredStickerPacks() : .single([]),
context.engine.data.get(TelegramEngine.EngineData.Item.ItemCache.Item(collectionId: Namespaces.CachedItemCollection.featuredStickersConfiguration, id: ValueBoxKey(length: 0))), context.engine.data.get(TelegramEngine.EngineData.Item.ItemCache.Item(collectionId: Namespaces.CachedItemCollection.featuredStickersConfiguration, id: ValueBoxKey(length: 0))),
ApplicationSpecificNotice.dismissedTrendingStickerPacks(accountManager: context.sharedContext.accountManager), ApplicationSpecificNotice.dismissedTrendingStickerPacks(accountManager: context.sharedContext.accountManager),

View File

@ -968,7 +968,8 @@ private final class ForumCreateTopicScreenComponent: CombinedComponent {
customLayout: nil, customLayout: nil,
externalBackground: nil, externalBackground: nil,
externalExpansionView: nil, externalExpansionView: nil,
useOpaqueTheme: true useOpaqueTheme: true,
hideBackground: false
) )
} }
} }