From 476fcd84841e5e20a9a547adbb01612e04ecce8f Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Wed, 27 Jan 2021 11:29:46 +1100 Subject: [PATCH] Fix edit closed group screen constraints --- Session/Closed Groups/EditClosedGroupVC.swift | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Session/Closed Groups/EditClosedGroupVC.swift b/Session/Closed Groups/EditClosedGroupVC.swift index 413db0ee1..31e476c85 100644 --- a/Session/Closed Groups/EditClosedGroupVC.swift +++ b/Session/Closed Groups/EditClosedGroupVC.swift @@ -3,8 +3,9 @@ final class EditClosedGroupVC : BaseVC, UITableViewDataSource, UITableViewDelegate { private let thread: TSGroupThread private var name = "" - private var members: [String] = [] { didSet { tableView.reloadData() } } + private var members: [String] = [] { didSet { handleMembersChanged() } } private var isEditingGroupName = false { didSet { handleIsEditingGroupNameChanged() } } + private var tableViewHeightConstraint: NSLayoutConstraint! // MARK: Components private lazy var groupNameLabel: UILabel = { @@ -67,8 +68,8 @@ final class EditClosedGroupVC : BaseVC, UITableViewDataSource, UITableViewDelega func getDisplayName(for publicKey: String) -> String { return UserDisplayNameUtilities.getPrivateChatDisplayName(for: publicKey) ?? publicKey } - members = GroupUtilities.getClosedGroupMembers(thread).sorted { getDisplayName(for: $0) < getDisplayName(for: $1) } setUpViewHierarchy() + members = GroupUtilities.getClosedGroupMembers(thread).sorted { getDisplayName(for: $0) < getDisplayName(for: $1) } updateNavigationBarButtons() name = thread.groupModel.groupName! } @@ -109,6 +110,9 @@ final class EditClosedGroupVC : BaseVC, UITableViewDataSource, UITableViewDelega middleStackView.alignment = .center middleStackView.layoutMargins = UIEdgeInsets(top: Values.smallSpacing, leading: Values.mediumSpacing, bottom: Values.smallSpacing, trailing: Values.mediumSpacing) middleStackView.isLayoutMarginsRelativeArrangement = true + middleStackView.set(.height, to: Values.largeButtonHeight + Values.smallSpacing * 2) + // Table view + tableViewHeightConstraint = tableView.set(.height, to: 0) // Main stack view let mainStackView = UIStackView(arrangedSubviews: [ UIView.vSpacer(Values.veryLargeSpacing), @@ -129,7 +133,6 @@ final class EditClosedGroupVC : BaseVC, UITableViewDataSource, UITableViewDelega mainStackView.pin(to: scrollView) view.addSubview(scrollView) scrollView.pin(to: view) - mainStackView.pin(.bottom, to: .bottom, of: view) } // MARK: Table View Data Source / Delegate @@ -175,6 +178,11 @@ final class EditClosedGroupVC : BaseVC, UITableViewDataSource, UITableViewDelega navigationItem.rightBarButtonItem = doneButton } + private func handleMembersChanged() { + tableViewHeightConstraint.constant = CGFloat(members.count) * 67 + tableView.reloadData() + } + private func handleIsEditingGroupNameChanged() { updateNavigationBarButtons() UIView.animate(withDuration: 0.25) {