Giter Site home page Giter Site logo

Comments (14)

maxsokolov avatar maxsokolov commented on June 15, 2024 2

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.

wdcurry avatar wdcurry commented on June 15, 2024

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.

wdcurry avatar wdcurry commented on June 15, 2024

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.

wdcurry avatar wdcurry commented on June 15, 2024

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.

maxsokolov avatar maxsokolov commented on June 15, 2024

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.

wdcurry avatar wdcurry commented on June 15, 2024

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.

Majituteniyazov avatar Majituteniyazov commented on June 15, 2024

@maxsokolov Здравия желаю. Подскажи пожалуйста как изменять название "кнопки" удаления по свайпу с помощью TableKit ? Мне надо локализацию добавить

from tablekit.

maxsokolov avatar maxsokolov commented on June 15, 2024

@maxsokolov Здравия желаю. Подскажи пожалуйста как изменять название "кнопки" удаления по свайпу с помощью TableKit ? Мне надо локализацию добавить

@Majituteniyazov привет! Из коробки этой функции нет, придется наследоваться от TableDirector и добавить ему в наследнике реализацию метода. Чтобы управлять title можно будет реализовать кастомный action. См исходник как там реализованы методы data source и delegate.

from tablekit.

Majituteniyazov avatar Majituteniyazov commented on June 15, 2024

@maxsokolov хорошо, спасибо, постараюсь сделать

@maxsokolov Здравия желаю. Подскажи пожалуйста как изменять название "кнопки" удаления по свайпу с помощью TableKit ? Мне надо локализацию добавить

@Majituteniyazov привет! Из коробки этой функции нет, придется наследоваться от TableDirector и добавить ему в наследнике реализацию метода. Чтобы управлять title можно будет реализовать кастомный action. См исходник как там реализованы методы data source и delegate.

from tablekit.

Majituteniyazov avatar Majituteniyazov commented on June 15, 2024

@maxsokolov Приветствую! Мы уже как-то общались на тему кастомного тайтла выше.
Подскажи можно ли как-либо кастомизировать TableRowAction ?
Я хотел бы добавить туда пару других еще экшенов

from tablekit.

maxsokolov avatar maxsokolov commented on June 15, 2024

@maxsokolov Приветствую! Мы уже как-то общались на тему кастомного тайтла выше.
Подскажи можно ли как-либо кастомизировать TableRowAction ?
Я хотел бы добавить туда пару других еще экшенов

Не очень понимаю, что значит кастомизировать? Лучше рассмотреть на примере, что требуется сделать.

from tablekit.

Majituteniyazov avatar Majituteniyazov commented on June 15, 2024

@maxsokolov Приветствую! Мы уже как-то общались на тему кастомного тайтла выше.
Подскажи можно ли как-либо кастомизировать TableRowAction ?
Я хотел бы добавить туда пару других еще экшенов

Не очень понимаю, что значит кастомизировать? Лучше рассмотреть на примере, что требуется сделать.

Я хочу добавить TableRowActionType и реализацию (как пример: .on(.canDelete) и .on(clickDelete) )
я хочу добавить также .on(.editAction) и его реализацию

from tablekit.

Majituteniyazov avatar Majituteniyazov commented on June 15, 2024

Снимок экрана 2020-05-13 в 14 22 42

from tablekit.

maxsokolov avatar maxsokolov commented on June 15, 2024

Я хочу добавить TableRowActionType и реализацию (как пример: .on(.canDelete) и .on(clickDelete) )

Как вариант можно использовать .custom("")

invoke(action: .custom("my_action") ... )

.on(.custom("my_action") ... )

from tablekit.

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.