This commit is contained in:
David Roman 2023-06-01 00:23:26 +01:00
parent fcea0a249f
commit a5eae004fb
No known key found for this signature in database
GPG Key ID: 7058646EEFCB70A7
1 changed files with 58 additions and 24 deletions

View File

@ -8,9 +8,15 @@ struct ContentView: View {
ListShowcase() ListShowcase()
.tabItem { Text("List") } .tabItem { Text("List") }
.tag(0) .tag(0)
// .introspectTabBarController { tabBarController in #if os(iOS) || os(tvOS)
// tabBarController.tabBar.layer.backgroundColor = UIColor.green.cgColor .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)
@ -29,10 +35,12 @@ struct ContentView: View {
struct ListShowcase: View { struct ListShowcase: View {
var body: some View { var body: some View {
VStack(spacing: 40) {
HStack {
VStack { VStack {
Text("Default") Text("Default")
.lineLimit(1)
.minimumScaleFactor(0.5)
.padding(.horizontal, 12)
List { List {
Text("Item 1") Text("Item 1")
Text("Item 2") Text("Item 2")
@ -40,28 +48,54 @@ struct ListShowcase: View {
} }
VStack { VStack {
Text("List.introspectTableView()") Text(".introspect(.list, ...)")
.lineLimit(1)
.minimumScaleFactor(0.5)
.padding(.horizontal, 12)
.font(.system(.subheadline, design: .monospaced))
List { List {
Text("Item 1") Text("Item 1")
Text("Item 2") Text("Item 2")
} }
// .introspectTableView { tableView in #if os(iOS) || os(tvOS)
// #if !os(tvOS) .introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16)) { tableView in
// tableView.separatorStyle = .none tableView.backgroundView = UIView()
// #endif tableView.backgroundColor = .blue
// } }
.introspect(.list, on: .iOS(.v16)) { collectionView in
collectionView.backgroundView = UIView()
collectionView.subviews.dropFirst(1).first?.backgroundColor = .blue
}
#elseif os(macOS)
.introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13)) { tableView in
tableView.backgroundColor = .blue
}
#endif
} }
VStack { VStack {
Text("child.introspectTableView()") Text(".introspect(.list, ..., scope: .ancestor)")
.lineLimit(1)
.minimumScaleFactor(0.5)
.padding(.horizontal, 12)
.font(.system(.subheadline, design: .monospaced))
List { List {
Text("Item 1") Text("Item 1")
Text("Item 2") Text("Item 2")
// .introspectTableView { tableView in #if os(iOS) || os(tvOS)
// #if !os(tvOS) .introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16), scope: .ancestor) { tableView in
// tableView.separatorStyle = .none tableView.backgroundView = UIView()
// #endif tableView.backgroundColor = .blue
// } }
.introspect(.list, on: .iOS(.v16), scope: .ancestor) { collectionView in
collectionView.backgroundView = UIView()
collectionView.subviews.dropFirst(1).first?.backgroundColor = .blue
}
#elseif os(macOS)
.introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13), scope: .ancestor) { tableView in
tableView.backgroundColor = .blue
}
#endif
} }
} }
} }
@ -73,13 +107,13 @@ struct NavigationShowcase: View {
var body: some View { var body: some View {
NavigationView { NavigationView {
Text("Customized") Text("Customized")
.modifier { // .modifier {
if #available(iOS 15, tvOS 15, *) { // if #available(iOS 15, tvOS 15, *) {
$0.searchable(text: .constant("")) // $0.searchable(text: .constant(""))
} else { // } else {
$0 // $0
} // }
} // }
// .modifier { // .modifier {
//// #if os(iOS) //// #if os(iOS)
// if #available(iOS 15, *) { // if #available(iOS 15, *) {