Skip to content

Instantly share code, notes, and snippets.

@YordiLorenzo
Created September 21, 2019 09:43
Show Gist options
  • Save YordiLorenzo/3d2805c916516cb9042d42598109cd30 to your computer and use it in GitHub Desktop.
Save YordiLorenzo/3d2805c916516cb9042d42598109cd30 to your computer and use it in GitHub Desktop.
Eureka example
self.form +++ Section("Filters")
<<< SwitchRow("sort_by_distance_tag"){
$0.value = User.sharedInstance.filters?.sortByDistance ?? false
$0.title = "Sorteer op afstand"
}.onChange({ row in
UserManager()
.updateFilters(cities: nil, sort_by_distance: row.value, distance: nil, completion: nil)
})
<<< StepperRow() {
$0.hidden = Condition.function(["sort_by_distance_tag"], { form in
return !((form.rowBy(tag: "sort_by_distance_tag") as? SwitchRow)?.value ?? false)
})
$0.title = "Afstand"
$0.value = Double(User.sharedInstance.filters?.distance ?? 25)
$0.cellSetup({ (cell, row) in
cell.stepper.stepValue = 5
cell.valueLabel?.textColor = .black
})
$0.cellUpdate({ (cell, row) in
cell.valueLabel?.text = "\(cell.stepper.value)KM"
cell.valueLabel?.textColor = .black
cell.valueLabel?.tintColor = .black
})
}.onChange({ (row) in
UserManager()
.updateFilters(cities: nil, sort_by_distance: nil, distance: Int(row.value ?? 0), completion: nil)
})
+++ Section("Notificatie filters")
<<< MultipleSelectorRow<String>() {
let cities = User.sharedInstance.cities.map { $0.name ?? "" }
$0.title = "Steden"
$0.options = self.viewModel.cities.value.map { $0.name ?? ""}
$0.value = Set(cities)
$0.selectorTitle = "Kies steden"
}.onPresent { from, to in
to.selectableRowCellUpdate = { cell, row in
cell.textLabel?.text = row.selectableValue!
}
}.onChange({ row in
let cities = Array(row.value!)
UserManager()
.updateFilters(cities: cities, sort_by_distance: nil, distance: nil, completion: nil)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment