preview member label should match group color
This commit is contained in:
parent
dc320fc69b
commit
df5c951d10
@ -190,6 +190,7 @@ struct CVItemModelBuilder: CVItemBuilding {
|
||||
threadAssociatedData: ThreadAssociatedData,
|
||||
threadViewModel: ThreadViewModel,
|
||||
itemBuildingContext: CVItemBuildingContext,
|
||||
groupNameColors: GroupNameColors,
|
||||
transaction: DBReadTransaction,
|
||||
) -> CVItemModel? {
|
||||
AssertIsOnMainThread()
|
||||
@ -209,7 +210,6 @@ struct CVItemModelBuilder: CVItemBuilding {
|
||||
return nil
|
||||
}
|
||||
|
||||
let groupNameColors = GroupNameColors.forThread(thread)
|
||||
let displayNameCache = DisplayNameCache()
|
||||
|
||||
configureItemViewState(
|
||||
|
||||
@ -304,12 +304,15 @@ public class CVLoader: NSObject {
|
||||
conversationStyle: conversationStyle,
|
||||
mediaCache: CVMediaCache(),
|
||||
)
|
||||
let groupNameColors = GroupNameColors.forThread(thread)
|
||||
|
||||
return CVLoader.buildStandaloneRenderItem(
|
||||
interaction: interaction,
|
||||
thread: thread,
|
||||
threadAssociatedData: threadAssociatedData,
|
||||
coreState: coreState,
|
||||
spoilerState: spoilerState,
|
||||
groupNameColors: groupNameColors,
|
||||
transaction: transaction,
|
||||
)
|
||||
}
|
||||
@ -320,6 +323,7 @@ public class CVLoader: NSObject {
|
||||
threadAssociatedData: ThreadAssociatedData,
|
||||
conversationStyle: ConversationStyle,
|
||||
spoilerState: SpoilerRenderState,
|
||||
groupNameColors: GroupNameColors,
|
||||
transaction: DBReadTransaction,
|
||||
) -> CVRenderItem? {
|
||||
let coreState = CVCoreState(
|
||||
@ -332,6 +336,7 @@ public class CVLoader: NSObject {
|
||||
threadAssociatedData: threadAssociatedData,
|
||||
coreState: coreState,
|
||||
spoilerState: spoilerState,
|
||||
groupNameColors: groupNameColors,
|
||||
transaction: transaction,
|
||||
)
|
||||
}
|
||||
@ -342,6 +347,7 @@ public class CVLoader: NSObject {
|
||||
threadAssociatedData: ThreadAssociatedData,
|
||||
coreState: CVCoreState,
|
||||
spoilerState: SpoilerRenderState,
|
||||
groupNameColors: GroupNameColors,
|
||||
transaction: DBReadTransaction,
|
||||
) -> CVRenderItem? {
|
||||
AssertIsOnMainThread()
|
||||
@ -376,6 +382,7 @@ public class CVLoader: NSObject {
|
||||
threadAssociatedData: threadAssociatedData,
|
||||
threadViewModel: threadViewModel,
|
||||
itemBuildingContext: itemBuildingContext,
|
||||
groupNameColors: groupNameColors,
|
||||
transaction: transaction,
|
||||
)
|
||||
else {
|
||||
|
||||
@ -236,6 +236,8 @@ class EditHistoryTableSheetViewController: OWSTableSheetViewController {
|
||||
isStandaloneRenderItem: true,
|
||||
)
|
||||
|
||||
let groupNameColors = GroupNameColors.forThread(thread)
|
||||
|
||||
let itemDate = Date(millisecondsSince1970: interaction.timestamp)
|
||||
let daysPrior = DateUtil.daysFrom(firstDate: itemDate, toSecondDate: Date())
|
||||
if forceDateHeader || daysPrior > currentDaysBefore {
|
||||
@ -249,6 +251,7 @@ class EditHistoryTableSheetViewController: OWSTableSheetViewController {
|
||||
threadAssociatedData: threadAssociatedData,
|
||||
conversationStyle: conversationStyle,
|
||||
spoilerState: self.spoilerState,
|
||||
groupNameColors: groupNameColors,
|
||||
transaction: tx,
|
||||
)
|
||||
{
|
||||
@ -263,6 +266,7 @@ class EditHistoryTableSheetViewController: OWSTableSheetViewController {
|
||||
threadAssociatedData: threadAssociatedData,
|
||||
conversationStyle: conversationStyle,
|
||||
spoilerState: self.spoilerState,
|
||||
groupNameColors: groupNameColors,
|
||||
transaction: tx,
|
||||
)
|
||||
{
|
||||
|
||||
@ -22,17 +22,19 @@ class MemberLabelViewController: OWSViewController, UITextFieldDelegate {
|
||||
private let stackView = UIStackView()
|
||||
private let textField = UITextField()
|
||||
private var characterCountLabel = UILabel()
|
||||
private var groupNameColors: GroupNameColors
|
||||
|
||||
weak var updateDelegate: MemberLabelUpdateDelegate?
|
||||
|
||||
private static let maxCharCount = 24
|
||||
private static let showCharacterCountMax = 9
|
||||
|
||||
init(memberLabel: String? = nil, emoji: String? = nil) {
|
||||
init(memberLabel: String? = nil, emoji: String? = nil, groupNameColors: GroupNameColors) {
|
||||
self.initialMemberLabel = memberLabel
|
||||
self.initialEmoji = emoji
|
||||
self.updatedMemberLabel = memberLabel
|
||||
self.updatedEmoji = emoji
|
||||
self.groupNameColors = groupNameColors
|
||||
textField.text = memberLabel
|
||||
|
||||
super.init()
|
||||
@ -205,6 +207,7 @@ class MemberLabelViewController: OWSViewController, UITextFieldDelegate {
|
||||
threadAssociatedData: threadAssociatedData,
|
||||
conversationStyle: conversationStyle,
|
||||
spoilerState: SpoilerRenderState(),
|
||||
groupNameColors: groupNameColors,
|
||||
transaction: tx,
|
||||
)
|
||||
}
|
||||
|
||||
@ -236,12 +236,15 @@ class MessageDetailViewController: OWSTableViewController2 {
|
||||
),
|
||||
)
|
||||
|
||||
let groupNameColors = GroupNameColors.forThread(thread)
|
||||
|
||||
return CVLoader.buildStandaloneRenderItem(
|
||||
interaction: interaction,
|
||||
thread: thread,
|
||||
threadAssociatedData: threadAssociatedData,
|
||||
conversationStyle: conversationStyle,
|
||||
spoilerState: spoilerState,
|
||||
groupNameColors: groupNameColors,
|
||||
transaction: transaction,
|
||||
)
|
||||
}
|
||||
|
||||
@ -229,12 +229,15 @@ class PinnedMessagesDetailsViewController: OWSViewController, DatabaseChangeDele
|
||||
isStandaloneRenderItem: true,
|
||||
)
|
||||
|
||||
let groupNameColors = GroupNameColors.forThread(threadViewModel.threadRecord)
|
||||
|
||||
return CVLoader.buildStandaloneRenderItem(
|
||||
interaction: dateInteraction,
|
||||
thread: threadViewModel.threadRecord,
|
||||
threadAssociatedData: threadViewModel.associatedData,
|
||||
conversationStyle: conversationStyle,
|
||||
spoilerState: self.spoilerState,
|
||||
groupNameColors: groupNameColors,
|
||||
transaction: tx,
|
||||
)
|
||||
}
|
||||
@ -259,12 +262,15 @@ class PinnedMessagesDetailsViewController: OWSViewController, DatabaseChangeDele
|
||||
),
|
||||
)
|
||||
|
||||
let groupNameColors = GroupNameColors.forThread(threadViewModel.threadRecord)
|
||||
|
||||
return CVLoader.buildStandaloneRenderItem(
|
||||
interaction: message,
|
||||
thread: thread,
|
||||
threadAssociatedData: threadAssociatedData,
|
||||
conversationStyle: conversationStyle,
|
||||
spoilerState: self.spoilerState,
|
||||
groupNameColors: groupNameColors,
|
||||
transaction: tx,
|
||||
)
|
||||
}
|
||||
|
||||
@ -206,11 +206,18 @@ class ContactAboutSheet: StackSheetViewController {
|
||||
canEditMemberLabel,
|
||||
let localAci = db.read(block: { tx in tsAccountManager.localIdentifiers(tx: tx)?.aci }),
|
||||
let groupModel = groupViewHelper?.delegate?.currentGroupModel,
|
||||
let groupThread = groupViewHelper?.thread as? TSGroupThread,
|
||||
let csvc = fromViewController as? ConversationSettingsViewController
|
||||
{
|
||||
let groupNameColors = GroupNameColors.forThread(groupThread)
|
||||
|
||||
stackView.addArrangedSubview(ProfileDetailLabel.memberLabel(memberLabel?.label, tapAction: { [weak self] in
|
||||
let fullMemberLabel = groupModel.groupMembership.memberLabel(for: localAci)
|
||||
let memberLabelViewController = MemberLabelViewController(memberLabel: fullMemberLabel?.label, emoji: fullMemberLabel?.labelEmoji)
|
||||
let memberLabelViewController = MemberLabelViewController(
|
||||
memberLabel: fullMemberLabel?.label,
|
||||
emoji: fullMemberLabel?.labelEmoji,
|
||||
groupNameColors: groupNameColors,
|
||||
)
|
||||
memberLabelViewController.updateDelegate = csvc
|
||||
self?.present(OWSNavigationController(rootViewController: memberLabelViewController), animated: true)
|
||||
}))
|
||||
|
||||
@ -890,6 +890,8 @@ extension ConversationSettingsViewController {
|
||||
|
||||
let db = DependenciesBridge.shared.db
|
||||
let tsAccountManager = DependenciesBridge.shared.tsAccountManager
|
||||
let groupNameColors = GroupNameColors.forThread(groupViewHelper.thread)
|
||||
|
||||
if
|
||||
BuildFlags.MemberLabel.send,
|
||||
groupViewHelper.canEditConversationAttributes,
|
||||
@ -904,7 +906,11 @@ extension ConversationSettingsViewController {
|
||||
),
|
||||
actionBlock: { [weak self] in
|
||||
let fullMemberLabel = groupModelV2.groupMembership.memberLabel(for: localAci)
|
||||
let memberLabelViewController = MemberLabelViewController(memberLabel: fullMemberLabel?.label, emoji: fullMemberLabel?.labelEmoji)
|
||||
let memberLabelViewController = MemberLabelViewController(
|
||||
memberLabel: fullMemberLabel?.label,
|
||||
emoji: fullMemberLabel?.labelEmoji,
|
||||
groupNameColors: groupNameColors,
|
||||
)
|
||||
memberLabelViewController.updateDelegate = self
|
||||
self?.present(OWSNavigationController(rootViewController: memberLabelViewController), animated: true)
|
||||
},
|
||||
|
||||
@ -167,6 +167,8 @@ class MockConversationView: UIView {
|
||||
interaction = MockIncomingMessage(messageBody: text!, thread: self.thread)
|
||||
}
|
||||
|
||||
let groupNameColors = GroupNameColors.forThread(thread)
|
||||
|
||||
guard
|
||||
let renderItem = CVLoader.buildStandaloneRenderItem(
|
||||
interaction: interaction,
|
||||
@ -174,6 +176,7 @@ class MockConversationView: UIView {
|
||||
threadAssociatedData: threadAssociatedData,
|
||||
conversationStyle: conversationStyle,
|
||||
spoilerState: SpoilerRenderState(),
|
||||
groupNameColors: groupNameColors,
|
||||
transaction: transaction,
|
||||
)
|
||||
else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user