@ObservedObjectvar model =ARStateModel()@Stateprivatevar colorIndex =0@Stateprivatevar showStroke =truevar body: some View {
Step 4
Add a variable to the extension that creates a color picker view
var colorPicker: some View {ScrollView(.horizontal) {HStack {ForEach(0..<colorItems.count) { i inButton(action: { showStroke =true colorIndex = i model.pickColor(paint: colorItems[i]) }) {RoundedRectangle(cornerRadius:17) .strokeBorder(lineWidth: (showStroke && i == colorIndex) ?5:0) .foregroundColor(.white) .background(Color(colorItems[i].color)) .clipShape(RoundedRectangle(cornerRadius:17)) .frame(width:74, height:74) .animation(Animation.interpolatingSpring(stiffness:60, damping:15)) } .onTapGesture { self.showStroke =true } } } .padding() } }
Step 5
Modify the view body to add the newly created colorPicker view.
var body: some View {ZStack {ZStack(alignment: .bottom, content: { arView .edgesIgnoringSafeArea(.all) colorPicker }) } .onAppear { model.pickColor(paint: colorItems[0]) } }
Step 6
Build and run your project. You will see a color picker has been added to the view. Scroll through the color picker and select different colors before tapping on the walls. You should be able to paint walls different colors now.
If at any point you need help from the Passio team, please reach out to us at support@passiolife.com