Merge pull request #3847 from signalapp/martin/PAPERCUT-129
new group: added animations and moved member count to the title
This commit is contained in:
commit
b0eceb46e2
@ -28,7 +28,27 @@ public class NewGroupMembersBar: UIView {
|
||||
private var members = [NewGroupMember]()
|
||||
|
||||
func setMembers(_ members: [NewGroupMember]) {
|
||||
var addedEntries: [IndexPath] = []
|
||||
var removedEntries: [IndexPath] = []
|
||||
let oldMemberHashes: [PickedRecipient] = self.members.map { $0.recipient }
|
||||
let newMemberHashes: [PickedRecipient] = members.map { $0.recipient }
|
||||
for row in 0..<self.members.count {
|
||||
if !newMemberHashes.contains(self.members[row].recipient) {
|
||||
removedEntries.append(IndexPath(row: row, section: 0))
|
||||
}
|
||||
}
|
||||
for row in 0..<members.count {
|
||||
if !oldMemberHashes.contains(members[row].recipient) {
|
||||
addedEntries.append(IndexPath(row: row, section: 0))
|
||||
}
|
||||
}
|
||||
self.members = members
|
||||
if !addedEntries.isEmpty || !removedEntries.isEmpty {
|
||||
collectionView.performBatchUpdates { [weak self] in
|
||||
self?.collectionView.deleteItems(at: removedEntries)
|
||||
self?.collectionView.insertItems(at: addedEntries)
|
||||
}
|
||||
}
|
||||
resetContentAndLayout()
|
||||
updateHeightConstraint()
|
||||
}
|
||||
@ -80,8 +100,16 @@ public class NewGroupMembersBar: UIView {
|
||||
owsFailDebug("Missing heightConstraint.")
|
||||
return
|
||||
}
|
||||
let contentHeight = self.contentHeight
|
||||
heightConstraint.constant = members.isEmpty ? 0 : contentHeight
|
||||
let desiredHeight = members.isEmpty ? 0 : self.contentHeight
|
||||
if heightConstraint.constant != desiredHeight {
|
||||
superview?.layoutIfNeeded()
|
||||
collectionView.alpha = desiredHeight == 0 ? 1 : 0
|
||||
heightConstraint.constant = desiredHeight
|
||||
UIView.animate(withDuration: 0.25) { [weak self] in
|
||||
self?.collectionView.alpha = desiredHeight == 0 ? 0 : 1
|
||||
self?.superview?.layoutIfNeeded()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var contentHeight: CGFloat {
|
||||
|
||||
@ -21,10 +21,6 @@ public class NewGroupMembersViewController: BaseGroupMemberViewController {
|
||||
@objc
|
||||
public override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
title = NSLocalizedString("NEW_GROUP_SELECT_MEMBERS_VIEW_TITLE",
|
||||
comment: "The title for the 'select members for new group' view.")
|
||||
|
||||
updateBarButtons()
|
||||
}
|
||||
|
||||
@ -42,6 +38,14 @@ public class NewGroupMembersViewController: BaseGroupMemberViewController {
|
||||
rightBarButtonItem.accessibilityLabel
|
||||
= NSLocalizedString("FINISH_GROUP_CREATION_LABEL", comment: "Accessibility label for finishing new group")
|
||||
navigationItem.rightBarButtonItem = rightBarButtonItem
|
||||
if newGroupState.recipientSet.count == 1 {
|
||||
title = NSLocalizedString("NEW_GROUP_1_MEMBERS_VIEW_TITLE", comment: "The title for the 'select members for new group' view if already one member is selected.")
|
||||
} else if hasMembers {
|
||||
let format = NSLocalizedString("NEW_GROUP_MANY_MEMBERS_VIEW_TITLE", comment: "The title for the 'select members for new group' view if already some members are selected. Embeds {{number}} of members.")
|
||||
title = String(format: format, OWSFormat.formatInt(newGroupState.recipientSet.count))
|
||||
} else {
|
||||
title = NSLocalizedString("NEW_GROUP_SELECT_MEMBERS_VIEW_TITLE", comment: "The title for the 'select members for new group' view.")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
@ -90,7 +94,7 @@ extension NewGroupMembersViewController: GroupMemberViewDelegate {
|
||||
}
|
||||
|
||||
func groupMemberViewShouldShowMemberCount() -> Bool {
|
||||
true
|
||||
false
|
||||
}
|
||||
|
||||
func groupMemberViewGroupMemberCountForDisplay() -> Int {
|
||||
|
||||
@ -1024,12 +1024,12 @@
|
||||
/* 1 hour */
|
||||
"CONVERSATION_MUTE_CONFIRMATION_OPTION_1H" = "1 hour";
|
||||
|
||||
/* 2 hours */
|
||||
"CONVERSATION_MUTE_CONFIRMATION_OPTION_8H" = "8 hours";
|
||||
|
||||
/* 7 days */
|
||||
/* 1 week */
|
||||
"CONVERSATION_MUTE_CONFIRMATION_OPTION_1W" = "1 week";
|
||||
|
||||
/* 8 hours */
|
||||
"CONVERSATION_MUTE_CONFIRMATION_OPTION_8H" = "8 hours";
|
||||
|
||||
/* Always */
|
||||
"CONVERSATION_MUTE_CONFIRMATION_OPTION_ALWAYS" = "Always";
|
||||
|
||||
@ -3601,6 +3601,9 @@
|
||||
/* A label the cell that lets you add a new member to a group. */
|
||||
"NEW_CONVERSATION_FIND_BY_PHONE_NUMBER" = "Find by Phone Number";
|
||||
|
||||
/* The title for the 'select members for new group' view if already one member is selected. */
|
||||
"NEW_GROUP_1_MEMBERS_VIEW_TITLE" = "1 Member";
|
||||
|
||||
/* Label for the 'create new group' button. */
|
||||
"NEW_GROUP_BUTTON" = "New Group";
|
||||
|
||||
@ -3625,6 +3628,9 @@
|
||||
/* Used in place of the group name when a group has not yet been named. */
|
||||
"NEW_GROUP_DEFAULT_TITLE" = "New Group";
|
||||
|
||||
/* The title for the 'select members for new group' view if already some members are selected. Embeds {{number}} of members. */
|
||||
"NEW_GROUP_MANY_MEMBERS_VIEW_TITLE" = "%@ Members";
|
||||
|
||||
/* notification title. Embeds {{author name}} and {{group name}} */
|
||||
"NEW_GROUP_MESSAGE_NOTIFICATION_TITLE" = "%@ to %@";
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user