commit 9885ff19128ebd68d8bea992394f1f8d77e9e8d8
parent abb818bbd4c82878559bef43958b61e730327a84
Author: Daniel D’Aquino <daniel@daquino.me>
Date: Sat, 13 Jul 2024 00:31:22 +0000
Reduce minimum width for chat event view
Some users have reported that there is unwanted horizontal padding on
small messages. This was due to the minimum chat event view width. To
address this feedback, the minimum width has been reduced to a very
small amount, so that small messages with no other content can more
tightly hug the inner content.
Closes: https://github.com/damus-io/damus/issues/2312
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Diffstat:
3 files changed, 38 insertions(+), 9 deletions(-)
diff --git a/damus/TestData.swift b/damus/TestData.swift
@@ -36,6 +36,13 @@ let test_short_note =
createdAt: UInt32(Date().timeIntervalSince1970 - 100)
)!
+let test_super_short_note =
+ NostrEvent(
+ content: "A",
+ keypair: jack_keypair,
+ createdAt: UInt32(Date().timeIntervalSince1970 - 100)
+ )!
+
let test_note_json_with_escaped_slash = "{\"tags\":[],\"pubkey\":\"f8e6c64342f1e052480630e27e1016dce35fc3a614e60434fef4aa2503328ca9\",\"content\":\"https:\\/\\/cdn.nostr.build\\/i\\/5c1d3296f66c2630131bf123106486aeaf051ed8466031c0e0532d70b33cddb2.jpg\",\"created_at\":1691864981,\"kind\":1,\"sig\":\"fc0033aa3d4df50b692a5b346fa816fdded698de2045e36e0642a021391468c44ca69c2471adc7e92088131872d4aaa1e90ea6e1ad97f3cc748f4aed96dfae18\",\"id\":\"e8f6eca3b161abba034dac9a02bb6930ecde9fd2fb5d6c5f22a05526e11382cb\"}"
let test_encoded_note_with_image = NostrEvent.owned_from_json(json: test_note_json_with_escaped_slash)
diff --git a/damus/Views/Chat/ChatEventView.swift b/damus/Views/Chat/ChatEventView.swift
@@ -127,7 +127,7 @@ struct ChatEventView: View {
NoteContentView(damus_state: damus_state, event: event, blur_images: blur_images, size: .normal, options: [])
.padding(2)
}
- .frame(minWidth: 150, alignment: is_ours ? .trailing : .leading)
+ .frame(minWidth: 5, alignment: is_ours ? .trailing : .leading)
.padding(10)
}
.tint(is_ours ? Color.white : Color.accentColor)
@@ -254,13 +254,25 @@ struct ChatEventView: View {
SwipeView {
self.event_bubble_with_long_press_interaction
} leadingActions: { context in
- EventActionBar(
- damus_state: damus_state,
- event: event,
- bar: bar,
- options: is_ours ? [.swipe_action_menu_reverse] : [.swipe_action_menu],
- swipe_context: context
- )
+ if !is_ours {
+ EventActionBar(
+ damus_state: damus_state,
+ event: event,
+ bar: bar,
+ options: is_ours ? [.swipe_action_menu_reverse] : [.swipe_action_menu],
+ swipe_context: context
+ )
+ }
+ } trailingActions: { context in
+ if is_ours {
+ EventActionBar(
+ damus_state: damus_state,
+ event: event,
+ bar: bar,
+ options: is_ours ? [.swipe_action_menu_reverse] : [.swipe_action_menu],
+ swipe_context: context
+ )
+ }
}
.swipeSpacing(-20)
.swipeActionsStyle(.mask)
@@ -322,3 +334,8 @@ extension Notification.Name {
let bar = make_actionbar_model(ev: test_note.id, damus: test_damus_state)
return ChatEventView(event: test_short_note, selected_event: test_note, prev_ev: nil, next_ev: nil, damus_state: test_damus_state, thread: ThreadModel(event: test_note, damus_state: test_damus_state), scroll_to_event: nil, focus_event: nil, highlight_bubble: true, bar: bar)
}
+
+#Preview {
+ let bar = make_actionbar_model(ev: test_note.id, damus: test_damus_state)
+ return ChatEventView(event: test_super_short_note, selected_event: test_note, prev_ev: nil, next_ev: nil, damus_state: test_damus_state, thread: ThreadModel(event: test_note, damus_state: test_damus_state), scroll_to_event: nil, focus_event: nil, highlight_bubble: false, bar: bar)
+}
diff --git a/damus/Views/NoteContentView.swift b/damus/Views/NoteContentView.swift
@@ -390,7 +390,12 @@ struct NoteContentView_Previews: PreviewProvider {
NoteContentView(damus_state: state, event: test_note, blur_images: false, size: .normal, options: [])
}
.previewDisplayName("Short note")
-
+
+ VStack {
+ NoteContentView(damus_state: state, event: test_super_short_note, blur_images: true, size: .normal, options: [])
+ }
+ .previewDisplayName("Super short note")
+
VStack {
NoteContentView(damus_state: state, event: test_encoded_note_with_image!, blur_images: false, size: .normal, options: [])
}