Will there be a Swipeable actions present in Eureka? It would be cool to have something like the following:
<<< DateInlineRow("DateInlineRow"){
$0.title = $0.tag
$0.rowActionsRight = [ RowAction("Delete",
action: { ... },
condition: Condition.Function(...)),
... ]
$0.rowActionsLeft = [ ... ]
}
Additionally a rowActionsRightTriggerAction
and a rowActionsLeftTriggerAction
would be cool (the action which should be executed if the users swipes through). Maybe this can just be the the first RowAction in the array? Then a rowActionsRightTriggerEnabled = true
should do the job?
@marbetschar I don't know how common is this problem but....
The right actions feature can be easily implemented using editActionsForRowAtIndexPath
table view delegate method:
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
var actions = [UITableViewRowAction]()
let action = UITableViewRowAction(style: .Destructive, title: "Delete") { (action, indexPath) -> Void in
}
actions.append(action)
let action2 = UITableViewRowAction(style: .Normal, title: "Martin") { (action, indexPath) -> Void in
}
action2.backgroundColor = .orangeColor()
actions.append(action2)
return actions
}
My thoughts about this feature.
rowActionsRight
type from [RowAction]
to () -> [RowAction]
so we will no longer need the condition parameter condition
.UITableViewRowAction
or some abstraction like RowAction
?@mtnbarreto thanks for your feedback. Here are my thoughts about this feature:
Condition
for the RowAction
to be rendered, but we are not forced to?RowAction
: This enables us to implement additional, Eureka specific behaviour like Event-Handler-Blocks, Conditions etc.And one additional point:
The implementation should support the accessibility features to enable UITesting. This is the main concern of all currently available implementations; they simply do not support it. See https://github.com/MortimerGoro/MGSwipeTableCell/issues/139 for additional details.
I'm aware of the Swipe Feature (especially the left-one) to be quite a big beast and unfortunately I can't find the time right now to implement it - so if anyone can afford some time this would be awesome!!!
The swipe feature would be amazing!
This would be a great feature to add to Eureka!!!
Also, it would be an awesome addition if we could implement swipe right actions, like MGSwipeTableCell does.
I took a first swing at adding actions support, but would really love to add swipe right actions too.
@mtnbarreto -
I'm trying to create swipe to left but it doesn't work this is my code ( those function are never called ):
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let action = UITableViewRowAction(style: .destructive, title: "Delete") { (action, indexPath) -> Void in
}
return [action]
}
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
switch indexPath.section {
case 2:
return true
case 3:
return true
default:
return false
}
}
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if (editingStyle == .delete) {
print(indexPath)
}
}
I've built Eureka as a framework and added it to my project. I found that I needed to use @objc to change the name of some methods. I'm not sure quite why, it may be an artefact of the fact that FormViewController has UITableViewDelegate specified as an extension.
The following code produces the NSLog messages as expected at the right times when swiping on a row, but I now have the problem if I try and delete a row, exceptions are thrown because there are observers on the row.
In my class MyFormViewController: FormViewController {
@objc(tableView:canEditRowAtIndexPath:)
open func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
NSLog(#function)
return true
}
open func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCellEditingStyle {
NSLog(#function)
return .delete
}
@objc(tableView:editActionsForRowAtIndexPath:)
open func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
NSLog(#function)
let more = UITableViewRowAction(style: .default, title: "Delete") { action, index in
NSLog("Delete action called")
}
return [more]
}
One use case is if you are adding multiple values of a type but don't have a predefined set of options to choose from. As you add more values, it could display the values in a dynamic LabelRow but if you decide you want to remove one of the values, you can just swipe left to delete that entry.
@mtnbarreto - do we have sort of specified direction in terms of how this issue goes further?
Is there an approach of how both swipe directions may be implemented best and if so, will this be part of Eureka core?
Together with @mathmatrix828 we started working on multivalued sections. As we both have limited time, help is very welcome! If any of you wants to see the multi valued section issue and/or the swipeable actions issue closed, please chime in!
And here's the plan:
As proposed here: https://github.com/xmartlabs/Eureka/issues/17#issuecomment-266218409 - my preferred way of managing items in a multivalued section would be by swiping to the left for removing, and swiping to the right for adding a new item. In order for this to work, we first have to add the basic functionality for multivalued sections.
As said, this is just a proposal - I'm open for any suggestions.
@mtnbarreto was busy in other projects the last couple of months, therefore things went a bit silent here. Now I'd like to start a new attempt for Swipeable Rows
.
I'd like to implement them using the new iOS11 features - with which branch should I start best? master
oder swift-4
?
If you want to go with iOS 11 features then you should start with the swift-4
branch. You have to remember that there might be changes to that branch until Xcode 9 (non-beta) is out.
Eureka currently supports from iOS 8 onwards. I think any new feature should support at least iOS 9.
Agreed, I'd go with swift-4. I've been pretty bogged down recently and am not sure when I'll be available since I have a bunch of things coming up soon, but I'll try to pitch some time if I have any
Has anyone a pull request?
Has been merged in #1361
Most helpful comment
The swipe feature would be amazing!