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:
committed by
William Casarin
parent
ea8394e7cf
commit
d7d8076bee
@@ -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)
|
||||
|
||||
29
damus/Views/Empty Views/EmptyTimelineView.swift
Normal file
29
damus/Views/Empty Views/EmptyTimelineView.swift
Normal 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()
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user