From c8fa4a85b962828f7cb00017b060c24842570aaa Mon Sep 17 00:00:00 2001 From: fmodf Date: Wed, 7 Aug 2024 11:19:53 +0200 Subject: [PATCH] wip --- .../View/Screens/ChatsListScreen.swift | 4 +- .../View/Screens/ContactsScreen.swift | 38 ++++---------- .../Conversation/ConversationHeader.swift | 33 ------------- .../Conversation/ConversationScreen.swift | 14 +++++- .../Create/AddContactOrChannelScreen.swift | 49 ++++++------------- .../View/Screens/Sharing/SharingHeader.swift | 29 ----------- .../Screens/Sharing/SharingPickerScreen.swift | 10 +++- 7 files changed, 48 insertions(+), 129 deletions(-) delete mode 100644 ConversationsClassic/View/Screens/Conversation/ConversationHeader.swift delete mode 100644 ConversationsClassic/View/Screens/Sharing/SharingHeader.swift diff --git a/ConversationsClassic/View/Screens/ChatsListScreen.swift b/ConversationsClassic/View/Screens/ChatsListScreen.swift index 7fde7bc..ba19103 100644 --- a/ConversationsClassic/View/Screens/ChatsListScreen.swift +++ b/ConversationsClassic/View/Screens/ChatsListScreen.swift @@ -13,8 +13,8 @@ struct ChatsListScreen: View { VStack(spacing: 0) { // Header SharedNavigationBar( - centerText: SharedNavBarText(text: L10n.Chats.title), - rightButton: SharedNavBarButton( + centerText: .init(text: L10n.Chats.title), + rightButton: .init( image: Image(systemName: "square.and.pencil"), action: { store.dispatch(.changeFlow(.createConversation)) diff --git a/ConversationsClassic/View/Screens/ContactsScreen.swift b/ConversationsClassic/View/Screens/ContactsScreen.swift index 1944c07..3de89a3 100644 --- a/ConversationsClassic/View/Screens/ContactsScreen.swift +++ b/ConversationsClassic/View/Screens/ContactsScreen.swift @@ -17,7 +17,15 @@ struct ContactsScreen: View { // Content VStack(spacing: 0) { // Header - ContactsScreenHeader(addPanelPresented: $addPanelPresented) + SharedNavigationBar( + centerText: .init(text: L10n.Contacts.title), + rightButton: .init( + image: Image(systemName: "plus"), + action: { + addPanelPresented = true + } + ) + ) // Contacts list let rosters = store.state.rostersState.rosters.filter { !$0.locallyDeleted } @@ -56,34 +64,6 @@ struct ContactsScreen: View { } } -private struct ContactsScreenHeader: View { - @Binding var addPanelPresented: Bool - - var body: some View { - ZStack { - // bg - Color.Material.Background.dark - .ignoresSafeArea() - - // title - Text(L10n.Contacts.title) - .font(.head2) - .foregroundColor(Color.Material.Text.main) - - HStack { - Spacer() - Image(systemName: "plus") - .foregroundColor(Color.Material.Elements.active) - .tappablePadding(.symmetric(12)) { - addPanelPresented = true - } - } - .padding(.horizontal, 16) - } - .frame(height: 44) - } -} - private struct ContactsScreenRow: View { @EnvironmentObject var store: AppStore diff --git a/ConversationsClassic/View/Screens/Conversation/ConversationHeader.swift b/ConversationsClassic/View/Screens/Conversation/ConversationHeader.swift deleted file mode 100644 index 2bd84ee..0000000 --- a/ConversationsClassic/View/Screens/Conversation/ConversationHeader.swift +++ /dev/null @@ -1,33 +0,0 @@ -import SwiftUI - -struct ConversationHeader: View { - @EnvironmentObject var store: AppStore - - var body: some View { - ZStack { - // bg - Color.Material.Background.dark - .ignoresSafeArea() - - // title - let name = ( - store.state.conversationsState.currentRoster?.name ?? - store.state.conversationsState.currentRoster?.contactBareJid - ) ?? L10n.Chat.title - Text(name) - .font(.head2) - .foregroundColor(.Material.Text.main) - - HStack { - Image(systemName: "chevron.left") - .foregroundColor(.Material.Elements.active) - .tappablePadding(.symmetric(12)) { - store.dispatch(.changeFlow(store.state.previousFlow)) - } - Spacer() - } - .padding(.horizontal, 16) - } - .frame(height: 44) - } -} diff --git a/ConversationsClassic/View/Screens/Conversation/ConversationScreen.swift b/ConversationsClassic/View/Screens/Conversation/ConversationScreen.swift index 4194e22..73657bf 100644 --- a/ConversationsClassic/View/Screens/Conversation/ConversationScreen.swift +++ b/ConversationsClassic/View/Screens/Conversation/ConversationScreen.swift @@ -18,7 +18,19 @@ struct ConversationScreen: View { // Content VStack(spacing: 0) { // Header - ConversationHeader() + let name = ( + store.state.conversationsState.currentRoster?.name ?? + store.state.conversationsState.currentRoster?.contactBareJid + ) ?? L10n.Chat.title + SharedNavigationBar( + leftButton: .init( + image: Image(systemName: "chevron.left"), + action: { + store.dispatch(.changeFlow(store.state.previousFlow)) + } + ), + centerText: .init(text: name) + ) // Msg list let messages = store.state.conversationsState.currentMessages diff --git a/ConversationsClassic/View/Screens/Create/AddContactOrChannelScreen.swift b/ConversationsClassic/View/Screens/Create/AddContactOrChannelScreen.swift index 2d14725..6f60ffc 100644 --- a/ConversationsClassic/View/Screens/Create/AddContactOrChannelScreen.swift +++ b/ConversationsClassic/View/Screens/Create/AddContactOrChannelScreen.swift @@ -27,7 +27,21 @@ struct AddContactOrChannelScreen: View { // Content VStack(spacing: 0) { // Header - AddContactsScreenHeader(isPresented: $isPresented) + SharedNavigationBar( + leftButton: .init( + image: Image(systemName: "chevron.left"), + action: { + isPresented = false + } + ), + centerText: .init(text: L10n.Contacts.Add.title), + rightButton: .init( + image: Image(systemName: "plus.viewfinder"), + action: { + print("Scan QR-code") + } + ) + ) VStack(spacing: 16) { // Explanation text @@ -132,36 +146,3 @@ struct AddContactOrChannelScreen: View { } } } - -private struct AddContactsScreenHeader: View { - @Binding var isPresented: Bool - - var body: some View { - ZStack { - // bg - Color.Material.Background.dark - .ignoresSafeArea() - - // title - Text(L10n.Contacts.Add.title) - .font(.head2) - .foregroundColor(.Material.Text.main) - - HStack { - Image(systemName: "chevron.left") - .foregroundColor(Color.Material.Elements.active) - .tappablePadding(.symmetric(12)) { - isPresented = false - } - Spacer() - Image(systemName: "plus.viewfinder") - .foregroundColor(Color.Material.Elements.active) - .tappablePadding(.symmetric(12)) { - print("Scan QR-code") - } - } - .padding(.horizontal, 16) - } - .frame(height: 44) - } -} diff --git a/ConversationsClassic/View/Screens/Sharing/SharingHeader.swift b/ConversationsClassic/View/Screens/Sharing/SharingHeader.swift deleted file mode 100644 index 3d39276..0000000 --- a/ConversationsClassic/View/Screens/Sharing/SharingHeader.swift +++ /dev/null @@ -1,29 +0,0 @@ -import SwiftUI - -struct SharingHeader: View { - @EnvironmentObject var store: AppStore - - var body: some View { - ZStack { - // bg - Color.Material.Background.dark - .ignoresSafeArea() - - // title - Text(L10n.Attachment.Prompt.main) - .font(.head2) - .foregroundColor(Color.Material.Text.main) - - HStack { - Spacer() - Image(systemName: "xmark") - .foregroundColor(Color.Material.Elements.active) - .tappablePadding(.symmetric(12)) { - store.dispatch(.sharingAction(.showSharing(false))) - } - } - .padding(.horizontal, 16) - } - .frame(height: 44) - } -} diff --git a/ConversationsClassic/View/Screens/Sharing/SharingPickerScreen.swift b/ConversationsClassic/View/Screens/Sharing/SharingPickerScreen.swift index 857267b..d67e9ca 100644 --- a/ConversationsClassic/View/Screens/Sharing/SharingPickerScreen.swift +++ b/ConversationsClassic/View/Screens/Sharing/SharingPickerScreen.swift @@ -14,7 +14,15 @@ struct AttachmentPickerScreen: View { // Content VStack(spacing: 0) { // Header - SharingHeader() + SharedNavigationBar( + centerText: .init(text: L10n.Attachment.Prompt.main), + rightButton: .init( + image: Image(systemName: "xmark"), + action: { + store.dispatch(.sharingAction(.showSharing(false))) + } + ) + ) // Pickers switch selectedTab {