Camera and editor improvements

This commit is contained in:
Ilya Laktyushin 2023-05-28 05:45:12 +04:00
parent 0ef81e2928
commit 69676bae7c
6 changed files with 32 additions and 6 deletions

View File

@ -792,7 +792,7 @@ public struct StoryCameraTransitionInCoordinator {
public protocol TelegramRootControllerInterface: NavigationController {
@discardableResult
func openStoryCamera(transitionIn: StoryCameraTransitionIn?, transitionOut: @escaping (Bool) -> StoryCameraTransitionOut?) -> StoryCameraTransitionInCoordinator?
func openStoryCamera(transitionIn: StoryCameraTransitionIn?, transitionedIn: @escaping () -> Void, transitionOut: @escaping (Bool) -> StoryCameraTransitionOut?) -> StoryCameraTransitionInCoordinator?
}
public protocol SharedAccountContext: AnyObject {

View File

@ -2523,7 +2523,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
}
if let peer, peer.id == self.context.account.peerId, storyContentState.slice == nil {
if let rootController = self.context.sharedContext.mainWindow?.viewController as? TelegramRootControllerInterface {
let coordinator = rootController.openStoryCamera(transitionIn: nil, transitionOut: { [weak self] finished in
let coordinator = rootController.openStoryCamera(transitionIn: nil, transitionedIn: {}, transitionOut: { [weak self] finished in
guard let self else {
return nil
}
@ -4951,7 +4951,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
if let current = self.storyCameraTransitionInCoordinator {
coordinator = current
} else {
coordinator = rootController.openStoryCamera(transitionIn: nil, transitionOut: { [weak self] finished in
coordinator = rootController.openStoryCamera(transitionIn: nil, transitionedIn: {}, transitionOut: { [weak self] finished in
guard let self else {
return nil
}

View File

@ -1228,7 +1228,8 @@ public class CameraScreen: ViewController {
}
}
fileprivate let completion: (Signal<CameraScreen.Result, NoError>, ResultTransition?) -> Void
public var transitionedIn: () -> Void = {}
private var audioSessionDisposable: Disposable?
public init(
@ -1393,6 +1394,7 @@ public class CameraScreen: ViewController {
if let self, let navigationController = self.navigationController as? NavigationController {
navigationController.updateRootContainerTransitionOffset(0.0, transition: .immediate)
self.node.requestUpdateLayout(hasAppeared: true, transition: .immediate)
self.transitionedIn()
}
})
} else {

View File

@ -1241,6 +1241,7 @@ public final class MediaEditorScreen: ViewController {
if self.entitiesView.hasSelection {
self.entitiesView.selectEntity(nil)
}
self.view.endEditing(true)
}
func animateIn() {
@ -1485,7 +1486,6 @@ public final class MediaEditorScreen: ViewController {
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
let result = super.hitTest(point, with: event)
if result == self.componentHost.view {
self.controller?.view.endEditing(true)
let point = self.view.convert(point, to: self.previewContainerView)
return self.previewContainerView.hitTest(point, with: event)
}

View File

@ -223,6 +223,20 @@ public final class MessageInputActionButtonComponent: Component {
if self.sendIconView.image == nil || previousComponent?.mode.iconName != component.mode.iconName {
if let iconName = component.mode.iconName {
self.sendIconView.image = generateTintedImage(image: UIImage(bundleImageName: iconName), color: .white)
} else if case .apply = component.mode {
self.sendIconView.image = generateImage(CGSize(width: 33.0, height: 33.0), contextGenerator: { size, context in
context.clear(CGRect(origin: CGPoint(), size: size))
context.setFillColor(UIColor.white.cgColor)
context.fillEllipse(in: CGRect(origin: CGPoint(), size: size))
if let image = UIImage(bundleImageName: "Media Editor/Apply"), let cgImage = image.cgImage {
context.setBlendMode(.clear)
context.clip(to: CGRect(origin: CGPoint(x: -4.0 + UIScreenPixel, y: -3.0 - UIScreenPixel), size: CGSize(width: 40.0, height: 40.0)), mask: cgImage)
context.fill(CGRect(origin: .zero, size: size))
}
})
} else if case .none = component.mode {
self.sendIconView.image = nil
} else {
self.sendIconView.image = generateImage(CGSize(width: 33.0, height: 33.0), rotatedContext: { size, context in
context.clear(CGRect(origin: CGPoint(), size: size))

View File

@ -199,6 +199,14 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
}
let coordinator = self.openStoryCamera(
transitionIn: nil,
transitionedIn: { [weak self] in
guard let self, let rootTabController = self.rootTabController else {
return
}
if let index = rootTabController.controllers.firstIndex(where: { $0 is ChatListController}) {
rootTabController.selectedIndex = index
}
},
transitionOut: { [weak self] finished in
guard let self else {
return nil
@ -275,7 +283,7 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
}
@discardableResult
public func openStoryCamera(transitionIn: StoryCameraTransitionIn?, transitionOut: @escaping (Bool) -> StoryCameraTransitionOut?) -> StoryCameraTransitionInCoordinator? {
public func openStoryCamera(transitionIn: StoryCameraTransitionIn?, transitionedIn: @escaping () -> Void, transitionOut: @escaping (Bool) -> StoryCameraTransitionOut?) -> StoryCameraTransitionInCoordinator? {
guard let controller = self.viewControllers.last as? ViewController else {
return nil
}
@ -370,6 +378,7 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
}
if let chatListController = self.chatListController as? ChatListControllerImpl {
chatListController.scrollToTop?()
switch mediaResult {
case let .image(image, dimensions, caption):
if let imageData = compressImageToJPEG(image, quality: 0.6) {
@ -482,6 +491,7 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
presentImpl?(controller)
}
)
cameraController.transitionedIn = transitionedIn
controller.push(cameraController)
presentImpl = { [weak cameraController] c in
if let navigationController = cameraController?.navigationController as? NavigationController {