-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from team-haribo/feature/34-write-the-logic-main
🔀 :: (#34) - write the logic main
- Loading branch information
Showing
52 changed files
with
1,302 additions
and
468 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
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
45 changes: 45 additions & 0 deletions
45
app/src/main/java/com/goms/goms_android_v2/MainActivityViewModel.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,45 @@ | ||
package com.goms.goms_android_v2 | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import com.goms.common.result.Result | ||
import com.goms.common.result.asResult | ||
import com.goms.data.repository.account.AccountRepository | ||
import com.goms.model.response.account.ProfileResponse | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.flow.SharingStarted | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.flow | ||
import kotlinx.coroutines.flow.map | ||
import kotlinx.coroutines.flow.stateIn | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class MainActivityViewModel @Inject constructor( | ||
private val accountRepository: AccountRepository | ||
) : ViewModel() { | ||
val uiState: StateFlow<MainActivityUiState> = flow { | ||
accountRepository.getProfile().collect { profileResponse -> | ||
emit(profileResponse) | ||
} | ||
} | ||
.asResult() | ||
.map { result -> | ||
when (result) { | ||
Result.Loading -> MainActivityUiState.Loading | ||
is Result.Success -> MainActivityUiState.Success(result.data) | ||
is Result.Error -> MainActivityUiState.Error(result.exception) | ||
} | ||
} | ||
.stateIn( | ||
scope = viewModelScope, | ||
initialValue = MainActivityUiState.Loading, | ||
started = SharingStarted.WhileSubscribed(5_000), | ||
) | ||
} | ||
|
||
sealed interface MainActivityUiState { | ||
object Loading : MainActivityUiState | ||
data class Success(val getProfileResponse: ProfileResponse) : MainActivityUiState | ||
data class Error(val exception: Throwable) : MainActivityUiState | ||
} |
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
8 changes: 8 additions & 0 deletions
8
core/data/src/main/java/com/goms/data/repository/account/AccountRepository.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 com.goms.data.repository.account | ||
|
||
import com.goms.model.response.account.ProfileResponse | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface AccountRepository { | ||
suspend fun getProfile(): Flow<ProfileResponse> | ||
} |
14 changes: 14 additions & 0 deletions
14
core/data/src/main/java/com/goms/data/repository/account/AccountRepositoryImpl.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 com.goms.data.repository.account | ||
|
||
import com.goms.model.response.account.ProfileResponse | ||
import com.goms.network.datasource.account.AccountDataSource | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class AccountRepositoryImpl @Inject constructor( | ||
private val remoteAccountDataSource: AccountDataSource | ||
) : AccountRepository { | ||
override suspend fun getProfile(): Flow<ProfileResponse> { | ||
return remoteAccountDataSource.getProfile() | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
core/data/src/main/java/com/goms/data/repository/late/LateRepository.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 com.goms.data.repository.late | ||
|
||
import com.goms.model.response.late.RankResponse | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface LateRepository { | ||
suspend fun getLateRankList(): Flow<List<RankResponse>> | ||
} |
14 changes: 14 additions & 0 deletions
14
core/data/src/main/java/com/goms/data/repository/late/LateRepositoryImpl.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 com.goms.data.repository.late | ||
|
||
import com.goms.model.response.late.RankResponse | ||
import com.goms.network.datasource.late.LateDataSource | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class LateRepositoryImpl @Inject constructor( | ||
private val remoteLateDataSource: LateDataSource | ||
) : LateRepository { | ||
override suspend fun getLateRankList(): Flow<List<RankResponse>> { | ||
return remoteLateDataSource.getLateRankList() | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
core/data/src/main/java/com/goms/data/repository/outing/OutingRepository.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,11 @@ | ||
package com.goms.data.repository.outing | ||
|
||
import com.goms.model.response.outing.CountResponse | ||
import com.goms.model.response.outing.OutingResponse | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface OutingRepository { | ||
suspend fun getOutingList(): Flow<List<OutingResponse>> | ||
|
||
suspend fun getOutingCount(): Flow<CountResponse> | ||
} |
19 changes: 19 additions & 0 deletions
19
core/data/src/main/java/com/goms/data/repository/outing/OutingRepositoryImpl.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,19 @@ | ||
package com.goms.data.repository.outing | ||
|
||
import com.goms.model.response.outing.CountResponse | ||
import com.goms.model.response.outing.OutingResponse | ||
import com.goms.network.datasource.outing.OutingDataSource | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class OutingRepositoryImpl @Inject constructor( | ||
private val remoteOutingDataSource: OutingDataSource | ||
) : OutingRepository { | ||
override suspend fun getOutingList(): Flow<List<OutingResponse>> { | ||
return remoteOutingDataSource.getOutingList() | ||
} | ||
|
||
override suspend fun getOutingCount(): Flow<CountResponse> { | ||
return remoteOutingDataSource.getOutingCount() | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="256dp" | ||
android:height="256dp" | ||
android:viewportWidth="256" | ||
android:viewportHeight="256"> | ||
<group> | ||
<clip-path | ||
android:pathData="M128,0L128,0A128,128 0,0 1,256 128L256,128A128,128 0,0 1,128 256L128,256A128,128 0,0 1,0 128L0,128A128,128 0,0 1,128 0z"/> | ||
<path | ||
android:pathData="M0,0h256v256h-256z" | ||
android:fillColor="#FFA600"/> | ||
<path | ||
android:pathData="M0,256a128,100 0,1 0,256 0a128,100 0,1 0,-256 0z" | ||
android:fillColor="#ffffff" | ||
android:fillAlpha="0.6"/> | ||
<path | ||
android:pathData="M128,80m-60,0a60,60 0,1 1,120 0a60,60 0,1 1,-120 0" | ||
android:fillColor="#ffffff" | ||
android:fillAlpha="0.6"/> | ||
</group> | ||
</vector> |
13 changes: 13 additions & 0 deletions
13
core/domain/src/main/java/com/goms/domain/account/GetProfileUseCase.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,13 @@ | ||
package com.goms.domain.account | ||
|
||
import com.goms.data.repository.account.AccountRepository | ||
import com.goms.model.response.account.ProfileResponse | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class GetProfileUseCase @Inject constructor( | ||
private val accountRepository: AccountRepository | ||
) { | ||
suspend operator fun invoke(): Flow<ProfileResponse> = | ||
accountRepository.getProfile() | ||
} |
13 changes: 13 additions & 0 deletions
13
core/domain/src/main/java/com/goms/domain/late/GetLateRankListUseCase.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,13 @@ | ||
package com.goms.domain.late | ||
|
||
import com.goms.data.repository.late.LateRepository | ||
import com.goms.model.response.late.RankResponse | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class GetLateRankListUseCase @Inject constructor( | ||
private val lateRepository: LateRepository | ||
) { | ||
suspend operator fun invoke(): Flow<List<RankResponse>> = | ||
lateRepository.getLateRankList() | ||
} |
13 changes: 13 additions & 0 deletions
13
core/domain/src/main/java/com/goms/domain/outing/GetOutingCountUseCase.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,13 @@ | ||
package com.goms.domain.outing | ||
|
||
import com.goms.data.repository.outing.OutingRepository | ||
import com.goms.model.response.outing.CountResponse | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class GetOutingCountUseCase @Inject constructor( | ||
private val outingRepository: OutingRepository | ||
) { | ||
suspend operator fun invoke(): Flow<CountResponse> = | ||
outingRepository.getOutingCount() | ||
} |
13 changes: 13 additions & 0 deletions
13
core/domain/src/main/java/com/goms/domain/outing/GetOutingListUseCase.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,13 @@ | ||
package com.goms.domain.outing | ||
|
||
import com.goms.data.repository.outing.OutingRepository | ||
import com.goms.model.response.outing.OutingResponse | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class GetOutingListUseCase @Inject constructor( | ||
private val outingRepository: OutingRepository | ||
) { | ||
suspend operator fun invoke(): Flow<List<OutingResponse>> = | ||
outingRepository.getOutingList() | ||
} |
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
Oops, something went wrong.