Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/MZ-129-my-statistics' in…
Browse files Browse the repository at this point in the history
…to feature/MZ-129-my-statistics
  • Loading branch information
yangsooplus committed Jan 25, 2024
2 parents 5c00d78 + 7f450c1 commit eaedf5b
Show file tree
Hide file tree
Showing 49 changed files with 1,327 additions and 82 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.susu.core.designsystem.component.appbar.icon

import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import com.susu.core.designsystem.R
import com.susu.core.designsystem.theme.Gray100
import com.susu.core.designsystem.theme.SusuTheme

@Composable
fun RegisterText(
modifier: Modifier = Modifier,
color: Color = Gray100,
) {
Text(
modifier = modifier,
text = stringResource(com.susu.core.ui.R.string.word_register),
style = SusuTheme.typography.title_xxs,
color = color,
)
}

@Preview
@Composable
fun RegisterTextPreview() {
SusuTheme {
RegisterText()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import androidx.compose.ui.unit.dp
import com.susu.core.designsystem.theme.Gray100
import com.susu.core.designsystem.theme.Gray30
import com.susu.core.designsystem.theme.SusuTheme
import com.susu.core.ui.extension.susuClickable

@OptIn(ExperimentalFoundationApi::class)
@Composable
Expand All @@ -41,21 +42,31 @@ fun <T> InfiniteColumn(
textColor: Color = Gray30,
selectedTextColor: Color = Gray100,
onItemSelected: (index: Int, item: T) -> Unit = { _, _ -> },
onItemClicked: (item: T) -> Unit = { },
) {
val itemHalfHeight = LocalDensity.current.run { itemHeight.toPx() / 2f }
var lastSelectedIndex by remember { mutableStateOf(0) }
var itemsState by remember { mutableStateOf(items) }
val lazyListState = rememberLazyListState(0)
val flingBehavior: FlingBehavior = rememberSnapFlingBehavior(lazyListState)
var clickedIndex: Int? by remember { mutableStateOf(null) }

LaunchedEffect(items) {
LaunchedEffect(key1 = items) {
var targetIndex = items.indexOf(initialItem)
targetIndex += ((Int.MAX_VALUE / 2) / items.size) * items.size
itemsState = items
lastSelectedIndex = targetIndex
lazyListState.scrollToItem(targetIndex - 2, scrollOffset = (itemHeight.value * 0.6f).toInt())
}

LaunchedEffect(clickedIndex) {
if (clickedIndex != null) {
lastSelectedIndex = clickedIndex!!
val targetIndex = clickedIndex!! - 2
lazyListState.animateScrollToItem(targetIndex, scrollOffset = (itemHeight.value * 0.6f).toInt())
}
}

LazyColumn(
modifier = modifier.height(itemHeight * numberOfDisplayedItems),
state = lazyListState,
Expand Down Expand Up @@ -85,6 +96,13 @@ fun <T> InfiniteColumn(
contentAlignment = Alignment.Center,
) {
Text(
modifier = Modifier.susuClickable(
onClick = {
clickedIndex = i
onItemClicked(item)
},
rippleEnabled = false,
),
text = item.toString(),
style = if (lastSelectedIndex == i) {
selectedTextStyle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ fun SusuDatePickerBottomSheet(
}
onItemSelected(selectedYear, selectedMonth, selectedDay)
},
onItemClicked = { item ->
selectedYear = item.dropLast(1).toIntOrNull() ?: currentDate.year
},
)
InfiniteColumn(
modifier = Modifier.width(100.dp),
Expand All @@ -95,6 +98,9 @@ fun SusuDatePickerBottomSheet(
}
onItemSelected(selectedYear, selectedMonth, selectedDay)
},
onItemClicked = { item ->
selectedMonth = item.dropLast(1).toIntOrNull() ?: currentDate.monthValue
},
)
InfiniteColumn(
modifier = Modifier.width(100.dp),
Expand All @@ -106,6 +112,9 @@ fun SusuDatePickerBottomSheet(
selectedDay = item.dropLast(1).toIntOrNull() ?: 1
onItemSelected(selectedYear, selectedMonth, selectedDay)
},
onItemClicked = { item ->
selectedMonth = item.dropLast(1).toIntOrNull() ?: 1
},
)
}
}
Expand Down Expand Up @@ -170,6 +179,7 @@ fun SusuLimitDatePickerBottomSheet(
initialMonth == criteriaMonth && initialDay > criteriaDay
)
-> criteriaDay

else -> initialDay
},
)
Expand Down Expand Up @@ -234,6 +244,9 @@ fun SusuLimitDatePickerBottomSheet(
selectedYear = item.dropLast(1).toIntOrNull() ?: criteriaYear
onItemSelected(selectedYear, selectedMonth, selectedDay)
},
onItemClicked = { item ->
selectedYear = item.dropLast(1).toIntOrNull() ?: criteriaYear
},
)
if (monthRange.count() > 1) {
InfiniteColumn(
Expand All @@ -246,6 +259,9 @@ fun SusuLimitDatePickerBottomSheet(
selectedMonth = item.dropLast(1).toIntOrNull() ?: criteriaMonth
onItemSelected(selectedYear, selectedMonth, selectedDay)
},
onItemClicked = { item ->
selectedMonth = item.dropLast(1).toIntOrNull() ?: criteriaMonth
},
)
} else {
selectedMonth = criteriaMonth
Expand Down Expand Up @@ -276,6 +292,9 @@ fun SusuLimitDatePickerBottomSheet(
selectedDay = item.dropLast(1).toIntOrNull() ?: 1
onItemSelected(selectedYear, selectedMonth, selectedDay)
},
onItemClicked = { item ->
selectedDay = item.dropLast(1).toIntOrNull() ?: 1
},
)
} else {
selectedDay = criteriaDay
Expand Down Expand Up @@ -312,10 +331,12 @@ fun SusuYearPickerBottomSheet(
cornerRadius: Dp = 24.dp,
onDismissRequest: (Int) -> Unit = {},
onItemSelected: (Int) -> Unit = {},
onItemClicked: (Int) -> Unit = {},
) {
val currentYear = remember { LocalDate.now().year }
var selectedYear by remember { mutableIntStateOf(initialYear ?: currentYear) }
val yearList = yearRange.map { stringResource(id = R.string.word_year_format, it) }.toImmutableList()
val yearList =
(yearRange.map { stringResource(id = R.string.word_year_format, it) } + listOf(stringResource(R.string.word_not_select))).toImmutableList()
SusuBottomSheet(
sheetState = sheetState,
containerHeight = minOf(maximumContainerHeight, itemHeight * numberOfDisplayedItems + 32.dp),
Expand All @@ -331,9 +352,10 @@ fun SusuYearPickerBottomSheet(
itemHeight = itemHeight,
numberOfDisplayedItems = numberOfDisplayedItems,
onItemSelected = { _, item ->
selectedYear = item.dropLast(1).toIntOrNull() ?: currentYear
selectedYear = item.dropLast(1).toIntOrNull() ?: 0
onItemSelected(selectedYear)
},
onItemClicked = { onItemClicked(it.dropLast(1).toIntOrNull() ?: 0) },
)
}
}
Expand Down Expand Up @@ -367,3 +389,12 @@ fun SusuLimitDatePickerBottomSheetPreview() {
)
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Preview
@Composable
fun SusuYearPickerBottomSheetPreview() {
SusuTheme {
SusuYearPickerBottomSheet(maximumContainerHeight = 300.dp)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.susu.core.ui.extension.susuClickable
fun BasicButton(
modifier: Modifier = Modifier,
shape: Shape = RectangleShape,
textModifier: Modifier = Modifier,
text: String? = null,
textStyle: TextStyle = TextStyle.Default,
contentColor: Color = Color.Unspecified,
Expand Down Expand Up @@ -72,6 +73,7 @@ fun BasicButton(

text?.let {
Text(
modifier = textModifier,
text = it,
style = textStyle,
color = contentColor,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,48 @@
package com.susu.core.designsystem.component.button

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
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
import androidx.compose.ui.unit.dp
import com.susu.core.designsystem.R
import com.susu.core.designsystem.theme.Gray10
import com.susu.core.designsystem.theme.Gray30
import com.susu.core.ui.extension.susuClickable

@Composable
fun ClearIconButton(
iconSize: Dp,
tint: Color = Gray30,
onClick: () -> Unit,
) {
Image(
Icon(
modifier = Modifier
.clip(CircleShape)
.background(tint)
.size(iconSize)
.susuClickable(onClick = onClick),
painter = painterResource(id = R.drawable.ic_clear),
painter = painterResource(id = com.susu.core.ui.R.drawable.ic_close),
contentDescription = "",
tint = Gray10,
)
}

@Preview
@Composable
fun ClearIconButtonPreview() {
Column {
ClearIconButton(
iconSize = 24.dp,
onClick = {},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.susu.core.designsystem.R
Expand Down Expand Up @@ -49,6 +50,8 @@ enum class FilledButtonColor(
fun SusuFilledButton(
modifier: Modifier = Modifier,
shape: Shape = RoundedCornerShape(4.dp),
textModifier: Modifier = Modifier,
textAlign: TextAlign = TextAlign.Unspecified,
text: String? = null,
color: FilledButtonColor,
style: @Composable () -> ButtonStyle,
Expand All @@ -63,8 +66,9 @@ fun SusuFilledButton(
BasicButton(
modifier = modifier,
shape = shape,
textModifier = textModifier,
text = text,
textStyle = textStyle,
textStyle = textStyle.copy(textAlign = textAlign),
contentColor = if (isActive) activeContentColor else inactiveContentColor,
rippleColor = rippleColor,
backgroundColor = if (isActive) activeBackgroundColor else inactiveBackgroundColor,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.susu.core.designsystem.component.button

import androidx.annotation.DrawableRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
Expand All @@ -12,6 +13,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.shadow
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 com.susu.core.designsystem.R
Expand All @@ -23,6 +25,7 @@ import com.susu.core.ui.extension.susuClickable
@Composable
fun SusuFloatingButton(
modifier: Modifier = Modifier,
@DrawableRes imageResId: Int = R.drawable.ic_floating_button_add,
onClick: () -> Unit = {},
) {
Box(
Expand All @@ -34,7 +37,10 @@ fun SusuFloatingButton(
.susuClickable(rippleColor = Gray10, onClick = onClick),
contentAlignment = Alignment.Center,
) {
Image(painter = painterResource(id = R.drawable.ic_floating_button_add), contentDescription = "추가 아이콘")
Image(
painter = painterResource(id = imageResId),
contentDescription = stringResource(id = com.susu.core.ui.R.string.content_description_add_button),
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.susu.core.designsystem.R
Expand Down Expand Up @@ -49,6 +50,8 @@ enum class GhostButtonColor(
fun SusuGhostButton(
modifier: Modifier = Modifier,
shape: Shape = RoundedCornerShape(4.dp),
textModifier: Modifier = Modifier,
textAlign: TextAlign = TextAlign.Unspecified,
text: String? = null,
color: GhostButtonColor,
style: @Composable () -> ButtonStyle,
Expand All @@ -64,8 +67,9 @@ fun SusuGhostButton(
BasicButton(
modifier = modifier,
shape = shape,
textModifier = textModifier,
text = text,
textStyle = textStyle,
textStyle = textStyle.copy(textAlign = textAlign),
contentColor = if (isActive) activeContentColor else inactiveContentColor,
rippleColor = rippleColor,
backgroundColor = if (isActive) activeBackgroundColor else inactiveBackgroundColor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.susu.core.designsystem.R
Expand Down Expand Up @@ -56,6 +57,8 @@ enum class LinedButtonColor(
fun SusuLinedButton(
modifier: Modifier = Modifier,
shape: Shape = RoundedCornerShape(4.dp),
textModifier: Modifier = Modifier,
textAlign: TextAlign = TextAlign.Unspecified,
text: String? = null,
color: LinedButtonColor,
style: @Composable () -> ButtonStyle,
Expand All @@ -70,8 +73,9 @@ fun SusuLinedButton(
BasicButton(
modifier = modifier,
shape = shape,
textModifier = textModifier,
text = text,
textStyle = textStyle,
textStyle = textStyle.copy(textAlign = textAlign),
borderWidth = 1.dp,
borderColor = if (isActive) activeBorderColor else inactiveBorderColor,
contentColor = if (isActive) activeContentColor else inactiveContentColor,
Expand Down
Loading

0 comments on commit eaedf5b

Please sign in to comment.