[WIP] Stories

This commit is contained in:
Ali
2023-04-28 23:34:33 +04:00
parent 7dd76ef329
commit d39cfca5a5
9 changed files with 205 additions and 47 deletions

View File

@@ -178,6 +178,7 @@ private final class ChatTextInputMediaRecordingButtonPresenter : NSObject, TGMod
public final class ChatTextInputMediaRecordingButton: TGModernConversationInputMicButton, TGModernConversationInputMicButtonDelegate {
private let context: AccountContext
private var theme: PresentationTheme
private let useDarkTheme: Bool
private let strings: PresentationStrings
public var mode: ChatTextInputMediaRecordingButtonMode = .audio
@@ -293,16 +294,17 @@ public final class ChatTextInputMediaRecordingButton: TGModernConversationInputM
if let current = self.micLockValue {
return current
} else {
let lockView = LockView(frame: CGRect(origin: CGPoint(), size: CGSize(width: 40.0, height: 60.0)), theme: self.theme, strings: self.strings)
let lockView = LockView(frame: CGRect(origin: CGPoint(), size: CGSize(width: 40.0, height: 60.0)), theme: self.theme, useDarkTheme: self.useDarkTheme, strings: self.strings)
lockView.addTarget(self, action: #selector(handleStopTap), for: .touchUpInside)
self.micLockValue = lockView
return lockView
}
}
public init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, presentController: @escaping (ViewController) -> Void) {
public init(context: AccountContext, theme: PresentationTheme, useDarkTheme: Bool = false, strings: PresentationStrings, presentController: @escaping (ViewController) -> Void) {
self.context = context
self.theme = theme
self.useDarkTheme = useDarkTheme
self.strings = strings
self.animationView = ComponentView<Empty>()
self.presentController = presentController
@@ -382,7 +384,7 @@ public final class ChatTextInputMediaRecordingButton: TGModernConversationInputM
transition: .immediate,
component: AnyComponent(LottieComponent(
content: LottieComponent.AppBundleContent(name: animationName),
color: self.theme.chat.inputPanel.panelControlColor.blitOver(self.theme.chat.inputPanel.inputBackgroundColor, alpha: 1.0)
color: self.useDarkTheme ? .white : self.theme.chat.inputPanel.panelControlColor.blitOver(self.theme.chat.inputPanel.inputBackgroundColor, alpha: 1.0)
)),
environment: {},
containerSize: animationFrame.size
@@ -407,7 +409,7 @@ public final class ChatTextInputMediaRecordingButton: TGModernConversationInputM
self.updateAnimation(previousMode: self.mode)
self.pallete = legacyInputMicPalette(from: theme)
self.micDecorationValue?.setColor(self.theme.chat.inputPanel.actionControlFillColor)
self.micDecorationValue?.setColor( self.theme.chat.inputPanel.actionControlFillColor)
(self.micLockValue as? LockView)?.updateTheme(theme)
}

View File

@@ -5,7 +5,7 @@ import Lottie
import TelegramPresentationData
final class LockView: UIButton, TGModernConversationInputMicButtonLock {
//private var colorCallbacks = [LOTValueDelegate]()
private let useDarkTheme: Bool
private let idleView: AnimationView = {
guard let url = getAppBundle().url(forResource: "LockWait", withExtension: "json"), let animation = Animation.filepath(url.path)
@@ -28,7 +28,9 @@ final class LockView: UIButton, TGModernConversationInputMicButtonLock {
return view
}()
init(frame: CGRect, theme: PresentationTheme, strings: PresentationStrings) {
init(frame: CGRect, theme: PresentationTheme, useDarkTheme: Bool = false, strings: PresentationStrings) {
self.useDarkTheme = useDarkTheme
super.init(frame: frame)
accessibilityLabel = strings.VoiceOver_Recording_StopAndPreview
@@ -60,8 +62,6 @@ final class LockView: UIButton, TGModernConversationInputMicButtonLock {
}
func updateTheme(_ theme: PresentationTheme) {
//colorCallbacks.removeAll()
[
"Rectangle.Заливка 1": theme.chat.inputPanel.panelBackgroundColor,
"Rectangle.Rectangle.Обводка 1": theme.chat.inputPanel.panelControlAccentColor,
@@ -69,9 +69,6 @@ final class LockView: UIButton, TGModernConversationInputMicButtonLock {
"Path 4.Path 4.Обводка 1": theme.chat.inputPanel.panelControlAccentColor
].forEach { key, value in
idleView.setValueProvider(ColorValueProvider(value.lottieColorValue), keypath: AnimationKeypath(keypath: "\(key).Color"))
/*let colorCallback = LOTColorValueCallback(color: value.cgColor)
self.colorCallbacks.append(colorCallback)
idleView.setValueDelegate(colorCallback, for: LOTKeypath(string: "\(key).Color"))*/
}
[
@@ -82,9 +79,6 @@ final class LockView: UIButton, TGModernConversationInputMicButtonLock {
"Path 4.Path 4.Обводка 1": theme.chat.inputPanel.panelControlAccentColor
].forEach { key, value in
lockingView.setValueProvider(ColorValueProvider(value.lottieColorValue), keypath: AnimationKeypath(keypath: "\(key).Color"))
/*let colorCallback = LOTColorValueCallback(color: value.cgColor)
self.colorCallbacks.append(colorCallback)
lockingView.setValueDelegate(colorCallback, for: LOTKeypath(string: "\(key).Color"))*/
}
}