2021-10-06 01:50:09 +05:30
|
|
|
import Foundation
|
2022-06-18 18:09:49 +05:30
|
|
|
import SDWebImageSwiftUI
|
2021-10-06 01:50:09 +05:30
|
|
|
import SwiftUI
|
2022-01-06 20:28:16 +05:30
|
|
|
|
2022-02-17 01:53:11 +05:30
|
|
|
struct BrowserPlayerControls<Content: View, Toolbar: View>: View {
|
2022-06-18 18:09:49 +05:30
|
|
|
enum Context {
|
|
|
|
case browser, player
|
|
|
|
}
|
2021-10-06 01:50:09 +05:30
|
|
|
|
2022-06-18 18:09:49 +05:30
|
|
|
let content: Content
|
2022-06-25 05:09:29 +05:30
|
|
|
let toolbar: Toolbar?
|
2021-10-06 01:50:09 +05:30
|
|
|
|
2022-06-18 18:09:49 +05:30
|
|
|
init(
|
|
|
|
context _: Context? = nil,
|
|
|
|
@ViewBuilder toolbar: @escaping () -> Toolbar? = { nil },
|
|
|
|
@ViewBuilder content: @escaping () -> Content
|
|
|
|
) {
|
2021-10-06 01:50:09 +05:30
|
|
|
self.content = content()
|
2022-06-25 05:09:29 +05:30
|
|
|
self.toolbar = toolbar()
|
2022-02-04 23:08:29 +05:30
|
|
|
}
|
|
|
|
|
2022-06-18 18:09:49 +05:30
|
|
|
init(
|
|
|
|
context: Context? = nil,
|
|
|
|
@ViewBuilder content: @escaping () -> Content
|
|
|
|
) where Toolbar == EmptyView {
|
|
|
|
self.init(context: context, toolbar: { EmptyView() }, content: content)
|
2021-10-06 01:50:09 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
var body: some View {
|
2022-06-25 05:09:29 +05:30
|
|
|
// TODO: remove
|
|
|
|
#if DEBUG
|
|
|
|
if #available(iOS 15.0, macOS 12.0, *) {
|
|
|
|
Self._printChanges()
|
|
|
|
}
|
|
|
|
#endif
|
2021-10-06 01:50:09 +05:30
|
|
|
|
2022-06-25 05:09:29 +05:30
|
|
|
return ZStack(alignment: .bottomLeading) {
|
2022-06-18 18:09:49 +05:30
|
|
|
content
|
2022-06-27 03:07:27 +05:30
|
|
|
.frame(maxHeight: .infinity)
|
2021-10-06 01:50:09 +05:30
|
|
|
|
2022-06-30 02:30:15 +05:30
|
|
|
#if os(iOS)
|
2022-06-25 05:09:29 +05:30
|
|
|
VStack(spacing: 0) {
|
|
|
|
toolbar
|
2022-06-30 13:21:44 +05:30
|
|
|
.frame(height: 35)
|
|
|
|
.frame(maxWidth: .infinity)
|
2022-06-25 05:09:29 +05:30
|
|
|
.borderTop(height: 0.4, color: Color("ControlsBorderColor"))
|
|
|
|
.modifier(ControlBackgroundModifier())
|
2022-06-25 22:03:35 +05:30
|
|
|
ControlsBar(fullScreen: .constant(false))
|
2022-06-25 05:09:29 +05:30
|
|
|
.edgesIgnoringSafeArea(.bottom)
|
|
|
|
}
|
2022-06-18 18:09:49 +05:30
|
|
|
#endif
|
2021-10-06 01:50:09 +05:30
|
|
|
}
|
2021-10-23 02:19:31 +05:30
|
|
|
}
|
2021-10-06 01:50:09 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
struct PlayerControlsView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
2022-06-30 13:21:44 +05:30
|
|
|
BrowserPlayerControls(context: .player, toolbar: {
|
|
|
|
Button("Button") {}
|
|
|
|
}) {
|
2022-06-18 18:09:49 +05:30
|
|
|
BrowserPlayerControls {
|
|
|
|
VStack {
|
|
|
|
Spacer()
|
2022-06-30 13:21:44 +05:30
|
|
|
TextField("A", text: .constant("abc"))
|
2022-06-18 18:09:49 +05:30
|
|
|
Spacer()
|
|
|
|
}
|
2021-10-06 01:50:09 +05:30
|
|
|
}
|
2022-06-18 18:09:49 +05:30
|
|
|
.offset(y: -100)
|
2021-10-06 01:50:09 +05:30
|
|
|
}
|
|
|
|
.injectFixtureEnvironmentObjects()
|
|
|
|
}
|
|
|
|
}
|