From 8f30bf0fb5748d42aa0c44e1b2699f16bec762d0 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sat, 24 Dec 2022 14:34:08 +0400 Subject: [PATCH] Various fixes --- .../DrawingUI/Sources/DrawingTextEntity.swift | 2 +- submodules/DrawingUI/Sources/DrawingView.swift | 2 +- submodules/DrawingUI/Sources/PenTool.swift | 17 +++++------------ .../Sources/PeerInfo/PeerInfoScreen.swift | 6 +++--- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/submodules/DrawingUI/Sources/DrawingTextEntity.swift b/submodules/DrawingUI/Sources/DrawingTextEntity.swift index c803f803c4..689e065690 100644 --- a/submodules/DrawingUI/Sources/DrawingTextEntity.swift +++ b/submodules/DrawingUI/Sources/DrawingTextEntity.swift @@ -258,7 +258,7 @@ final class DrawingTextEntityView: DrawingEntityView, UITextViewDelegate { self.textView.minimumZoomScale = 1.0 self.textView.maximumZoomScale = 1.0 self.textView.keyboardAppearance = .dark - self.textView.autocorrectionType = .default + self.textView.autocorrectionType = .no self.textView.spellCheckingType = .no super.init(context: context, entity: entity) diff --git a/submodules/DrawingUI/Sources/DrawingView.swift b/submodules/DrawingUI/Sources/DrawingView.swift index e2411dbaa9..f448bdb95e 100644 --- a/submodules/DrawingUI/Sources/DrawingView.swift +++ b/submodules/DrawingUI/Sources/DrawingView.swift @@ -996,7 +996,7 @@ private class DrawingSlice { self.rect = rect self.path = NSTemporaryDirectory() + "/drawing_\(uuid.hashValue).slice" - DrawingSlice.queue.async { + DrawingSlice.queue.after(2.0) { let image = UIImage(cgImage: image) if let data = image.pngData() as? NSData { try? data.write(toFile: self.path) diff --git a/submodules/DrawingUI/Sources/PenTool.swift b/submodules/DrawingUI/Sources/PenTool.swift index 998ca5c89d..6a0f4791e3 100644 --- a/submodules/DrawingUI/Sources/PenTool.swift +++ b/submodules/DrawingUI/Sources/PenTool.swift @@ -198,7 +198,7 @@ final class PenTool: DrawingElement { let minRenderArrowLength = max(10.0, max(drawingSize.width, drawingSize.height) * 0.02) self.renderLineWidth = lineWidth - self.renderMinLineWidth = isEraser || isBlur ? lineWidth : minLineWidth + (lineWidth - minLineWidth) * 0.3 + self.renderMinLineWidth = isEraser || isBlur ? lineWidth : minLineWidth + (lineWidth - minLineWidth) * 0.2 self.renderArrowLength = max(minRenderArrowLength, lineWidth * 3.0) self.renderArrowLineWidth = max(minLineWidth * 1.8, lineWidth * 0.75) @@ -234,14 +234,8 @@ final class PenTool: DrawingElement { guard case let .point(point) = path else { return } - - let filterDistance: CGFloat - if point.velocity > 1200.0 { - filterDistance = 25.0 - } else { - filterDistance = 15.0 - } - + + let filterDistance: CGFloat = 20.0 if let previousPoint, point.location.distance(to: previousPoint) < filterDistance, state == .changed, self.segments.count > 1 { return } @@ -252,14 +246,13 @@ final class PenTool: DrawingElement { velocity = 1000.0 } - var effectiveRenderLineWidth = max(self.renderMinLineWidth, min(self.renderLineWidth - (velocity / 150.0), self.renderLineWidth)) + var effectiveRenderLineWidth = max(self.renderMinLineWidth, min(self.renderLineWidth - (velocity / 100.0), self.renderLineWidth)) if let previousRenderLineWidth = self.previousRenderLineWidth { effectiveRenderLineWidth = effectiveRenderLineWidth * 0.2 + previousRenderLineWidth * 0.8 } self.previousRenderLineWidth = effectiveRenderLineWidth let rect = append(point: Point(position: point.location, width: effectiveRenderLineWidth)) - if let currentRenderView = self.currentRenderView as? RenderView, let rect = rect { currentRenderView.draw(element: self, rect: rect) } @@ -461,7 +454,7 @@ final class PenTool: DrawingElement { let segmentDistance: CGFloat = 6.0 let distance = midPoint1.distance(to: midPoint2) - let numberOfSegments = min(128, max(floor(distance / segmentDistance), 32)) + let numberOfSegments = min(48, max(floor(distance / segmentDistance), 24)) let step = 1.0 / numberOfSegments for t in stride(from: 0, to: 1, by: step) { diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index 561a1f9ca4..5fcc48a636 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -1379,7 +1379,7 @@ private func editingItems(data: PeerInfoScreenData?, state: PeerInfoState, chatL })) let setText: String - if user.photo.first?.isPersonal == true { + if user.photo.first?.isPersonal == true || state.updatingAvatar != nil { setText = presentationData.strings.UserInfo_ChangeCustomPhoto(compactName).string } else { setText = presentationData.strings.UserInfo_SetCustomPhoto(compactName).string @@ -3117,7 +3117,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate let firstName = strongSelf.headerNode.editingContentNode.editingTextForKey(.firstName) ?? "" let lastName = strongSelf.headerNode.editingContentNode.editingTextForKey(.lastName) ?? "" - if peer.firstName != firstName || peer.lastName != lastName { + if (peer.firstName ?? "") != firstName || (peer.lastName ?? "") != lastName { if firstName.isEmpty && lastName.isEmpty { if strongSelf.hapticFeedback == nil { strongSelf.hapticFeedback = HapticFeedback() @@ -7179,7 +7179,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate confirmationAction = nil } - let mixin = TGMediaAvatarMenuMixin(context: legacyController.context, parentController: emptyController, hasSearchButton: true, hasDeleteButton: hasDeleteButton, hasViewButton: false, personalPhoto: strongSelf.isSettings, isVideo: currentIsVideo, saveEditedPhotos: false, saveCapturedMedia: false, signup: false, forum: isForum, title: title, isSuggesting: mode == .suggest)! + let mixin = TGMediaAvatarMenuMixin(context: legacyController.context, parentController: emptyController, hasSearchButton: true, hasDeleteButton: hasDeleteButton, hasViewButton: false, personalPhoto: strongSelf.isSettings, isVideo: currentIsVideo, saveEditedPhotos: false, saveCapturedMedia: false, signup: false, forum: isForum, title: title, isSuggesting: [.custom, .suggest].contains(mode))! mixin.stickersContext = paintStickersContext let _ = strongSelf.currentAvatarMixin.swap(mixin) mixin.requestSearchController = { [weak self] assetsController in