Skip to content

Commit

Permalink
Move PaymentsTheme to ui-core and rename to StripeTheme (#6052)
Browse files Browse the repository at this point in the history
* [skip ci] Start PR

* Move theme to stripe-ui-core.

* Detekt fixes.

* Regenerates baseline.

* Regenerates API.
  • Loading branch information
carlosmuvi-stripe committed Jan 18, 2023
1 parent 78c10dd commit 08806f7
Show file tree
Hide file tree
Showing 60 changed files with 303 additions and 304 deletions.
18 changes: 9 additions & 9 deletions link/src/main/java/com/stripe/android/link/theme/Color.kt
Expand Up @@ -6,9 +6,9 @@ import androidx.compose.material.darkColors
import androidx.compose.material.lightColors
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import com.stripe.android.ui.core.PaymentsTheme
import com.stripe.android.ui.core.PaymentsThemeDefaults
import com.stripe.android.ui.core.elements.OTPElementColors
import com.stripe.android.uicore.StripeTheme
import com.stripe.android.uicore.StripeThemeDefaults

private val LinkTeal = Color(0xFF33DDB3)
private val ActionLightGreen = Color(0xFF1AC59B)
Expand Down Expand Up @@ -69,21 +69,21 @@ internal data class LinkColors(
)

@Composable
internal fun PaymentsThemeForLink(
internal fun StripeThemeForLink(
content: @Composable () -> Unit
) {
val paymentsColors = PaymentsThemeDefaults.colors(isSystemInDarkTheme())
val stripeDefaultColors = StripeThemeDefaults.colors(isSystemInDarkTheme())

PaymentsTheme(
colors = paymentsColors.copy(
materialColors = paymentsColors.materialColors.copy(
StripeTheme(
colors = stripeDefaultColors.copy(
materialColors = stripeDefaultColors.materialColors.copy(
primary = ActionGreen
)
),
shapes = PaymentsThemeDefaults.shapes.copy(
shapes = StripeThemeDefaults.shapes.copy(
cornerRadius = 9f
),
typography = PaymentsThemeDefaults.typography
typography = StripeThemeDefaults.typography
) {
content()
}
Expand Down
4 changes: 2 additions & 2 deletions link/src/main/java/com/stripe/android/link/ui/LinkTerms.kt
Expand Up @@ -8,7 +8,7 @@ import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import com.stripe.android.link.R
import com.stripe.android.ui.core.paymentsColors
import com.stripe.android.uicore.stripeColors
import com.stripe.android.uicore.text.Html

@Preview
Expand All @@ -19,7 +19,7 @@ internal fun LinkTerms(
) {
Html(
html = stringResource(R.string.sign_up_terms).replaceHyperlinks(),
color = MaterialTheme.paymentsColors.placeholderText,
color = MaterialTheme.stripeColors.placeholderText,
style = MaterialTheme.typography.subtitle1,
modifier = modifier,
urlSpanStyle = SpanStyle(
Expand Down
Expand Up @@ -27,7 +27,7 @@ import com.stripe.android.core.injection.NonFallbackInjector
import com.stripe.android.link.R
import com.stripe.android.link.model.LinkAccount
import com.stripe.android.link.theme.DefaultLinkTheme
import com.stripe.android.link.theme.PaymentsThemeForLink
import com.stripe.android.link.theme.StripeThemeForLink
import com.stripe.android.link.ui.ErrorMessage
import com.stripe.android.link.ui.ErrorText
import com.stripe.android.link.ui.PrimaryButton
Expand Down Expand Up @@ -134,7 +134,7 @@ internal fun CardEditBody(
style = MaterialTheme.typography.h2,
color = MaterialTheme.colors.onPrimary
)
PaymentsThemeForLink {
StripeThemeForLink {
formContent()

Spacer(modifier = Modifier.height(8.dp))
Expand Down
Expand Up @@ -25,9 +25,9 @@ import androidx.lifecycle.viewmodel.compose.viewModel
import com.stripe.android.link.LinkPaymentLauncher
import com.stripe.android.link.R
import com.stripe.android.link.theme.linkShapes
import com.stripe.android.ui.core.PaymentsTheme
import com.stripe.android.ui.core.getBorderStroke
import com.stripe.android.ui.core.paymentsColors
import com.stripe.android.uicore.StripeTheme
import com.stripe.android.uicore.getBorderStroke
import com.stripe.android.uicore.stripeColors

@Composable
fun LinkInlineSignedIn(
Expand All @@ -42,15 +42,15 @@ fun LinkInlineSignedIn(

val accountEmail = viewModel.accountEmail.collectAsState(initial = "")

PaymentsTheme {
StripeTheme {
Box(
modifier = modifier
.border(
border = MaterialTheme.getBorderStroke(isSelected = false),
shape = MaterialTheme.linkShapes.small
)
.background(
color = MaterialTheme.paymentsColors.component,
color = MaterialTheme.stripeColors.component,
shape = MaterialTheme.linkShapes.small
)
.semantics {
Expand All @@ -67,7 +67,7 @@ fun LinkInlineSignedIn(
modifier = Modifier.padding(bottom = 16.dp)
)
Divider(
color = MaterialTheme.paymentsColors.componentBorder.copy(alpha = 0.1f),
color = MaterialTheme.stripeColors.componentBorder.copy(alpha = 0.1f),
modifier = Modifier.padding(bottom = 16.dp)
)
Row(
Expand All @@ -76,7 +76,7 @@ fun LinkInlineSignedIn(
) {
Text(
text = accountEmail.value ?: "",
color = MaterialTheme.paymentsColors.subtitle
color = MaterialTheme.stripeColors.subtitle
)
ClickableText(
text = AnnotatedString(text = stringResource(id = R.string.logout)),
Expand Down
Expand Up @@ -50,15 +50,15 @@ import com.stripe.android.link.ui.ErrorText
import com.stripe.android.link.ui.LinkTerms
import com.stripe.android.link.ui.signup.EmailCollectionSection
import com.stripe.android.link.ui.signup.SignUpState
import com.stripe.android.ui.core.PaymentsTheme
import com.stripe.android.ui.core.elements.PhoneNumberCollectionSection
import com.stripe.android.ui.core.elements.SimpleTextFieldController
import com.stripe.android.ui.core.elements.TextFieldController
import com.stripe.android.ui.core.elements.TextFieldSection
import com.stripe.android.ui.core.elements.menu.Checkbox
import com.stripe.android.ui.core.getBorderStroke
import com.stripe.android.ui.core.paymentsColors
import com.stripe.android.uicore.StripeTheme
import com.stripe.android.uicore.elements.PhoneNumberController
import com.stripe.android.uicore.getBorderStroke
import com.stripe.android.uicore.stripeColors

@Preview
@Composable
Expand Down Expand Up @@ -152,15 +152,15 @@ internal fun LinkInlineSignup(
CompositionLocalProvider(
LocalContentAlpha provides if (enabled) ContentAlpha.high else ContentAlpha.disabled
) {
PaymentsTheme {
StripeTheme {
Box(
modifier = modifier
.border(
border = MaterialTheme.getBorderStroke(isSelected = false),
shape = MaterialTheme.linkShapes.small
)
.background(
color = MaterialTheme.paymentsColors.component,
color = MaterialTheme.stripeColors.component,
shape = MaterialTheme.linkShapes.small
)
) {
Expand Down Expand Up @@ -207,7 +207,7 @@ internal fun LinkInlineSignup(
Column {
Divider(
color =
MaterialTheme.paymentsColors.componentBorder.copy(alpha = 0.1f)
MaterialTheme.stripeColors.componentBorder.copy(alpha = 0.1f)
)
Column(
modifier = Modifier
Expand Down Expand Up @@ -275,7 +275,7 @@ internal fun LinkInlineSignup(
}
Divider(
color =
MaterialTheme.paymentsColors.componentBorder.copy(alpha = 0.1f)
MaterialTheme.stripeColors.componentBorder.copy(alpha = 0.1f)
)
Row(modifier = Modifier.padding(16.dp)) {
Icon(
Expand Down
Expand Up @@ -44,7 +44,7 @@ import com.stripe.android.financialconnections.launcher.FinancialConnectionsShee
import com.stripe.android.link.R
import com.stripe.android.link.model.LinkAccount
import com.stripe.android.link.theme.DefaultLinkTheme
import com.stripe.android.link.theme.PaymentsThemeForLink
import com.stripe.android.link.theme.StripeThemeForLink
import com.stripe.android.link.theme.linkColors
import com.stripe.android.link.theme.linkShapes
import com.stripe.android.link.ui.ErrorMessage
Expand Down Expand Up @@ -193,7 +193,7 @@ internal fun PaymentMethodBody(
}
if (selectedPaymentMethod.showsForm) {
Spacer(modifier = Modifier.height(4.dp))
PaymentsThemeForLink {
StripeThemeForLink {
formContent()
}
Spacer(modifier = Modifier.height(8.dp))
Expand Down
Expand Up @@ -32,7 +32,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel
import com.stripe.android.core.injection.NonFallbackInjector
import com.stripe.android.link.R
import com.stripe.android.link.theme.DefaultLinkTheme
import com.stripe.android.link.theme.PaymentsThemeForLink
import com.stripe.android.link.theme.StripeThemeForLink
import com.stripe.android.link.theme.linkColors
import com.stripe.android.link.ui.ErrorMessage
import com.stripe.android.link.ui.ErrorText
Expand Down Expand Up @@ -125,7 +125,7 @@ internal fun SignUpBody(
style = MaterialTheme.typography.body1,
color = MaterialTheme.colors.onSecondary
)
PaymentsThemeForLink {
StripeThemeForLink {
EmailCollectionSection(
enabled = true,
emailController = emailController,
Expand All @@ -143,7 +143,7 @@ internal fun SignUpBody(
}
AnimatedVisibility(visible = signUpState == SignUpState.InputtingPhoneOrName) {
Column(modifier = Modifier.fillMaxWidth()) {
PaymentsThemeForLink {
StripeThemeForLink {
PhoneNumberCollectionSection(
enabled = true,
phoneNumberController = phoneNumberController,
Expand Down
Expand Up @@ -46,10 +46,10 @@ import com.stripe.android.link.theme.linkShapes
import com.stripe.android.link.ui.ErrorMessage
import com.stripe.android.link.ui.ErrorText
import com.stripe.android.link.ui.ScrollableTopLevelColumn
import com.stripe.android.ui.core.DefaultPaymentsTheme
import com.stripe.android.ui.core.elements.OTPElement
import com.stripe.android.ui.core.elements.OTPElementUI
import com.stripe.android.ui.core.elements.OTPSpec
import com.stripe.android.uicore.DefaultStripeTheme
import kotlinx.coroutines.delay

@Preview
Expand Down Expand Up @@ -196,7 +196,7 @@ internal fun VerificationBody(
style = MaterialTheme.typography.body1,
color = MaterialTheme.colors.onSecondary
)
DefaultPaymentsTheme {
DefaultStripeTheme {
OTPElementUI(
enabled = !isProcessing,
element = otpElement,
Expand Down
Expand Up @@ -47,7 +47,7 @@ import com.stripe.android.link.R
import com.stripe.android.link.model.LinkAccount
import com.stripe.android.link.theme.DefaultLinkTheme
import com.stripe.android.link.theme.HorizontalPadding
import com.stripe.android.link.theme.PaymentsThemeForLink
import com.stripe.android.link.theme.StripeThemeForLink
import com.stripe.android.link.theme.linkColors
import com.stripe.android.link.theme.linkShapes
import com.stripe.android.link.ui.BottomSheetContent
Expand Down Expand Up @@ -379,7 +379,7 @@ internal fun CardDetailsRecollectionForm(
R.string.wallet_recollect_cvc_error
}

PaymentsThemeForLink {
StripeThemeForLink {
Column(modifier) {
ErrorText(
text = stringResource(errorTextResId),
Expand Down
Expand Up @@ -10,8 +10,8 @@ import com.stripe.android.paymentmethodmessaging.view.PaymentMethodMessageMapper
import com.stripe.android.paymentmethodmessaging.view.PaymentMethodMessagingData
import com.stripe.android.paymentmethodmessaging.view.PaymentMethodMessagingView
import com.stripe.android.payments.core.injection.PRODUCT_USAGE
import com.stripe.android.ui.core.isSystemDarkTheme
import com.stripe.android.uicore.image.StripeImageLoader
import com.stripe.android.uicore.isSystemDarkTheme
import dagger.Module
import dagger.Provides
import kotlinx.coroutines.CoroutineScope
Expand Down
9 changes: 0 additions & 9 deletions payments-ui-core/api/payments-ui-core.api
Expand Up @@ -37,15 +37,6 @@ public final class com/stripe/android/ui/core/FieldValuesToParamsMapConverter$Co
public final class com/stripe/android/ui/core/FormUIKt {
}

public final class com/stripe/android/ui/core/PaymentsThemeKt {
public static final fun getBorderStroke (Landroidx/compose/material/MaterialTheme;ZLandroidx/compose/runtime/Composer;I)Landroidx/compose/foundation/BorderStroke;
public static final fun getLocalColors ()Landroidx/compose/runtime/ProvidableCompositionLocal;
public static final fun getLocalShapes ()Landroidx/compose/runtime/ProvidableCompositionLocal;
public static final fun getLocalTypography ()Landroidx/compose/runtime/ProvidableCompositionLocal;
public static final fun getPaymentsColors (Landroidx/compose/material/MaterialTheme;Landroidx/compose/runtime/Composer;I)Lcom/stripe/android/ui/core/PaymentsColors;
public static final fun getPaymentsShapes (Landroidx/compose/material/MaterialTheme;Landroidx/compose/runtime/Composer;I)Lcom/stripe/android/ui/core/PaymentsShapes;
}

public final class com/stripe/android/ui/core/address/AddressRepository$Companion {
}

Expand Down
8 changes: 1 addition & 7 deletions payments-ui-core/detekt-baseline.xml
Expand Up @@ -20,7 +20,7 @@
<ID>LongMethod:DropdownFieldUI.kt$@Composable internal fun DropDown( controller: DropdownFieldController, enabled: Boolean, modifier: Modifier = Modifier )</ID>
<ID>LongMethod:LpmRepository.kt$LpmRepository$private fun convertToSupportedPaymentMethod( @Suppress("UNUSED_PARAMETER") stripeIntent: StripeIntent, sharedDataSpec: SharedDataSpec, )</ID>
<ID>LongMethod:Menu.kt$@Suppress("ModifierParameter") @Composable internal fun DropdownMenuContent( expandedStates: MutableTransitionState&lt;Boolean>, transformOriginState: MutableState&lt;TransformOrigin>, initialFirstVisibleItemIndex: Int, modifier: Modifier = Modifier, content: LazyListScope.() -> Unit )</ID>
<ID>LongMethod:OTPElementUI.kt$@OptIn(ExperimentalMaterialApi::class) @Composable @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun OTPElementUI( enabled: Boolean, element: OTPElement, modifier: Modifier = Modifier, colors: OTPElementColors = OTPElementColors( selectedBorder = MaterialTheme.colors.primary, placeholder = MaterialTheme.paymentsColors.placeholderText ), focusRequester: FocusRequester = remember { FocusRequester() } )</ID>
<ID>LongMethod:OTPElementUI.kt$@OptIn(ExperimentalMaterialApi::class) @Composable @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun OTPElementUI( enabled: Boolean, element: OTPElement, modifier: Modifier = Modifier, colors: OTPElementColors = OTPElementColors( selectedBorder = MaterialTheme.colors.primary, placeholder = MaterialTheme.stripeColors.placeholderText ), focusRequester: FocusRequester = remember { FocusRequester() } )</ID>
<ID>LongMethod:PhoneNumberElementUI.kt$@Composable internal fun PhoneNumberElementUI( enabled: Boolean, controller: PhoneNumberController, requestFocusWhenShown: Boolean = false, imeAction: ImeAction = ImeAction.Done )</ID>
<ID>LongMethod:SectionFieldElementUI.kt$@Composable internal fun SectionFieldElementUI( enabled: Boolean, field: SectionFieldElement, modifier: Modifier = Modifier, hiddenIdentifiers: Set&lt;IdentifierSpec> = emptySet(), lastTextFieldIdentifier: IdentifierSpec?, nextFocusDirection: FocusDirection = FocusDirection.Down, previousFocusDirection: FocusDirection = FocusDirection.Up )</ID>
<ID>LongMethod:TextFieldUI.kt$@Composable fun TextField( textFieldController: TextFieldController, enabled: Boolean, imeAction: ImeAction, modifier: Modifier = Modifier, onTextStateChanged: (TextFieldState?) -> Unit = {}, nextFocusDirection: FocusDirection = FocusDirection.Next, previousFocusDirection: FocusDirection = FocusDirection.Previous )</ID>
Expand Down Expand Up @@ -49,8 +49,6 @@
<ID>MagicNumber:CardNumberVisualTransformation.kt$CardNumberVisualTransformation.&lt;no name provided>$4</ID>
<ID>MagicNumber:CardNumberVisualTransformation.kt$CardNumberVisualTransformation.&lt;no name provided>$7</ID>
<ID>MagicNumber:CardNumberVisualTransformation.kt$CardNumberVisualTransformation.&lt;no name provided>$9</ID>
<ID>MagicNumber:CountryConfig.kt$CountryConfig.Companion$0x1F1E6</ID>
<ID>MagicNumber:CountryConfig.kt$CountryConfig.Companion$0x41</ID>
<ID>MagicNumber:DateConfig.kt$DateConfig$4</ID>
<ID>MagicNumber:DateConfig.kt$DateConfig.Companion$100</ID>
<ID>MagicNumber:DateConfig.kt$DateConfig.Companion$12</ID>
Expand All @@ -62,9 +60,6 @@
<ID>MagicNumber:IbanConfig.kt$IbanConfig$4</ID>
<ID>MagicNumber:LpmRepository.kt$LpmRepository$20</ID>
<ID>MagicNumber:Menu.kt$0.8f</ID>
<ID>MagicNumber:PaymentsTheme.kt$0.15</ID>
<ID>MagicNumber:PaymentsTheme.kt$0.32</ID>
<ID>MagicNumber:PaymentsTheme.kt$3</ID>
<ID>MagicNumber:PostalCodeVisualTransformation.kt$PostalCodeVisualTransformation.&lt;no name provided>$3</ID>
<ID>MagicNumber:PostalCodeVisualTransformation.kt$PostalCodeVisualTransformation.&lt;no name provided>$5</ID>
<ID>MagicNumber:PostalCodeVisualTransformation.kt$PostalCodeVisualTransformation.&lt;no name provided>$6</ID>
Expand Down Expand Up @@ -103,7 +98,6 @@
<ID>ThrowingExceptionsWithoutMessageOrCause:TransformAddressToElement.kt$IllegalArgumentException()</ID>
<ID>TooGenericExceptionCaught:LpmSerializer.kt$LpmSerializer$e: Exception</ID>
<ID>TooGenericExceptionCaught:PlacesClientProxy.kt$DefaultPlacesClientProxy$e: Exception</ID>
<ID>TooManyFunctions:PaymentsTheme.kt$com.stripe.android.ui.core.PaymentsTheme.kt</ID>
<ID>UnnecessaryAbstractClass:FormControllerModule.kt$FormControllerModule$FormControllerModule</ID>
<ID>UnnecessaryAbstractClass:ResourceRepositoryModule.kt$ResourceRepositoryModule$ResourceRepositoryModule</ID>
<ID>UtilityClassWithPublicConstructor:FieldValuesToParamsMapConverter.kt$FieldValuesToParamsMapConverter</ID>
Expand Down
Expand Up @@ -9,8 +9,8 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.stripe.android.ui.core.paymentsColors
import com.stripe.android.ui.core.paymentsShapes
import com.stripe.android.uicore.stripeColors
import com.stripe.android.uicore.stripeShapes

@Composable
internal fun AddressElementUI(
Expand All @@ -34,10 +34,10 @@ internal fun AddressElementUI(
)
if (index != fieldList.lastIndex) {
Divider(
color = MaterialTheme.paymentsColors.componentDivider,
thickness = MaterialTheme.paymentsShapes.borderStrokeWidth.dp,
color = MaterialTheme.stripeColors.componentDivider,
thickness = MaterialTheme.stripeShapes.borderStrokeWidth.dp,
modifier = Modifier.padding(
horizontal = MaterialTheme.paymentsShapes.borderStrokeWidth.dp
horizontal = MaterialTheme.stripeShapes.borderStrokeWidth.dp
)
)
}
Expand Down
Expand Up @@ -8,7 +8,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.stripe.android.ui.core.R
import com.stripe.android.ui.core.paymentsColors
import com.stripe.android.uicore.stripeColors
import com.stripe.android.uicore.text.EmbeddableImage
import com.stripe.android.uicore.text.Html

Expand All @@ -23,7 +23,7 @@ fun AffirmElementUI() {
R.string.stripe_paymentsheet_payment_method_affirm
)
),
color = MaterialTheme.paymentsColors.subtitle,
color = MaterialTheme.stripeColors.subtitle,
style = MaterialTheme.typography.h6,
modifier = Modifier.padding(vertical = 8.dp)
)
Expand Down

0 comments on commit 08806f7

Please sign in to comment.