Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TNT-185] 트레이니 마이페이지 UI 구현 #58

Merged
merged 21 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6b4e6a3
[TNT-185] fix: 스트링 리소스 Diet -> Meal 수정
SeonJeongk Jan 30, 2025
bf7bfd2
[TNT-185] feat: 트레이니 mypage 모듈 최초 생성
SeonJeongk Jan 30, 2025
c9b2563
[TNT-185] feat: switch 컴포넌트 구현
SeonJeongk Jan 30, 2025
4f91321
[TNT-185] feat: 트레이니 마이페이지 UI 구현
SeonJeongk Jan 30, 2025
30383ca
[TNT-185] feat: 트레이니 마이페이지 Navigation 구현
SeonJeongk Jan 30, 2025
c4d3ee8
[TNT-185] feat: TnTIconPopupDialog 기본 아이콘 설정
SeonJeongk Jan 30, 2025
438dd3d
[TNT-185] feat: 마이페이지 PopupType 정의
SeonJeongk Jan 30, 2025
14287fb
[TNT-185] feat: 마이페이지 로그아웃, 계정 탈퇴, 연결 끊기 팝업 구현
SeonJeongk Jan 30, 2025
2df84c1
[TNT-185] feat: 서비스 이용약관, 개인정보 처리방침 웹뷰 구현
SeonJeongk Jan 30, 2025
23ffad1
[TNT-185] fix: 웹뷰 수정
SeonJeongk Jan 30, 2025
046a5b5
[TNT-185] feat: 마이페이지 하얀 버튼 core:ui 컴포넌트로 분리
SeonJeongk Jan 30, 2025
e9c8421
[TNT-185] fix: 마이페이지 텍스트 크기에 대응하도록 UI 수정
SeonJeongk Jan 31, 2025
7c0fcc5
[TNT-185] fix: 디자인 시스템 Button 텍스트 사이즈에 대응하도록 수정
SeonJeongk Jan 31, 2025
863ed3a
[TNT-185] feat: 두번째 팝업 뒤로가기 눌러도 확인 클릭처럼 동작하게 수정
SeonJeongk Jan 31, 2025
c63a8c9
[TNT-185] fix: LocalMinimumInteractiveComponentSize 최소 높이인 39.dp로 수정
SeonJeongk Jan 31, 2025
bdd9555
[TNT-185] refactor: 두 줄 이상인 코드 줄바꿈
SeonJeongk Jan 31, 2025
1baad73
[TNT-185] refactor: try catch 삭제
SeonJeongk Jan 31, 2025
ea65e4b
[TNT-185] refactor: dialog로 통일 및 웹뷰 화면 따로 빼기
SeonJeongk Jan 31, 2025
52f1b24
[TNT-185] feat: 트레이니 마이페이지 화면 연결
SeonJeongk Jan 31, 2025
d93e336
[TNT-185] feat: 트레이니 mypage 모듈 최초 생성
SeonJeongk Jan 31, 2025
f1f70a6
[TNT-185] feat: 트레이니 mypage랑 webview 네비게이션 연결
SeonJeongk Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fun TnTSingleButtonPopupDialog(
fun TnTIconPopupDialog(
title: String,
content: String,
topIcon: Painter,
topIcon: Painter = painterResource(R.drawable.ic_round_warning),
leftButtonText: String,
rightButtonText: String,
modifier: Modifier = Modifier,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
package co.kr.tnt.designsystem.component

import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -39,6 +51,43 @@ fun TnTCheckToggle(
)
}

@Composable
fun TnTSwitch(
checked: Boolean,
onCheckedChange: () -> Unit,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

음.. 뭔가 네이밍이 버튼을 누르면 내부에서 checked 를 변화시킬 것 같은 느낌이에요!

단순하게 onClick 도 괜찮아 보입니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋습니다아! 수정해두겠습니다

modifier: Modifier = Modifier,
) {
val trackColor = if (checked) {
TnTTheme.colors.redColors.Red500
} else {
TnTTheme.colors.neutralColors.Neutral300
}

val thumbPosition by animateFloatAsState(
targetValue = if (checked) 20f else 0f,
animationSpec = tween(durationMillis = 200, easing = FastOutSlowInEasing),
label = "thumbPosition",
)

Box(
modifier = modifier
.width(44.dp)
.height(24.dp)
.clip(RoundedCornerShape(12.dp))
.background(trackColor)
.clickable(onClick = onCheckedChange)
.padding(horizontal = 2.dp),
) {
Box(
modifier = Modifier
.size(20.dp)
.offset(x = thumbPosition.dp)
.align(Alignment.CenterStart)
.background(Color.White, CircleShape),
)
}
}

@Preview
@Composable
private fun TnTCheckTogglePreview() {
Expand All @@ -51,3 +100,16 @@ private fun TnTCheckTogglePreview() {
)
}
}

@Preview
@Composable
private fun TnTSwitchPreview() {
TnTTheme {
var checked by remember { mutableStateOf(true) }

TnTSwitch(
checked = checked,
onCheckedChange = { checked = !checked },
)
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package co.kr.tnt.designsystem.component.button

import androidx.compose.foundation.BorderStroke
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.defaultMinSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
Expand All @@ -17,6 +18,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -45,14 +47,14 @@ fun TnTTextButton(
color = type.borderColor(enabled),
),
contentPadding = size.contentPadding,
modifier = modifier
.height(size.height)
// Small, XSmall 버튼을 위해 Button minWidth 설정
.defaultMinSize(minWidth = Dp.Hairline),
// Small, XSmall 버튼을 위해 Button minWidth, minHeight 설정
modifier = modifier.defaultMinSize(minWidth = Dp.Hairline, minHeight = size.height),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
modifier = modifier.defaultMinSize(minWidth = Dp.Hairline, minHeight = size.height),
modifier = modifier.defaultMinSize(
minWidth = Dp.Hairline,
minHeight = size.height
),

2줄 이상이면 줄바꿈 해주는게 좋을 것 같습니다!

) {
Text(
text = text,
style = size.textStyle(),
overflow = TextOverflow.Ellipsis,
maxLines = 1,
)
}
}
Expand All @@ -77,28 +79,40 @@ fun TnTIconButton(
color = type.borderColor(enabled),
),
contentPadding = size.contentPadding,
modifier = modifier
.height(size.height)
// Small, XSmall 버튼을 위해 Button minWidth 설정
.defaultMinSize(minWidth = Dp.Hairline),
// Small, XSmall 버튼을 위해 Button minWidth 설정
modifier = modifier.defaultMinSize(minWidth = Dp.Hairline, minHeight = size.height),
) {
when (iconPosition) {
is IconPosition.Leading -> {
iconPosition.icon()
Text(
text = text,
style = size.textStyle(),
modifier = Modifier.padding(start = 4.dp),
)
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp),
) {
iconPosition.icon()
Text(
text = text,
style = size.textStyle(),
overflow = TextOverflow.Ellipsis,
maxLines = 1,
modifier = Modifier.weight(1f, false),
)
}
}

is IconPosition.Trailing -> {
Text(
text = text,
style = size.textStyle(),
modifier = Modifier.padding(end = 4.dp),
)
iconPosition.icon()
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp),
) {
Text(
text = text,
style = size.textStyle(),
overflow = TextOverflow.Ellipsis,
maxLines = 1,
modifier = Modifier.weight(1f, false),
)
iconPosition.icon()
}
}
}
}
Expand Down Expand Up @@ -137,9 +151,9 @@ fun TnTBottomButton(
fun TnTTnTTextButtonPreview() {
TnTTheme {
TnTTextButton(
size = ButtonSize.Medium,
size = ButtonSize.Small,
type = ButtonType.Primary,
text = "텍스트",
text = "텍스트ddddddddddddd",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 프리뷰긴 한데 좀 더 의미있는 텍스트면 더 좋을 것 같아요 ㅋ_ㅋ

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵.. 고민 해보겠습니다ㅋㅋㅋ큐ㅜㅜ

enabled = true,
onClick = { },
modifier = Modifier.wrapContentSize(),
Expand All @@ -154,32 +168,48 @@ private fun TnTOutLinedButtonPreview() {
TnTTextButton(
size = ButtonSize.Medium,
type = ButtonType.RedOutline,
text = "텍스트",
text = "텍스트dddddddddddddddddddddd",
enabled = true,
onClick = { },
modifier = Modifier.wrapContentSize(),
)
}
}

@Preview(showBackground = true, widthDp = 150, heightDp = 100)
@Preview(showBackground = true, widthDp = 150, heightDp = 130)
@Composable
private fun TnTIconButtonPreview() {
TnTTheme {
TnTIconButton(
size = ButtonSize.Medium,
type = ButtonType.GrayOutline,
iconPosition = IconPosition.Trailing {
Icon(
painter = painterResource(R.drawable.ic_delete),
contentDescription = null,
)
},
text = "텍스트",
enabled = true,
onClick = { },
modifier = Modifier.wrapContentSize(),
)
Column(verticalArrangement = Arrangement.spacedBy(5.dp)) {
TnTIconButton(
size = ButtonSize.Medium,
type = ButtonType.GrayOutline,
iconPosition = IconPosition.Trailing {
Icon(
painter = painterResource(R.drawable.ic_delete),
contentDescription = null,
)
},
text = "텍스트ttttttttttttttttt",
enabled = true,
onClick = { },
modifier = Modifier.wrapContentSize(),
)
TnTIconButton(
size = ButtonSize.Medium,
type = ButtonType.GrayOutline,
iconPosition = IconPosition.Leading {
Icon(
painter = painterResource(R.drawable.ic_delete),
contentDescription = null,
)
},
text = "텍스트tttttttttttttttttt",
enabled = true,
onClick = { },
modifier = Modifier.wrapContentSize(),
)
}
}
}

Expand Down
13 changes: 8 additions & 5 deletions core/navigation/src/main/java/co/kr/tnt/navigation/RouteModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ sealed interface Route {
@Serializable
data object Login : Route

@Serializable
data class RoleSelection(
val authId: String,
val authType: String,
val email: String,
) : Route

@Serializable
data class TrainerSignUp(
val authId: String,
Expand All @@ -33,9 +40,5 @@ sealed interface Route {
data class TraineeConnect(val isFromMyPage: Boolean) : Route

@Serializable
data class RoleSelection(
val authId: String,
val authType: String,
val email: String,
) : Route
data object TraineeMyPage : Route
}
65 changes: 65 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,65 @@
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.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonColors
import androidx.compose.material3.LocalMinimumInteractiveComponentSize
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextOverflow
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,
verticalPadding: Dp,
modifier: Modifier = Modifier,
onClick: () -> Unit,
) {
CompositionLocalProvider(LocalMinimumInteractiveComponentSize provides 39.dp) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

옹 얘는 어떤 방식으로 쓰는건가요?

Copy link
Contributor Author

@SeonJeongk SeonJeongk Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Material 3의 버튼과 같은 터치 가능한 컴포넌트는 최소 터치 영역(48.dp) 을 가지도록 설계되어 있습니다. 이로 인해 버튼 높이가 48.dp보다 작을 경우 자동으로 여백이 추가되는 문제가 발생했습니다!

이를 해결하기 위해 LocalMinimumInteractiveComponentSize를 사용하여 디자인에서 정의된 버튼의 최소 높이(39.dp) 로 최소 터치 가능 영역을 설정했습니다

0.dp로 설정하지 않은 이유는 클릭은 가능하지만 리플 효과가 사라지기 때문입니다!

참고 링크

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오호 넵넵 ㅎㅎ 좋습니다!!

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,
),
elevation = null,
contentPadding = PaddingValues(horizontal = 20.dp, vertical = verticalPadding),
modifier = modifier
.fillMaxWidth()
.defaultMinSize(Dp.Hairline),
) {
Text(
text = text,
style = TnTTheme.typography.body2Medium,
modifier = Modifier.fillMaxWidth(),
overflow = TextOverflow.Ellipsis,
maxLines = 1,
)
}
}
}

@Preview
@Preview(fontScale = 1.5f)
@Composable
private fun TnTMyPageButtonPreview() {
TnTTheme {
TnTMyPageButton(
text = "트레이너와 연결하기",
onClick = {},
verticalPadding = 8.dp,
)
}
}
8 changes: 4 additions & 4 deletions core/ui/src/main/java/co/kr/tnt/ui/model/RecordChip.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ sealed interface RecordChip {
return when (type) {
is RecordType.MealType -> {
val title = when (type) {
RecordType.MealType.BREAKFAST -> stringResource(R.string.diet_breakfast)
RecordType.MealType.LUNCH -> stringResource(R.string.diet_lunch)
RecordType.MealType.DINNER -> stringResource(R.string.diet_dinner)
RecordType.MealType.SNACK -> stringResource(R.string.diet_snack)
RecordType.MealType.BREAKFAST -> stringResource(R.string.meal_breakfast)
RecordType.MealType.LUNCH -> stringResource(R.string.meal_lunch)
RecordType.MealType.DINNER -> stringResource(R.string.meal_dinner)
RecordType.MealType.SNACK -> stringResource(R.string.meal_snack)
}
val emoji = when (type) {
RecordType.MealType.BREAKFAST -> "🌞"
Expand Down
Loading