Various fixes

This commit is contained in:
Ilya Laktyushin 2023-08-12 19:49:16 +02:00
parent d4408c2bb0
commit 40c2c1b620
14 changed files with 50 additions and 22 deletions

View File

@ -9847,6 +9847,8 @@ Sorry for the inconvenience.";
"Story.StealthMode.CooldownAction" = "Available in %@"; "Story.StealthMode.CooldownAction" = "Available in %@";
"Story.StealthMode.UpgradeAction" = "Unlock Stealth Mode"; "Story.StealthMode.UpgradeAction" = "Unlock Stealth Mode";
"Story.ViewLocation" = "View Location";
"Location.AddThisLocation" = "Add This Location"; "Location.AddThisLocation" = "Add This Location";
"Location.AddMyLocation" = "Add My Current Location"; "Location.AddMyLocation" = "Add My Current Location";
"Location.TypeCity" = "City"; "Location.TypeCity" = "City";

View File

@ -460,7 +460,7 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView {
} }
func duplicate(_ entity: DrawingEntity) -> DrawingEntity { func duplicate(_ entity: DrawingEntity) -> DrawingEntity {
let newEntity = entity.duplicate() let newEntity = entity.duplicate(copy: false)
self.prepareNewEntity(newEntity, setup: false, relativeTo: entity) self.prepareNewEntity(newEntity, setup: false, relativeTo: entity)
guard let view = makeEntityView(context: self.context, entity: newEntity) else { guard let view = makeEntityView(context: self.context, entity: newEntity) else {

View File

@ -210,7 +210,7 @@ public final class DrawingTextEntityView: DrawingEntityView, UITextViewDelegate
func beginEditing(accessoryView: UIView?) { func beginEditing(accessoryView: UIView?) {
self._isEditing = true self._isEditing = true
if !self.textEntity.text.string.isEmpty { if !self.textEntity.text.string.isEmpty {
let previousEntity = self.textEntity.duplicate() as? DrawingTextEntity let previousEntity = self.textEntity.duplicate(copy: false) as? DrawingTextEntity
previousEntity?.uuid = self.textEntity.uuid previousEntity?.uuid = self.textEntity.uuid
self.previousEntity = previousEntity self.previousEntity = previousEntity
} }

View File

@ -22,7 +22,7 @@ public final class DrawingBubbleEntity: DrawingEntity, Codable {
case stroke case stroke
} }
public let uuid: UUID public var uuid: UUID
public let isAnimated: Bool public let isAnimated: Bool
public var drawType: DrawType public var drawType: DrawType
@ -96,8 +96,11 @@ public final class DrawingBubbleEntity: DrawingEntity, Codable {
} }
} }
public func duplicate() -> DrawingEntity { public func duplicate(copy: Bool) -> DrawingEntity {
let newEntity = DrawingBubbleEntity(drawType: self.drawType, color: self.color, lineWidth: self.lineWidth) let newEntity = DrawingBubbleEntity(drawType: self.drawType, color: self.color, lineWidth: self.lineWidth)
if copy {
newEntity.uuid = self.uuid
}
newEntity.referenceDrawingSize = self.referenceDrawingSize newEntity.referenceDrawingSize = self.referenceDrawingSize
newEntity.position = self.position newEntity.position = self.position
newEntity.size = self.size newEntity.size = self.size

View File

@ -2,7 +2,7 @@ import Foundation
import UIKit import UIKit
public protocol DrawingEntity: AnyObject { public protocol DrawingEntity: AnyObject {
var uuid: UUID { get } var uuid: UUID { get set }
var isAnimated: Bool { get } var isAnimated: Bool { get }
var center: CGPoint { get } var center: CGPoint { get }
@ -13,7 +13,7 @@ public protocol DrawingEntity: AnyObject {
var scale: CGFloat { get set } var scale: CGFloat { get set }
func duplicate() -> DrawingEntity func duplicate(copy: Bool) -> DrawingEntity
var renderImage: UIImage? { get set } var renderImage: UIImage? { get set }
var renderSubEntities: [DrawingEntity]? { get set } var renderSubEntities: [DrawingEntity]? { get set }

View File

@ -161,8 +161,11 @@ public final class DrawingLocationEntity: DrawingEntity, Codable {
} }
} }
public func duplicate() -> DrawingEntity { public func duplicate(copy: Bool) -> DrawingEntity {
let newEntity = DrawingLocationEntity(title: self.title, style: self.style, location: self.location, icon: self.icon, queryId: self.queryId, resultId: self.resultId) let newEntity = DrawingLocationEntity(title: self.title, style: self.style, location: self.location, icon: self.icon, queryId: self.queryId, resultId: self.resultId)
if copy {
newEntity.uuid = self.uuid
}
newEntity.referenceDrawingSize = self.referenceDrawingSize newEntity.referenceDrawingSize = self.referenceDrawingSize
newEntity.position = self.position newEntity.position = self.position
newEntity.width = self.width newEntity.width = self.width

View File

@ -60,7 +60,7 @@ public final class DrawingMediaEntity: DrawingEntity, Codable {
case mirrored case mirrored
} }
public let uuid: UUID public var uuid: UUID
public let content: Content public let content: Content
public let size: CGSize public let size: CGSize
@ -157,7 +157,7 @@ public final class DrawingMediaEntity: DrawingEntity, Codable {
try container.encode(self.mirrored, forKey: .mirrored) try container.encode(self.mirrored, forKey: .mirrored)
} }
public func duplicate() -> DrawingEntity { public func duplicate(copy: Bool) -> DrawingEntity {
let newEntity = DrawingMediaEntity(content: self.content, size: self.size) let newEntity = DrawingMediaEntity(content: self.content, size: self.size)
newEntity.referenceDrawingSize = self.referenceDrawingSize newEntity.referenceDrawingSize = self.referenceDrawingSize
newEntity.position = self.position newEntity.position = self.position

View File

@ -28,7 +28,7 @@ public final class DrawingSimpleShapeEntity: DrawingEntity, Codable {
case stroke case stroke
} }
public let uuid: UUID public var uuid: UUID
public let isAnimated: Bool public let isAnimated: Bool
public var shapeType: ShapeType public var shapeType: ShapeType
@ -102,8 +102,11 @@ public final class DrawingSimpleShapeEntity: DrawingEntity, Codable {
} }
} }
public func duplicate() -> DrawingEntity { public func duplicate(copy: Bool) -> DrawingEntity {
let newEntity = DrawingSimpleShapeEntity(shapeType: self.shapeType, drawType: self.drawType, color: self.color, lineWidth: self.lineWidth) let newEntity = DrawingSimpleShapeEntity(shapeType: self.shapeType, drawType: self.drawType, color: self.color, lineWidth: self.lineWidth)
if copy {
newEntity.uuid = self.uuid
}
newEntity.referenceDrawingSize = self.referenceDrawingSize newEntity.referenceDrawingSize = self.referenceDrawingSize
newEntity.position = self.position newEntity.position = self.position
newEntity.size = self.size newEntity.size = self.size

View File

@ -69,7 +69,7 @@ public final class DrawingStickerEntity: DrawingEntity, Codable {
case isExplicitlyStatic case isExplicitlyStatic
} }
public let uuid: UUID public var uuid: UUID
public let content: Content public let content: Content
public var referenceDrawingSize: CGSize public var referenceDrawingSize: CGSize
@ -221,8 +221,11 @@ public final class DrawingStickerEntity: DrawingEntity, Codable {
try container.encode(self.isExplicitlyStatic, forKey: .isExplicitlyStatic) try container.encode(self.isExplicitlyStatic, forKey: .isExplicitlyStatic)
} }
public func duplicate() -> DrawingEntity { public func duplicate(copy: Bool) -> DrawingEntity {
let newEntity = DrawingStickerEntity(content: self.content) let newEntity = DrawingStickerEntity(content: self.content)
if copy {
newEntity.uuid = self.uuid
}
newEntity.referenceDrawingSize = self.referenceDrawingSize newEntity.referenceDrawingSize = self.referenceDrawingSize
newEntity.position = self.position newEntity.position = self.position
newEntity.scale = self.scale newEntity.scale = self.scale

View File

@ -247,8 +247,11 @@ public final class DrawingTextEntity: DrawingEntity, Codable {
} }
} }
public func duplicate() -> DrawingEntity { public func duplicate(copy: Bool) -> DrawingEntity {
let newEntity = DrawingTextEntity(text: self.text, style: self.style, animation: self.animation, font: self.font, alignment: self.alignment, fontSize: self.fontSize, color: self.color) let newEntity = DrawingTextEntity(text: self.text, style: self.style, animation: self.animation, font: self.font, alignment: self.alignment, fontSize: self.fontSize, color: self.color)
if copy {
newEntity.uuid = self.uuid
}
newEntity.referenceDrawingSize = self.referenceDrawingSize newEntity.referenceDrawingSize = self.referenceDrawingSize
newEntity.position = self.position newEntity.position = self.position
newEntity.width = self.width newEntity.width = self.width

View File

@ -23,7 +23,7 @@ public final class DrawingVectorEntity: DrawingEntity, Codable {
case twoSidedArrow case twoSidedArrow
} }
public let uuid: UUID public var uuid: UUID
public let isAnimated: Bool public let isAnimated: Bool
public var type: VectorType public var type: VectorType
@ -98,8 +98,11 @@ public final class DrawingVectorEntity: DrawingEntity, Codable {
} }
} }
public func duplicate() -> DrawingEntity { public func duplicate(copy: Bool) -> DrawingEntity {
let newEntity = DrawingVectorEntity(type: self.type, color: self.color, lineWidth: self.lineWidth) let newEntity = DrawingVectorEntity(type: self.type, color: self.color, lineWidth: self.lineWidth)
if copy {
newEntity.uuid = self.uuid
}
newEntity.drawingSize = self.drawingSize newEntity.drawingSize = self.drawingSize
newEntity.referenceDrawingSize = self.referenceDrawingSize newEntity.referenceDrawingSize = self.referenceDrawingSize
newEntity.start = self.start newEntity.start = self.start

View File

@ -1857,7 +1857,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
initialValues = draft.values initialValues = draft.values
for entity in draft.values.entities { for entity in draft.values.entities {
self.entitiesView.add(entity.entity, announce: false) self.entitiesView.add(entity.entity.duplicate(copy: true), announce: false)
} }
if let drawingData = initialValues?.drawing?.pngData() { if let drawingData = initialValues?.drawing?.pngData() {
@ -3974,6 +3974,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
var caption = self.getCaption() var caption = self.getCaption()
caption = convertMarkdownToAttributes(caption) caption = convertMarkdownToAttributes(caption)
var hasEntityChanges = false
let randomId: Int64 let randomId: Int64
if case let .draft(_, id) = subject, let id { if case let .draft(_, id) = subject, let id {
randomId = id randomId = id
@ -3982,7 +3983,10 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
} }
var mediaAreas: [MediaArea] = [] var mediaAreas: [MediaArea] = []
if case .draft = subject { if case let .draft(draft, _) = subject {
if draft.values.entities != codableEntities {
hasEntityChanges = true
}
} else { } else {
mediaAreas = self.initialMediaAreas ?? [] mediaAreas = self.initialMediaAreas ?? []
} }
@ -4010,7 +4014,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
} }
} }
if self.isEditingStory && !self.node.hasAnyChanges { if self.isEditingStory && !(self.node.hasAnyChanges || hasEntityChanges) {
self.completion(randomId, nil, [], caption, self.state.privacy, stickers, { [weak self] finished in self.completion(randomId, nil, [], caption, self.state.privacy, stickers, { [weak self] finished in
self?.node.animateOut(finished: true, saveDraft: false, completion: { [weak self] in self?.node.animateOut(finished: true, saveDraft: false, completion: { [weak self] in
self?.dismiss() self?.dismiss()

View File

@ -3233,7 +3233,7 @@ final class StoryItemSetContainerSendMessage {
let subject = EngineMessage(stableId: 0, stableVersion: 0, id: EngineMessage.Id(peerId: PeerId(0), namespace: 0, id: 0), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 0, flags: [], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: nil, text: "", attributes: [], media: [.geo(TelegramMediaMap(latitude: venue.latitude, longitude: venue.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: venue.venue, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil))], peers: [:], associatedMessages: [:], associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:]) let subject = EngineMessage(stableId: 0, stableVersion: 0, id: EngineMessage.Id(peerId: PeerId(0), namespace: 0, id: 0), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 0, flags: [], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: nil, text: "", attributes: [], media: [.geo(TelegramMediaMap(latitude: venue.latitude, longitude: venue.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: venue.venue, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil))], peers: [:], associatedMessages: [:], associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
let context = component.context let context = component.context
actions.append(ContextMenuAction(content: .textWithIcon(title: "View Location", icon: generateTintedImage(image: UIImage(bundleImageName: "Settings/TextArrowRight"), color: .white)), action: { [weak controller, weak view] in actions.append(ContextMenuAction(content: .textWithIcon(title: updatedPresentationData.initial.strings.Story_ViewLocation, icon: generateTintedImage(image: UIImage(bundleImageName: "Settings/TextArrowRight"), color: .white)), action: { [weak controller, weak view] in
let locationController = LocationViewController( let locationController = LocationViewController(
context: context, context: context,
updatedPresentationData: updatedPresentationData, updatedPresentationData: updatedPresentationData,

View File

@ -1075,7 +1075,11 @@ public class TranslateScreen: ViewController {
self.component = AnyComponent(component) self.component = AnyComponent(component)
self.theme = theme self.theme = theme
super.init(navigationBarPresentationData: NavigationBarPresentationData(presentationData: context.sharedContext.currentPresentationData.with { $0 })) var presentationData = context.sharedContext.currentPresentationData.with { $0 }
if let theme {
presentationData = presentationData.withUpdated(theme: theme)
}
super.init(navigationBarPresentationData: NavigationBarPresentationData(presentationData: presentationData))
} }
required public init(coder aDecoder: NSCoder) { required public init(coder aDecoder: NSCoder) {