From db66442393391ba49e9a707ef85f3329e82b63b4 Mon Sep 17 00:00:00 2001 From: fmodf Date: Thu, 19 Sep 2024 17:24:56 +0200 Subject: [PATCH] wip --- .../View/Main/Conversation/ConversationScreen.swift | 13 ++++++++++++- .../View/SharedComponents/SharedNavigationBar.swift | 12 ++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ConversationsClassic/View/Main/Conversation/ConversationScreen.swift b/ConversationsClassic/View/Main/Conversation/ConversationScreen.swift index 6c5a021..b74a2cd 100644 --- a/ConversationsClassic/View/Main/Conversation/ConversationScreen.swift +++ b/ConversationsClassic/View/Main/Conversation/ConversationScreen.swift @@ -27,7 +27,9 @@ struct ConversationScreen: View { router.dismissScreen() } ), - centerText: .init(text: L10n.Conversation.title) + centerText: .init(text: centerText(), action: { + print("Center text tapped") + }) ) // Msg list @@ -106,4 +108,13 @@ struct ConversationScreen: View { .environmentObject(attachments) } } + + private func centerText() -> String { + let name = messagesStore.roster.name ?? JID(messagesStore.roster.contactBareJid).localPart + if let name = name { + return name + } else { + return L10n.Conversation.title + } + } } diff --git a/ConversationsClassic/View/SharedComponents/SharedNavigationBar.swift b/ConversationsClassic/View/SharedComponents/SharedNavigationBar.swift index f6e651a..5587122 100644 --- a/ConversationsClassic/View/SharedComponents/SharedNavigationBar.swift +++ b/ConversationsClassic/View/SharedComponents/SharedNavigationBar.swift @@ -31,11 +31,23 @@ struct SharedNavBarButton: View { struct SharedNavBarText: View { let text: String + let action: (() -> Void)? + + init( + text: String, + action: (() -> Void)? = nil + ) { + self.text = text + self.action = action + } var body: some View { Text(text) .font(.head2) .foregroundColor(.Material.Text.main) + .tappablePadding(.init(top: 8, leading: 24, bottom: 8, trailing: 24)) { + action?() + } } }