Reputation: 2924
I have this SelectableSection
with Images in my Eureka form.
+++ SelectableSection<ImageCheckRow<String>>("Τρόπος Αποστολής", selectionType: .singleSelection(enableDeselection: true)) { section in
section.tag = "troposapostolis"
}
<<< ImageCheckRow<String>("speedex"){
$0.title = "Σταθερή Χρέωση - 3,00€\n SPEEDEX (Για όλη την Ελλάδα)"
$0.selectableValue = ""
$0.value = nil
}.cellSetup { cell, _ in
cell.trueImage = UIImage(named: "selectedRectangle")!
cell.falseImage = UIImage(named: "unselectedRectangle")!
}.onCellSelection({ (cell, row) in
row.title = "speedex"
row.selectableValue = "selectedspeedex"
})
<<< ImageCheckRow<String>("paradosi"){
$0.title = "Αυθημερόν Παράδοση - 6,00€\n Ισχύει για ορισμένες περιοχές εντός Αττικής. Υποβολή παραγγελίας μέχρι τις 14:00."
$0.selectableValue = ""
$0.value = nil
}.cellSetup { cell, _ in
cell.trueImage = UIImage(named: "selectedRectangle")!
cell.falseImage = UIImage(named: "unselectedRectangle")!
}.onCellSelection({ (cell, row) in
row.title = "paradosi"
row.selectableValue = "selectedparadosi"
})
And I want to update another section when the user taps any of the above selections. This is the section->custom cell I want to update
+++ Section("summary")
<<< SummaryPuchaseRow().cellUpdate({ (cell, row) in
cell.merikoSinolo.text = "\(self.realmfunctions.getAmount())€"
cell.sum.text = "" \\value depending on the image selected
})
So if the user taps the first row on the SelectableSection
I would like the
cell.sum.text = "3"
And if the user taps the second row in the SelectableSection
I would ike the
cell.sum.text = "6"
Is there any efficient way to do so ?? Thanks a lot!
Upvotes: 1
Views: 802
Reputation: 20804
You need use a tag, to get your cell from Form in the onCellSelection
search for your cell with tag defined, and getting the cell change the value on the control in this case sum.text
, here is the code
+++ SelectableSection<ImageCheckRow<String>>("Τρόπος Αποστολής", selectionType: .singleSelection(enableDeselection: true)) { section in
section.tag = "troposapostolis"
}
<<< ImageCheckRow<String>("speedex"){
$0.title = "Σταθερή Χρέωση - 3,00€\n SPEEDEX (Για όλη την Ελλάδα)"
$0.selectableValue = ""
$0.value = nil
}.cellSetup { cell, _ in
cell.trueImage = UIImage(named: "selectedRectangle")!
cell.falseImage = UIImage(named: "unselectedRectangle")!
}.onCellSelection({ (cell, row) in
row.title = "speedex"
row.selectableValue = "selectedspeedex"
if let summaryRow = self.form.rowBy(tag: "important") as? SummaryPuchaseRow
{
if let baseCellSummary = summaryRow.baseCell as? ???? //ATTENTION!!! put here your cell type name
{
baseCellSummary.sum.text = "3"
}
}
})
<<< ImageCheckRow<String>("paradosi"){
$0.title = "Αυθημερόν Παράδοση - 6,00€\n Ισχύει για ορισμένες περιοχές εντός Αττικής. Υποβολή παραγγελίας μέχρι τις 14:00."
$0.selectableValue = ""
$0.value = nil
}.cellSetup { cell, _ in
cell.trueImage = UIImage(named: "selectedRectangle")!
cell.falseImage = UIImage(named: "unselectedRectangle")!
}.onCellSelection({ (cell, row) in
row.title = "paradosi"
row.selectableValue = "selectedparadosi"
if let summaryRow = self.form.rowBy(tag: "important") as? SummaryPuchaseRow
{
if let baseCellSummary = summaryRow.baseCell as? ???? //ATTENTION!!! put here your cell type name
{
baseCellSummary.sum.text = "3"
}
}
})
And you need setup a tag for your SummaryRow, in this example I use "important" as tag
+++ Section("summary")
<<< SummaryPuchaseRow(tag: "important").cellUpdate({ (cell, row) in
cell.merikoSinolo.text = "\(self.realmfunctions.getAmount())€"
cell.sum.text = "" \\value depending on the image selected
})
I hope this helps you, best regards
Upvotes: 2