Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would love to see a currency field / row added. (Formatters) #9

Closed
btripp opened this issue Oct 1, 2015 · 3 comments
Closed

Would love to see a currency field / row added. (Formatters) #9

btripp opened this issue Oct 1, 2015 · 3 comments

Comments

@btripp
Copy link

btripp commented Oct 1, 2015

No description provided.

@mtnbarreto
Copy link
Member

@btripp
What do you mean by currency field?
We have added support for NSFormatters, look at the example project which contains a field that shows a currency value.
Eureka gives the ability to set up any custom formatter to a field cell or create a completely new row type.

@thiagorossener
Copy link

That would be nice.

I think I know what he is talking about. I made a component to format a NSNumber given a currencyCode, for example.

What would be great is a field where you set a value (NSNumber), and a currencyCode (BRL, USD, etc..) and it formats the number for you like R$ 1.234,00 or US$ 1,234.00. A price field.

If you want to take a look at my component:
https://github.com/thiagoross/TRCurrencyTextField

@mtnbarreto mtnbarreto changed the title Would love to see a currency field / row added. Would love to see a currency field / row added. (Formatters) Oct 15, 2015
@mtnbarreto
Copy link
Member

TextField rows provided by default have a formatter property that can be used to set up any formatter.

for instance:

DecimalRow(){
        $0.useFormatterDuringInput = true
        $0.title = "Currency style"
        $0.value = 2015
        let formatter = CurrencyFormatter()
        formatter.locale = NSLocale.currentLocale()
        formatter.numberStyle = NSNumberFormatterStyle.CurrencyStyle
        $0.formatter = formatter
}

I think that setting up the formatter is enough and there is no need to use a different row.
Anyway If you want to provide a default formatter customization you can extend from
public class FieldRow<T: Any, Cell: CellType where Cell: BaseCell, Cell: TextFieldCell, Cell.Value == T> and accordingly configure the formatter by overriding the init.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants