damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit d7d8076bee0bc38ab210c8dfe92d0091b6b8e281
parent ea8394e7cf7ee550529bdfff9ec43e221a79f524
Author: Sam DuBois <sdubois@umass.edu>
Date:   Sat, 17 Dec 2022 15:26:03 -0700

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

Diffstat:
Mdamus.xcodeproj/project.pbxproj | 12++++++++++++
Mdamus/Views/DirectMessagesView.swift | 8++++++--
Adamus/Views/Empty Views/EmptyTimelineView.swift | 29+++++++++++++++++++++++++++++
Mdamus/Views/TimelineView.swift | 25+++++++++++++++----------
4 files changed, 62 insertions(+), 12 deletions(-)

diff --git a/damus.xcodeproj/project.pbxproj b/damus.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 3169CAE6294E69C000EE4006 /* EmptyTimelineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3169CAE5294E69C000EE4006 /* EmptyTimelineView.swift */; }; 4C06670128FC7C5900038D2A /* RelayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C06670028FC7C5900038D2A /* RelayView.swift */; }; 4C06670428FC7EC500038D2A /* Kingfisher in Frameworks */ = {isa = PBXBuildFile; productRef = 4C06670328FC7EC500038D2A /* Kingfisher */; }; 4C06670628FCB08600038D2A /* ImageCarousel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C06670528FCB08600038D2A /* ImageCarousel.swift */; }; @@ -146,6 +147,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 3169CAE5294E69C000EE4006 /* EmptyTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyTimelineView.swift; sourceTree = "<group>"; }; 4C06670028FC7C5900038D2A /* RelayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayView.swift; sourceTree = "<group>"; }; 4C06670528FCB08600038D2A /* ImageCarousel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageCarousel.swift; sourceTree = "<group>"; }; 4C06670828FDE64700038D2A /* damus-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "damus-Bridging-Header.h"; sourceTree = "<group>"; }; @@ -330,6 +332,14 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 3169CAE4294E699400EE4006 /* Empty Views */ = { + isa = PBXGroup; + children = ( + 3169CAE5294E69C000EE4006 /* EmptyTimelineView.swift */, + ); + path = "Empty Views"; + sourceTree = "<group>"; + }; 4C06670728FDE62900038D2A /* damus-c */ = { isa = PBXGroup; children = ( @@ -421,6 +431,7 @@ 4C75EFA227FA576C0006080F /* Views */ = { isa = PBXGroup; children = ( + 3169CAE4294E699400EE4006 /* Empty Views */, 4C75EFA327FA577B0006080F /* PostView.swift */, 4C75EFAC28049CFB0006080F /* PostButton.swift */, 4C75EFB82804A2740006080F /* EventView.swift */, @@ -778,6 +789,7 @@ 4C3AC79F2833115300E1F516 /* FollowButtonView.swift in Sources */, 4C3BEFD22819DB9B00B3DE84 /* ProfileModel.swift in Sources */, 4C0A3F93280F66F5000448DE /* ReplyMap.swift in Sources */, + 3169CAE6294E69C000EE4006 /* EmptyTimelineView.swift in Sources */, 4C3EA64928FF597700C48A62 /* bech32.c in Sources */, 4C90BD162839DB54008EE7EF /* NostrMetadata.swift in Sources */, 4C3EA67528FF7A5A00C48A62 /* take.c in Sources */, diff --git a/damus/Views/DirectMessagesView.swift b/damus/Views/DirectMessagesView.swift @@ -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) diff --git a/damus/Views/Empty Views/EmptyTimelineView.swift b/damus/Views/Empty Views/EmptyTimelineView.swift @@ -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() + } +} diff --git a/damus/Views/TimelineView.swift b/damus/Views/TimelineView.swift @@ -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 {