From 2f584639375cca496e2bcaf4e06337bd0999bbd0 Mon Sep 17 00:00:00 2001 From: arinming Date: Sun, 7 Jul 2024 03:49:16 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT/#15]=20TerningTopAppBar=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/topappbar/TerningTopAppBar.kt | 37 --------------- .../component/topappbar/TerningTopAppBar.kt | 46 +++++++++++++++++++ .../com/terning/feature/main/MainScreen.kt | 2 +- feature/src/main/res/drawable/ic_btn_back.xml | 13 ++++++ feature/src/main/res/values/strings.xml | 2 + 5 files changed, 62 insertions(+), 38 deletions(-) delete mode 100644 core/src/main/java/com/terning/core/component/topappbar/TerningTopAppBar.kt create mode 100644 feature/src/main/java/com/terning/feature/component/topappbar/TerningTopAppBar.kt create mode 100644 feature/src/main/res/drawable/ic_btn_back.xml diff --git a/core/src/main/java/com/terning/core/component/topappbar/TerningTopAppBar.kt b/core/src/main/java/com/terning/core/component/topappbar/TerningTopAppBar.kt deleted file mode 100644 index b567c79e0..000000000 --- a/core/src/main/java/com/terning/core/component/topappbar/TerningTopAppBar.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.terning.core.component.topappbar - -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.automirrored.filled.ArrowBack -import androidx.compose.material.icons.filled.Menu -import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.Icon -import androidx.compose.material3.IconButton -import androidx.compose.material3.Text -import androidx.compose.material3.TopAppBar -import androidx.compose.runtime.Composable - -@OptIn(ExperimentalMaterial3Api::class) -@Composable -fun TerningTopAppBar( - title: String, -) { - TopAppBar( - title = { Text(text = title) }, - navigationIcon = { - IconButton(onClick = {}) { - Icon( - imageVector = Icons.AutoMirrored.Filled.ArrowBack, - contentDescription = "Localized description" - ) - } - }, - actions = { - IconButton(onClick = {}) { - Icon( - imageVector = Icons.Filled.Menu, - contentDescription = "Localized description" - ) - } - }, - ) -} \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/component/topappbar/TerningTopAppBar.kt b/feature/src/main/java/com/terning/feature/component/topappbar/TerningTopAppBar.kt new file mode 100644 index 000000000..16c3269fe --- /dev/null +++ b/feature/src/main/java/com/terning/feature/component/topappbar/TerningTopAppBar.kt @@ -0,0 +1,46 @@ +package com.terning.feature.component.topappbar + +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign +import com.terning.feature.R + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun TerningTopAppBar( + title: String, + showBackButton: Boolean = false, + customActions: List<@Composable (() -> Unit)>? = null, + onBackButtonClick: (() -> Unit)? = null, +) { + TopAppBar( + title = { + Text(text = title, modifier = Modifier.fillMaxWidth(), textAlign = TextAlign.Center) + }, + navigationIcon = { + if (showBackButton) { + IconButton(onClick = { + onBackButtonClick?.invoke() + }) { + Icon( + painter = painterResource(id = R.drawable.ic_btn_back), + contentDescription = stringResource(id = R.string.ic_btn_back) + ) + } + } + }, + actions = { + customActions?.forEach { customAction -> + customAction() + } + }, + ) +} diff --git a/feature/src/main/java/com/terning/feature/main/MainScreen.kt b/feature/src/main/java/com/terning/feature/main/MainScreen.kt index 1f212ca12..7cbde2cbe 100644 --- a/feature/src/main/java/com/terning/feature/main/MainScreen.kt +++ b/feature/src/main/java/com/terning/feature/main/MainScreen.kt @@ -18,7 +18,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.navigation.compose.NavHost -import com.terning.core.component.topappbar.TerningTopAppBar +import com.terning.feature.component.topappbar.TerningTopAppBar import com.terning.core.designsystem.theme.Grey300 import com.terning.core.designsystem.theme.TerningMain import com.terning.core.designsystem.theme.White diff --git a/feature/src/main/res/drawable/ic_btn_back.xml b/feature/src/main/res/drawable/ic_btn_back.xml new file mode 100644 index 000000000..fac96f803 --- /dev/null +++ b/feature/src/main/res/drawable/ic_btn_back.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/feature/src/main/res/values/strings.xml b/feature/src/main/res/values/strings.xml index 133c0442b..37c3d4a4c 100644 --- a/feature/src/main/res/values/strings.xml +++ b/feature/src/main/res/values/strings.xml @@ -10,4 +10,6 @@ 탐색 마이페이지 + + 뒤로가기 버튼 \ No newline at end of file