Jump from Recordings to Requests tab

This commit is contained in:
relikd
2020-09-05 20:08:37 +02:00
parent 8cd3f7fb3a
commit b8660c9a35
3 changed files with 69 additions and 1 deletions

View File

@@ -191,7 +191,7 @@
<scene sceneID="DxJ-8o-gTM">
<objects>
<tableViewController id="50g-BI-Q6S" customClass="TVCRecordingDetails" customModule="AppCheck" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" allowsSelection="NO" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="cLV-Db-JxM">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="cLV-Db-JxM">
<rect key="frame" x="0.0" y="0.0" width="320" height="369.5"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>

View File

@@ -118,4 +118,63 @@ class TVCRecordingDetails: UITableViewController, EditActionsRemove {
shareButton.isEnabled = !noResults
return true
}
// MARK: - Tap to Copy
private var rowToCopy: Int = Int.max
override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
if rowToCopy == indexPath.row {
UIMenuController.shared.setMenuVisible(false, animated: true)
rowToCopy = Int.max
return nil
}
rowToCopy = indexPath.row
self.becomeFirstResponder()
let cell = tableView.cellForRow(at: indexPath)!
UIMenuController.shared.setTargetRect(cell.bounds, in: cell)
UIMenuController.shared.menuItems = [
.init(title: "All requests", action: #selector(openInLogs)),
// .init(title: "CoOccurrence", action: #selector(openCoOccurrence))
]
UIMenuController.shared.setMenuVisible(true, animated: true)
return nil
}
override var canBecomeFirstResponder: Bool { true }
override func copy(_ sender: Any?) {
UIPasteboard.general.string = getDomain()
rowToCopy = Int.max
}
@objc private func openInLogs() {
guard let selectedDomain = getDomain(),
let tabBar = tabBarController as? TBCMain,
let tab = tabBar.openTab(0) as? TVCDomains else {
return
}
VCDateFilter.disableFilter()
tab.pushOpen(domain: selectedDomain)
}
private func getDomain() -> String? {
if showRaw {
guard rowToCopy < dataSourceRaw.count else { return nil }
return dataSourceRaw[rowToCopy].domain
} else {
guard rowToCopy < dataSourceSum.count else { return nil }
return dataSourceSum[rowToCopy].domain
}
}
// @objc private func openCoOccurrence() {
// guard let vc: VCCoOccurrence = storyboard?.load("IBCoOccurrence") else {
// return
// }
// vc.domainName = getDomain()
// vc.isFQDN = true
// present(vc, animated: true)
// }
}

View File

@@ -116,4 +116,13 @@ class VCDateFilter: UIViewController, UIGestureRecognizerDelegate {
NotifyDateFilterChanged.post()
}
}
static func disableFilter() {
if Prefs.DateFilter.Kind <-? .Off {
Prefs.DateFilter.LastXMin = 0
Prefs.DateFilter.RangeA = nil
Prefs.DateFilter.RangeB = nil
NotifyDateFilterChanged.post()
}
}
}