wip
This commit is contained in:
parent
b572bb72f5
commit
1f27b641c8
|
@ -2,21 +2,13 @@ import SwiftUI
|
||||||
import SwiftUIIntrospect
|
import SwiftUIIntrospect
|
||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
@State private var selection = 0
|
@State var selection = 0
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
TabView(selection: $selection) {
|
TabView(selection: $selection) {
|
||||||
ListShowcase()
|
ListShowcase()
|
||||||
.tabItem { Text("List") }
|
.tabItem { Text("List") }
|
||||||
.tag(0)
|
.tag(0)
|
||||||
#if os(iOS) || os(tvOS)
|
|
||||||
.introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16), .tvOS(.v13, .v14, .v15, .v16), scope: .ancestor) { tabBarController in
|
|
||||||
tabBarController.tabBar.layer.backgroundColor = UIColor.green.cgColor
|
|
||||||
}
|
|
||||||
#elseif os(macOS)
|
|
||||||
.introspect(.tabView, on: .macOS(.v10_15, .v11, .v12, .v13), scope: .ancestor) { splitView in
|
|
||||||
splitView.subviews.first?.layer?.backgroundColor = NSColor.green.cgColor
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
ScrollViewShowcase()
|
ScrollViewShowcase()
|
||||||
.tabItem { Text("ScrollView") }
|
.tabItem { Text("ScrollView") }
|
||||||
.tag(1)
|
.tag(1)
|
||||||
|
@ -30,6 +22,16 @@ struct ContentView: View {
|
||||||
.tabItem { Text("Simple elements") }
|
.tabItem { Text("Simple elements") }
|
||||||
.tag(4)
|
.tag(4)
|
||||||
}
|
}
|
||||||
|
#if os(iOS) || os(tvOS)
|
||||||
|
.introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16), .tvOS(.v13, .v14, .v15, .v16)) { tabBarController in
|
||||||
|
tabBarController.tabBar.layer.backgroundColor = UIColor.green.cgColor
|
||||||
|
}
|
||||||
|
#elseif os(macOS)
|
||||||
|
.introspect(.tabView, on: .macOS(.v10_15, .v11, .v12, .v13)) { splitView in
|
||||||
|
splitView.subviews.first?.layer?.backgroundColor = NSColor.green.cgColor
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
.preferredColorScheme(.light)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,15 +62,15 @@ struct ListShowcase: View {
|
||||||
#if os(iOS) || os(tvOS)
|
#if os(iOS) || os(tvOS)
|
||||||
.introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16)) { tableView in
|
.introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16)) { tableView in
|
||||||
tableView.backgroundView = UIView()
|
tableView.backgroundView = UIView()
|
||||||
tableView.backgroundColor = .blue
|
tableView.backgroundColor = .cyan
|
||||||
}
|
}
|
||||||
.introspect(.list, on: .iOS(.v16)) { collectionView in
|
.introspect(.list, on: .iOS(.v16)) { collectionView in
|
||||||
collectionView.backgroundView = UIView()
|
collectionView.backgroundView = UIView()
|
||||||
collectionView.subviews.dropFirst(1).first?.backgroundColor = .blue
|
collectionView.subviews.dropFirst(1).first?.backgroundColor = .cyan
|
||||||
}
|
}
|
||||||
#elseif os(macOS)
|
#elseif os(macOS)
|
||||||
.introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13)) { tableView in
|
.introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13)) { tableView in
|
||||||
tableView.backgroundColor = .blue
|
tableView.backgroundColor = .cyan
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -85,15 +87,15 @@ struct ListShowcase: View {
|
||||||
#if os(iOS) || os(tvOS)
|
#if os(iOS) || os(tvOS)
|
||||||
.introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16), scope: .ancestor) { tableView in
|
.introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16), scope: .ancestor) { tableView in
|
||||||
tableView.backgroundView = UIView()
|
tableView.backgroundView = UIView()
|
||||||
tableView.backgroundColor = .blue
|
tableView.backgroundColor = .cyan
|
||||||
}
|
}
|
||||||
.introspect(.list, on: .iOS(.v16), scope: .ancestor) { collectionView in
|
.introspect(.list, on: .iOS(.v16), scope: .ancestor) { collectionView in
|
||||||
collectionView.backgroundView = UIView()
|
collectionView.backgroundView = UIView()
|
||||||
collectionView.subviews.dropFirst(1).first?.backgroundColor = .blue
|
collectionView.subviews.dropFirst(1).first?.backgroundColor = .cyan
|
||||||
}
|
}
|
||||||
#elseif os(macOS)
|
#elseif os(macOS)
|
||||||
.introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13), scope: .ancestor) { tableView in
|
.introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13), scope: .ancestor) { tableView in
|
||||||
tableView.backgroundColor = .blue
|
tableView.backgroundColor = .cyan
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -103,6 +105,58 @@ struct ListShowcase: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ScrollViewShowcase: View {
|
||||||
|
var body: some View {
|
||||||
|
VStack(spacing: 40) {
|
||||||
|
ScrollView {
|
||||||
|
Text("Default")
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.lineLimit(1)
|
||||||
|
.minimumScaleFactor(0.5)
|
||||||
|
.padding(.horizontal, 12)
|
||||||
|
}
|
||||||
|
|
||||||
|
ScrollView {
|
||||||
|
Text(".introspect(.scrollView, ...)")
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.lineLimit(1)
|
||||||
|
.minimumScaleFactor(0.5)
|
||||||
|
.padding(.horizontal, 12)
|
||||||
|
.font(.system(.subheadline, design: .monospaced))
|
||||||
|
}
|
||||||
|
#if os(iOS) || os(tvOS)
|
||||||
|
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16), .tvOS(.v13, .v14, .v15, .v16)) { scrollView in
|
||||||
|
scrollView.layer.backgroundColor = UIColor.cyan.cgColor
|
||||||
|
}
|
||||||
|
#elseif os(macOS)
|
||||||
|
.introspect(.scrollView, on: .macOS(.v10_15, .v11, .v12, .v13)) { scrollView in
|
||||||
|
scrollView.drawsBackground = true
|
||||||
|
scrollView.backgroundColor = .cyan
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ScrollView {
|
||||||
|
Text(".introspect(.scrollView, ..., scope: .ancestor)")
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.lineLimit(1)
|
||||||
|
.minimumScaleFactor(0.5)
|
||||||
|
.padding(.horizontal, 12)
|
||||||
|
.font(.system(.subheadline, design: .monospaced))
|
||||||
|
#if os(iOS) || os(tvOS)
|
||||||
|
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16), .tvOS(.v13, .v14, .v15, .v16), scope: .ancestor) { scrollView in
|
||||||
|
scrollView.layer.backgroundColor = UIColor.cyan.cgColor
|
||||||
|
}
|
||||||
|
#elseif os(macOS)
|
||||||
|
.introspect(.scrollView, on: .macOS(.v10_15, .v11, .v12, .v13), scope: .ancestor) { scrollView in
|
||||||
|
scrollView.drawsBackground = true
|
||||||
|
scrollView.backgroundColor = .cyan
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct NavigationShowcase: View {
|
struct NavigationShowcase: View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationView {
|
NavigationView {
|
||||||
|
@ -153,28 +207,6 @@ struct ViewControllerShowcase: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ScrollViewShowcase: View {
|
|
||||||
var body: some View {
|
|
||||||
HStack {
|
|
||||||
ScrollView {
|
|
||||||
Text("Default")
|
|
||||||
}
|
|
||||||
ScrollView {
|
|
||||||
Text("ScrollView.introspectScrollView()")
|
|
||||||
}
|
|
||||||
// .introspectScrollView { scrollView in
|
|
||||||
// scrollView.layer.backgroundColor = UIColor.red.cgColor
|
|
||||||
// }
|
|
||||||
ScrollView {
|
|
||||||
Text("child.introspectScrollView()")
|
|
||||||
// .introspectScrollView { scrollView in
|
|
||||||
// scrollView.layer.backgroundColor = UIColor.green.cgColor
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct SimpleElementsShowcase: View {
|
struct SimpleElementsShowcase: View {
|
||||||
|
|
||||||
@State private var textFieldValue = ""
|
@State private var textFieldValue = ""
|
||||||
|
@ -271,11 +303,8 @@ struct SimpleElementsShowcase: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//struct ContentView_Previews: PreviewProvider {
|
struct ContentView_Previews: PreviewProvider {
|
||||||
// static var previews: some View {
|
static var previews: some View {
|
||||||
// Group {
|
ContentView(selection: 1)
|
||||||
// ListShowcase()
|
}
|
||||||
// NavigationShowcase()
|
}
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
Loading…
Reference in New Issue