Various fixes

This commit is contained in:
Ilya Laktyushin 2023-06-28 17:57:52 +02:00
parent 106ff49522
commit 1387bb5416
5 changed files with 99 additions and 71 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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<CameraScreen.Result, NoError> 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)
})

View File

@ -1227,7 +1227,8 @@ final class MediaEditorScreenComponent: Component {
transition.setAlpha(view: saveButtonView, alpha: displayTopButtons && !component.isDismissing && !component.isInteractingWithEntities ? saveButtonAlpha : 0.0)
}
if let playerState = state.playerState, playerState.hasAudio {
if let playerState = state.playerState {
if playerState.hasAudio {
let isVideoMuted = mediaEditor?.values.videoIsMuted ?? false
let muteContentComponent: AnyComponentWithIdentity<Empty>
@ -1300,6 +1301,17 @@ final class MediaEditorScreenComponent: Component {
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:

View File

@ -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)