• Orhan Tozan

    Orhan Tozan

    1 year ago
    What is the recommended way to declare computed state? Is it with
    remember(a, b) { a + b}
    or
    derivedStateOf { a + b }
    ?
    Orhan Tozan
    lewis
    +3
    43 replies
    Copy to Clipboard
  • Peter Parker

    Peter Parker

    1 year ago
    Today we updated our project from compose alpha version to beta. Now we got this strange exception (ava.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/ui/platform/AndroidAmbientsKt😉 when using the Insets class from Chris Banes for edge-to-edge. Does someone know this exception and has a solution for this problem?
    Peter Parker
    lewis
    2 replies
    Copy to Clipboard
  • Kensuke Sano

    Kensuke Sano

    1 year ago
    Is there any way to show placehoder while loading text or image like redacted in SwiftUI? https://swiftwithmajid.com/2020/10/22/the-magic-of-redacted-modifier-in-swiftui/
    Kensuke Sano
    John O'Reilly
    +2
    5 replies
    Copy to Clipboard
  • Archie

    Archie

    1 year ago
    Hi @Adam Powell, Any reason why,
    @Composable
    fun TopAppBar(
        title: @Composable () -> Unit,
        modifier: Modifier = Modifier,
        navigationIcon: @Composable (() -> Unit)? = null,
        actions: @Composable RowScope.() -> Unit = {},
        backgroundColor: Color = MaterialTheme.colors.primarySurface,
        contentColor: Color = contentColorFor(backgroundColor),
        elevation: Dp = AppBarDefaults.TopAppBarElevation
    ) {
    ...
    }
    Doesn't expose
    contentPadding
    ? Is it possible to request exposing the content padding to adding addition padding for
    WindowInsets
    would be easier?
    Archie
    a
    +2
    12 replies
    Copy to Clipboard
  • Lukas K-G

    Lukas K-G

    1 year ago
    I would like to align some text in different Rows by the longest text before it. I.e.
    Auto
    Normal
    and
    Auto
    should start at the same offset depending on the longest text in the previous “column” (visualized in green). Any ideas how I achieve do that? 🤔
    Lukas K-G
    d
    +1
    9 replies
    Copy to Clipboard
  • escodro

    escodro

    1 year ago
    Hello, everyone! 😊 I have a
    Flow
    inside a
    ViewModel
    that is notified in every time a change is made in my database and reflect the state via
    sealed class
    to my composable. This
    Flow
    is attached to the
    viewModelScope
    . Basically I’m facing two problems:1. Every time the screen is recomposed, the function to load the data is called and a new flow is registered and listening to changes. 2. When I’m navigating in another composables that handles the same data, the
    Flow
    keeps emitting data changes for the composable that is no longer visible. Is there a better way to implement it? Should I use my own scope instead the one from
    ViewModel
    ? If so, how can I “dispose” the scope when the Composable is no longer visible?
    @Composable
    private fun TaskListLoader(viewModel: TaskListViewModel = viewModel()) {
        viewModel.loadTasks()
        val viewState by viewModel.state.collectAsState()
        TaskScaffold(...)
    }
    fun loadTasks() = viewModelScope.launch {
        loadAllTasksUseCase().collect { tasks ->
            // emit via StateFlow
        }
    }
    Thanks a lot in advance! ❤️
    escodro
    a
    +6
    76 replies
    Copy to Clipboard
  • Samir Basnet

    Samir Basnet

    1 year ago
    Do we have an animation so that we set a delay and from the point of composition after the delay the Animation starts ?
    Samir Basnet
    1 replies
    Copy to Clipboard
  • Deepak Gahlot

    Deepak Gahlot

    1 year ago
    @Preview
    @Composable
    fun AttachmentComponent() {
    
        var fileName = remember { mutableStateOf(ArrayList<String>()) }
        var array = arrayOf("application/pdf")
        var files = ArrayList<String>()
        var fileAttached = remember { mutableStateOf(false) }
    
    
        Column {
    
            val registerTakeFile = registerForActivityResult(
                ActivityResultContracts.OpenMultipleDocuments()
            ) {
                for (i in 0 until it.size) {
                    var uri = it.get(i)
                    files.add(uri.path!!)
                }
                fileName.value = files
            }
    
            Text(
                text = "Attachment",
                color = colorResource(id = R.color.gray1)
            )
            if (fileAttached.value) {
                FileAttached(item = fileName.value)
            }
            OutlinedButton(
                modifier = Modifier
                    .fillMaxWidth()
                    .padding(16.dp),
                colors = ButtonDefaults.outlinedButtonColors(
                    contentColor = colorResource(id = R.color.blue1)
                ),
                onClick = {
                    registerTakeFile.launch(array)
                    fileAttached.value = true
                }
            ) {
                Icon(painterResource(id = R.drawable.ico_attach), contentDescription = "attach")
                Text(
                    fontSize = 14.sp,
                    text = "Add Files",
                    )
            }
        }
    }
    
    @Composable
    fun FileAttached(item: ArrayList<String>) {
        Column {
            item.forEach {
                Row {
                    Text(
                        text = it,
                        color = colorResource(id = R.color.black)
                    )
                }
            }
        }
    }
    Deepak Gahlot
    i
    4 replies
    Copy to Clipboard
  • Shakil Karim

    Shakil Karim

    1 year ago
    I found Bottom Sheet API very weird to use, for example when I have show more than 1 bottom sheet on screen, I have to do something like that.
    ModalBottomSheet(
        sheetState = clubsSheetState,
        sheetContent = {
              ---------Sheet 1 content
        },
        content = {
            ---- Sheet 1 body
              ModalBottomSheet(
                   sheetState = clubsSheetState,
                   sheetContent = {
                         ---------Sheet 2 content
                   },
                   content = {
                       ---- Sheet 2 body
                   })
    
        })
    Isn't it will be better to use it like Dialog if(show) { BottomSheet() }
    Shakil Karim
    Halil Ozercan
    2 replies
    Copy to Clipboard
  • Neal Sanche

    Neal Sanche

    1 year ago
    So, yesterday, I was tracking down what I am referring to as unexpected recomposition issues in an app I'm working on that deals with images from the CameraX API. Content Redacted for brevity, see thread.
    Neal Sanche
    jim
    +1
    10 replies
    Copy to Clipboard