From 1c3ce6ecc524d93416e07b6c4b3a1c1cd5320e3e Mon Sep 17 00:00:00 2001 From: Anna Zakharova Date: Tue, 9 Apr 2024 16:15:15 +0100 Subject: [PATCH] IOS-2593 Add backlinks swipe action --- Anytype/Generated/Strings.swift | 4 ++++ .../Strings/en.lproj/Localizable.strings | 1 + .../SwiftUI/List/ListSectionHeaderView.swift | 6 +++-- .../SwiftUI/List/SectionHeaderView.swift | 6 +++-- .../GlobalSearch/GlobalSearchView.swift | 23 +++++++++++-------- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Anytype/Generated/Strings.swift b/Anytype/Generated/Strings.swift index e1aa0abb24..6dbcc638cd 100644 --- a/Anytype/Generated/Strings.swift +++ b/Anytype/Generated/Strings.swift @@ -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 { diff --git a/Anytype/Resources/Strings/en.lproj/Localizable.strings b/Anytype/Resources/Strings/en.lproj/Localizable.strings index 5032c1a6a5..d9ea9ef40e 100644 --- a/Anytype/Resources/Strings/en.lproj/Localizable.strings +++ b/Anytype/Resources/Strings/en.lproj/Localizable.strings @@ -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 diff --git a/Anytype/Sources/PresentationLayer/Common/SwiftUI/List/ListSectionHeaderView.swift b/Anytype/Sources/PresentationLayer/Common/SwiftUI/List/ListSectionHeaderView.swift index 31646a8fcb..c8a7c8665c 100644 --- a/Anytype/Sources/PresentationLayer/Common/SwiftUI/List/ListSectionHeaderView.swift +++ b/Anytype/Sources/PresentationLayer/Common/SwiftUI/List/ListSectionHeaderView.swift @@ -2,15 +2,17 @@ import SwiftUI struct ListSectionHeaderView: 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) } } diff --git a/Anytype/Sources/PresentationLayer/Common/SwiftUI/List/SectionHeaderView.swift b/Anytype/Sources/PresentationLayer/Common/SwiftUI/List/SectionHeaderView.swift index 3042a61f14..da88a809e3 100644 --- a/Anytype/Sources/PresentationLayer/Common/SwiftUI/List/SectionHeaderView.swift +++ b/Anytype/Sources/PresentationLayer/Common/SwiftUI/List/SectionHeaderView.swift @@ -3,10 +3,12 @@ import SwiftUI struct SectionHeaderView: 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 } @@ -17,7 +19,7 @@ struct SectionHeaderView: View where Content: View { Spacer() rightContent() } - .padding(.top, 26) + .padding(.top, increasedTopPadding ? 26 : 8) .padding(.bottom, 8) } } diff --git a/Anytype/Sources/PresentationLayer/Common/SwiftUI/Search/GlobalSearch/GlobalSearchView.swift b/Anytype/Sources/PresentationLayer/Common/SwiftUI/Search/GlobalSearch/GlobalSearchView.swift index 3e064fc40d..3d7fe722ee 100644 --- a/Anytype/Sources/PresentationLayer/Common/SwiftUI/Search/GlobalSearch/GlobalSearchView.swift +++ b/Anytype/Sources/PresentationLayer/Common/SwiftUI/Search/GlobalSearch/GlobalSearchView.swift @@ -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) } } } @@ -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: { @@ -78,6 +76,11 @@ struct GlobalSearchView: View { model.showBacklinks(data) } } + .swipeActions { + Button(Loc.Search.Backlinks.Swipe.title) { + model.showBacklinks(data) + } + } } }