Skip to content

Conversation

@Senbazuru1075
Copy link
Collaborator

pinterest layout

@Senbazuru1075 Senbazuru1075 requested a review from cjc8 January 5, 2022 00:27
Copy link
Contributor

@cjc8 cjc8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job getting it to work, I just want to make it a little more customizable, giving the user the ability to set the number of columns in different ways.

@Senbazuru1075 Senbazuru1075 requested a review from cjc8 January 5, 2022 20:05
Copy link
Contributor

@cjc8 cjc8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it needs a rebase. A lot of the changes that have previously been merged in are not implemented.

Copy link
Contributor

@cjc8 cjc8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's something weird going on with your repo, your latest commit doesn't have anything to do with the Pinterest stuff and deletes some of the changes we've merged recently

@Senbazuru1075 Senbazuru1075 requested a review from cjc8 January 9, 2022 15:34
Copy link
Contributor

@cjc8 cjc8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closer! Don't get discouraged, this is a big project and would take many iterations for either me or Elliot.

@Senbazuru1075 Senbazuru1075 requested a review from cjc8 January 11, 2022 15:24
Copy link
Contributor

@cjc8 cjc8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closer! Have you been trying to use this layout in that test project you were using? If not, I'd recommend doing so so we can make sure it works

offSet = columnWidth
for column in 0..<columnCount {
let width = (widthForColumn ?? { _ in return 0 })(setWidthForColumn ?? 0) ?? offSet
xOffSet.append(width * CGFloat(column))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this will work. The idea for the widthForColumn function is to allow users multiwidth columns, where they can be like 'I want column 1 to be 100 wide, and column 2 to be 50 wide. In that case, we we need our xOffsets to be [0, 100], but this code will generate [0,50]. Using this function will have to change the way that we generate our offsets (not just taking the width and multiplying by the column number).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Calvin,

if you haven't ran that code then do try and run it. It compiles and it works. The only thing it doesn't do is set the width for multiple sizes. I think it takes a variadic parameter though so it would be on the user to calculate and return the array.

I've ventured into making the requirement change you want and swift just doesn't support the functionality you're asking for. Swift gives me a compile error that says it cannot accept variadic tuples.

You can review the code I currently have to see what I'm doing when we meet at 12pm PST. The functionality is pretty much impossible. It's too much calculating for the compiler and trees to calculate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you change your requirements to a limit like 3 columns then it should work, but you need to limit the number of columns for the iOS device.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something along these lines is what I'm thinking:


func xOffsets(numCol: Int, widthForColumn: (Int) -> CGFloat?) -> [CGFloat] {
    var offsets: [CGFloat] = [0.0]
    for i in 0..<numCol - 1 {
        let width = widthForColumn(i) ?? 50.0
        offsets.append(offsets.last! + width)
    }
    return offsets
}

I highly doubt it has to do with whether or not it's 'possible', I think it's more likely that I'm not explaining what I want clearly enough

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The part we were debating about is where it broke when I texted you. The way I'm doing it makes it work. The only thing that is messed up is device orientation. However, we need to recalculate X and Y offsets on device orientation change.

I don't know what to call for that to get it to recalculate because it doesn't currently do it yet.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants