-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rewrite by grouping based on screen
- Loading branch information
1 parent
29bbc3b
commit 0505ef9
Showing
28 changed files
with
235 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...lin/id/gdg/app/ui/state/common/UiState.kt → ...nMain/kotlin/id/gdg/app/common/UiState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,3 @@ | ||
package id.gdg.app.ui | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
sealed interface Router | ||
|
||
@Serializable | ||
data object SplashScreenRouter : Router | ||
|
||
@Serializable | ||
data object OnboardingRouter : Router | ||
|
||
@Serializable | ||
data object HomeRouter : Router | ||
|
||
@Serializable | ||
data class EventDetailRouter(val eventId: String) : Router | ||
interface Router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
app/src/commonMain/kotlin/id/gdg/app/ui/detail/EventDetailRouter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package id.gdg.app.ui.detail | ||
|
||
import id.gdg.app.ui.Router | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class EventDetailRouter(val eventId: String) : Router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...id/gdg/app/ui/state/EventDetailUiModel.kt → ...d/gdg/app/ui/detail/EventDetailUiModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app/src/commonMain/kotlin/id/gdg/app/ui/detail/EventDetailViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package id.gdg.app.ui.detail | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import id.gdg.app.common.UiState | ||
import id.gdg.app.common.asUiState | ||
import id.gdg.event.domain.GetEventDetailUseCase | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.asStateFlow | ||
import kotlinx.coroutines.flow.update | ||
import kotlinx.coroutines.launch | ||
import kotlinx.coroutines.withContext | ||
|
||
class EventDetailViewModel( | ||
private val eventDetailUseCase: GetEventDetailUseCase | ||
) : ViewModel() { | ||
|
||
private var _eventDetailUiState = MutableStateFlow(EventDetailUiModel.Empty) | ||
val eventDetailUiState get() = _eventDetailUiState.asStateFlow() | ||
|
||
fun fetch(eventId: Int) { | ||
_eventDetailUiState.update { it.copy(state = UiState.Loading) } | ||
|
||
viewModelScope.launch { | ||
val result = eventDetailUseCase(eventId) | ||
|
||
withContext(Dispatchers.Main) { | ||
_eventDetailUiState.update { | ||
it.copy( | ||
state = result.asUiState(), | ||
detail = result.getOrNull() | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package id.gdg.app.ui.main | ||
|
||
sealed class MainEvent { | ||
|
||
data class ChangeChapterId(val chapterId: Int) : MainEvent() | ||
|
||
data object InitialContent : MainEvent() | ||
|
||
data object FetchPreviousEvent : MainEvent() | ||
data object FetchUpcomingEvent : MainEvent() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package id.gdg.app.ui.main | ||
|
||
import id.gdg.app.ui.Router | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data object MainRouter : Router |
Oops, something went wrong.