Skip to content

Commit

Permalink
IOS-2593 Add backlinks swipe action
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-pusya committed Apr 9, 2024
1 parent acda026 commit 1c3ce6e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
4 changes: 4 additions & 0 deletions Anytype/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1897,6 +1897,10 @@ internal enum Loc {
/// Show backlinks
internal static let title = Loc.tr("Localizable", "Search.Backlinks.Show.title", fallback: "Show backlinks")
}
internal enum Swipe {
/// Backlinks
internal static let title = Loc.tr("Localizable", "Search.Backlinks.Swipe.title", fallback: "Backlinks")
}
}
}
internal enum Server {
Expand Down
1 change: 1 addition & 0 deletions Anytype/Resources/Strings/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@
"Create a new one or search for something else" = "Create a new one or search for something else";
"Search.Backlinks.Show.title" = "Show backlinks";
"Search.Backlinks.Header.title" = "Backlinks of: %@";
"Search.Backlinks.Swipe.title" = "Backlinks";

// MARK: - Home

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import SwiftUI

struct ListSectionHeaderView<Content>: View where Content: View {
let title: String
let increasedTopPadding: Bool
let rightContent: () -> Content?

init(title: String, @ViewBuilder rightContent: @escaping () -> Content? = { EmptyView() }) {
init(title: String, increasedTopPadding: Bool = true, @ViewBuilder rightContent: @escaping () -> Content? = { EmptyView() }) {
self.title = title
self.increasedTopPadding = increasedTopPadding
self.rightContent = rightContent
}

var body: some View {
SectionHeaderView(title: title, rightContent: rightContent)
SectionHeaderView(title: title, increasedTopPadding: increasedTopPadding, rightContent: rightContent)
.divider(spacing: 0, alignment: .leading)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import SwiftUI

struct SectionHeaderView<Content>: View where Content: View {
let title: String
let increasedTopPadding: Bool
let rightContent: () -> Content?

init(title: String, @ViewBuilder rightContent: @escaping () -> Content? = { EmptyView() }) {
init(title: String, increasedTopPadding: Bool = true, @ViewBuilder rightContent: @escaping () -> Content? = { EmptyView() }) {
self.title = title
self.increasedTopPadding = increasedTopPadding
self.rightContent = rightContent
}

Expand All @@ -17,7 +19,7 @@ struct SectionHeaderView<Content>: View where Content: View {
Spacer()
rightContent()
}
.padding(.top, 26)
.padding(.top, increasedTopPadding ? 26 : 8)
.padding(.bottom, 8)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@ struct GlobalSearchView: View {
}

private var searchResults: some View {
ScrollView {
LazyVStack(spacing: 0) {
ForEach(model.searchData) { section in
Section {
ForEach(section.searchData) { data in
itemRow(for: data)
}
} header: {
sectionHeader(for: section)
PlainList {
ForEach(model.searchData) { section in
Section {
ForEach(section.searchData) { data in
itemRow(for: data)
}
} header: {
sectionHeader(for: section)
}
}
}
Expand All @@ -53,7 +51,7 @@ struct GlobalSearchView: View {
@ViewBuilder
private func sectionHeader(for section: GlobalSearchDataSection) -> some View {
if let sectionConfig = section.sectionConfig {
ListSectionHeaderView(title: sectionConfig.title) {
ListSectionHeaderView(title: sectionConfig.title, increasedTopPadding: false) {
Button {
model.clear()
} label: {
Expand All @@ -78,6 +76,11 @@ struct GlobalSearchView: View {
model.showBacklinks(data)
}
}
.swipeActions {
Button(Loc.Search.Backlinks.Swipe.title) {
model.showBacklinks(data)
}
}
}
}

Expand Down

0 comments on commit 1c3ce6e

Please sign in to comment.