-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upping compose compile version to 1.5.7 Upping kotlin gradle plugin.
- Loading branch information
1 parent
417836d
commit 30d60d5
Showing
16 changed files
with
528 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
app/src/main/java/org/zotero/android/pdf/reader/pdfsearch/PdfReaderSearchPopup.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package org.zotero.android.pdf.reader.pdfsearch | ||
|
||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.shadow | ||
import androidx.compose.ui.platform.LocalDensity | ||
import androidx.compose.ui.unit.IntOffset | ||
import androidx.compose.ui.unit.IntRect | ||
import androidx.compose.ui.unit.IntSize | ||
import androidx.compose.ui.unit.LayoutDirection | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.window.Popup | ||
import androidx.compose.ui.window.PopupPositionProvider | ||
import androidx.compose.ui.window.PopupProperties | ||
import org.zotero.android.pdf.reader.PdfReaderVMInterface | ||
import org.zotero.android.pdf.reader.PdfReaderViewState | ||
import org.zotero.android.uicomponents.CustomScaffold | ||
import org.zotero.android.uicomponents.theme.CustomTheme | ||
|
||
@Composable | ||
internal fun PdfReaderSearchPopup( | ||
viewState: PdfReaderViewState, | ||
viewModel: PdfReaderVMInterface, | ||
) { | ||
val backgroundColor = CustomTheme.colors.cardBackground | ||
Popup( | ||
properties = PopupProperties( | ||
dismissOnBackPress = true, | ||
dismissOnClickOutside = true, | ||
focusable = true | ||
), | ||
onDismissRequest = viewModel::hidePdfSearch, | ||
popupPositionProvider = createPdfReaderSearchPopupPositionProvider(), | ||
|
||
) { | ||
CustomScaffold( | ||
modifier = Modifier | ||
.width(350.dp) | ||
.height(530.dp) | ||
.shadow( | ||
elevation = 4.dp, | ||
shape = RoundedCornerShape(16.dp), | ||
), | ||
backgroundColor = backgroundColor, | ||
) { | ||
PdfReaderSearchScreen(onBack = viewModel::hidePdfSearch) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun createPdfReaderSearchPopupPositionProvider() = object : PopupPositionProvider { | ||
val localDensity = LocalDensity.current | ||
override fun calculatePosition( | ||
anchorBounds: IntRect, | ||
windowSize: IntSize, | ||
layoutDirection: LayoutDirection, | ||
popupContentSize: IntSize | ||
): IntOffset { | ||
val extraXOffset = with(localDensity) { | ||
12.dp.toPx() | ||
}.toInt() | ||
val extraYOffset = with(localDensity) { | ||
8.dp.toPx() | ||
}.toInt() | ||
|
||
val xOffset = windowSize.width - popupContentSize.width - extraXOffset | ||
val yOffset = anchorBounds.bottom + extraYOffset | ||
|
||
return IntOffset( | ||
x = xOffset, | ||
y = yOffset | ||
) | ||
} | ||
} |
Oops, something went wrong.