Add load more content button to the top bar
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
@@ -174,7 +174,7 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case .home:
|
case .home:
|
||||||
PostingTimelineView(damus_state: damus_state!, home: home, isSideBarOpened: $isSideBarOpened, active_sheet: $active_sheet, headerOffset: $headerOffset)
|
PostingTimelineView(damus_state: damus_state!, home: home, homeEvents: home.events, isSideBarOpened: $isSideBarOpened, active_sheet: $active_sheet, headerOffset: $headerOffset)
|
||||||
|
|
||||||
case .notifications:
|
case .notifications:
|
||||||
NotificationsView(state: damus, notifications: home.notifications, subtitle: $menu_subtitle)
|
NotificationsView(state: damus, notifications: home.notifications, subtitle: $menu_subtitle)
|
||||||
|
|||||||
@@ -29,26 +29,6 @@ struct InnerTimelineView: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
LazyVStack(spacing: 0) {
|
LazyVStack(spacing: 0) {
|
||||||
let incomingEvents = events.incoming.filter({ filter($0) })
|
|
||||||
if incomingEvents.count > 0 {
|
|
||||||
Button(
|
|
||||||
action: {
|
|
||||||
notify(.scroll_to_top)
|
|
||||||
},
|
|
||||||
label: {
|
|
||||||
HStack(spacing: 6) {
|
|
||||||
CondensedProfilePicturesView(state: state, pubkeys: incomingEvents.map({ $0.pubkey }), maxPictures: 3)
|
|
||||||
Text("Load new content", comment: "Button to load new notes in the timeline")
|
|
||||||
.bold()
|
|
||||||
}
|
|
||||||
.padding(.horizontal, 20)
|
|
||||||
.padding(.vertical, 10)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.buttonStyle(NeutralButtonStyle(cornerRadius: 50))
|
|
||||||
.padding(.vertical, 10)
|
|
||||||
}
|
|
||||||
|
|
||||||
let events = self.events.events
|
let events = self.events.events
|
||||||
if events.isEmpty {
|
if events.isEmpty {
|
||||||
EmptyTimelineView()
|
EmptyTimelineView()
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ struct PostingTimelineView: View {
|
|||||||
|
|
||||||
let damus_state: DamusState
|
let damus_state: DamusState
|
||||||
@ObservedObject var home: HomeModel
|
@ObservedObject var home: HomeModel
|
||||||
|
/// Set this to `home.events`. This is separate from `home` because we need the events object to be directly observed so that we get instant view updates
|
||||||
|
@ObservedObject var homeEvents: EventHolder
|
||||||
@State var search: String = ""
|
@State var search: String = ""
|
||||||
@State var results: [NostrEvent] = []
|
@State var results: [NostrEvent] = []
|
||||||
@State var initialOffset: CGFloat?
|
@State var initialOffset: CGFloat?
|
||||||
@@ -45,6 +47,7 @@ struct PostingTimelineView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func HeaderView() -> some View {
|
func HeaderView() -> some View {
|
||||||
|
VStack {
|
||||||
VStack {
|
VStack {
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
// This is needed for the Dynamic Island
|
// This is needed for the Dynamic Island
|
||||||
@@ -92,6 +95,27 @@ struct PostingTimelineView: View {
|
|||||||
DamusColors.adaptableWhite
|
DamusColors.adaptableWhite
|
||||||
.ignoresSafeArea()
|
.ignoresSafeArea()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if homeEvents.incoming.count > 0 {
|
||||||
|
Button(
|
||||||
|
action: {
|
||||||
|
notify(.scroll_to_top)
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
HStack(spacing: 6) {
|
||||||
|
CondensedProfilePicturesView(state: damus_state, pubkeys: homeEvents.incoming.map({ $0.pubkey }), maxPictures: 3)
|
||||||
|
.scaleEffect(0.75)
|
||||||
|
Text("Load new content", comment: "Button to load new notes in the timeline")
|
||||||
|
.bold()
|
||||||
|
}
|
||||||
|
.padding(.horizontal, 10)
|
||||||
|
.padding(.vertical, 5)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.buttonStyle(NeutralButtonStyle(cornerRadius: 50))
|
||||||
|
.padding(.vertical, 10)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
|||||||
Reference in New Issue
Block a user