diff --git a/Sources/Shared/Models/ChatMessage.swift b/Sources/Shared/Models/ChatMessage.swift index 954981b..b9e15e8 100644 --- a/Sources/Shared/Models/ChatMessage.swift +++ b/Sources/Shared/Models/ChatMessage.swift @@ -167,7 +167,8 @@ final class ChatMessage { var quotePreview: String { if isRetracted { return "Сообщение удалено" } let value = kind == .text ? body : previewText - let normalized = value + let normalized = + value .replacingOccurrences(of: "\n", with: " ") .trimmingCharacters(in: .whitespacesAndNewlines) guard normalized.count > 140 else { return normalized } @@ -264,4 +265,15 @@ final class ChatMessage { let bare = value[.. some View { if let data = model.mediaThumbnail(for: target) { -#if os(iOS) - if let image = ChatMediaImageCache.image(for: target, data: data) { - Image(uiImage: image) - .resizable() - .scaledToFill() - } else { - Image(systemName: replyMediaIcon(for: target.kind)) - .foregroundStyle(compactReplyColor) - } -#elseif os(macOS) - if let image = ChatMediaImageCache.image(for: target, data: data) { - Image(nsImage: image) - .resizable() - .scaledToFill() - } else { - Image(systemName: replyMediaIcon(for: target.kind)) - .foregroundStyle(compactReplyColor) - } -#endif + #if os(iOS) + if let image = ChatMediaImageCache.image(for: target, data: data) { + Image(uiImage: image) + .resizable() + .scaledToFill() + } else { + Image(systemName: replyMediaIcon(for: target.kind)) + .foregroundStyle(compactReplyColor) + } + #elseif os(macOS) + if let image = ChatMediaImageCache.image(for: target, data: data) { + Image(nsImage: image) + .resizable() + .scaledToFill() + } else { + Image(systemName: replyMediaIcon(for: target.kind)) + .foregroundStyle(compactReplyColor) + } + #endif } else { Image(systemName: replyMediaIcon(for: target.kind)) .font(.system(size: 12, weight: .semibold)) @@ -611,7 +643,9 @@ struct MessageBubble: View { ZStack { Circle() .fill(.white.opacity(message.direction == .outgoing ? 0.22 : 0.12)) - .frame(width: message.kind == .videoNote ? 58 : 38, height: message.kind == .videoNote ? 58 : 38) + .frame( + width: message.kind == .videoNote ? 58 : 38, + height: message.kind == .videoNote ? 58 : 38) Image(systemName: mediaIcon) .font(.system(size: message.kind == .videoNote ? 24 : 17)) } @@ -649,7 +683,8 @@ struct MessageBubble: View { parts.append(String(format: "%d:%02d", seconds / 60, seconds % 60)) } if let byteCount = message.byteCount { - parts.append(ByteCountFormatter.string(fromByteCount: Int64(byteCount), countStyle: .file)) + parts.append( + ByteCountFormatter.string(fromByteCount: Int64(byteCount), countStyle: .file)) } return parts.isEmpty ? "Нажмите для просмотра" : parts.joined(separator: " · ") } @@ -684,7 +719,10 @@ struct MessageBubble: View { private var bubbleBackground: some View { if message.direction == .outgoing { LinearGradient( - colors: [Color(red: 0.13, green: 0.51, blue: 0.94), Color(red: 0.12, green: 0.63, blue: 0.94)], + colors: [ + Color(red: 0.13, green: 0.51, blue: 0.94), + Color(red: 0.12, green: 0.63, blue: 0.94), + ], startPoint: .topLeading, endPoint: .bottomTrailing ) @@ -722,13 +760,13 @@ struct MessageBubble: View { } } -private extension View { +extension View { @ViewBuilder - func lumaTextSelection() -> some View { -#if os(macOS) - textSelection(.enabled) -#else - self -#endif + fileprivate func lumaTextSelection() -> some View { + #if os(macOS) + textSelection(.enabled) + #else + self + #endif } }