-
Notifications
You must be signed in to change notification settings - Fork 665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support showing institution picker first #10397
Draft
tillh-stripe
wants to merge
2
commits into
master
Choose a base branch
from
tillh/institution-picker-first
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import FinancialConnectionsGenericInfoScreen.Footer | |
import FinancialConnectionsGenericInfoScreen.Header | ||
import Size | ||
import android.util.Log | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
|
@@ -22,17 +23,21 @@ import androidx.compose.material.Text | |
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.draw.shadow | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.tooling.preview.PreviewParameter | ||
import androidx.compose.ui.unit.dp | ||
import com.stripe.android.financialconnections.features.common.IconSize | ||
import com.stripe.android.financialconnections.features.common.ListItem | ||
import com.stripe.android.financialconnections.features.common.ShapedIcon | ||
import com.stripe.android.financialconnections.ui.FinancialConnectionsPreview | ||
import com.stripe.android.financialconnections.ui.LocalImageLoader | ||
import com.stripe.android.financialconnections.ui.TextResource | ||
import com.stripe.android.financialconnections.ui.components.AnnotatedText | ||
import com.stripe.android.financialconnections.ui.components.FinancialConnectionsButton | ||
import com.stripe.android.financialconnections.ui.sdui.BulletUI | ||
import com.stripe.android.financialconnections.ui.sdui.fromHtml | ||
import com.stripe.android.financialconnections.ui.theme.FinancialConnectionsTheme.colors | ||
import com.stripe.android.financialconnections.ui.theme.FinancialConnectionsTheme.typography | ||
|
@@ -133,6 +138,23 @@ internal fun GenericBody( | |
modifier = Modifier.padding(horizontal = 24.dp), | ||
) | ||
} | ||
is Body.Entry.Bullets -> { | ||
val bullets = remember(entry.bullets) { | ||
entry.bullets.map(BulletUI::from) | ||
} | ||
|
||
Column( | ||
modifier = Modifier.padding(horizontal = 24.dp), | ||
) { | ||
bullets.forEach { bullet -> | ||
ListItem( | ||
bullet = bullet, | ||
onClickableTextClick = onClickableTextClick | ||
) | ||
Spacer(modifier = Modifier.size(24.dp)) | ||
} | ||
} | ||
} | ||
else -> { | ||
Log.e("GenericBody", "Unsupported entry type: $entry") | ||
} | ||
|
@@ -148,16 +170,29 @@ internal fun GenericHeader( | |
onClickableTextClick: (String) -> Unit, | ||
modifier: Modifier = Modifier, | ||
) { | ||
val isBrandIcon: Boolean = | ||
remember(payload.icon?.default) { payload.icon?.default?.contains("BrandIcon") == true } | ||
val isBrandIcon: Boolean = remember(payload.icon?.default) { | ||
payload.icon?.default?.contains("BrandIcon") == true | ||
} | ||
|
||
Column( | ||
modifier = modifier.fillMaxWidth(), | ||
verticalArrangement = Arrangement.spacedBy(20.dp), | ||
) { | ||
val iconShape = if (isBrandIcon) RoundedCornerShape(12.dp) else CircleShape | ||
|
||
val iconModifier = if (isBrandIcon) { | ||
Modifier | ||
.shadow(8.dp, iconShape) | ||
.clip(iconShape) | ||
.background(color = colors.backgroundSecondary, shape = iconShape) | ||
} else { | ||
Modifier | ||
} | ||
|
||
payload.icon?.default?.let { iconUrl -> | ||
ShapedIcon( | ||
modifier = Modifier.align(payload.alignment.toComposeAlignment()), | ||
backgroundShape = if (isBrandIcon) RoundedCornerShape(12.dp) else CircleShape, | ||
modifier = iconModifier.align(payload.alignment.toComposeAlignment()), | ||
backgroundShape = iconShape, | ||
flushed = isBrandIcon, | ||
url = iconUrl, | ||
contentDescription = null, | ||
|
@@ -210,7 +245,7 @@ internal fun GenericFooter( | |
onClickableTextClick = onClickableTextClick, | ||
defaultStyle = typography.labelSmall.copy( | ||
color = colors.textDefault, | ||
textAlign = TextAlign.Start, | ||
textAlign = TextAlign.Center, | ||
), | ||
) | ||
} | ||
|
@@ -234,11 +269,11 @@ internal fun GenericFooter( | |
payload.belowCta?.let { belowCta -> | ||
AnnotatedText( | ||
modifier = Modifier.fillMaxWidth(), | ||
text = TextResource.Text(fromHtml(belowCta.label)), | ||
text = TextResource.Text(fromHtml(belowCta)), | ||
onClickableTextClick = onClickableTextClick, | ||
defaultStyle = typography.labelSmall.copy( | ||
color = colors.textDefault, | ||
textAlign = TextAlign.Start, | ||
textAlign = TextAlign.Center, | ||
Comment on lines
-241
to
+276
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here: Our footer content is usually centered. |
||
), | ||
) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...a/com/stripe/android/financialconnections/features/streamlinedconsent/IDConsentContent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.stripe.android.financialconnections.features.streamlinedconsent | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import com.stripe.android.financialconnections.features.common.FullScreenGenericLoading | ||
import com.stripe.android.financialconnections.features.common.UnclassifiedErrorContent | ||
import com.stripe.android.financialconnections.features.generic.GenericScreen | ||
import com.stripe.android.financialconnections.presentation.Async.Fail | ||
import com.stripe.android.financialconnections.presentation.Async.Loading | ||
import com.stripe.android.financialconnections.presentation.Async.Success | ||
import com.stripe.android.financialconnections.presentation.Async.Uninitialized | ||
import com.stripe.android.financialconnections.presentation.paneViewModel | ||
import com.stripe.android.financialconnections.presentation.parentViewModel | ||
import com.stripe.android.uicore.utils.collectAsState | ||
|
||
@Composable | ||
internal fun IDConsentContentScreen() { | ||
val viewModel: IDConsentContentViewModel = paneViewModel(IDConsentContentViewModel::factory) | ||
val parentViewModel = parentViewModel() | ||
|
||
val state by viewModel.stateFlow.collectAsState() | ||
|
||
IDConsentContent( | ||
state = state, | ||
onPrimaryButtonClick = viewModel::onContinueClick, | ||
onSecondaryButtonClick = { | ||
// There is no secondary button | ||
}, | ||
onClickableTextClick = viewModel::onClickableTextClick, | ||
onCloseFromErrorClick = parentViewModel::onCloseFromErrorClick, | ||
) | ||
} | ||
|
||
@Composable | ||
private fun IDConsentContent( | ||
state: IDConsentContentState, | ||
onPrimaryButtonClick: () -> Unit, | ||
onSecondaryButtonClick: () -> Unit, | ||
onClickableTextClick: (String) -> Unit, | ||
onCloseFromErrorClick: (Throwable) -> Unit, | ||
) { | ||
when (val result = state.payload) { | ||
is Uninitialized, | ||
is Loading -> { | ||
FullScreenGenericLoading() | ||
} | ||
is Success -> { | ||
GenericScreen( | ||
state = result().genericScreenState, | ||
onPrimaryButtonClick = onPrimaryButtonClick, | ||
onSecondaryButtonClick = onSecondaryButtonClick, | ||
onClickableTextClick = onClickableTextClick, | ||
) | ||
} | ||
is Fail -> { | ||
UnclassifiedErrorContent( | ||
onCtaClick = { onCloseFromErrorClick(result.error) }, | ||
) | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
.../stripe/android/financialconnections/features/streamlinedconsent/IDConsentContentState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.stripe.android.financialconnections.features.streamlinedconsent | ||
|
||
import com.stripe.android.financialconnections.features.generic.GenericScreenState | ||
import com.stripe.android.financialconnections.model.FinancialConnectionsSessionManifest | ||
import com.stripe.android.financialconnections.model.IDConsentContentPane | ||
import com.stripe.android.financialconnections.presentation.Async | ||
|
||
internal data class IDConsentContentState( | ||
val payload: Async<Payload> = Async.Uninitialized, | ||
val acceptConsent: Async<FinancialConnectionsSessionManifest> = Async.Uninitialized, | ||
val viewEffect: ViewEffect? = null, | ||
) { | ||
|
||
data class Payload( | ||
val idConsentContentPane: IDConsentContentPane, | ||
) { | ||
|
||
val genericScreenState: GenericScreenState | ||
get() = GenericScreenState(idConsentContentPane.screen, inModal = false) | ||
} | ||
|
||
sealed interface ViewEffect { | ||
data class OpenUrl( | ||
val url: String, | ||
val id: Long, | ||
) : ViewEffect | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our footer content is usually centered.