]> git.r.bdr.sh - rbdr/patterns/blobdiff - Sources/Patterns/Pattern.swift
Add supported platforms
[rbdr/patterns] / Sources / Patterns / Pattern.swift
index 19518883173b35c638bd3317db788c50568671db..6c63870fa7e077394181da79730ef97500ca7d09 100644 (file)
@@ -2,21 +2,22 @@ import SwiftUI
 
 public struct Pattern: View {
 
-  private let pixelSize: CGFloat = 2.0;
+  @Binding public var design: TileDesign;
+  public var pixelSize: CGFloat = 2.0;
+  public var foregroundColor: Color = .black
+  public var backgroundColor: Color = .white
   
   private var patternSize: CGFloat {
     pixelSize * 8.0;
   }
   
-  @Binding var design: TileDesign;
-  
   public var body: some View {
     GeometryReader { gr in
       VStack(spacing: 0) {
         ForEach(0 ..< 1 + Int(ceil(gr.size.height / patternSize)), id: \.self) { i in
           HStack(spacing: 0) {
             ForEach(0 ..< Int(ceil(gr.size.width / patternSize)), id: \.self) { j in
-              Tile(design: design)
+              Tile(design: design, pixelSize: pixelSize, foregroundColor: foregroundColor, backgroundColor: backgroundColor)
             }
           }
         }
@@ -27,6 +28,13 @@ public struct Pattern: View {
 
 struct Pattern_Previews: PreviewProvider {
     static var previews: some View {
-      Pattern(design: .constant(TileDesign.grid))
+      VStack {
+        Text("Default")
+        Pattern(design: .constant(TileDesign.grid))
+        Text("Color override")
+        Pattern(design: .constant(TileDesign.balls), foregroundColor: .pink, backgroundColor: .cyan)
+        Text("Pixel size override")
+        Pattern(design: .constant(TileDesign.shingles), pixelSize: 8.0)
+      }
     }
 }