This commit is contained in:
SessionHero01 2024-10-31 15:10:58 +11:00
parent 7520571a7d
commit 02d4741bd7
No known key found for this signature in database
13 changed files with 147 additions and 137 deletions

View File

@ -1,6 +1,5 @@
package org.thoughtcrime.securesms.conversation.disappearingmessages.ui package org.thoughtcrime.securesms.conversation.disappearingmessages.ui
import androidx.compose.foundation.layout.Box
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.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
@ -12,19 +11,19 @@ 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
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import network.loki.messenger.R import network.loki.messenger.R
import network.loki.messenger.libsession_util.util.ExpiryMode import network.loki.messenger.libsession_util.util.ExpiryMode
import org.thoughtcrime.securesms.ui.BottomFadingEdgeBox
import org.thoughtcrime.securesms.ui.Callbacks import org.thoughtcrime.securesms.ui.Callbacks
import org.thoughtcrime.securesms.ui.NoOpCallbacks import org.thoughtcrime.securesms.ui.NoOpCallbacks
import org.thoughtcrime.securesms.ui.OptionsCard import org.thoughtcrime.securesms.ui.OptionsCard
import org.thoughtcrime.securesms.ui.RadioOption import org.thoughtcrime.securesms.ui.RadioOption
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineButton import org.thoughtcrime.securesms.ui.components.PrimaryOutlineButton
import org.thoughtcrime.securesms.ui.components.SlimOutlineButton
import org.thoughtcrime.securesms.ui.contentDescription import org.thoughtcrime.securesms.ui.contentDescription
import org.thoughtcrime.securesms.ui.fadingEdges
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.LocalDimensions
import org.thoughtcrime.securesms.ui.theme.LocalType import org.thoughtcrime.securesms.ui.theme.LocalType
@ -38,15 +37,12 @@ fun DisappearingMessages(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
callbacks: ExpiryCallbacks = NoOpCallbacks callbacks: ExpiryCallbacks = NoOpCallbacks
) { ) {
val scrollState = rememberScrollState()
Column(modifier = modifier.padding(horizontal = LocalDimensions.current.spacing)) { Column(modifier = modifier.padding(horizontal = LocalDimensions.current.spacing)) {
Box(modifier = Modifier.weight(1f)) { BottomFadingEdgeBox(modifier = Modifier.weight(1f)) { bottomContentPadding ->
Column( Column(
modifier = Modifier modifier = Modifier
.padding(vertical = LocalDimensions.current.spacing) .verticalScroll(rememberScrollState())
.verticalScroll(scrollState) .padding(vertical = LocalDimensions.current.spacing),
.fadingEdges(scrollState),
) { ) {
state.cards.forEachIndexed { index, option -> state.cards.forEachIndexed { index, option ->
OptionsCard(option, callbacks) OptionsCard(option, callbacks)
@ -69,6 +65,8 @@ fun DisappearingMessages(
.fillMaxWidth() .fillMaxWidth()
.padding(top = LocalDimensions.current.xsSpacing) .padding(top = LocalDimensions.current.xsSpacing)
) )
Spacer(modifier = Modifier.height(bottomContentPadding))
} }
} }

View File

@ -6,6 +6,8 @@ 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
import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
@ -17,8 +19,11 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
@ -28,6 +33,7 @@ import org.session.libsignal.utilities.AccountId
import org.thoughtcrime.securesms.groups.ContactItem import org.thoughtcrime.securesms.groups.ContactItem
import org.thoughtcrime.securesms.groups.CreateGroupEvent import org.thoughtcrime.securesms.groups.CreateGroupEvent
import org.thoughtcrime.securesms.groups.CreateGroupViewModel import org.thoughtcrime.securesms.groups.CreateGroupViewModel
import org.thoughtcrime.securesms.ui.BottomFadingEdgeBox
import org.thoughtcrime.securesms.ui.LoadingArcOr import org.thoughtcrime.securesms.ui.LoadingArcOr
import org.thoughtcrime.securesms.ui.SearchBar import org.thoughtcrime.securesms.ui.SearchBar
import org.thoughtcrime.securesms.ui.components.BackAppBar import org.thoughtcrime.securesms.ui.components.BackAppBar
@ -104,11 +110,10 @@ fun CreateGroup(
) )
} }
) { paddings -> ) { paddings ->
Box(modifier = modifier.padding(paddings),) { Box(modifier = modifier.padding(paddings)) {
Column( Column(
modifier = modifier.padding(vertical = LocalDimensions.current.spacing), modifier = modifier.padding(vertical = LocalDimensions.current.xsSpacing),
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.spacing)
) { ) {
SessionOutlinedTextField( SessionOutlinedTextField(
text = groupName, text = groupName,
@ -122,6 +127,8 @@ fun CreateGroup(
onContinue = focusManager::clearFocus onContinue = focusManager::clearFocus
) )
Spacer(modifier = Modifier.height(LocalDimensions.current.spacing))
SearchBar( SearchBar(
query = contactSearchQuery, query = contactSearchQuery,
onValueChanged = onContactSearchQueryChanged, onValueChanged = onContactSearchQueryChanged,
@ -130,17 +137,30 @@ fun CreateGroup(
enabled = !showLoading enabled = !showLoading
) )
LazyColumn(modifier = Modifier.weight(1f)) { Spacer(modifier = Modifier.height(LocalDimensions.current.spacing))
BottomFadingEdgeBox(
modifier = Modifier.weight(1f)
.nestedScroll(rememberNestedScrollInteropConnection()),
fadingColor = LocalColors.current.backgroundSecondary
) { bottomContentPadding ->
LazyColumn(
contentPadding = PaddingValues(bottom = bottomContentPadding)) {
multiSelectMemberList( multiSelectMemberList(
contacts = items, contacts = items,
onContactItemClicked = onContactItemClicked, onContactItemClicked = onContactItemClicked,
enabled = !showLoading enabled = !showLoading
) )
} }
}
Spacer(modifier = Modifier.height(LocalDimensions.current.xsSpacing))
PrimaryOutlineButton( PrimaryOutlineButton(
onClick = onCreateClicked, onClick = onCreateClicked,
modifier = Modifier.widthIn(min = 120.dp) modifier = Modifier
.padding(horizontal = LocalDimensions.current.spacing)
.widthIn(min = LocalDimensions.current.minButtonWidth)
) { ) {
LoadingArcOr(loading = showLoading) { LoadingArcOr(loading = showLoading) {
Text(stringResource(R.string.create)) Text(stringResource(R.string.create))

View File

@ -1,35 +1,35 @@
package org.thoughtcrime.securesms.groups.compose package org.thoughtcrime.securesms.groups.compose
import androidx.annotation.StringRes import androidx.annotation.StringRes
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
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.defaultMinSize import androidx.compose.foundation.layout.defaultMinSize
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.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.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.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush.Companion.verticalGradient
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel import androidx.hilt.navigation.compose.hiltViewModel
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import network.loki.messenger.R import network.loki.messenger.R
import org.session.libsignal.utilities.AccountId import org.session.libsignal.utilities.AccountId
import org.thoughtcrime.securesms.groups.ContactItem import org.thoughtcrime.securesms.groups.ContactItem
import org.thoughtcrime.securesms.groups.SelectContactsViewModel import org.thoughtcrime.securesms.groups.SelectContactsViewModel
import org.thoughtcrime.securesms.ui.BottomFadingEdgeBox
import org.thoughtcrime.securesms.ui.SearchBar import org.thoughtcrime.securesms.ui.SearchBar
import org.thoughtcrime.securesms.ui.components.BackAppBar import org.thoughtcrime.securesms.ui.components.BackAppBar
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineButton import org.thoughtcrime.securesms.ui.components.PrimaryOutlineButton
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.PreviewTheme import org.thoughtcrime.securesms.ui.theme.PreviewTheme
@ -67,7 +67,7 @@ fun SelectContacts(
onBack: () -> Unit, onBack: () -> Unit,
@StringRes okButtonResId: Int = R.string.ok @StringRes okButtonResId: Int = R.string.ok
) { ) {
Column(verticalArrangement = Arrangement.spacedBy(16.dp)) { Column(verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallSpacing)) {
BackAppBar( BackAppBar(
title = stringResource(id = R.string.contactSelect), title = stringResource(id = R.string.contactSelect),
onBack = onBack, onBack = onBack,
@ -78,32 +78,33 @@ fun SelectContacts(
query = searchQuery, query = searchQuery,
onValueChanged = onSearchQueryChanged, onValueChanged = onSearchQueryChanged,
placeholder = stringResource(R.string.searchContacts), placeholder = stringResource(R.string.searchContacts),
modifier = Modifier.padding(horizontal = 16.dp), modifier = Modifier.padding(horizontal = LocalDimensions.current.smallSpacing),
backgroundColor = LocalColors.current.backgroundSecondary, backgroundColor = LocalColors.current.backgroundSecondary,
) )
LazyColumn(modifier = Modifier.weight(1f)) { val scrollState = rememberLazyListState()
BottomFadingEdgeBox(modifier = Modifier.weight(1f)) { bottomContentPadding ->
LazyColumn(
state = scrollState,
contentPadding = PaddingValues(bottom = bottomContentPadding),
) {
multiSelectMemberList( multiSelectMemberList(
contacts = contacts, contacts = contacts,
onContactItemClicked = onContactItemClicked, onContactItemClicked = onContactItemClicked,
) )
} }
}
Box( Box(
contentAlignment = Alignment.Center, contentAlignment = Alignment.Center,
modifier = Modifier modifier = Modifier.fillMaxWidth()
.fillMaxWidth()
.background(
verticalGradient(
0f to Color.Transparent,
0.2f to LocalColors.current.background,
)
)
) { ) {
PrimaryOutlineButton( PrimaryOutlineButton(
onClick = onDoneClicked, onClick = onDoneClicked,
modifier = Modifier modifier = Modifier
.padding(horizontal = 12.dp, vertical = 4.dp) .padding(vertical = LocalDimensions.current.spacing)
.defaultMinSize(minWidth = 128.dp), .defaultMinSize(minWidth = LocalDimensions.current.minButtonWidth),
) { ) {
Text( Text(
stringResource(id = okButtonResId) stringResource(id = okButtonResId)
@ -118,21 +119,17 @@ fun SelectContacts(
@Composable @Composable
private fun PreviewSelectContacts() { private fun PreviewSelectContacts() {
val random = "05abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234" val random = "05abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234"
val contacts = List(20) {
ContactItem(
accountID = AccountId(random),
name = "User $it",
selected = it % 3 == 0,
)
}
PreviewTheme { PreviewTheme {
SelectContacts( SelectContacts(
contacts = listOf( contacts = contacts,
ContactItem(
accountID = AccountId(random),
name = "User 1",
selected = false,
),
ContactItem(
accountID = AccountId(random),
name = "User 2",
selected = true,
),
),
onContactItemClicked = {}, onContactItemClicked = {},
searchQuery = "", searchQuery = "",
onSearchQueryChanged = {}, onSearchQueryChanged = {},

View File

@ -648,12 +648,12 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
.cancelPendingMessageSendJobs(threadID) .cancelPendingMessageSendJobs(threadID)
// Delete the conversation // Delete the conversation
val v2OpenGroup = lokiThreadDatabase val community = lokiThreadDatabase
.getOpenGroupChat(threadID) .getOpenGroupChat(threadID)
if (v2OpenGroup != null) { if (community != null) {
OpenGroupManager.delete( OpenGroupManager.delete(
v2OpenGroup.server, community.server,
v2OpenGroup.room, community.room,
context context
) )
} else { } else {

View File

@ -28,6 +28,7 @@ import org.thoughtcrime.securesms.ui.components.QRScannerScreen
import org.thoughtcrime.securesms.ui.components.SessionOutlinedTextField import org.thoughtcrime.securesms.ui.components.SessionOutlinedTextField
import org.thoughtcrime.securesms.ui.components.SessionTabRow import org.thoughtcrime.securesms.ui.components.SessionTabRow
import org.thoughtcrime.securesms.ui.contentDescription import org.thoughtcrime.securesms.ui.contentDescription
import org.thoughtcrime.securesms.ui.qaTag
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
@ -101,7 +102,7 @@ private fun RecoveryPassword(state: State, onChange: (String) -> Unit = {}, onCo
SessionOutlinedTextField( SessionOutlinedTextField(
text = state.recoveryPhrase, text = state.recoveryPhrase,
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
.contentDescription(R.string.AccessibilityId_recoveryPasswordEnter), .qaTag(stringResource(R.string.AccessibilityId_recoveryPasswordEnter)),
placeholder = stringResource(R.string.recoveryPasswordEnter), placeholder = stringResource(R.string.recoveryPasswordEnter),
onChange = onChange, onChange = onChange,
onContinue = onContinue, onContinue = onContinue,

View File

@ -21,6 +21,7 @@ import org.thoughtcrime.securesms.ui.theme.LocalDimensions
import org.thoughtcrime.securesms.ui.theme.PreviewTheme import org.thoughtcrime.securesms.ui.theme.PreviewTheme
import org.thoughtcrime.securesms.ui.components.SessionOutlinedTextField import org.thoughtcrime.securesms.ui.components.SessionOutlinedTextField
import org.thoughtcrime.securesms.ui.contentDescription import org.thoughtcrime.securesms.ui.contentDescription
import org.thoughtcrime.securesms.ui.qaTag
import org.thoughtcrime.securesms.ui.theme.LocalType import org.thoughtcrime.securesms.ui.theme.LocalType
@Preview @Preview
@ -67,7 +68,7 @@ internal fun PickDisplayName(
SessionOutlinedTextField( SessionOutlinedTextField(
text = state.displayName, text = state.displayName,
modifier = Modifier.fillMaxWidth().contentDescription(R.string.AccessibilityId_displayNameEnter), modifier = Modifier.fillMaxWidth().qaTag(stringResource(R.string.AccessibilityId_displayNameEnter)),
placeholder = stringResource(R.string.displayNameEnter), placeholder = stringResource(R.string.displayNameEnter),
onChange = onChange, onChange = onChange,
onContinue = onContinue, onContinue = onContinue,

View File

@ -6,25 +6,20 @@ import androidx.appcompat.content.res.AppCompatResources
import androidx.compose.animation.AnimatedVisibility 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.background import androidx.compose.foundation.background
import androidx.compose.foundation.border import androidx.compose.foundation.border
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.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.aspectRatio
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.heightIn import androidx.compose.foundation.layout.heightIn
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.layout.width
import androidx.compose.foundation.layout.wrapContentHeight 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
@ -46,18 +41,15 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.geometry.Size import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.SolidColor import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.StrokeCap import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.TileMode
import androidx.compose.ui.graphics.drawscope.Stroke import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalInspectionMode import androidx.compose.ui.platform.LocalInspectionMode
@ -79,6 +71,7 @@ import org.session.libsession.utilities.Address
import org.session.libsession.utilities.recipients.Recipient import org.session.libsession.utilities.recipients.Recipient
import org.thoughtcrime.securesms.components.ProfilePictureView import org.thoughtcrime.securesms.components.ProfilePictureView
import org.thoughtcrime.securesms.conversation.disappearingmessages.ui.OptionsCardData import org.thoughtcrime.securesms.conversation.disappearingmessages.ui.OptionsCardData
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineButton
import org.thoughtcrime.securesms.ui.components.SmallCircularProgressIndicator import org.thoughtcrime.securesms.ui.components.SmallCircularProgressIndicator
import org.thoughtcrime.securesms.ui.components.TitledRadioButton import org.thoughtcrime.securesms.ui.components.TitledRadioButton
import org.thoughtcrime.securesms.ui.theme.LocalColors import org.thoughtcrime.securesms.ui.theme.LocalColors
@ -86,7 +79,6 @@ 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.transparentButtonColors import org.thoughtcrime.securesms.ui.theme.transparentButtonColors
import kotlin.math.min
import kotlin.math.roundToInt import kotlin.math.roundToInt
interface Callbacks<in T> { interface Callbacks<in T> {
@ -370,43 +362,58 @@ fun Modifier.contentDescription(text: String?): Modifier {
return text?.let { semantics { contentDescription = it } } ?: this return text?.let { semantics { contentDescription = it } } ?: this
} }
fun Modifier.fadingEdges( @Composable
scrollState: ScrollState, fun BottomFadingEdgeBox(
topEdgeHeight: Dp = 0.dp, modifier: Modifier = Modifier,
bottomEdgeHeight: Dp = 20.dp fadingEdgeHeight: Dp = LocalDimensions.current.spacing,
): Modifier = this.then( fadingColor: Color = LocalColors.current.background,
Modifier content: @Composable BoxScope.(bottomContentPadding: Dp) -> Unit,
// adding layer fixes issue with blending gradient and content ) {
.graphicsLayer { alpha = 0.99F } Box(modifier) {
.drawWithContent { this.content(fadingEdgeHeight)
drawContent()
val topColors = listOf(Color.Transparent, Color.Black) Box(
val topStartY = scrollState.value.toFloat() modifier = Modifier
val topGradientHeight = min(topEdgeHeight.toPx(), topStartY) .fillMaxWidth()
if (topGradientHeight > 0f) drawRect( .align(Alignment.BottomCenter)
brush = Brush.verticalGradient( .height(fadingEdgeHeight)
colors = topColors, .background(
startY = topStartY, Brush.verticalGradient(
endY = topStartY + topGradientHeight 0f to Color.Transparent,
), 1f to fadingColor,
blendMode = BlendMode.DstIn tileMode = TileMode.Repeated
)
) )
val bottomColors = listOf(Color.Black, Color.Transparent)
val bottomEndY = size.height - scrollState.maxValue + scrollState.value
val bottomGradientHeight =
min(bottomEdgeHeight.toPx(), scrollState.maxValue.toFloat() - scrollState.value)
if (bottomGradientHeight > 0f) drawRect(
brush = Brush.verticalGradient(
colors = bottomColors,
startY = bottomEndY - bottomGradientHeight,
endY = bottomEndY
),
blendMode = BlendMode.DstIn
) )
} }
) }
@Preview
@Composable
private fun BottomFadingEdgeBoxPreview() {
Column(modifier = Modifier.background(LocalColors.current.background)) {
BottomFadingEdgeBox(
modifier = Modifier
.height(600.dp)
.background(LocalColors.current.backgroundSecondary),
content = { bottomContentPadding ->
LazyColumn(contentPadding = PaddingValues(bottom = bottomContentPadding)) {
items(200) {
Text("Item $it",
color = LocalColors.current.text,
style = LocalType.current.base)
}
}
},
)
PrimaryOutlineButton(
modifier = Modifier
.align(Alignment.CenterHorizontally),
text = "Do stuff", onClick = {}
)
}
}
@Composable @Composable
fun Divider(modifier: Modifier = Modifier, startIndent: Dp = 0.dp) { fun Divider(modifier: Modifier = Modifier, startIndent: Dp = 0.dp) {
@ -565,8 +572,11 @@ fun SearchBar(
LocalColors.current.textSecondary LocalColors.current.textSecondary
), ),
modifier = Modifier modifier = Modifier
.padding(horizontal = 16.dp, vertical = 8.dp) .padding(
.size(24.dp) horizontal = LocalDimensions.current.smallSpacing,
vertical = LocalDimensions.current.xxsSpacing
)
.size(LocalDimensions.current.iconMedium)
) )
Box(modifier = Modifier.weight(1f)) { Box(modifier = Modifier.weight(1f)) {

View File

@ -18,6 +18,7 @@ data class Dimensions(
val appBarHeight: Dp = 64.dp, val appBarHeight: Dp = 64.dp,
val minItemButtonHeight: Dp = 50.dp, val minItemButtonHeight: Dp = 50.dp,
val minLargeItemButtonHeight: Dp = 60.dp, val minLargeItemButtonHeight: Dp = 60.dp,
val minButtonWidth: Dp = 160.dp,
val indicatorHeight: Dp = 4.dp, val indicatorHeight: Dp = 4.dp,
val borderStroke: Dp = 1.dp, val borderStroke: Dp = 1.dp,

View File

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:viewportHeight="50" android:viewportWidth="50" android:width="24dp">
<path android:fillColor="#000000" android:fillType="evenOdd" android:pathData="M4.167,10.415C5.317,10.415 6.25,11.348 6.25,12.499V41.666C6.25,42.218 6.47,42.748 6.86,43.139C7.251,43.529 7.781,43.749 8.333,43.749H37.5C38.651,43.749 39.583,44.682 39.583,45.832C39.583,46.983 38.651,47.916 37.5,47.916H8.333C6.676,47.916 5.086,47.257 3.914,46.085C2.742,44.913 2.083,43.323 2.083,41.666V12.499C2.083,11.348 3.016,10.415 4.167,10.415Z"/>
<path android:fillColor="#000000" android:fillType="evenOdd" android:pathData="M34.56,22.909C35.893,21.577 37.699,20.829 39.583,20.829C41.467,20.829 43.274,21.577 44.606,22.909L44.606,22.909L47.306,25.609C48.12,26.423 48.12,27.742 47.306,28.555C46.493,29.369 45.174,29.369 44.36,28.555L41.66,25.855C41.109,25.305 40.362,24.995 39.583,24.995C38.804,24.995 38.057,25.305 37.506,25.855L24.39,38.972C23.576,39.786 22.257,39.786 21.443,38.972C20.63,38.159 20.63,36.839 21.443,36.026L34.56,22.909L34.56,22.909Z"/>
<path android:fillColor="#000000" android:fillType="evenOdd" android:pathData="M25,14.582C23.849,14.582 22.917,15.515 22.917,16.666C22.917,17.816 23.849,18.749 25,18.749C26.151,18.749 27.083,17.816 27.083,16.666C27.083,15.515 26.151,14.582 25,14.582ZM18.75,16.666C18.75,13.214 21.548,10.415 25,10.415C28.452,10.415 31.25,13.214 31.25,16.666C31.25,20.117 28.452,22.916 25,22.916C21.548,22.916 18.75,20.117 18.75,16.666Z"/>
<path android:fillColor="#000000" android:fillType="evenOdd" android:pathData="M16.667,6.249C15.516,6.249 14.583,7.182 14.583,8.333V33.333C14.583,34.483 15.516,35.416 16.667,35.416H41.667C42.817,35.416 43.75,34.483 43.75,33.333V8.333C43.75,7.182 42.817,6.249 41.667,6.249H16.667ZM10.417,8.333C10.417,4.881 13.215,2.083 16.667,2.083H41.667C45.118,2.083 47.917,4.881 47.917,8.333V33.333C47.917,36.784 45.118,39.583 41.667,39.583H16.667C13.215,39.583 10.417,36.784 10.417,33.333V8.333Z"/>
</vector>

View File

@ -1,12 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="18dp"
android:height="18dp"
android:viewportWidth="18"
android:viewportHeight="18">
<path
android:pathData="M14.806,3.228C14.069,2.493 13.047,2.35 11.743,2.35H6.239C4.953,2.35 3.93,2.493 3.193,3.228C2.458,3.964 2.323,4.978 2.323,6.26V11.723C2.323,13.03 2.458,14.037 3.193,14.771C3.931,15.508 4.953,15.65 6.25,15.65H11.743C13.047,15.65 14.071,15.508 14.806,14.771C15.542,14.036 15.676,13.03 15.676,11.723V6.277C15.676,4.972 15.542,3.957 14.806,3.228ZM14.273,6.077V11.917C14.273,12.667 14.179,13.346 13.777,13.75C13.381,14.144 12.687,14.247 11.945,14.247H6.056C5.313,14.247 4.618,14.144 4.216,13.75C3.822,13.346 3.726,12.667 3.726,11.917V6.094C3.726,5.339 3.822,4.648 4.216,4.252C4.618,3.85 5.319,3.753 6.073,3.753H11.945C12.687,3.753 13.381,3.856 13.777,4.252C14.179,4.654 14.273,5.333 14.273,6.077Z"
android:fillColor="#000000"/>
<path
android:pathData="M11.238,10.857C11.594,10.857 11.823,10.587 11.823,10.208V6.875C11.823,6.386 11.549,6.166 11.105,6.166H7.753C7.365,6.166 7.118,6.395 7.118,6.751C7.118,7.108 7.37,7.337 7.761,7.337H8.97L9.953,7.223L8.888,8.195L6.38,10.71C6.259,10.83 6.178,11 6.178,11.167C6.178,11.545 6.438,11.791 6.8,11.791C6.994,11.791 7.153,11.72 7.282,11.593L9.784,9.092L10.751,8.04L10.646,9.074V10.217C10.646,10.604 10.875,10.857 11.238,10.857Z"
android:fillColor="#000000"/>
</vector>

View File

@ -1,18 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="57dp"
android:height="44dp"
android:viewportWidth="57"
android:viewportHeight="44">
<path
android:pathData="M10.066,2.663L51.25,6.085A4,4 62.853,0 1,54.905 10.402L52.546,38.797A4,4 72.977,0 1,48.229 42.452L7.044,39.031A4,4 77.145,0 1,3.389 34.713L5.748,6.318A4,4 50.655,0 1,10.066 2.663z"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#000000"/>
<path
android:pathData="M5.182,1.414L45.74,1.414A4,4 0,0 1,49.74 5.414L49.74,33.907A4,4 0,0 1,45.74 37.907L5.182,37.907A4,4 0,0 1,1.182 33.907L1.182,5.414A4,4 0,0 1,5.182 1.414z"
android:strokeWidth="2"
android:strokeColor="#000000"/>
<path
android:pathData="M14.528,20.623L1.708,32.896C1.034,33.542 0.896,34.569 1.376,35.37L1.855,36.168C1.957,36.338 2.083,36.494 2.237,36.619C2.866,37.13 4.009,37.879 4.918,37.879H46.554C46.917,37.879 47.263,37.781 47.574,37.594L48.552,37.007C49.154,36.646 49.523,35.995 49.523,35.292V24.57C49.523,23.99 49.272,23.439 48.834,23.059L38.721,14.277C37.899,13.563 36.656,13.638 35.926,14.446L26.337,25.058C25.646,25.822 24.489,25.937 23.662,25.324L17.102,20.461C16.319,19.88 15.231,19.949 14.528,20.623Z"
android:fillColor="#000000"/>
</vector>

View File

@ -276,6 +276,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
app:drawableTint="@color/black"
app:layout_constraintTop_toBottomOf="@+id/outdatedDisappearingBanner" app:layout_constraintTop_toBottomOf="@+id/outdatedDisappearingBanner"
android:background="@color/outdated_client_banner_background_color" android:background="@color/outdated_client_banner_background_color"
android:paddingVertical="@dimen/very_small_spacing" android:paddingVertical="@dimen/very_small_spacing"
@ -287,7 +288,7 @@
tools:text="@string/groupLegacyBanner" tools:text="@string/groupLegacyBanner"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible" tools:visibility="visible"
app:drawableEndCompat="@drawable/ic_link_out" /> app:drawableEndCompat="@drawable/ic_external" />
<TextView <TextView
android:padding="@dimen/medium_spacing" android:padding="@dimen/medium_spacing"

View File

@ -14,7 +14,7 @@
android:id="@+id/pendingDownloadIcon" android:id="@+id/pendingDownloadIcon"
android:layout_width="16dp" android:layout_width="16dp"
android:layout_height="16dp" android:layout_height="16dp"
android:src="@drawable/ic_media" android:src="@drawable/ic_images"
app:tint="?android:textColorPrimary" /> app:tint="?android:textColorPrimary" />
<TextView <TextView