avatar
Untitled

Guest 72 11th Apr, 2024

MARKUP 1.65 KB
                                           
                         if let figure = selectedFigure {
                ShapePreview(figure: figure, fillColor: fillColor, widthText: widthText, heightText: heightText, showBorder: showBorder)
                    .padding()
            }

// ShapePreview.swift

import SwiftUI

struct ShapePreview: View {
    var figure: FigurePickerElement
    var fillColor: Color
    var widthText: String
    var heightText: String
    var showBorder: Bool
    
    var body: some View {
        VStack {
            switch figure.name {
            case "Circle":
                Circle()
                    .fill(fillColor)
                    .frame(width: CGFloat(dataForView.stringToCGFloat(widthText)), height: CGFloat(dataForView.stringToCGFloat(heightText)))
                    .overlay(showBorder ? Circle().stroke(Color.black, lineWidth: 2) : nil)
            case "Square":
                Rectangle()
                    .fill(fillColor)
                    .frame(width: CGFloat(dataForView.stringToCGFloat(widthText)), height: CGFloat(dataForView.stringToCGFloat(heightText)))
                    .overlay(showBorder ? Rectangle().stroke(Color.black, lineWidth: 2) : nil)
            case "Ellipse":
                Ellipse()
                    .fill(fillColor)
                    .frame(width: CGFloat(dataForView.stringToCGFloat(widthText)), height: CGFloat(dataForView.stringToCGFloat(heightText)))
                    .overlay(showBorder ? Ellipse().stroke(Color.black, lineWidth: 2) : nil)
            default:
                Text("Invalid figure")
            }
        }
    }
}
                      
                                       
To share this paste please copy this url and send to your friends
RAW Paste Data
Recent Pastes
Ta strona używa plików cookie w celu usprawnienia i ułatwienia dostępu do serwisu oraz prowadzenia danych statystycznych. Dalsze korzystanie z tej witryny oznacza akceptację tego stanu rzeczy.
Wykorzystywanie plików Cookie
Jak wyłączyć cookies?
ROZUMIEM