New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swift 4 swipeable #1249
Swift 4 swipeable #1249
Changes from 8 commits
a0b7c1b
806ba34
2f43a69
76617fc
0e3babc
be4c01d
ffed289
72a3951
017d4a3
4ea0ef5
8c76499
1da1d35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,15 +106,11 @@ class HomeViewController : FormViewController { | |
row.title = row.tag | ||
row.presentationMode = .segueName(segueName: "MultivaluedSectionsControllerSegue", onDismiss: nil) | ||
} | ||
|
||
|
||
+++ Section() | ||
<<< ButtonRow() { (row: ButtonRow) -> Void in | ||
row.title = "About" | ||
} | ||
.onCellSelection { [weak self] (cell, row) in | ||
self?.showAlert() | ||
} | ||
|
||
<<< ButtonRow("Swipe Actions") { (row: ButtonRow) -> Void in | ||
row.title = row.tag | ||
row.presentationMode = .segueName(segueName: "SwipeActionsControllerSegue", onDismiss: nil) | ||
} | ||
} | ||
|
||
|
||
|
@@ -1747,6 +1743,64 @@ class MultivaluedOnlyDeleteController: FormViewController { | |
} | ||
} | ||
|
||
class SwipeActionsController: FormViewController { | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
form +++ Section(footer: "Eureka sets table.isEditing = false for SwipeActions.\n\nMultivaluedSections need table.isEditing = true, therefore both can't be used on the same view.") | ||
<<< LabelRow("Actions Right: iOS >= 7"){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please always keep a white space before an opening curly brace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
$0.title = $0.tag | ||
|
||
$0.trailingSwipeConfiguration = SwipeConfiguration(){ | ||
let moreAction = SwipeAction(style: .normal, title: "More", handler: { (action, path, completionHandler) in | ||
print("More") | ||
completionHandler?(true) | ||
}) | ||
|
||
let deleteAction = SwipeAction(style: .destructive, title: "Delete", handler: { (action, path, completionHandler) in | ||
print("Delete") | ||
completionHandler?(true) | ||
}) | ||
|
||
$0.actions = [deleteAction,moreAction] | ||
} | ||
} | ||
|
||
<<< LabelRow("Actions Left & Right: iOS >= 11"){ | ||
$0.title = $0.tag | ||
|
||
$0.trailingSwipeConfiguration = SwipeConfiguration(){ | ||
let moreAction = SwipeAction(style: .normal, title: "More", handler: { (action, path, completionHandler) in | ||
print("More") | ||
completionHandler?(true) | ||
}) | ||
|
||
let deleteAction = SwipeAction(style: .destructive, title: "Delete", handler: { (action, path, completionHandler) in | ||
print("Delete") | ||
completionHandler?(true) | ||
}) | ||
|
||
$0.performsFirstActionWithFullSwipe = true | ||
$0.actions = [deleteAction,moreAction] | ||
} | ||
|
||
if #available(iOS 11,*){ | ||
$0.leadingSwipeConfiguration = SwipeConfiguration(){ | ||
let infoAction = SwipeAction(style: .normal, title: "Info", handler: { (action, path, completionHandler) in | ||
print("Info") | ||
completionHandler?(true) | ||
}) | ||
infoAction.backgroundColor = .blue | ||
|
||
$0.performsFirstActionWithFullSwipe = true | ||
$0.actions = [infoAction] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
class EurekaLogoViewNib: UIView { | ||
|
||
@IBOutlet weak var imageView: UIImageView! | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,7 +98,18 @@ open class BaseRow: BaseRowType { | |
public var isHidden: Bool { return hiddenCache } | ||
|
||
/// The section to which this row belongs. | ||
public weak var section: Section? | ||
open weak var section: Section? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this change does not seem to be needed? Please revert it back There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right. Done. |
||
|
||
public var trailingSwipeConfiguration: SwipeConfiguration? | ||
|
||
//needs the accessor because if marked directly this throws "Stored properties cannot be marked potentially unavailable with '@available'" | ||
private var _leadingSwipeConfiguration: SwipeConfiguration? | ||
|
||
@available(iOS 11,*) | ||
public var leadingSwipeConfiguration: SwipeConfiguration?{ | ||
get{ return self._leadingSwipeConfiguration } | ||
set{ self._leadingSwipeConfiguration = newValue } | ||
} | ||
|
||
public required init(tag: String? = nil) { | ||
self.tag = tag | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the same indentation that is used in the whole project (4 spaces)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.