-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
�[AN] feat: 내가 만든 & 방장인 모임 구체화 (#450)
- Loading branch information
Showing
23 changed files
with
242 additions
and
153 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
97 changes: 7 additions & 90 deletions
97
android/app/src/main/java/com/happy/friendogly/data/repository/MyClubRepositoryImpl.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,97 +1,14 @@ | ||
package com.happy.friendogly.data.repository | ||
|
||
import com.happy.friendogly.data.mapper.toDomain | ||
import com.happy.friendogly.data.source.MyClubDataSource | ||
import com.happy.friendogly.domain.model.Club | ||
import com.happy.friendogly.domain.model.ClubAddress | ||
import com.happy.friendogly.domain.model.ClubState | ||
import com.happy.friendogly.domain.model.Gender | ||
import com.happy.friendogly.domain.model.SizeType | ||
import com.happy.friendogly.domain.repository.MyClubRepository | ||
import kotlinx.datetime.toKotlinLocalDateTime | ||
import java.time.LocalDateTime | ||
|
||
// TODO: change club api | ||
class MyClubRepositoryImpl : MyClubRepository { | ||
override suspend fun getMyClubs(): Result<List<Club>> { | ||
return dummyMyClub | ||
} | ||
class MyClubRepositoryImpl( | ||
private val source: MyClubDataSource, | ||
) : MyClubRepository { | ||
override suspend fun getMyClubs(): Result<List<Club>> = source.getParticipatingClubs().mapCatching { it.toDomain() } | ||
|
||
override suspend fun getMyHeadClubs(): Result<List<Club>> { | ||
return dummyMyHeadClub | ||
} | ||
override suspend fun getMyHeadClubs(): Result<List<Club>> = source.getMyOwningClubs().mapCatching { it.toDomain() } | ||
} | ||
|
||
private val dummyMyHeadClub = | ||
runCatching { | ||
listOf( | ||
Club( | ||
id = -1, | ||
title = "내가만든클럽~", | ||
content = "내가 방장인 클럽", | ||
ownerMemberName = "누누", | ||
address = | ||
ClubAddress( | ||
"서울특별시", | ||
"송파구", | ||
"올림픽로", | ||
), | ||
status = ClubState.OPEN, | ||
createdAt = java.time.LocalDateTime.now().toKotlinLocalDateTime(), | ||
allowedSize = | ||
listOf( | ||
SizeType.LARGE, | ||
SizeType.SMALL, | ||
), | ||
allowedGender = | ||
listOf( | ||
Gender.FEMALE, | ||
Gender.MALE_NEUTERED, | ||
), | ||
memberCapacity = 5, | ||
currentMemberCount = 3, | ||
imageUrl = null, | ||
petImageUrls = | ||
listOf( | ||
null, | ||
null, | ||
), | ||
), | ||
) | ||
} | ||
|
||
private val dummyMyClub = | ||
runCatching { | ||
listOf( | ||
Club( | ||
id = -1, | ||
title = "내가가입한클럽~", | ||
content = "내가 가입한 클럽", | ||
ownerMemberName = "땡이", | ||
address = | ||
ClubAddress( | ||
"서울특별시", | ||
"송파구", | ||
"올림픽로", | ||
), | ||
status = ClubState.OPEN, | ||
createdAt = LocalDateTime.now().toKotlinLocalDateTime(), | ||
allowedSize = | ||
listOf( | ||
SizeType.LARGE, | ||
SizeType.SMALL, | ||
), | ||
allowedGender = | ||
listOf( | ||
Gender.FEMALE, | ||
Gender.MALE_NEUTERED, | ||
), | ||
memberCapacity = 5, | ||
currentMemberCount = 3, | ||
imageUrl = null, | ||
petImageUrls = | ||
listOf( | ||
null, | ||
null, | ||
), | ||
), | ||
) | ||
} |
9 changes: 9 additions & 0 deletions
9
android/app/src/main/java/com/happy/friendogly/data/source/MyClubDataSource.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,9 @@ | ||
package com.happy.friendogly.data.source | ||
|
||
import com.happy.friendogly.data.model.ClubDto | ||
|
||
interface MyClubDataSource { | ||
suspend fun getMyOwningClubs(): Result<List<ClubDto>> | ||
|
||
suspend fun getParticipatingClubs(): Result<List<ClubDto>> | ||
} |
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
5 changes: 5 additions & 0 deletions
5
...p/src/main/java/com/happy/friendogly/presentation/ui/club/common/ClubChangeStateIntent.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,5 @@ | ||
package com.happy.friendogly.presentation.ui.club.common | ||
|
||
object ClubChangeStateIntent { | ||
const val CHANGE_CLUB_STATE = "clubChangeState" | ||
} |
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
47 changes: 47 additions & 0 deletions
47
android/app/src/main/java/com/happy/friendogly/presentation/ui/club/my/MyClubViewModel.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,47 @@ | ||
package com.happy.friendogly.presentation.ui.club.my | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModelProvider | ||
import androidx.lifecycle.viewModelScope | ||
import com.happy.friendogly.domain.fold | ||
import com.happy.friendogly.domain.usecase.GetPetsMineUseCase | ||
import com.happy.friendogly.presentation.base.BaseViewModel | ||
import com.happy.friendogly.presentation.base.BaseViewModelFactory | ||
import com.happy.friendogly.presentation.base.Event | ||
import com.happy.friendogly.presentation.base.emit | ||
import kotlinx.coroutines.launch | ||
|
||
class MyClubViewModel( | ||
private val getPetsMineUseCase: GetPetsMineUseCase, | ||
) : BaseViewModel() { | ||
private val _myClubEvent: MutableLiveData<Event<MyClubEvent.AddPet>> = MutableLiveData() | ||
val myClubEvent: LiveData<Event<MyClubEvent.AddPet>> get() = _myClubEvent | ||
|
||
fun loadPetState() = | ||
viewModelScope.launch { | ||
getPetsMineUseCase() | ||
.fold( | ||
onSuccess = { pets -> | ||
if (pets.isEmpty()) { | ||
_myClubEvent.emit(MyClubEvent.AddPet.OpenAddPet) | ||
} else { | ||
_myClubEvent.emit(MyClubEvent.AddPet.OpenAddClub) | ||
} | ||
}, | ||
onError = { | ||
// TODO 예외처리 | ||
}, | ||
) | ||
} | ||
|
||
companion object { | ||
fun factory(getPetsMineUseCase: GetPetsMineUseCase): ViewModelProvider.Factory { | ||
return BaseViewModelFactory { | ||
MyClubViewModel( | ||
getPetsMineUseCase = getPetsMineUseCase, | ||
) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.