This commit is contained in:
fmodf 2024-08-07 11:19:53 +02:00
parent 0aafcf6362
commit c8fa4a85b9
7 changed files with 48 additions and 129 deletions

View file

@ -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))

View file

@ -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

View file

@ -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)
}
}

View file

@ -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

View file

@ -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)
}
}

View file

@ -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)
}
}

View file

@ -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 {