Untitled

mail@pastecode.io avatar
unknown
plain_text
10 days ago
1.5 kB
1
Indexable
Never
ContentView

import SwiftUI

struct ContentView: View {
    @ObservedObject var viewModel: DrawingViewModel

    var body: some View {
        NavigationView {
            Form {
                Section(header: Text("Kształt")) {
                    Picker("Wybierz kształt", selection: $viewModel.selectedFigure) {
                        ForEach(FigureType.allCases, id: \.self) { figureType in
                            Label(figureType.figure().name, systemImage: figureType.figure().systemIconName)
                                .tag(figureType)
                        }
                    }
                }

                Section(header: Text("Kolor wypełnienia")) {
                    ColorPicker("Wybierz kolor", selection: $viewModel.fillColor)
                }

                Section(header: Text("Rozmiar")) {
                    TextField("Szerokość", text: $viewModel.widthText)
                        .keyboardType(.decimalPad)
                    TextField("Wysokość", text: $viewModel.heightText)
                        .keyboardType(.decimalPad)
                }

                Section {
                    Toggle(isOn: $viewModel.hasBorder) {
                        Text("Obramowanie")
                    }
                }
            }
            .navigationBarTitle("Rysowanie figur")
        }
    }
}

@main
struct DrawingApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView(viewModel: DrawingViewModel())
        }
    }
}
Leave a Comment