• Nat Strangerweather

    Nat Strangerweather

    2 years ago
    Is there a tutorial for custom radio buttons? I got a kind reply here but I have not managed to understand how it is supposed to work. 😥
    Nat Strangerweather
    Anna-Chiara Bellini [G]
    3 replies
    Copy to Clipboard
  • Geert

    Geert

    2 years ago
    What do you think about the easiest way to show a circle? Currently I have 3 options, but only 2 are working… I would prefer to use Icon and CircleShape. But that seems impossible
    // CircleShape does not work
        Image(
            asset = CircleShape,
            modifier = Modifier
                .preferredSize(16.dp)
                .background(Color.Red)
        )
        
        // Show an Circle
        Box(shape = CircleShape,
            backgroundColor = Color.Red,
            modifier = Modifier.preferredSize(16.dp)
        ) { }
    
    
    
        //  Material has no regular circle
        Image(
            asset = Icons.Default.AddCircle,
            modifier = Modifier
                .preferredSize(16.dp)
                .background(Color.Red)
        )
    Geert
    Nader Jawad
    +1
    10 replies
    Copy to Clipboard
  • r

    Răzvan Roșu

    2 years ago
    Is there anything like a GridView yet?
    r
    Zach Klippenstein (he/him) [MOD]
    2 replies
    Copy to Clipboard
  • rkeazor

    rkeazor

    2 years ago
    Can you enable compose without buildFeatures?
    rkeazor
    jim
    +1
    6 replies
    Copy to Clipboard
  • Colton Idle

    Colton Idle

    2 years ago
    New to compose, but I expected something like this to work but it does not. My activity has a field myTodoList mutableListOf<String> and it has items added to it by another source (right now I have a post delayed handler that waits for 5 seconds, and then adds ten items) and I expect the items to update this Screen composable, but nothing shows. I'm assuming it's because the state can't live in the activity? That actually doesn't really make sense I guess. Just want someone to look this over. Thank you!
    @Composable
    private fun MyActivityScreen(items: List<String>) {
        val myThings = remember { mutableStateOf(items) }
        Column() {
            myThings.value.forEach {
                Text(text = it)
            }
        }
    }
    Colton Idle
    a
    +2
    18 replies
    Copy to Clipboard
  • n

    nglauber

    2 years ago
    Quick question: how can I see the preview of a Composable into the inline documentation? Like @romainguy is showing here:

    https://youtu.be/U5BwfqBpiWU?t=475

    n
    a
    +2
    19 replies
    Copy to Clipboard
  • lib

    lib

    2 years ago
    How to route from one screen to another ?
    lib
    n
    +4
    11 replies
    Copy to Clipboard
  • Mehdi Haghgoo

    Mehdi Haghgoo

    2 years ago
    I am filling the content of a fragment with Compose. I don't know why there is a huge margin around the Compose area. I haven't used any padding for the scaffold. Here's my fragment code:
    class HomeFragment : Fragment() {
        override fun onCreateView(
            inflater: LayoutInflater,
            container: ViewGroup?,
            savedInstanceState: Bundle?
        ): View? = LinearLayout(context).apply{
            addView(ComposeView(context).apply {
                setContent {
                    BodyContent(this.findFragment())
                }
            })
        }
    
    }
    
    @Composable
    fun BodyContent(fragment: Fragment) {
    
    
        val data = listOf("One", "Two", "Three", "Four", "Five")
    
        Scaffold(
            modifier = Modifier.background(Color.Black).fillMaxSize()
                .background(Color.Blue),
            topBar = {
                MyTopAppBar()
            },
            bottomBar = {
                MyBottomBar()
            },
    
            floatingActionButton = { MyFab(fragment) },
            floatingActionButtonPosition = FabPosition.End,
            snackbarHost = {  },
            drawerContent = { MyDrawer() }
    
        ){
    
    
    
            LazyColumnFor(items = data, modifier = Modifier
                .background(Color.Green),
                itemContent = {item->
                    Text(item, modifier = Modifier.padding(8.dp))
                }
            )
    
    
    
    
        }
    }
    
    @Composable
    fun MyDrawer() {
        val items = arrayOf("My Account", "Monthly Cost", "Savings Report")
        Box(paddingStart = 32.dp) {
            Column(modifier = Modifier.align(Alignment.CenterVertically)) {
                for (item in items) {
                    Text(item, modifier = Modifier.padding(8.dp))
                }
            }
        }
    }
    
    
    @Composable
    fun MyTopAppBar() {
        TopAppBar(modifier = Modifier.padding(8.dp, 16.dp, 8.dp, 8.dp)) {
            if(gCost != null){
                Text("Cost is $gCost", modifier = Modifier.border(1.dp, Color.Red))
            }
            Icon(Icons.Default.Add, modifier = Modifier.clip(RoundedCornerShape(8.dp)))
            Icon(Icons.Default.AccountBox, modifier = Modifier.clip(RoundedCornerShape(8.dp)))
            Icon(Icons.Default.ExitToApp, modifier = Modifier.clip(RoundedCornerShape(8.dp)))
            Icon(Icons.Default.ArrowBack, modifier = Modifier.clip(RoundedCornerShape(8.dp)))
        }
    }
    
    
    
    
    @Composable
    fun MyBottomBar() {
        BottomAppBar() {
            Row(){
                Icon(Icons.Default.Person, modifier = Modifier.clip(RoundedCornerShape(8.dp)).weight(0.25f))
                Icon(Icons.Default.Call, modifier = Modifier.clip(RoundedCornerShape(8.dp)).weight(0.25f))
                Icon(Icons.Default.Send, modifier = Modifier.clip(RoundedCornerShape(8.dp)).weight(0.25f))
                Icon(Icons.Default.Refresh, modifier = Modifier.clip(RoundedCornerShape(8.dp)).weight(0.25f))
            }
        }
    }
    
    @Composable
    fun MyFab(fragment: Fragment) {
        FloatingActionButton(
            icon = { Icon(Icons.Default.Add) },
    
            onClick = {
                findNavController(fragment).navigate(HomeFragmentDirections.actionHomeFragmentToAddCostActivity())
    
                launchActivity = true
            },
            modifier = Modifier.padding(8.dp)
        )
    }
    Mehdi Haghgoo
    Yann Badoual
    +1
    14 replies
    Copy to Clipboard
  • Mehdi Haghgoo

    Mehdi Haghgoo

    2 years ago
    One general question. Is Scaffold better to be used for each screen or just the home screen?
    Mehdi Haghgoo
    1 replies
    Copy to Clipboard
  • r

    Răzvan Roșu

    2 years ago
    I thinks it’s a silly question, but I want to define a set of colors based on theme like I did with
    colors.xml
    and
    colors-night.xml
    (besides the primaryColor, secondaryColor and so on) without using the xml resources.
    <!-- colors.xml -->
    <color name="customers_button_background">#123456</color>
    <color name="customers_button_content">#FFFFFF</color>
    
    <!-- colors-night.xml -->
    <color name="customers_button_background">#7890AB</color>
    <color name="customers_button_content">#000000</color>
    How can I achieve this in Compose? Thanks!
    r
    Yann Badoual
    8 replies
    Copy to Clipboard