This commit is contained in:
fmodf 2024-09-19 18:50:48 +02:00
parent db66442393
commit c27a935a3f
7 changed files with 87 additions and 4 deletions

View file

@ -61,6 +61,11 @@
"Attachment.Send.contact" = "Send contact";
"Attachment.Downloading.retry" = "Retry";
// MARK: Conversation settings title
"Conversation.settings.title.chat" = "Chat settings";
"Conversation.settings.title.group" = "Group settings";
"Conversation.settings.title.channel" = "Channel settings";
"Conversation.settings.enableOmemo" = "Enable OMEMO";

View file

@ -49,7 +49,7 @@ private struct ChatsRow: View {
var chat: Chat
var body: some View {
SharedListRow(iconType: .charCircle(chat.participant), text: chat.participant)
SharedListRow(iconType: .charCircle(chat.participant), text: chat.participant, controlType: .none)
.onTapGesture {
Task {
router.showModal {

View file

@ -53,7 +53,8 @@ private struct ContactsScreenRow: View {
var body: some View {
SharedListRow(
iconType: .charCircle(roster.name?.firstLetter ?? roster.contactBareJid.firstLetter),
text: roster.contactBareJid
text: roster.contactBareJid,
controlType: .none
)
.onTapGesture {
startChat()

View file

@ -60,7 +60,8 @@ private struct ContactRow: View {
var body: some View {
SharedListRow(
iconType: .charCircle(roster.name?.firstLetter ?? roster.contactBareJid.firstLetter),
text: roster.contactBareJid
text: roster.contactBareJid,
controlType: .none
)
.onTapGesture {
selectedContact = roster

View file

@ -28,7 +28,9 @@ struct ConversationScreen: View {
}
),
centerText: .init(text: centerText(), action: {
print("Center text tapped")
router.showScreen(.fullScreenCover) { _ in
ConversationSettingsScreen()
}
})
)

View file

@ -0,0 +1,49 @@
import Combine
import Foundation
import Martin
import SwiftUI
struct ConversationSettingsScreen: View {
@Environment(\.router) var router
@EnvironmentObject var messagesStore: MessagesStore
@State private var omemoEnabled = true
var body: some View {
ZStack {
// Background color
Color.Material.Background.light
.ignoresSafeArea()
// Content
VStack(spacing: 0) {
// Header
SharedNavigationBar(
leftButton: .init(
image: Image(systemName: "chevron.left"),
action: {
router.dismissScreen()
}
),
centerText: .init(text: centerText())
)
// Settings list
ScrollView {
LazyVStack(spacing: 0) {
SharedListRow(
iconType: .none,
text: L10n.Conversation.Settings.enableOmemo,
controlType: .switcher(isOn: $omemoEnabled)
)
}
}
}
}
}
private func centerText() -> String {
// TODO: make center text depend on conversation type in future (chat, group chat, channel, etc.)
L10n.Conversation.Settings.Title.chat
}
}

View file

@ -3,11 +3,18 @@ import SwiftUI
enum SharedListRowIconType {
case charCircle(String)
case image(Image, Color)
case none
}
enum SharedListRowControlType {
case none
case switcher(isOn: Binding<Bool>)
}
struct SharedListRow: View {
let iconType: SharedListRowIconType
let text: String
let controlType: SharedListRowControlType
var body: some View {
VStack(spacing: 0) {
@ -36,6 +43,11 @@ struct SharedListRow: View {
.foregroundColor(color)
}
}
case .none:
Rectangle()
.fill(Color.clear)
.frame(width: 0.1, height: 44)
}
// Text
@ -43,6 +55,19 @@ struct SharedListRow: View {
.foregroundColor(Color.Material.Text.main)
.font(.body2)
Spacer()
// If control is needed
switch controlType {
case .none:
Rectangle()
.fill(Color.clear)
.frame(width: 0.1, height: 44)
case .switcher(let isOn):
Toggle("", isOn: isOn)
.toggleStyle(SwitchToggleStyle(tint: .Material.Elements.active))
.frame(width: 49, height: 31)
}
}
.padding(.horizontal, 16)
.padding(.vertical, 4)