mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-06 00:36:09 +00:00
rename
This commit is contained in:
@@ -70,7 +70,7 @@ struct CIGroupInvitationView: View {
|
||||
}
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 6)
|
||||
.modifier(ChatBubblePadding(chatItem: chatItem))
|
||||
.modifier(ChatTailPadding(chatItem: chatItem))
|
||||
.background(chatItemFrameColor(chatItem, theme))
|
||||
.textSelection(.disabled)
|
||||
.onPreferenceChange(DetermineWidth.Key.self) { frameWidth = $0 }
|
||||
|
||||
@@ -72,7 +72,7 @@ struct FramedItemView: View {
|
||||
.accessibilityLabel("")
|
||||
}
|
||||
}
|
||||
.modifier(ChatBubblePadding(chatItem: chatItem))
|
||||
.modifier(ChatTailPadding(chatItem: chatItem))
|
||||
.background(chatItemFrameColorMaybeImageOrVideo(chatItem, theme))
|
||||
.onPreferenceChange(DetermineWidth.Key.self) { msgWidth = $0 }
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ struct MarkedDeletedItemView: View {
|
||||
.foregroundColor(theme.colors.secondary)
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 6)
|
||||
.modifier(ChatBubblePadding(chatItem: chatItem))
|
||||
.modifier(ChatTailPadding(chatItem: chatItem))
|
||||
.background(chatItemFrameColor(chatItem, theme))
|
||||
.textSelection(.disabled)
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ import SimpleXChat
|
||||
/// by retaining pill shape, even when ``ChatItem``'s height is less that twice its corner radius
|
||||
struct ChatItemClipped: ViewModifier {
|
||||
@AppStorage(DEFAULT_CHAT_ITEM_ROUNDNESS) private var roundness = defaultChatItemRoundness
|
||||
private let shapePath: ChatBubble.ShapePath
|
||||
private let itemShape: ChatItemShape
|
||||
|
||||
init() { shapePath = .roundRect(maxRadius: 8) }
|
||||
init() { itemShape = .roundRect(maxRadius: 8) }
|
||||
|
||||
init(_ chatItem: ChatItem, isTailVisible: Bool) {
|
||||
shapePath = switch chatItem.content {
|
||||
itemShape = switch chatItem.content {
|
||||
case
|
||||
.sndMsgContent,
|
||||
.rcvMsgContent,
|
||||
@@ -35,7 +35,9 @@ struct ChatItemClipped: ViewModifier {
|
||||
.rcvBlocked,
|
||||
.invalidJSON: .bubble(
|
||||
padding: ChatBubble.paddingEdge(for: chatItem),
|
||||
isTailVisible: Self.hidesTail(chatItem.content.msgContent) ? false : isTailVisible
|
||||
isTailVisible: Self.hidesTail(chatItem.content.msgContent)
|
||||
? false
|
||||
: isTailVisible
|
||||
)
|
||||
default: .roundRect(maxRadius: 8)
|
||||
}
|
||||
@@ -51,7 +53,7 @@ struct ChatItemClipped: ViewModifier {
|
||||
}
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
let shape = ChatBubble(roundness: roundness, shapePath: shapePath)
|
||||
let shape = ChatBubble(roundness: roundness, shapePath: itemShape)
|
||||
content
|
||||
.contentShape(.dragPreview, shape)
|
||||
.contentShape(.contextMenuPreview, shape)
|
||||
@@ -59,27 +61,11 @@ struct ChatItemClipped: ViewModifier {
|
||||
}
|
||||
}
|
||||
|
||||
struct ChatBubblePadding: ViewModifier {
|
||||
let chatItem: ChatItem
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
content.padding(
|
||||
chatItem.chatDir.sent ? .trailing : .leading,
|
||||
ChatBubble.tailSize
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
struct ChatBubble: Shape {
|
||||
enum ShapePath {
|
||||
case bubble(padding: HorizontalEdge, isTailVisible: Bool)
|
||||
case roundRect(maxRadius: Double)
|
||||
}
|
||||
|
||||
static let tailSize: Double = 8
|
||||
static let maxRadius: Double = 16
|
||||
let roundness: Double
|
||||
let shapePath: ShapePath
|
||||
fileprivate let roundness: Double
|
||||
fileprivate let shapePath: ChatItemShape
|
||||
|
||||
func path(in rect: CGRect) -> Path {
|
||||
switch shapePath {
|
||||
@@ -141,3 +127,19 @@ struct ChatBubble: Shape {
|
||||
chatItem.chatDir.sent ? .trailing : .leading
|
||||
}
|
||||
}
|
||||
|
||||
struct ChatTailPadding: ViewModifier {
|
||||
let chatItem: ChatItem
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
content.padding(
|
||||
chatItem.chatDir.sent ? .trailing : .leading,
|
||||
ChatBubble.tailSize
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate enum ChatItemShape {
|
||||
case bubble(padding: HorizontalEdge, isTailVisible: Bool)
|
||||
case roundRect(maxRadius: Double)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user