Audio transcription

This commit is contained in:
Ali
2022-05-14 00:08:44 +04:00
parent f80bf33453
commit 6b3c11a6fd
39 changed files with 1139 additions and 189 deletions

View File

@@ -0,0 +1,20 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "AudioWaveformComponent",
module_name = "AudioWaveformComponent",
srcs = glob([
"Sources/**/*.swift",
]),
copts = [
"-warnings-as-errors",
],
deps = [
"//submodules/ComponentFlow:ComponentFlow",
"//submodules/AppBundle:AppBundle",
"//submodules/Display:Display",
],
visibility = [
"//visibility:public",
],
)

View File

@@ -0,0 +1,63 @@
import Foundation
import UIKit
import ComponentFlow
import Display
public final class AudioWaveformComponent: Component {
public let backgroundColor: UIColor
public let foregroundColor: UIColor
public let samples: Data
public let peak: Int32
public init(
backgroundColor: UIColor,
foregroundColor: UIColor,
samples: Data,
peak: Int32
) {
self.backgroundColor = backgroundColor
self.foregroundColor = foregroundColor
self.samples = samples
self.peak = peak
}
public static func ==(lhs: AudioWaveformComponent, rhs: AudioWaveformComponent) -> Bool {
if lhs.backgroundColor !== rhs.backgroundColor {
return false
}
if lhs.foregroundColor != rhs.foregroundColor {
return false
}
if lhs.samples != rhs.samples {
return false
}
if lhs.peak != rhs.peak {
return false
}
return true
}
public final class View: UIView {
private var component: AudioWaveformComponent?
override init(frame: CGRect) {
super.init(frame: frame)
}
required public init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func update(component: AudioWaveformComponent, availableSize: CGSize, transition: Transition) -> CGSize {
return CGSize(width: availableSize.width, height: availableSize.height)
}
}
public func makeView() -> View {
return View(frame: CGRect())
}
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
return view.update(component: self, availableSize: availableSize, transition: transition)
}
}