From 27ab2a621a97e1678c3625b5b114bed67a132850 Mon Sep 17 00:00:00 2001 From: relikd Date: Tue, 8 Sep 2020 02:51:25 +0200 Subject: [PATCH] Set recording time as filter --- main/GUI/Base.lproj/Recordings.storyboard | 37 +++++++++++++++-------- main/Recordings/VCEditRecording.swift | 14 +++++++-- main/Requests/VCDateFilter.swift | 7 +++++ main/TBCMain.swift | 1 + 4 files changed, 45 insertions(+), 14 deletions(-) diff --git a/main/GUI/Base.lproj/Recordings.storyboard b/main/GUI/Base.lproj/Recordings.storyboard index b92f7a1..ecc6169 100644 --- a/main/GUI/Base.lproj/Recordings.storyboard +++ b/main/GUI/Base.lproj/Recordings.storyboard @@ -497,18 +497,18 @@ - + - + - + @@ -518,7 +518,7 @@ - + @@ -562,7 +562,7 @@ - + - + 1. Line 2. Line @@ -596,7 +596,7 @@ - + - + - Start: 1970-01-01 01:00 End: 1970-01-01 02:00 @@ -616,10 +615,23 @@ Duration: 60:00 + + + + + + + @@ -635,9 +647,9 @@ Duration: 60:00 - - - + + + @@ -727,6 +739,7 @@ Duration: 60:00 + diff --git a/main/Recordings/VCEditRecording.swift b/main/Recordings/VCEditRecording.swift index 266d6d8..83b4552 100644 --- a/main/Recordings/VCEditRecording.swift +++ b/main/Recordings/VCEditRecording.swift @@ -62,7 +62,7 @@ class VCEditRecording: UIViewController, UITextFieldDelegate, UITextViewDelegate // MARK: Save & Cancel Buttons - @IBAction func didTapSave(_ sender: UIBarButtonItem) { + @IBAction func didTapSave() { let newlyCreated = deleteOnCancel if newlyCreated { // if remains true, `viewDidDisappear` will delete the record @@ -90,7 +90,7 @@ class VCEditRecording: UIViewController, UITextFieldDelegate, UITextViewDelegate } } - @IBAction func didTapCancel(_ sender: UIBarButtonItem) { + @IBAction func didTapCancel() { QLog.Debug("discard edit of record #\(record.id)") dismiss(animated: true) } @@ -103,6 +103,16 @@ class VCEditRecording: UIViewController, UITextFieldDelegate, UITextViewDelegate } } + @IBAction func didTapFilter() { + if buttonSave.isEnabled { + NotificationBanner("Filter set", style: .ok).present(in: self, hideAfter: 1) + } else { + (presentingViewController as? TBCMain)?.openTab(0) + didTapCancel() + } + VCDateFilter.setFilter(range: record.start, to: record.stop) + } + // MARK: Handle Keyboard & Notes Frame diff --git a/main/Requests/VCDateFilter.swift b/main/Requests/VCDateFilter.swift index c21c640..45c5f08 100644 --- a/main/Requests/VCDateFilter.swift +++ b/main/Requests/VCDateFilter.swift @@ -125,4 +125,11 @@ class VCDateFilter: UIViewController, UIGestureRecognizerDelegate { NotifyDateFilterChanged.post() } } + + static func setFilter(range from: Timestamp?, to: Timestamp?) { + Prefs.DateFilter.Kind = .ABRange + Prefs.DateFilter.RangeA = from + Prefs.DateFilter.RangeB = to + NotifyDateFilterChanged.post() + } } diff --git a/main/TBCMain.swift b/main/TBCMain.swift index 2d3ebc8..36803ec 100644 --- a/main/TBCMain.swift +++ b/main/TBCMain.swift @@ -43,6 +43,7 @@ class TBCMain: UITabBarController { } extension TBCMain { + /// Open tab and pop to root view controller. @discardableResult func openTab(_ index: Int) -> UIViewController? { selectedIndex = index guard let nav = selectedViewController as? UINavigationController else {