GithubHelp home page GithubHelp logo

Comments (9)

g-Off avatar g-Off commented on April 30, 2024

Contemplating this one a bit now. If we hook into it with an action similar to SelectionAction you lose a bit of the type safety in that your view would come through as a UIView and would require a force/optional cast to the expected type before digging into the view hierarchy to manipulate backgroundColor.

I wonder if we should change the signature of the update function:
func update(cell: UITableViewCell, in tableView: UITableView)

to be more along the lines of
func update(cell: UITableViewCell, in tableView: UITableView, context: UpdateContext)

UpdateContext could then be something along the lines of

enum UpdateContext {
    case default // the regular old case of just updating the data
    case selection // maybe?
    case highlight
    case ... // I don't know, are there more cases? begin a drag? move? edit mode initiated on the table...
}

FunctionalTableData Delegate/Datasource's would then, on highlight/select/etc calls trigger this.
HostCell would then have its own implementation of this and the cellUpdater function would be extended to support the context argument. This would then mean that the update function would be passed a concrete view type, the state, and the context.

I think this could be introduced in a backwards compatible way as well.

@runmad thoughts?
@raulriera could use your opinions here as well

from functionaltabledata.

runmad avatar runmad commented on April 30, 2024

I really like that suggestion!

With the actions, I definitely feel like we're missing parts of what comes for free with UITableViewCell callbacks on selection and highlighting within the view itself.

I think starting with selection/highlighting seems appropriate for now and more closely resemble
func setSelected(Bool, animated: Bool) and func setHighlighted(Bool, animated: Bool).

Is this somewhat related to #54?

from functionaltabledata.

g-Off avatar g-Off commented on April 30, 2024

The highlight delegate methods are:

func tableView(_ tableView: UITableView, shouldHighlightRowAt indexPath: IndexPath) -> Bool
func tableView(_ tableView: UITableView, didHighlightRowAt indexPath: IndexPath)

returning false on the shouldHighlightRowAt "halts the selection process and does not cause the currently selected row to lose its selected look while the touch is down"

didHighlightRowAt might be called after the highlight is finished, which is possibly too late and the highlight animation on the cell may have finished. I don't currently have time at the moment to dig into the nuances of these functions vs UITableViewCell's func setHighlighted(_ highlighted: Bool, animated: Bool). If the delegate one triggers at the right time then that's the better one to tie into as it would no longer require any special implementation on the cell level. If the setHighlighted is the right spot then we'd need to have our TableCell implementation (that backs HostCell) implement that behaviour (a bit more annoying but doable as well).

And yeah, this could be somewhat related to #54 as it could be one of the cases used in the Context enum

from functionaltabledata.

runmad avatar runmad commented on April 30, 2024

That's true. I suppose this ties in a bit with functionality in FunctionalTableData+Cells.swift

from functionaltabledata.

raulriera avatar raulriera commented on April 30, 2024

The Context change will be a good addition, but complexity for implementing a cell will skyrocket. Now we are dealing with many more "states". I would be inclined for some magic here, an UIView extension for shouldHighlightItem and didHighlightItem that HostCell automatically call to all its subviews.

This will have to work with highlight from CellStyle to shut it down I assume, otherwise we will have multiple "highlight" API

from functionaltabledata.

runmad avatar runmad commented on April 30, 2024

@g-Off @raulriera any thoughts on this?

from functionaltabledata.

runmad avatar runmad commented on April 30, 2024

Looks like iOS 13 changes the way highlighting works, which affects CellConfigs

from functionaltabledata.

raulriera avatar raulriera commented on April 30, 2024

Looks like iOS 13 changes the way highlighting works

How did they change?

from functionaltabledata.

runmad avatar runmad commented on April 30, 2024

For example:

Selections don't show up here using functionalTableData.select(keyPath:animated:)
image

and when tapping:
image

from functionaltabledata.

Related Issues (20)

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.