Skip to content

Commit

Permalink
Merge pull request #4 from crsantos/feature/select_text
Browse files Browse the repository at this point in the history
Allow copy URL on FNMDebugListingViewController via iOS 11 `UIC…
  • Loading branch information
fabioalmeida authored Sep 15, 2020
2 parents 7f3d5ce + da31598 commit a850bf5
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion FNMNetworkMonitor.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |spec|
spec.name = 'FNMNetworkMonitor'
spec.module_name = 'FNMNetworkMonitor'
spec.version = '9.0.0'
spec.version = '9.1.0'
spec.summary = 'A network monitor'
spec.homepage = 'https://github.com/Farfetch/network-monitor-ios'
spec.license = 'MIT'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ final class FNMDebugListingViewController: FNMViewController {
type(of: self).defaults().set(newSortOrder.rawValue, forKey: SortOrder.key)
}
}

private var errorFilterType: ErrorFilterType = .allRequests

// MARK: Lifecycle
Expand Down Expand Up @@ -405,6 +406,41 @@ private extension FNMDebugListingViewController {
}
}

// MARK: - Private

private extension FNMDebugListingViewController {

@available(iOS 11.0, *)
func makeShareContextualAction(forRowAt indexPath: IndexPath) -> UIContextualAction {

let action = UIContextualAction(style: .normal, title: nil) { [weak self] (action, swipeButtonView, completion) in

guard let self = self else {

return completion(false)
}

if self.filteredRecords.count > indexPath.row,
let requestURL = self.filteredRecords[indexPath.row].request.url {

let ac = UIActivityViewController(activityItems: [requestURL], applicationActivities: nil)
self.present(ac, animated: true)
}

completion(true)
}

action.backgroundColor = .systemTeal

if #available(iOS 13, *) {

action.image = UIImage(systemName: Constants.exportImage, withConfiguration: nil)
}

return action
}
}

// MARK: - FNMNetworkMonitorObserver

extension FNMDebugListingViewController: FNMNetworkMonitorObserver {
Expand Down Expand Up @@ -467,6 +503,14 @@ extension FNMDebugListingViewController: UITableViewDelegate {
animated: true)
}
}

@available(iOS 11.0, *)
func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {

return UISwipeActionsConfiguration(actions: [
self.makeShareContextualAction(forRowAt: indexPath)
])
}
}

// MARK: - UISearchBarDelegate
Expand Down

0 comments on commit a850bf5

Please sign in to comment.