mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Camera and editor improvements
This commit is contained in:
parent
6dbd76bf7a
commit
f42de6eba9
@ -124,12 +124,21 @@ public final class CameraButton: Component {
|
||||
|
||||
func update(component: CameraButton, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
if let currentId = self.component?.content.id, currentId != component.content.id {
|
||||
self.contentView.removeFromSuperview()
|
||||
let previousContentView = self.contentView
|
||||
|
||||
self.contentView = ComponentHostView<Empty>()
|
||||
self.contentView.isUserInteractionEnabled = false
|
||||
self.contentView.layer.allowsGroupOpacity = true
|
||||
self.addSubview(self.contentView)
|
||||
|
||||
if transition.animation.isImmediate {
|
||||
previousContentView.removeFromSuperview()
|
||||
} else {
|
||||
self.addSubview(previousContentView)
|
||||
previousContentView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak previousContentView] _ in
|
||||
previousContentView?.removeFromSuperview()
|
||||
})
|
||||
}
|
||||
}
|
||||
let contentSize = self.contentView.update(
|
||||
transition: transition,
|
||||
|
@ -1923,8 +1923,11 @@ public class CameraScreen: ViewController {
|
||||
}
|
||||
}
|
||||
}, dismissed: { [weak self] in
|
||||
self?.node.hasGallery = false
|
||||
resumeCameraCapture()
|
||||
if let self {
|
||||
self.node.hasGallery = false
|
||||
self.node.requestUpdateLayout(hasAppeared: self.node.hasAppeared, transition: .immediate)
|
||||
}
|
||||
})
|
||||
self.galleryController = controller
|
||||
}
|
||||
|
@ -516,7 +516,9 @@ final class CaptureControlsComponent: Component {
|
||||
var lastGalleryAsset: PHAsset? {
|
||||
didSet {
|
||||
if self.cachedAssetImage?.0 != self.lastGalleryAsset?.localIdentifier {
|
||||
self.cachedAssetImage = nil
|
||||
if self.cachedAssetImage?.0 != "" {
|
||||
self.cachedAssetImage = nil
|
||||
}
|
||||
if let lastGalleryAsset = self.lastGalleryAsset {
|
||||
self.assetDisposable.set((fetchPhotoLibraryImage(localIdentifier: lastGalleryAsset.localIdentifier, thumbnail: true)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] imageAndDegraded in
|
||||
@ -890,12 +892,18 @@ final class CaptureControlsComponent: Component {
|
||||
gallerySize = CGSize(width: 50.0, height: 50.0)
|
||||
galleryCornerRadius = 10.0
|
||||
}
|
||||
let galleryButtonId: String
|
||||
if let (identifier, _) = state.cachedAssetImage, identifier == "" {
|
||||
galleryButtonId = "placeholder"
|
||||
} else {
|
||||
galleryButtonId = "gallery"
|
||||
}
|
||||
let galleryButtonSize = self.galleryButtonView.update(
|
||||
transition: .immediate,
|
||||
transition: transition,
|
||||
component: AnyComponent(
|
||||
CameraButton(
|
||||
content: AnyComponentWithIdentity(
|
||||
id: "gallery",
|
||||
id: galleryButtonId,
|
||||
component: AnyComponent(
|
||||
Image(
|
||||
image: state.cachedAssetImage?.1,
|
||||
|
Loading…
x
Reference in New Issue
Block a user