eurekacommunity / splitrow Goto Github PK
View Code? Open in Web Editor NEWA row for Eureka to put two rows side by side into the same UITableViewCell
License: MIT License
A row for Eureka to put two rows side by side into the same UITableViewCell
License: MIT License
SPM support have been merged in main branch.
But no release tag were created since then.
Please to fully support SPM, tag a new release
Currently, if I use inline rows as the left/right row, I can't expand them:
form +++ Section()
<<< SplitRow<PickerInlineRow<String>,TextRow>(){
$0.rowLeft = PickerInlineRow<String>(){
$0.title = "Choice 1"
$0.options = ["A","B","C"]
$0.value = "A"
}
$0.rowRight = TextRow(){
$0.title = "Hello"
}
$0.rowLeftPercentage = 0.5
}
Any plans to support them? I mean I could replace it with a PushRow
, but bringing the user to another VC seems a bit to heavyweight for what I am doing...
All other community listings are published on Cocoapods.org - it does seem to be the more popular package manager.
Such like PostalAddressRow
. Maybe this is related to the constraints errors of #4
Hi there,
I've decided to utilize splitRow in a project so some fields can be optional, so I am using splitRow with a <SwitchRow, DecimalRow> for example.
I want to parse the entire form when the user has submitted, however I'm having trouble getting data from the SplitRow's like I normally would in a non split-row.
My form looks like: https://i.imgur.com/jUS8lWg.png
When I print out the form data to the console, it looks like:
[
"postAs": Optional("The Byron List"),
"postDescription": Optional("Test details"),
"splitRowURL": Optional(SplitRow.SplitRowValue<Swift.Bool, Swift.String>(left: Optional(true), right: Optional("Www.fun.com"))),
"saveButton": nil, "title": Optional("Test Title"),
"splitEvent": Optional(SplitRow.SplitRowValue<Swift.Bool, Swift.String>(left: Optional(true), right: nil)),
"splitRowPrice": Optional(SplitRow.SplitRowValue<Swift.Bool, Swift.Double>(left: Optional(true), right: Optional(5.55))),
"splitLocation": Optional(SplitRow.SplitRowValue<Swift.Bool, __C.CLLocation>(left: Optional(true), right: Optional(<-28.63381450,+153.63690625> +/- 0.00m (speed -1.00 mps / course -1.00) @ 12/16/19, 2:21:24 PM Australian Eastern Daylight Time)))]
and this code:
private func parsePost(formData : [ String : Any? ]) -> [String : String] {
let splitRowPrice = formData["splitRowPrice"]
//returns nil: as? SplitRowValue<Bool,String>
print(splitRowPrice)
return ["hello" : "kitty"]
}
will print out the splitRowPrice as:
Optional(Optional(SplitRow.SplitRowValue<Swift.Bool, Swift.Double>(left: Optional(true), right: Optional(242.34))))
I just don't know how exactly I get the the left and right values!! Casting as a SplitRow<SwitchRow, DecimalRow>
and variations will give me a nil value, and I'm just not sure exactly how to get the values from the form. Please help!
Thanks.
Please advise
Hello.
Thank you for the very useful SplitRow extension.
How I can validate text content (required) of left TextRow?
I added validation logic on rowLeft (TextRow) : row.onRowValidationChanged(self.validateNoteButtonRow)
func validateNoteButtonRow(_ cell: TextCell, _ row: TextRow) {
if let noteRow = self.form.rowBy(tag: "addNote") as? SplitRow<TextRow,ButtonRow> {
let rowIndex = noteRow.indexPath!.row
while noteRow.section!.count > rowIndex + 1 && noteRow.section?[rowIndex + 1] is LabelRow {
noteRow.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 = { 30 }
$0.cell.backgroundColor = .red
$0.cell.textLabel?.tintColor = .white
}
let indexPath = noteRow.indexPath!.row + index + 1
noteRow.section?.insert(labelRow, at: indexPath)
}
}
} else {
Log.debug("Validation: SplitRow nil")
}
}
I would like:
to do it as the Eureka example that pop ups a label with message below of the SplitRow: I succeeded with that using your hints from another issue. The validation is activated when starting to type text.
To make the above validation to execute when I call self.form.validate() because the user can press an ADD button to add what is in TextRow on a list. When the user press ADD, I would like to force validation. For the moment, when I call self.form.validate() only validations created in other basic fields of the form are called. Maybe SplitRow validation is not called because it is included/defined only in let TextRow? Another thing that I tried was to force call validation code but it did not work... Code below did not succeeded to call validation of TextRow field:
// if let noteRow = self.form.rowBy(tag: "addNote") as? SplitRow<TextRow,ButtonRow>, let row = noteRow.rowLeft as TextRow? {
// Log.debug("VitalSignsViewController: checkIsEmpty: note field/row found")
// self.validateNoteButtonRow(row.cell, row)
// }
Thank you very much in advance :)
DecimalRow not worked
As soon as the keyboard gets visible, the SplitRow
should be moved if necessary to avoid having the keyboard hiding the SplitRow
.
me got error like below when running an example. i'm new to this. help pls.
dyld: Library not loaded: @rpath/SplitRow.framework/SplitRow
Referenced from: /var/containers/Bundle/Application/5F0927C0-7C88-4336-9A31-AB212DD86158/Example.app/Example
Reason: image not found
Hello,
I'm trying to hide only the right row but is not working. Is that possible with SplitRow?
Thanks
We should expose the possibility to set the SeparatorStyle for the SplitRow with a public property called separatorStyle
which subsequently sets the tableViewRight.leftSeparatorStyle
to the user defined value:
SplitRow/SplitRow/SplitRowCell.swift
Lines 32 to 33 in b60b6ab
@marbetschar Do you have some time to upgrade it?
I am creating a form builder and I want to create a form with two columns based on given JSON data. The issue is that my method decides on runtime which form item (like TextRow, NameRow etc) is to be rendered so I need to provide some base class/interface to SplitView like in the following way:
SplitRow<BaseRow,BaseRow>(){
$0.rowLeft = getFormField(fieldToRender: "Text Area") as? TextAreaRow // getFormField decides on runtime which type of field to render i.e TextRow and returns BaseRow type.
$0.rowRight = getFormField(fieldToRender: "Text Row") as? TextRow
}
But the above code gives the following error:-
Type 'BaseRow' does not conform to protocol 'RowType'
I want that somehow I can give a base class to Split row so it can infer class (form item) at runtime as Eureka does, if I pass BaseRow to Eurekas <<< operator it dynamically renders the field base on given sub class. Following is Eureka's example that accepts BaseRow class and renders given form filed, TextRow or PickerInputRow or any other class:
form.last! <<< getFormField(fieldToRender: "Text Field")
For refrence i have added getFormField() method:-
func getFormField(fieldToRender: String) -> BaseRow {
if fieldToRender == "Text Area" {
return TextAreaRow(){
$0.title = "Title"
$0.value = "Value"
}
}else{
return TextRow() {
$0.title = "Title"
$0.value = "Value"
}
}
}
Hi there,
I might be doing it wrong, but when I set up one of my splitcells, the .cellSetup method does not appear to be applied to my splitCell.
e.g. the cell background colour for my right row will stay white. This is how I normally set up cells that are not in a splitCell configuration.
<<< SplitRow<SwitchRow, TextRow>(){
$0.rowLeftPercentage = 0.2
$0.rowLeft = SwitchRow() {
$0.value = false
$0.tag = "isEventSet"
}
$0.rowRight = TextRow(){ row in
row.title = "TEST"
row.tag = "TEST"
}.cellSetup { cell, row in
cell.backgroundColor = .red
}
}
Hi there,
I'm having an issue setting the keyboard type when using a TextRow contained within a splitRow..
For example, the keyboard type in the following is not being observed:
<<< SplitRow<TextRow, TextRow>() {
$0.tag = "SplitAddressLine2"
$0.rowLeftPercentage = 0.7
$0.hidden = true
$0.rowLeft = TextRow() {
$0.placeholder = "Town" //Working
$0.tag = "town"
}
$0.rowRight = TextRow() {
$0.tag = "postcode"
$0.cell.textField.keyboardType = .numberPad //Not working
$0.placeholder = "Postcode" //Is working
}.cellSetup {cell, row in
cell.textField.keyboardType = .numberPad //Also Not working
}
}
The placeholder text is being set correctly, but the keyboard type is not.
Where in a basic TextRow, outside of a SplitRow, the keyboard type is being set correctly. e.g.
<<< TextRow() { row in
row.placeholder = "TEST"
row.cell.textField.keyboardType = .numberPad //Works
}
How can I get the TextRow to show the correct keyboardType?
Hey there,
Trying to fetch the indexpath of the row to validate an error of the right row. Unsure of how to add another row below it.
Thx
Is there a way to change the background color of a split row, either each cell individually or both at the same time? I have spent a while trying to change just about every .backgroundColor property I could find with no luck.
Thanks,
Josh
I have 3 types of SplitRows in my app:
SplitRow<ActionSheetRow, EmailRow>
SplitRow<ActionSheetRow, PhoneRow>
SplitRow<TextRow, TextRow>
I am seeing an issue with the first 2. The scenario is that the user opens an edit modal and the SplitRows with existing values are loaded just fine (all the types and values are populated for email and phone). However, if I go to change the value of the type within action sheet (aka I change the left side), the value on the right side clears. If I had changed the value on the right initially instead, the left side clears. If I override the code to not call subscribe for onChange at all, it works perfectly.
I am having the same issue when I go to move focus off of this row entirely. When I do, both values (left and right) are cleared. This particular issue wasn't happening until I got your latest update. If I override the code to not call subscribe for onCellHighlightChanged, it works perfectly.
I have not seen this weird behavior when both types are TextRow, only when both contain an ActionSheet. I have not tested PushRow but I suspect it may be similar.
So I have got around my issue by creating my own custom class but it's not an ideal solution. Can you tell me what the purpose of the code for onChange and onCellHighlighted is? Since it works perfect without it, I haven't figured out what the purpose of the code is. I am NOT using any custom tag names or anything like that.
This is my simple custom class that I'm using now to get it working as I would expect in all cases:
import Foundation
import Eureka
import SplitRow
public final class OrionSplitRow<L: RowType, R: RowType>: _SplitRow<L,R>, RowType where L: BaseRow, R: BaseRow {
override public func subscribe<T>(onChange row: T) where T : BaseRow, T : RowType {
//Do nothing
}
override public func subscribe<T>(onCellHighlightChanged row: T) where T : BaseRow, T : RowType {
//Do nothing
}
}
I can remove the separator lines from the top and bottom of the rows using:
self.tableView?.separatorStyle = .none
But it doesn't remove the lines between the 2 rows in the splitRow row..
Any ideas?
BTW Thanks a lot for this very useful row!
Instead of using Cocoapod, can we support Carthage?
In an attempt of creating a segmentedRow, I've got:
'SplitRow' requires that 'SegmentedRow' inherit from 'BaseRow.'
so I turned it back as a simple base row of Eureka.
Now for filling the form with stored values, I follow the method which has been covered in other issues:
let rw = form.rowBy(tag: spltKey) as! SplitRow<TextRow,LabelRow>
rw.value?.left = vl.value as! String
However, I cannot set the SegmentedRow value like this. Is there any way to set the value for specific BaseRow (instead of the whole form by form.setValues(storedValue) ) or make this row as a splitRow and follow the same approach for setting values?
Hello,
Thank you for the SplitRow code. I get an xcode warning (acknowledged in the code):
Cast from 'RowOf<SplitRowValue<L.Cell.Value, R.Cell.Value>>!' to unrelated type '_SplitRow<L, R>' always fails
Is there a way to solve this warning as it is distracting and it is harder to tell if there are other warnings that deserve our attention.
Thanks
HI there,
I just updated to version 2.1.0 but I still got a strange issue:
When the dark mode is activated I get a wrong background color for Rows which are embedded in the Splitrow (see Screenshot)
Is this working as expected or really an issue? How can I change the background color so that it matches that of the "Feedback button"?
Thank you in advance!
My code setup looks like this:
<<< SplitRow<ButtonRow, ButtonRow>(){
$0.rowLeftPercentage = 0.5
$0.rowLeft = ButtonRow() {
$0.title = "Show Intro"
$0.onCellSelection(self.openIntro)
}
$0.rowRight = ButtonRow() {
$0.title = "Whats new?"
$0.onCellSelection(self.openWhatsNew)
}
}
<<< ButtonRow() {
$0.title = "Feedback"
$0.onCellSelection (self.sendMail)
}
For Eureka rows:
// Get the value of a single row
let row: DateInlineRow? = form.rowBy(tag: "date")
let dateValue = row?.value
but i cant get it for SplitRow
Please advise
Hi,
I tried the following:
`
<<< SplitRow<ImageRow,ImageRow>() {
$0.baseCell.height = {
return 200
}
$0.rowLeft = ImageRow(){
$0.title = "Cheque"
$0.sourceTypes = [.Camera, .PhotoLibrary]
$0.clearAction = .yes(style: UIAlertActionStyle.destructive)
$0.add(rule: RuleRequired())
}.cellUpdate { cell, row in
if !row.isValid {
cell.textLabel?.textColor = .red
} else {
cell.textLabel?.textColor = .black
}
cell.height = {
return 200
}
cell.accessoryView?.layer.cornerRadius = 5
cell.accessoryView?.frame = CGRect(x: 0, y: 0, width: 180, height: 180)
}
$0.rowRight = ImageRow(){
$0.title = "ID"
$0.sourceTypes = [.Camera, .PhotoLibrary]
$0.clearAction = .yes(style: UIAlertActionStyle.destructive)
$0.add(rule: RuleRequired())
}.cellUpdate { cell, row in
if !row.isValid {
cell.textLabel?.textColor = .red
} else {
cell.textLabel?.textColor = .black
}
cell.height = {
return 200
}
cell.accessoryView?.layer.cornerRadius = 5
cell.accessoryView?.frame = CGRect(x: 0, y: 0, width: 180, height: 180)
}
`
But the height is weird and uncontrollable, something overrides the height of the ImageRow.
BTW: It doesn't work even if the height is unchanged.
Tag commits intended as separate releases.
SplitRow should support the navigation with the keyboard accessory buttons <
, >
- as well as the Next
button.
I have a use case in which my title is for text row is large. I want to ask that how can I make my title of TextRow in two lines?
Thanks!
Similar to the Eureka issue listed here: xmartlabs/Eureka#1910
Except SplitRow
seems to create a dual stepper control.
eg.
let signNumberQuantityRow = SplitRow<TextFloatLabelRow, StepperRow>() { row in
I have all the requirements as mentioned but still i cannot use SplitRow in my project.
SplitRow<TextRow, LocationRow> { $0.rowLeftPercentage = 0.65 $0.rowLeft = TextRow("locationText") { $0.placeholder = placeholder if let name = value?.name { $0.value = name } if isDisabled { $0.disabled = true } } $0.rowRight = LocationRow("locationLookup") { $0.shouldDisplayValue = false $0.title = title if let value = value { $0.value = value } else { $0.value = Place(address: nil, coordinates: nil, name: nil) } if isDisabled { $0.disabled = true } } }
Actual String when user types into the TextRow: 시ㅇ
Expected String: 설 (above characters should build this string)
SplitRow is an awesome addition to Eureka. But I don't suppose it's possible yet to change the row type of rowRight based on (for example) a selection from a PushRow at the rowLeft, is it?
So take your basic usage example, imagine you select "Work" from the selector at your left. Based on this selected value the rowRight changes from a TextRow into a PushRow where a corresponding value can be selected for Work, or perhaps a switch row, etc.
Any pointers to how something like this could be implemented?
Anyway to make adding a split row more generic?
For example...
form +++ SplitRow<TextFloatLabelRow, TextFloatLabelRow>() {...}
this requires that TextFloatLabelRow be explicitly stated. I would like to do something like...
form +++ SplitRow<rowA, rowB>() {...}
this would allow rowA to be TextRow,EmailRow, Phone row, etc.
Any ideas? Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.