Skip to content

Commit

Permalink
[FEATURE] #50 : EventRegistration Indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn committed Nov 29, 2023
1 parent 5d3851d commit 0169c8d
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ internal fun ManagementEventContent(
}

WappButton(
textRes = R.string.add_event,
textRes = R.string.event_registration,
onClick = { onAddEventButtonClicked() },
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.ComposeView
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import com.wap.designsystem.WappTheme
import com.wap.wapp.core.commmon.extensions.showToast
import com.wap.wapp.core.commmon.extensions.toSupportingText
Expand Down Expand Up @@ -39,6 +40,7 @@ class ManagementFragment : Fragment() {
WappTheme {
ManagementScreen(
showManageCodeDialog = { isShowDialog = true },
navigateToEventRegistration = { navigateToEventRegistration() },
)

if (isShowDialog) {
Expand All @@ -54,4 +56,8 @@ class ManagementFragment : Fragment() {
}
}
}

private fun navigateToEventRegistration() = findNavController().navigate(
ManagementFragmentDirections.actionManageFragmentToEventRegistrationFragment(),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import kotlinx.coroutines.flow.collectLatest
internal fun ManagementScreen(
showManageCodeDialog: () -> Unit,
viewModel: ManagementViewModel = hiltViewModel(),
navigateToEventRegistration: () -> Unit,
) {
val snackBarHostState = remember { SnackbarHostState() }
val surveyList = viewModel.surveyList.collectAsState().value
Expand Down Expand Up @@ -84,7 +85,7 @@ internal fun ManagementScreen(
ManagementEventContent(
eventList = eventList,
onCardClicked = {},
onAddEventButtonClicked = {},
onAddEventButtonClicked = navigateToEventRegistration,
)

ManagementSurveyContent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import android.view.View
import android.view.ViewGroup
import androidx.compose.ui.platform.ComposeView
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import com.wap.designsystem.WappTheme
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class EventRegistrationFragment : Fragment() {

private lateinit var composeView: ComposeView
Expand All @@ -25,7 +28,15 @@ class EventRegistrationFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
composeView.setContent {
WappTheme {}
WappTheme {
EventRegistrationScreen(
onBackButtonClicked = { navigateToManagement() },
)
}
}
}

private fun navigateToManagement() = findNavController().navigate(
EventRegistrationFragmentDirections.actionEventRegistrationFragmentToManageFragment(),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package com.wap.wapp.feature.management.event

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
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.material3.LinearProgressIndicator
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.wap.designsystem.WappTheme
import com.wap.designsystem.component.WappTopBar
import com.wap.wapp.feature.management.R

@Composable
internal fun EventRegistrationScreen(
viewModel: EventRegistrationViewModel = hiltViewModel(),
onBackButtonClicked: () -> Unit,
) {
val snackBarHostState = remember { SnackbarHostState() }
val currentRegistrationState by viewModel.currentRegistrationState.collectAsStateWithLifecycle()

Scaffold(
snackbarHost = { SnackbarHost(snackBarHostState) },
containerColor = WappTheme.colors.backgroundBlack,
modifier = Modifier.fillMaxSize(),
) { paddingValues ->
Column(
modifier = Modifier
.fillMaxSize()
.padding(paddingValues) // paddingValue padding
.padding(16.dp), // dp value padding
) {
WappTopBar(
titleRes = R.string.event_registration,
showLeftButton = true,
onClickLeftButton = onBackButtonClicked,
)

EventRegistrationStateIndicator(
eventRegistrationState = currentRegistrationState,
modifier = Modifier.padding(top = 16.dp),
)
}
}
}

@Composable
private fun EventRegistrationStateIndicator(
eventRegistrationState: EventRegistrationState,
modifier: Modifier = Modifier,
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(8.dp),
modifier = modifier,
) {
EventRegistrationStateProgressBar(eventRegistrationState.progress)
EventRegistrationStateText(eventRegistrationState.page)
}
}

@Composable
private fun EventRegistrationStateText(
currentRegistrationPage: String,
) {
Row {
Text(
text = currentRegistrationPage,
style = WappTheme.typography.contentMedium,
color = WappTheme.colors.yellow,
)
Text(
text = stringResource(R.string.event_registration_total_page),
style = WappTheme.typography.contentMedium,
color = WappTheme.colors.white,
)
}
}

@Composable
private fun EventRegistrationStateProgressBar(
currentRegistrationProgress: Float,
) {
LinearProgressIndicator(
modifier = Modifier
.fillMaxWidth()
.height(10.dp),
color = WappTheme.colors.yellow,
progress = currentRegistrationProgress,
strokeCap = StrokeCap.Round,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.wap.wapp.feature.management.event

import androidx.lifecycle.ViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import javax.inject.Inject

@HiltViewModel
class EventRegistrationViewModel @Inject constructor() : ViewModel() {
private val _currentRegistrationState: MutableStateFlow<EventRegistrationState> =
MutableStateFlow(EventRegistrationState.EVENT_DETAILS)
val currentRegistrationState = _currentRegistrationState.asStateFlow()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.wap.wapp.feature.management.event

enum class EventRegistrationState(
val page: String,
val progress: Float,
) {
EVENT_DETAILS("1", 0.5f),
EVENT_SCHEDULE("2", 1.0f),
}
15 changes: 14 additions & 1 deletion feature/management/src/main/res/navigation/nav_management.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,20 @@
<fragment
android:id="@+id/manageFragment"
android:name="com.wap.wapp.feature.management.ManagementFragment"
android:label="fragment_manage" />
android:label="fragment_manage" >
<action
android:id="@+id/action_manageFragment_to_eventRegistrationFragment"
app:destination="@id/eventRegistrationFragment" />
</fragment>

<deepLink app:uri="wapp://feature/nav_management"/>

<fragment
android:id="@+id/eventRegistrationFragment"
android:name="com.wap.wapp.feature.management.event.EventRegistrationFragment"
android:label="EventRegistrationFragment" >
<action
android:id="@+id/action_eventRegistrationFragment_to_manageFragment"
app:destination="@id/manageFragment" />
</fragment>
</navigation>
4 changes: 2 additions & 2 deletions feature/management/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<string name="detail_icon_description">자세히보기 버튼</string>
<string name="survey">설문</string>
<string name="event">일정</string>
<string name="add_event">일정 추가</string>

<string name="event_registration">일정 추가</string>
<string name="event_registration_total_page">/ 2</string>
</resources>

0 comments on commit 0169c8d

Please sign in to comment.