diff --git a/submodules/DrawingUI/Sources/DrawingEntitiesView.swift b/submodules/DrawingUI/Sources/DrawingEntitiesView.swift index 8207fec372..f8c87ae3da 100644 --- a/submodules/DrawingUI/Sources/DrawingEntitiesView.swift +++ b/submodules/DrawingUI/Sources/DrawingEntitiesView.swift @@ -60,7 +60,7 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView { private let context: AccountContext private let size: CGSize private let hasBin: Bool - private let isStickerEditor: Bool + public let isStickerEditor: Bool weak var drawingView: DrawingView? public weak var selectionContainerView: DrawingSelectionContainerView? diff --git a/submodules/DrawingUI/Sources/DrawingEntitySnapTool.swift b/submodules/DrawingUI/Sources/DrawingEntitySnapTool.swift index 7a5e065ac1..050c688530 100644 --- a/submodules/DrawingUI/Sources/DrawingEntitySnapTool.swift +++ b/submodules/DrawingUI/Sources/DrawingEntitySnapTool.swift @@ -98,6 +98,7 @@ class DrawingEntitySnapTool { guard let snapCenterLocation = (entityView.superview as? DrawingEntitiesView)?.getEntityCenterPosition() else { return updatedPosition } + let isStickerEditor = (entityView.superview as? DrawingEntitiesView)?.isStickerEditor ?? false let snapEdgeLocations = (entityView.superview as? DrawingEntitiesView)?.getEntityEdgePositions() let currentTimestamp = CACurrentMediaTime() @@ -202,7 +203,7 @@ class DrawingEntitySnapTool { self.yState = updatedYState self.previousYSnapTimestamp = updatedYPreviousTimestamp - if let snapEdgeLocations { + if let snapEdgeLocations, !isStickerEditor { if updatedXState == nil { let (updatedXLeftEdgeValue, updatedLeftEdgeState, updatedLeftEdgePreviousTimestamp) = process( state: self.leftEdgeState, diff --git a/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift b/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift index 6c343f3a31..fe07fa0fc0 100644 --- a/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift +++ b/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift @@ -1676,16 +1676,11 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { } else if collection == nil { self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Cancel, style: .plain, target: self, action: #selector(self.cancelPressed)) - if [.story, .createSticker].contains(mode) { + if [.createSticker].contains(mode) { self.navigationItem.rightBarButtonItem = UIBarButtonItem(customDisplayNode: self.moreButtonNode) self.navigationItem.rightBarButtonItem?.action = #selector(self.rightButtonPressed) self.navigationItem.rightBarButtonItem?.target = self } -// if mode == .story || mode == .addImage { -// self.navigationItem.rightBarButtonItem = UIBarButtonItem(customDisplayNode: self.moreButtonNode) -// self.navigationItem.rightBarButtonItem?.action = #selector(self.rightButtonPressed) -// self.navigationItem.rightBarButtonItem?.target = self -// } } else { self.navigationItem.leftBarButtonItem = UIBarButtonItem(backButtonAppearanceWithTitle: self.presentationData.strings.Common_Back, target: self, action: #selector(self.backPressed)) } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ImportStickers.swift b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ImportStickers.swift index 307914d26f..183e1be0f9 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ImportStickers.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ImportStickers.swift @@ -250,8 +250,12 @@ func _internal_renameStickerSet(account: Account, packReference: StickerPackRefe return .complete() } return account.postbox.transaction { transaction -> Void in - transaction.replaceItemCollectionInfos(namespace: Namespaces.ItemCollection.CloudStickerPacks, itemCollectionInfos: [(info.id, info)]) - + let collectionNamespace = Namespaces.ItemCollection.CloudStickerPacks + var currentInfos = transaction.getItemCollectionsInfos(namespace: collectionNamespace).map { $0.1 as! StickerPackCollectionInfo } + if let index = currentInfos.firstIndex(where: { $0.id == info.id }) { + currentInfos[index] = info + } + transaction.replaceItemCollectionInfos(namespace: collectionNamespace, itemCollectionInfos: currentInfos.map { ($0.id, $0) }) cacheStickerPack(transaction: transaction, info: info, items: items) } |> castError(RenameStickerSetError.self) diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/StickerCutoutOutlineView.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/StickerCutoutOutlineView.swift index b0973cb1f9..e561d496b3 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/StickerCutoutOutlineView.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/StickerCutoutOutlineView.swift @@ -151,7 +151,7 @@ private func getPathFromMaskImage(_ image: CIImage, size: CGSize, values: MediaE var contour = findContours(pixelBuffer: pixelBuffer) contour = simplify(contour, tolerance: 1.4) - let path = UIBezierPath(points: contour, close: true) + let path = UIBezierPath(points: contour, smooth: false) let firstScale = min(size.width, size.height) / 256.0 let secondScale = size.width / 1080.0 @@ -480,28 +480,38 @@ fileprivate extension Array { return (index + self.count) % self.count } } -extension UIBezierPath { - convenience init(points: [CGPoint], close: Bool) { + +private extension UIBezierPath { + convenience init(points: [CGPoint], smooth: Bool) { self.init() - let K: CGFloat = 0.2 - var c1 = [Int: CGPoint]() - var c2 = [Int: CGPoint]() - let count = close ? points.count + 1 : points.count - 1 - for index in 1 ..< count { - let p = points[circularIndex: index] - let vP1 = points[circularIndex: index + 1] - let vP2 = points[index - 1] - let vP = CGPoint(x: vP1.x - vP2.x, y: vP1.y - vP2.y) - let v = CGPoint(x: vP.x * K, y: vP.y * K) - c2[(index + points.count - 1) % points.count] = CGPoint(x: p.x - v.x, y: p.y - v.y) //(p - v) - c1[(index + points.count) % points.count] = CGPoint(x: p.x + v.x, y: p.y + v.y) //(p + v) + + if smooth { + let K: CGFloat = 0.2 + var c1 = [Int: CGPoint]() + var c2 = [Int: CGPoint]() + let count = points.count - 1 + for index in 1 ..< count { + let p = points[circularIndex: index] + let vP1 = points[circularIndex: index + 1] + let vP2 = points[index - 1] + let vP = CGPoint(x: vP1.x - vP2.x, y: vP1.y - vP2.y) + let v = CGPoint(x: vP.x * K, y: vP.y * K) + c2[(index + points.count - 1) % points.count] = CGPoint(x: p.x - v.x, y: p.y - v.y) //(p - v) + c1[(index + points.count) % points.count] = CGPoint(x: p.x + v.x, y: p.y + v.y) //(p + v) + } + self.move(to: points[0]) + for index in 0 ..< points.count - 1 { + let c1 = c1[index] ?? points[points.circularIndex(index)] + let c2 = c2[index] ?? points[points.circularIndex(index + 1)] + self.addCurve(to: points[circularIndex: index + 1], controlPoint1: c1, controlPoint2: c2) + } + self.close() + } else { + self.move(to: points[0]) + for index in 1 ..< points.count - 1 { + self.addLine(to: points[index]) + } + self.close() } - self.move(to: points[0]) - for index in 0 ..< points.count - 1 { - let c1 = c1[index] ?? points[points.circularIndex(index)] - let c2 = c2[index] ?? points[points.circularIndex(index + 1)] - self.addCurve(to: points[circularIndex: index + 1], controlPoint1: c1, controlPoint2: c2) - } - self.close() } } diff --git a/submodules/TelegramUI/Components/Settings/BirthdayPickerScreen/Sources/BirthdayPickerComponent.swift b/submodules/TelegramUI/Components/Settings/BirthdayPickerScreen/Sources/BirthdayPickerComponent.swift index 231accf4f2..527dbd8f57 100644 --- a/submodules/TelegramUI/Components/Settings/BirthdayPickerScreen/Sources/BirthdayPickerComponent.swift +++ b/submodules/TelegramUI/Components/Settings/BirthdayPickerScreen/Sources/BirthdayPickerComponent.swift @@ -61,7 +61,7 @@ public final class BirthdayPickerComponent: Component { private let calendar = Calendar(identifier: .gregorian) private var value = TelegramBirthday(day: 1, month: 1, year: nil) - private let minYear: Int32 = 1900 + private var minYear: Int32 = 1900 private let maxYear: Int32 override init(frame: CGRect) { @@ -84,6 +84,10 @@ public final class BirthdayPickerComponent: Component { self.component = component self.componentState = state + if let year = component.value.year, year < self.minYear { + self.minYear = year + } + self.pickerView.frame = CGRect(origin: .zero, size: availableSize) if isFirstTime || self.value != component.value {