Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.flipcash.app.currency.internal.components.RegionList
import com.flipcash.app.currency.internal.components.SearchBar
import com.flipcash.features.currency.R
import com.getcode.navigation.core.LocalCodeNavigator
import com.getcode.theme.CodeTheme
import com.getcode.ui.components.SearchInput
import com.getcode.ui.core.rememberAnimationScale
import com.getcode.ui.core.scaled
import com.getcode.ui.utils.rememberKeyboardController
Expand Down Expand Up @@ -51,10 +53,11 @@ internal fun RegionSelectionModalContent(viewModel: CurrencyViewModel) {
snapshotFlow { state.searchState.text }
.launchIn(this)
}
SearchBar(
SearchInput(
modifier = Modifier.padding(top = CodeTheme.dimens.grid.x3),
state = state.searchState,
contentPadding = PaddingValues(start = CodeTheme.dimens.grid.x1),
placeholder = stringResource(R.string.subtitle_searchRegions)
)

RegionList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@ import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewWrapper
import androidx.compose.ui.tooling.preview.PreviewWrapperProvider
import com.getcode.animation.LocalSharedTransitionScope
import com.flipcash.app.theme.internal.Flipcash2DesignSystem
import com.flipcash.app.theme.internal.FlipcashLegacyDesignSystem
import com.getcode.theme.CodeTheme

@Deprecated("Use FlipcashThemeWrapper")
@Composable
fun FlipcashPreview(
showBackground: Boolean = false,
useLegacyColors: Boolean = false,
content: @Composable () -> Unit
) {
val previewContent = @Composable {
Expand All @@ -39,11 +36,7 @@ fun FlipcashPreview(
}
}

if (useLegacyColors) {
FlipcashLegacyDesignSystem(previewContent)
} else {
Flipcash2DesignSystem(previewContent)
}
Flipcash2DesignSystem(previewContent)
}

class FlipcashThemeWrapper: PreviewWrapperProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@ package com.flipcash.app.theme

import androidx.compose.runtime.Composable
import com.flipcash.app.theme.internal.Flipcash2DesignSystem
import com.flipcash.app.theme.internal.FlipcashLegacyDesignSystem

@Composable
fun FlipcashTheme(
useLegacyColors: Boolean = false,
content: @Composable () -> Unit,
) {
if (useLegacyColors) {
FlipcashLegacyDesignSystem(content)
} else {
Flipcash2DesignSystem(content)
}
Flipcash2DesignSystem(content)
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ object Flipcash2ColorSpec {
borderColor = null,
borderWidth = 0f,
)
val contactAvatar = GradientSpec(
background = Color.Black,
colors = listOf(
Color(0xFF414141),
Color(0xFF202020)
),
stops = listOf(0f, 1f)
)
}

private val colors = with(Flipcash2ColorSpec) {
Expand Down Expand Up @@ -94,7 +102,8 @@ private val colors = with(Flipcash2ColorSpec) {
bannerWarning = Warning,
bannerSuccess = BannerSuccess,
scrim = Black40,
accessKey = accessKey
accessKey = accessKey,
contactAvatar = contactAvatar,
)
}
@Composable
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.flipcash.app.currency.internal.components
package com.getcode.ui.components

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.text.input.TextFieldState
import androidx.compose.foundation.text.input.clearText
import androidx.compose.material.Icon
Expand All @@ -12,16 +13,15 @@ import androidx.compose.material.icons.outlined.Close
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import com.flipcash.features.currency.R
import com.getcode.theme.CodeTheme
import com.getcode.theme.White50
import com.getcode.ui.components.TextInput

@Composable
internal fun SearchBar(
fun SearchInput(
state: TextFieldState,
modifier: Modifier = Modifier,
contentPadding: PaddingValues = PaddingValues(),
placeholder: String = stringResource(R.string.action_search),
) {
TextInput(
modifier = modifier
Expand All @@ -30,13 +30,13 @@ internal fun SearchBar(
contentPadding = contentPadding,
leadingIcon = {
Icon(
modifier = Modifier.padding(start = CodeTheme.dimens.grid.x1),
modifier = Modifier.padding(start = CodeTheme.dimens.grid.x3),
imageVector = Icons.Filled.Search,
contentDescription = null,
tint = White50,
tint = CodeTheme.colors.textMain,
)
},
placeholder = stringResource(id = R.string.subtitle_searchRegions),
placeholder = placeholder,
placeholderStyle = CodeTheme.typography.textMedium,
trailingIcon = {
if (state.text.isNotEmpty()) {
Expand All @@ -55,6 +55,6 @@ internal fun SearchBar(
},
maxLines = 1,
style = CodeTheme.typography.textMedium,
shape = CodeTheme.shapes.small
shape = CircleShape,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,12 @@ private fun <S : FlowStep, R : Parcelable> FlowHostImpl(
// We track what was seeded and only re-seed if the backstack is still untouched.
// Animation is suppressed during re-seed so NavDisplay doesn't slide between
// the stale and corrected content.
val seededStack = remember { initialStack.map { it::class } }
val currentInitialClasses = initialStack.map { it::class }
val seededStack = rememberSaveable { initialStack.map { it::class.qualifiedName } }
val currentInitialClasses = initialStack.map { it::class.qualifiedName }
val suppressTransition = remember { mutableStateOf(false) }
LaunchedEffect(currentInitialClasses) {
if (currentInitialClasses == seededStack) return@LaunchedEffect
val backstackClasses = innerBackStack.map { it::class }
val backstackClasses = innerBackStack.map { it::class.qualifiedName }
if (backstackClasses != seededStack) return@LaunchedEffect
suppressTransition.value = true
Snapshot.withMutableSnapshot {
Expand Down
9 changes: 9 additions & 0 deletions ui/theme/src/main/kotlin/com/getcode/theme/Color.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ val CodeAccessKey = GradientSpec(
stops = listOf(0f, 0.3f, 0.6f, 1f)
)

val CodeContactAvatar = GradientSpec(
background = Brand,
colors = listOf(
Color(0xFF4A5568),
Color(0xFF6B7A90),
),
stops = listOf(0f, 1f)
)

data class GradientSpec(
val background: Color,
val colors: List<Color>,
Expand Down
8 changes: 7 additions & 1 deletion ui/theme/src/main/kotlin/com/getcode/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ internal val CodeDefaultColorScheme = ColorScheme(
bannerSuccess = BannerSuccess,
scrim = Black40,
accessKey = CodeAccessKey,
contactAvatar = CodeContactAvatar,
)

@Composable
Expand Down Expand Up @@ -148,6 +149,7 @@ class ColorScheme(
bannerSuccess: Color,
scrim: Color,
accessKey: GradientSpec,
contactAvatar: GradientSpec,
) {
var brand by mutableStateOf(brand)
private set
Expand Down Expand Up @@ -230,6 +232,8 @@ class ColorScheme(

var accessKey by mutableStateOf(accessKey)
private set
var contactAvatar by mutableStateOf(contactAvatar)
private set


fun update(other: ColorScheme) {
Expand Down Expand Up @@ -272,6 +276,7 @@ class ColorScheme(
bannerSuccess = other.bannerSuccess
scrim = other.scrim
accessKey = other.accessKey
contactAvatar = other.contactAvatar
}

fun copy(): ColorScheme = ColorScheme(
Expand Down Expand Up @@ -314,6 +319,7 @@ class ColorScheme(
bannerSuccess = bannerSuccess,
scrim = scrim,
accessKey = accessKey,
contactAvatar = contactAvatar,
)
}

Expand Down Expand Up @@ -361,7 +367,7 @@ fun inputColors(
borderColor: Color = CodeTheme.colors.border,
unfocusedBorderColor: Color = borderColor,
backgroundColor: Color = White05,
placeholderColor: Color = CodeTheme.colors.textTertiary,
placeholderColor: Color = CodeTheme.colors.textSecondary,
cursorColor: Color = Color.White,
errorBorderColor: Color = CodeTheme.colors.error,
) = TextFieldDefaults.outlinedTextFieldColors(
Expand Down
Loading