This commit changes the thread view to a new UX concept where children views of the selected view are now presented as chat bubbles, and the entire tree of conversation is shown flattened. New interactions, layout, and design changes have been introduced to revamp the user experience. Testing ------- Device: A mix of iPhone physical devices and simulator iOS: A mix of iOS 17 versions Damus: A mix of versions leading up to this one. Coverage: 1. Unit tests are passing 2. A select few users have been using prototypes versions of this as their daily driver 3. Layout tested with an eclectic mix of threads 4. Posting new notes to the thread works 5. Clicking on reply quote view takes user to the mentioned message with a momentary visible highlight 6. Swipe actions work 7. Long press on chat bubbles works and shows emoji selector. Adding emoji sends the reaction 8. Clicking on notes selects them with an easy to follow transition Known issues: 1. The text on the reply quote view occasionally appears to be off-center (in about 10% of occurrences). The cause is still unknown 2. Long press will still show the emoji keyboard even if user is on "onlyzaps" mode 3. Quoted events are not rendered on chat bubbles. When user posts a quoted event with no text, that could lead to confusion Closes: https://github.com/damus-io/damus/issues/1126 Changelog-Added: Completely new threads experience that is easier and more pleasant to use Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
77 lines
2.6 KiB
Swift
77 lines
2.6 KiB
Swift
//
|
|
// TextEvent.swift
|
|
// damus
|
|
//
|
|
// Created by William Casarin on 2023-02-03.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct EventViewOptions: OptionSet {
|
|
let rawValue: UInt32
|
|
|
|
static let no_action_bar = EventViewOptions(rawValue: 1 << 0)
|
|
static let no_replying_to = EventViewOptions(rawValue: 1 << 1)
|
|
static let wide = EventViewOptions(rawValue: 1 << 3)
|
|
static let truncate_content = EventViewOptions(rawValue: 1 << 4)
|
|
static let no_translate = EventViewOptions(rawValue: 1 << 5)
|
|
static let small_pfp = EventViewOptions(rawValue: 1 << 6)
|
|
static let nested = EventViewOptions(rawValue: 1 << 7)
|
|
static let top_zap = EventViewOptions(rawValue: 1 << 8)
|
|
static let no_mentions = EventViewOptions(rawValue: 1 << 9)
|
|
static let no_media = EventViewOptions(rawValue: 1 << 10)
|
|
static let truncate_content_very_short = EventViewOptions(rawValue: 1 << 11)
|
|
static let no_previews = EventViewOptions(rawValue: 1 << 12)
|
|
static let no_show_more = EventViewOptions(rawValue: 1 << 13)
|
|
|
|
static let embedded: EventViewOptions = [.no_action_bar, .small_pfp, .wide, .truncate_content, .nested]
|
|
static let embedded_text_only: EventViewOptions = [.no_action_bar, .small_pfp, .wide, .truncate_content, .nested, .no_media, .truncate_content_very_short, .no_previews]
|
|
}
|
|
|
|
struct TextEvent: View {
|
|
let damus: DamusState
|
|
let event: NostrEvent
|
|
let pubkey: Pubkey
|
|
let options: EventViewOptions
|
|
let evdata: EventData
|
|
|
|
init(damus: DamusState, event: NostrEvent, pubkey: Pubkey, options: EventViewOptions) {
|
|
self.damus = damus
|
|
self.event = event
|
|
self.pubkey = pubkey
|
|
self.options = options
|
|
self.evdata = damus.events.get_cache_data(event.id)
|
|
}
|
|
|
|
var body: some View {
|
|
EventShell(state: damus, event: event, pubkey: pubkey, options: options) {
|
|
EvBody(options: options)
|
|
}
|
|
}
|
|
|
|
func EvBody(options: EventViewOptions) -> some View {
|
|
let blur_imgs = should_blur_images(settings: damus.settings, contacts: damus.contacts, ev: event, our_pubkey: damus.pubkey)
|
|
return NoteContentView(
|
|
damus_state: damus,
|
|
event: event,
|
|
blur_images: blur_imgs,
|
|
size: .normal,
|
|
options: options
|
|
)
|
|
}
|
|
|
|
}
|
|
|
|
struct TextEvent_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
VStack(spacing: 20) {
|
|
TextEvent(damus: test_damus_state, event: test_note, pubkey: test_pubkey, options: [])
|
|
.frame(height: 400)
|
|
|
|
TextEvent(damus: test_damus_state, event: test_note, pubkey: test_pubkey, options: [.wide])
|
|
.frame(height: 400)
|
|
}
|
|
}
|
|
}
|
|
|