diff options
| author | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-04-16 23:33:04 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-04-16 23:33:04 +0200 |
| commit | 23e47cd8c0e84d68b8d53724b66a0274a6b9cb71 (patch) | |
| tree | e64732d4e8d4e3b18b68e2b266e0cc4ef29799e1 /Sources | |
| parent | ba4ee0edf2aba19ad73fa53cb01dd0fb9b527526 (diff) | |
Don't use binding for PatternView3.0.0
Diffstat (limited to 'Sources')
| -rw-r--r-- | Sources/Patterns/PatternPicker.swift | 2 | ||||
| -rw-r--r-- | Sources/Patterns/PatternView.swift | 20 |
2 files changed, 10 insertions, 12 deletions
diff --git a/Sources/Patterns/PatternPicker.swift b/Sources/Patterns/PatternPicker.swift index 32c9f39..46b7ef2 100644 --- a/Sources/Patterns/PatternPicker.swift +++ b/Sources/Patterns/PatternPicker.swift @@ -26,7 +26,7 @@ public struct PatternPicker: View { HStack(alignment: .top, spacing: 0) { ForEach(0 ..< 5) { j in if i * 5 + j < patterns.count { - PatternView(design: .constant(patterns[i * 5 + j]), pixelSize: pixelSize, foregroundColor: foregroundColor, backgroundColor: backgroundColor) + PatternView(design: patterns[i * 5 + j], pixelSize: pixelSize, foregroundColor: foregroundColor, backgroundColor: backgroundColor) .frame(width: pixelSize * 16, height: pixelSize * 12) .border(selectedDesign == patterns[i * 5 + j] ? selectedColor : foregroundColor, width: pixelSize / 2.0) .onTapGesture(perform: { diff --git a/Sources/Patterns/PatternView.swift b/Sources/Patterns/PatternView.swift index d4ed37b..e95b4df 100644 --- a/Sources/Patterns/PatternView.swift +++ b/Sources/Patterns/PatternView.swift @@ -2,7 +2,7 @@ import SwiftUI public struct PatternView: View { - @Binding public var design: TileDesign + public var design: TileDesign public var pixelSize: CGFloat public var foregroundColor: Color public var backgroundColor: Color @@ -12,8 +12,8 @@ public struct PatternView: View { pixelSize * 8.0; } - public init(design: Binding<TileDesign>, pixelSize: CGFloat = 2.0, foregroundColor: Color = .black, backgroundColor: Color = .white) { - self._design = design + public init(design: TileDesign, pixelSize: CGFloat = 2.0, foregroundColor: Color = .black, backgroundColor: Color = .white) { + self.design = design self.pixelSize = pixelSize self.foregroundColor = foregroundColor self.backgroundColor = backgroundColor @@ -26,13 +26,11 @@ public struct PatternView: View { let backgroundCGColor = NSColor(backgroundColor).cgColor #endif - self.image = TileImage.image(design.wrappedValue, pixelSize: pixelSize, foregroundColor: foregroundCGColor, backgroundColor: backgroundCGColor) + self.image = TileImage.image(design, pixelSize: pixelSize, foregroundColor: foregroundCGColor, backgroundColor: backgroundCGColor) } - public var body: some View { - GeometryReader { gr in - Image(image, scale: 1, label: Text("Test")).resizable(resizingMode: .tile) - }.drawingGroup() + public var body: some View { + Image(image, scale: 1, label: Text("Test")).resizable(resizingMode: .tile).drawingGroup() } } @@ -40,11 +38,11 @@ struct Pattern_Previews: PreviewProvider { static var previews: some View { VStack { Text("Default") - PatternView(design: .constant(TileDesign.grid)) + PatternView(design: TileDesign.grid) Text("Color override") - PatternView(design: .constant(TileDesign.balls), foregroundColor: .pink, backgroundColor: .cyan) + PatternView(design: TileDesign.balls, foregroundColor: .pink, backgroundColor: .cyan) Text("Pixel size override") - PatternView(design: .constant(TileDesign.shingles), pixelSize: 8.0) + PatternView(design: TileDesign.shingles, pixelSize: 8.0) } } } |