Skip to content

Commit 53ac6e6

Browse files
authored
Merge pull request #269 from GSM-MSG/feature/268_create_datepicker
๐Ÿ”€ :: (#268) - Date Picker ์ œ์ž‘
2 parents 4bdc086 + 94e7391 commit 53ac6e6

File tree

6 files changed

+127
-13
lines changed

6 files changed

+127
-13
lines changed

โ€ŽbuildSrc/src/main/java/Dependency.kt

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ object Dependency {
4141
const val OKHTTP_LOGGING_INTERCEPTOR =
4242
"com.squareup.okhttp3:logging-interceptor:${Versions.OKHTTP}"
4343
const val COIL = "io.coil-kt:coil-compose:${Versions.COIL}"
44+
const val NUMBER_PICKER = "com.chargemap.compose:numberpicker:${Versions.NUMBER_PICKER}"
4445
}
4546

4647
object Msg {

โ€ŽbuildSrc/src/main/java/Versions.kt

+2
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ object Versions {
3333
const val COIL = "2.4.0"
3434

3535
const val LOTTIE_COMPOSE = "6.1.0"
36+
37+
const val NUMBER_PICKER = "1.0.3"
3638
}

โ€Ždesign-system/build.gradle.kts

+2
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,6 @@ dependencies {
6565

6666
implementation(Dependency.Google.HILT)
6767
kapt(Dependency.Google.HILT_COMPILER)
68+
69+
implementation(Dependency.Libraries.NUMBER_PICKER)
6870
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package com.msg.sms.design.component.picker
2+
3+
import androidx.compose.foundation.background
4+
import androidx.compose.foundation.layout.*
5+
import androidx.compose.foundation.shape.RoundedCornerShape
6+
import androidx.compose.runtime.Composable
7+
import androidx.compose.runtime.mutableStateOf
8+
import androidx.compose.runtime.remember
9+
import androidx.compose.ui.Alignment
10+
import androidx.compose.ui.Modifier
11+
import androidx.compose.ui.draw.clip
12+
import androidx.compose.ui.graphics.Color
13+
import androidx.compose.ui.text.TextStyle
14+
import androidx.compose.ui.text.font.FontWeight
15+
import androidx.compose.ui.tooling.preview.Preview
16+
import androidx.compose.ui.unit.dp
17+
import androidx.compose.ui.unit.sp
18+
import com.chargemap.compose.numberpicker.NumberPicker
19+
import com.msg.sms.design.theme.SMSTheme
20+
21+
@Composable
22+
fun SmsDatePicker(
23+
yearValue: Int,
24+
monthValue: Int,
25+
yearRange: Iterable<Int>,
26+
monthRange: Iterable<Int>,
27+
onYearValueChange: (Int) -> Unit,
28+
onMonthValueChange: (Int) -> Unit
29+
) {
30+
SMSTheme { colors, typography ->
31+
Box(
32+
modifier = Modifier
33+
.fillMaxWidth()
34+
.padding(horizontal = 20.dp)
35+
) {
36+
Box(
37+
modifier = Modifier
38+
.fillMaxWidth()
39+
.height(35.dp)
40+
.clip(RoundedCornerShape(8.dp))
41+
.background(colors.N10)
42+
.align(Alignment.Center)
43+
)
44+
Row(
45+
modifier = Modifier
46+
.align(Alignment.Center)
47+
.height(163.dp),
48+
verticalAlignment = Alignment.CenterVertically
49+
) {
50+
NumberPicker(
51+
value = yearValue,
52+
modifier = Modifier
53+
.weight(1f)
54+
.fillMaxHeight(),
55+
range = yearRange,
56+
dividersColor = Color.Transparent,
57+
textStyle = TextStyle(
58+
fontFamily = typography.pretendard,
59+
fontSize = 20.sp,
60+
lineHeight = 24.sp,
61+
fontWeight = FontWeight.Bold
62+
),
63+
onValueChange = onYearValueChange
64+
)
65+
NumberPicker(
66+
value = monthValue,
67+
modifier = Modifier
68+
.weight(1f)
69+
.fillMaxHeight(),
70+
range = monthRange,
71+
dividersColor = Color.Transparent,
72+
textStyle = TextStyle(
73+
fontFamily = typography.pretendard,
74+
fontSize = 20.sp,
75+
lineHeight = 24.sp,
76+
fontWeight = FontWeight.Bold
77+
),
78+
onValueChange = onMonthValueChange
79+
)
80+
}
81+
}
82+
}
83+
}
84+
85+
@Preview
86+
@Composable
87+
fun DatePickerPre() {
88+
val month = remember {
89+
mutableStateOf(0)
90+
}
91+
val year = remember {
92+
mutableStateOf(0)
93+
}
94+
SmsDatePicker(
95+
monthValue = month.value,
96+
yearValue = year.value,
97+
monthRange = 0..12,
98+
yearRange = 2000..2030,
99+
onMonthValueChange = {},
100+
onYearValueChange = {}
101+
)
102+
}

โ€Ždesign-system/src/main/java/com/msg/sms/design/theme/SMSTypography.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import com.sms.design_system.R
1010

1111
object SMSTypography {
1212

13-
private val pretendard = FontFamily(
13+
internal val pretendard = FontFamily(
1414
Font(R.font.pretendard_extralight, FontWeight.ExtraLight),
1515
Font(R.font.pretendard_thin, FontWeight.Thin),
1616
Font(R.font.pretendard_light, FontWeight.Light),

โ€Žpresentation/src/main/java/com/sms/presentation/main/ui/fill_out_information/screen/ProjectsScreen.kt

+19-12
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import androidx.navigation.NavController
2020
import com.msg.sms.design.component.SmsDialog
2121
import com.msg.sms.design.component.button.ButtonState
2222
import com.msg.sms.design.component.button.SmsRoundedButton
23+
import com.msg.sms.design.component.picker.SmsDatePicker
2324
import com.msg.sms.design.component.toggle.ToggleComponent
2425
import com.msg.sms.design.modifier.smsClickable
2526
import com.msg.sms.design.theme.SMSTheme
@@ -115,12 +116,18 @@ fun ProjectsScreen(
115116

116117
bottomSheetContent(
117118
content = {
118-
val month = remember {
119+
val year = remember {
119120
mutableStateOf(0)
120121
}
121-
val year = remember {
122+
val month = remember {
122123
mutableStateOf(0)
123124
}
125+
val yearRange = remember {
126+
mutableStateOf(2000..2030)
127+
}
128+
val monthRange = remember {
129+
mutableStateOf(1..12)
130+
}
124131

125132
SMSTheme { colors, typography ->
126133
Box(
@@ -150,15 +157,15 @@ fun ProjectsScreen(
150157
}
151158
)
152159
}
153-
Spacer(modifier = Modifier.height(19.dp))
154-
Row(
155-
modifier = Modifier
156-
.fillMaxWidth()
157-
.padding(38.dp),
158-
horizontalArrangement = Arrangement.Center
159-
) {
160-
//TODO (Kimhyunseung) - DatePicker ๊ตฌํ˜„ํ•ด์„œ ํ•œ๊บผ๋ฒˆ์— ์ปดํฌ๋„ŒํŠธ ๋ถ„๋ฆฌํ•˜๊ธฐ
161-
}
160+
Spacer(modifier = Modifier.height(16.dp))
161+
SmsDatePicker(
162+
yearValue = year.value,
163+
monthValue = month.value,
164+
yearRange = yearRange.value,
165+
monthRange = monthRange.value,
166+
onYearValueChange = { year.value = it },
167+
onMonthValueChange = { month.value = it }
168+
)
162169
}
163170
}
164171
)
@@ -206,7 +213,7 @@ fun ProjectsScreen(
206213
coroutineScope.launch { bottomSheetState.show() }
207214
},
208215
onEndDateCalendarClick = {
209-
isProjectStartDate.value = true
216+
isProjectStartDate.value = false
210217
coroutineScope.launch { bottomSheetState.show() }
211218
},
212219
onProgressButtonClick = {

0 commit comments

Comments
ย (0)