Skip to content

Commit

Permalink
[Feature] Schedule 구조 추가 (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajou4095 authored Feb 6, 2024
1 parent 1ac6381 commit 060ced8
Show file tree
Hide file tree
Showing 37 changed files with 740 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.notification

object NotificationConstant {
const val ROUTE: String = "/notification"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.notification

import ac.dnd.bookkeeping.android.presentation.common.util.ErrorObserver
import ac.dnd.bookkeeping.android.presentation.ui.main.ApplicationState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable

fun NavGraphBuilder.notificationDestination(
appState: ApplicationState
) {
composable(
route = NotificationConstant.ROUTE
) {
val viewModel: NotificationViewModel = hiltViewModel()

val model: NotificationModel = let {
val state by viewModel.state.collectAsStateWithLifecycle()

NotificationModel(
state = state
)
}

ErrorObserver(viewModel)

NotificationScreen(
appState = appState,
model = model,
event = viewModel.event,
intent = viewModel::onIntent,
handler = viewModel.handler
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.notification

sealed interface NotificationEvent
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.notification

sealed interface NotificationIntent
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.notification

data class NotificationModel(
val state: NotificationState,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.notification

import ac.dnd.bookkeeping.android.presentation.common.util.LaunchedEffectWithLifecycle
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.EventFlow
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.MutableEventFlow
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.eventObserve
import ac.dnd.bookkeeping.android.presentation.ui.main.ApplicationState
import ac.dnd.bookkeeping.android.presentation.ui.main.rememberApplicationState
import androidx.compose.foundation.layout.Box
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.tooling.preview.Preview
import kotlinx.coroutines.CoroutineExceptionHandler

@Composable
fun NotificationScreen(
appState: ApplicationState,
model: NotificationModel,
event: EventFlow<NotificationEvent>,
intent: (NotificationIntent) -> Unit,
handler: CoroutineExceptionHandler
) {
val scope = rememberCoroutineScope()

Box {

}

LaunchedEffectWithLifecycle(event, handler) {
event.eventObserve { event ->

}
}
}

@Preview
@Composable
fun NotificationScreenPreview() {
NotificationScreen(
appState = rememberApplicationState(),
model = NotificationModel(
state = NotificationState.Init
),
event = MutableEventFlow(),
intent = {},
handler = CoroutineExceptionHandler { _, _ -> }
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.notification

sealed interface NotificationState {
data object Init : NotificationState
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.notification

import ac.dnd.bookkeeping.android.presentation.common.base.BaseViewModel
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.EventFlow
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.MutableEventFlow
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.asEventFlow
import androidx.lifecycle.SavedStateHandle
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import javax.inject.Inject

@HiltViewModel
class NotificationViewModel @Inject constructor(
private val savedStateHandle: SavedStateHandle,
) : BaseViewModel() {

private val _state: MutableStateFlow<NotificationState> =
MutableStateFlow(NotificationState.Init)
val state: StateFlow<NotificationState> = _state.asStateFlow()

private val _event: MutableEventFlow<NotificationEvent> = MutableEventFlow()
val event: EventFlow<NotificationEvent> = _event.asEventFlow()

fun onIntent(intent: NotificationIntent) {

}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.relation.add

object AddRelationConstant {
const val ROUTE: String = "addName"
const val ROUTE: String = "/addName"

const val ROUTE_ARGUMENT_MODEL = "relation"
const val CONTAIN_RELATION = "${ROUTE}/{${ROUTE_ARGUMENT_MODEL}}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.relation.get

object GetRelationConstant {
const val ROUTE: String = "searchName"
const val ROUTE: String = "/searchName"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.schedule

object ScheduleConstant {
const val ROUTE: String = "/schedule"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.schedule

sealed interface ScheduleEvent
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.schedule

sealed interface ScheduleIntent
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.schedule

data class ScheduleModel(
val state: ScheduleState,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.schedule

import ac.dnd.bookkeeping.android.presentation.common.util.LaunchedEffectWithLifecycle
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.EventFlow
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.MutableEventFlow
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.eventObserve
import ac.dnd.bookkeeping.android.presentation.ui.main.ApplicationState
import ac.dnd.bookkeeping.android.presentation.ui.main.rememberApplicationState
import androidx.compose.foundation.layout.Box
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.tooling.preview.Preview
import kotlinx.coroutines.CoroutineExceptionHandler

@Composable
fun ScheduleScreen(
appState: ApplicationState,
model: ScheduleModel,
event: EventFlow<ScheduleEvent>,
intent: (ScheduleIntent) -> Unit,
handler: CoroutineExceptionHandler
) {
val scope = rememberCoroutineScope()

Box {

}

LaunchedEffectWithLifecycle(event, handler) {
event.eventObserve { event ->

}
}
}

@Preview
@Composable
fun ScheduleScreenPreview() {
ScheduleScreen(
appState = rememberApplicationState(),
model = ScheduleModel(
state = ScheduleState.Init
),
event = MutableEventFlow(),
intent = {},
handler = CoroutineExceptionHandler { _, _ -> }
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.schedule

sealed interface ScheduleState {
data object Init : ScheduleState
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.schedule

import ac.dnd.bookkeeping.android.presentation.common.base.BaseViewModel
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.EventFlow
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.MutableEventFlow
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.asEventFlow
import androidx.lifecycle.SavedStateHandle
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import javax.inject.Inject

@HiltViewModel
class ScheduleViewModel @Inject constructor(
private val savedStateHandle: SavedStateHandle,
) : BaseViewModel() {

private val _state: MutableStateFlow<ScheduleState> = MutableStateFlow(ScheduleState.Init)
val state: StateFlow<ScheduleState> = _state.asStateFlow()

private val _event: MutableEventFlow<ScheduleEvent> = MutableEventFlow()
val event: EventFlow<ScheduleEvent> = _event.asEventFlow()

fun onIntent(intent: ScheduleIntent) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.schedule.add

import ac.dnd.bookkeeping.android.presentation.ui.main.home.schedule.ScheduleConstant

object ScheduleAddConstant {
const val ROUTE: String = "${ScheduleConstant.ROUTE}/add"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.schedule.add

import ac.dnd.bookkeeping.android.presentation.common.util.ErrorObserver
import ac.dnd.bookkeeping.android.presentation.ui.main.ApplicationState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable

fun NavGraphBuilder.scheduleAddDestination(
appState: ApplicationState
) {
composable(
route = ScheduleAddConstant.ROUTE
) {
val viewModel: ScheduleAddViewModel = hiltViewModel()

val model: ScheduleAddModel = let {
val state by viewModel.state.collectAsStateWithLifecycle()

ScheduleAddModel(
state = state
)
}

ErrorObserver(viewModel)

ScheduleAddScreen(
appState = appState,
model = model,
event = viewModel.event,
intent = viewModel::onIntent,
handler = viewModel.handler
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.schedule.add

sealed interface ScheduleAddEvent
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.schedule.add

sealed interface ScheduleAddIntent
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.schedule.add

data class ScheduleAddModel(
val state: ScheduleAddState,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.schedule.add

import ac.dnd.bookkeeping.android.presentation.common.util.LaunchedEffectWithLifecycle
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.EventFlow
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.MutableEventFlow
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.eventObserve
import ac.dnd.bookkeeping.android.presentation.ui.main.ApplicationState
import ac.dnd.bookkeeping.android.presentation.ui.main.rememberApplicationState
import androidx.compose.foundation.layout.Box
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.tooling.preview.Preview
import kotlinx.coroutines.CoroutineExceptionHandler

@Composable
fun ScheduleAddScreen(
appState: ApplicationState,
model: ScheduleAddModel,
event: EventFlow<ScheduleAddEvent>,
intent: (ScheduleAddIntent) -> Unit,
handler: CoroutineExceptionHandler
) {
val scope = rememberCoroutineScope()

Box {

}

LaunchedEffectWithLifecycle(event, handler) {
event.eventObserve { event ->

}
}
}

@Preview
@Composable
fun ScheduleAddScreenPreview() {
ScheduleAddScreen(
appState = rememberApplicationState(),
model = ScheduleAddModel(
state = ScheduleAddState.Init
),
event = MutableEventFlow(),
intent = {},
handler = CoroutineExceptionHandler { _, _ -> }
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.schedule.add

sealed interface ScheduleAddState {
data object Init : ScheduleAddState
}
Loading

0 comments on commit 060ced8

Please sign in to comment.