wip
This commit is contained in:
parent
db66442393
commit
c27a935a3f
|
@ -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";
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -28,7 +28,9 @@ struct ConversationScreen: View {
|
|||
}
|
||||
),
|
||||
centerText: .init(text: centerText(), action: {
|
||||
print("Center text tapped")
|
||||
router.showScreen(.fullScreenCover) { _ in
|
||||
ConversationSettingsScreen()
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue