Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into add/#28-shadow-mod…
Browse files Browse the repository at this point in the history
…ifier
  • Loading branch information
Hyobeen-Park committed Jul 10, 2024
2 parents ecfa173 + 78b74fb commit 4bdd40c
Show file tree
Hide file tree
Showing 39 changed files with 883 additions and 113 deletions.
3 changes: 2 additions & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ dependencies {
// Kotlin
implementation(libs.kotlin)

// Lifecycle Ktx
// AndroidXDependencies
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.compose.saveable)

// Hilt
implementation(libs.hilt.android)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.terning.core.designsystem.component.bottomsheet

import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun TerningBasicBottomSheet(
modifier: Modifier = Modifier,
content: @Composable () -> Unit,
onDismissRequest: () -> Unit
) {
val sheetState = rememberModalBottomSheetState()

ModalBottomSheet(
onDismissRequest = {
onDismissRequest()
},
sheetState = sheetState,
modifier = modifier.navigationBarsPadding()
) {
content()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package com.terning.core.designsystem.component.box

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
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.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.terning.core.designsystem.theme.CalPink
import com.terning.core.designsystem.theme.CalPurple
import com.terning.core.designsystem.theme.Grey150
import com.terning.core.designsystem.theme.White

/**
* ScrapBox is made for easy customization of scrap box used in Calendar & Home Screen
*
* [modifier] must be assigned for assigning size of the box and padding
* [elevation] must be set greater than zero for shadow effect, mainly used in Calendar
* [borderWidth] must be set greater than zero for border effect, mainly used in Home
*/

@Composable
fun ScrapBox(
cornerRadius: Dp,
scrapColor: Color,
modifier: Modifier = Modifier,
elevation: Dp = 0.dp,
borderWidth: Dp = 0.dp,
borderColor: Color = Grey150,
content: @Composable () -> Unit,
) {
Box(
modifier = modifier
.border(
width = borderWidth,
color = borderColor,
RoundedCornerShape(cornerRadius),
)
.shadow(
elevation = elevation,
RoundedCornerShape(cornerRadius),
)
) {
Box(
modifier = Modifier
.background(
color = scrapColor,
shape = RoundedCornerShape(cornerRadius)
)
.fillMaxSize()
)
Box(
modifier = Modifier
.fillMaxSize()
.padding(start = 9.dp)
.background(
shape = RoundedCornerShape(
topEnd = cornerRadius, bottomEnd = cornerRadius
), color = White
)
) {
content()
}
}
}

@Preview(showBackground = true)
@Composable
fun BorderedScrapBoxPreview() {
ScrapBox(
modifier = Modifier
.height(116.dp)
.width(140.dp),
scrapColor = CalPink,
cornerRadius = 5.dp,
borderWidth = 1.dp
) {}
}

@Preview(showBackground = true)
@Composable
fun ShadowedScrapBoxPreview() {
ScrapBox(
modifier = Modifier
.height(height = 92.dp)
.fillMaxWidth(),
scrapColor = CalPurple,
cornerRadius = 10.dp,
elevation = 1.dp
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.terning.core.designsystem.component.button
import androidx.annotation.StringRes
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.ripple.LocalRippleTheme
Expand Down Expand Up @@ -46,6 +47,7 @@ fun TerningBasicButton(

CompositionLocalProvider(LocalRippleTheme provides NoRippleTheme) {
Button(
contentPadding = PaddingValues(paddingVertical),
modifier = modifier.fillMaxWidth(),
interactionSource = interactionSource,
enabled = isEnabled,
Expand All @@ -61,7 +63,6 @@ fun TerningBasicButton(
Text(
text = stringResource(id = text),
style = style,
modifier = modifier.padding(vertical = paddingVertical)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.SolidColor
import com.terning.core.designsystem.theme.Grey300
import com.terning.core.designsystem.theme.Grey400
import com.terning.core.designsystem.theme.TerningMain
import com.terning.core.designsystem.theme.TerningTheme

@Composable
Expand All @@ -12,18 +13,20 @@ fun SearchTextField(
onValueChange: (String) -> Unit,
hint: String,
leftIcon: Int,
readOnly: Boolean = false,
) {
TerningBasicTextField(
value = text,
onValueChange = onValueChange,
textStyle = TerningTheme.typography.button3,
textColor = Grey400,
cursorBrush = SolidColor(Grey300),
drawLineColor = Grey300,
drawLineColor = TerningMain,
strokeWidth = 2f,
hint = hint,
hintColor = Grey300,
leftIcon = leftIcon,
leftIconColor = Grey400,
leftIconColor = TerningMain,
readOnly = readOnly,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import com.terning.core.designsystem.theme.White
fun TerningBasicTextField(
value: String,
onValueChange: (String) -> Unit,
readOnly: Boolean = false,
textStyle: TextStyle,
textColor: Color,
hintColor: Color,
Expand All @@ -52,6 +51,7 @@ fun TerningBasicTextField(
helperMessage: String = "",
helperIcon: Int? = null,
helperColor: Color = TerningMain,
readOnly: Boolean = false,
) {
val keyboardController = LocalSoftwareKeyboardController.current
val focusManager = LocalFocusManager.current
Expand All @@ -62,7 +62,6 @@ fun TerningBasicTextField(
onValueChange = onValueChange,
singleLine = true,
maxLines = 1,
readOnly = readOnly,
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(
onDone = {
Expand Down Expand Up @@ -124,7 +123,9 @@ fun TerningBasicTextField(
)
}
}
})
},
readOnly = readOnly,
)

Row(
verticalAlignment = Alignment.CenterVertically,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
package com.terning.core.designsystem.component.topappbar

import androidx.compose.foundation.layout.padding
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.terning.core.R
import com.terning.core.designsystem.theme.TerningTheme
import com.terning.core.designsystem.theme.White

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand Down Expand Up @@ -49,5 +54,7 @@ fun TerningBasicTopAppBar(
action()
}
},
colors = TopAppBarDefaults.topAppBarColors(White),
modifier = Modifier.padding(horizontal = 16.dp)
)
}
17 changes: 11 additions & 6 deletions core/src/main/java/com/terning/core/designsystem/theme/Color.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,27 @@ val Black = Color(0xFF171717)
val TerningMain = Color(0xFF1EA65E)
val TerningMain2 = Color(0xFF179653)

// Sub Color
val TerningSub1 = Color(0xFF179653)
val TerningSub2 = Color(0xFF52C689)
val TerningSub3 = Color(0XFFE2F1E9)
val TerningSub4 = Color(0XFFE9F8F0)
val TerningSub5 = Color(0XFFF8FFFB)

// Background
val Back = Color(0xFFF8F8F8)
val ToastGrey = Color(0XFF666666)

// Calendar Color
val CalRed = Color(0xFFED4E54)

val CalOrange1 = Color(0xFFEE7647)
val CalOrange2 = Color(0xFF5397F3)

val CalYellow = Color(0xFFF5E660)

val CalGreen1 = Color(0xFFC4E953)
val CalGreen2 = Color(0xFF84D558)

val CalBlue1 = Color(0xFF45D0CC)
val CalBlue2 = Color(0xFF4119F2)

val CalPurple = Color(0xFF9B64E2)

val CalPink = Color(0xFFF260AC)

// Other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.runtime.staticCompositionLocalOf

private val LightColorScheme = lightColorScheme(
primary = TerningMain,
background = White
)

private val LocalTerningTypography = staticCompositionLocalOf<TerningTypography> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ package com.terning.core.extension
import java.time.LocalDate

fun LocalDate.getStringAsTitle(): String =
"${year}${monthValue.toString().padStart(2, '0')}"
"${year}${monthValue.toString().padStart(2, '0')}"

fun LocalDate.getWeekIndexContainingSelectedDate(): Int = dayOfMonth / 7

fun LocalDate.isToday(): Boolean = this == LocalDate.now()
6 changes: 2 additions & 4 deletions data/src/main/java/com/terning/data/dto/BaseResponse.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import kotlinx.serialization.Serializable
data class BaseResponse<T>(
@SerialName("status")
val status: Int,
@SerialName("code")
val code: String,
@SerialName("message")
val message: String,
@SerialName("data")
val data: T,
@SerialName("result")
val result: T,
)
1 change: 1 addition & 0 deletions feature/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ dependencies {
implementation(libs.androidx.workManager)
implementation(libs.hilt.compiler)
implementation(libs.androidx.lifecycle.runtime.compose.android)
implementation(libs.androidx.compose.saveable)

// KspDependencies
ksp(libs.hilt.android.compiler)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.terning.core.designsystem.theme.Grey150
import com.terning.core.designsystem.theme.TerningPointTheme
import com.terning.core.designsystem.theme.TerningTheme
import com.terning.core.extension.isToday
import com.terning.feature.calendar.models.MonthData
import com.terning.feature.calendar.models.Scrap
import com.terning.feature.calendar.models.SelectedDateState
import java.time.LocalDate
import java.time.YearMonth

Expand All @@ -26,7 +27,7 @@ fun CalendarMonth(
modifier: Modifier = Modifier,
monthData: MonthData,
onDateSelected: (LocalDate) -> Unit,
selectedDate: LocalDate,
selectedDate: SelectedDateState,
scrapLists: List<List<Scrap>> = listOf()
) {
Column(
Expand All @@ -48,8 +49,8 @@ fun CalendarMonth(
) {
CalendarDay(
dayData = day,
isSelected = selectedDate == day.date,
isToday = day.date == LocalDate.now(),
isSelected = selectedDate.selectedDate == day.date && selectedDate.isEnabled,
isToday = day.date.isToday(),
onDateSelected = onDateSelected
)
if(!day.isOutDate) {
Expand Down Expand Up @@ -79,7 +80,7 @@ fun CalendarMonthPreview() {
TerningPointTheme {
CalendarMonth(
monthData = MonthData(YearMonth.now()),
selectedDate = LocalDate.now(),
selectedDate = SelectedDateState(LocalDate.now(), true),
onDateSelected = {},
scrapLists = listOf()
)
Expand Down
Loading

0 comments on commit 4bdd40c

Please sign in to comment.