Skip to content

Commit

Permalink
fix: use stable compose bom version to fix video calls [WPB-4992] (#2326
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Garzas committed Oct 16, 2023
1 parent 05fe218 commit e066cb0
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 72 deletions.
20 changes: 12 additions & 8 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ android {
// through the Wire Application convention plugin

// Remove protobuf-java as dependencies, so we can get protobuf-lite
configurations.implementation.configure {
configurations.implementation.configure {
exclude(module = "protobuf-java")
}
}

packaging {
resources.pickFirsts.add("google/protobuf/*.proto")
Expand Down Expand Up @@ -96,7 +96,11 @@ dependencies {
implementation(libs.androidx.lifecycle.viewModelSavedState)

// Compose
implementation(libs.compose.core)
val composeBom = platform(libs.compose.bom)
implementation(composeBom)
androidTestImplementation(composeBom)

implementation(libs.compose.ui)
implementation(libs.compose.foundation)
// we still cannot get rid of material2 because swipeable is still missing - https://issuetracker.google.com/issues/229839039
// https://developer.android.com/jetpack/compose/designsystems/material2-material3#components-and
Expand All @@ -105,11 +109,11 @@ dependencies {
// the only libraries with material2 packages that can be used with material3 are icons and ripple
implementation(libs.compose.material.icons)
implementation(libs.compose.material.ripple)
implementation(libs.compose.preview)
implementation(libs.compose.ui.preview)
implementation(libs.compose.activity)
implementation(libs.compose.navigation)
implementation(libs.compose.constraintLayout)
implementation(libs.compose.liveData)
implementation(libs.compose.runtime.liveData)
implementation(libs.compose.destinations.core)
ksp(libs.compose.destinations.ksp)

Expand All @@ -124,7 +128,7 @@ dependencies {
implementation(libs.androidx.profile.installer)

// Compose iterative code, layout inspector, etc.
debugImplementation(libs.compose.tooling)
debugImplementation(libs.compose.ui.tooling)

// Emoji
implementation(libs.androidx.emoji.picker)
Expand Down Expand Up @@ -177,8 +181,8 @@ dependencies {
androidTestImplementation(libs.coroutines.test)
androidTestImplementation(libs.mockk.android)
androidTestImplementation(libs.kluent.android)
androidTestImplementation(libs.compose.test.junit)
debugImplementation(libs.compose.test.manifest)
androidTestImplementation(libs.compose.ui.test.junit)
debugImplementation(libs.compose.ui.test.manifest)
androidTestUtil(libs.androidx.test.orchestrator)

// Development dependencies
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/kotlin/com/wire/android/ui/WireActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.runtime.setValue
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
Expand Down Expand Up @@ -102,6 +103,7 @@ import kotlinx.coroutines.flow.onSubscription
import kotlinx.coroutines.launch
import javax.inject.Inject

@OptIn(ExperimentalComposeUiApi::class)
@AndroidEntryPoint
@Suppress("TooManyFunctions")
class WireActivity : AppCompatActivity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,18 @@
* along with this program. If not, see http://www.gnu.org/licenses/.
*/

import androidx.compose.animation.core.SpringSpec
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.gestures.AnchoredDraggableState
import androidx.compose.foundation.gestures.DraggableAnchors
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.anchoredDraggable
import androidx.compose.foundation.layout.offset
// TODO uncomment when anchoredDraggable will be available on [composeBom] version
// import androidx.compose.foundation.gestures.AnchoredDraggableState
// import androidx.compose.foundation.gestures.DraggableAnchors
// import androidx.compose.foundation.gestures.anchoredDraggable
import androidx.compose.material3.Snackbar
import androidx.compose.material3.SnackbarData
import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import kotlin.math.roundToInt

/**
* A swipeable [Snackbar] that allows users to manually dismiss it by dragging.
Expand All @@ -51,7 +44,7 @@ import kotlin.math.roundToInt
* @see SnackbarData
* @see SnackbarHostState
*/
@OptIn(ExperimentalFoundationApi::class)

@Composable
fun SwipeableSnackbar(
hostState: SnackbarHostState,
Expand All @@ -63,10 +56,11 @@ fun SwipeableSnackbar(

val currentScreenWidth = with(density) { configuration.screenWidthDp.dp.toPx() }

val anchors = DraggableAnchors {
SnackBarState.Visible at 0f
SnackBarState.Dismissed at currentScreenWidth
}
// TODO uncomment when anchoredDraggable will be available on [composeBom] version
// val anchors = DraggableAnchors {
// SnackBarState.Visible at 0f
// SnackBarState.Dismissed at currentScreenWidth
// }

// Determines how far the user needs to drag (as a fraction of total distance) for an action to be triggered.
// In this example, the Snackbar will trigger an action if dragged to half (0.5) of its width.
Expand All @@ -77,37 +71,42 @@ fun SwipeableSnackbar(
// Here, it's set to 125 device-independent pixels per second.
val velocityThreshold: () -> Float = with(density) { { 125.dp.toPx() } }

val state = remember {
AnchoredDraggableState(
initialValue = SnackBarState.Visible,
anchors = anchors,
positionalThreshold = positionalThreshold,
velocityThreshold = velocityThreshold,
animationSpec = SpringSpec(),
confirmValueChange = { true }
)
}
// TODO uncomment when anchoredDraggable will be available on [composeBom] version
// val state = remember {
// AnchoredDraggableState(
// initialValue = SnackBarState.Visible,
// anchors = anchors,
// positionalThreshold = positionalThreshold,
// velocityThreshold = velocityThreshold,
// animationSpec = SpringSpec(),
// confirmValueChange = { true }
// )
// }

LaunchedEffect(state.currentValue) {
if (state.currentValue == SnackBarState.Dismissed) {
onDismiss()
}
}
// TODO uncomment when anchoredDraggable will be available on [composeBom] version
// LaunchedEffect(state.currentValue) {
// if (state.currentValue == SnackBarState.Dismissed) {
// onDismiss()
// }
// }

Snackbar(
snackbarData = data,
modifier = Modifier
.anchoredDraggable(
state = state,
orientation = Orientation.Horizontal
)
.offset {
IntOffset(
state
.requireOffset()
.roundToInt(), 0
)
})
// TODO uncomment when anchoredDraggable will be available on [composeBom] version
// .anchoredDraggable(
// state = state,
// orientation = Orientation.Horizontal
// )
// .offset {
// IntOffset(
// state
// .requireOffset()
// .roundToInt(), 0
// )
// }
)
}

private enum class SnackBarState { Visible, Dismissed }
// TODO uncomment when anchoredDraggable will be available on [composeBom] version
// private enum class SnackBarState { Visible, Dismissed }
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalFocusManager
Expand Down Expand Up @@ -222,7 +223,7 @@ fun GroupConversationDetailsScreen(

@OptIn(
ExperimentalMaterial3Api::class,
ExperimentalFoundationApi::class
ExperimentalFoundationApi::class, ExperimentalComposeUiApi::class
)
@Composable
private fun GroupConversationDetailsContent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.focus.FocusRequester
Expand Down Expand Up @@ -184,6 +185,7 @@ fun ActiveMessageComposerInput(
}
}

@OptIn(ExperimentalComposeUiApi::class)
@Composable
private fun MessageComposerTextInput(
inputFocused: Boolean,
Expand Down
40 changes: 20 additions & 20 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@ androidx-browser = "1.5.0"
androidx-biometric = "1.1.0"

# Compose
compose = "1.6.0-alpha07"
compose-material = "1.6.0-alpha07"
compose-activity = "1.7.2"
composeBom = "2023.10.00" # TODO check if in new version [anchoredDraggable] is available
compose-compiler = "1.5.2"
compose-constraint = "1.0.1"
compose-material3 = "1.2.0-alpha09"
compose-navigation = "2.6.0"
compose-destinations = "1.9.40-beta"

Expand Down Expand Up @@ -160,23 +157,26 @@ hilt-navigationCompose = { module = "androidx.hilt:hilt-navigation-compose", ver
hilt-test = { module = "com.google.dagger:hilt-android-testing", version.ref = "hilt" }
hilt-work = { module = "androidx.hilt:hilt-work", version.ref = "hilt-work" }

# Compose
compose-core = { module = "androidx.compose.ui:ui", version.ref = "compose" }
compose-activity = { module = "androidx.activity:activity-compose", version.ref = "compose-activity" }
compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" }
compose-material-core = { module = "androidx.compose.material:material", version.ref = "compose-material" }
compose-material-icons = { module = "androidx.compose.material:material-icons-extended", version.ref = "compose-material" }
compose-material-ripple = { module = "androidx.compose.material:material-ripple", version.ref = "compose-material" }
compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" }
compose-navigation = { module = "androidx.navigation:navigation-compose", version.ref = "compose-navigation" }
compose-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
compose-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" }
# Compose BOM
compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
compose-activity = { module = "androidx.activity:activity-compose" }
compose-foundation = { module = "androidx.compose.foundation:foundation" }
compose-material-core = { module = "androidx.compose.material:material" }
compose-material-icons = { module = "androidx.compose.material:material-icons-extended" }
compose-material-ripple = { module = "androidx.compose.material:material-ripple" }
compose-material3 = { module = "androidx.compose.material3:material3" }
compose-runtime-liveData = { module = "androidx.compose.runtime:runtime-livedata" }
compose-ui = { module = "androidx.compose.ui:ui" }
compose-ui-test-junit = { module = "androidx.compose.ui:ui-test-junit4" }
compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" }
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
compose-ui-preview = { module = "androidx.compose.ui:ui-tooling-preview" }

# Compose other
compose-constraintLayout = { module = "androidx.constraintlayout:constraintlayout-compose", version.ref = "compose-constraint" }
compose-liveData = { module = "androidx.compose.runtime:runtime-livedata", version.ref = "compose" }
compose-test-junit = {module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" }
compose-test-manifest = {module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" }
compose-destinations-core ={module = "io.github.raamcosta.compose-destinations:animations-core", version.ref = "compose-destinations" }
compose-destinations-ksp ={module = "io.github.raamcosta.compose-destinations:ksp", version.ref = "compose-destinations" }
compose-navigation = { module = "androidx.navigation:navigation-compose", version.ref = "compose-navigation" }
compose-destinations-core = { module = "io.github.raamcosta.compose-destinations:animations-core", version.ref = "compose-destinations" }
compose-destinations-ksp = { module = "io.github.raamcosta.compose-destinations:ksp", version.ref = "compose-destinations" }

# Accompanist
accompanist-systemUI = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanist" }
Expand Down

0 comments on commit e066cb0

Please sign in to comment.