Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge-to-edge cell separator / margin bug with picker rows #438

Closed
plastus opened this issue May 19, 2016 · 5 comments
Closed

Edge-to-edge cell separator / margin bug with picker rows #438

plastus opened this issue May 19, 2016 · 5 comments

Comments

@plastus
Copy link

plastus commented May 19, 2016

When setting up code to allow for edge-to-edge separators, any picker rows (date, generic, etc.) do not conform to the newly set rules.

    tableView!.layoutMargins = UIEdgeInsetsZero
    tableView!.separatorInset = UIEdgeInsetsZero

    TestRow.defaultCellSetup = { cell, row in
        cell.contentView.layoutMargins.left = 0
        cell.layoutMargins = UIEdgeInsetsZero
        cell.datePicker.layoutMargins = UIEdgeInsetsZero
        cell.preservesSuperviewLayoutMargins = false
    }

Example below:

eureka_margin_bug

Edit: Is there any way to preserve actual text margins and ONLY make the separator line edge-to-edge? I've tried every imaginable combination of settings on the tableView and cell itself, but I can't get it to work right.

@plastus plastus changed the title Margin bug w/ picker rows Edge-to-edge cell separator / margin bug with picker rows May 19, 2016
@mtnbarreto
Copy link
Member

I have never tried to change the cell margin yet.
Could you provide me more info about what you want to do, what you expect and what you got.
Have you implemented TestRow ?
Please point out the issue on image provided.

@plastus
Copy link
Author

plastus commented May 20, 2016

That's "TextRow"...sorry, my mistake when typing up the code.

I'm trying to get this look:

1-qcz0bkm73uwqwj_cie14sq

What happens when I use the commonly referenced ways of accomplishing this is that not all the rows conform to the zero inset margin. Ideally I would want to retain the actual text margins from left/right as they are by default in Eureka, and ONLY extend the cell separator so that it spans the entire width of the screen.

@mtnbarreto
Copy link
Member

mtnbarreto commented May 20, 2016

Try using this code...

    override func viewDidLoad() {
        super.viewDidLoad()
        tableView?.separatorInset = UIEdgeInsetsZero //  Add this line on each FormViewController
        // ... 
     }


// The following code should be executed before loading any form view controller. 
// It will set up layout properties for the whole app. Missing rows/custom rows types should be added. 
// I tested it against Eureka example app and it works like a charm.

        TextRow.defaultCellSetup = { cell, row in
            cell.preservesSuperviewLayoutMargins = false
            cell.layoutMargins.left = 0
            cell.contentView.preservesSuperviewLayoutMargins = false
            cell.contentView.layoutMargins.left = 50
        }

        ButtonRow.defaultCellSetup = { cell, row in
            cell.preservesSuperviewLayoutMargins = false
            cell.layoutMargins.left = 0
            cell.indentationLevel = 5
        }

        SwitchRow.defaultCellSetup = { cell, row in
            cell.preservesSuperviewLayoutMargins = false
            cell.layoutMargins.left = 0
            cell.indentationLevel = 5
        }

        DateTimeInlineRow.defaultCellSetup = { cell, row in
            cell.preservesSuperviewLayoutMargins = false
            cell.layoutMargins.left = 0
            cell.indentationLevel = 5
        }


        DateRow.defaultCellSetup = { cell, row in
            cell.preservesSuperviewLayoutMargins = false
            cell.layoutMargins.left = 0
            cell.indentationLevel = 5
        }

        DateTimeRow.defaultCellSetup = { cell, row in
            cell.preservesSuperviewLayoutMargins = false
            cell.layoutMargins.left = 0
            cell.indentationLevel = 5
        }

        PickerInlineRow<NSDate>.defaultCellSetup = { cell, row in
            cell.preservesSuperviewLayoutMargins = false
            cell.layoutMargins.left = 0
            cell.indentationLevel = 5
        }

As you may have seen, indentationLevel does not work for every cell and sometimes cell.contentView.layoutMargins.left = 50 should be used as TextRow.defaultCellSetup shows. I think this is because TextRow cell is not a pure build-in cell, we are making some changes on textLabel, in particular in its constraint.

Let me know if this works.

@plastus
Copy link
Author

plastus commented May 23, 2016

Thanks, I wasn't able to get the Date/Picker rows to allow zero margins with any combination of properties on the cell/contentview, etc. So what I did was approximate what the gap is on the left (~15px) and set all the other cells to use that for the left/right margins. I think it looks better anyway, because it gives it a slight indentation underneath the header/section.

End result is that I have edge-to-edge separators and I maintained the default padding on left/right. :) 👍

One issue: How to adjust margin for footer now? Because all footer text starts at the very left edge. Padding is gone.

@mats-claassen
Copy link
Member

Headers and footers are managed by UIKit if you use a simple string. If you use custo =m views then you should be able to align it to your rows.

Anyway we have fixed some misalignments since this issue was opened. I will close this issue. If any new issue arises please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants