mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-03 22:45:39 +00:00
Migrating to Material3
This commit is contained in:
parent
aabfb47f2b
commit
a84ba25a79
@ -380,7 +380,7 @@ dependencies {
|
|||||||
implementation "androidx.compose.ui:ui-tooling:$composeVersion"
|
implementation "androidx.compose.ui:ui-tooling:$composeVersion"
|
||||||
implementation "androidx.compose.runtime:runtime-livedata:$composeVersion"
|
implementation "androidx.compose.runtime:runtime-livedata:$composeVersion"
|
||||||
implementation "androidx.compose.foundation:foundation-layout:$composeVersion"
|
implementation "androidx.compose.foundation:foundation-layout:$composeVersion"
|
||||||
implementation "androidx.compose.material:material:$composeVersion"
|
implementation "androidx.compose.material3:material3:1.2.1"
|
||||||
androidTestImplementation "androidx.compose.ui:ui-test-junit4-android:$composeVersion"
|
androidTestImplementation "androidx.compose.ui:ui-test-junit4-android:$composeVersion"
|
||||||
debugImplementation "androidx.compose.ui:ui-test-manifest:$composeVersion"
|
debugImplementation "androidx.compose.ui:ui-test-manifest:$composeVersion"
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import androidx.compose.foundation.layout.height
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
@ -7,9 +7,9 @@ import androidx.compose.foundation.layout.height
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
|
@ -8,8 +8,8 @@ import androidx.compose.foundation.layout.Spacer
|
|||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
@ -14,8 +14,8 @@ import androidx.compose.foundation.pager.HorizontalPager
|
|||||||
import androidx.compose.foundation.pager.rememberPagerState
|
import androidx.compose.foundation.pager.rememberPagerState
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
@ -27,9 +27,9 @@ import androidx.compose.foundation.pager.rememberPagerState
|
|||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
@ -3,8 +3,8 @@ package org.thoughtcrime.securesms.home
|
|||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
@ -10,7 +10,7 @@ import androidx.compose.foundation.layout.height
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.requiredWidth
|
import androidx.compose.foundation.layout.requiredWidth
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
@ -5,6 +5,7 @@ import androidx.compose.animation.AnimatedVisibility
|
|||||||
import androidx.compose.animation.core.tween
|
import androidx.compose.animation.core.tween
|
||||||
import androidx.compose.animation.fadeIn
|
import androidx.compose.animation.fadeIn
|
||||||
import androidx.compose.animation.slideInVertically
|
import androidx.compose.animation.slideInVertically
|
||||||
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
@ -16,9 +17,8 @@ import androidx.compose.foundation.layout.padding
|
|||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.material.Card
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material.Text
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
@ -39,16 +39,16 @@ import network.loki.messenger.R
|
|||||||
import org.thoughtcrime.securesms.ui.AlertDialog
|
import org.thoughtcrime.securesms.ui.AlertDialog
|
||||||
import org.thoughtcrime.securesms.ui.DialogButtonModel
|
import org.thoughtcrime.securesms.ui.DialogButtonModel
|
||||||
import org.thoughtcrime.securesms.ui.GetString
|
import org.thoughtcrime.securesms.ui.GetString
|
||||||
import org.thoughtcrime.securesms.ui.theme.LocalDimensions
|
|
||||||
import org.thoughtcrime.securesms.ui.theme.PreviewTheme
|
|
||||||
import org.thoughtcrime.securesms.ui.theme.SessionColorsParameterProvider
|
|
||||||
import org.thoughtcrime.securesms.ui.theme.ThemeColors
|
|
||||||
import org.thoughtcrime.securesms.ui.theme.LocalColors
|
|
||||||
import org.thoughtcrime.securesms.ui.components.BorderlessHtmlButton
|
import org.thoughtcrime.securesms.ui.components.BorderlessHtmlButton
|
||||||
import org.thoughtcrime.securesms.ui.components.PrimaryFillButton
|
import org.thoughtcrime.securesms.ui.components.PrimaryFillButton
|
||||||
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineButton
|
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineButton
|
||||||
import org.thoughtcrime.securesms.ui.contentDescription
|
import org.thoughtcrime.securesms.ui.contentDescription
|
||||||
|
import org.thoughtcrime.securesms.ui.theme.LocalColors
|
||||||
|
import org.thoughtcrime.securesms.ui.theme.LocalDimensions
|
||||||
import org.thoughtcrime.securesms.ui.theme.LocalType
|
import org.thoughtcrime.securesms.ui.theme.LocalType
|
||||||
|
import org.thoughtcrime.securesms.ui.theme.PreviewTheme
|
||||||
|
import org.thoughtcrime.securesms.ui.theme.SessionColorsParameterProvider
|
||||||
|
import org.thoughtcrime.securesms.ui.theme.ThemeColors
|
||||||
import kotlin.time.Duration.Companion.milliseconds
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
|
|
||||||
@Preview
|
@Preview
|
||||||
@ -208,11 +208,9 @@ private fun MessageText(
|
|||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
textColor: Color = Color.Unspecified
|
textColor: Color = Color.Unspecified
|
||||||
) {
|
) {
|
||||||
Card(
|
Box(
|
||||||
modifier = modifier.fillMaxWidth(0.666f),
|
modifier = modifier.fillMaxWidth(0.666f)
|
||||||
shape = MaterialTheme.shapes.small,
|
.background(color = color, shape = MaterialTheme.shapes.small)
|
||||||
backgroundColor = color,
|
|
||||||
elevation = 0.dp
|
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text,
|
text,
|
||||||
|
@ -13,8 +13,8 @@ import androidx.compose.foundation.pager.HorizontalPager
|
|||||||
import androidx.compose.foundation.pager.rememberPagerState
|
import androidx.compose.foundation.pager.rememberPagerState
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
@ -3,7 +3,7 @@ package org.thoughtcrime.securesms.onboarding.loading
|
|||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
@ -10,7 +10,7 @@ import androidx.compose.foundation.layout.fillMaxSize
|
|||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
@ -8,7 +8,7 @@ import androidx.compose.foundation.layout.height
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
@ -8,7 +8,7 @@ import androidx.compose.foundation.layout.fillMaxSize
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.pager.HorizontalPager
|
import androidx.compose.foundation.pager.HorizontalPager
|
||||||
import androidx.compose.foundation.pager.rememberPagerState
|
import androidx.compose.foundation.pager.rememberPagerState
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
@ -11,7 +11,7 @@ import androidx.compose.foundation.layout.width
|
|||||||
import androidx.compose.foundation.layout.wrapContentWidth
|
import androidx.compose.foundation.layout.wrapContentWidth
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.thoughtcrime.securesms.ui
|
package org.thoughtcrime.securesms.ui
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.IntrinsicSize
|
import androidx.compose.foundation.layout.IntrinsicSize
|
||||||
@ -8,11 +9,13 @@ import androidx.compose.foundation.layout.fillMaxHeight
|
|||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.Icon
|
import androidx.compose.material3.BasicAlertDialog
|
||||||
import androidx.compose.material.IconButton
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material.TextButton
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@ -39,6 +42,7 @@ class DialogButtonModel(
|
|||||||
val onClick: () -> Unit = {},
|
val onClick: () -> Unit = {},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun AlertDialog(
|
fun AlertDialog(
|
||||||
onDismissRequest: () -> Unit,
|
onDismissRequest: () -> Unit,
|
||||||
@ -48,12 +52,13 @@ fun AlertDialog(
|
|||||||
showCloseButton: Boolean = false,
|
showCloseButton: Boolean = false,
|
||||||
content: @Composable () -> Unit = {}
|
content: @Composable () -> Unit = {}
|
||||||
) {
|
) {
|
||||||
androidx.compose.material.AlertDialog(
|
BasicAlertDialog(
|
||||||
onDismissRequest,
|
onDismissRequest = onDismissRequest,
|
||||||
shape = MaterialTheme.shapes.small,
|
content = {
|
||||||
backgroundColor = LocalColors.current.backgroundSecondary,
|
Box(
|
||||||
buttons = {
|
modifier = Modifier.background(color = LocalColors.current.backgroundSecondary,
|
||||||
Box {
|
shape = MaterialTheme.shapes.small)
|
||||||
|
) {
|
||||||
// only show the 'x' button is required
|
// only show the 'x' button is required
|
||||||
if(showCloseButton) {
|
if(showCloseButton) {
|
||||||
IconButton(
|
IconButton(
|
||||||
|
@ -16,12 +16,8 @@ import androidx.compose.foundation.layout.size
|
|||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.pager.PagerState
|
import androidx.compose.foundation.pager.PagerState
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.material.Card
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material.ContentAlpha
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material.Icon
|
|
||||||
import androidx.compose.material.IconButton
|
|
||||||
import androidx.compose.material.LocalContentAlpha
|
|
||||||
import androidx.compose.material.LocalContentColor
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
@ -47,19 +43,17 @@ import kotlin.math.sign
|
|||||||
@OptIn(ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun BoxScope.HorizontalPagerIndicator(pagerState: PagerState) {
|
fun BoxScope.HorizontalPagerIndicator(pagerState: PagerState) {
|
||||||
if (pagerState.pageCount >= 2) Card(
|
if (pagerState.pageCount >= 2) Box(
|
||||||
shape = pillShape,
|
|
||||||
backgroundColor = blackAlpha40,
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
.background(color = blackAlpha40, shape = pillShape)
|
||||||
.align(Alignment.BottomCenter)
|
.align(Alignment.BottomCenter)
|
||||||
.padding(LocalDimensions.current.xxsSpacing)
|
.padding(LocalDimensions.current.xxsSpacing)
|
||||||
) {
|
) {
|
||||||
Box(modifier = Modifier.padding(LocalDimensions.current.xxsSpacing)) {
|
Box(modifier = Modifier.padding(LocalDimensions.current.xxsSpacing)) {
|
||||||
ClickableHorizontalPagerIndicator(
|
ClickableHorizontalPagerIndicator(
|
||||||
pagerState = pagerState,
|
pagerState = pagerState,
|
||||||
pageCount = pagerState.pageCount,
|
pageCount = pagerState.pageCount
|
||||||
activeColor = Color.White,
|
)
|
||||||
inactiveColor = LocalColors.current.textSecondary)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,8 +70,8 @@ fun ClickableHorizontalPagerIndicator(
|
|||||||
pageCount: Int,
|
pageCount: Int,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
pageIndexMapping: (Int) -> Int = { it },
|
pageIndexMapping: (Int) -> Int = { it },
|
||||||
activeColor: Color = LocalContentColor.current.copy(alpha = LocalContentAlpha.current),
|
activeColor: Color = Color.White,
|
||||||
inactiveColor: Color = activeColor.copy(ContentAlpha.disabled),
|
inactiveColor: Color = LocalColors.current.disabled,
|
||||||
indicatorWidth: Dp = LocalDimensions.current.xxsSpacing,
|
indicatorWidth: Dp = LocalDimensions.current.xxsSpacing,
|
||||||
indicatorHeight: Dp = indicatorWidth,
|
indicatorHeight: Dp = indicatorWidth,
|
||||||
spacing: Dp = indicatorWidth,
|
spacing: Dp = indicatorWidth,
|
||||||
@ -118,8 +112,8 @@ private fun HorizontalPagerIndicator(
|
|||||||
pageCount: Int,
|
pageCount: Int,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
pageIndexMapping: (Int) -> Int = { it },
|
pageIndexMapping: (Int) -> Int = { it },
|
||||||
activeColor: Color = LocalContentColor.current.copy(alpha = LocalContentAlpha.current),
|
activeColor: Color = Color.White,
|
||||||
inactiveColor: Color = activeColor.copy(ContentAlpha.disabled),
|
inactiveColor: Color = LocalColors.current.disabled,
|
||||||
indicatorWidth: Dp = LocalDimensions.current.xxsSpacing,
|
indicatorWidth: Dp = LocalDimensions.current.xxsSpacing,
|
||||||
indicatorHeight: Dp = indicatorWidth,
|
indicatorHeight: Dp = indicatorWidth,
|
||||||
spacing: Dp = indicatorWidth,
|
spacing: Dp = indicatorWidth,
|
||||||
|
@ -7,6 +7,7 @@ import androidx.compose.animation.AnimatedVisibility
|
|||||||
import androidx.compose.foundation.Canvas
|
import androidx.compose.foundation.Canvas
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.ScrollState
|
import androidx.compose.foundation.ScrollState
|
||||||
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.BoxScope
|
import androidx.compose.foundation.layout.BoxScope
|
||||||
import androidx.compose.foundation.layout.ColumnScope
|
import androidx.compose.foundation.layout.ColumnScope
|
||||||
@ -22,13 +23,14 @@ import androidx.compose.foundation.layout.wrapContentHeight
|
|||||||
import androidx.compose.foundation.layout.wrapContentSize
|
import androidx.compose.foundation.layout.wrapContentSize
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
import androidx.compose.material.ButtonColors
|
import androidx.compose.material3.ButtonColors
|
||||||
import androidx.compose.material.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.material.Icon
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.material.LocalContentColor
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material3.LocalContentColor
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material.TextButton
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
@ -67,7 +69,6 @@ import org.thoughtcrime.securesms.ui.theme.LocalColors
|
|||||||
import org.thoughtcrime.securesms.ui.theme.LocalDimensions
|
import org.thoughtcrime.securesms.ui.theme.LocalDimensions
|
||||||
import org.thoughtcrime.securesms.ui.theme.LocalType
|
import org.thoughtcrime.securesms.ui.theme.LocalType
|
||||||
import org.thoughtcrime.securesms.ui.theme.PreviewTheme
|
import org.thoughtcrime.securesms.ui.theme.PreviewTheme
|
||||||
import org.thoughtcrime.securesms.ui.theme.divider
|
|
||||||
import org.thoughtcrime.securesms.ui.theme.transparentButtonColors
|
import org.thoughtcrime.securesms.ui.theme.transparentButtonColors
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
@ -270,11 +271,10 @@ fun CellWithPaddingAndMargin(
|
|||||||
margin: Dp = LocalDimensions.current.spacing,
|
margin: Dp = LocalDimensions.current.spacing,
|
||||||
content: @Composable () -> Unit
|
content: @Composable () -> Unit
|
||||||
) {
|
) {
|
||||||
Card(
|
Box(
|
||||||
backgroundColor = LocalColors.current.backgroundSecondary,
|
|
||||||
shape = MaterialTheme.shapes.medium,
|
|
||||||
elevation = 0.dp,
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
.background(color = LocalColors.current.backgroundSecondary,
|
||||||
|
shape = MaterialTheme.shapes.small)
|
||||||
.wrapContentHeight()
|
.wrapContentHeight()
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(horizontal = margin),
|
.padding(horizontal = margin),
|
||||||
@ -342,10 +342,10 @@ fun Modifier.fadingEdges(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Divider(modifier: Modifier = Modifier, startIndent: Dp = 0.dp) {
|
fun Divider(modifier: Modifier = Modifier, startIndent: Dp = 0.dp) {
|
||||||
androidx.compose.material.Divider(
|
HorizontalDivider(
|
||||||
modifier = modifier.padding(horizontal = LocalDimensions.current.smallSpacing),
|
modifier = modifier.padding(horizontal = LocalDimensions.current.smallSpacing)
|
||||||
color = LocalColors.current.divider,
|
.padding(start = startIndent),
|
||||||
startIndent = startIndent
|
color = LocalColors.current.borders,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,9 +5,9 @@ import androidx.compose.foundation.layout.Row
|
|||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.material.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.thoughtcrime.securesms.ui.components
|
package org.thoughtcrime.securesms.ui.components
|
||||||
|
|
||||||
import androidx.compose.foundation.border
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.SolidColor
|
import androidx.compose.ui.graphics.SolidColor
|
||||||
|
@ -16,8 +16,8 @@ import androidx.compose.foundation.layout.PaddingValues
|
|||||||
import androidx.compose.foundation.layout.RowScope
|
import androidx.compose.foundation.layout.RowScope
|
||||||
import androidx.compose.foundation.layout.heightIn
|
import androidx.compose.foundation.layout.heightIn
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.ButtonColors
|
import androidx.compose.material3.ButtonColors
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
@ -66,16 +66,16 @@ fun Button(
|
|||||||
content: @Composable RowScope.() -> Unit
|
content: @Composable RowScope.() -> Unit
|
||||||
) {
|
) {
|
||||||
style.applyButtonConstraints {
|
style.applyButtonConstraints {
|
||||||
androidx.compose.material.Button(
|
androidx.compose.material3.Button(
|
||||||
onClick,
|
onClick = onClick,
|
||||||
modifier.heightIn(min = style.minHeight),
|
modifier = modifier.heightIn(min = style.minHeight),
|
||||||
enabled,
|
enabled = enabled,
|
||||||
interactionSource,
|
interactionSource = interactionSource,
|
||||||
elevation = null,
|
elevation = null,
|
||||||
shape,
|
shape = shape,
|
||||||
border,
|
border = border,
|
||||||
colors,
|
colors = colors,
|
||||||
contentPadding
|
contentPadding = contentPadding
|
||||||
) {
|
) {
|
||||||
// Button sets LocalTextStyle, so text style is applied inside to override that.
|
// Button sets LocalTextStyle, so text style is applied inside to override that.
|
||||||
style.applyTextConstraints {
|
style.applyTextConstraints {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package org.thoughtcrime.securesms.ui.components
|
package org.thoughtcrime.securesms.ui.components
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import androidx.compose.material.ExperimentalMaterialApi
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material.LocalMinimumInteractiveComponentEnforcement
|
import androidx.compose.material3.LocalMinimumInteractiveComponentEnforcement
|
||||||
import androidx.compose.material.LocalTextStyle
|
import androidx.compose.material3.LocalTextStyle
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.ui.text.TextStyle
|
import androidx.compose.ui.text.TextStyle
|
||||||
@ -14,7 +14,7 @@ import org.thoughtcrime.securesms.ui.theme.LocalType
|
|||||||
import org.thoughtcrime.securesms.ui.theme.bold
|
import org.thoughtcrime.securesms.ui.theme.bold
|
||||||
|
|
||||||
interface ButtonStyle {
|
interface ButtonStyle {
|
||||||
@OptIn(ExperimentalMaterialApi::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@SuppressLint("ComposableNaming")
|
@SuppressLint("ComposableNaming")
|
||||||
@Composable fun applyButtonConstraints(content: @Composable () -> Unit) {
|
@Composable fun applyButtonConstraints(content: @Composable () -> Unit) {
|
||||||
CompositionLocalProvider(
|
CompositionLocalProvider(
|
||||||
|
@ -2,13 +2,13 @@ package org.thoughtcrime.securesms.ui.components
|
|||||||
|
|
||||||
import androidx.compose.foundation.BorderStroke
|
import androidx.compose.foundation.BorderStroke
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.material.ButtonColors
|
import androidx.compose.material3.ButtonColors
|
||||||
import androidx.compose.material.ButtonDefaults
|
import androidx.compose.material3.ButtonDefaults
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import org.thoughtcrime.securesms.ui.theme.LocalDimensions
|
|
||||||
import org.thoughtcrime.securesms.ui.theme.LocalColors
|
import org.thoughtcrime.securesms.ui.theme.LocalColors
|
||||||
|
import org.thoughtcrime.securesms.ui.theme.LocalDimensions
|
||||||
|
|
||||||
private val disabledBorder @Composable get() = BorderStroke(
|
private val disabledBorder @Composable get() = BorderStroke(
|
||||||
width = LocalDimensions.current.borderStroke,
|
width = LocalDimensions.current.borderStroke,
|
||||||
@ -35,9 +35,9 @@ interface ButtonType {
|
|||||||
@Composable
|
@Composable
|
||||||
override fun buttonColors() = ButtonDefaults.buttonColors(
|
override fun buttonColors() = ButtonDefaults.buttonColors(
|
||||||
contentColor = contentColor,
|
contentColor = contentColor,
|
||||||
backgroundColor = Color.Unspecified,
|
containerColor = Color.Unspecified,
|
||||||
disabledContentColor = LocalColors.current.disabled,
|
disabledContentColor = LocalColors.current.disabled,
|
||||||
disabledBackgroundColor = Color.Unspecified
|
disabledContainerColor = Color.Transparent
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,9 +47,9 @@ interface ButtonType {
|
|||||||
@Composable
|
@Composable
|
||||||
override fun buttonColors() = ButtonDefaults.buttonColors(
|
override fun buttonColors() = ButtonDefaults.buttonColors(
|
||||||
contentColor = LocalColors.current.background,
|
contentColor = LocalColors.current.background,
|
||||||
backgroundColor = LocalColors.current.text,
|
containerColor = LocalColors.current.text,
|
||||||
disabledContentColor = LocalColors.current.disabled,
|
disabledContentColor = LocalColors.current.disabled,
|
||||||
disabledBackgroundColor = Color.Unspecified
|
disabledContainerColor = Color.Transparent
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,9 +59,9 @@ interface ButtonType {
|
|||||||
@Composable
|
@Composable
|
||||||
override fun buttonColors() = ButtonDefaults.buttonColors(
|
override fun buttonColors() = ButtonDefaults.buttonColors(
|
||||||
contentColor = LocalColors.current.primaryButtonFillText,
|
contentColor = LocalColors.current.primaryButtonFillText,
|
||||||
backgroundColor = LocalColors.current.primaryButtonFill,
|
containerColor = LocalColors.current.primaryButtonFill,
|
||||||
disabledContentColor = LocalColors.current.disabled,
|
disabledContentColor = LocalColors.current.disabled,
|
||||||
disabledBackgroundColor = Color.Unspecified
|
disabledContainerColor = Color.Transparent
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,8 +73,9 @@ interface ButtonType {
|
|||||||
@Composable
|
@Composable
|
||||||
override fun buttonColors() = ButtonDefaults.outlinedButtonColors(
|
override fun buttonColors() = ButtonDefaults.outlinedButtonColors(
|
||||||
contentColor = color,
|
contentColor = color,
|
||||||
backgroundColor = Color.Transparent,
|
containerColor = Color.Transparent,
|
||||||
disabledContentColor = LocalColors.current.disabled
|
disabledContentColor = LocalColors.current.disabled,
|
||||||
|
disabledContainerColor = Color.Transparent
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.thoughtcrime.securesms.ui.components
|
package org.thoughtcrime.securesms.ui.components
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.material.LocalContentColor
|
import androidx.compose.material3.LocalContentColor
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
@ -9,7 +9,7 @@ import androidx.compose.ui.unit.dp
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun CircularProgressIndicator(color: Color = LocalContentColor.current) {
|
fun CircularProgressIndicator(color: Color = LocalContentColor.current) {
|
||||||
androidx.compose.material.CircularProgressIndicator(
|
androidx.compose.material3.CircularProgressIndicator(
|
||||||
modifier = Modifier.size(40.dp),
|
modifier = Modifier.size(40.dp),
|
||||||
color = color,
|
color = color,
|
||||||
strokeWidth = 2.dp
|
strokeWidth = 2.dp
|
||||||
@ -18,7 +18,7 @@ fun CircularProgressIndicator(color: Color = LocalContentColor.current) {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SmallCircularProgressIndicator(color: Color = LocalContentColor.current) {
|
fun SmallCircularProgressIndicator(color: Color = LocalContentColor.current) {
|
||||||
androidx.compose.material.CircularProgressIndicator(
|
androidx.compose.material3.CircularProgressIndicator(
|
||||||
modifier = Modifier.size(20.dp),
|
modifier = Modifier.size(20.dp),
|
||||||
color = color,
|
color = color,
|
||||||
strokeWidth = 2.dp
|
strokeWidth = 2.dp
|
||||||
|
@ -22,11 +22,11 @@ import androidx.compose.foundation.layout.height
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material.Snackbar
|
import androidx.compose.material3.Snackbar
|
||||||
import androidx.compose.material.SnackbarHost
|
import androidx.compose.material3.SnackbarHost
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.SnackbarHostState
|
||||||
import androidx.compose.material.rememberScaffoldState
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.DisposableEffect
|
import androidx.compose.runtime.DisposableEffect
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
@ -56,8 +56,8 @@ import kotlinx.coroutines.flow.Flow
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.session.libsignal.utilities.Log
|
import org.session.libsignal.utilities.Log
|
||||||
import org.thoughtcrime.securesms.ui.theme.LocalDimensions
|
|
||||||
import org.thoughtcrime.securesms.ui.theme.LocalColors
|
import org.thoughtcrime.securesms.ui.theme.LocalColors
|
||||||
|
import org.thoughtcrime.securesms.ui.theme.LocalDimensions
|
||||||
import org.thoughtcrime.securesms.ui.theme.LocalType
|
import org.thoughtcrime.securesms.ui.theme.LocalType
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
|
|
||||||
@ -158,13 +158,12 @@ fun ScanQrCode(errors: Flow<String>, onScan: (String) -> Unit) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val scaffoldState = rememberScaffoldState()
|
val snackbarHostState = remember { SnackbarHostState() }
|
||||||
|
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
errors.collect { error ->
|
errors.collect { error ->
|
||||||
scaffoldState.snackbarHostState
|
snackbarHostState
|
||||||
.takeIf { it.currentSnackbarData == null }
|
.takeIf { it.currentSnackbarData == null }
|
||||||
?.run {
|
?.run {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
@ -175,17 +174,16 @@ fun ScanQrCode(errors: Flow<String>, onScan: (String) -> Unit) {
|
|||||||
// Don't use debounce() because many QR scans can come through each second,
|
// Don't use debounce() because many QR scans can come through each second,
|
||||||
// and each scan could restart the timer which could mean no scan gets
|
// and each scan could restart the timer which could mean no scan gets
|
||||||
// through until the user stops scanning; quite perplexing.
|
// through until the user stops scanning; quite perplexing.
|
||||||
showSnackbar(message = error)
|
snackbarHostState.showSnackbar(message = error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
scaffoldState = scaffoldState,
|
|
||||||
snackbarHost = {
|
snackbarHost = {
|
||||||
SnackbarHost(
|
SnackbarHost(
|
||||||
hostState = scaffoldState.snackbarHostState,
|
hostState = snackbarHostState,
|
||||||
modifier = Modifier.padding(LocalDimensions.current.smallSpacing)
|
modifier = Modifier.padding(LocalDimensions.current.smallSpacing)
|
||||||
) { data ->
|
) { data ->
|
||||||
Snackbar(
|
Snackbar(
|
||||||
|
@ -10,8 +10,8 @@ import androidx.compose.foundation.layout.aspectRatio
|
|||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.material.Card
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material.Icon
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
@ -32,8 +32,8 @@ import androidx.compose.ui.unit.dp
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.thoughtcrime.securesms.ui.theme.LocalDimensions
|
|
||||||
import org.thoughtcrime.securesms.ui.theme.LocalColors
|
import org.thoughtcrime.securesms.ui.theme.LocalColors
|
||||||
|
import org.thoughtcrime.securesms.ui.theme.LocalDimensions
|
||||||
import org.thoughtcrime.securesms.util.QRCodeUtilities
|
import org.thoughtcrime.securesms.util.QRCodeUtilities
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -56,10 +56,9 @@ fun QrImage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Card(
|
Box(
|
||||||
backgroundColor = LocalColors.current.qrCodeBackground,
|
modifier = modifier.background(color = LocalColors.current.qrCodeBackground,
|
||||||
elevation = 0.dp,
|
shape = MaterialTheme.shapes.small)
|
||||||
modifier = modifier
|
|
||||||
) { Content(bitmap, icon, Modifier.padding(contentPadding), backgroundColor = LocalColors.current.qrCodeBackground) }
|
) { Content(bitmap, icon, Modifier.padding(contentPadding), backgroundColor = LocalColors.current.qrCodeBackground) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,9 +20,9 @@ import androidx.compose.foundation.layout.size
|
|||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.selection.selectable
|
import androidx.compose.foundation.selection.selectable
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.material.LocalContentColor
|
import androidx.compose.material3.LocalContentColor
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material.TextButton
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package org.thoughtcrime.securesms.ui.components
|
package org.thoughtcrime.securesms.ui.components
|
||||||
|
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.layout.heightIn
|
||||||
import androidx.compose.foundation.layout.height
|
|
||||||
import androidx.compose.foundation.pager.PagerState
|
import androidx.compose.foundation.pager.PagerState
|
||||||
import androidx.compose.foundation.pager.rememberPagerState
|
import androidx.compose.foundation.pager.rememberPagerState
|
||||||
import androidx.compose.material.Tab
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.material.TabRow
|
import androidx.compose.material3.Tab
|
||||||
import androidx.compose.material.TabRowDefaults
|
import androidx.compose.material3.TabRow
|
||||||
import androidx.compose.material.TabRowDefaults.tabIndicatorOffset
|
import androidx.compose.material3.TabRowDefaults
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.TabRowDefaults.tabIndicatorOffset
|
||||||
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@ -25,7 +25,6 @@ import org.thoughtcrime.securesms.ui.theme.LocalType
|
|||||||
import org.thoughtcrime.securesms.ui.theme.PreviewTheme
|
import org.thoughtcrime.securesms.ui.theme.PreviewTheme
|
||||||
import org.thoughtcrime.securesms.ui.theme.SessionColorsParameterProvider
|
import org.thoughtcrime.securesms.ui.theme.SessionColorsParameterProvider
|
||||||
import org.thoughtcrime.securesms.ui.theme.ThemeColors
|
import org.thoughtcrime.securesms.ui.theme.ThemeColors
|
||||||
import org.thoughtcrime.securesms.ui.theme.divider
|
|
||||||
|
|
||||||
private val TITLES = listOf(R.string.sessionRecoveryPassword, R.string.qrScan)
|
private val TITLES = listOf(R.string.sessionRecoveryPassword, R.string.qrScan)
|
||||||
|
|
||||||
@ -33,31 +32,29 @@ private val TITLES = listOf(R.string.sessionRecoveryPassword, R.string.qrScan)
|
|||||||
@Composable
|
@Composable
|
||||||
fun SessionTabRow(pagerState: PagerState, titles: List<Int>) {
|
fun SessionTabRow(pagerState: PagerState, titles: List<Int>) {
|
||||||
TabRow(
|
TabRow(
|
||||||
backgroundColor = Color.Unspecified,
|
containerColor = Color.Unspecified,
|
||||||
selectedTabIndex = pagerState.currentPage,
|
selectedTabIndex = pagerState.currentPage,
|
||||||
contentColor = LocalColors.current.text,
|
contentColor = LocalColors.current.text,
|
||||||
indicator = { tabPositions ->
|
indicator = { tabPositions ->
|
||||||
TabRowDefaults.Indicator(
|
TabRowDefaults.SecondaryIndicator(
|
||||||
Modifier.tabIndicatorOffset(tabPositions[pagerState.currentPage]),
|
Modifier.tabIndicatorOffset(tabPositions[pagerState.currentPage]),
|
||||||
color = LocalColors.current.primary,
|
color = LocalColors.current.primary,
|
||||||
height = LocalDimensions.current.indicatorHeight
|
height = LocalDimensions.current.indicatorHeight
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
divider = { TabRowDefaults.Divider(color = LocalColors.current.divider) },
|
divider = { HorizontalDivider(color = LocalColors.current.borders) }
|
||||||
modifier = Modifier
|
|
||||||
.height(48.dp)
|
|
||||||
.background(color = Color.Unspecified)
|
|
||||||
) {
|
) {
|
||||||
val animationScope = rememberCoroutineScope()
|
val animationScope = rememberCoroutineScope()
|
||||||
titles.forEachIndexed { i, it ->
|
titles.forEachIndexed { i, it ->
|
||||||
Tab(
|
Tab(
|
||||||
i == pagerState.currentPage,
|
modifier = Modifier.heightIn(min = 48.dp),
|
||||||
|
selected = i == pagerState.currentPage,
|
||||||
onClick = { animationScope.launch { pagerState.animateScrollToPage(i) } },
|
onClick = { animationScope.launch { pagerState.animateScrollToPage(i) } },
|
||||||
selectedContentColor = LocalColors.current.text,
|
selectedContentColor = LocalColors.current.text,
|
||||||
unselectedContentColor = LocalColors.current.text,
|
unselectedContentColor = LocalColors.current.text,
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
stringResource(id = it),
|
text = stringResource(id = it),
|
||||||
style = LocalType.current.h8
|
style = LocalType.current.h8
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,9 @@ import androidx.compose.foundation.text.InlineTextContent
|
|||||||
import androidx.compose.foundation.text.KeyboardActions
|
import androidx.compose.foundation.text.KeyboardActions
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
import androidx.compose.foundation.text.appendInlineContent
|
import androidx.compose.foundation.text.appendInlineContent
|
||||||
import androidx.compose.material.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
package org.thoughtcrime.securesms.ui.theme
|
package org.thoughtcrime.securesms.ui.theme
|
||||||
|
|
||||||
import androidx.compose.material.Typography
|
import androidx.compose.material3.Typography
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.text.TextStyle
|
import androidx.compose.ui.text.TextStyle
|
||||||
import androidx.compose.ui.text.font.FontFamily
|
import androidx.compose.ui.text.font.FontFamily
|
||||||
import androidx.compose.ui.text.font.FontFamily.Companion.Monospace
|
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.TextUnit
|
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun TextStyle.bold() = TextStyle.Default.copy(
|
fun TextStyle.bold() = TextStyle.Default.copy(
|
||||||
fontWeight = FontWeight.Bold
|
fontWeight = FontWeight.Bold
|
||||||
)
|
)
|
||||||
@ -114,10 +111,9 @@ data class SessionTypography(
|
|||||||
fontWeight = FontWeight.Bold
|
fontWeight = FontWeight.Bold
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
//todo ready to go when we switch to Material3
|
|
||||||
|
|
||||||
// An opinionated override of Material's defaults
|
// An opinionated override of Material's defaults
|
||||||
/*@Composable
|
@Composable
|
||||||
fun asMaterialTypography() = Typography(
|
fun asMaterialTypography() = Typography(
|
||||||
// Display
|
// Display
|
||||||
displayLarge = h1,
|
displayLarge = h1,
|
||||||
@ -143,23 +139,6 @@ data class SessionTypography(
|
|||||||
labelLarge = extraSmall,
|
labelLarge = extraSmall,
|
||||||
labelMedium = fine,
|
labelMedium = fine,
|
||||||
labelSmall = fine
|
labelSmall = fine
|
||||||
)*/
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun asMaterialTypography() = Typography(
|
|
||||||
h1 = h1,
|
|
||||||
h2 = h2,
|
|
||||||
h3 = h3,
|
|
||||||
h4 = h4,
|
|
||||||
h5 = h5,
|
|
||||||
h6 = h6,
|
|
||||||
subtitle1 = h7,
|
|
||||||
subtitle2 = h8,
|
|
||||||
body1 = base,
|
|
||||||
body2 = small,
|
|
||||||
button = base,
|
|
||||||
caption = small,
|
|
||||||
overline = fine
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,12 +4,10 @@ import androidx.compose.foundation.background
|
|||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.text.selection.TextSelectionColors
|
import androidx.compose.foundation.text.selection.TextSelectionColors
|
||||||
import androidx.compose.material.ButtonDefaults
|
import androidx.compose.material3.ButtonDefaults
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material.RadioButtonDefaults
|
import androidx.compose.material3.darkColorScheme
|
||||||
import androidx.compose.material.TabRowDefaults
|
import androidx.compose.material3.lightColorScheme
|
||||||
import androidx.compose.material.Text
|
|
||||||
import androidx.compose.material.primarySurface
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
@ -37,55 +35,70 @@ interface ThemeColors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// extra functions and properties that work for all themes
|
// extra functions and properties that work for all themes
|
||||||
val ThemeColors.textSelectionColors get() = TextSelectionColors(
|
val ThemeColors.textSelectionColors
|
||||||
handleColor = primary,
|
get() = TextSelectionColors(
|
||||||
backgroundColor = primary.copy(alpha = 0.5f)
|
handleColor = primary,
|
||||||
)
|
backgroundColor = primary.copy(alpha = 0.5f)
|
||||||
|
)
|
||||||
val ThemeColors.divider get() = text.copy(alpha = TabRowDefaults.DividerOpacity)
|
|
||||||
|
|
||||||
fun ThemeColors.text(isError: Boolean): Color = if (isError) danger else text
|
fun ThemeColors.text(isError: Boolean): Color = if (isError) danger else text
|
||||||
fun ThemeColors.textSecondary(isError: Boolean): Color = if (isError) danger else textSecondary
|
fun ThemeColors.textSecondary(isError: Boolean): Color = if (isError) danger else textSecondary
|
||||||
fun ThemeColors.textEnabled(enabled: Boolean) = if (enabled) text else disabled
|
fun ThemeColors.textEnabled(enabled: Boolean) = if (enabled) text else disabled
|
||||||
fun ThemeColors.borders(isError: Boolean): Color = if (isError) danger else borders
|
fun ThemeColors.borders(isError: Boolean): Color = if (isError) danger else borders
|
||||||
|
|
||||||
fun ThemeColors.toMaterialColors() = androidx.compose.material.Colors(
|
fun ThemeColors.toMaterialColors() = if (isLight) {
|
||||||
primary = background,
|
lightColorScheme(
|
||||||
primaryVariant = backgroundSecondary,
|
primary = background,
|
||||||
secondary = background,
|
secondary = backgroundSecondary,
|
||||||
secondaryVariant = background,
|
tertiary = backgroundSecondary,
|
||||||
background = background,
|
onPrimary = text,
|
||||||
surface = background,
|
onSecondary = text,
|
||||||
error = danger,
|
onTertiary = text,
|
||||||
onPrimary = text,
|
background = background,
|
||||||
onSecondary = text,
|
surface = background,
|
||||||
onBackground = text,
|
surfaceVariant = background,
|
||||||
onSurface = text,
|
onBackground = text,
|
||||||
onError = text,
|
onSurface = text,
|
||||||
isLight = isLight
|
scrim = blackAlpha40,
|
||||||
)
|
outline = text,
|
||||||
|
outlineVariant = text
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
darkColorScheme(
|
||||||
|
primary = background,
|
||||||
|
secondary = backgroundSecondary,
|
||||||
|
tertiary = backgroundSecondary,
|
||||||
|
onPrimary = text,
|
||||||
|
onSecondary = text,
|
||||||
|
onTertiary = text,
|
||||||
|
background = background,
|
||||||
|
surface = background,
|
||||||
|
surfaceVariant = background,
|
||||||
|
onBackground = text,
|
||||||
|
onSurface = text,
|
||||||
|
scrim = blackAlpha40,
|
||||||
|
outline = text,
|
||||||
|
outlineVariant = text
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun ThemeColors.radioButtonColors() = RadioButtonDefaults.colors(
|
|
||||||
selectedColor = primary,
|
|
||||||
unselectedColor = text,
|
|
||||||
disabledColor = disabled
|
|
||||||
)
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun transparentButtonColors() = ButtonDefaults.buttonColors(
|
fun transparentButtonColors() = ButtonDefaults.buttonColors(
|
||||||
backgroundColor = Color.Transparent,
|
containerColor = Color.Transparent,
|
||||||
disabledBackgroundColor = Color.Transparent,
|
disabledContainerColor = Color.Transparent,
|
||||||
disabledContentColor = LocalColors.current.disabled
|
disabledContentColor = LocalColors.current.disabled
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun dangerButtonColors() = ButtonDefaults.buttonColors(backgroundColor = Color.Transparent, contentColor = LocalColors.current.danger)
|
fun dangerButtonColors() = ButtonDefaults.buttonColors(
|
||||||
|
containerColor = Color.Transparent,
|
||||||
|
contentColor = LocalColors.current.danger
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
// Our themes
|
// Our themes
|
||||||
data class ClassicDark(override val primary: Color = primaryGreen): ThemeColors {
|
data class ClassicDark(override val primary: Color = primaryGreen) : ThemeColors {
|
||||||
override val isLight = false
|
override val isLight = false
|
||||||
override val danger = dangerDark
|
override val danger = dangerDark
|
||||||
override val disabled = disabledDark
|
override val disabled = disabledDark
|
||||||
@ -103,7 +116,7 @@ data class ClassicDark(override val primary: Color = primaryGreen): ThemeColors
|
|||||||
override val primaryButtonFillText = Color.Black
|
override val primaryButtonFillText = Color.Black
|
||||||
}
|
}
|
||||||
|
|
||||||
data class ClassicLight(override val primary: Color = primaryGreen): ThemeColors {
|
data class ClassicLight(override val primary: Color = primaryGreen) : ThemeColors {
|
||||||
override val isLight = true
|
override val isLight = true
|
||||||
override val danger = dangerLight
|
override val danger = dangerLight
|
||||||
override val disabled = disabledLight
|
override val disabled = disabledLight
|
||||||
@ -121,7 +134,7 @@ data class ClassicLight(override val primary: Color = primaryGreen): ThemeColors
|
|||||||
override val primaryButtonFillText = Color.White
|
override val primaryButtonFillText = Color.White
|
||||||
}
|
}
|
||||||
|
|
||||||
data class OceanDark(override val primary: Color = primaryBlue): ThemeColors {
|
data class OceanDark(override val primary: Color = primaryBlue) : ThemeColors {
|
||||||
override val isLight = false
|
override val isLight = false
|
||||||
override val danger = dangerDark
|
override val danger = dangerDark
|
||||||
override val disabled = disabledDark
|
override val disabled = disabledDark
|
||||||
@ -139,7 +152,7 @@ data class OceanDark(override val primary: Color = primaryBlue): ThemeColors {
|
|||||||
override val primaryButtonFillText = Color.Black
|
override val primaryButtonFillText = Color.Black
|
||||||
}
|
}
|
||||||
|
|
||||||
data class OceanLight(override val primary: Color = primaryBlue): ThemeColors {
|
data class OceanLight(override val primary: Color = primaryBlue) : ThemeColors {
|
||||||
override val isLight = true
|
override val isLight = true
|
||||||
override val danger = dangerLight
|
override val danger = dangerLight
|
||||||
override val disabled = disabledLight
|
override val disabled = disabledLight
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
package org.thoughtcrime.securesms.ui.theme
|
package org.thoughtcrime.securesms.ui.theme
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.isSystemInDarkTheme
|
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.foundation.text.selection.LocalTextSelectionColors
|
import androidx.compose.foundation.text.selection.LocalTextSelectionColors
|
||||||
import androidx.compose.material.LocalContentColor
|
import androidx.compose.material3.LocalContentColor
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material.Shapes
|
import androidx.compose.material3.Shapes
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.runtime.compositionLocalOf
|
import androidx.compose.runtime.compositionLocalOf
|
||||||
import androidx.compose.runtime.staticCompositionLocalOf
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
@ -52,7 +49,7 @@ fun SessionMaterialTheme(
|
|||||||
content: @Composable () -> Unit
|
content: @Composable () -> Unit
|
||||||
) {
|
) {
|
||||||
MaterialTheme(
|
MaterialTheme(
|
||||||
colors = colors.toMaterialColors(),
|
colorScheme = colors.toMaterialColors(),
|
||||||
typography = sessionTypography.asMaterialTypography(),
|
typography = sessionTypography.asMaterialTypography(),
|
||||||
shapes = sessionShapes,
|
shapes = sessionShapes,
|
||||||
) {
|
) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user