Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.ui.test.assertContentDescriptionEquals
import androidx.compose.ui.test.assertIsNotDisplayed
import androidx.compose.ui.test.assertIsSelected
import androidx.compose.ui.test.captureToImage
import androidx.compose.ui.test.click
import androidx.compose.ui.test.getUnclippedBoundsInRoot
import androidx.compose.ui.test.junit4.v2.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
Expand All @@ -25,6 +26,7 @@ import androidx.compose.ui.test.performTextReplacement
import androidx.compose.ui.test.performTouchInput
import androidx.compose.ui.test.swipeLeft
import androidx.compose.ui.test.swipeRight
import androidx.compose.ui.test.swipeUp
import androidx.compose.ui.semantics.SemanticsActions
import androidx.compose.ui.text.TextLayoutResult
import androidx.test.ext.junit.runners.AndroidJUnit4
Expand Down Expand Up @@ -215,6 +217,43 @@ class AndroidQueryResultViewsTest {
@Test fun tableVirtualizesLargeResultsAndEditsDistantCells() = assertVirtualResults("table")
@Test fun galleryVirtualizesLargeResultsAndRestoresEarlierCards() = assertVirtualResults("gallery")

@Test fun tagPageTableLastRowsCanBeTappedAboveBottomToolbar() {
mount { result ->
val query = result.getJSONArray("outlinerRows").getJSONObject(0)
.getJSONObject("block").getJSONObject("query")
val table = query.getJSONArray("views").getJSONObject(1)
val rowTemplate = table.getJSONArray("rows").getJSONObject(0).toString()
val rows = JSONArray()
repeat(24) { index ->
val row = JSONObject(rowTemplate)
val title = "Tagged result $index"
row.getJSONObject("block").put("uuid", "tag-row-$index").put("title", title)
row.getJSONArray("properties").getJSONObject(0).put("text", title)
rows.put(row)
}
table.put("rowsDeferred", true).put("rowCount", rows.length()).put("rowOffset", 0).put("rows", rows)
result.put("selectedPage", JSONObject().put("uuid", "collection").put("title", "Collection"))
result.put("selectedPageIsTag", true)
result.put("resultViews", JSONObject().put("ownerUuid", "collection")
.put("featureType", "class-objects").put("views", JSONArray().put(table)))
}

val toolbar = ui.onNodeWithTag("row.bottom.capture").assertIsDisplayed()
val viewport = ui.onNodeWithTag("view.table.viewport.table").assertIsDisplayed()
val toolbarTop = toolbar.getUnclippedBoundsInRoot().top
assertTrue("The table viewport must end above the bottom toolbar",
viewport.getUnclippedBoundsInRoot().bottom <= toolbarTop)
repeat(4) { viewport.performTouchInput { swipeUp() } }
for (index in 22..23) {
val cell = ui.onNodeWithTag("view.cell.table.tag-row-$index.block/title").assertIsDisplayed()
assertTrue("Row $index must fit above the bottom toolbar at the end of the table",
cell.getUnclippedBoundsInRoot().bottom <= toolbarTop)
cell.performTouchInput { click() }
ui.onNodeWithTag("view.edit.value.table").assertIsDisplayed()
ui.onNodeWithTag("view.edit.cancel.table").performClick()
}
}

@Test fun allViewSelectorAlignsLeadingAndKeepsAdaptiveWidth() {
mount { result ->
result.put("selectedPage", JSONObject().put("uuid", "collection").put("title", "Collection"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,22 @@ import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.IntState
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.platform.LocalFocusManager
Expand Down Expand Up @@ -101,6 +106,8 @@ private const val SEARCH_FINGERPRINT =
"13:query-changed[5:query:string:required],4:back[5:count:int:required]," +
"7:dismiss[],7:present[]"

private val LocalBottomChromeHeight = staticCompositionLocalOf<IntState?> { null }

fun logseqExtensionRegistry(
onOpenImage: ((String, String) -> Unit)? = null,
loadImage: (suspend (String, String) -> String)? = null,
Expand Down Expand Up @@ -328,6 +335,15 @@ fun logseqExtensionRegistry(
properties = listOf(LuiExtensionProperty("kind", LuiExtensionValueKind.STRING, required = true)),
builder = { AuthInput(string("kind") ?: "text") { Children() } },
)
registerTweak(
"android-result-page-inset",
"lui-tweak-v1|25:android-result-page-inset|profiles:android/kotlin|properties:",
properties = emptyList(),
) {
// Full-page results own a bounded scroll viewport. Keep its last row above the overlay.
val bottomInset = with(LocalDensity.current) { (LocalBottomChromeHeight.current?.intValue ?: 0).toDp() }
Box(Modifier.fillMaxSize().padding(bottom = bottomInset)) { Children() }
}
registerTweak(
"native-adaptive-insets",
"lui-tweak-v1|22:native-adaptive-insets|profiles:android/kotlin,ios/swiftui|properties:10:breakpoint:int:required:none,10:wide-inset:int:required:none",
Expand Down Expand Up @@ -439,10 +455,14 @@ private fun NavigationBoundary(context: LuiExtensionContext) {
// intrinsic measurements unsupported by subcomposed LUI layouts.
// Editor chrome needs an opaque container because autocomplete rows are
// translucent; otherwise journal text bleeds through above the IME.
val chromeHeight = remember { mutableIntStateOf(0) }
Box(Modifier.fillMaxSize()) {
Column(Modifier.fillMaxSize()) { NavigationContent(context, childIds[0], dismissesComposer) }
CompositionLocalProvider(LocalBottomChromeHeight provides chromeHeight) {
Column(Modifier.fillMaxSize()) { NavigationContent(context, childIds[0], dismissesComposer) }
}
val chromeModifier = Modifier
.align(Alignment.BottomCenter)
.onSizeChanged { chromeHeight.intValue = it.height }
.wrapContentHeight(unbounded = true)
Box(
if (context.flag("bottom-occupies-layout-space")) {
Expand Down
2 changes: 2 additions & 0 deletions shared/src/logseq/view.ml
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,8 @@ let extension_registry () =
Lui_extension.register_tweak registry (liquid_glass_schema ());
Lui_extension.register_tweak registry (native_control_tint_schema ());
Lui_extension.register_tweak registry (adaptive_content_insets_schema ());
Lui_extension.register_tweak registry (let open Lui_protocol in
Lui_extension.tweak "android-result-page-inset" [profile AndroidOS KotlinHost] []);
Lui_extension.register_tweak registry
(Lui_extension.tweak "sidebar-current-item"
[Lui_protocol.profile Lui_protocol.IOS Lui_protocol.SwiftUIHost]
Expand Down
13 changes: 11 additions & 2 deletions shared/src/logseq/view_outliner.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1098,9 +1098,18 @@ let page_title_inset context =
if Lui_ui.host context = KotlinHost then outliner_entry_inset + android_bullet_center_inset
else 16

let with_result_page_inset content =
custom (fun context parent ->
if Lui_ui.host context = KotlinHost then begin
let tweak = Lui_ui.platform_tweak context "android-result-page-inset" in
ignore (mount context ~parent:tweak content);
attach context parent tweak;
tweak
end else mount context ?parent content)

let with_result_page ?(root = false) context model_source send fallback : t =
reactive (fun full_page -> if not full_page then fallback else
column ~grow:1.0 ~gap:0 ~cross:`stretch ~accessibility_identifier:"page.results" [
with_result_page_inset (column ~grow:1.0 ~gap:0 ~cross:`stretch ~accessibility_identifier:"page.results" [
box ~height:16 [];
if_ ~test:(reactive View_base.active_node_has_breadcrumbs_ model_source)
(node_breadcrumbs model_source send);
Expand All @@ -1117,7 +1126,7 @@ let with_result_page ?(root = false) context model_source send fallback : t =
box ~grow:1.0 ~padding_horizontal:16 ~padding_vertical:8 [
View_query.collection ~fill_height:true ~render_block:(render_result_block context model_source)
model_source (Signal.map View_base.active_node_result_views model_source) send];
])
]))
(Signal.map (fun current ->
(View_base.current_content_is_tag_ current || View_base.current_content_is_property_ current)
&& View_base.page_content_ready_ current && View_base.active_node_result_views current <> "") model_source)
Expand Down
Loading