Story collage improvements

This commit is contained in:
Ilya Laktyushin 2024-11-30 04:06:13 +04:00
parent 685ed2cc9e
commit 7dd7a6ba69
4 changed files with 31 additions and 11 deletions

View File

@ -13304,6 +13304,8 @@ Sorry for the inconvenience.";
"Chat.VideoProcessingInfo" = "The video will be published once converted and optimized.";
"Camera.CollageRetake" = "Retake";
"Camera.CollageDelete" = "Delete";
"Camera.CollageManagementTooltip" = "Tap a tile to delete or reorder it.";
"Camera.CollageReorderingInfo" = "Hold and drag tiles to reorder them.";

View File

@ -504,6 +504,10 @@ final class CameraCollageView: UIView, UIGestureRecognizerDelegate {
self.contextAction?(item.uniqueId, self.extractedContainerView, nil)
}
func stopPlayback() {
self.videoPlayer?.pause()
}
func resetPlayback() {
self.videoPlayer?.seek(to: .zero)
self.videoPlayer?.play()
@ -991,6 +995,12 @@ final class CameraCollageView: UIView, UIGestureRecognizerDelegate {
}
}
func stopPlayback() {
for (_, itemView) in self.itemViews {
itemView.stopPlayback()
}
}
func resetPlayback() {
for (_, itemView) in self.itemViews {
itemView.resetPlayback()
@ -1054,7 +1064,7 @@ final class CameraCollageView: UIView, UIGestureRecognizerDelegate {
var itemList: [ContextMenuItem] = []
if self.collage.cameraIndex == nil {
itemList.append(.action(ContextMenuActionItem(text: "Retake", icon: { theme in
itemList.append(.action(ContextMenuActionItem(text: presentationData.strings.Camera_CollageRetake, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Camera"), color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, f in
f(.default)
@ -1066,7 +1076,7 @@ final class CameraCollageView: UIView, UIGestureRecognizerDelegate {
if self.itemViews.count > 2 {
itemList.append(.separator)
itemList.append(.action(ContextMenuActionItem(text: "Delete", textColor: .destructive, icon: { theme in
itemList.append(.action(ContextMenuActionItem(text: presentationData.strings.Camera_CollageDelete, textColor: .destructive, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Delete"), color: theme.contextMenu.destructiveColor)
}, action: { [weak self] _, f in
f(.dismissWithoutContent)

View File

@ -2615,13 +2615,9 @@ public class CameraScreenImpl: ViewController, CameraScreen {
view.animateOutToEditor(transition: transition)
}
Queue.mainQueue().after(2.0, {
if self.cameraState.isCollageEnabled {
self.collage = nil
if let collageView = self.collageView {
collageView.removeFromSuperview()
self.collageView = nil
}
Queue.mainQueue().after(1.5, {
if let collageView = self.collageView {
collageView.stopPlayback()
}
})
}
@ -2679,6 +2675,10 @@ public class CameraScreenImpl: ViewController, CameraScreen {
if !toGallery {
self.resumeCameraCapture(fromGallery: false)
if let collageView = self.collageView {
collageView.resetPlayback()
}
self.cameraIsActive = true
self.requestUpdateLayout(transition: .immediate)

View File

@ -999,14 +999,22 @@ final class CaptureControlsComponent: Component {
func animateInFromEditor(transition: ComponentTransition) {
self.animatedOut = false
guard let component = self.component else {
return
}
if let view = self.galleryButtonView.view {
transition.setScale(view: view, scale: 1.0)
transition.setAlpha(view: view, alpha: 1.0)
if !component.hideControls {
transition.setAlpha(view: view, alpha: 1.0)
}
}
if let view = self.flipButtonView.view {
transition.setScale(view: view, scale: 1.0)
transition.setAlpha(view: view, alpha: 1.0)
if !component.hideControls {
transition.setAlpha(view: view, alpha: 1.0)
}
}
if let view = self.shutterButtonView.view {