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

iOS: table view selection doesn't really work #92

Open
Adlai-Holler opened this issue Jul 9, 2015 · 5 comments
Open

iOS: table view selection doesn't really work #92

Adlai-Holler opened this issue Jul 9, 2015 · 5 comments

Comments

@Adlai-Holler
Copy link
Contributor

@joshaber We call reloadData() every time we diff a TableView, and that kills our selection. I'll work on this one – just putting it here as a reminder.

Current thinking is we need to make Element equatable, and not call reloadData() unless our row data has actually changed. Thoughts?

@ghost
Copy link

ghost commented Jul 9, 2015

Good one

This seems hard to fix because if you want to make Element conform to Equatable you have to check all properties of Element and also all subclasses must overwrite the == func to add checks for their properties.

@joshaber
Copy link
Owner

joshaber commented Jul 9, 2015

Yeah, I'd really like to avoid making Element Equatable for those reasons ☝️

@joshaber
Copy link
Owner

joshaber commented Jul 9, 2015

On Mac we save and restore the selected indexes: https://github.com/joshaber/Few.swift/blob/221ff4ccf6c339bb7d815398614556b07a80073d/Few-Mac/TableView.swift#L53-56 Could we do that on iOS too?

@aocenas
Copy link

aocenas commented Dec 11, 2015

@Adlai-Holler you can do something like this to preserve the selection:

            TableView([state.elements],
                selectedRow: state.selected,
                selectionChanged: { [unowned component] indexPath in
                    component.updateState { state in
                        var state = state
                        state.selected = indexPath
                        return state
                    }
                })
struct AppState {
    var elements: [Element]
    var selected: NSIndexPath?
}

To me it seems ok that elements do not have state. You can make component that wraps TableView element and adds state in this way. Otherwise leaving state management to native implementation of UITableView seems to me like leaky abstraction.

@Rene759
Copy link

Rene759 commented May 3, 2016

Hi there!!!
My name is Patrick and i'm begin in coding, i was hoping if it's possible if you can help me to understand how this github work, and what it does basically.

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

No branches or pull requests

4 participants