Adding a small empty timeline view to make it more obvious when there is no content and when there is content

This commit is contained in:
Sam DuBois
2022-12-17 15:26:03 -07:00
committed by William Casarin
parent ea8394e7cf
commit d7d8076bee
4 changed files with 62 additions and 12 deletions

View File

@@ -14,8 +14,12 @@ struct DirectMessagesView: View {
var MainContent: some View {
ScrollView {
LazyVStack {
ForEach(model.dms, id: \.0) { tup in
MaybeEvent(tup)
if model.dms.isEmpty, !model.loading {
EmptyTimelineView()
} else {
ForEach(model.dms, id: \.0) { tup in
MaybeEvent(tup)
}
}
}
.padding(.horizontal)

View File

@@ -0,0 +1,29 @@
//
// EmptyNotificationsView.swift
// damus
//
// Created by Sam DuBois on 12/17/22.
//
import SwiftUI
struct EmptyTimelineView: View {
var body: some View {
VStack {
Image(systemName: "tray.fill")
.font(.system(size: 35))
.padding()
Text("Nothing to see here. Check back later!")
.multilineTextAlignment(.center)
.font(.callout.weight(.medium))
}
.foregroundColor(.gray)
.padding()
}
}
struct EmptyTimelineView_Previews: PreviewProvider {
static var previews: some View {
EmptyTimelineView()
}
}

View File

@@ -20,16 +20,20 @@ struct InnerTimelineView: View {
var body: some View {
LazyVStack {
ForEach(events.filter(filter), id: \.id) { (ev: NostrEvent) in
let tm = ThreadModel(event: inner_event_or_self(ev: ev), damus_state: damus)
let is_chatroom = should_show_chatroom(ev)
let tv = ThreadView(thread: tm, damus: damus, is_chatroom: is_chatroom)
NavigationLink(destination: tv) {
EventView(event: ev, highlight: .none, has_action_bar: true, damus: damus, show_friend_icon: show_friend_icon)
if events.isEmpty {
EmptyTimelineView()
} else {
ForEach(events.filter(filter), id: \.id) { (ev: NostrEvent) in
let tm = ThreadModel(event: inner_event_or_self(ev: ev), damus_state: damus)
let is_chatroom = should_show_chatroom(ev)
let tv = ThreadView(thread: tm, damus: damus, is_chatroom: is_chatroom)
NavigationLink(destination: tv) {
EventView(event: ev, highlight: .none, has_action_bar: true, damus: damus, show_friend_icon: show_friend_icon)
}
.isDetailLink(true)
.buttonStyle(PlainButtonStyle())
}
.isDetailLink(true)
.buttonStyle(PlainButtonStyle())
}
}
.padding(.horizontal)
@@ -54,8 +58,9 @@ struct TimelineView: View {
if loading {
ProgressView()
.progressViewStyle(.circular)
} else {
InnerTimelineView(events: $events, damus: damus, show_friend_icon: show_friend_icon, filter: filter)
}
InnerTimelineView(events: $events, damus: damus, show_friend_icon: show_friend_icon, filter: filter)
}
.onReceive(NotificationCenter.default.publisher(for: .scroll_to_top)) { _ in
guard let event = events.filter(self.filter).first else {