From 515c296b268c99414b7df06fd099fbeb19c0ee7b Mon Sep 17 00:00:00 2001 From: relikd Date: Sat, 4 Apr 2020 01:52:07 +0200 Subject: [PATCH] Keep title for expanded notes --- main/Base.lproj/Main.storyboard | 8 ++++++-- main/Recordings/VCEditRecording.swift | 22 +++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/main/Base.lproj/Main.storyboard b/main/Base.lproj/Main.storyboard index 19b0d9a..918c3d3 100644 --- a/main/Base.lproj/Main.storyboard +++ b/main/Base.lproj/Main.storyboard @@ -613,9 +613,8 @@ - + - 1. Line 2. Line @@ -631,7 +630,11 @@ + + + + @@ -687,6 +690,7 @@ Duration: 60:00 + diff --git a/main/Recordings/VCEditRecording.swift b/main/Recordings/VCEditRecording.swift index 425423e..cfda235 100644 --- a/main/Recordings/VCEditRecording.swift +++ b/main/Recordings/VCEditRecording.swift @@ -9,6 +9,7 @@ class VCEditRecording: UIViewController, UITextFieldDelegate, UITextViewDelegate @IBOutlet private var inputTitle: UITextField! @IBOutlet private var inputNotes: UITextView! @IBOutlet private var inputDetails: UITextView! + @IBOutlet private var noteBottom: NSLayoutConstraint! override func viewDidLoad() { inputTitle.placeholder = record.fallbackTitle @@ -105,19 +106,14 @@ class VCEditRecording: UIViewController, UITextFieldDelegate, UITextViewDelegate guard let parent = inputNotes.superview, let stack = parent.superview else { return } - let shouldAdjust = (isEditingNotes && keyboardHeight > 0) - let noteTitle = parent.subviews.first! - noteTitle.isHidden = shouldAdjust - stack.subviews.forEach{ $0.isHidden = (shouldAdjust && $0 != parent) } + let adjust = (isEditingNotes && keyboardHeight > 0) + stack.subviews.forEach{ $0.isHidden = (adjust && $0 != parent) } - if shouldAdjust { - inputNotes.frame.origin.y = 0 - inputNotes.frame.size.height = view.frame.height - keyboardHeight - stack.frame.minY - 4 - inputNotes.autoresizingMask = .init(arrayLiteral: .flexibleWidth, .flexibleBottomMargin) - } else { - inputNotes.frame.origin.y = noteTitle.frame.height - inputNotes.frame.size.height = parent.frame.height - noteTitle.frame.height - inputNotes.autoresizingMask = .init(arrayLiteral: .flexibleWidth, .flexibleHeight) - } + let title = parent.subviews.first as! UILabel + title.font = .preferredFont(forTextStyle: adjust ? .subheadline : .title2) + title.sizeToFit() + title.frame.size.width = parent.frame.width + + noteBottom.constant = adjust ? view.frame.height - stack.frame.maxY - keyboardHeight : 0 } }