Skip to content

Commit

Permalink
Update to Compose 1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tillh-stripe committed Sep 12, 2023
1 parent 3549ea8 commit 1c0f597
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 10 deletions.
8 changes: 8 additions & 0 deletions build-configuration/android-application.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ apply from: rootProject.file('build-configuration/ktlint.gradle')

check.dependsOn('ktlint')

configurations {
all {
resolutionStrategy {
force 'androidx.emoji2:emoji2:1.3.0'
}
}
}

android {
namespace STRIPE_ANDROID_NAMESPACE
compileSdkVersion rootProject.ext.compileSdkVersion
Expand Down
6 changes: 6 additions & 0 deletions build-configuration/android-library.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ check.dependsOn('ktlint')

configurations {
javadocDeps

all {
resolutionStrategy {
force 'androidx.emoji2:emoji2:1.3.0'
}
}
}

if (System.getenv("JITPACK")) {
Expand Down
3 changes: 1 addition & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ext.versions = [
androidxAppcompat : '1.6.1',
androidxArchCore : '2.2.0',
androidxBrowser : '1.5.0',
androidxCompose : '1.4.3',
androidxCompose : '1.5.1',
androidxComposeCompiler : '1.4.1',
androidxComposeRuntime : '1.4.3',
androidxComposeUi : '1.4.3',
Expand All @@ -25,7 +25,6 @@ ext.versions = [
androidxRecyclerview : '1.2.1',
androidxSecurity : '1.1.0-alpha05',
binaryCompatibilityValidator: '0.13.1',
buildTools : "30.0.3",
cameraX : '1.2.3',
dagger : '2.48',
detekt : "1.22.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ internal const val BottomSheetContentTestTag = "BottomSheetContentTestTag"
internal class BottomSheetState(
val modalBottomSheetState: ModalBottomSheetState,
val keyboardHandler: BottomSheetKeyboardHandler,
val sheetGesturesEnabled: Boolean,
) {

private var dismissalType: DismissalType? = null
Expand Down Expand Up @@ -86,6 +87,7 @@ internal class BottomSheetState(
@OptIn(ExperimentalMaterialApi::class)
@Composable
internal fun rememberBottomSheetState(
sheetGesturesEnabled: Boolean = true,
confirmValueChange: (ModalBottomSheetValue) -> Boolean = { true },
): BottomSheetState {
val modalBottomSheetState = rememberModalBottomSheetState(
Expand All @@ -101,6 +103,7 @@ internal fun rememberBottomSheetState(
BottomSheetState(
modalBottomSheetState = modalBottomSheetState,
keyboardHandler = keyboardHandler,
sheetGesturesEnabled = sheetGesturesEnabled,
)
}
}
Expand Down Expand Up @@ -172,6 +175,7 @@ internal fun BottomSheet(
topStart = MaterialTheme.stripeShapes.cornerRadius.dp,
topEnd = MaterialTheme.stripeShapes.cornerRadius.dp,
),
sheetGesturesEnabled = state.sheetGesturesEnabled,
sheetContent = {
Box(modifier = Modifier.testTag(BottomSheetContentTestTag)) {
sheetContent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal class CustomerSheetActivity : AppCompatActivity() {

setContent {
StripeTheme {
val bottomSheetState = rememberBottomSheetState()
val bottomSheetState = rememberBottomSheetState(sheetGesturesEnabled = false)

val viewState by viewModel.viewState.collectAsState()
val result by viewModel.result.collectAsState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ internal class PaymentOptionsActivity : BaseSheetActivity<PaymentOptionResult>()
val isProcessing by viewModel.processing.collectAsState()

val bottomSheetState = rememberBottomSheetState(
sheetGesturesEnabled = false,
confirmValueChange = { !isProcessing },
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ internal class PaymentSheetActivity : BaseSheetActivity<PaymentSheetResult>() {
val isProcessing by viewModel.processing.collectAsState()

val bottomSheetState = rememberBottomSheetState(
sheetGesturesEnabled = false,
confirmValueChange = { !isProcessing },
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,7 @@ internal class AddressElementActivity : ComponentActivity() {
val navController = rememberAnimatedNavController()
viewModel.navigator.navigationController = navController

val bottomSheetState = rememberBottomSheetState(
confirmValueChange = {
val route = navController.currentDestination?.route
route != AddressElementScreen.Autocomplete.route
},
)
val bottomSheetState = rememberBottomSheetState(sheetGesturesEnabled = false)

BackHandler {
viewModel.navigator.onBack()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.ModalBottomSheetValue
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -46,9 +47,18 @@ internal class PollingActivity : AppCompatActivity() {

setContent {
StripeTheme {
val state = rememberBottomSheetState(confirmValueChange = { false })
val uiState by viewModel.uiState.collectAsState()

val state = rememberBottomSheetState(
confirmValueChange = { proposedValue ->
if (proposedValue == ModalBottomSheetValue.Hidden) {
uiState.pollingState != PollingState.Active
} else {
true
}
}
)

BackHandler(enabled = true) {
if (uiState.pollingState == PollingState.Failed) {
viewModel.handleCancel()
Expand Down
1 change: 1 addition & 0 deletions stripe-ui-core/src/test/resources/robolectric.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sdk=33

0 comments on commit 1c0f597

Please sign in to comment.