Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ feature モジュールに explicitApi を追加 #48

Merged
merged 3 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions feature/auth/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ plugins {
android.namespace = "club.nito.feature.auth"

kotlin {
explicitApi()

sourceSets {
commonMain {
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import moe.tlaster.precompose.navigation.NavOptions
import moe.tlaster.precompose.navigation.Navigator
import moe.tlaster.precompose.navigation.RouteBuilder

const val loginNavigationRoute = "login_route"
public const val loginNavigationRoute: String = "login_route"

fun Navigator.navigateToLogin(navOptions: NavOptions? = null) {
public fun Navigator.navigateToLogin(navOptions: NavOptions? = null) {
this.navigate(loginNavigationRoute, navOptions)
}

fun RouteBuilder.loginScreen(
public fun RouteBuilder.loginScreen(
onLoggedIn: () -> Unit = {},
onRegisterClick: () -> Unit = {},
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import club.nito.core.ui.koinStateMachine
import club.nito.core.ui.message.SnackbarMessageEffect

@Composable
fun LoginRoute(
public fun LoginRoute(
viewModel: LoginScreenStateMachine = koinStateMachine(),
onLoggedIn: () -> Unit = {},
onRegisterClick: () -> Unit = {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package club.nito.feature.auth

sealed class LoginScreenEvent {
data object LoggedIn : LoginScreenEvent()
data object NavigateToRegister : LoginScreenEvent()
public sealed class LoginScreenEvent {
public data object LoggedIn : LoginScreenEvent()
public data object NavigateToRegister : LoginScreenEvent()
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package club.nito.feature.auth

sealed class LoginScreenIntent {
data class ChangeInputEmail(val email: String) : LoginScreenIntent()
data class ChangeInputPassword(val password: String) : LoginScreenIntent()
data object ClickSignIn : LoginScreenIntent()
data object ClickRegister : LoginScreenIntent()
public sealed class LoginScreenIntent {
public data class ChangeInputEmail(val email: String) : LoginScreenIntent()
public data class ChangeInputPassword(val password: String) : LoginScreenIntent()
public data object ClickSignIn : LoginScreenIntent()
public data object ClickRegister : LoginScreenIntent()
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch

class LoginScreenStateMachine internal constructor(
public class LoginScreenStateMachine internal constructor(
observeAuthStatusUseCase: ObserveAuthStatusUseCase,
private val signInUseCase: SignInUseCase,
val userMessageStateHolder: UserMessageStateHolder,
public val userMessageStateHolder: UserMessageStateHolder,
) : StateMachine(),
UserMessageStateHolder by userMessageStateHolder {

Expand All @@ -33,7 +33,7 @@ class LoginScreenStateMachine internal constructor(
initialValue = FetchSingleResult.Loading,
)

val uiState: StateFlow<LoginScreenUiState> = buildUiState(
public val uiState: StateFlow<LoginScreenUiState> = buildUiState(
email,
password,
authStatus,
Expand All @@ -46,7 +46,7 @@ class LoginScreenStateMachine internal constructor(
}

private val _events = MutableStateFlow<List<LoginScreenEvent>>(emptyList())
val event: Flow<LoginScreenEvent?> = _events.map { it.firstOrNull() }
public val event: Flow<LoginScreenEvent?> = _events.map { it.firstOrNull() }

init {
stateMachineScope.launch {
Expand All @@ -58,7 +58,7 @@ class LoginScreenStateMachine internal constructor(
}
}

fun dispatch(intent: LoginScreenIntent) {
public fun dispatch(intent: LoginScreenIntent) {
stateMachineScope.launch {
when (intent) {
is LoginScreenIntent.ChangeInputEmail -> email.emit(intent.email)
Expand All @@ -75,7 +75,7 @@ class LoginScreenStateMachine internal constructor(
}
}

fun consume(event: LoginScreenEvent) {
public fun consume(event: LoginScreenEvent) {
stateMachineScope.launch {
_events.emit(_events.value.filterNot { it == event })
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package club.nito.feature.auth

data class LoginScreenUiState(
public data class LoginScreenUiState(
val email: String,
val password: String,
val isSignInning: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import club.nito.feature.auth.LoginScreenStateMachine
import org.koin.core.module.Module
import org.koin.dsl.module

val authFeatureModule: Module = module {
public val authFeatureModule: Module = module {
factory {
LoginScreenStateMachine(
observeAuthStatusUseCase = get(),
Expand Down
2 changes: 2 additions & 0 deletions feature/schedule/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ plugins {
android.namespace = "club.nito.feature.schedule"

kotlin {
explicitApi()

sourceSets {
commonMain {
dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package club.nito.feature.schedule

sealed class ScheduleListEvent {
data class NavigateToScheduleDetail(val scheduleId: String) : ScheduleListEvent()
public sealed class ScheduleListEvent {
public data class NavigateToScheduleDetail(val scheduleId: String) : ScheduleListEvent()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package club.nito.feature.schedule

import club.nito.core.domain.model.ParticipantSchedule

sealed class ScheduleListIntent {
data class ClickShowConfirmParticipateDialog(val schedule: ParticipantSchedule) : ScheduleListIntent()
data class ClickParticipateSchedule(val schedule: ParticipantSchedule) : ScheduleListIntent()
data object ClickDismissConfirmParticipateDialog : ScheduleListIntent()
public sealed class ScheduleListIntent {
public data class ClickShowConfirmParticipateDialog(val schedule: ParticipantSchedule) : ScheduleListIntent()
public data class ClickParticipateSchedule(val schedule: ParticipantSchedule) : ScheduleListIntent()
public data object ClickDismissConfirmParticipateDialog : ScheduleListIntent()
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import club.nito.core.common.NitoDateTimeFormatter
import club.nito.core.domain.model.ParticipantSchedule
import club.nito.core.model.FetchMultipleContentResult

data class ScheduleListScreenUiState(
public data class ScheduleListScreenUiState(
val dateTimeFormatter: NitoDateTimeFormatter,
val scheduleList: FetchMultipleContentResult<ParticipantSchedule>,
val confirmParticipateDialog: ConfirmParticipateDialogUiState,
)

sealed class ConfirmParticipateDialogUiState {
data class Show(val schedule: ParticipantSchedule) : ConfirmParticipateDialogUiState()
data object Hide : ConfirmParticipateDialogUiState()
public sealed class ConfirmParticipateDialogUiState {
public data class Show(val schedule: ParticipantSchedule) : ConfirmParticipateDialogUiState()
public data object Hide : ConfirmParticipateDialogUiState()
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import moe.tlaster.precompose.viewmodel.viewModelScope

class ScheduleListViewModel internal constructor(
public class ScheduleListViewModel internal constructor(
getParticipantScheduleListUseCase: GetParticipantScheduleListUseCase,
val userMessageStateHolder: UserMessageStateHolder,
public val userMessageStateHolder: UserMessageStateHolder,
private val dateTimeFormatter: NitoDateTimeFormatter,
) : StateMachine(),
UserMessageStateHolder by userMessageStateHolder {
Expand All @@ -30,7 +30,7 @@ class ScheduleListViewModel internal constructor(
initialValue = FetchMultipleContentResult.Loading,
)

val uiState: StateFlow<ScheduleListScreenUiState> = buildUiState(
public val uiState: StateFlow<ScheduleListScreenUiState> = buildUiState(
showConfirmParticipateSchedule,
scheduleList,
) { showConfirmParticipateSchedule, scheduleList ->
Expand All @@ -44,25 +44,30 @@ class ScheduleListViewModel internal constructor(
}

private val _events = MutableStateFlow<List<ScheduleListEvent>>(emptyList())
val event: Flow<ScheduleListEvent?> = _events.map { it.firstOrNull() }
public val event: Flow<ScheduleListEvent?> = _events.map { it.firstOrNull() }

fun dispatch(intent: ScheduleListIntent) {
public fun dispatch(intent: ScheduleListIntent) {
viewModelScope.launch {
when (intent) {
is ScheduleListIntent.ClickShowConfirmParticipateDialog -> showConfirmParticipateSchedule.emit(intent.schedule)
is ScheduleListIntent.ClickShowConfirmParticipateDialog -> {
showConfirmParticipateSchedule.emit(intent.schedule)
}

is ScheduleListIntent.ClickParticipateSchedule -> {
showConfirmParticipateSchedule.emit(null)

val scheduledAt = dateTimeFormatter.formatDateTimeString(intent.schedule.scheduledAt)
userMessageStateHolder.showMessage("$scheduledAt に参加登録しました 🎉")
}

ScheduleListIntent.ClickDismissConfirmParticipateDialog -> showConfirmParticipateSchedule.emit(null)
ScheduleListIntent.ClickDismissConfirmParticipateDialog -> {
showConfirmParticipateSchedule.emit(null)
}
}
}
}

fun consume(event: ScheduleListEvent) {
public fun consume(event: ScheduleListEvent) {
viewModelScope.launch {
_events.emit(_events.value.filterNot { it == event })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import moe.tlaster.precompose.navigation.NavOptions
import moe.tlaster.precompose.navigation.Navigator
import moe.tlaster.precompose.navigation.RouteBuilder

const val scheduleNavigationRoute = "schedule_route"
public const val scheduleNavigationRoute: String = "schedule_route"

fun Navigator.navigateToSchedule(navOptions: NavOptions? = null) {
public fun Navigator.navigateToSchedule(navOptions: NavOptions? = null) {
this.navigate(scheduleNavigationRoute, navOptions)
}

fun RouteBuilder.scheduleScreen() {
public fun RouteBuilder.scheduleScreen() {
scene(
route = scheduleNavigationRoute,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import club.nito.core.ui.message.SnackbarMessageEffect
import club.nito.feature.schedule.component.ScheduleListSection

@Composable
fun ScheduleRoute(
public fun ScheduleRoute(
viewModel: ScheduleListViewModel = koinStateMachine(),
) {
viewModel.event.collectAsState(initial = null).value?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import club.nito.feature.schedule.ScheduleListViewModel
import org.koin.core.module.Module
import org.koin.dsl.module

val scheduleFeatureModule: Module = module {
public val scheduleFeatureModule: Module = module {
factory {
ScheduleListViewModel(
getParticipantScheduleListUseCase = get(),
Expand Down
2 changes: 2 additions & 0 deletions feature/settings/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ plugins {
android.namespace = "club.nito.feature.settings"

kotlin {
explicitApi()

sourceSets {
commonMain {
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import moe.tlaster.precompose.navigation.NavOptions
import moe.tlaster.precompose.navigation.Navigator
import moe.tlaster.precompose.navigation.RouteBuilder

const val settingsNavigationRoute = "settings_route"
public const val settingsNavigationRoute: String = "settings_route"

fun Navigator.navigateToSettings(navOptions: NavOptions? = null) {
public fun Navigator.navigateToSettings(navOptions: NavOptions? = null) {
this.navigate(settingsNavigationRoute, navOptions)
}

fun RouteBuilder.settingsScreen(
public fun RouteBuilder.settingsScreen(
onSignedOut: () -> Unit = {},
) {
scene(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import club.nito.core.ui.message.SnackbarMessageEffect
import club.nito.feature.settings.component.ModifyPasswordDialog

@Composable
fun SettingsRoute(
public fun SettingsRoute(
stateMachine: SettingsScreenStateMachine = koinStateMachine(),
onSignedOut: () -> Unit = {},
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package club.nito.feature.settings

sealed class SettingsScreenEvent {
data object SignedOut : SettingsScreenEvent()
public sealed class SettingsScreenEvent {
public data object SignedOut : SettingsScreenEvent()
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package club.nito.feature.settings

sealed class SettingsScreenIntent {
data object ClickShowModifyPasswordDialog : SettingsScreenIntent()
data class ChangeNewPasswordValue(val newValue: String) : SettingsScreenIntent()
data object ClickModifyPassword : SettingsScreenIntent()
data object ClickDismissModifyPasswordDialog : SettingsScreenIntent()
data object ClickSignOut : SettingsScreenIntent()
public sealed class SettingsScreenIntent {
public data object ClickShowModifyPasswordDialog : SettingsScreenIntent()
public data class ChangeNewPasswordValue(val newValue: String) : SettingsScreenIntent()
public data object ClickModifyPassword : SettingsScreenIntent()
public data object ClickDismissModifyPasswordDialog : SettingsScreenIntent()
public data object ClickSignOut : SettingsScreenIntent()
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import moe.tlaster.precompose.viewmodel.viewModelScope

class SettingsScreenStateMachine(
public class SettingsScreenStateMachine(
observeAuthStatus: ObserveAuthStatusUseCase,
private val modifyPassword: ModifyPasswordUseCase,
private val signOut: SignOutUseCase,
val userMessageStateHolder: UserMessageStateHolder,
public val userMessageStateHolder: UserMessageStateHolder,
) : StateMachine(),
UserMessageStateHolder by userMessageStateHolder {

Expand All @@ -38,7 +38,7 @@ class SettingsScreenStateMachine(
private val newPassword = MutableStateFlow("")
private val isPasswordModifying = MutableStateFlow(false)

val uiState: StateFlow<SettingsScreenUiState> = buildUiState(
public val uiState: StateFlow<SettingsScreenUiState> = buildUiState(
authStatus,
showModifyPasswordDialog,
newPassword,
Expand All @@ -57,7 +57,7 @@ class SettingsScreenStateMachine(
}

private val _events = MutableStateFlow<List<SettingsScreenEvent>>(emptyList())
val event: Flow<SettingsScreenEvent?> = _events.map { it.firstOrNull() }
public val event: Flow<SettingsScreenEvent?> = _events.map { it.firstOrNull() }

init {
viewModelScope.launch {
Expand All @@ -69,7 +69,7 @@ class SettingsScreenStateMachine(
}
}

fun dispatch(intent: SettingsScreenIntent) {
public fun dispatch(intent: SettingsScreenIntent) {
viewModelScope.launch {
when (intent) {
SettingsScreenIntent.ClickShowModifyPasswordDialog -> showModifyPasswordDialog.emit(true)
Expand Down Expand Up @@ -98,7 +98,7 @@ class SettingsScreenStateMachine(
}
}

fun consume(event: SettingsScreenEvent) {
public fun consume(event: SettingsScreenEvent) {
viewModelScope.launch {
_events.emit(_events.value.filterNot { it == event })
}
Expand Down
Loading