|
|
@ -22,6 +22,14 @@ final class EditClosedGroupVC : BaseVC, UITableViewDataSource, UITableViewDelega
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private lazy var addMembersButton: Button = {
|
|
|
|
|
|
|
|
let result = Button(style: .prominentOutline, size: .large)
|
|
|
|
|
|
|
|
result.setTitle("Add Members", for: UIControl.State.normal)
|
|
|
|
|
|
|
|
result.addTarget(self, action: #selector(addMembers), for: UIControl.Event.touchUpInside)
|
|
|
|
|
|
|
|
result.contentEdgeInsets = UIEdgeInsets(top: 0, leading: Values.mediumSpacing, bottom: 0, trailing: Values.mediumSpacing)
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
@objc private lazy var tableView: UITableView = {
|
|
|
|
@objc private lazy var tableView: UITableView = {
|
|
|
|
let result = UITableView()
|
|
|
|
let result = UITableView()
|
|
|
|
result.dataSource = self
|
|
|
|
result.dataSource = self
|
|
|
@ -56,13 +64,13 @@ final class EditClosedGroupVC : BaseVC, UITableViewDataSource, UITableViewDelega
|
|
|
|
let backButton = UIBarButtonItem(title: "Back", style: .plain, target: nil, action: nil)
|
|
|
|
let backButton = UIBarButtonItem(title: "Back", style: .plain, target: nil, action: nil)
|
|
|
|
backButton.tintColor = Colors.text
|
|
|
|
backButton.tintColor = Colors.text
|
|
|
|
navigationItem.backBarButtonItem = backButton
|
|
|
|
navigationItem.backBarButtonItem = backButton
|
|
|
|
setUpViewHierarchy()
|
|
|
|
|
|
|
|
updateNavigationBarButtons()
|
|
|
|
|
|
|
|
name = thread.groupModel.groupName!
|
|
|
|
|
|
|
|
func getDisplayName(for publicKey: String) -> String {
|
|
|
|
func getDisplayName(for publicKey: String) -> String {
|
|
|
|
return UserDisplayNameUtilities.getPrivateChatDisplayName(for: publicKey) ?? publicKey
|
|
|
|
return UserDisplayNameUtilities.getPrivateChatDisplayName(for: publicKey) ?? publicKey
|
|
|
|
}
|
|
|
|
}
|
|
|
|
members = GroupUtilities.getClosedGroupMembers(thread).sorted { getDisplayName(for: $0) < getDisplayName(for: $1) }
|
|
|
|
members = GroupUtilities.getClosedGroupMembers(thread).sorted { getDisplayName(for: $0) < getDisplayName(for: $1) }
|
|
|
|
|
|
|
|
setUpViewHierarchy()
|
|
|
|
|
|
|
|
updateNavigationBarButtons()
|
|
|
|
|
|
|
|
name = thread.groupModel.groupName!
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private func setUpViewHierarchy() {
|
|
|
|
private func setUpViewHierarchy() {
|
|
|
@ -88,11 +96,8 @@ final class EditClosedGroupVC : BaseVC, UITableViewDataSource, UITableViewDelega
|
|
|
|
membersLabel.font = .systemFont(ofSize: Values.mediumFontSize)
|
|
|
|
membersLabel.font = .systemFont(ofSize: Values.mediumFontSize)
|
|
|
|
membersLabel.text = "Members"
|
|
|
|
membersLabel.text = "Members"
|
|
|
|
// Add members button
|
|
|
|
// Add members button
|
|
|
|
let addMembersButton = Button(style: .prominentOutline, size: .large)
|
|
|
|
let hasContactsToAdd = !Set(ContactUtilities.getAllContacts()).subtracting(self.members).isEmpty
|
|
|
|
addMembersButton.setTitle("Add Members", for: UIControl.State.normal)
|
|
|
|
if (!hasContactsToAdd) {
|
|
|
|
addMembersButton.addTarget(self, action: #selector(addMembers), for: UIControl.Event.touchUpInside)
|
|
|
|
|
|
|
|
addMembersButton.contentEdgeInsets = UIEdgeInsets(top: 0, leading: Values.mediumSpacing, bottom: 0, trailing: Values.mediumSpacing)
|
|
|
|
|
|
|
|
if (Set(ContactUtilities.getAllContacts()).subtracting(members).isEmpty) {
|
|
|
|
|
|
|
|
addMembersButton.isUserInteractionEnabled = false
|
|
|
|
addMembersButton.isUserInteractionEnabled = false
|
|
|
|
let disabledColor = Colors.text.withAlphaComponent(Values.unimportantElementOpacity)
|
|
|
|
let disabledColor = Colors.text.withAlphaComponent(Values.unimportantElementOpacity)
|
|
|
|
addMembersButton.layer.borderColor = disabledColor.cgColor
|
|
|
|
addMembersButton.layer.borderColor = disabledColor.cgColor
|
|
|
@ -222,6 +227,11 @@ final class EditClosedGroupVC : BaseVC, UITableViewDataSource, UITableViewDelega
|
|
|
|
return UserDisplayNameUtilities.getPrivateChatDisplayName(for: publicKey) ?? publicKey
|
|
|
|
return UserDisplayNameUtilities.getPrivateChatDisplayName(for: publicKey) ?? publicKey
|
|
|
|
}
|
|
|
|
}
|
|
|
|
self.members = members.sorted { getDisplayName(for: $0) < getDisplayName(for: $1) }
|
|
|
|
self.members = members.sorted { getDisplayName(for: $0) < getDisplayName(for: $1) }
|
|
|
|
|
|
|
|
let hasContactsToAdd = !Set(ContactUtilities.getAllContacts()).subtracting(self.members).isEmpty
|
|
|
|
|
|
|
|
self.addMembersButton.isUserInteractionEnabled = hasContactsToAdd
|
|
|
|
|
|
|
|
let color = hasContactsToAdd ? Colors.accent : Colors.text.withAlphaComponent(Values.unimportantElementOpacity)
|
|
|
|
|
|
|
|
self.addMembersButton.layer.borderColor = color.cgColor
|
|
|
|
|
|
|
|
self.addMembersButton.setTitleColor(color, for: UIControl.State.normal)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
navigationController!.pushViewController(userSelectionVC, animated: true, completion: nil)
|
|
|
|
navigationController!.pushViewController(userSelectionVC, animated: true, completion: nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|