|
| 1 | +package com.nextroom.nextroom.presentation.common.compose |
| 2 | + |
| 3 | +import androidx.compose.foundation.Image |
| 4 | +import androidx.compose.foundation.background |
| 5 | +import androidx.compose.foundation.layout.Arrangement |
| 6 | +import androidx.compose.foundation.layout.Box |
| 7 | +import androidx.compose.foundation.layout.Row |
| 8 | +import androidx.compose.foundation.layout.fillMaxWidth |
| 9 | +import androidx.compose.foundation.layout.height |
| 10 | +import androidx.compose.foundation.layout.padding |
| 11 | +import androidx.compose.foundation.layout.size |
| 12 | +import androidx.compose.foundation.shape.RoundedCornerShape |
| 13 | +import androidx.compose.material3.Text |
| 14 | +import androidx.compose.runtime.Composable |
| 15 | +import androidx.compose.ui.Alignment |
| 16 | +import androidx.compose.ui.Modifier |
| 17 | +import androidx.compose.ui.res.painterResource |
| 18 | +import androidx.compose.ui.res.stringResource |
| 19 | +import androidx.compose.ui.text.style.TextAlign |
| 20 | +import androidx.compose.ui.tooling.preview.Preview |
| 21 | +import androidx.compose.ui.unit.dp |
| 22 | +import com.nextroom.nextroom.presentation.R |
| 23 | +import com.nextroom.nextroom.presentation.extension.throttleClick |
| 24 | + |
| 25 | +@Composable |
| 26 | +fun NRToolbar( |
| 27 | + title: String, |
| 28 | + onBackClick: () -> Unit, |
| 29 | + onRightButtonClick: () -> Unit, |
| 30 | + modifier: Modifier = Modifier |
| 31 | +) { |
| 32 | + Box( |
| 33 | + contentAlignment = Alignment.Center |
| 34 | + ) { |
| 35 | + Text( |
| 36 | + text = title, |
| 37 | + style = NRTypo.Poppins.size20, |
| 38 | + color = NRColor.White, |
| 39 | + textAlign = TextAlign.Center, |
| 40 | + ) |
| 41 | + |
| 42 | + Row( |
| 43 | + modifier = modifier |
| 44 | + .fillMaxWidth() |
| 45 | + .height(64.dp), |
| 46 | + verticalAlignment = Alignment.CenterVertically, |
| 47 | + horizontalArrangement = Arrangement.SpaceBetween, |
| 48 | + ) { |
| 49 | + Image( |
| 50 | + painter = painterResource(R.drawable.ic_navigate_back_24), |
| 51 | + modifier = modifier |
| 52 | + .size(64.dp) |
| 53 | + .throttleClick { onBackClick() } |
| 54 | + .padding(20.dp), |
| 55 | + contentDescription = null, |
| 56 | + ) |
| 57 | + |
| 58 | + Text( |
| 59 | + text = stringResource(R.string.memo_button), |
| 60 | + color = NRColor.Dark01, |
| 61 | + style = NRTypo.Poppins.size14, |
| 62 | + modifier = modifier |
| 63 | + .padding(end = 20.dp) |
| 64 | + .background( |
| 65 | + color = NRColor.White, |
| 66 | + shape = RoundedCornerShape(size = 50.dp) |
| 67 | + ) |
| 68 | + .padding(vertical = 6.dp, horizontal = 16.dp) |
| 69 | + .throttleClick { onRightButtonClick() } |
| 70 | + ) |
| 71 | + } |
| 72 | + } |
| 73 | +} |
| 74 | + |
| 75 | +@Preview(showBackground = true, backgroundColor = 0xFF1D1B20) |
| 76 | +@Composable |
| 77 | +private fun NRToolbarPreview() { |
| 78 | + NRToolbar( |
| 79 | + title = "01:23:45", |
| 80 | + onBackClick = {}, |
| 81 | + onRightButtonClick = {} |
| 82 | + ) |
| 83 | +} |
0 commit comments