Skip to content

Commit

Permalink
[TNT-185] feat: 마이페이지 하얀 버튼 core:ui 컴포넌트로 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
SeonJeongk committed Jan 30, 2025
1 parent 23ffad1 commit 046a5b5
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 40 deletions.
58 changes: 58 additions & 0 deletions core/ui/src/main/java/co/kr/tnt/ui/component/TnTMyPageButton.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package co.kr.tnt.ui.component

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonColors
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import co.kr.tnt.designsystem.theme.TnTTheme

@Composable
fun TnTMyPageButton(
text: String,
height: Dp,
modifier: Modifier = Modifier,
onClick: () -> Unit,
) {
Button(
onClick = onClick,
shape = RoundedCornerShape(12.dp),
colors = ButtonColors(
containerColor = TnTTheme.colors.commonColors.Common0,
contentColor = TnTTheme.colors.neutralColors.Neutral700,
disabledContainerColor = TnTTheme.colors.commonColors.Common0,
disabledContentColor = TnTTheme.colors.neutralColors.Neutral700,
),
contentPadding = PaddingValues(horizontal = 20.dp, vertical = 12.dp),
modifier = modifier
.fillMaxWidth()
.height(height)
.defaultMinSize(minWidth = Dp.Hairline),
) {
Text(
text = text,
style = TnTTheme.typography.body2Medium,
modifier = Modifier.fillMaxWidth(),
)
}
}

@Preview
@Composable
private fun TnTMyPageButtonPreview() {
TnTTheme {
TnTMyPageButton(
text = "트레이너와 연결하기",
height = 47.dp,
onClick = {},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonColors
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -32,7 +28,6 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.hilt.navigation.compose.hiltViewModel
Expand All @@ -50,6 +45,7 @@ import co.kr.tnt.trainee.mypage.TraineeMyPageContract.TraineeMyPageEffect
import co.kr.tnt.trainee.mypage.TraineeMyPageContract.TraineeMyPageUiEvent
import co.kr.tnt.trainee.mypage.TraineeMyPageContract.TraineeMyPageUiState
import co.kr.tnt.trainee.mypage.model.PopupType
import co.kr.tnt.ui.component.TnTMyPageButton
import co.kr.tnt.ui.model.DefaultUserProfile
import co.kr.tnt.core.ui.R as uiResource

Expand Down Expand Up @@ -153,7 +149,7 @@ private fun TraineeMyPageScreen(
.padding(20.dp),
) {
if (state.isConnected.not()) {
WhiteButton(
TnTMyPageButton(
text = stringResource(R.string.connect_with_trainer),
height = 47.dp,
onClick = onConnectButtonClick,
Expand Down Expand Up @@ -185,12 +181,12 @@ private fun TraineeMyPageScreen(
.background(TnTTheme.colors.commonColors.Common0)
.padding(vertical = 12.dp),
) {
WhiteButton(
TnTMyPageButton(
text = stringResource(uiResource.string.terms_of_service),
height = 40.dp,
onClick = onServiceTermClick,
)
WhiteButton(
TnTMyPageButton(
text = stringResource(uiResource.string.privacy_policy),
height = 40.dp,
onClick = onPrivacyClick,
Expand All @@ -214,14 +210,14 @@ private fun TraineeMyPageScreen(
style = TnTTheme.typography.body2Medium,
)
}
WhiteButton(
TnTMyPageButton(
text = stringResource(uiResource.string.open_source_license),
height = 40.dp,
onClick = onOpenSourceClick,
)
}
if (state.isConnected) {
WhiteButton(
TnTMyPageButton(
text = stringResource(R.string.disconnect_with_trainer),
height = 47.dp,
onClick = onDisconnectButtonClick,
Expand Down Expand Up @@ -287,36 +283,6 @@ private fun TraineeMyPageScreen(
}
}

@Composable
private fun WhiteButton(
text: String,
height: Dp,
modifier: Modifier = Modifier,
onClick: () -> Unit,
) {
Button(
onClick = onClick,
shape = RoundedCornerShape(12.dp),
colors = ButtonColors(
containerColor = TnTTheme.colors.commonColors.Common0,
contentColor = TnTTheme.colors.neutralColors.Neutral700,
disabledContainerColor = TnTTheme.colors.commonColors.Common0,
disabledContentColor = TnTTheme.colors.neutralColors.Neutral700,
),
contentPadding = PaddingValues(horizontal = 20.dp, vertical = 12.dp),
modifier = modifier
.fillMaxWidth()
.height(height)
.defaultMinSize(minWidth = Dp.Hairline),
) {
Text(
text = text,
style = TnTTheme.typography.body2Medium,
modifier = Modifier.fillMaxWidth(),
)
}
}

@Composable
fun WebViewScreen(url: String, onBackPress: () -> Unit) {
var webView: WebView? = null
Expand Down

0 comments on commit 046a5b5

Please sign in to comment.