Coder Social home page Coder Social logo

Comments (10)

zenangst avatar zenangst commented on August 20, 2024

Consider it on our todo list :-)

from form.

andrewgubanov avatar andrewgubanov commented on August 20, 2024

👍

from form.

3lvis avatar 3lvis commented on August 20, 2024

@andrewgubanov ❤️

from form.

3lvis avatar 3lvis commented on August 20, 2024

We have

typedef void (^HYPFieldConfigureCellBlock)(id cell, NSIndexPath *indexPath, HYPFormField *field);

It's a configuration block that gets called when the cells get called for usage (reusage), if it's not implemented it only does this.

The idea is that you in this configuration block can change the color of the cell background, cell title label and so on.

You can do the same thing with the headerConfigurationBlock.

This might be an overkill since styling should be applied only on initialization.

Other idea could be providing a "THEMEPROVIDER"

Yeah.

from form.

andrewgubanov avatar andrewgubanov commented on August 20, 2024

@NSElvis I was more thinking about HYPFormBackgroundView which is not possible to style for now.
But anyways, ThemeProvider/ThemeStyler would be the best solution as it could style propper views/cells only when those are instantiated.

from form.

3lvis avatar 3lvis commented on August 20, 2024

@andrewgubanov maybe considering UIAppearance is a good idea too

from form.

andrewgubanov avatar andrewgubanov commented on August 20, 2024

@NSElvis depends on how much you want to allow user to customize your interface. UIAppearance is good for "coloring" already styled UI. But if you want your users to be able to actually style the UI, then you need smth like ThemeProvier, etc. It is like if I want to have my backgroundview in a shape of a peer for example. In this case UIAppearance won't help much :)

from form.

3lvis avatar 3lvis commented on August 20, 2024

I tried UIAppearance with FORMTextField, works pretty good.

[[FORMTextField appearance] setTextColor:[UIColor redColor]];
[[FORMTextField appearance] setBackgroundColor:[UIColor yellowColor]];

There are two caveats, the first one is that we need to avoid setting the colors the way we've been doing it, otherwise UIAppearance doesn't work.

The second one is that I haven't figured out how to style a CALayer using UIAppearance, this is important if we want to give access to thinks like border color, or corner radius.

from form.

andrewgubanov avatar andrewgubanov commented on August 20, 2024

@NSElvis

There are two caveats, the first one is that we need to avoid setting the colors the way we've been doing it, otherwise UIAppearance doesn't work.

This is expected behaviour of the way UIAppearane works. You can read more info here.

There is also no way to style CALayer as it does not conform to UIAppearance. For this reason I have implemented my own DMAppearance you can check out. Then in your custom CALayer you conform to UIAppearance protocol and in +[MYCALayer appearance] return DMAppearanceRecord instance.
Another option is to not give access to underlying CALayer of your UIView. You simply declare properties cornerRadius, borderColor, etc with UI_APPEARANCE_SELECTOR in your UIView subclass, and in setters set those values into self.layer.
Keep in mind that if you want to provide default styling via UIAppearance flow in your custom views, you should do this in +load or +initialize methods depends on how much you do not care about the memory footpring of your app :) I personally do this in +initialize

from form.

3lvis avatar 3lvis commented on August 20, 2024

You simply declare properties cornerRadius, borderColor, etc with UI_APPEARANCE_SELECTOR in your UIView subclass, and in setters set those values into self.layer.

@andrewgubanov I was looking into this approach and I like it a lot! :)

from form.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.