Skip to content

Commit

Permalink
[MERGE/#214] develop -> #214
Browse files Browse the repository at this point in the history
  • Loading branch information
boiledEgg-s committed Sep 8, 2024
2 parents cdacbbd + 57a5058 commit ab8d72d
Show file tree
Hide file tree
Showing 82 changed files with 1,367 additions and 1,460 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.terning.core.R
import com.terning.core.designsystem.theme.TerningMain
import com.terning.core.designsystem.theme.TerningTheme
import com.terning.core.extension.noRippleClickable
import com.terning.core.type.ProfileImage
import kotlinx.coroutines.launch

/**
Expand All @@ -38,15 +39,15 @@ import kotlinx.coroutines.launch
* @param modifier ๋ฐ”ํ…€์‹œํŠธ์— ์ ์šฉํ•  Modifier์ž…๋‹ˆ๋‹ค.
* @param onDismiss ๋ฐ”ํ…€์‹œํŠธ๊ฐ€ ๋‹ซํž ๋•Œ ํ˜ธ์ถœ๋˜๋Š” ์ฝœ๋ฐฑ ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
* @param onSaveClick ์ €์žฅํ•˜๊ธฐ ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ, ํ˜ธ์ถœ๋˜๋Š” ์ฝœ๋ฐฑ ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
* @param initialSelectedOption ์ดˆ๊ธฐ์— ์„ ํƒ๋œ ์ด๋ฏธ์ง€๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ์ธ๋ฑ์Šค ๊ฐ’์ž…๋‹ˆ๋‹ค.
* @param initialSelectedOption ์ดˆ๊ธฐ์— ์„ ํƒ๋œ ์ด๋ฏธ์ง€์˜ ์ด๋ฆ„์„ ๋‚˜ํƒ€๋‚ด๋Š” string ๊ฐ’์ž…๋‹ˆ๋‹ค.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ProfileBottomSheet(
modifier: Modifier = Modifier,
onDismiss: () -> Unit,
onSaveClick: (Int) -> Unit,
initialSelectedOption: Int
onSaveClick: (ProfileImage) -> Unit,
initialSelectedOption: String
) {
val scope = rememberCoroutineScope()
val sheetState = rememberModalBottomSheetState()
Expand All @@ -64,11 +65,11 @@ fun ProfileBottomSheet(
),
)
RadioButtonGroup(
onOptionSelected = { index ->
onOptionSelected = { selectedProfile ->
scope.launch { sheetState.hide() }
.invokeOnCompletion {
if (!sheetState.isVisible) {
onSaveClick(index)
onSaveClick(selectedProfile)
}
}
},
Expand All @@ -82,38 +83,34 @@ fun ProfileBottomSheet(
)
}


/**
* 6๊ฐœ์˜ ํ”„๋กœํ•„ ์ด๋ฏธ์ง€ ์ค‘, ํ•˜๋‚˜์˜ ์ด๋ฏธ์ง€๋งŒ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” ๋ผ๋””์˜ค ๋ฒ„ํŠผ์ž…๋‹ˆ๋‹ค.
*
* @param onOptionSelected ์„ ํƒ๋œ ์ด๋ฏธ์ง€์˜ ์ธ๋ฑ์Šค ๊ฐ’์„ ๋‚˜ํƒ€๋‚ด๋Š” ์ฝœ๋ฐฑ ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
* @param initialSelectedOption ์ดˆ๊ธฐ์— ์„ ํƒ๋œ ์ด๋ฏธ์ง€๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ์ธ๋ฑ์Šค ๊ฐ’์ž…๋‹ˆ๋‹ค.
* @param onOptionSelected ์„ ํƒ๋œ ์ด๋ฏธ์ง€์˜ ์ด๋ฆ„์„ ๋‚˜ํƒ€๋‚ด๋Š” ์ฝœ๋ฐฑ ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
* @param initialSelectedOption ์ดˆ๊ธฐ์— ์„ ํƒ๋œ ์ด๋ฏธ์ง€์˜ ์ด๋ฆ„์„ ๋‚˜ํƒ€๋‚ด๋Š” string ๊ฐ’์ž…๋‹ˆ๋‹ค.
* @param modifier ๋ผ๋””์˜ค ๋ฒ„ํŠผ์— ์ ์šฉํ•  Modifier์ž…๋‹ˆ๋‹ค.
*/
@Composable
fun RadioButtonGroup(
onOptionSelected: (Int) -> Unit,
initialSelectedOption: Int,
onOptionSelected: (ProfileImage) -> Unit,
initialSelectedOption: String,
modifier: Modifier = Modifier,
) {
val options = listOf(
R.drawable.ic_terning_profile_00,
R.drawable.ic_terning_profile_01,
R.drawable.ic_terning_profile_02,
R.drawable.ic_terning_profile_03,
R.drawable.ic_terning_profile_04,
R.drawable.ic_terning_profile_05
)
val options = ProfileImage.entries

var selectedOption by rememberSaveable { mutableIntStateOf(options[initialSelectedOption]) }
var selectedOptionIndex by rememberSaveable {
mutableIntStateOf(ProfileImage.toIndex(ProfileImage.fromString(initialSelectedOption)))
}

LazyVerticalGrid(
columns = GridCells.Fixed(3),
verticalArrangement = Arrangement.spacedBy(8.dp),
horizontalArrangement = Arrangement.spacedBy(20.dp),
modifier = modifier.padding(horizontal = 34.dp)
) {
itemsIndexed(options) { index, option ->
val imageModifier = if (selectedOption == options[index]) {
itemsIndexed(options.take(6)) { index, option ->
val imageModifier = if (selectedOptionIndex == index) {
Modifier
.border(
color = TerningMain,
Expand All @@ -126,19 +123,17 @@ fun RadioButtonGroup(
}

Image(
painter = painterResource(
id = option
),
painter = painterResource(id = option.drawableResId),
contentDescription = "profile image",
modifier = imageModifier
.noRippleClickable {
onOptionSelected(index)
selectedOption = option
onOptionSelected(option)
selectedOptionIndex = index
}
.clip(shape = CircleShape)
.size(76.dp)
.aspectRatio(1f)
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.terning.core.R
import com.terning.core.designsystem.theme.Grey400
import com.terning.core.designsystem.theme.Grey150
import com.terning.core.designsystem.theme.Grey200
import com.terning.core.designsystem.theme.Grey375
import com.terning.core.designsystem.theme.TerningMain
import com.terning.core.designsystem.theme.TerningPointTheme
import com.terning.core.designsystem.theme.TerningSub1
import com.terning.core.designsystem.theme.TerningSub3
import com.terning.core.designsystem.theme.TerningSub4
import com.terning.core.designsystem.theme.TerningSub5
import com.terning.core.designsystem.theme.TerningTheme
import com.terning.core.designsystem.theme.White
import com.terning.core.util.NoRippleTheme
Expand Down Expand Up @@ -58,19 +56,16 @@ fun FilteringButton(
) {
val interactionSource = remember { MutableInteractionSource() }
val isPressed by interactionSource.collectIsPressedAsState()
val backgroundColor = when {
!isSelected && !isPressed -> White
!isSelected && isPressed -> TerningSub5
isSelected && !isPressed -> TerningSub4
else -> TerningSub3
}
val backgroundColor = White
val textColor = when {
!isSelected -> Grey400
!isSelected -> Grey375
isPressed -> Grey375
else -> TerningMain
}
val borderColor = when {
!isSelected -> TerningMain
else -> TerningSub1
!isSelected && !isPressed -> Grey150
isPressed -> Grey200
else -> TerningMain
}

CompositionLocalProvider(LocalRippleTheme provides NoRippleTheme) {
Expand All @@ -87,7 +82,7 @@ fun FilteringButton(
color = borderColor
),
shape = RoundedCornerShape(cornerRadius),
onClick = { onButtonClick() }
onClick = onButtonClick
) {
Text(
text = stringResource(id = text),
Expand All @@ -104,14 +99,14 @@ fun FilteringButtonPreview() {
TerningPointTheme {
Column {
FilteringButton(
isSelected = true,
isSelected = false,
text = R.string.button_preview,
cornerRadius = 15.dp,
paddingVertical = 10.dp,
onButtonClick = {}
)
FilteringButton(
isSelected = false,
isSelected = true,
text = R.string.button_preview,
cornerRadius = 15.dp,
paddingVertical = 10.dp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,20 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.terning.core.R
import com.terning.core.type.ProfileImage

@Composable
fun ProfileWithPlusButton(
index: Int,
profileImage: String,
modifier: Modifier = Modifier,
) {
val grade = when (index) {
0 -> R.drawable.ic_terning_profile_00
1 -> R.drawable.ic_terning_profile_01
2 -> R.drawable.ic_terning_profile_02
3 -> R.drawable.ic_terning_profile_03
4 -> R.drawable.ic_terning_profile_04
else -> R.drawable.ic_terning_profile_05
}
val userProfile = ProfileImage.fromString(profileImage)

Box(
modifier = modifier.wrapContentWidth()
) {
Image(
painterResource(id = grade),
painterResource(id = userProfile.drawableResId),
contentDescription = "profile image",
modifier = modifier
.clip(shape = CircleShape)
Expand All @@ -51,5 +45,5 @@ fun ProfileWithPlusButton(
@Preview(showBackground = true)
@Composable
fun ProfileWithPlusButtonPreview() {
ProfileWithPlusButton(index = 1)
ProfileWithPlusButton(profileImage = "basic")
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@ package com.terning.core.designsystem.component.item
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.RectangleShape
import com.airbnb.lottie.compose.LottieAnimation
import com.airbnb.lottie.compose.LottieCompositionSpec
import com.airbnb.lottie.compose.rememberLottieComposition

@Composable
fun TerningLottieAnimation(
jsonString: String,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
iterations: Int = 1,
) {
val lottieComposition by rememberLottieComposition(LottieCompositionSpec.Asset(jsonString))
LottieAnimation(
modifier = modifier,
composition = lottieComposition
modifier = modifier.clip(RectangleShape),
composition = lottieComposition,
iterations = iterations,
clipToCompositionBounds = false
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.terning.core.designsystem.component.snackbar

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp
import com.terning.core.designsystem.theme.Grey500

@Composable
fun TerningBasicSnackBar(content: @Composable () -> Unit) {
Box(
modifier = Modifier
.clip(CircleShape)
.background(Grey500)
.padding(vertical = 7.dp, horizontal = 20.dp)
) {
content()
}
}
7 changes: 7 additions & 0 deletions core/src/main/java/com/terning/core/extension/CalendarExt.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.terning.core.extension

import java.util.Calendar

val Calendar.currentYear: Int get() = get(Calendar.YEAR)

val Calendar.currentMonth: Int get() = get(Calendar.MONTH) + 1
33 changes: 33 additions & 0 deletions core/src/main/java/com/terning/core/type/ProfileImage.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.terning.core.type

import androidx.annotation.DrawableRes
import com.terning.core.R

enum class ProfileImage(
@DrawableRes val drawableResId: Int,
val stringValue: String
) {

BASIC(drawableResId = R.drawable.ic_terning_profile_00, stringValue = "basic"),
LUCKY(drawableResId = R.drawable.ic_terning_profile_01, stringValue = "lucky"),
SMART(drawableResId = R.drawable.ic_terning_profile_02, stringValue = "smart"),
GLASS(drawableResId = R.drawable.ic_terning_profile_03, stringValue = "glass"),
CALENDAR(drawableResId = R.drawable.ic_terning_profile_04, stringValue = "calendar"),
PASSION(drawableResId = R.drawable.ic_terning_profile_05, stringValue = "passion"),
DEFAULT(drawableResId = R.drawable.ic_terning_profile_default, stringValue = "default");

companion object {
fun fromString(value: String): ProfileImage = when (value) {
"basic" -> BASIC
"lucky" -> LUCKY
"smart" -> SMART
"glass" -> GLASS
"calendar" -> CALENDAR
"passion" -> PASSION
else -> BASIC
}

fun toIndex(profileImage: ProfileImage): Int =
entries.indexOf(profileImage)
}
}
8 changes: 8 additions & 0 deletions core/src/main/java/com/terning/core/util/CalendarDefaults.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.terning.core.util

object CalendarDefaults {
const val START_YEAR = 2010
const val END_YEAR = 2030
const val START_MONTH = 1
const val END_MONTH = 12
}
Loading

0 comments on commit ab8d72d

Please sign in to comment.