diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index 9e2eaf2500..b08565aa11 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -2640,7 +2640,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController }))) let isMuted = notificationSettings.storiesMuted == true - items.append(.action(ContextMenuActionItem(text: isMuted ? "Notify" : "Not Notify", icon: { theme in + items.append(.action(ContextMenuActionItem(text: isMuted ? "Notify" : "Don't Notify", icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: isMuted ? "Chat/Context Menu/Unmute" : "Chat/Context Menu/Muted"), color: theme.contextMenu.primaryColor) }, action: { [weak self] _, f in f(.default) diff --git a/submodules/ContactListUI/Sources/ContactContextMenus.swift b/submodules/ContactListUI/Sources/ContactContextMenus.swift index f772241d12..314bd4a6fc 100644 --- a/submodules/ContactListUI/Sources/ContactContextMenus.swift +++ b/submodules/ContactListUI/Sources/ContactContextMenus.swift @@ -43,7 +43,7 @@ func contactContextMenuItems(context: AccountContext, peerId: EnginePeer.Id, con }))) let isMuted = notificationSettings.storiesMuted == true - items.append(.action(ContextMenuActionItem(text: isMuted ? "Notify" : "Not Notify", icon: { theme in + items.append(.action(ContextMenuActionItem(text: isMuted ? "Notify" : "Don't Notify", icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: isMuted ? "Chat/Context Menu/Unmute" : "Chat/Context Menu/Muted"), color: theme.contextMenu.primaryColor) }, action: { _, f in f(.default) diff --git a/submodules/TelegramUI/Components/CameraScreen/Sources/CameraScreen.swift b/submodules/TelegramUI/Components/CameraScreen/Sources/CameraScreen.swift index 02ccf65af7..953eda0d54 100644 --- a/submodules/TelegramUI/Components/CameraScreen/Sources/CameraScreen.swift +++ b/submodules/TelegramUI/Components/CameraScreen/Sources/CameraScreen.swift @@ -374,7 +374,12 @@ private final class CameraScreenComponent: CombinedComponent { self.updated(transition: .easeInOut(duration: 0.2)) } + private var isTakingPhoto = false func takePhoto() { + guard !self.isTakingPhoto else { + return + } + self.isTakingPhoto = true let takePhoto = self.camera.takePhoto() |> mapToSignal { value -> Signal in switch value { @@ -387,9 +392,15 @@ private final class CameraScreenComponent: CombinedComponent { } } self.completion.invoke(takePhoto) + Queue.mainQueue().after(1.0) { + self.isTakingPhoto = false + } } func startVideoRecording(pressing: Bool) { + guard case .none = self.cameraState.recording else { + return + } self.cameraState = self.cameraState.updatedDuration(0.0).updatedRecording(pressing ? .holding : .handsFree) self.resultDisposable.set((self.camera.startRecording() |> deliverOnMainQueue).start(next: { [weak self] duration in @@ -413,7 +424,7 @@ private final class CameraScreenComponent: CombinedComponent { } })) self.isTransitioning = true - Queue.mainQueue().after(0.8, { + Queue.mainQueue().after(1.25, { self.isTransitioning = false self.updated(transition: .immediate) }) diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift index 7ec1fc10cc..a3778a3c91 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift @@ -1227,79 +1227,91 @@ final class MediaEditorScreenComponent: Component { transition.setAlpha(view: saveButtonView, alpha: displayTopButtons && !component.isDismissing && !component.isInteractingWithEntities ? saveButtonAlpha : 0.0) } - if let playerState = state.playerState, playerState.hasAudio { - let isVideoMuted = mediaEditor?.values.videoIsMuted ?? false - - let muteContentComponent: AnyComponentWithIdentity - if component.hasAppeared { - muteContentComponent = AnyComponentWithIdentity( - id: "animatedIcon", - component: AnyComponent( - LottieAnimationComponent( - animation: LottieAnimationComponent.AnimationItem( - name: "anim_storymute", - mode: state.muteDidChange ? .animating(loop: false) : .still(position: .begin), - range: isVideoMuted ? (0.0, 0.5) : (0.5, 1.0) - ), - colors: ["__allcolors__": .white], - size: CGSize(width: 30.0, height: 30.0) - ).tagged(muteButtonTag) - ) - ) - } else { - muteContentComponent = AnyComponentWithIdentity( - id: "staticIcon", - component: AnyComponent( - BundleIconComponent( - name: "Media Editor/MuteIcon", - tintColor: nil + if let playerState = state.playerState { + if playerState.hasAudio { + let isVideoMuted = mediaEditor?.values.videoIsMuted ?? false + + let muteContentComponent: AnyComponentWithIdentity + if component.hasAppeared { + muteContentComponent = AnyComponentWithIdentity( + id: "animatedIcon", + component: AnyComponent( + LottieAnimationComponent( + animation: LottieAnimationComponent.AnimationItem( + name: "anim_storymute", + mode: state.muteDidChange ? .animating(loop: false) : .still(position: .begin), + range: isVideoMuted ? (0.0, 0.5) : (0.5, 1.0) + ), + colors: ["__allcolors__": .white], + size: CGSize(width: 30.0, height: 30.0) + ).tagged(muteButtonTag) ) ) - ) - } - - let muteButtonSize = self.muteButton.update( - transition: transition, - component: AnyComponent(CameraButton( - content: muteContentComponent, - action: { [weak state, weak mediaEditor] in - if let mediaEditor { - state?.muteDidChange = true - let isMuted = !mediaEditor.values.videoIsMuted - mediaEditor.setVideoIsMuted(isMuted) - state?.updated() - - if let controller = environment.controller() as? MediaEditorScreen { - controller.node.presentMutedTooltip() + } else { + muteContentComponent = AnyComponentWithIdentity( + id: "staticIcon", + component: AnyComponent( + BundleIconComponent( + name: "Media Editor/MuteIcon", + tintColor: nil + ) + ) + ) + } + + let muteButtonSize = self.muteButton.update( + transition: transition, + component: AnyComponent(CameraButton( + content: muteContentComponent, + action: { [weak state, weak mediaEditor] in + if let mediaEditor { + state?.muteDidChange = true + let isMuted = !mediaEditor.values.videoIsMuted + mediaEditor.setVideoIsMuted(isMuted) + state?.updated() + + if let controller = environment.controller() as? MediaEditorScreen { + controller.node.presentMutedTooltip() + } } } + )), + environment: {}, + containerSize: CGSize(width: 44.0, height: 44.0) + ) + let muteButtonFrame = CGRect( + origin: CGPoint(x: availableSize.width - 20.0 - muteButtonSize.width - 50.0, y: max(environment.statusBarHeight + 10.0, environment.safeInsets.top + 20.0)), + size: muteButtonSize + ) + if let muteButtonView = self.muteButton.view { + if muteButtonView.superview == nil { + muteButtonView.layer.shadowOffset = CGSize(width: 0.0, height: 0.0) + muteButtonView.layer.shadowRadius = 2.0 + muteButtonView.layer.shadowColor = UIColor.black.cgColor + muteButtonView.layer.shadowOpacity = 0.35 + self.addSubview(muteButtonView) + + if self.animatingButtons { + muteButtonView.layer.animateAlpha(from: 0.0, to: muteButtonView.alpha, duration: 0.1) + muteButtonView.layer.animateScale(from: 0.4, to: 1.0, duration: 0.1) + } } - )), - environment: {}, - containerSize: CGSize(width: 44.0, height: 44.0) - ) - let muteButtonFrame = CGRect( - origin: CGPoint(x: availableSize.width - 20.0 - muteButtonSize.width - 50.0, y: max(environment.statusBarHeight + 10.0, environment.safeInsets.top + 20.0)), - size: muteButtonSize - ) - if let muteButtonView = self.muteButton.view { - if muteButtonView.superview == nil { - muteButtonView.layer.shadowOffset = CGSize(width: 0.0, height: 0.0) - muteButtonView.layer.shadowRadius = 2.0 - muteButtonView.layer.shadowColor = UIColor.black.cgColor - muteButtonView.layer.shadowOpacity = 0.35 - self.addSubview(muteButtonView) - - if self.animatingButtons { - muteButtonView.layer.animateAlpha(from: 0.0, to: muteButtonView.alpha, duration: 0.1) - muteButtonView.layer.animateScale(from: 0.4, to: 1.0, duration: 0.1) - } + transition.setPosition(view: muteButtonView, position: muteButtonFrame.center) + transition.setBounds(view: muteButtonView, bounds: CGRect(origin: .zero, size: muteButtonFrame.size)) + transition.setScale(view: muteButtonView, scale: displayTopButtons ? 1.0 : 0.01) + transition.setAlpha(view: muteButtonView, alpha: displayTopButtons && !component.isDismissing && !component.isInteractingWithEntities ? 1.0 : 0.0) } - transition.setPosition(view: muteButtonView, position: muteButtonFrame.center) - transition.setBounds(view: muteButtonView, bounds: CGRect(origin: .zero, size: muteButtonFrame.size)) - transition.setScale(view: muteButtonView, scale: displayTopButtons ? 1.0 : 0.01) - transition.setAlpha(view: muteButtonView, alpha: displayTopButtons && !component.isDismissing && !component.isInteractingWithEntities ? 1.0 : 0.0) + } else if let muteButtonView = self.muteButton.view, muteButtonView.superview != nil { + muteButtonView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak muteButtonView] _ in + muteButtonView?.removeFromSuperview() + }) + muteButtonView.layer.animateScale(from: 1.0, to: 0.01, duration: 0.2, removeOnCompletion: false) } + } else if let muteButtonView = self.muteButton.view, muteButtonView.superview != nil { + muteButtonView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak muteButtonView] _ in + muteButtonView?.removeFromSuperview() + }) + muteButtonView.layer.animateScale(from: 1.0, to: 0.01, duration: 0.2, removeOnCompletion: false) } let textCancelButtonSize = self.textCancelButton.update( @@ -1870,6 +1882,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate self.previewContainerView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25, completion: { _ in self.previewContainerView.layer.allowsGroupOpacity = false self.previewContainerView.alpha = 1.0 + self.backgroundDimView.isHidden = false }) } else { self.backgroundDimView.isHidden = false @@ -2946,6 +2959,10 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate } } + var isPhoto: Bool { + return !self.isVideo + } + var isVideo: Bool { switch self { case .image: diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift index 798d6c3f0e..cd910d9e67 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift @@ -2997,7 +2997,7 @@ public final class StoryItemSetContainerComponent: Component { items.append(.separator) - items.append(.action(ContextMenuActionItem(text: component.slice.item.storyItem.isPinned ? "Remove from profile" : "Save to profile", icon: { theme in + items.append(.action(ContextMenuActionItem(text: component.slice.item.storyItem.isPinned ? "Remove from Profile" : "Save to Profile", icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: component.slice.item.storyItem.isPinned ? "Chat/Context Menu/Check" : "Chat/Context Menu/Add"), color: theme.contextMenu.primaryColor) }, action: { [weak self] _, a in a(.default) @@ -3121,7 +3121,7 @@ public final class StoryItemSetContainerComponent: Component { var items: [ContextMenuItem] = [] let isMuted = settings.storiesMuted == true - items.append(.action(ContextMenuActionItem(text: isMuted ? "Notify" : "Not Notify", icon: { theme in + items.append(.action(ContextMenuActionItem(text: isMuted ? "Notify" : "Don't Notify", icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: component.slice.additionalPeerData.isMuted ? "Chat/Context Menu/Unmute" : "Chat/Context Menu/Muted"), color: theme.contextMenu.primaryColor) }, action: { [weak self] _, a in a(.default)