Comments (14)
Hi @wdcurry,
Here is an example of row deletion:
let row = TableRow<MyCell>(item: /*...*/)
let canDeleteAction = TableRowAction<MyCell>(.canDelete) { (options) in
return true
}
let deleteAction = TableRowAction<MyCell>(.clickDelete) { [weak self] (options) in
self?.tableDirector.sections[options.indexPath.section].delete(rowAt: options.indexPath.row)
self?.tableView.beginUpdates()
self?.tableView.deleteRows(at: [options.indexPath], with: .automatic)
self?.tableView.endUpdates()
}
row.on(canDeleteAction)
row.on(deleteAction)
tableDirector += row
Hope it helps!
from tablekit.
This is awesome, thank you. I must have had a typo as I tried the original "return true" but received a compile error. Once I get tested, I will consider Dwiff as it is just so slick, as is TableKit.
from tablekit.
Perhaps my bits are not up-to-date, as I cannot assign a return value to canDeleteAction. This is what through me off the trail to begin with. The workflow is a bit unintuitive as the delete action in canDeleteAction is more an attribute than an action. Perhaps an evolution to allow us to pass in an array of attributes might make this tighter?
My pod line is: pod 'FileKit' and the laptop is new so I should have the latest. I trust my cell definition is not involved in the issue as it is only a T ..
edit: I had dropped a print() within the canDeleteAction closure and that was throwing it off, I can now proceed ;) to test.
from tablekit.
For completeness, as I typically work with arrays of records that feed my tables, I ended up with
for video in self.recentVideos { rows.append( TableRow<RecentVideoTableViewCell>(item: video, actions: [action, canDeleteAction, deleteAction]) ) }
. *yes, my formatting skills here suck at present ;)
from tablekit.
The workflow is a bit unintuitive as the delete action in canDeleteAction is more an attribute than an action.
The original idea behind all those actions is how UITableViewDelegate
operates with that. Take a quick look at shouldHighlightRowAt/willSelectRowAt
and all other methods. It's just one delegate and so many responsibilities...
At the moment of implementing I just followed simplicity and wrapped everything under Action
kind of thing. Probably, it could have been done better by grouping actions some how, or even introduce some kind of Attributes
. But I don't have such plans. It's good idea to document things better anyway.
from tablekit.
Thanks Max, you did a great job, and I like it. Once I get a bit of time, I will see about integrating Dwiff into the mix, which should allow even greater ease. The idea being that by simply managing the actual data itself will then be reflected into the tableview, which is a true plumber's helper.
from tablekit.
@maxsokolov Здравия желаю. Подскажи пожалуйста как изменять название "кнопки" удаления по свайпу с помощью TableKit ? Мне надо локализацию добавить
from tablekit.
@maxsokolov Здравия желаю. Подскажи пожалуйста как изменять название "кнопки" удаления по свайпу с помощью TableKit ? Мне надо локализацию добавить
@Majituteniyazov привет! Из коробки этой функции нет, придется наследоваться от TableDirector
и добавить ему в наследнике реализацию метода. Чтобы управлять title можно будет реализовать кастомный action. См исходник как там реализованы методы data source и delegate.
from tablekit.
@maxsokolov хорошо, спасибо, постараюсь сделать
@maxsokolov Здравия желаю. Подскажи пожалуйста как изменять название "кнопки" удаления по свайпу с помощью TableKit ? Мне надо локализацию добавить
@Majituteniyazov привет! Из коробки этой функции нет, придется наследоваться от
TableDirector
и добавить ему в наследнике реализацию метода. Чтобы управлять title можно будет реализовать кастомный action. См исходник как там реализованы методы data source и delegate.
from tablekit.
@maxsokolov Приветствую! Мы уже как-то общались на тему кастомного тайтла выше.
Подскажи можно ли как-либо кастомизировать TableRowAction ?
Я хотел бы добавить туда пару других еще экшенов
from tablekit.
@maxsokolov Приветствую! Мы уже как-то общались на тему кастомного тайтла выше.
Подскажи можно ли как-либо кастомизировать TableRowAction ?
Я хотел бы добавить туда пару других еще экшенов
Не очень понимаю, что значит кастомизировать? Лучше рассмотреть на примере, что требуется сделать.
from tablekit.
@maxsokolov Приветствую! Мы уже как-то общались на тему кастомного тайтла выше.
Подскажи можно ли как-либо кастомизировать TableRowAction ?
Я хотел бы добавить туда пару других еще экшеновНе очень понимаю, что значит кастомизировать? Лучше рассмотреть на примере, что требуется сделать.
Я хочу добавить TableRowActionType и реализацию (как пример: .on(.canDelete) и .on(clickDelete) )
я хочу добавить также .on(.editAction) и его реализацию
from tablekit.
from tablekit.
Я хочу добавить TableRowActionType и реализацию (как пример: .on(.canDelete) и .on(clickDelete) )
Как вариант можно использовать .custom("")
invoke(action: .custom("my_action") ... )
.on(.custom("my_action") ... )
from tablekit.
Related Issues (20)
- Подскажи пожалуйста, как организовать получение данных из ячеек HOT 7
- How to activate canMove, canMoveTo for sorting drag & drop rows
- [QUESTION] Is there any way to customize rows appending/deleting HOT 1
- What you mean about options.userInfo
- Update sections with animation HOT 2
- Missing header view using AutoLayout HOT 6
- Plain table with no header or footer still shows the header/footer HOT 2
- [QUESTION] Scrolling is relatively glitchy HOT 4
- Support for moving rows? HOT 2
- Crash when doing clear() HOT 2
- [ВОПРОС] Как перезагружать секции при постраничной загрузке HOT 3
- willDisplayHeaderView and willDisplayFooterView HOT 3
- Can't remove top extra space for grouped tableview HOT 8
- ConfigurableCell T triggers SwiftLint warning HOT 2
- Crash on reload of empty table if tableView contains tableHeaderView | iOS 10.3.1 HOT 1
- How to get rid of AutoLayout warning when using TableKit HOT 5
- Remove/delete a section HOT 1
- How to reload a concrete row or cell? HOT 2
- Pagination?
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 tablekit.