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
+ }
0 commit comments