Skip to content

Conversation

@marbetschar
Copy link

This pull request adds the ability to define a country selector using the newly added var countrySelectorRow : PushRow<String>? as discussed in #3.

To make use of this you'll define a PostalAddressRow like this (see the Example project):

<<< PostalAddressRow() {
	$0.streetPlaceholder = "Street"
	$0.statePlaceholder = "State"
	$0.cityPlaceholder = "City"
	$0.countryPlaceholder = "Country"
	$0.postalCodePlaceholder = "Zip code"
	
	$0.countrySelectorRow = PushRow<String>(){
		$0.options = ["GB","US"]
		$0.displayValueFor = { guard let isoCode = $0 else{ return nil }
			return Locale.current.localizedString(forRegionCode: isoCode)
		}
	}
}

If you want to use custom Nibs, you'll have to add a UITableView linked with @IBOutlet open var countrySelectorTableView: UITableView?.

And this is how it looks like:

picker
detail

Marco Betschart added 5 commits December 11, 2017 14:40
As PushRow<String> in order to allow country selection instead of a textField
This allows us to initialize an empty object of the PostalAddressType used - instead of the non-generic implementation. We also made sure the onChange event is only fired once - and not multiple times (this was the case if the PostalAddress value was not initialized before).
Because the onChange event of the PushRow was not fired, the child cell was never reloaded and therefore displayed a wrong state.
Still waiting for a new tagged release though
@marbetschar
Copy link
Author

Any chance we can get this merged?

@@ -1 +1 @@
github "xmartlabs/Eureka" ~> 4.0
github "xmartlabs/Eureka" "master"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use 4.1 now


+++ Section()
<<< MyPostalAddressRow() {
$0.streetPlaceholder = "Street"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you align this line to its context? Maybe if you set Xcode to replace tabs with spaces


@IBOutlet weak var postalPercentageConstraint: NSLayoutConstraint?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove trailing whitespace

cityTextField?.removeTarget(self, action: nil, for: .allEvents)
countryTextField?.delegate = nil
countryTextField?.removeTarget(self, action: nil, for: .allEvents)
countrySelectorTableView?.delegate = nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here for indentation.

@mats-claassen
Copy link
Member

Hi @marbetschar, sorry for the late reply.

Why did you use a UITableView with a PushRow instead or a simple button that pushes a SelectorViewController?

@marbetschar
Copy link
Author

@mats-claassen main idea was to provide a way for further customization, using native Eureka features .... but looking back it might not made too much sense probably...?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants