mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
[WIP] Stories
This commit is contained in:
41
submodules/Utils/VolumeButtons/Sources/VolumeButtons.swift
Normal file
41
submodules/Utils/VolumeButtons/Sources/VolumeButtons.swift
Normal file
@@ -0,0 +1,41 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import SwiftSignalKit
|
||||
import MediaPlayer
|
||||
|
||||
import LegacyComponents
|
||||
|
||||
public class VolumeButtonsListener: NSObject {
|
||||
private let handler: PGCameraVolumeButtonHandler
|
||||
|
||||
private var disposable: Disposable?
|
||||
|
||||
public init(shouldBeActive: Signal<Bool, NoError>, valueChanged: @escaping () -> Void) {
|
||||
var impl: (() -> Void)?
|
||||
|
||||
self.handler = PGCameraVolumeButtonHandler(upButtonPressedBlock: {
|
||||
impl?()
|
||||
}, upButtonReleasedBlock: {}, downButtonPressedBlock: {
|
||||
impl?()
|
||||
}, downButtonReleasedBlock: {})
|
||||
|
||||
super.init()
|
||||
|
||||
impl = {
|
||||
valueChanged()
|
||||
}
|
||||
|
||||
self.disposable = (shouldBeActive
|
||||
|> deliverOnMainQueue).start(next: { [weak self] value in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.handler.enabled = value
|
||||
})
|
||||
}
|
||||
|
||||
deinit {
|
||||
self.handler.enabled = false
|
||||
self.disposable?.dispose()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user