Giter VIP home page Giter VIP logo

splitrow's People

Contributors

dean151 avatar elgartoinf1 avatar jimisaacs avatar joshatpci avatar kamerc avatar marbetschar avatar wimzee-rcheng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

splitrow's Issues

Support inline rows?

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...

Parsing values from a SplitRow.

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.

Add validation support to SplitRow

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")
}
}
Screenshot 2019-08-25 at 22 21 27

I would like:

  1. 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.

  2. 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 :)

Right and left margins of SplitRow

The SplitRow does not align with other rows from Eureka. Both left and right sides are closer to the edges than the normal TextRow. It's not much but a couple of pixels on both sides.

image

Otherwise a great addition to Eureka

Keyboard hides SplitRow

As soon as the keyboard gets visible, the SplitRow should be moved if necessary to avoid having the keyboard hiding the SplitRow.

sigbart error

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

How to dynamically create two columns at runtime

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"
        }
   }
}

Set cell.backgroundColor in .cellSetup not working

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
            }
            
        }

Setting keyboardType

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?

Indexpath of row

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

Change background color of a SplitRow?

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

Values are getting cleared if one of the row types is ActionSheet

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
    }
}

Is there a way to remove separator line between the 2 rows?

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!

Set SegmentedRow value

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?

Solving the warning

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

Wrong background color in iOS13 darkmode

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!

CleanShot2019-11-05at21 02 13

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)
            }

SplitRow + ImageRow is not displaying properly

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.

Add form navigation support

SplitRow should support the navigation with the keyboard accessory buttons <, > - as well as the Next button.

Disable Split Row

Hi! I wanted to know how can I disable only one element (i.e row) in split row? Currently if set rowLeft or rowRight to disable = true, the row still is editable. See the attached screenshot link.

Screenshot 2021-08-31 at 3 54 35 PM

Cocoapods support

I have all the requirements as mentioned but still i cannot use SplitRow in my project.

TextRow (when used in SplitRow) is not able to render Korean string correctly

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)

Screen Shot 2019-09-17 at 10 29 41 PM

rowLeft / rowRight flexible row type?

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?

Generic split row funtion

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.