https://kotlinlang.org logo
#compose-ios
Title
# compose-ios
m

mangubatrj

10/06/2023, 1:41 AM
Hi guys! Is there anyone here who have implemented back swipe using the library https://voyager.adriel.cafe/navigation?
a

Angga Ardinata

10/10/2023, 11:50 PM
want to know to .
m

mangubatrj

10/11/2023, 12:20 AM
no luck yet 😞 might just switch to a different library like decompose
a

Angga Ardinata

10/12/2023, 5:33 AM
i was able to imitate back swipe
m

mangubatrj

10/12/2023, 5:41 AM
hello @Angga Ardinata wow! does it work in IOS, if its alright do you have sample?
a

Angga Ardinata

10/12/2023, 5:46 AM
Copy code
abstract class BaseScreen : Screen, BaseScreenContent, ScreenLifecycleOwner {

    @Composable
    override fun Content() {
        val navigator = LocalNavigator.currentOrThrow
        var offsetState by remember { mutableFloatStateOf(0f) }
        Box(
            modifier = Modifier.background(Color.White)
        ) {
            ScreenContent()
            if (Platform.os == PlatformOS.iOS){
                Box(
                    modifier = Modifier
                        .fillMaxHeight()
                        .width(20.dp)
                        .pointerInput(Unit){
                            detectHorizontalDragGestures(
                                onDragEnd = {
                                    if (offsetState > 100) {
                                        if (navigator.items.size > 1) navigator.pop()
                                    }
                                    offsetState = 0f
                                }
                            ) { _, dragAmount ->
                                if (offsetState < 0) return@detectHorizontalDragGestures
                                offsetState += dragAmount
                            }
                        }
                )
            }
        }
    }
}

private interface BaseScreenContent {
    @Composable
    fun ScreenContent()
}
Im using something like this .. hope this helps
4 Views