-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #610 from gini/PP-881-skonto-content-description
feature(bank-sdk): Add contentDescription for Skonto
- Loading branch information
Showing
7 changed files
with
206 additions
and
45 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
62 changes: 62 additions & 0 deletions
62
...re-sdk/sdk/src/main/java/net/gini/android/capture/ui/components/tooltip/GiniTooltipBox.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,62 @@ | ||
@file:OptIn(ExperimentalMaterial3Api::class) | ||
|
||
package net.gini.android.capture.ui.components.tooltip | ||
|
||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.CaretProperties | ||
import androidx.compose.material3.CaretScope | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.PlainTooltip | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TooltipBox | ||
import androidx.compose.material3.TooltipDefaults | ||
import androidx.compose.material3.rememberTooltipState | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.unit.dp | ||
import net.gini.android.capture.ui.theme.GiniTheme | ||
|
||
@Composable | ||
fun GiniTooltipBox( | ||
tooltipText: String, | ||
modifier: Modifier = Modifier, | ||
colors: GiniTooltipBoxColors = GiniTooltipBoxColors.contentDescriptionColors(), | ||
content: @Composable () -> Unit, | ||
) { | ||
TooltipBox( | ||
modifier = modifier, | ||
positionProvider = TooltipDefaults.rememberPlainTooltipPositionProvider(8.dp), | ||
tooltip = { | ||
GiniPlainTooltip( | ||
containerColor = colors.containerColor, | ||
contentColor = colors.contentColor, | ||
) { | ||
Text( | ||
modifier = Modifier.padding(horizontal = 4.dp, vertical = 4.dp), | ||
text = tooltipText, | ||
style = GiniTheme.typography.body1 | ||
) | ||
} | ||
}, | ||
state = rememberTooltipState(), | ||
content = content, | ||
) | ||
} | ||
|
||
@Composable | ||
private fun CaretScope.GiniPlainTooltip( | ||
modifier: Modifier = Modifier, | ||
caretProperties: (CaretProperties)? = null, | ||
contentColor: Color, | ||
containerColor: Color, | ||
content: @Composable () -> Unit | ||
) { | ||
PlainTooltip( | ||
modifier = modifier, | ||
caretProperties = caretProperties, | ||
contentColor = contentColor, | ||
containerColor = containerColor, | ||
content = content | ||
) | ||
} |
32 changes: 32 additions & 0 deletions
32
.../sdk/src/main/java/net/gini/android/capture/ui/components/tooltip/GiniTooltipBoxColors.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,32 @@ | ||
package net.gini.android.capture.ui.components.tooltip | ||
|
||
import androidx.compose.foundation.isSystemInDarkTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.Immutable | ||
import androidx.compose.ui.graphics.Color | ||
|
||
@Immutable | ||
data class GiniTooltipBoxColors( | ||
val containerColor: Color, | ||
val contentColor: Color, | ||
) { | ||
companion object { | ||
|
||
@Composable | ||
fun contentDescriptionColors( | ||
containerColor: Color = getContentDescriptionContainerColors(), | ||
contentColor: Color = getContentDescriptionContentColors(), | ||
) = GiniTooltipBoxColors( | ||
containerColor = containerColor, | ||
contentColor = contentColor, | ||
) | ||
|
||
@Composable | ||
private fun getContentDescriptionContainerColors() = | ||
if (isSystemInDarkTheme()) Color.White.copy(alpha = 0.9f) else Color.Black | ||
|
||
@Composable | ||
private fun getContentDescriptionContentColors() = | ||
if (isSystemInDarkTheme()) Color.Black.copy(alpha = 0.9f) else Color.White | ||
} | ||
} |