mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 01:07:47 +00:00
Utilise new SessionColors
This commit is contained in:
parent
f1000ac6e6
commit
939999de76
@ -18,7 +18,7 @@ import org.thoughtcrime.securesms.conversation.disappearingmessages.ui.Disappear
|
|||||||
import org.thoughtcrime.securesms.conversation.disappearingmessages.ui.UiState
|
import org.thoughtcrime.securesms.conversation.disappearingmessages.ui.UiState
|
||||||
import org.thoughtcrime.securesms.database.RecipientDatabase
|
import org.thoughtcrime.securesms.database.RecipientDatabase
|
||||||
import org.thoughtcrime.securesms.database.ThreadDatabase
|
import org.thoughtcrime.securesms.database.ThreadDatabase
|
||||||
import org.thoughtcrime.securesms.ui.AppTheme
|
import org.thoughtcrime.securesms.ui.SessionMaterialTheme
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
@ -87,7 +87,7 @@ class DisappearingMessagesActivity: PassphraseRequiredActionBarActivity() {
|
|||||||
@Composable
|
@Composable
|
||||||
fun DisappearingMessagesScreen() {
|
fun DisappearingMessagesScreen() {
|
||||||
val uiState by viewModel.uiState.collectAsState(UiState())
|
val uiState by viewModel.uiState.collectAsState(UiState())
|
||||||
AppTheme {
|
SessionMaterialTheme {
|
||||||
DisappearingMessages(uiState, callbacks = viewModel)
|
DisappearingMessages(uiState, callbacks = viewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,19 +7,19 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||||
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
|
||||||
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.conversation.disappearingmessages.ExpiryType
|
import org.thoughtcrime.securesms.conversation.disappearingmessages.ExpiryType
|
||||||
import org.thoughtcrime.securesms.conversation.disappearingmessages.State
|
import org.thoughtcrime.securesms.conversation.disappearingmessages.State
|
||||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||||
import org.thoughtcrime.securesms.ui.ThemeResPreviewParameterProvider
|
import org.thoughtcrime.securesms.ui.SessionColors
|
||||||
|
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||||
|
|
||||||
@Preview(widthDp = 450, heightDp = 700)
|
@Preview(widthDp = 450, heightDp = 700)
|
||||||
@Composable
|
@Composable
|
||||||
fun PreviewStates(
|
fun PreviewStates(
|
||||||
@PreviewParameter(StatePreviewParameterProvider::class) state: State
|
@PreviewParameter(StatePreviewParameterProvider::class) state: State
|
||||||
) {
|
) {
|
||||||
PreviewTheme(R.style.Classic_Dark) {
|
PreviewTheme {
|
||||||
DisappearingMessages(
|
DisappearingMessages(
|
||||||
state.toUiState()
|
state.toUiState()
|
||||||
)
|
)
|
||||||
@ -51,9 +51,9 @@ class StatePreviewParameterProvider : PreviewParameterProvider<State> {
|
|||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
fun PreviewThemes(
|
fun PreviewThemes(
|
||||||
@PreviewParameter(ThemeResPreviewParameterProvider::class) themeResId: Int
|
@PreviewParameter(SessionColorsParameterProvider::class) sessionColors: SessionColors
|
||||||
) {
|
) {
|
||||||
PreviewTheme(themeResId) {
|
PreviewTheme(sessionColors) {
|
||||||
DisappearingMessages(
|
DisappearingMessages(
|
||||||
State(expiryMode = ExpiryMode.AfterSend(43200)).toUiState(),
|
State(expiryMode = ExpiryMode.AfterSend(43200)).toUiState(),
|
||||||
modifier = Modifier.size(400.dp, 600.dp)
|
modifier = Modifier.size(400.dp, 600.dp)
|
||||||
|
@ -44,11 +44,12 @@ import org.thoughtcrime.securesms.conversation.start.NewConversationDelegate
|
|||||||
import org.thoughtcrime.securesms.conversation.v2.ConversationActivityV2
|
import org.thoughtcrime.securesms.conversation.v2.ConversationActivityV2
|
||||||
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
||||||
import org.thoughtcrime.securesms.showOpenUrlDialog
|
import org.thoughtcrime.securesms.showOpenUrlDialog
|
||||||
import org.thoughtcrime.securesms.ui.AppTheme
|
|
||||||
import org.thoughtcrime.securesms.ui.LoadingArcOr
|
import org.thoughtcrime.securesms.ui.LoadingArcOr
|
||||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||||
import org.thoughtcrime.securesms.ui.ThemeResPreviewParameterProvider
|
import org.thoughtcrime.securesms.ui.SessionColors
|
||||||
|
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||||
|
import org.thoughtcrime.securesms.ui.SessionMaterialTheme
|
||||||
import org.thoughtcrime.securesms.ui.classicDarkColors
|
import org.thoughtcrime.securesms.ui.classicDarkColors
|
||||||
import org.thoughtcrime.securesms.ui.components.AppBar
|
import org.thoughtcrime.securesms.ui.components.AppBar
|
||||||
import org.thoughtcrime.securesms.ui.components.BorderlessButtonWithIcon
|
import org.thoughtcrime.securesms.ui.components.BorderlessButtonWithIcon
|
||||||
@ -80,7 +81,7 @@ class NewMessageFragment : Fragment() {
|
|||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View = ComposeView(requireContext()).apply {
|
): View = ComposeView(requireContext()).apply {
|
||||||
setContent {
|
setContent {
|
||||||
AppTheme {
|
SessionMaterialTheme {
|
||||||
val uiState by viewModel.state.collectAsState(State())
|
val uiState by viewModel.state.collectAsState(State())
|
||||||
NewMessage(
|
NewMessage(
|
||||||
uiState,
|
uiState,
|
||||||
@ -108,9 +109,9 @@ class NewMessageFragment : Fragment() {
|
|||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
private fun PreviewNewMessage(
|
private fun PreviewNewMessage(
|
||||||
@PreviewParameter(ThemeResPreviewParameterProvider::class) themeResId: Int
|
@PreviewParameter(SessionColorsParameterProvider::class) sessionColors: SessionColors
|
||||||
) {
|
) {
|
||||||
PreviewTheme(themeResId) {
|
PreviewTheme(sessionColors) {
|
||||||
NewMessage(State())
|
NewMessage(State())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -148,13 +149,16 @@ fun EnterAccountId(
|
|||||||
onHelp: () -> Unit = {}
|
onHelp: () -> Unit = {}
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.padding(horizontal = 12.dp, vertical = 16.dp).fillMaxHeight(),
|
modifier = Modifier
|
||||||
|
.padding(horizontal = 12.dp, vertical = 16.dp)
|
||||||
|
.fillMaxHeight(),
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||||
) {
|
) {
|
||||||
SessionOutlinedTextField(
|
SessionOutlinedTextField(
|
||||||
text = state.newMessageIdOrOns,
|
text = state.newMessageIdOrOns,
|
||||||
modifier = Modifier.padding(horizontal = LocalDimensions.current.marginSmall)
|
modifier = Modifier
|
||||||
|
.padding(horizontal = LocalDimensions.current.marginSmall)
|
||||||
.contentDescription("Session id input box"),
|
.contentDescription("Session id input box"),
|
||||||
placeholder = stringResource(R.string.accountIdOrOnsEnter),
|
placeholder = stringResource(R.string.accountIdOrOnsEnter),
|
||||||
onChange = callbacks::onChange,
|
onChange = callbacks::onChange,
|
||||||
@ -183,7 +187,7 @@ fun EnterAccountId(
|
|||||||
onClick = { callbacks.onContinue() }
|
onClick = { callbacks.onContinue() }
|
||||||
) {
|
) {
|
||||||
LoadingArcOr(state.loading) {
|
LoadingArcOr(state.loading) {
|
||||||
SessionButtonText(stringResource(R.string.next))
|
SessionButtonText(stringResource(R.string.next), enabled = state.isNextButtonEnabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import androidx.compose.material.primarySurface
|
|||||||
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.platform.ComposeView
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
@ -32,15 +31,14 @@ import network.loki.messenger.R
|
|||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import org.thoughtcrime.securesms.preferences.copyPublicKey
|
import org.thoughtcrime.securesms.preferences.copyPublicKey
|
||||||
import org.thoughtcrime.securesms.preferences.sendInvitationToUseSession
|
import org.thoughtcrime.securesms.preferences.sendInvitationToUseSession
|
||||||
import org.thoughtcrime.securesms.ui.AppTheme
|
|
||||||
import org.thoughtcrime.securesms.ui.base
|
import org.thoughtcrime.securesms.ui.base
|
||||||
import org.thoughtcrime.securesms.ui.classicDarkColors
|
import org.thoughtcrime.securesms.ui.classicDarkColors
|
||||||
import org.thoughtcrime.securesms.ui.components.AppBar
|
import org.thoughtcrime.securesms.ui.components.AppBar
|
||||||
import org.thoughtcrime.securesms.ui.components.OnPrimaryButtons
|
|
||||||
import org.thoughtcrime.securesms.ui.components.OutlineButton
|
import org.thoughtcrime.securesms.ui.components.OutlineButton
|
||||||
import org.thoughtcrime.securesms.ui.components.OutlineCopyButton
|
import org.thoughtcrime.securesms.ui.components.OutlineCopyButton
|
||||||
import org.thoughtcrime.securesms.ui.components.SmallButtons
|
import org.thoughtcrime.securesms.ui.components.SmallButtons
|
||||||
import org.thoughtcrime.securesms.ui.contentDescription
|
import org.thoughtcrime.securesms.ui.contentDescription
|
||||||
|
import org.thoughtcrime.securesms.ui.onCreateView
|
||||||
import org.thoughtcrime.securesms.ui.small
|
import org.thoughtcrime.securesms.ui.small
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
@ -50,18 +48,14 @@ class InviteFriendFragment : Fragment() {
|
|||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View = ComposeView(requireContext()).apply {
|
): View = onCreateView {
|
||||||
setContent {
|
InviteFriend(
|
||||||
AppTheme {
|
TextSecurePreferences.getLocalNumber(LocalContext.current)!!,
|
||||||
InviteFriend(
|
onBack = { delegate.onDialogBackPressed() },
|
||||||
TextSecurePreferences.getLocalNumber(LocalContext.current)!!,
|
onClose = { delegate.onDialogClosePressed() },
|
||||||
onBack = { delegate.onDialogBackPressed() },
|
copyPublicKey = requireContext()::copyPublicKey,
|
||||||
onClose = { delegate.onDialogClosePressed() },
|
sendInvitation = requireContext()::sendInvitationToUseSession,
|
||||||
copyPublicKey = requireContext()::copyPublicKey,
|
)
|
||||||
sendInvitation = requireContext()::sendInvitationToUseSession,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,22 +107,20 @@ private fun InviteFriend(
|
|||||||
color = classicDarkColors[5],
|
color = classicDarkColors[5],
|
||||||
modifier = Modifier.padding(horizontal = 8.dp)
|
modifier = Modifier.padding(horizontal = 8.dp)
|
||||||
)
|
)
|
||||||
OnPrimaryButtons {
|
SmallButtons {
|
||||||
SmallButtons {
|
Row(horizontalArrangement = spacedBy(20.dp)) {
|
||||||
Row(horizontalArrangement = spacedBy(20.dp)) {
|
OutlineButton(
|
||||||
OutlineButton(
|
modifier = Modifier
|
||||||
modifier = Modifier
|
.weight(1f)
|
||||||
.weight(1f)
|
.contentDescription("Share button"),
|
||||||
.contentDescription("Share button"),
|
text = stringResource(R.string.share),
|
||||||
text = stringResource(R.string.share),
|
onClick = sendInvitation
|
||||||
onClick = sendInvitation
|
)
|
||||||
)
|
|
||||||
|
|
||||||
OutlineCopyButton(
|
OutlineCopyButton(
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
onClick = copyPublicKey
|
onClick = copyPublicKey
|
||||||
)
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,19 +15,18 @@ import androidx.compose.material.Text
|
|||||||
import androidx.compose.material.primarySurface
|
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.platform.ComposeView
|
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import org.thoughtcrime.securesms.ui.AppTheme
|
|
||||||
import org.thoughtcrime.securesms.ui.ItemButton
|
import org.thoughtcrime.securesms.ui.ItemButton
|
||||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||||
import org.thoughtcrime.securesms.ui.classicDarkColors
|
import org.thoughtcrime.securesms.ui.classicDarkColors
|
||||||
import org.thoughtcrime.securesms.ui.components.AppBar
|
import org.thoughtcrime.securesms.ui.components.AppBar
|
||||||
import org.thoughtcrime.securesms.ui.components.QrImage
|
import org.thoughtcrime.securesms.ui.components.QrImage
|
||||||
import org.thoughtcrime.securesms.ui.contentDescription
|
import org.thoughtcrime.securesms.ui.contentDescription
|
||||||
|
import org.thoughtcrime.securesms.ui.onCreateView
|
||||||
import org.thoughtcrime.securesms.ui.small
|
import org.thoughtcrime.securesms.ui.small
|
||||||
import org.thoughtcrime.securesms.ui.xl
|
import org.thoughtcrime.securesms.ui.xl
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -44,13 +43,7 @@ class NewConversationHomeFragment : Fragment() {
|
|||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View = ComposeView(requireContext()).apply {
|
): View = onCreateView { NewConversationScreen() }
|
||||||
setContent {
|
|
||||||
AppTheme {
|
|
||||||
NewConversationScreen()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun NewConversationScreen() {
|
fun NewConversationScreen() {
|
||||||
|
@ -28,7 +28,6 @@ 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.material.Icon
|
||||||
import androidx.compose.material.LocalTextStyle
|
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material.MaterialTheme
|
||||||
import androidx.compose.material.Surface
|
import androidx.compose.material.Surface
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
@ -43,8 +42,6 @@ import androidx.compose.ui.platform.ComposeView
|
|||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
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.FontWeight
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
@ -59,7 +56,6 @@ import network.loki.messenger.databinding.ViewVisibleMessageContentBinding
|
|||||||
import org.thoughtcrime.securesms.MediaPreviewActivity.getPreviewIntent
|
import org.thoughtcrime.securesms.MediaPreviewActivity.getPreviewIntent
|
||||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||||
import org.thoughtcrime.securesms.database.Storage
|
import org.thoughtcrime.securesms.database.Storage
|
||||||
import org.thoughtcrime.securesms.ui.AppTheme
|
|
||||||
import org.thoughtcrime.securesms.ui.Avatar
|
import org.thoughtcrime.securesms.ui.Avatar
|
||||||
import org.thoughtcrime.securesms.ui.CarouselNextButton
|
import org.thoughtcrime.securesms.ui.CarouselNextButton
|
||||||
import org.thoughtcrime.securesms.ui.CarouselPrevButton
|
import org.thoughtcrime.securesms.ui.CarouselPrevButton
|
||||||
@ -70,14 +66,15 @@ import org.thoughtcrime.securesms.ui.Divider
|
|||||||
import org.thoughtcrime.securesms.ui.GetString
|
import org.thoughtcrime.securesms.ui.GetString
|
||||||
import org.thoughtcrime.securesms.ui.HorizontalPagerIndicator
|
import org.thoughtcrime.securesms.ui.HorizontalPagerIndicator
|
||||||
import org.thoughtcrime.securesms.ui.ItemButton
|
import org.thoughtcrime.securesms.ui.ItemButton
|
||||||
|
import org.thoughtcrime.securesms.ui.LocalColors
|
||||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||||
import org.thoughtcrime.securesms.ui.ThemeResPreviewParameterProvider
|
import org.thoughtcrime.securesms.ui.SessionColors
|
||||||
|
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||||
|
import org.thoughtcrime.securesms.ui.SessionMaterialTheme
|
||||||
import org.thoughtcrime.securesms.ui.TitledText
|
import org.thoughtcrime.securesms.ui.TitledText
|
||||||
import org.thoughtcrime.securesms.ui.base
|
import org.thoughtcrime.securesms.ui.base
|
||||||
import org.thoughtcrime.securesms.ui.baseBold
|
|
||||||
import org.thoughtcrime.securesms.ui.baseMonospace
|
import org.thoughtcrime.securesms.ui.baseMonospace
|
||||||
import org.thoughtcrime.securesms.ui.blackAlpha40
|
import org.thoughtcrime.securesms.ui.blackAlpha40
|
||||||
import org.thoughtcrime.securesms.ui.colorDestructive
|
|
||||||
import org.thoughtcrime.securesms.ui.components.SessionButtonText
|
import org.thoughtcrime.securesms.ui.components.SessionButtonText
|
||||||
import org.thoughtcrime.securesms.ui.destructiveButtonColors
|
import org.thoughtcrime.securesms.ui.destructiveButtonColors
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -125,7 +122,7 @@ class MessageDetailActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
@Composable
|
@Composable
|
||||||
private fun MessageDetailsScreen() {
|
private fun MessageDetailsScreen() {
|
||||||
val state by viewModel.stateFlow.collectAsState()
|
val state by viewModel.stateFlow.collectAsState()
|
||||||
AppTheme {
|
SessionMaterialTheme {
|
||||||
MessageDetails(
|
MessageDetails(
|
||||||
state = state,
|
state = state,
|
||||||
onReply = if (state.canReply) { { setResultAndFinish(ON_REPLY) } } else null,
|
onReply = if (state.canReply) { { setResultAndFinish(ON_REPLY) } } else null,
|
||||||
@ -320,9 +317,9 @@ fun ExpandButton(modifier: Modifier = Modifier, onClick: () -> Unit) {
|
|||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
fun PreviewMessageDetails(
|
fun PreviewMessageDetails(
|
||||||
@PreviewParameter(ThemeResPreviewParameterProvider::class) themeResId: Int
|
@PreviewParameter(SessionColorsParameterProvider::class) sessionColors: SessionColors
|
||||||
) {
|
) {
|
||||||
PreviewTheme(themeResId) {
|
PreviewTheme(sessionColors) {
|
||||||
MessageDetails(
|
MessageDetails(
|
||||||
state = MessageDetailsState(
|
state = MessageDetailsState(
|
||||||
nonImageAttachmentFileDetails = listOf(
|
nonImageAttachmentFileDetails = listOf(
|
||||||
@ -369,7 +366,7 @@ fun FileDetails(fileDetails: List<TitledText>) {
|
|||||||
fun TitledErrorText(titledText: TitledText?) {
|
fun TitledErrorText(titledText: TitledText?) {
|
||||||
TitledText(
|
TitledText(
|
||||||
titledText,
|
titledText,
|
||||||
style = MaterialTheme.typography.base.copy(color = colorDestructive)
|
style = MaterialTheme.typography.base.copy(color = LocalColors.current.danger)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.view.isGone
|
|
||||||
import androidx.core.view.isInvisible
|
import androidx.core.view.isInvisible
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
@ -43,11 +42,9 @@ import androidx.lifecycle.repeatOnLifecycle
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.collect
|
|
||||||
import kotlinx.coroutines.flow.collectLatest
|
import kotlinx.coroutines.flow.collectLatest
|
||||||
import kotlinx.coroutines.flow.filter
|
import kotlinx.coroutines.flow.filter
|
||||||
import kotlinx.coroutines.flow.filterNotNull
|
import kotlinx.coroutines.flow.filterNotNull
|
||||||
import kotlinx.coroutines.flow.onEach
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
@ -97,11 +94,12 @@ import org.thoughtcrime.securesms.permissions.Permissions
|
|||||||
import org.thoughtcrime.securesms.preferences.SettingsActivity
|
import org.thoughtcrime.securesms.preferences.SettingsActivity
|
||||||
import org.thoughtcrime.securesms.showMuteDialog
|
import org.thoughtcrime.securesms.showMuteDialog
|
||||||
import org.thoughtcrime.securesms.showSessionDialog
|
import org.thoughtcrime.securesms.showSessionDialog
|
||||||
import org.thoughtcrime.securesms.ui.AppTheme
|
|
||||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||||
|
import org.thoughtcrime.securesms.ui.SessionColors
|
||||||
|
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||||
|
import org.thoughtcrime.securesms.ui.SessionMaterialTheme
|
||||||
import org.thoughtcrime.securesms.ui.SessionShieldIcon
|
import org.thoughtcrime.securesms.ui.SessionShieldIcon
|
||||||
import org.thoughtcrime.securesms.ui.ThemeResPreviewParameterProvider
|
|
||||||
import org.thoughtcrime.securesms.ui.base
|
import org.thoughtcrime.securesms.ui.base
|
||||||
import org.thoughtcrime.securesms.ui.components.OutlineButton
|
import org.thoughtcrime.securesms.ui.components.OutlineButton
|
||||||
import org.thoughtcrime.securesms.ui.contentDescription
|
import org.thoughtcrime.securesms.ui.contentDescription
|
||||||
@ -363,16 +361,16 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
|||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
fun PreviewMessageDetails(
|
fun PreviewMessageDetails(
|
||||||
@PreviewParameter(ThemeResPreviewParameterProvider::class) themeResId: Int
|
@PreviewParameter(SessionColorsParameterProvider::class) sessionColors: SessionColors
|
||||||
) {
|
) {
|
||||||
PreviewTheme(themeResId) {
|
PreviewTheme(sessionColors) {
|
||||||
SeedReminder()
|
SeedReminder()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun SeedReminder() {
|
private fun SeedReminder() {
|
||||||
AppTheme {
|
SessionMaterialTheme {
|
||||||
Column {
|
Column {
|
||||||
// Color Strip
|
// Color Strip
|
||||||
Box(
|
Box(
|
||||||
@ -384,7 +382,10 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
|||||||
Row(
|
Row(
|
||||||
Modifier
|
Modifier
|
||||||
.background(MaterialTheme.colors.surface)
|
.background(MaterialTheme.colors.surface)
|
||||||
.padding(horizontal = LocalDimensions.current.marginSmall, vertical = LocalDimensions.current.marginExtraSmall)
|
.padding(
|
||||||
|
horizontal = LocalDimensions.current.marginSmall,
|
||||||
|
vertical = LocalDimensions.current.marginExtraSmall
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
Column(Modifier.weight(1f)) {
|
Column(Modifier.weight(1f)) {
|
||||||
Row {
|
Row {
|
||||||
@ -415,7 +416,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun EmptyView(newAccount: Boolean) {
|
private fun EmptyView(newAccount: Boolean) {
|
||||||
AppTheme {
|
SessionMaterialTheme {
|
||||||
Column(
|
Column(
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
@ -47,17 +47,17 @@ import org.thoughtcrime.securesms.crypto.IdentityKeyUtil
|
|||||||
import org.thoughtcrime.securesms.onboarding.pickname.startPickDisplayNameActivity
|
import org.thoughtcrime.securesms.onboarding.pickname.startPickDisplayNameActivity
|
||||||
import org.thoughtcrime.securesms.service.KeyCachingService
|
import org.thoughtcrime.securesms.service.KeyCachingService
|
||||||
import org.thoughtcrime.securesms.showOpenUrlDialog
|
import org.thoughtcrime.securesms.showOpenUrlDialog
|
||||||
import org.thoughtcrime.securesms.ui.AppTheme
|
|
||||||
import org.thoughtcrime.securesms.ui.LocalColors
|
import org.thoughtcrime.securesms.ui.LocalColors
|
||||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||||
import org.thoughtcrime.securesms.ui.ThemeResPreviewParameterProvider
|
import org.thoughtcrime.securesms.ui.SessionColors
|
||||||
import org.thoughtcrime.securesms.ui.classicDarkColors
|
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||||
import org.thoughtcrime.securesms.ui.components.BorderlessHtmlButton
|
import org.thoughtcrime.securesms.ui.components.BorderlessHtmlButton
|
||||||
import org.thoughtcrime.securesms.ui.components.FilledButton
|
import org.thoughtcrime.securesms.ui.components.FilledButton
|
||||||
import org.thoughtcrime.securesms.ui.components.OutlineButton
|
import org.thoughtcrime.securesms.ui.components.OutlineButton
|
||||||
import org.thoughtcrime.securesms.ui.contentDescription
|
import org.thoughtcrime.securesms.ui.contentDescription
|
||||||
import org.thoughtcrime.securesms.ui.large
|
import org.thoughtcrime.securesms.ui.large
|
||||||
|
import org.thoughtcrime.securesms.ui.setComposeContent
|
||||||
import org.thoughtcrime.securesms.util.setUpActionBarSessionLogo
|
import org.thoughtcrime.securesms.util.setUpActionBarSessionLogo
|
||||||
import org.thoughtcrime.securesms.util.start
|
import org.thoughtcrime.securesms.util.start
|
||||||
import kotlin.time.Duration.Companion.milliseconds
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
@ -85,9 +85,7 @@ class LandingActivity : BaseActionBarActivity() {
|
|||||||
|
|
||||||
setUpActionBarSessionLogo(true)
|
setUpActionBarSessionLogo(true)
|
||||||
|
|
||||||
ComposeView(this)
|
setComposeContent { LandingScreen() }
|
||||||
.apply { setContent { AppTheme { LandingScreen() } } }
|
|
||||||
.let(::setContentView)
|
|
||||||
|
|
||||||
IdentityKeyUtil.generateIdentityKeyPair(this)
|
IdentityKeyUtil.generateIdentityKeyPair(this)
|
||||||
TextSecurePreferences.setPasswordDisabled(this, true)
|
TextSecurePreferences.setPasswordDisabled(this, true)
|
||||||
@ -98,9 +96,9 @@ class LandingActivity : BaseActionBarActivity() {
|
|||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
private fun LandingScreen(
|
private fun LandingScreen(
|
||||||
@PreviewParameter(ThemeResPreviewParameterProvider::class) themeResId: Int
|
@PreviewParameter(SessionColorsParameterProvider::class) sessionColors: SessionColors
|
||||||
) {
|
) {
|
||||||
PreviewTheme(themeResId) {
|
PreviewTheme(sessionColors) {
|
||||||
LandingScreen()
|
LandingScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,9 +33,9 @@ import network.loki.messenger.R
|
|||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import org.thoughtcrime.securesms.BaseActionBarActivity
|
import org.thoughtcrime.securesms.BaseActionBarActivity
|
||||||
import org.thoughtcrime.securesms.onboarding.messagenotifications.startMessageNotificationsActivity
|
import org.thoughtcrime.securesms.onboarding.messagenotifications.startMessageNotificationsActivity
|
||||||
import org.thoughtcrime.securesms.ui.AppTheme
|
|
||||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||||
|
import org.thoughtcrime.securesms.ui.SessionMaterialTheme
|
||||||
import org.thoughtcrime.securesms.ui.base
|
import org.thoughtcrime.securesms.ui.base
|
||||||
import org.thoughtcrime.securesms.ui.baseBold
|
import org.thoughtcrime.securesms.ui.baseBold
|
||||||
import org.thoughtcrime.securesms.ui.components.MaybeScanQrCode
|
import org.thoughtcrime.securesms.ui.components.MaybeScanQrCode
|
||||||
@ -78,7 +78,7 @@ class LinkDeviceActivity : BaseActionBarActivity() {
|
|||||||
ComposeView(this).apply {
|
ComposeView(this).apply {
|
||||||
setContent {
|
setContent {
|
||||||
val state by viewModel.stateFlow.collectAsState()
|
val state by viewModel.stateFlow.collectAsState()
|
||||||
AppTheme {
|
SessionMaterialTheme {
|
||||||
LoadAccountScreen(state, viewModel::onChange, viewModel::onContinue, viewModel::onScanQrCode)
|
LoadAccountScreen(state, viewModel::onChange, viewModel::onContinue, viewModel::onScanQrCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ class LinkDeviceActivity : BaseActionBarActivity() {
|
|||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
fun PreviewRecoveryPassword() {
|
fun PreviewRecoveryPassword() {
|
||||||
PreviewTheme(R.style.Classic_Dark) {
|
PreviewTheme {
|
||||||
RecoveryPassword(state = LinkDeviceState())
|
RecoveryPassword(state = LinkDeviceState())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,8 @@ import org.thoughtcrime.securesms.BaseActionBarActivity
|
|||||||
import org.thoughtcrime.securesms.dependencies.ConfigFactory
|
import org.thoughtcrime.securesms.dependencies.ConfigFactory
|
||||||
import org.thoughtcrime.securesms.onboarding.messagenotifications.startMessageNotificationsActivity
|
import org.thoughtcrime.securesms.onboarding.messagenotifications.startMessageNotificationsActivity
|
||||||
import org.thoughtcrime.securesms.onboarding.pickname.startPickDisplayNameActivity
|
import org.thoughtcrime.securesms.onboarding.pickname.startPickDisplayNameActivity
|
||||||
import org.thoughtcrime.securesms.ui.AppTheme
|
|
||||||
import org.thoughtcrime.securesms.ui.ProgressArc
|
import org.thoughtcrime.securesms.ui.ProgressArc
|
||||||
|
import org.thoughtcrime.securesms.ui.SessionMaterialTheme
|
||||||
import org.thoughtcrime.securesms.ui.base
|
import org.thoughtcrime.securesms.ui.base
|
||||||
import org.thoughtcrime.securesms.ui.contentDescription
|
import org.thoughtcrime.securesms.ui.contentDescription
|
||||||
import org.thoughtcrime.securesms.ui.h7
|
import org.thoughtcrime.securesms.ui.h7
|
||||||
@ -103,7 +103,7 @@ class LoadingActivity: BaseActionBarActivity() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
AppTheme {
|
SessionMaterialTheme {
|
||||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
ProgressArc(
|
ProgressArc(
|
||||||
|
@ -24,7 +24,6 @@ import androidx.compose.runtime.collectAsState
|
|||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
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.platform.ComposeView
|
import androidx.compose.ui.platform.ComposeView
|
||||||
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
|
||||||
@ -37,11 +36,12 @@ import org.thoughtcrime.securesms.ApplicationContext
|
|||||||
import org.thoughtcrime.securesms.BaseActionBarActivity
|
import org.thoughtcrime.securesms.BaseActionBarActivity
|
||||||
import org.thoughtcrime.securesms.home.HomeActivity
|
import org.thoughtcrime.securesms.home.HomeActivity
|
||||||
import org.thoughtcrime.securesms.notifications.PushRegistry
|
import org.thoughtcrime.securesms.notifications.PushRegistry
|
||||||
import org.thoughtcrime.securesms.ui.AppTheme
|
|
||||||
import org.thoughtcrime.securesms.ui.LocalColors
|
import org.thoughtcrime.securesms.ui.LocalColors
|
||||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||||
import org.thoughtcrime.securesms.ui.ThemeResPreviewParameterProvider
|
import org.thoughtcrime.securesms.ui.SessionColors
|
||||||
|
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||||
|
import org.thoughtcrime.securesms.ui.SessionMaterialTheme
|
||||||
import org.thoughtcrime.securesms.ui.base
|
import org.thoughtcrime.securesms.ui.base
|
||||||
import org.thoughtcrime.securesms.ui.components.OutlineButton
|
import org.thoughtcrime.securesms.ui.components.OutlineButton
|
||||||
import org.thoughtcrime.securesms.ui.contentDescription
|
import org.thoughtcrime.securesms.ui.contentDescription
|
||||||
@ -72,7 +72,7 @@ class MessageNotificationsActivity : BaseActionBarActivity() {
|
|||||||
private fun MessageNotificationsScreen() {
|
private fun MessageNotificationsScreen() {
|
||||||
val state by viewModel.stateFlow.collectAsState()
|
val state by viewModel.stateFlow.collectAsState()
|
||||||
|
|
||||||
AppTheme {
|
SessionMaterialTheme {
|
||||||
MessageNotificationsScreen(state, viewModel::setEnabled, ::register)
|
MessageNotificationsScreen(state, viewModel::setEnabled, ::register)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,9 +91,9 @@ class MessageNotificationsActivity : BaseActionBarActivity() {
|
|||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
fun MessageNotificationsScreenPreview(
|
fun MessageNotificationsScreenPreview(
|
||||||
@PreviewParameter(ThemeResPreviewParameterProvider::class) themeResId: Int
|
@PreviewParameter(SessionColorsParameterProvider::class) sessionColors: SessionColors
|
||||||
) {
|
) {
|
||||||
PreviewTheme(themeResId) {
|
PreviewTheme(sessionColors) {
|
||||||
MessageNotificationsScreen()
|
MessageNotificationsScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,32 +104,35 @@ fun MessageNotificationsScreen(
|
|||||||
setEnabled: (Boolean) -> Unit = {},
|
setEnabled: (Boolean) -> Unit = {},
|
||||||
onContinue: () -> Unit = {}
|
onContinue: () -> Unit = {}
|
||||||
) {
|
) {
|
||||||
Column(Modifier.padding(horizontal = LocalDimensions.current.marginMedium)) {
|
Column {
|
||||||
Spacer(Modifier.weight(1f))
|
Spacer(Modifier.weight(1f))
|
||||||
Text(stringResource(R.string.notificationsMessage), style = MaterialTheme.typography.h4)
|
Column(modifier = Modifier.padding(horizontal = LocalDimensions.current.marginMedium)) {
|
||||||
Spacer(Modifier.height(LocalDimensions.current.marginExtraSmall))
|
Text(stringResource(R.string.notificationsMessage), style = MaterialTheme.typography.h4)
|
||||||
Text(stringResource(R.string.onboardingMessageNotificationExplaination), style = MaterialTheme.typography.base)
|
Spacer(Modifier.height(LocalDimensions.current.marginExtraSmall))
|
||||||
Spacer(Modifier.height(LocalDimensions.current.marginExtraSmall))
|
Text(stringResource(R.string.onboardingMessageNotificationExplaination), style = MaterialTheme.typography.base)
|
||||||
NotificationRadioButton(
|
Spacer(Modifier.height(LocalDimensions.current.marginExtraSmall))
|
||||||
R.string.activity_pn_mode_fast_mode,
|
NotificationRadioButton(
|
||||||
R.string.activity_pn_mode_fast_mode_explanation,
|
R.string.activity_pn_mode_fast_mode,
|
||||||
R.string.activity_pn_mode_recommended_option_tag,
|
R.string.activity_pn_mode_fast_mode_explanation,
|
||||||
contentDescription = R.string.AccessibilityId_fast_mode_notifications_button,
|
R.string.activity_pn_mode_recommended_option_tag,
|
||||||
selected = state.pushEnabled,
|
contentDescription = R.string.AccessibilityId_fast_mode_notifications_button,
|
||||||
onClick = { setEnabled(true) }
|
selected = state.pushEnabled,
|
||||||
)
|
onClick = { setEnabled(true) }
|
||||||
Spacer(Modifier.height(LocalDimensions.current.marginExtraSmall))
|
)
|
||||||
NotificationRadioButton(
|
Spacer(Modifier.height(LocalDimensions.current.marginExtraSmall))
|
||||||
R.string.activity_pn_mode_slow_mode,
|
NotificationRadioButton(
|
||||||
R.string.activity_pn_mode_slow_mode_explanation,
|
R.string.activity_pn_mode_slow_mode,
|
||||||
contentDescription = R.string.AccessibilityId_slow_mode_notifications_button,
|
R.string.activity_pn_mode_slow_mode_explanation,
|
||||||
selected = state.pushDisabled,
|
contentDescription = R.string.AccessibilityId_slow_mode_notifications_button,
|
||||||
onClick = { setEnabled(false) }
|
selected = state.pushDisabled,
|
||||||
)
|
onClick = { setEnabled(false) }
|
||||||
|
)
|
||||||
|
}
|
||||||
Spacer(Modifier.weight(1f))
|
Spacer(Modifier.weight(1f))
|
||||||
OutlineButton(
|
OutlineButton(
|
||||||
textId = R.string.continue_2,
|
textId = R.string.continue_2,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
.padding(horizontal = LocalDimensions.current.marginLarge)
|
||||||
.contentDescription(R.string.AccessibilityId_continue)
|
.contentDescription(R.string.AccessibilityId_continue)
|
||||||
.align(Alignment.CenterHorizontally)
|
.align(Alignment.CenterHorizontally)
|
||||||
.fillMaxWidth(),
|
.fillMaxWidth(),
|
||||||
@ -151,8 +154,10 @@ fun NotificationRadioButton(
|
|||||||
Row {
|
Row {
|
||||||
OutlinedButton(
|
OutlinedButton(
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
modifier = Modifier.weight(1f).contentDescription(contentDescription),
|
modifier = Modifier
|
||||||
colors = ButtonDefaults.outlinedButtonColors(backgroundColor = MaterialTheme.colors.background, contentColor = Color.White),
|
.weight(1f)
|
||||||
|
.contentDescription(contentDescription),
|
||||||
|
colors = ButtonDefaults.outlinedButtonColors(backgroundColor = LocalColors.current.background, contentColor = LocalColors.current.text),
|
||||||
border = if (selected) BorderStroke(ButtonDefaults.OutlinedBorderSize, LocalColors.current.primary) else ButtonDefaults.outlinedBorder,
|
border = if (selected) BorderStroke(ButtonDefaults.OutlinedBorderSize, LocalColors.current.primary) else ButtonDefaults.outlinedBorder,
|
||||||
shape = RoundedCornerShape(8.dp)
|
shape = RoundedCornerShape(8.dp)
|
||||||
) {
|
) {
|
||||||
|
@ -10,21 +10,13 @@ import androidx.compose.foundation.layout.Spacer
|
|||||||
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.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
||||||
import androidx.compose.foundation.text.KeyboardActions
|
|
||||||
import androidx.compose.material.ContentAlpha
|
|
||||||
import androidx.compose.material.LocalContentAlpha
|
|
||||||
import androidx.compose.material.LocalContentColor
|
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material.MaterialTheme
|
||||||
import androidx.compose.material.OutlinedTextField
|
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
import androidx.compose.material.TextFieldDefaults
|
|
||||||
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.platform.ComposeView
|
import androidx.compose.ui.platform.ComposeView
|
||||||
import androidx.compose.ui.platform.testTag
|
|
||||||
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
|
||||||
@ -32,20 +24,16 @@ import androidx.lifecycle.lifecycleScope
|
|||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.session.libsession.utilities.AppTextSecurePreferences
|
|
||||||
import org.thoughtcrime.securesms.ApplicationContext
|
import org.thoughtcrime.securesms.ApplicationContext
|
||||||
import org.thoughtcrime.securesms.BaseActionBarActivity
|
import org.thoughtcrime.securesms.BaseActionBarActivity
|
||||||
import org.thoughtcrime.securesms.onboarding.messagenotifications.MessageNotificationsActivity
|
|
||||||
import org.thoughtcrime.securesms.onboarding.messagenotifications.startMessageNotificationsActivity
|
import org.thoughtcrime.securesms.onboarding.messagenotifications.startMessageNotificationsActivity
|
||||||
import org.thoughtcrime.securesms.ui.AppTheme
|
|
||||||
import org.thoughtcrime.securesms.ui.GetString
|
|
||||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||||
|
import org.thoughtcrime.securesms.ui.SessionMaterialTheme
|
||||||
import org.thoughtcrime.securesms.ui.base
|
import org.thoughtcrime.securesms.ui.base
|
||||||
import org.thoughtcrime.securesms.ui.baseBold
|
|
||||||
import org.thoughtcrime.securesms.ui.components.OutlineButton
|
import org.thoughtcrime.securesms.ui.components.OutlineButton
|
||||||
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.outlinedTextFieldColors
|
import org.thoughtcrime.securesms.ui.setComposeContent
|
||||||
import org.thoughtcrime.securesms.util.setUpActionBarSessionLogo
|
import org.thoughtcrime.securesms.util.setUpActionBarSessionLogo
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -66,9 +54,7 @@ class PickDisplayNameActivity : BaseActionBarActivity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setUpActionBarSessionLogo()
|
setUpActionBarSessionLogo()
|
||||||
|
|
||||||
ComposeView(this)
|
setComposeContent { DisplayNameScreen(viewModel) }
|
||||||
.apply { setContent { DisplayNameScreen(viewModel) } }
|
|
||||||
.let(::setContentView)
|
|
||||||
|
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
viewModel.eventFlow.collect {
|
viewModel.eventFlow.collect {
|
||||||
@ -80,16 +66,13 @@ class PickDisplayNameActivity : BaseActionBarActivity() {
|
|||||||
@Composable
|
@Composable
|
||||||
private fun DisplayNameScreen(viewModel: PickDisplayNameViewModel) {
|
private fun DisplayNameScreen(viewModel: PickDisplayNameViewModel) {
|
||||||
val state = viewModel.stateFlow.collectAsState()
|
val state = viewModel.stateFlow.collectAsState()
|
||||||
|
DisplayName(state.value, viewModel::onChange) { viewModel.onContinue(this) }
|
||||||
AppTheme {
|
|
||||||
DisplayName(state.value, viewModel::onChange) { viewModel.onContinue(this) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
fun PreviewDisplayName() {
|
fun PreviewDisplayName() {
|
||||||
PreviewTheme(R.style.Classic_Dark) {
|
PreviewTheme {
|
||||||
DisplayName(State())
|
DisplayName(State())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,15 +33,15 @@ import androidx.compose.ui.unit.dp
|
|||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.thoughtcrime.securesms.BaseActionBarActivity
|
import org.thoughtcrime.securesms.BaseActionBarActivity
|
||||||
import org.thoughtcrime.securesms.showSessionDialog
|
import org.thoughtcrime.securesms.showSessionDialog
|
||||||
import org.thoughtcrime.securesms.ui.AppTheme
|
|
||||||
import org.thoughtcrime.securesms.ui.CellWithPaddingAndMargin
|
import org.thoughtcrime.securesms.ui.CellWithPaddingAndMargin
|
||||||
|
import org.thoughtcrime.securesms.ui.LocalColors
|
||||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||||
|
import org.thoughtcrime.securesms.ui.SessionColors
|
||||||
|
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||||
|
import org.thoughtcrime.securesms.ui.SessionMaterialTheme
|
||||||
import org.thoughtcrime.securesms.ui.SessionShieldIcon
|
import org.thoughtcrime.securesms.ui.SessionShieldIcon
|
||||||
import org.thoughtcrime.securesms.ui.ThemeResPreviewParameterProvider
|
|
||||||
import org.thoughtcrime.securesms.ui.base
|
import org.thoughtcrime.securesms.ui.base
|
||||||
import org.thoughtcrime.securesms.ui.classicDarkColors
|
|
||||||
import org.thoughtcrime.securesms.ui.components.DestructiveButtons
|
|
||||||
import org.thoughtcrime.securesms.ui.components.OutlineButton
|
import org.thoughtcrime.securesms.ui.components.OutlineButton
|
||||||
import org.thoughtcrime.securesms.ui.components.OutlineCopyButton
|
import org.thoughtcrime.securesms.ui.components.OutlineCopyButton
|
||||||
import org.thoughtcrime.securesms.ui.components.QrImage
|
import org.thoughtcrime.securesms.ui.components.QrImage
|
||||||
@ -96,9 +96,9 @@ class RecoveryPasswordActivity : BaseActionBarActivity() {
|
|||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
fun PreviewRecoveryPasswordScreen(
|
fun PreviewRecoveryPasswordScreen(
|
||||||
@PreviewParameter(ThemeResPreviewParameterProvider::class) themeResId: Int
|
@PreviewParameter(SessionColorsParameterProvider::class) sessionColors: SessionColors
|
||||||
) {
|
) {
|
||||||
PreviewTheme(themeResId) {
|
PreviewTheme(sessionColors) {
|
||||||
RecoveryPasswordScreen(seed = "Voyage urban toyed maverick peculiar tuxedo penguin tree grass building listen speak withdraw terminal plane")
|
RecoveryPasswordScreen(seed = "Voyage urban toyed maverick peculiar tuxedo penguin tree grass building listen speak withdraw terminal plane")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ fun RecoveryPasswordScreen(
|
|||||||
copySeed:() -> Unit = {},
|
copySeed:() -> Unit = {},
|
||||||
onHide:() -> Unit = {}
|
onHide:() -> Unit = {}
|
||||||
) {
|
) {
|
||||||
AppTheme {
|
SessionMaterialTheme {
|
||||||
Column(
|
Column(
|
||||||
verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.marginExtraSmall),
|
verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.marginExtraSmall),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@ -172,11 +172,13 @@ fun RecoveryPasswordCell(seed: String, copySeed:() -> Unit = {}) {
|
|||||||
Modifier
|
Modifier
|
||||||
.weight(1f)
|
.weight(1f)
|
||||||
.contentDescription(R.string.AccessibilityId_copy_button),
|
.contentDescription(R.string.AccessibilityId_copy_button),
|
||||||
|
color = LocalColors.current.text,
|
||||||
onClick = copySeed
|
onClick = copySeed
|
||||||
)
|
)
|
||||||
OutlineButton(
|
OutlineButton(
|
||||||
textId = R.string.qrView,
|
textId = R.string.qrView,
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
|
color = LocalColors.current.text,
|
||||||
onClick = { showQr = !showQr }
|
onClick = { showQr = !showQr }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -201,13 +203,13 @@ private fun RecoveryPassword(seed: String) {
|
|||||||
.padding(vertical = LocalDimensions.current.marginSmall)
|
.padding(vertical = LocalDimensions.current.marginSmall)
|
||||||
.border(
|
.border(
|
||||||
width = 1.dp,
|
width = 1.dp,
|
||||||
color = classicDarkColors[3],
|
color = LocalColors.current.borders,
|
||||||
shape = RoundedCornerShape(11.dp)
|
shape = RoundedCornerShape(11.dp)
|
||||||
)
|
)
|
||||||
.padding(LocalDimensions.current.marginSmall),
|
.padding(LocalDimensions.current.marginSmall),
|
||||||
textAlign = TextAlign.Center,
|
textAlign = TextAlign.Center,
|
||||||
style = MaterialTheme.typography.extraSmallMonospace,
|
style = MaterialTheme.typography.extraSmallMonospace,
|
||||||
color = MaterialTheme.colors.run { if (isLight) onSurface else secondary },
|
color = LocalColors.current.run { if (isLight) text else primary },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,16 +230,15 @@ private fun HideRecoveryPasswordCell(onHide: () -> Unit = {}) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
Spacer(modifier = Modifier.width(LocalDimensions.current.marginExtraExtraSmall))
|
Spacer(modifier = Modifier.width(LocalDimensions.current.marginExtraExtraSmall))
|
||||||
DestructiveButtons {
|
OutlineButton(
|
||||||
OutlineButton(
|
textId = R.string.hide,
|
||||||
textId = R.string.hide,
|
modifier = Modifier
|
||||||
modifier = Modifier
|
.wrapContentWidth()
|
||||||
.wrapContentWidth()
|
.align(Alignment.CenterVertically)
|
||||||
.align(Alignment.CenterVertically)
|
.contentDescription(R.string.AccessibilityId_hide_recovery_password_button),
|
||||||
.contentDescription(R.string.AccessibilityId_hide_recovery_password_button),
|
color = LocalColors.current.danger,
|
||||||
onClick = onHide
|
onClick = onHide
|
||||||
)
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,12 +73,12 @@ import org.thoughtcrime.securesms.permissions.Permissions
|
|||||||
import org.thoughtcrime.securesms.preferences.appearance.AppearanceSettingsActivity
|
import org.thoughtcrime.securesms.preferences.appearance.AppearanceSettingsActivity
|
||||||
import org.thoughtcrime.securesms.profiles.ProfileMediaConstraints
|
import org.thoughtcrime.securesms.profiles.ProfileMediaConstraints
|
||||||
import org.thoughtcrime.securesms.showSessionDialog
|
import org.thoughtcrime.securesms.showSessionDialog
|
||||||
import org.thoughtcrime.securesms.ui.AppTheme
|
|
||||||
import org.thoughtcrime.securesms.ui.Cell
|
import org.thoughtcrime.securesms.ui.Cell
|
||||||
import org.thoughtcrime.securesms.ui.Divider
|
import org.thoughtcrime.securesms.ui.Divider
|
||||||
import org.thoughtcrime.securesms.ui.ItemButton
|
import org.thoughtcrime.securesms.ui.ItemButton
|
||||||
import org.thoughtcrime.securesms.ui.ItemButtonWithDrawable
|
import org.thoughtcrime.securesms.ui.ItemButtonWithDrawable
|
||||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||||
|
import org.thoughtcrime.securesms.ui.SessionMaterialTheme
|
||||||
import org.thoughtcrime.securesms.ui.components.OutlineButton
|
import org.thoughtcrime.securesms.ui.components.OutlineButton
|
||||||
import org.thoughtcrime.securesms.ui.components.OutlineCopyButton
|
import org.thoughtcrime.securesms.ui.components.OutlineCopyButton
|
||||||
import org.thoughtcrime.securesms.ui.destructiveButtonColors
|
import org.thoughtcrime.securesms.ui.destructiveButtonColors
|
||||||
@ -133,7 +133,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
binding.composeView.setContent {
|
binding.composeView.setContent {
|
||||||
AppTheme {
|
SessionMaterialTheme {
|
||||||
Buttons()
|
Buttons()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,6 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
|
|
||||||
val colorDestructive = Color(0xffFF453A)
|
|
||||||
|
|
||||||
const val classicDark0 = 0xff111111
|
const val classicDark0 = 0xff111111
|
||||||
const val classicDark1 = 0xff1B1B1B
|
const val classicDark1 = 0xff1B1B1B
|
||||||
const val classicDark2 = 0xff2D2D2D
|
const val classicDark2 = 0xff2D2D2D
|
||||||
@ -73,12 +71,7 @@ val blackAlpha40 = Color.Black.copy(alpha = 0.4f)
|
|||||||
fun transparentButtonColors() = ButtonDefaults.buttonColors(backgroundColor = Color.Transparent)
|
fun transparentButtonColors() = ButtonDefaults.buttonColors(backgroundColor = Color.Transparent)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun destructiveButtonColors() = ButtonDefaults.buttonColors(backgroundColor = Color.Transparent, contentColor = colorDestructive)
|
fun destructiveButtonColors() = ButtonDefaults.buttonColors(backgroundColor = Color.Transparent, contentColor = LocalColors.current.danger)
|
||||||
|
|
||||||
@Preview @Composable fun ClassicLight() { Colors("classic light", classicLightColors) }
|
|
||||||
@Preview @Composable fun ClassicDark() { Colors("classic dark", classicDarkColors) }
|
|
||||||
@Preview @Composable fun OceanLight() { Colors("ocean light", oceanLightColors) }
|
|
||||||
@Preview @Composable fun OceanDark() { Colors("ocean dark", oceanDarkColors) }
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Colors(name: String, colors: List<Color>) {
|
fun Colors(name: String, colors: List<Color>) {
|
||||||
@ -94,41 +87,37 @@ fun Colors(name: String, colors: List<Color>) {
|
|||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
fun PreviewThemeColors(
|
fun PreviewThemeColors(
|
||||||
@PreviewParameter(ThemeResPreviewParameterProvider::class) themeResId: Int
|
@PreviewParameter(SessionColorsParameterProvider::class) sessionColors: SessionColors
|
||||||
) {
|
) {
|
||||||
PreviewTheme(themeResId) {
|
PreviewTheme(sessionColors) { ThemeColors() }
|
||||||
ThemeColors()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ThemeColors() {
|
private fun ThemeColors() {
|
||||||
AppTheme {
|
Column {
|
||||||
Column {
|
Box(Modifier.background(MaterialTheme.colors.primary)) {
|
||||||
Box(Modifier.background(MaterialTheme.colors.primary)) {
|
Text("primary", style = MaterialTheme.typography.base)
|
||||||
Text("primary", style = MaterialTheme.typography.base)
|
}
|
||||||
}
|
Box(Modifier.background(MaterialTheme.colors.primaryVariant)) {
|
||||||
Box(Modifier.background(MaterialTheme.colors.primaryVariant)) {
|
Text("primaryVariant", style = MaterialTheme.typography.base)
|
||||||
Text("primaryVariant", style = MaterialTheme.typography.base)
|
}
|
||||||
}
|
Box(Modifier.background(MaterialTheme.colors.secondary)) {
|
||||||
Box(Modifier.background(MaterialTheme.colors.secondary)) {
|
Text("secondary", style = MaterialTheme.typography.base)
|
||||||
Text("secondary", style = MaterialTheme.typography.base)
|
}
|
||||||
}
|
Box(Modifier.background(MaterialTheme.colors.secondaryVariant)) {
|
||||||
Box(Modifier.background(MaterialTheme.colors.secondaryVariant)) {
|
Text("secondaryVariant", style = MaterialTheme.typography.base)
|
||||||
Text("secondaryVariant", style = MaterialTheme.typography.base)
|
}
|
||||||
}
|
Box(Modifier.background(MaterialTheme.colors.surface)) {
|
||||||
Box(Modifier.background(MaterialTheme.colors.surface)) {
|
Text("surface", style = MaterialTheme.typography.base)
|
||||||
Text("surface", style = MaterialTheme.typography.base)
|
}
|
||||||
}
|
Box(Modifier.background(MaterialTheme.colors.primarySurface)) {
|
||||||
Box(Modifier.background(MaterialTheme.colors.primarySurface)) {
|
Text("primarySurface", style = MaterialTheme.typography.base)
|
||||||
Text("primarySurface", style = MaterialTheme.typography.base)
|
}
|
||||||
}
|
Box(Modifier.background(MaterialTheme.colors.background)) {
|
||||||
Box(Modifier.background(MaterialTheme.colors.background)) {
|
Text("background", style = MaterialTheme.typography.base)
|
||||||
Text("background", style = MaterialTheme.typography.base)
|
}
|
||||||
}
|
Box(Modifier.background(MaterialTheme.colors.error)) {
|
||||||
Box(Modifier.background(MaterialTheme.colors.error)) {
|
Text("error", style = MaterialTheme.typography.base)
|
||||||
Text("error", style = MaterialTheme.typography.base)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,11 +126,11 @@ private fun ThemeColors() {
|
|||||||
fun outlinedTextFieldColors(
|
fun outlinedTextFieldColors(
|
||||||
isError: Boolean
|
isError: Boolean
|
||||||
) = TextFieldDefaults.outlinedTextFieldColors(
|
) = TextFieldDefaults.outlinedTextFieldColors(
|
||||||
textColor = if (isError) colorDestructive else LocalContentColor.current,
|
textColor = if (isError) LocalColors.current.danger else LocalContentColor.current,
|
||||||
cursorColor = if (isError) colorDestructive else LocalContentColor.current,
|
cursorColor = if (isError) LocalColors.current.danger else LocalContentColor.current,
|
||||||
focusedBorderColor = Color(classicDark3),
|
focusedBorderColor = LocalColors.current.borders,
|
||||||
unfocusedBorderColor = Color(classicDark3),
|
unfocusedBorderColor = LocalColors.current.borders,
|
||||||
placeholderColor = if (isError) colorDestructive else MaterialTheme.colors.onSurface.copy(ContentAlpha.medium)
|
placeholderColor = if (isError) LocalColors.current.danger else LocalColors.current.textSecondary
|
||||||
)
|
)
|
||||||
|
|
||||||
fun TextSecurePreferences.Companion.getAccentColor(context: Context): Color = when (getAccentColorName(context)) {
|
fun TextSecurePreferences.Companion.getAccentColor(context: Context): Color = when (getAccentColorName(context)) {
|
||||||
|
@ -66,7 +66,6 @@ import org.session.libsession.utilities.recipients.Recipient
|
|||||||
import org.session.libsession.utilities.runIf
|
import org.session.libsession.utilities.runIf
|
||||||
import org.thoughtcrime.securesms.components.ProfilePictureView
|
import org.thoughtcrime.securesms.components.ProfilePictureView
|
||||||
import org.thoughtcrime.securesms.conversation.disappearingmessages.ui.OptionsCard
|
import org.thoughtcrime.securesms.conversation.disappearingmessages.ui.OptionsCard
|
||||||
import org.thoughtcrime.securesms.ui.components.OnPrimaryButtons
|
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@ -209,18 +208,16 @@ fun CellWithPaddingAndMargin(
|
|||||||
margin: Dp = 32.dp,
|
margin: Dp = 32.dp,
|
||||||
content: @Composable () -> Unit
|
content: @Composable () -> Unit
|
||||||
) {
|
) {
|
||||||
OnPrimaryButtons {
|
Card(
|
||||||
Card(
|
backgroundColor = LocalColors.current.backgroundSecondary,
|
||||||
backgroundColor = LocalCellColor.current,
|
shape = RoundedCornerShape(16.dp),
|
||||||
shape = RoundedCornerShape(16.dp),
|
elevation = 0.dp,
|
||||||
elevation = 0.dp,
|
modifier = Modifier
|
||||||
modifier = Modifier
|
.wrapContentHeight()
|
||||||
.wrapContentHeight()
|
.fillMaxWidth()
|
||||||
.fillMaxWidth()
|
.padding(horizontal = margin),
|
||||||
.padding(horizontal = margin),
|
) {
|
||||||
) {
|
Box(Modifier.padding(padding)) { content() }
|
||||||
Box(Modifier.padding(padding)) { content() }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,9 +8,11 @@ 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.foundation.text.selection.TextSelectionColors
|
import androidx.compose.foundation.text.selection.TextSelectionColors
|
||||||
|
import androidx.compose.material.Colors
|
||||||
import androidx.compose.material.LocalContentColor
|
import androidx.compose.material.LocalContentColor
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material.MaterialTheme
|
||||||
import androidx.compose.material.Shapes
|
import androidx.compose.material.Shapes
|
||||||
|
import androidx.compose.material.TabRowDefaults
|
||||||
import androidx.compose.material.Typography
|
import androidx.compose.material.Typography
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
@ -31,10 +33,9 @@ import com.google.accompanist.themeadapter.appcompat.createAppCompatTheme
|
|||||||
import com.google.android.material.color.MaterialColors
|
import com.google.android.material.color.MaterialColors
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.session.libsession.utilities.AppTextSecurePreferences
|
import org.session.libsession.utilities.AppTextSecurePreferences
|
||||||
|
import org.thoughtcrime.securesms.util.ThemeState
|
||||||
import org.thoughtcrime.securesms.util.themeState
|
import org.thoughtcrime.securesms.util.themeState
|
||||||
|
|
||||||
val LocalCellColor = staticCompositionLocalOf { Color.Black }
|
|
||||||
val LocalButtonColor = staticCompositionLocalOf { Color.Black }
|
|
||||||
val LocalLightCell = staticCompositionLocalOf { Color.Black }
|
val LocalLightCell = staticCompositionLocalOf { Color.Black }
|
||||||
val LocalOnLightCell = staticCompositionLocalOf { Color.Black }
|
val LocalOnLightCell = staticCompositionLocalOf { Color.Black }
|
||||||
|
|
||||||
@ -54,9 +55,10 @@ data class Dimensions(
|
|||||||
val dividerIndent: Dp = 80.dp,
|
val dividerIndent: Dp = 80.dp,
|
||||||
)
|
)
|
||||||
|
|
||||||
val LocalColors = staticCompositionLocalOf { SessionColors() }
|
val LocalColors = staticCompositionLocalOf { sessionColors(isLight = false, isClassic = true) }
|
||||||
|
|
||||||
data class SessionColors(
|
data class SessionColors(
|
||||||
|
val isLight: Boolean = false,
|
||||||
val primary: Color = Color.Unspecified,
|
val primary: Color = Color.Unspecified,
|
||||||
val danger: Color = Color.Unspecified,
|
val danger: Color = Color.Unspecified,
|
||||||
val disabled: Color = Color.Unspecified,
|
val disabled: Color = Color.Unspecified,
|
||||||
@ -69,6 +71,7 @@ data class SessionColors(
|
|||||||
val backgroundBubbleReceived: Color = Color.Unspecified,
|
val backgroundBubbleReceived: Color = Color.Unspecified,
|
||||||
val textBubbleReceived: Color = Color.Unspecified,
|
val textBubbleReceived: Color = Color.Unspecified,
|
||||||
) {
|
) {
|
||||||
|
val divider get() = text.copy(alpha = TabRowDefaults.DividerOpacity)
|
||||||
val backgroundBubbleSent get() = primary
|
val backgroundBubbleSent get() = primary
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,107 +105,90 @@ private class UnresolvedColor(val function: (Boolean, Boolean) -> Color) {
|
|||||||
constructor(classicDark: Color, classicLight: Color, oceanDark: Color, oceanLight: Color): this(function = { isLight, isClassic -> if (isLight) if (isClassic) classicLight else oceanLight else if (isClassic) classicDark else oceanDark })
|
constructor(classicDark: Color, classicLight: Color, oceanDark: Color, oceanLight: Color): this(function = { isLight, isClassic -> if (isLight) if (isClassic) classicLight else oceanLight else if (isClassic) classicDark else oceanDark })
|
||||||
}
|
}
|
||||||
|
|
||||||
private class UnresolvedSessionColors(
|
private fun sessionColors(
|
||||||
val danger: UnresolvedColor = UnresolvedColor(dark = dangerDark, light = dangerLight),
|
isLight: Boolean,
|
||||||
val disabled: UnresolvedColor = UnresolvedColor(dark = disabledDark, light = disabledLioht),
|
isClassic: Boolean,
|
||||||
val background: UnresolvedColor = UnresolvedColor(Color.Black, Color.White, oceanDarkColors[2], oceanLightColors[7]),
|
primary: Color = if (isClassic) primaryGreen else primaryBlue
|
||||||
val backgroundSecondary: UnresolvedColor = UnresolvedColor(classicDarkColors[1], classicLightColors[5], oceanDarkColors[1], oceanLightColors[6]),
|
): SessionColors {
|
||||||
val text: UnresolvedColor = UnresolvedColor(Color.White, Color.Black, oceanDarkColors[1], oceanLightColors[1]),
|
val index = (if (isLight) 1 else 0) + if (isClassic) 0 else 2
|
||||||
val textSecondary: UnresolvedColor = UnresolvedColor(classicDarkColors[5], classicLightColors[1], oceanDarkColors[5], oceanLightColors[2]),
|
return SessionColors(
|
||||||
val borders: UnresolvedColor = UnresolvedColor(classicDarkColors[3], classicLightColors[3], oceanDarkColors[4], oceanLightColors[3]),
|
isLight = isLight,
|
||||||
val textBubbleSent: UnresolvedColor = UnresolvedColor(Color.Black, Color.Black, Color.Black, oceanLightColors[1]),
|
|
||||||
val backgroundBubbleReceived: UnresolvedColor = UnresolvedColor(classicDarkColors[2], classicLightColors[4], oceanDarkColors[4], oceanLightColors[4]),
|
|
||||||
val textBubbleReceived: UnresolvedColor = UnresolvedColor(Color.White, classicLightColors[4], oceanDarkColors[4], oceanLightColors[4]),
|
|
||||||
) {
|
|
||||||
operator fun invoke(primary: Color, isLight: Boolean, isClassic: Boolean) = SessionColors(
|
|
||||||
primary = primary,
|
primary = primary,
|
||||||
danger = danger(isLight, isClassic),
|
danger = if (isLight) dangerLight else dangerDark,
|
||||||
disabled = disabled(isLight, isClassic),
|
disabled = if (isLight) disabledLioht else disabledDark,
|
||||||
background = background(isLight, isClassic),
|
background = listOf(Color.Black, Color.White, oceanDarkColors[2], oceanLightColors[7])[index],
|
||||||
backgroundSecondary = backgroundSecondary(isLight, isClassic),
|
backgroundSecondary = listOf(classicDarkColors[1], classicLightColors[5], oceanDarkColors[1], oceanLightColors[6])[index],
|
||||||
text = text(isLight, isClassic),
|
text = listOf(Color.White, Color.Black, oceanDarkColors[1], oceanLightColors[1])[index],
|
||||||
textSecondary = textSecondary(isLight, isClassic),
|
textSecondary = listOf(classicDarkColors[5], classicLightColors[1], oceanDarkColors[5], oceanLightColors[2])[index],
|
||||||
borders = borders(isLight, isClassic),
|
borders = listOf(classicDarkColors[3], classicLightColors[3], oceanDarkColors[4], oceanLightColors[3])[index],
|
||||||
textBubbleSent = textBubbleSent(isLight, isClassic),
|
textBubbleSent = listOf(Color.Black, Color.Black, Color.Black, oceanLightColors[1])[index],
|
||||||
backgroundBubbleReceived = backgroundBubbleReceived(isLight, isClassic),
|
backgroundBubbleReceived = listOf(classicDarkColors[2], classicLightColors[4], oceanDarkColors[4], oceanLightColors[4])[index],
|
||||||
textBubbleReceived = textBubbleReceived(isLight, isClassic),
|
textBubbleReceived = listOf(Color.White, classicLightColors[4], oceanDarkColors[4], oceanLightColors[4])[index],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun Context.sessionColors() = AppTextSecurePreferences(this).themeState().sessionColors()
|
||||||
|
private fun ThemeState.sessionColors() = sessionColors(isLight, isClassic, accent)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts current Theme to Compose Theme.
|
* Sets a Material2 compose theme based on your selections in SharedPreferences.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun AppTheme(
|
fun SessionMaterialTheme(
|
||||||
content: @Composable () -> Unit
|
content: @Composable () -> Unit
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
SessionMaterialTheme(LocalContext.current.sessionColors()) { content() }
|
||||||
|
}
|
||||||
|
|
||||||
val surface = context.getColorFromTheme(R.attr.colorSettingsBackground)
|
|
||||||
|
|
||||||
val themeState = AppTextSecurePreferences(context).themeState()
|
/**
|
||||||
|
*
|
||||||
val sessionColors = UnresolvedSessionColors()(themeState.accent, themeState.isLight, themeState.isClassic)
|
**/
|
||||||
|
@Composable
|
||||||
val textSelectionColors = TextSelectionColors(
|
fun SessionMaterialTheme(
|
||||||
handleColor = MaterialTheme.colors.secondary,
|
sessionColors: SessionColors,
|
||||||
backgroundColor = MaterialTheme.colors.secondary.copy(alpha = 0.5f)
|
content: @Composable () -> Unit
|
||||||
)
|
) {
|
||||||
|
MaterialTheme(
|
||||||
CompositionLocalProvider(
|
colors = sessionColors.toMaterialColors(),
|
||||||
*listOf(
|
typography = sessionTypography,
|
||||||
LocalCellColor to R.attr.colorSettingsBackground,
|
shapes = sessionShapes,
|
||||||
LocalButtonColor to R.attr.prominentButtonColor,
|
|
||||||
LocalLightCell to R.attr.lightCell,
|
|
||||||
LocalOnLightCell to R.attr.onLightCell,
|
|
||||||
).map { (local, attr) -> local provides context.getColorFromTheme(attr) }.toTypedArray()
|
|
||||||
) {
|
) {
|
||||||
AppCompatTheme(surface = surface) {
|
val textSelectionColors = TextSelectionColors(
|
||||||
CompositionLocalProvider(
|
handleColor = LocalColors.current.primary,
|
||||||
LocalColors provides sessionColors,
|
backgroundColor = LocalColors.current.primary.copy(alpha = 0.5f)
|
||||||
LocalTextSelectionColors provides textSelectionColors
|
)
|
||||||
) {
|
|
||||||
content()
|
CompositionLocalProvider(
|
||||||
}
|
LocalColors provides sessionColors,
|
||||||
|
LocalContentColor provides sessionColors.text,
|
||||||
|
LocalTextSelectionColors provides textSelectionColors
|
||||||
|
) {
|
||||||
|
content()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
private fun SessionColors.toMaterialColors() = Colors(
|
||||||
fun AppCompatTheme(
|
primary = background,
|
||||||
context: Context = LocalContext.current,
|
primaryVariant = backgroundSecondary,
|
||||||
readColors: Boolean = true,
|
secondary = background,
|
||||||
typography: Typography = sessionTypography,
|
secondaryVariant = background,
|
||||||
shapes: Shapes = MaterialTheme.shapes,
|
background = background,
|
||||||
surface: Color? = null,
|
surface = background,
|
||||||
content: @Composable () -> Unit
|
error = danger,
|
||||||
) {
|
onPrimary = text,
|
||||||
val themeParams = remember(context.theme) {
|
onSecondary = text,
|
||||||
context.createAppCompatTheme(
|
onBackground = text,
|
||||||
readColors = readColors,
|
onSurface = background,
|
||||||
readTypography = false
|
onError = text,
|
||||||
)
|
isLight = isLight
|
||||||
}
|
)
|
||||||
|
|
||||||
val colors = themeParams.colors ?: MaterialTheme.colors
|
val sessionShapes = Shapes(
|
||||||
|
small = RoundedCornerShape(50)
|
||||||
MaterialTheme(
|
)
|
||||||
colors = colors.copy(
|
|
||||||
surface = surface ?: colors.surface
|
|
||||||
),
|
|
||||||
typography = typography,
|
|
||||||
shapes = shapes.copy(
|
|
||||||
small = RoundedCornerShape(50)
|
|
||||||
),
|
|
||||||
) {
|
|
||||||
// We update the LocalContentColor to match our onBackground. This allows the default
|
|
||||||
// content color to be more appropriate to the theme background
|
|
||||||
CompositionLocalProvider(
|
|
||||||
LocalContentColor provides MaterialTheme.colors.onBackground,
|
|
||||||
content = content
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun boldStyle(size: TextUnit) = TextStyle.Default.copy(
|
fun boldStyle(size: TextUnit) = TextStyle.Default.copy(
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
@ -246,25 +232,21 @@ fun Context.getColorFromTheme(@AttrRes attr: Int, defaultValue: Int = 0x0): Colo
|
|||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun PreviewTheme(
|
fun PreviewTheme(
|
||||||
themeResId: Int,
|
sessionColors: SessionColors = LocalColors.current,
|
||||||
content: @Composable () -> Unit
|
content: @Composable () -> Unit
|
||||||
) {
|
) {
|
||||||
CompositionLocalProvider(
|
SessionMaterialTheme(sessionColors) {
|
||||||
LocalContext provides ContextThemeWrapper(LocalContext.current, themeResId)
|
Box(modifier = Modifier.background(color = LocalColors.current.background)) {
|
||||||
) {
|
content()
|
||||||
AppTheme {
|
|
||||||
Box(modifier = Modifier.background(color = MaterialTheme.colors.background)) {
|
|
||||||
content()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ThemeResPreviewParameterProvider : PreviewParameterProvider<Int> {
|
class SessionColorsParameterProvider : PreviewParameterProvider<SessionColors> {
|
||||||
override val values = sequenceOf(
|
override val values = sequenceOf(
|
||||||
R.style.Classic_Dark,
|
sessionColors(isLight = false, isClassic = true),
|
||||||
R.style.Classic_Light,
|
sessionColors(isLight = true, isClassic = true),
|
||||||
R.style.Ocean_Dark,
|
sessionColors(isLight = false, isClassic = false),
|
||||||
R.style.Ocean_Light,
|
sessionColors(isLight = true, isClassic = false),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,18 @@ package org.thoughtcrime.securesms.ui
|
|||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.platform.ComposeView
|
import androidx.compose.ui.platform.ComposeView
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
|
||||||
fun Activity.setComposeContent(content: @Composable () -> Unit) {
|
fun Activity.setComposeContent(content: @Composable () -> Unit) {
|
||||||
ComposeView(this)
|
ComposeView(this)
|
||||||
.apply { setContent { AppTheme { content() } } }
|
.apply { setContent { SessionMaterialTheme { content() } } }
|
||||||
.let(::setContentView)
|
.let(::setContentView)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Fragment.onCreateView(content: @Composable () -> Unit): ComposeView = ComposeView(requireContext()).apply {
|
||||||
|
setContent {
|
||||||
|
SessionMaterialTheme {
|
||||||
|
content()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -43,12 +43,12 @@ import kotlinx.coroutines.flow.filter
|
|||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.thoughtcrime.securesms.ui.GetString
|
import org.thoughtcrime.securesms.ui.GetString
|
||||||
import org.thoughtcrime.securesms.ui.LaunchedEffectAsync
|
import org.thoughtcrime.securesms.ui.LaunchedEffectAsync
|
||||||
import org.thoughtcrime.securesms.ui.LocalButtonColor
|
import org.thoughtcrime.securesms.ui.LocalColors
|
||||||
import org.thoughtcrime.securesms.ui.baseBold
|
import org.thoughtcrime.securesms.ui.baseBold
|
||||||
import org.thoughtcrime.securesms.ui.colorDestructive
|
|
||||||
import org.thoughtcrime.securesms.ui.contentDescription
|
import org.thoughtcrime.securesms.ui.contentDescription
|
||||||
import org.thoughtcrime.securesms.ui.disabled
|
|
||||||
import org.thoughtcrime.securesms.ui.extraSmall
|
import org.thoughtcrime.securesms.ui.extraSmall
|
||||||
|
import kotlin.time.Duration
|
||||||
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
val LocalButtonSize = staticCompositionLocalOf { mediumButton }
|
val LocalButtonSize = staticCompositionLocalOf { mediumButton }
|
||||||
|
|
||||||
@ -61,12 +61,15 @@ val smallButton = Modifier.wrapContentHeight()
|
|||||||
@Composable
|
@Composable
|
||||||
fun SessionButtonText(
|
fun SessionButtonText(
|
||||||
text: String,
|
text: String,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier,
|
||||||
){
|
color: Color = LocalColors.current.primary,
|
||||||
|
enabled: Boolean = true
|
||||||
|
) {
|
||||||
Text(
|
Text(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
text = text,
|
text = text,
|
||||||
style = MaterialTheme.typography.baseBold
|
style = MaterialTheme.typography.baseBold,
|
||||||
|
color = if (enabled) color else LocalColors.current.disabled
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,20 +77,23 @@ fun SessionButtonText(
|
|||||||
fun OutlineButton(
|
fun OutlineButton(
|
||||||
@StringRes textId: Int,
|
@StringRes textId: Int,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
color: Color = LocalColors.current.primary,
|
||||||
onClick: () -> Unit
|
onClick: () -> Unit
|
||||||
) { OutlineButton(stringResource(textId), modifier, onClick) }
|
) { OutlineButton(stringResource(textId), modifier, color, onClick) }
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun OutlineButton(
|
fun OutlineButton(
|
||||||
text: String,
|
text: String,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
color: Color = LocalColors.current.primary,
|
||||||
onClick: () -> Unit
|
onClick: () -> Unit
|
||||||
) {
|
) {
|
||||||
OutlineButton(
|
OutlineButton(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
|
color = color,
|
||||||
onClick = onClick
|
onClick = onClick
|
||||||
) {
|
) {
|
||||||
SessionButtonText(text = text)
|
SessionButtonText(text = text, color = color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,6 +102,7 @@ fun OutlineButton(
|
|||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
enabled: Boolean = true,
|
enabled: Boolean = true,
|
||||||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
||||||
|
color: Color = LocalColors.current.primary,
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit,
|
||||||
content: @Composable () -> Unit = {}
|
content: @Composable () -> Unit = {}
|
||||||
) {
|
) {
|
||||||
@ -104,9 +111,9 @@ fun OutlineButton(
|
|||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
interactionSource = interactionSource,
|
interactionSource = interactionSource,
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
border = BorderStroke(1.dp, if (enabled) LocalButtonColor.current else MaterialTheme.colors.disabled),
|
border = BorderStroke(1.dp, if (enabled) color else LocalColors.current.disabled),
|
||||||
colors = ButtonDefaults.outlinedButtonColors(
|
colors = ButtonDefaults.outlinedButtonColors(
|
||||||
contentColor = if (enabled) LocalButtonColor.current else Color.Unspecified,
|
contentColor = if (enabled) color else Color.Unspecified,
|
||||||
backgroundColor = Color.Unspecified
|
backgroundColor = Color.Unspecified
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
@ -117,6 +124,7 @@ fun OutlineButton(
|
|||||||
@Composable
|
@Composable
|
||||||
fun OutlineCopyButton(
|
fun OutlineCopyButton(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
color: Color = LocalColors.current.primary,
|
||||||
onClick: () -> Unit = {}
|
onClick: () -> Unit = {}
|
||||||
) {
|
) {
|
||||||
val interactionSource = remember { MutableInteractionSource() }
|
val interactionSource = remember { MutableInteractionSource() }
|
||||||
@ -124,6 +132,7 @@ fun OutlineCopyButton(
|
|||||||
OutlineButton(
|
OutlineButton(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
interactionSource = interactionSource,
|
interactionSource = interactionSource,
|
||||||
|
color = color,
|
||||||
onClick = onClick
|
onClick = onClick
|
||||||
) {
|
) {
|
||||||
TemporaryClickedContent(
|
TemporaryClickedContent(
|
||||||
@ -134,8 +143,9 @@ fun OutlineCopyButton(
|
|||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
) {
|
) {
|
||||||
SessionButtonText(
|
SessionButtonText(
|
||||||
|
text = stringResource(R.string.copy),
|
||||||
modifier = Modifier.align(Alignment.Center),
|
modifier = Modifier.align(Alignment.Center),
|
||||||
text = stringResource(R.string.copy)
|
color = color
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -145,8 +155,9 @@ fun OutlineCopyButton(
|
|||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
) {
|
) {
|
||||||
SessionButtonText(
|
SessionButtonText(
|
||||||
|
text = stringResource(R.string.copied),
|
||||||
modifier = Modifier.align(Alignment.Center),
|
modifier = Modifier.align(Alignment.Center),
|
||||||
text = stringResource(R.string.copied)
|
color = color
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,7 +171,7 @@ fun TemporaryClickedContent(
|
|||||||
interactionSource: MutableInteractionSource,
|
interactionSource: MutableInteractionSource,
|
||||||
content: @Composable () -> Unit,
|
content: @Composable () -> Unit,
|
||||||
temporaryContent: @Composable () -> Unit,
|
temporaryContent: @Composable () -> Unit,
|
||||||
temporaryDelay: Long = 2000
|
temporaryDelay: Duration = 2.seconds
|
||||||
) {
|
) {
|
||||||
var clicked by remember { mutableStateOf(false) }
|
var clicked by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
@ -193,11 +204,11 @@ fun FilledButton(
|
|||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
colors = ButtonDefaults.outlinedButtonColors(
|
colors = ButtonDefaults.outlinedButtonColors(
|
||||||
contentColor = MaterialTheme.colors.background,
|
contentColor = LocalColors.current.background,
|
||||||
backgroundColor = LocalButtonColor.current
|
backgroundColor = LocalColors.current.primary
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
SessionButtonText(text)
|
SessionButtonText(text, color = LocalColors.current.background)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,13 +304,3 @@ private val MutableInteractionSource.releases
|
|||||||
fun SmallButtons(content: @Composable () -> Unit) {
|
fun SmallButtons(content: @Composable () -> Unit) {
|
||||||
CompositionLocalProvider(LocalButtonSize provides smallButton) { content() }
|
CompositionLocalProvider(LocalButtonSize provides smallButton) { content() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun DestructiveButtons(content: @Composable () -> Unit) {
|
|
||||||
CompositionLocalProvider(LocalButtonColor provides colorDestructive) { content() }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun OnPrimaryButtons(content: @Composable () -> Unit) {
|
|
||||||
CompositionLocalProvider(LocalButtonColor provides MaterialTheme.colors.onPrimary) { content() }
|
|
||||||
}
|
|
||||||
|
@ -32,6 +32,7 @@ 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.LocalColors
|
||||||
import org.thoughtcrime.securesms.ui.LocalLightCell
|
import org.thoughtcrime.securesms.ui.LocalLightCell
|
||||||
import org.thoughtcrime.securesms.ui.LocalOnLightCell
|
import org.thoughtcrime.securesms.ui.LocalOnLightCell
|
||||||
import org.thoughtcrime.securesms.util.QRCodeUtilities
|
import org.thoughtcrime.securesms.util.QRCodeUtilities
|
||||||
@ -55,7 +56,7 @@ fun QrImage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MaterialTheme.colors.isLight) {
|
if (LocalColors.current.isLight) {
|
||||||
Content(bitmap, icon, modifier = modifier, backgroundColor = MaterialTheme.colors.surface)
|
Content(bitmap, icon, modifier = modifier, backgroundColor = MaterialTheme.colors.surface)
|
||||||
} else {
|
} else {
|
||||||
Card(
|
Card(
|
||||||
|
@ -19,9 +19,10 @@ import androidx.compose.ui.tooling.preview.PreviewParameter
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.thoughtcrime.securesms.ui.LocalButtonColor
|
import org.thoughtcrime.securesms.ui.LocalColors
|
||||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||||
import org.thoughtcrime.securesms.ui.ThemeResPreviewParameterProvider
|
import org.thoughtcrime.securesms.ui.SessionColors
|
||||||
|
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||||
import org.thoughtcrime.securesms.ui.h8
|
import org.thoughtcrime.securesms.ui.h8
|
||||||
|
|
||||||
private val TITLES = listOf(R.string.sessionRecoveryPassword, R.string.qrScan)
|
private val TITLES = listOf(R.string.sessionRecoveryPassword, R.string.qrScan)
|
||||||
@ -32,8 +33,8 @@ fun SessionTabRow(pagerState: PagerState, titles: List<Int>) {
|
|||||||
TabRow(
|
TabRow(
|
||||||
backgroundColor = Color.Unspecified,
|
backgroundColor = Color.Unspecified,
|
||||||
selectedTabIndex = pagerState.currentPage,
|
selectedTabIndex = pagerState.currentPage,
|
||||||
contentColor = LocalButtonColor.current,
|
contentColor = LocalColors.current.primary,
|
||||||
divider = { TabRowDefaults.Divider(color = MaterialTheme.colors.onPrimary.copy(alpha = TabRowDefaults.DividerOpacity)) },
|
divider = { TabRowDefaults.Divider(color = LocalColors.current.divider) },
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.height(48.dp)
|
.height(48.dp)
|
||||||
.background(color = Color.Unspecified)
|
.background(color = Color.Unspecified)
|
||||||
@ -43,8 +44,8 @@ fun SessionTabRow(pagerState: PagerState, titles: List<Int>) {
|
|||||||
Tab(
|
Tab(
|
||||||
i == pagerState.currentPage,
|
i == pagerState.currentPage,
|
||||||
onClick = { animationScope.launch { pagerState.animateScrollToPage(i) } },
|
onClick = { animationScope.launch { pagerState.animateScrollToPage(i) } },
|
||||||
selectedContentColor = MaterialTheme.colors.onPrimary,
|
selectedContentColor = LocalColors.current.text,
|
||||||
unselectedContentColor = MaterialTheme.colors.onPrimary,
|
unselectedContentColor = LocalColors.current.text,
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
stringResource(id = it),
|
stringResource(id = it),
|
||||||
@ -59,9 +60,9 @@ fun SessionTabRow(pagerState: PagerState, titles: List<Int>) {
|
|||||||
@androidx.compose.ui.tooling.preview.Preview
|
@androidx.compose.ui.tooling.preview.Preview
|
||||||
@Composable
|
@Composable
|
||||||
fun PreviewSessionTabRow(
|
fun PreviewSessionTabRow(
|
||||||
@PreviewParameter(ThemeResPreviewParameterProvider::class) themeResId: Int
|
@PreviewParameter(SessionColorsParameterProvider::class) sessionColors: SessionColors
|
||||||
) {
|
) {
|
||||||
PreviewTheme(themeResId) {
|
PreviewTheme(sessionColors) {
|
||||||
val pagerState = rememberPagerState { TITLES.size }
|
val pagerState = rememberPagerState { TITLES.size }
|
||||||
SessionTabRow(pagerState = pagerState, titles = TITLES)
|
SessionTabRow(pagerState = pagerState, titles = TITLES)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import androidx.annotation.DrawableRes
|
|||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
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.width
|
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.foundation.text.InlineTextContent
|
import androidx.compose.foundation.text.InlineTextContent
|
||||||
import androidx.compose.foundation.text.KeyboardActions
|
import androidx.compose.foundation.text.KeyboardActions
|
||||||
@ -16,17 +15,16 @@ import androidx.compose.material.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.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.text.Placeholder
|
import androidx.compose.ui.text.Placeholder
|
||||||
import androidx.compose.ui.text.PlaceholderVerticalAlign
|
import androidx.compose.ui.text.PlaceholderVerticalAlign
|
||||||
import androidx.compose.ui.text.TextStyle
|
import androidx.compose.ui.text.TextStyle
|
||||||
import androidx.compose.ui.text.buildAnnotatedString
|
import androidx.compose.ui.text.buildAnnotatedString
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.Dp
|
|
||||||
import androidx.compose.ui.unit.TextUnit
|
import androidx.compose.ui.unit.TextUnit
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
|
import org.thoughtcrime.securesms.ui.LocalColors
|
||||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||||
import org.thoughtcrime.securesms.ui.base
|
import org.thoughtcrime.securesms.ui.base
|
||||||
import org.thoughtcrime.securesms.ui.baseBold
|
import org.thoughtcrime.securesms.ui.baseBold
|
||||||
@ -70,41 +68,12 @@ fun SessionOutlinedTextField(
|
|||||||
modifier = Modifier.padding(top = LocalDimensions.current.marginExtraExtraSmall),
|
modifier = Modifier.padding(top = LocalDimensions.current.marginExtraExtraSmall),
|
||||||
textAlign = TextAlign.Center,
|
textAlign = TextAlign.Center,
|
||||||
style = MaterialTheme.typography.baseBold,
|
style = MaterialTheme.typography.baseBold,
|
||||||
color = MaterialTheme.colors.error
|
color = LocalColors.current.danger
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun AnnotatedTextWithIcon(
|
|
||||||
text: String,
|
|
||||||
icon: ImageVector,
|
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
style: TextStyle = MaterialTheme.typography.base
|
|
||||||
) {
|
|
||||||
val myId = "inlineContent"
|
|
||||||
val annotatedText = buildAnnotatedString {
|
|
||||||
append(text)
|
|
||||||
appendInlineContent(myId, "[icon]")
|
|
||||||
}
|
|
||||||
|
|
||||||
val inlineContent = mapOf(
|
|
||||||
myId to Placeholder(
|
|
||||||
width = TextUnit.Unspecified,
|
|
||||||
height = TextUnit.Unspecified,
|
|
||||||
placeholderVerticalAlign = PlaceholderVerticalAlign.AboveBaseline
|
|
||||||
).let { InlineTextContent(it) { Icon(icon, contentDescription = null) } }
|
|
||||||
)
|
|
||||||
|
|
||||||
Text(
|
|
||||||
text = annotatedText,
|
|
||||||
modifier = modifier,
|
|
||||||
inlineContent = inlineContent,
|
|
||||||
style = style
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AnnotatedTextWithIcon(
|
fun AnnotatedTextWithIcon(
|
||||||
text: String,
|
text: String,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user