mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
@@ -21,12 +21,12 @@ enum CallControllerButtonsSpeakerMode: Equatable {
|
||||
}
|
||||
|
||||
enum CallControllerButtonsMode: Equatable {
|
||||
enum VideoState: Equatable {
|
||||
case notAvailable
|
||||
case possible(isEnabled: Bool, isInitializing: Bool)
|
||||
case outgoingRequested(isInitializing: Bool)
|
||||
case incomingRequested(sendsVideo: Bool)
|
||||
case active
|
||||
struct VideoState: Equatable {
|
||||
var isAvailable: Bool
|
||||
var isCameraActive: Bool
|
||||
var canChangeStatus: Bool
|
||||
var hasVideo: Bool
|
||||
var isInitializingCamera: Bool
|
||||
}
|
||||
|
||||
case active(speakerMode: CallControllerButtonsSpeakerMode, hasAudioRouteMenu: Bool, videoState: VideoState)
|
||||
@@ -96,7 +96,6 @@ final class CallControllerButtonsNode: ASDisplayNode {
|
||||
private var validLayout: (CGFloat, CGFloat)?
|
||||
|
||||
var isMuted = false
|
||||
var isCameraPaused = false
|
||||
|
||||
var acceptOrEnd: (() -> Void)?
|
||||
var decline: (() -> Void)?
|
||||
@@ -189,16 +188,8 @@ final class CallControllerButtonsNode: ASDisplayNode {
|
||||
case .outgoingRinging:
|
||||
mappedState = .outgoingRinging
|
||||
case let .active(_, _, videoStateValue):
|
||||
switch videoStateValue {
|
||||
case let .incomingRequested(sendsVideo):
|
||||
mappedState = .active
|
||||
videoState = .incomingRequested(sendsVideo: sendsVideo)
|
||||
case let .outgoingRequested(isInitializing):
|
||||
mappedState = .active
|
||||
videoState = .outgoingRequested(isInitializing: isInitializing)
|
||||
case .active, .possible, .notAvailable:
|
||||
mappedState = .active
|
||||
}
|
||||
mappedState = .active
|
||||
videoState = videoStateValue
|
||||
}
|
||||
|
||||
var buttons: [PlacedButton] = []
|
||||
@@ -226,22 +217,21 @@ final class CallControllerButtonsNode: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
|
||||
switch videoState {
|
||||
case .active, .possible, .incomingRequested, .outgoingRequested:
|
||||
if videoState.isAvailable {
|
||||
let isCameraActive: Bool
|
||||
let isCameraEnabled: Bool
|
||||
let isCameraInitializing: Bool
|
||||
if case let .possible(value, isInitializing) = videoState {
|
||||
isCameraActive = false
|
||||
isCameraEnabled = value
|
||||
isCameraInitializing = isInitializing
|
||||
if videoState.hasVideo {
|
||||
isCameraActive = videoState.isCameraActive
|
||||
isCameraEnabled = videoState.canChangeStatus
|
||||
isCameraInitializing = videoState.isInitializingCamera
|
||||
} else {
|
||||
isCameraActive = !self.isCameraPaused
|
||||
isCameraEnabled = true
|
||||
isCameraInitializing = false
|
||||
isCameraActive = false
|
||||
isCameraEnabled = videoState.canChangeStatus
|
||||
isCameraInitializing = videoState.isInitializingCamera
|
||||
}
|
||||
topButtons.append(.enableCamera(isCameraActive, false, isCameraInitializing))
|
||||
if case .possible = videoState {
|
||||
if !videoState.hasVideo {
|
||||
topButtons.append(.mute(self.isMuted))
|
||||
topButtons.append(.soundOutput(soundOutput))
|
||||
} else {
|
||||
@@ -252,7 +242,7 @@ final class CallControllerButtonsNode: ASDisplayNode {
|
||||
}
|
||||
topButtons.append(.switchCamera(isCameraActive && !isCameraInitializing))
|
||||
}
|
||||
case .notAvailable:
|
||||
} else {
|
||||
topButtons.append(.mute(self.isMuted))
|
||||
topButtons.append(.soundOutput(soundOutput))
|
||||
}
|
||||
@@ -286,23 +276,18 @@ final class CallControllerButtonsNode: ASDisplayNode {
|
||||
|
||||
height = largeButtonSize + topBottomSpacing + largeButtonSize + max(bottomInset + 32.0, 46.0)
|
||||
case .active:
|
||||
switch videoState {
|
||||
case .active, .incomingRequested, .outgoingRequested:
|
||||
if videoState.hasVideo {
|
||||
let isCameraActive: Bool
|
||||
let isCameraEnabled: Bool
|
||||
var isCameraInitializing: Bool
|
||||
if case .incomingRequested = videoState {
|
||||
isCameraActive = false
|
||||
isCameraEnabled = true
|
||||
isCameraInitializing = false
|
||||
} else if case let .possible(value, isInitializing) = videoState {
|
||||
isCameraActive = false
|
||||
isCameraEnabled = value
|
||||
isCameraInitializing = isInitializing
|
||||
let isCameraInitializing: Bool
|
||||
if videoState.hasVideo {
|
||||
isCameraActive = videoState.isCameraActive
|
||||
isCameraEnabled = videoState.canChangeStatus
|
||||
isCameraInitializing = videoState.isInitializingCamera
|
||||
} else {
|
||||
isCameraActive = !self.isCameraPaused
|
||||
isCameraEnabled = true
|
||||
isCameraInitializing = false
|
||||
isCameraActive = false
|
||||
isCameraEnabled = videoState.canChangeStatus
|
||||
isCameraInitializing = videoState.isInitializingCamera
|
||||
}
|
||||
|
||||
var topButtons: [ButtonDescription] = []
|
||||
@@ -326,10 +311,6 @@ final class CallControllerButtonsNode: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
|
||||
if case let .outgoingRequested(isInitializing) = videoState {
|
||||
isCameraInitializing = isInitializing
|
||||
}
|
||||
|
||||
topButtons.append(.enableCamera(isCameraActive, isCameraEnabled, isCameraInitializing))
|
||||
if hasAudioRouteMenu {
|
||||
topButtons.append(.soundOutput(soundOutput))
|
||||
@@ -350,21 +331,21 @@ final class CallControllerButtonsNode: ASDisplayNode {
|
||||
}
|
||||
|
||||
height = smallButtonSize + max(bottomInset + 19.0, 46.0)
|
||||
case .notAvailable, .possible:
|
||||
} else {
|
||||
var topButtons: [ButtonDescription] = []
|
||||
var bottomButtons: [ButtonDescription] = []
|
||||
|
||||
let isCameraActive: Bool
|
||||
let isCameraEnabled: Bool
|
||||
var isCameraInitializing: Bool
|
||||
if case let .possible(value, isInitializing) = videoState {
|
||||
isCameraActive = false
|
||||
isCameraEnabled = value
|
||||
isCameraInitializing = isInitializing
|
||||
let isCameraInitializing: Bool
|
||||
if videoState.hasVideo {
|
||||
isCameraActive = videoState.isCameraActive
|
||||
isCameraEnabled = videoState.canChangeStatus
|
||||
isCameraInitializing = videoState.isInitializingCamera
|
||||
} else {
|
||||
isCameraActive = false
|
||||
isCameraEnabled = true
|
||||
isCameraInitializing = false
|
||||
isCameraEnabled = videoState.canChangeStatus
|
||||
isCameraInitializing = videoState.isInitializingCamera
|
||||
}
|
||||
|
||||
let soundOutput: ButtonDescription.SoundOutput
|
||||
|
||||
Reference in New Issue
Block a user