Compare commits

..

No commits in common. "452ccfacd6bdf6badce21ebee565c906faf37987" and "ec70d1f59d0ae39ae3805874f3585e357de6df5b" have entirely different histories.

3 changed files with 102 additions and 251 deletions

View File

@ -598,9 +598,6 @@
},
"Добро пожаловать в Yobble!" : {
},
"Дождитесь отправки предыдущего сообщения." : {
},
"Дополнительные действия." : {
"comment" : "Message profile more action description"
@ -1913,9 +1910,6 @@
},
"Ошибка в данных. Проверьте введённую информацию." : {
},
"Ошибка отправки" : {
},
"Ошибка при деавторизации." : {
"localizations" : {

View File

@ -6,7 +6,6 @@ final class PrivateChatViewModel: ObservableObject {
@Published private(set) var isInitialLoading: Bool = false
@Published private(set) var isLoadingMore: Bool = false
@Published var errorMessage: String?
@Published var sendingErrorMessage: String?
@Published private(set) var isSending: Bool = false
@Published private(set) var hasMore: Bool = true
@ -75,12 +74,11 @@ final class PrivateChatViewModel: ObservableObject {
return
}
guard trimmed.count <= maxMessageLength else {
sendingErrorMessage = NSLocalizedString("Сообщение слишком длинное.", comment: "")
errorMessage = NSLocalizedString("Сообщение слишком длинное.", comment: "")
completion(false)
return
}
guard !isSending else {
sendingErrorMessage = NSLocalizedString("Дождитесь отправки предыдущего сообщения.", comment: "")
completion(false)
return
}
@ -90,7 +88,6 @@ final class PrivateChatViewModel: ObservableObject {
}
isSending = true
sendingErrorMessage = nil
chatService.sendPrivateMessage(chatId: chatId, content: trimmed) { [weak self] result in
guard let self else { return }
@ -116,7 +113,7 @@ final class PrivateChatViewModel: ObservableObject {
self.errorMessage = nil
completion(true)
case .failure(let error):
self.sendingErrorMessage = self.message(for: error)
self.errorMessage = self.message(for: error)
completion(false)
}
@ -216,4 +213,4 @@ final class PrivateChatViewModel: ObservableObject {
return lhs.messageId < rhs.messageId
}
}
}

View File

@ -22,7 +22,6 @@ struct PrivateChatView: View {
@State private var legacyComposerHeight: CGFloat = 40
@State private var isProfilePresented: Bool = false
@FocusState private var isComposerFocused: Bool
@EnvironmentObject private var themeManager: ThemeManager
@EnvironmentObject private var messageCenter: IncomingMessageCenter
@Environment(\.dismiss) private var dismiss
@ -66,14 +65,6 @@ struct PrivateChatView: View {
}
.hidden()
}
.alert("Ошибка отправки", isPresented: Binding(
get: { viewModel.sendingErrorMessage != nil },
set: { if !$0 { viewModel.sendingErrorMessage = nil } }
), actions: {
Button("OK") { }
}, message: {
Text(viewModel.sendingErrorMessage ?? "Не удалось отправить сообщение.")
})
.navigationTitle(toolbarTitle)
.navigationBarTitleDisplayMode(.inline)
// .navigationBarBackButtonHidden(true)
@ -253,213 +244,104 @@ struct PrivateChatView: View {
let topPadding: CGFloat = decoratedMessage.showHorns ? 5 : -12
let verticalPadding: CGFloat = hasDecorations ? 0 : 0
if #available(iOS 16.0, *) {
return HStack(alignment: .bottom, spacing: 8) {
if isCurrentUser { Spacer(minLength: 32) }
messageBubble(
for: message,
decorations: decoratedMessage,
isCurrentUser: isCurrentUser
)
if !isCurrentUser { Spacer(minLength: 32) }
}
.padding(.horizontal, 8)
.padding(.top, topPadding)
.padding(.vertical, verticalPadding)
.contextMenu(menuItems: {
if isCurrentUser {
if message.isViewed == true {
Text("Прочитано") // Placeholder for read status
}
Button(action: {
// Reply action
}) {
Text("Ответить")
Image(systemName: "arrowshape.turn.up.left")
}
Button(action: {
// Copy action
}) {
Text("Копировать")
Image(systemName: "doc.on.doc")
}
Button(action: {
// Edit action
}) {
Text("Изменить")
Image(systemName: "pencil")
}
Button(action: {
// Pin action
}) {
Text("Закрепить")
Image(systemName: "pin")
}
Button(action: {
// Forward action
}) {
Text("Переслать")
Image(systemName: "arrowshape.turn.up.right")
}
Button(role: .destructive, action: {
// Delete action
}) {
Text("Удалить")
Image(systemName: "trash")
}
Button(action: {
// Select action
}) {
Text("Выбрать")
Image(systemName: "checkmark.circle")
}
} else {
Button(action: {
// Reply action
}) {
Text("Ответить")
Image(systemName: "arrowshape.turn.up.left")
}
Button(action: {
// Copy action
}) {
Text("Копировать")
Image(systemName: "doc.on.doc")
}
Button(action: {
// Pin action
}) {
Text("Закрепить")
Image(systemName: "pin")
}
Button(action: {
// Forward action
}) {
Text("Переслать")
Image(systemName: "arrowshape.turn.up.right")
}
Button(role: .destructive, action: {
// Delete action
}) {
Text("Удалить")
Image(systemName: "trash")
}
Button(action: {
// Select action
}) {
Text("Выбрать")
Image(systemName: "checkmark.circle")
}
return HStack(alignment: .bottom, spacing: 8) {
if isCurrentUser { Spacer(minLength: 32) }
messageBubble(
for: message,
decorations: decoratedMessage,
isCurrentUser: isCurrentUser
)
if !isCurrentUser { Spacer(minLength: 32) }
}
.padding(.horizontal, 8)
.padding(.top, topPadding)
.padding(.vertical, verticalPadding)
.contextMenu {
if isCurrentUser {
if message.isViewed == true {
Text("Прочитано") // Placeholder for read status
}
}, preview: {
messageBubble(
for: message,
decorations: decoratedMessage,
isCurrentUser: isCurrentUser
)
})
} else {
return HStack(alignment: .bottom, spacing: 8) {
if isCurrentUser { Spacer(minLength: 32) }
messageBubble(
for: message,
decorations: decoratedMessage,
isCurrentUser: isCurrentUser
)
if !isCurrentUser { Spacer(minLength: 32) }
}
.padding(.horizontal, 8)
.padding(.top, topPadding)
.padding(.vertical, verticalPadding)
.contextMenu {
if isCurrentUser {
if message.isViewed == true {
Text("Прочитано") // Placeholder for read status
}
Button(action: {
// Reply action
}) {
Text("Ответить")
Image(systemName: "arrowshape.turn.up.left")
}
Button(action: {
// Copy action
}) {
Text("Копировать")
Image(systemName: "doc.on.doc")
}
Button(action: {
// Edit action
}) {
Text("Изменить")
Image(systemName: "pencil")
}
Button(action: {
// Pin action
}) {
Text("Закрепить")
Image(systemName: "pin")
}
Button(action: {
// Forward action
}) {
Text("Переслать")
Image(systemName: "arrowshape.turn.up.right")
}
Button(role: .destructive, action: {
// Delete action
}) {
Text("Удалить")
Image(systemName: "trash")
}
Button(action: {
// Select action
}) {
Text("Выбрать")
Image(systemName: "checkmark.circle")
}
} else {
Button(action: {
// Reply action
}) {
Text("Ответить")
Image(systemName: "arrowshape.turn.up.left")
}
Button(action: {
// Copy action
}) {
Text("Копировать")
Image(systemName: "doc.on.doc")
}
Button(action: {
// Pin action
}) {
Text("Закрепить")
Image(systemName: "pin")
}
Button(action: {
// Forward action
}) {
Text("Переслать")
Image(systemName: "arrowshape.turn.up.right")
}
Button(role: .destructive, action: {
// Delete action
}) {
Text("Удалить")
Image(systemName: "trash")
}
Button(action: {
// Select action
}) {
Text("Выбрать")
Image(systemName: "checkmark.circle")
}
Button(action: {
// Reply action
}) {
Text("Ответить")
Image(systemName: "arrowshape.turn.up.left")
}
Button(action: {
// Copy action
}) {
Text("Копировать")
Image(systemName: "doc.on.doc")
}
Button(action: {
// Edit action
}) {
Text("Изменить")
Image(systemName: "pencil")
}
Button(action: {
// Pin action
}) {
Text("Закрепить")
Image(systemName: "pin")
}
Button(action: {
// Forward action
}) {
Text("Переслать")
Image(systemName: "arrowshape.turn.up.right")
}
Button(role: .destructive, action: {
// Delete action
}) {
Text("Удалить")
Image(systemName: "trash")
}
Button(action: {
// Select action
}) {
Text("Выбрать")
Image(systemName: "checkmark.circle")
}
} else {
Button(action: {
// Reply action
}) {
Text("Ответить")
Image(systemName: "arrowshape.turn.up.left")
}
Button(action: {
// Copy action
}) {
Text("Копировать")
Image(systemName: "doc.on.doc")
}
Button(action: {
// Pin action
}) {
Text("Закрепить")
Image(systemName: "pin")
}
Button(action: {
// Forward action
}) {
Text("Переслать")
Image(systemName: "arrowshape.turn.up.right")
}
Button(role: .destructive, action: {
// Delete action
}) {
Text("Удалить")
Image(systemName: "trash")
}
Button(action: {
// Select action
}) {
Text("Выбрать")
Image(systemName: "checkmark.circle")
}
}
}
@ -656,7 +538,7 @@ struct PrivateChatView: View {
.padding(.horizontal, 6)
.padding(.top, 10)
.padding(.bottom, 8)
.modifier(ComposerBackgroundModifier(theme: themeManager.theme))
.background(.ultraThinMaterial)
}
private func scrollToBottomButton(proxy: ScrollViewProxy) -> some View {
@ -731,10 +613,10 @@ struct PrivateChatView: View {
let text = draftText.trimmingCharacters(in: .whitespacesAndNewlines)
guard !text.isEmpty else { return }
draftText = ""
scrollToBottomTrigger = .init()
viewModel.sendMessage(text: text) { success in
if success {
draftText = ""
hasPositionedToBottom = true
}
}
@ -1030,28 +912,6 @@ private var headerPlaceholderAvatar: some View {
}
private struct ComposerBackgroundModifier: ViewModifier {
let theme: Theme
@ViewBuilder
func body(content: Content) -> some View {
if theme == .oledDark {
content
.background(Color.black.opacity(0.85)) // глубокий чёрный
// .overlay(
// Color.black.opacity(0.25) // лёгкое затемнение сверху
// .allowsHitTesting(false)
// )
// content.background(.ultraThinMaterial)
// content.background(Color.black)
// content.background(Color(white: 0.15))
} else {
content.background(.ultraThinMaterial)
}
}
}
/// Helper model that stores a message alongside horn/leg flags for grouping sequences.
private struct DecoratedMessage: Identifiable {
let message: MessageItem