alles auf TabContent umgestellt
This commit is contained in:
parent
3e9762c3bf
commit
7aebdcefb1
9 changed files with 32 additions and 21 deletions
|
|
@ -3,7 +3,7 @@
|
|||
import SwiftUI
|
||||
|
||||
|
||||
struct BikeView: View {
|
||||
struct BikeView: TabContent {
|
||||
static var title = "Bike"
|
||||
static var image = "bicycle"
|
||||
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@ enum TabLabel: String {
|
|||
"hand.draw.fill"
|
||||
} }
|
||||
}
|
||||
//
|
||||
//func tab<C: TabContent>(_ contentType: C.Type)
|
||||
//-> Tab<Never, C, DefaultTabLabel> {
|
||||
// Tab(C.title, systemImage: C.image) {
|
||||
// C()
|
||||
// }
|
||||
//}
|
||||
|
||||
func tab<C: TabContent>(_ contentType: C.Type)
|
||||
-> Tab<Never, C, DefaultTabLabel> {
|
||||
Tab(C.title, systemImage: C.image) {
|
||||
C()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -38,6 +38,12 @@ struct ContentView: View {
|
|||
Tab("drücken", systemImage: TabLabel.cars.image) {
|
||||
SwapperView()
|
||||
}
|
||||
tab(ListView.self)
|
||||
tab(CountView.self)
|
||||
tab(BikeView.self)
|
||||
tab(TrainView.self)
|
||||
tab(SwapperView.self)
|
||||
tab(PaddingView.self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import SwiftUI
|
||||
|
||||
struct CountView: View, TabContent {
|
||||
struct CountView: TabContent {
|
||||
static var title = "Count"
|
||||
static var image = "42.circle"
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import SwiftUI
|
|||
//import Playgrounds
|
||||
import Foundation
|
||||
|
||||
struct ListView: View , TabContent{
|
||||
struct ListView: TabContent{
|
||||
static var title = "List"
|
||||
static var image = "list.bullet"
|
||||
|
||||
|
|
|
|||
|
|
@ -7,13 +7,8 @@ protocol Vehicle {
|
|||
var color: Color { get set }
|
||||
}
|
||||
|
||||
protocol TabContent {
|
||||
init() //title: String, image: String)
|
||||
|
||||
// <#statements#>
|
||||
// }
|
||||
|
||||
|
||||
protocol TabContent: View {
|
||||
init()
|
||||
static var title: String { get }
|
||||
static var image: String { get }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,21 @@
|
|||
import SwiftUI
|
||||
|
||||
struct PaddingView: View {
|
||||
struct PaddingView: TabContent {
|
||||
static var title = "Padding"
|
||||
static var image = "pad.header"
|
||||
|
||||
var body: some View {
|
||||
Text("Hello, World!")
|
||||
Color.black
|
||||
.padding()
|
||||
.background(.green)
|
||||
.padding()
|
||||
.background(.blue)
|
||||
.padding()
|
||||
.background(.red)
|
||||
.frame(width: 380, height: 380)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
PaddingView()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import SwiftUI
|
||||
|
||||
struct SwapperView: View{
|
||||
struct SwapperView: TabContent {
|
||||
static var title = "Swap"
|
||||
static var image = "rectangle.2.swap"
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -3,7 +3,7 @@
|
|||
import SwiftUI
|
||||
|
||||
|
||||
struct TrainView: View , TabContent {
|
||||
struct TrainView: TabContent {
|
||||
static var title = "Train"
|
||||
static var image = "train.side.front.car"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue