Skip to content
This repository was archived by the owner on Jun 17, 2023. It is now read-only.

Commit 9b0bc04

Browse files
author
Amir Khorsandi
committed
Fix not listening to inputs on cell options
1 parent 54484d5 commit 9b0bc04

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Samples/PagingLayoutSamples/Modules/LayoutDesigner/Options/cell/LayoutDesignerOptionCell.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class LayoutDesignerOptionCell: UITableViewCell, NibBased {
115115
}
116116

117117
private func onInputChange(input: UITextField, fromSlider: Bool) {
118-
let value = input.floatValue
118+
let value = input.floatValue ?? 0
119119
if input == singleSliderInput, !(singleSliderInput.floatValue == value && fromSlider) {
120120
onSingleSliderInputChange(CGFloat(value))
121121
onSliderChange(slider: singleSlider, fromInput: true)
@@ -158,6 +158,7 @@ class LayoutDesignerOptionCell: UITableViewCell, NibBased {
158158
}
159159

160160
onSingleSliderChange = onNewValue
161+
onSingleSliderInputChange = onNewValue
161162
if optional {
162163
switchView.isHidden = false
163164
switchView.isOn = latestValue == nil
@@ -192,6 +193,8 @@ class LayoutDesignerOptionCell: UITableViewCell, NibBased {
192193

193194
onDoubleSlider1Change = { _ in onNewValue(getValues()) }
194195
onDoubleSlider2Change = { _ in onNewValue(getValues()) }
196+
onDoubleSliderInput1Change = { _ in onNewValue(getValues()) }
197+
onDoubleSliderInput2Change = { _ in onNewValue(getValues()) }
195198
if optional {
196199
switchView.isHidden = false
197200
switchView.isOn = latestValue == nil
@@ -235,8 +238,8 @@ class LayoutDesignerOptionCell: UITableViewCell, NibBased {
235238

236239
private extension UITextField {
237240

238-
var floatValue: Float {
239-
text?.floatValue ?? 0
241+
var floatValue: Float? {
242+
text?.floatValue
240243
}
241244

242245
func set(value: Float) {

Samples/PagingLayoutSamples/Utilities/CGFloat+String.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ import UIKit
1010

1111

1212
extension String {
13-
var floatValue: Float {
13+
var floatValue: Float? {
1414
let formatter = NumberFormatter()
1515
formatter.numberStyle = .decimal
1616
formatter.allowsFloats = true
17-
formatter.maximumFractionDigits = 2
17+
formatter.maximumFractionDigits = 5
1818
formatter.locale = Locale(identifier: "en_US")
1919
let text = self.replacingOccurrences(of: ",", with: ".")
2020
let number = formatter.number(from: text)
21-
return number?.floatValue ?? 0
21+
return number?.floatValue
2222
}
2323
}
2424

0 commit comments

Comments
 (0)