• n

    nglauber

    11 months ago
    I’m declaring an
    AnimatedNavHost
    which has many screens and the first one is the
    HomeScreen
    .
    HomeScreen
    has another
    NavHost
    to implement the navigation between the bottom navigation tabs. Here’s the steps to reproduce:1. Select second tab in
    HomeScreen
    (or any other tab but the first) 2. Navigate to another screen declared inside the
    AnimatedNavHost
    (let’s say
    DetailsTab2Screen
    3. Press back. So the
    HomeScreen
    is displayed again with the second tab selected. 4. Press back again. The first tab of the
    HomeScreen
    is selected. 5. Press back again. The expected result is: the application must be closed The actual result is: the user has to press the back button again to leave the app. And if you repeat the steps 2 and 3, N times, the user has to press the back key N + 2 times to leave the app. Any thoughts?
    n
    i
    +1
    7 replies
    Copy to Clipboard
  • myanmarking

    myanmarking

    11 months ago
    is there any code samples with dynamic typography (i know some jetSamples have dynamic colors) - but i was interested in dynamic typography
    myanmarking
    Alex
    +2
    14 replies
    Copy to Clipboard
  • Alex

    Alex

    11 months ago
    Is there something special I need to do to enable overscroll glowing effects on a scrollable Column? (code in thread)
    Alex
    5 replies
    Copy to Clipboard
  • t

    Tolriq

    11 months ago
    What would be the correct modifier to have a Row containing 2 Text that are adjacent but with the second one always visible, so that max width of the first one would be total width - second text width?
    t
    Csaba Szugyiczki
    6 replies
    Copy to Clipboard
  • Daniel Weidensdörfer

    Daniel Weidensdörfer

    11 months ago
    How can I preview an AlertDialog in compose? It is always empty for the code in thread.
    Daniel Weidensdörfer
    1 replies
    Copy to Clipboard
  • nilTheDev

    nilTheDev

    11 months ago

    https://youtu.be/Gi-MnWDRcmQ

    In this video Mitch says there is no way to have a viewModel scoped to the lifecycle of a composable. So, he would use fragments to architect applications. The video is from 2020 so I was wondering whether Jetpack Compose has found any way out of this. This code snippet from the page https://developer.android.com/jetpack/compose/state seems useful here.
    class HelloViewModel : ViewModel() {
    
        // LiveData holds state which is observed by the UI
        // (state flows down from ViewModel)
        private val _name = MutableLiveData("")
        val name: LiveData<String> = _name
    
        // onNameChange is an event we're defining that the UI can invoke
        // (events flow up from UI)
        fun onNameChange(newName: String) {
            _name.value = newName
        }
    }
    
    @Composable
    fun HelloScreen(helloViewModel: HelloViewModel = viewModel()) {
        // by default, viewModel() follows the Lifecycle as the Activity or Fragment
        // that calls HelloScreen(). This lifecycle can be modified by callers of HelloScreen.
    
        // name is the current value of [helloViewModel.name]
        // with an initial value of ""
        val name: String by helloViewModel.name.observeAsState("")
        HelloContent(name = name, onNameChange = { helloViewModel.onNameChange(it) })
    }
    
    @Composable
    fun HelloContent(name: String, onNameChange: (String) -> Unit) {
        Column(modifier = Modifier.padding(16.dp)) {
            Text(
                text = "Hello, $name",
                modifier = Modifier.padding(bottom = 8.dp),
                style = MaterialTheme.typography.h5
            )
            OutlinedTextField(
                value = name,
                onValueChange = onNameChange,
                label = { Text("Name") }
            )
        }
    }
    However I couldn't use it on my environment. Particularly, this line of code
    fun HelloScreen(helloViewModel: HelloViewModel = viewModel())
    is where the problem lies. My IDE isn't able to identify the
    viewModel()
    function here. Where is it coming from? Do I need any other dependency to make it work?
    nilTheDev
    i
    +1
    11 replies
    Copy to Clipboard
  • Viktor Petrovski

    Viktor Petrovski

    11 months ago
    I’m implementing DeepLinks in compose navigation and I just realised that: This works:
    private const val DEEP_LINK_URI = "<https://example.com>"
    This doesn’t:
    private const val DEEP_LINK_URI = "<http://www.example.com|www.example.com>"
    Is this intentional or I’m missing something? Thanks 🙏
    Viktor Petrovski
    i
    6 replies
    Copy to Clipboard
  • adjpd

    adjpd

    11 months ago
    How can I make the check left-aligned? Code in 🧵. (If the image is blank, clicking on it seems to help)
    adjpd
    n
    +1
    8 replies
    Copy to Clipboard
  • e

    enighma

    11 months ago
    Any news on writing widgets in Compose?
    e
    ian.shaun.thomas
    +1
    13 replies
    Copy to Clipboard
  • s

    ste

    11 months ago
    Also this one generates a compiler error (issue):
    @Parcelize @JvmInline value class Err<T>(val value: Int) : Parcelable
    s
    e
    3 replies
    Copy to Clipboard