Browse Source

enhance(mobile): show page above block in search results

Tienson Qin 1 tuần trước cách đây
mục cha
commit
ddcfe02091
2 tập tin đã thay đổi với 25 bổ sung13 xóa
  1. 21 11
      ios/App/App/LiquidTabsRootView.swift
  2. 4 2
      src/main/mobile/search.cljs

+ 21 - 11
ios/App/App/LiquidTabsRootView.swift

@@ -509,22 +509,32 @@ private struct SearchResultsContent: View {
     var body: some View {
         List(store.searchResults) { result in
             NavigationLink(value: result) {
-                Text(result.title)
-                  .foregroundColor(.primary)
-                  .padding(.vertical, 8)
-                  .contentShape(Rectangle())   // improves tap area
+                VStack(alignment: .leading, spacing: 4) {
+                    if let subtitle = result.subtitle,
+                       !subtitle.isEmpty {
+                        Text(subtitle)
+                          .font(.subheadline)
+                          .foregroundColor(.primary.opacity(0.7))
+                          .lineLimit(1)
+                    }
+
+                    Text(result.title)
+                      .foregroundColor(.primary.opacity(0.9))
+                }
+                .padding(.vertical, 4)
+                .contentShape(Rectangle())   // improves tap area
             }
-              .listRowBackground(Color.clear)
+            .listRowBackground(Color.clear)
         }
-          .scrollContentBackground(.hidden)
-          .scrollDismissesKeyboard(.immediately)
-          .navigationTitle("Search")
-          .navigationDestination(for: NativeSearchResult.self) { result in
-              NativeNavHost(navController: navController)
+        .scrollContentBackground(.hidden)
+        .scrollDismissesKeyboard(.immediately)
+        .navigationTitle("Search")
+        .navigationDestination(for: NativeSearchResult.self) { result in
+            NativeNavHost(navController: navController)
                 .ignoresSafeArea()
                 .onAppear {
                     LiquidTabsPlugin.shared?.openResult(id: result.id)
                 }
-          }
+        }
     }
 }

+ 4 - 2
src/main/mobile/search.cljs

@@ -42,13 +42,15 @@
   [item]
   (let [block (:source-block item)
         id (:block/uuid block)
-        title (some-> block :block/title string/trim)
+        title (some-> block :block.temp/original-title string/trim)
         subtitle (some-> block block->page-name string/trim)]
     (when (and id (not (string/blank? title)))
       (let [short-title (when title (safe-truncate title))]
         {:id (str id)
          :title short-title
-         :subtitle (when-not (string/blank? subtitle) subtitle)}))))
+         :subtitle (when-not (:page? block)
+                     (when-not (string/blank? subtitle)
+                       subtitle))}))))
 
 (defn search
   [input]