generated from AND-SOPT-ANDROID/and-sopt-android-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Week7] 7주차 필수과제 #16
Open
hyeeum
wants to merge
40
commits into
develop
Choose a base branch
from
week7
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Week7] 7주차 필수과제 #16
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
0ebb8fc
chore #13: move component to presentation layer
hyeeum f512b35
add #13: add core package
hyeeum 1248207
chore #13: add Route and edit navigation package
hyeeum 0f51c4f
chore #13: divide component to each package
hyeeum 0a6499f
feature #13: MyUseCase
hyeeum 13738ee
chore #13: apply MyUseCase
hyeeum e8cc88b
feature #13: SignInUseCase
hyeeum e4170ab
chore #13: apply SignInUseCase
hyeeum 833364c
feature #13: SignUpUseCase
hyeeum 8383bee
chore #13: apply SignUpUseCase
hyeeum 094db33
feature #13: SignInRepositoryImpl
hyeeum fdf4887
feature #13: SignUpRepositoryImpl
hyeeum 7cb7dc7
feature #13: MyRepositoryImpl
hyeeum f228e2f
feature #13: MyRepository
hyeeum a7ba597
feature #13: SignInRepository
hyeeum 859d8e8
feature #13: SignUpRepository
hyeeum ad24c45
feature #13: AuthService
hyeeum 0ca0bed
feature #13: MyService
hyeeum 0b0d469
feature #13: MyDataSourceImpl
hyeeum bcba10b
feature #13: AuthDataSourceImpl
hyeeum 9f0cd0e
feature #13: AuthDataSource
hyeeum 66fa970
feature #13: MyDataSource
hyeeum 92f4d78
chore #13: DataSourceModule
hyeeum 2bf2804
chore #13: RepositoryModule
hyeeum ce45e9e
chore #13: ServiceModule
hyeeum 374274f
chore #13: edit DataSourceModule function naming
hyeeum 59fae34
Add #15: SignUpEvent
hyeeum a799136
Chore #15: apply SignUpEvent
hyeeum 0388bd4
Chore #15: apply SignUpEvent
hyeeum 03a85c7
Add #15: SignInEvent
hyeeum 006ffb2
Chore #15: apply SignInEvent
hyeeum c690d8a
Chore #15: apply Timber
hyeeum b0e0fb6
Chore #15: SignUpContract
hyeeum 63c27e9
Delete #15: delete origin SignUpEvent,SideEffect,State
hyeeum a1fe2e6
Delete #15: delete origin SignInEvent,SideEffect,State
hyeeum 11aa8c3
Chore #15: SignInContract
hyeeum f724a13
Delete #15: delete origin MySideEffect,State
hyeeum e4b6858
Chore #15: MyContract
hyeeum 40aa62c
Feature #15: set BaseViewModel
hyeeum cc2f3b3
Refactor #15: APPJAM Refactor
hyeeum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
...a/org/sopt/and/component/AuthTextField.kt → .../sopt/and/core/component/AuthTextField.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
2 changes: 1 addition & 1 deletion
2
.../org/sopt/and/component/ExpandedButton.kt → ...sopt/and/core/component/ExpandedButton.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
2 changes: 1 addition & 1 deletion
2
...a/org/sopt/and/component/RoundedButton.kt → .../sopt/and/core/component/RoundedButton.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
2 changes: 1 addition & 1 deletion
2
...ain/java/org/sopt/and/component/TopBar.kt → ...ava/org/sopt/and/core/component/TopBar.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
2 changes: 1 addition & 1 deletion
2
app/src/main/java/org/sopt/and/Extension.kt → ...pt/and/core/extension/ContextExtension.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
3 changes: 3 additions & 0 deletions
3
app/src/main/java/org/sopt/and/core/navigation/MainTabRoute.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,3 @@ | ||
package org.sopt.and.core.navigation | ||
|
||
interface MainTabRoute : Route |
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,3 @@ | ||
package org.sopt.and.core.navigation | ||
|
||
interface Route |
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,52 @@ | ||
package org.sopt.and.core.util | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import kotlinx.coroutines.channels.Channel | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.MutableSharedFlow | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.SharedFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.asSharedFlow | ||
import kotlinx.coroutines.flow.asStateFlow | ||
import kotlinx.coroutines.flow.receiveAsFlow | ||
import kotlinx.coroutines.launch | ||
|
||
abstract class BaseViewModel<State : UiState, SideEffect : UiSideEffect, Intent : UiEvent>() : | ||
ViewModel() { | ||
private val initialState: State by lazy { createInitialState() } | ||
abstract fun createInitialState(): State | ||
|
||
private val _state = MutableStateFlow<State>(initialState) | ||
val uiState: StateFlow<State> | ||
get() = _state.asStateFlow() | ||
val currentState: State | ||
get() = uiState.value | ||
|
||
private val _event: MutableSharedFlow<Intent> = MutableSharedFlow() | ||
val event: SharedFlow<Intent> | ||
get() = _event.asSharedFlow() | ||
|
||
private val _sideEffect: Channel<SideEffect> = Channel() | ||
val sideEffect: Flow<SideEffect> | ||
get() = _sideEffect.receiveAsFlow() | ||
|
||
fun setState(reduce: State.() -> State) { | ||
_state.value = currentState.reduce() | ||
} | ||
|
||
open fun setIntent(intent: Intent) { | ||
dispatchIntent(intent) | ||
} | ||
|
||
private fun dispatchIntent(intent: Intent) = viewModelScope.launch { | ||
handleEvent(intent) | ||
} | ||
|
||
protected abstract suspend fun handleEvent(intent: Intent) | ||
|
||
fun setSideEffect(sideEffect: () -> SideEffect) { | ||
viewModelScope.launch { _sideEffect.send(sideEffect()) } | ||
} | ||
} |
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,8 @@ | ||
package org.sopt.and.core.util | ||
|
||
enum class LoadState { | ||
Idle, | ||
Loading, | ||
Success, | ||
Failure | ||
} |
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,3 @@ | ||
package org.sopt.and.core.util | ||
|
||
interface UiEvent |
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,3 @@ | ||
package org.sopt.and.core.util | ||
|
||
interface UiSideEffect |
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,3 @@ | ||
package org.sopt.and.core.util | ||
|
||
interface UiState |
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
8 changes: 8 additions & 0 deletions
8
app/src/main/java/org/sopt/and/data/datasource/MyDataSource.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,8 @@ | ||
package org.sopt.and.data.datasource | ||
|
||
import org.sopt.and.data.dto.response.BaseResponse | ||
import org.sopt.and.data.dto.response.ResponseUserHobbyDto | ||
|
||
interface MyDataSource { | ||
suspend fun getUserHobby(): BaseResponse<ResponseUserHobbyDto> | ||
} |
19 changes: 7 additions & 12 deletions
19
...ata/datasourceimpl/WavveDataSourceImpl.kt → ...data/datasourceimpl/AuthDataSourceImpl.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 |
---|---|---|
@@ -1,25 +1,20 @@ | ||
package org.sopt.and.data.datasourceimpl | ||
|
||
import org.sopt.and.data.datasource.WavveDataSource | ||
import org.sopt.and.data.datasource.AuthDataSource | ||
import org.sopt.and.data.dto.request.RequestSignInDto | ||
import org.sopt.and.data.dto.request.RequestSignUpDto | ||
import org.sopt.and.data.dto.response.BaseResponse | ||
import org.sopt.and.data.dto.response.ResponseUserHobbyDto | ||
import org.sopt.and.data.dto.response.ResponseSignInDto | ||
import org.sopt.and.data.dto.response.ResponseSignUpDto | ||
import org.sopt.and.data.service.WavveService | ||
import org.sopt.and.data.service.AuthService | ||
import javax.inject.Inject | ||
|
||
class WavveDataSourceImpl @Inject constructor( | ||
private val wavveService: WavveService | ||
) : WavveDataSource { | ||
class AuthDataSourceImpl @Inject constructor( | ||
private val authService: AuthService | ||
) : AuthDataSource { | ||
override suspend fun postSignUp(requestSignUpDto: RequestSignUpDto): BaseResponse<ResponseSignUpDto> = | ||
wavveService.postSignUp(requestSignUpDto) | ||
authService.postSignUp(requestSignUpDto) | ||
|
||
override suspend fun postSignIn(requestSignInDto: RequestSignInDto): BaseResponse<ResponseSignInDto> = | ||
wavveService.postSignIn(requestSignInDto) | ||
|
||
override suspend fun getUserHobby(): BaseResponse<ResponseUserHobbyDto> = | ||
wavveService.getUserHobby() | ||
|
||
authService.postSignIn(requestSignInDto) | ||
} |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/org/sopt/and/data/datasourceimpl/MyDataSourceImpl.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,14 @@ | ||
package org.sopt.and.data.datasourceimpl | ||
|
||
import org.sopt.and.data.datasource.MyDataSource | ||
import org.sopt.and.data.dto.response.BaseResponse | ||
import org.sopt.and.data.dto.response.ResponseUserHobbyDto | ||
import org.sopt.and.data.service.MyService | ||
import javax.inject.Inject | ||
|
||
class MyDataSourceImpl @Inject constructor( | ||
private val myService: MyService | ||
) : MyDataSource { | ||
override suspend fun getUserHobby(): BaseResponse<ResponseUserHobbyDto> = | ||
myService.getUserHobby() | ||
} |
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 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
14 changes: 14 additions & 0 deletions
14
app/src/main/java/org/sopt/and/data/repositoryimpl/MyRepositoryImpl.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,14 @@ | ||
package org.sopt.and.data.repositoryimpl | ||
|
||
import org.sopt.and.data.datasource.MyDataSource | ||
import org.sopt.and.domain.entity.response.ResponseHobbyEntity | ||
import org.sopt.and.domain.repository.MyRepository | ||
import javax.inject.Inject | ||
|
||
class MyRepositoryImpl @Inject constructor( | ||
private val myDataSource: MyDataSource | ||
) : MyRepository { | ||
override suspend fun getHobby(): Result<ResponseHobbyEntity> = runCatching { | ||
myDataSource.getUserHobby().result.toEntity() | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
app/src/main/java/org/sopt/and/data/repositoryimpl/SignInRepositoryImpl.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,17 @@ | ||
package org.sopt.and.data.repositoryimpl | ||
|
||
import org.sopt.and.data.datasource.AuthDataSource | ||
import org.sopt.and.data.dto.request.toDto | ||
import org.sopt.and.domain.entity.request.RequestSignInEntity | ||
import org.sopt.and.domain.entity.response.ResponseSignInEntity | ||
import org.sopt.and.domain.repository.SignInRepository | ||
import javax.inject.Inject | ||
|
||
class SignInRepositoryImpl @Inject constructor( | ||
private val authDataSource: AuthDataSource | ||
) : SignInRepository { | ||
override suspend fun signIn(body: RequestSignInEntity): Result<ResponseSignInEntity> = | ||
runCatching { | ||
authDataSource.postSignIn(body.toDto()).result.toEntity() | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
app/src/main/java/org/sopt/and/data/repositoryimpl/SignUpRepositoryImpl.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,17 @@ | ||
package org.sopt.and.data.repositoryimpl | ||
|
||
import org.sopt.and.data.datasource.AuthDataSource | ||
import org.sopt.and.data.dto.request.toDto | ||
import org.sopt.and.domain.entity.request.RequestSignUpEntity | ||
import org.sopt.and.domain.entity.response.ResponseSignUpEntity | ||
import org.sopt.and.domain.repository.SignUpRepository | ||
import javax.inject.Inject | ||
|
||
class SignUpRepositoryImpl @Inject constructor( | ||
private val authDataSource: AuthDataSource | ||
) : SignUpRepository { | ||
override suspend fun signUp(body: RequestSignUpEntity): Result<ResponseSignUpEntity> = | ||
runCatching { | ||
authDataSource.postSignUp(body.toDto()).result.toEntity() | ||
} | ||
} |
27 changes: 0 additions & 27 deletions
27
app/src/main/java/org/sopt/and/data/repositoryimpl/WavveRepositoryImpl.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repository랑 RepositoryImpl을 구분하는 이유는 무엇인가요? 어차피 구현체 하나라서 인터페이스 없이 Repository를 구체 클래스로 제공해도 무방할 것 같아서요