Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
@@ -0,0 +1,44 @@
package com.lyrics.feelin.core.designsystem.component

import androidx.compose.ui.test.assertIsEnabled
import androidx.compose.ui.test.assertIsNotEnabled
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import com.lyrics.feelin.presentation.designsystem.theme.FeelinTheme
import org.junit.Rule
import org.junit.Test

class FeelinNormalButtonTest {
@get:Rule
val composeRule = createComposeRule()

@Test
fun enabledButtonShowsTextAndAcceptsInput() {
composeRule.setContent {
FeelinTheme {
FeelinNormalButton(
text = "완료",
enabled = true,
onClick = {},
)
}
}

composeRule.onNodeWithText("완료").assertIsEnabled()
}

@Test
fun disabledButtonShowsTextAndRejectsInput() {
composeRule.setContent {
FeelinTheme {
FeelinNormalButton(
text = "프로필 저장",
enabled = false,
onClick = {},
)
}
}

composeRule.onNodeWithText("프로필 저장").assertIsNotEnabled()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.lyrics.feelin.core.designsystem.component

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.ButtonDefaults
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 com.lyrics.feelin.presentation.designsystem.theme.FeelinTheme
import com.lyrics.feelin.presentation.designsystem.theme.FeelinTypography
import com.lyrics.feelin.presentation.designsystem.theme.LocalFeelinColors

/** 디자인시스템에 접미사가 없이 선언된 버튼입니다. */
@Composable
fun FeelinNormalButton(
text: String,
enabled: Boolean,
modifier: Modifier = Modifier,
onClick: () -> Unit = {},
) {
Button(
onClick = onClick,
enabled = enabled,
modifier = modifier
.fillMaxWidth()
.height(56.dp),
shape = RoundedCornerShape(12.dp),
colors = ButtonDefaults.buttonColors(
containerColor = LocalFeelinColors.current.systemActivate,
disabledContainerColor = LocalFeelinColors.current.systemDisable,
)
) {
Text(
text = text,
style = FeelinTypography.title2,
color = LocalFeelinColors.current.gray00,
)
}
}

@Preview(showBackground = true)
@Composable
private fun FeelinNormalButtonPreview() {
FeelinTheme {
FeelinNormalButton(
text = "완료",
enabled = true,
onClick = {},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.input.TextFieldState
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -34,6 +31,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.lyrics.feelin.core.designsystem.component.FeelinModalDialog
import com.lyrics.feelin.core.designsystem.component.FeelinNicknameInputField
import com.lyrics.feelin.core.designsystem.component.FeelinNormalButton
import com.lyrics.feelin.core.designsystem.component.FeelinTopAppBarWithBack
import com.lyrics.feelin.core.designsystem.component.NicknameValidationResult
import com.lyrics.feelin.core.designsystem.component.ProfileCharacter
Expand Down Expand Up @@ -126,7 +124,7 @@ fun EditProfileScreen(

Spacer(modifier = Modifier.weight(1f))

CompleteButton(
FeelinNormalButton(
text = "프로필 저장",
enabled = isNicknameValid && hasChanges,
onClick = {
Expand Down Expand Up @@ -213,28 +211,6 @@ private fun ProfileImageSelectorWithEdit(
}
}

@Composable
private fun CompleteButton(text: String, enabled: Boolean, onClick: () -> Unit) {
Button(
onClick = onClick,
enabled = enabled,
modifier = Modifier
.fillMaxWidth()
.height(56.dp),
shape = RoundedCornerShape(12.dp),
colors = ButtonDefaults.buttonColors(
containerColor = LocalFeelinColors.current.systemActivate,
disabledContainerColor = LocalFeelinColors.current.systemDisable
)
) {
Text(
text = text,
style = FeelinTypography.title2,
color = LocalFeelinColors.current.gray00
)
}
}

@Preview
@Composable
private fun EditProfileScreenPreview() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.input.TextFieldState
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -34,6 +31,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.lyrics.feelin.core.designsystem.component.FeelinModalDialog
import com.lyrics.feelin.core.designsystem.component.FeelinNicknameInputField
import com.lyrics.feelin.core.designsystem.component.FeelinNormalButton
import com.lyrics.feelin.core.designsystem.component.FeelinTopAppBarWithBack
import com.lyrics.feelin.core.designsystem.component.NicknameValidationResult
import com.lyrics.feelin.core.designsystem.component.ProfileCharacter
Expand Down Expand Up @@ -122,7 +120,7 @@ fun ProfileScreen(

Spacer(modifier = Modifier.weight(1f))

CompleteButton(
FeelinNormalButton(
text = "완료",
enabled = isNicknameValid,
onClick = {
Expand Down Expand Up @@ -204,28 +202,6 @@ private fun ProfileImageSelectorWithEdit(
}
}

@Composable
private fun CompleteButton(text: String, enabled: Boolean, onClick: () -> Unit) {
Button(
onClick = onClick,
enabled = enabled,
modifier = Modifier
.fillMaxWidth()
.height(56.dp),
shape = RoundedCornerShape(12.dp),
colors = ButtonDefaults.buttonColors(
containerColor = LocalFeelinColors.current.systemActivate,
disabledContainerColor = LocalFeelinColors.current.systemDisable
)
) {
Text(
text = text,
style = FeelinTypography.title2,
color = LocalFeelinColors.current.gray00
)
}
}

@Preview
@Composable
private fun ProfileScreenPreview() {
Expand Down
Loading