11package team.aliens.dms.android.feature.main.application
22
3+ import android.R.id.tabs
34import androidx.compose.animation.AnimatedVisibility
45import androidx.compose.animation.animateContentSize
56import androidx.compose.animation.fadeIn
@@ -13,28 +14,40 @@ import androidx.compose.foundation.layout.Box
1314import androidx.compose.foundation.layout.Column
1415import androidx.compose.foundation.layout.PaddingValues
1516import androidx.compose.foundation.layout.Row
17+ import androidx.compose.foundation.layout.Spacer
18+ import androidx.compose.foundation.layout.fillMaxHeight
1619import androidx.compose.foundation.layout.fillMaxSize
1720import androidx.compose.foundation.layout.fillMaxWidth
21+ import androidx.compose.foundation.layout.height
1822import androidx.compose.foundation.layout.padding
1923import androidx.compose.foundation.layout.size
24+ import androidx.compose.foundation.layout.width
2025import androidx.compose.foundation.lazy.LazyColumn
2126import androidx.compose.foundation.lazy.items
2227import androidx.compose.foundation.pager.HorizontalPager
2328import androidx.compose.foundation.pager.rememberPagerState
2429import androidx.compose.foundation.shape.CircleShape
2530import androidx.compose.material3.Card
2631import androidx.compose.material3.CardDefaults
32+ import androidx.compose.material3.Divider
2733import androidx.compose.material3.ExperimentalMaterial3Api
34+ import androidx.compose.material3.Tab
2835import androidx.compose.material3.Text
2936import androidx.compose.runtime.Composable
3037import androidx.compose.runtime.getValue
38+ import androidx.compose.runtime.mutableStateOf
39+ import androidx.compose.runtime.remember
40+ import androidx.compose.runtime.setValue
3141import androidx.compose.ui.Alignment
3242import androidx.compose.ui.Modifier
3343import androidx.compose.ui.draw.clip
44+ import androidx.compose.ui.graphics.Color
3445import androidx.compose.ui.platform.LocalLifecycleOwner
3546import androidx.compose.ui.res.stringResource
47+ import androidx.compose.ui.text.font.FontWeight
3648import androidx.compose.ui.text.style.TextAlign
3749import androidx.compose.ui.unit.dp
50+ import androidx.compose.ui.unit.sp
3851import androidx.hilt.navigation.compose.hiltViewModel
3952import androidx.lifecycle.compose.collectAsStateWithLifecycle
4053import com.ramcosta.composedestinations.annotation.Destination
@@ -45,6 +58,7 @@ import team.aliens.dms.android.core.designsystem.DmsTheme
4558import team.aliens.dms.android.core.designsystem.DmsTopAppBar
4659import team.aliens.dms.android.core.designsystem.RoundedButton
4760import team.aliens.dms.android.core.designsystem.Scaffold
61+ import team.aliens.dms.android.core.designsystem.clickable
4862import team.aliens.dms.android.core.designsystem.shadow
4963import team.aliens.dms.android.core.ui.ExtraLargeVerticalSpace
5064import team.aliens.dms.android.core.ui.PaddingDefaults
@@ -71,6 +85,8 @@ internal fun ApplicationScreen(
7185 val viewModel: ApplicationViewModel = hiltViewModel()
7286 val uiState by viewModel.stateFlow.collectAsStateWithLifecycle()
7387 val pagerState = rememberPagerState(pageCount = { 2 })
88+ var selectedTab by remember { mutableStateOf(0 ) }
89+ val tabs = listOf (" 신청" , " 투표" )
7490
7591 LocalLifecycleOwner .current.lifecycle.addObserver(viewModel)
7692
@@ -79,19 +95,45 @@ internal fun ApplicationScreen(
7995 topBar = {
8096 DmsTopAppBar (
8197 title = {
82- Box (
83- modifier = Modifier
84- .fillMaxWidth()
85- .padding(end = 12 .dp),
86- contentAlignment = Alignment .Center ,
98+ Column (
99+ modifier = Modifier .background(Color .White )
87100 ) {
88- Text (
89- text = when (pagerState.currentPage) {
90- 0 -> stringResource(R .string.application)
91- else -> stringResource(R .string.voting_submit)
92- },
93- textAlign = TextAlign .Center ,
94- style = DmsTheme .typography.body2,
101+ Row (
102+ modifier = Modifier
103+ .fillMaxWidth()
104+ .height(56 .dp),
105+ horizontalArrangement = Arrangement .Center
106+ ) {
107+ tabs.forEachIndexed { index, title ->
108+ Box (
109+ modifier = Modifier
110+ .weight(1f )
111+ .fillMaxHeight()
112+ .clickable { selectedTab = index },
113+ contentAlignment = Alignment .Center
114+ ) {
115+ Text (
116+ text = title,
117+ style = DmsTheme .typography.body2,
118+ color = Color .Black ,
119+ )
120+ if (selectedTab == index) {
121+ Box (
122+ modifier = Modifier
123+ .fillMaxWidth()
124+ .height(2 .dp)
125+ .background( if (selectedTab == index) Color .Black else DmsTheme .colorScheme.line)
126+ .align(Alignment .BottomCenter )
127+ )
128+ }
129+ }
130+ }
131+ }
132+ Box (
133+ modifier = Modifier
134+ .fillMaxWidth()
135+ .height(1 .dp)
136+ .background(Color (0xFFE5E5E5 ))
95137 )
96138 }
97139 },
@@ -109,27 +151,6 @@ internal fun ApplicationScreen(
109151 .align(Alignment .Start ),
110152 state = pagerState,
111153 ) { page ->
112- Row (
113- modifier = Modifier
114- .fillMaxWidth()
115- .padding(vertical = 16 .dp),
116- horizontalArrangement = Arrangement .Center ,
117- ) {
118- repeat(pagerState.pageCount) { index ->
119- val color = if (pagerState.currentPage == index) {
120- DmsTheme .colorScheme.backgroundVariant
121- } else {
122- DmsTheme .colorScheme.onSurfaceVariant
123- }
124- Box (
125- modifier = Modifier
126- .padding(horizontal = 4 .dp)
127- .clip(CircleShape )
128- .background(color)
129- .size(8 .dp),
130- )
131- }
132- }
133154 Column (
134155 modifier = Modifier
135156 .fillMaxSize()
@@ -141,7 +162,7 @@ internal fun ApplicationScreen(
141162 modifier = Modifier .fillMaxSize(),
142163 verticalArrangement = Arrangement .spacedBy(30 .dp),
143164 ) {
144- when (page ) {
165+ when (selectedTab ) {
145166 0 -> {
146167 items(1 ) {
147168// ApplicationCard(
@@ -195,9 +216,7 @@ internal fun ApplicationScreen(
195216 title = it.topicName,
196217 description = it.description,
197218 isVoted = it.isVoted,
198- onButtonClick = {
199- onNavigateToSelectedVote(it.id, it.topicName)
200- },
219+ onButtonClick = { onNavigateToSelectedVote(it.id, it.topicName) },
201220 )
202221 }
203222 items(uiState.studentVoteList) {
@@ -321,7 +340,7 @@ private fun VoteCard(
321340 onButtonClick : () -> Unit ,
322341) {
323342 val formatter = DateTimeFormatter .ofPattern(" MM/dd HH:mm" )
324- val buttonText = if (isVoted) " 투표하기 " else " 투표 종료 "
343+ val buttonText = if (isVoted) " 투표 종료 " else " 투표하기 "
325344
326345 Text (
327346 modifier = modifier
@@ -395,7 +414,7 @@ private fun VoteCard(
395414 .horizontalPadding()
396415 .bottomPadding(28 .dp),
397416 onClick = onButtonClick,
398- enabled = isVoted,
417+ enabled = ! isVoted,
399418 ) {
400419 Text (text = buttonText)
401420 }
0 commit comments