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