|
| 1 | +#if canImport(AndroidSwiftUI) |
| 2 | +import AndroidSwiftUI |
| 3 | +#else |
| 4 | +import SwiftUI |
| 5 | +#endif |
| 6 | + |
| 7 | +struct StylePlayground: View { |
| 8 | + @State private var taps = 0 |
| 9 | + var body: some View { |
| 10 | + ScrollView { |
| 11 | + VStack(alignment: .leading, spacing: 0) { |
| 12 | + Example("Inherited font") { |
| 13 | + VStack(alignment: .leading, spacing: 6) { |
| 14 | + Text("All three") |
| 15 | + Text("inherit the") |
| 16 | + Text("title font") |
| 17 | + } |
| 18 | + .font(.title) |
| 19 | + } |
| 20 | + Example("Inherited color") { |
| 21 | + VStack(alignment: .leading, spacing: 6) { |
| 22 | + Text("Both lines are") |
| 23 | + Text("blue from the container") |
| 24 | + } |
| 25 | + .foregroundColor(.blue) |
| 26 | + } |
| 27 | + Example("Child overrides parent") { |
| 28 | + VStack(alignment: .leading, spacing: 6) { |
| 29 | + Text("Title by inheritance") |
| 30 | + Text("Caption overrides").font(.caption) |
| 31 | + } |
| 32 | + .font(.title) |
| 33 | + } |
| 34 | + Example("Font and color together") { |
| 35 | + VStack(alignment: .leading, spacing: 6) { |
| 36 | + Text("Headline weight") |
| 37 | + Text("and purple color") |
| 38 | + } |
| 39 | + .font(.headline) |
| 40 | + .foregroundColor(.purple) |
| 41 | + } |
| 42 | + Example("Inherited disabled") { |
| 43 | + VStack(alignment: .leading, spacing: 8) { |
| 44 | + Text("Both buttons are disabled (taps: \(taps))") |
| 45 | + Button("First") { taps += 1 } |
| 46 | + Button("Second") { taps += 1 } |
| 47 | + } |
| 48 | + .disabled(true) |
| 49 | + } |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | +} |
0 commit comments