Skip to content

Commit

Permalink
Merge pull request #112 from Team-Notitime/feat/announcement/111-anno…
Browse files Browse the repository at this point in the history
…uncement-creation

Feat/announcement/111 announcement creation
  • Loading branch information
easyhz authored Aug 20, 2024
2 parents ae4731a + d2abd62 commit 946e9fd
Show file tree
Hide file tree
Showing 31 changed files with 760 additions and 196 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/com/easyhz/noffice/NofficeApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ internal fun NofficeApp(
navController = navController
)
announcementGraph(
snackBarHostState = snackBarHostState,
navController = navController,
)
myPageGraph(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.easyhz.noffice.navigation.announcement

import androidx.compose.material3.SnackbarHostState
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavOptions
import androidx.navigation.compose.composable
import androidx.navigation.compose.navigation
import androidx.navigation.navOptions
import androidx.navigation.toRoute
import com.easyhz.noffice.core.model.announcement.param.AnnouncementParam
import com.easyhz.noffice.feature.announcement.screen.creation.ContentScreen
Expand All @@ -17,13 +20,18 @@ import com.easyhz.noffice.feature.announcement.screen.creation.remind.RemindView
import com.easyhz.noffice.feature.announcement.screen.creation.selection.NofficeSelectionScreen
import com.easyhz.noffice.feature.announcement.screen.creation.task.TaskScreen
import com.easyhz.noffice.feature.announcement.screen.detail.AnnouncementDetailScreen
import com.easyhz.noffice.feature.announcement.screen.success.SuccessScreen
import com.easyhz.noffice.navigation.announcement.screen.AnnouncementCreation
import com.easyhz.noffice.navigation.announcement.screen.AnnouncementCreation.Promotion.Companion.decode
import com.easyhz.noffice.navigation.announcement.screen.AnnouncementCreation.Promotion.Companion.encode
import com.easyhz.noffice.navigation.announcement.screen.AnnouncementDetail
import com.easyhz.noffice.navigation.announcement.screen.AnnouncementSuccess
import com.easyhz.noffice.navigation.home.navigateToHome
import com.easyhz.noffice.navigation.home.screen.Home
import com.easyhz.noffice.navigation.util.sharedViewModel

internal fun NavGraphBuilder.announcementGraph(
snackBarHostState: SnackbarHostState,
navController: NavController,
) {
composable<AnnouncementDetail> {
Expand All @@ -46,8 +54,10 @@ internal fun NavGraphBuilder.announcementGraph(

composable<AnnouncementCreation.Content> {
val viewModel = it.sharedViewModel<CreationViewModel>(navController = navController)
val args = it.toRoute<AnnouncementCreation.Content>()
ContentScreen(
viewModel = viewModel,
organizationId = args.organizationId,
navigateToUp = navController::navigateUp,
navigateToDateTime = navController::navigateToDateTime,
navigateToPlace = navController::navigateToPlace,
Expand Down Expand Up @@ -93,7 +103,8 @@ internal fun NavGraphBuilder.announcementGraph(

composable<AnnouncementCreation.Remind> {
val viewModel = it.sharedViewModel<RemindViewModel>(navController = navController)
val creationViewModel = it.sharedViewModel<CreationViewModel>(navController = navController)
val creationViewModel =
it.sharedViewModel<CreationViewModel>(navController = navController)
val args = it.toRoute<AnnouncementCreation.Remind>()
RemindScreen(
viewModel = viewModel,
Expand All @@ -115,19 +126,48 @@ internal fun NavGraphBuilder.announcementGraph(
composable<AnnouncementCreation.Promotion>(
typeMap = AnnouncementCreation.Promotion.typeMap
) {
val navOptions = navOptions {
popUpTo(Home) {
inclusive = false
}
}
val args = it.toRoute<AnnouncementCreation.Promotion>()
PromotionScreen(
param = args.announcementParam.decode()
param = args.announcementParam.decode(),
snackBarHostState = snackBarHostState,
navigateToUp = navController::navigateUp,
navigateToSuccess = { id, title ->
navController.navigateToSuccess(
id,
title,
navOptions
)
}
)
}
}
composable<AnnouncementSuccess> {
val args = it.toRoute<AnnouncementSuccess>()
val navOptions = navOptions {
popUpTo(Home) {
inclusive = false
}
}
SuccessScreen(
id = args.announcementId,
title = args.title,
navigateToHome = { navController.navigateToHome(navOptions) },
navigateToAnnouncementDetail = { id, title -> navController.navigateToAnnouncementDetail(id, title, navOptions)}
)
}
}

internal fun NavController.navigateToAnnouncementDetail(
id: Int,
title: String
title: String,
navOptions: NavOptions? = null
) {
navigate(route = AnnouncementDetail(id, title))
navigate(route = AnnouncementDetail(id, title), navOptions)
}

internal fun NavController.navigateToAnnouncementNofficeSelection() {
Expand All @@ -136,9 +176,9 @@ internal fun NavController.navigateToAnnouncementNofficeSelection() {
)
}

internal fun NavController.navigateToAnnouncementCreationContent() {
internal fun NavController.navigateToAnnouncementCreationContent(organizationId: Int) {
navigate(
route = AnnouncementCreation.Content
route = AnnouncementCreation.Content(organizationId)
)
}

Expand Down Expand Up @@ -168,9 +208,15 @@ internal fun NavController.navigateToTask(taskList: List<String>?) {
)
}

internal fun NavController.navigateToRemind(remindList: List<String>?, isSelectedDateTime: Boolean) {
internal fun NavController.navigateToRemind(
remindList: List<String>?,
isSelectedDateTime: Boolean
) {
navigate(
route = AnnouncementCreation.Remind(remindList = remindList, isSelectedDateTime = isSelectedDateTime)
route = AnnouncementCreation.Remind(
remindList = remindList,
isSelectedDateTime = isSelectedDateTime
)
)
}

Expand All @@ -182,4 +228,12 @@ internal fun NavController.navigateToCustomRemind() {

internal fun NavController.navigateToPromotion(param: AnnouncementParam) {
navigate(route = AnnouncementCreation.Promotion(param.encode()))
}

internal fun NavController.navigateToSuccess(
id: Int,
title: String,
navOptions: NavOptions? = null
) {
navigate(route = AnnouncementSuccess(id, title), navOptions)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ internal object AnnouncementCreation: Parcelable {
data object NofficeSelection

@Serializable
data object Content
data class Content(
val organizationId: Int
)

@Serializable
data class DateTime(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.easyhz.noffice.navigation.announcement.screen

import kotlinx.serialization.Serializable

@Serializable
data class AnnouncementSuccess(
val announcementId: Int,
val title: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.easyhz.noffice.core.common.util
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalTime
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
import java.time.format.DateTimeParseException
import java.time.format.TextStyle
Expand All @@ -19,8 +18,9 @@ object DateFormat {
CUSTOM_REMIND("MM월 dd일 E a h:mm"),
DAY("MM/dd"),
TIME("HH:mm"),
SERVER("yyyy-MM-dd'T'HH:mm:ss")
REQUEST("yyyy-MM-dd'T'HH:mm:ss")
}

fun fullText(date: LocalDate): String =
DateTimeFormatter.ofPattern(PATTERN.DATE_TEXT.value).format(date)

Expand Down Expand Up @@ -51,21 +51,19 @@ object DateFormat {
}

fun formatDateTime(date: String, pattern: PATTERN = PATTERN.FULL): String {
val dateTime = ZonedDateTime.parse(date)
val dateTime = LocalDateTime.parse(date)

val formatter = DateTimeFormatter.ofPattern(pattern.value)
.withLocale(Locale.KOREAN)
val formattedDate = dateTime.format(formatter)

return formattedDate
}

fun formatDateTimeNullable(date: String?, pattern: PATTERN = PATTERN.FULL): String? {
if (date.isNullOrBlank()) return null
val dateTime = ZonedDateTime.parse(date)
val dateTime = LocalDateTime.parse(date)

val formatter = DateTimeFormatter.ofPattern(pattern.value)
.withLocale(Locale.KOREAN)
val formattedDate = dateTime.format(formatter)

return formattedDate
Expand All @@ -83,9 +81,12 @@ object DateFormat {
val dayOfWeek = currentDate.dayOfWeek
return dayOfWeek.getDisplayName(TextStyle.FULL, Locale.getDefault())
}
fun localDateTimeToString(dateTime: LocalDateTime, pattern: PATTERN = PATTERN.FULL): String {
val formatter = DateTimeFormatter.ofPattern(pattern.value)
return dateTime.format(formatter)

fun localDateTimeToString(dateTime: String, pattern: PATTERN = PATTERN.CUSTOM_REMIND): String {
val parsDate = LocalDateTime.parse(dateTime, DateTimeFormatter.ISO_LOCAL_DATE_TIME)
val outputFormatter = DateTimeFormatter.ofPattern(pattern.value, Locale.KOREAN)
val formattedDate = parsDate.format(outputFormatter)
return formattedDate
}

fun dateTimeToRequestStringNullable(date: LocalDate?, time: LocalTime?): String? {
Expand All @@ -94,4 +95,12 @@ object DateFormat {
val formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME
return dateTime.format(formatter)
}

fun localDateTimeToRequest(dateTime: LocalDateTime): String {
val formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME
return dateTime.format(formatter)
}

fun parseLocalDateTime(input: String): LocalDateTime? =
LocalDateTime.parse(input, DateTimeFormatter.ISO_LOCAL_DATE_TIME)
}
Loading

0 comments on commit 946e9fd

Please sign in to comment.