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
d4e0dd8ef9
commit
75dbdec6f6
@ -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?
|
||||
|
@ -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,
|
||||
|
@ -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))
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user