EurekaCommunity / ColorPickerRow

A color picker row for use with the Eureka form library
MIT License
56 stars 15 forks source link

How to change inlineColorPicker's color? or I'd love to use palette. #8

Closed jamesdawkins closed 6 years ago

jamesdawkins commented 6 years ago

Hi, Thank you for improving wonderful function.

Now I'm makeing apps and want to use InlineColorPicker for it.

I want to ask is same as the title. Can't we change the colors in the inlineColorPicker? Or it will be so happy to use palette.

Is there any information or plan?

Kindly confirm. Thank you!

alldritt commented 6 years ago

I'm pleased to hear you find the control useful.

If you want to change the chosen colour, just set the colour row's value property:

        form
            +++ Section()
                <<< InlineColorPickerRow { (row) in
                    row.title = "Stimulus Color"
                    row.value = ????
                }
                .onChange { (row) in
                    ??? = row.value
                }

If you want to change the pallets of colours offered, then you can do that like this:

        form
            +++ Section()
                <<< InlineColorPickerRow { (row) in
                    row.title = "Stimulus Color"
                    row.value = ????
                }
                .cellSetup { (cell, row) in
                    //  Exclude the Solorized palette
                    row.inlineRow?.cell.palettes = [iOS().palette,
                                     WP8().palette,
                                     Flat().palette,
                                     Material().palette,
                                     Metro().palette]
                }
                .onChange { (row) in
                    ??? = row.value
                }
jamesdawkins commented 6 years ago

Tnank you!!

If you want to change the pallets of colours offered, then you can do that like this:

I wanted to use this side but it didn't work and it just can show Apple,metro and so on in the pallet... Is there any bad line in my code?

<<< InlineColorPickerRow { (row) in row.title = "Stimulus Color" row.value = UIColor.white } .cellSetup { (cell, row) in // Exclude the Solorized palette row.inlineRow?.cell.palettes = [ColorPalette(name: "All",palette: [ColorSpec(hex: "#BDC3C4", name: ""), ColorSpec(hex: "#000000", name: ""), ColorSpec(hex: "#d8de00", name: ""), ColorSpec(hex: "#9ec700", name: ""), ColorSpec(hex: "#4caf0f", name: ""), ColorSpec(hex: "#009825", name: ""), ColorSpec(hex: "#009b71", name: ""), ColorSpec(hex: "#009e9f", name: ""), ColorSpec(hex: "#00a1c5", name: ""), ColorSpec(hex: "#00a3e7", name: ""), ColorSpec(hex: "#008dd0", name: ""), ColorSpec(hex: "#0072b6", name: ""), ColorSpec(hex: "#00509a", name: ""), ColorSpec(hex: "#000c7a", name: ""), ColorSpec(hex: "#6d087c", name: ""), ColorSpec(hex: "#a1007e", name: ""), ColorSpec(hex: "#cb0080", name: ""), ColorSpec(hex: "#f00082", name: ""), ColorSpec(hex: "#ef0070", name: ""), ColorSpec(hex: "#ef005a", name: ""), ColorSpec(hex: "#ef003a", name: ""), ColorSpec(hex: "#ef0000", name: ""), ColorSpec(hex: "#f56b00", name: ""), ColorSpec(hex: "#fca000", name: ""), ColorSpec(hex: "#ffcd00", name: ""), ColorSpec(hex: "#fff500", name: "")])] } .onChange { (row) in }.cellUpdate { cell, row in cell.textLabel?.font = .italicSystemFont(ofSize: 14) }

alldritt commented 6 years ago

Yes, that seems fine to me.