|
|
@ -8,21 +8,8 @@ struct AppFormAppearance { |
|
|
|
static func textArea(tag: String? = .none, callback: @escaping (TextAreaRow) -> Void) -> TextAreaRow { |
|
|
|
static func textArea(tag: String? = .none, callback: @escaping (TextAreaRow) -> Void) -> TextAreaRow { |
|
|
|
let textArea = TextAreaRow(tag) { |
|
|
|
let textArea = TextAreaRow(tag) { |
|
|
|
$0.title = "" |
|
|
|
$0.title = "" |
|
|
|
}.onRowValidationChanged { cell, row in |
|
|
|
}.onRowValidationChanged { |
|
|
|
let rowIndex = row.indexPath!.row |
|
|
|
AppFormAppearance.onRowValidationChanged(baseCell: $0.0, row: $0.1) |
|
|
|
while row.section!.count > rowIndex + 1 && row.section?[rowIndex + 1] is LabelRow { |
|
|
|
|
|
|
|
row.section?.remove(at: rowIndex + 1) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if !row.isValid { |
|
|
|
|
|
|
|
for (index, validationMsg) in row.validationErrors.map({ $0.msg }).enumerated() { |
|
|
|
|
|
|
|
let labelRow = LabelRow { |
|
|
|
|
|
|
|
$0.title = validationMsg |
|
|
|
|
|
|
|
$0.cell.height = { 20 } |
|
|
|
|
|
|
|
$0.cell.textLabel?.textColor = .red |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
row.section?.insert(labelRow, at: row.indexPath!.row + index + 1) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
callback(textArea) |
|
|
|
callback(textArea) |
|
|
|
return textArea |
|
|
|
return textArea |
|
|
@ -35,21 +22,8 @@ struct AppFormAppearance { |
|
|
|
if !row.isValid { |
|
|
|
if !row.isValid { |
|
|
|
cell.textField?.textColor = .red |
|
|
|
cell.textField?.textColor = .red |
|
|
|
} |
|
|
|
} |
|
|
|
}.onRowValidationChanged { cell, row in |
|
|
|
}.onRowValidationChanged { |
|
|
|
let rowIndex = row.indexPath!.row |
|
|
|
AppFormAppearance.onRowValidationChanged(baseCell: $0.0, row: $0.1) |
|
|
|
while row.section!.count > rowIndex + 1 && row.section?[rowIndex + 1] is LabelRow { |
|
|
|
|
|
|
|
row.section?.remove(at: rowIndex + 1) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if !row.isValid { |
|
|
|
|
|
|
|
for (index, validationMsg) in row.validationErrors.map({ $0.msg }).enumerated() { |
|
|
|
|
|
|
|
let labelRow = LabelRow { |
|
|
|
|
|
|
|
$0.title = validationMsg |
|
|
|
|
|
|
|
$0.cell.height = { 20 } |
|
|
|
|
|
|
|
$0.cell.textLabel?.textColor = .red |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
row.section?.insert(labelRow, at: row.indexPath!.row + index + 1) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
callback(textField) |
|
|
|
callback(textField) |
|
|
|
return textField |
|
|
|
return textField |
|
|
@ -62,26 +36,30 @@ struct AppFormAppearance { |
|
|
|
if !row.isValid { |
|
|
|
if !row.isValid { |
|
|
|
cell.textField?.textColor = .red |
|
|
|
cell.textField?.textColor = .red |
|
|
|
} |
|
|
|
} |
|
|
|
}.onRowValidationChanged { cell, row in |
|
|
|
}.onRowValidationChanged { |
|
|
|
let rowIndex = row.indexPath!.row |
|
|
|
AppFormAppearance.onRowValidationChanged(baseCell: $0.0, row: $0.1) |
|
|
|
while row.section!.count > rowIndex + 1 && row.section?[rowIndex + 1] is LabelRow { |
|
|
|
|
|
|
|
row.section?.remove(at: rowIndex + 1) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if !row.isValid { |
|
|
|
|
|
|
|
for (index, validationMsg) in row.validationErrors.map({ $0.msg }).enumerated() { |
|
|
|
|
|
|
|
let labelRow = LabelRow { |
|
|
|
|
|
|
|
$0.title = validationMsg |
|
|
|
|
|
|
|
$0.cell.height = { 20 } |
|
|
|
|
|
|
|
$0.cell.textLabel?.textColor = .red |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
row.section?.insert(labelRow, at: row.indexPath!.row + index + 1) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
callback(textField) |
|
|
|
callback(textField) |
|
|
|
return textField |
|
|
|
return textField |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func onRowValidationChanged(baseCell: BaseCell, row: BaseRow) { |
|
|
|
|
|
|
|
let rowIndex = row.indexPath!.row |
|
|
|
|
|
|
|
while row.section!.count > rowIndex + 1 && row.section?[rowIndex + 1] is LabelRow { |
|
|
|
|
|
|
|
row.section?.remove(at: rowIndex + 1) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if !row.isValid { |
|
|
|
|
|
|
|
for (index, validationMsg) in row.validationErrors.map({ $0.msg }).enumerated() { |
|
|
|
|
|
|
|
let labelRow = LabelRow { |
|
|
|
|
|
|
|
$0.title = validationMsg |
|
|
|
|
|
|
|
$0.cell.height = { 20 } |
|
|
|
|
|
|
|
$0.cell.textLabel?.textColor = .red |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
row.section?.insert(labelRow, at: row.indexPath!.row + index + 1) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static func button(_ title: String? = .none, callback: @escaping (ButtonRow) -> Void) -> ButtonRow { |
|
|
|
static func button(_ title: String? = .none, callback: @escaping (ButtonRow) -> Void) -> ButtonRow { |
|
|
|
let button = ButtonRow(title) |
|
|
|
let button = ButtonRow(title) |
|
|
|
.cellUpdate { cell, _ in |
|
|
|
.cellUpdate { cell, _ in |
|
|
|