Comments (9)
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.
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.
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.
That's true. I suppose this ties in a bit with functionality in FunctionalTableData+Cells.swift
from functionaltabledata.
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.
@g-Off @raulriera any thoughts on this?
from functionaltabledata.
Looks like iOS 13 changes the way highlighting works, which affects CellConfig
s
from functionaltabledata.
Looks like iOS 13 changes the way highlighting works
How did they change?
from functionaltabledata.
For example:
Selections don't show up here using functionalTableData.select(keyPath:animated:)
from functionaltabledata.
Related Issues (20)
- Issues with using FunctionalTableData HOT 6
- Adding support for table row deletion HOT 2
- Deselecting table view cell automatically after selection HOT 4
- Incorrect contentOffset being set on pull-to-refresh
- Usage with Xib HOT 4
- Show example for custom view in readme HOT 1
- Editing style for a row isn't well defined
- Add support for UITableView and UICollectionView prefetch data source
- Convert our keys to being AnyHashable instead of String
- New Difference engine
- Create a "Playground Book"
- Investigate Codable TableSection and CellConfig
- UIContextualAction won't render both image and text if cell is <= 90pts HOT 2
- Touches cancelled when long pressed HOT 3
- Revisit new CellAction previewingViewControllerAction process HOT 1
- DemoApp link is broken HOT 2
- Row deletions - extra argument in call: rowActions HOT 1
- Support CellStyle selected property for UICollectionView. HOT 1
- Module compiled with Swift 5.2.2 cannot be imported by the Swift 5.3.2 compiler HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from functionaltabledata.