-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [추가] 잔여좌석화면 전환용 배너 추가 * [수정] api 쿼리파라미터 수정 * [수정] 상태창 패딩 추가 * [제거] 주석 코드 삭제 * [추가] 뷰모델 추가 및 레포지토리 연결 * [추가] 도서관 앱 이동 로직 추가 * [수정] 도서관 잔여좌석 오류UI 수정 * [수정] 폰트 수정 * [수정] StateFlow 선언 수정 * [수정] indicator 패키지 이름 * [수정] PagingLoadingIndicator 컴포넌트화 * [삭제] 미사용 라이브러리 삭제 * [추가] 패키지 에러 크래시리틱 * [수정] 공백 제거
- Loading branch information
1 parent
40b39a8
commit 1ca09b1
Showing
21 changed files
with
471 additions
and
135 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
2 changes: 1 addition & 1 deletion
2
...r_indicator/HorizontalSlidingIndicator.kt → ...s/indicator/HorizontalSlidingIndicator.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
19 changes: 19 additions & 0 deletions
19
...in/java/com/ku_stacks/ku_ring/designsystem/components/indicator/PagingLoadingIndicator.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.ku_stacks.ku_ring.designsystem.components.indicator | ||
|
||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.colorResource | ||
import androidx.compose.material.CircularProgressIndicator | ||
import com.ku_stacks.ku_ring.designsystem.R | ||
|
||
@Composable | ||
fun PagingLoadingIndicator(modifier: Modifier = Modifier) { | ||
Box(modifier = modifier) { | ||
CircularProgressIndicator( | ||
color = colorResource(id = R.color.kus_green), | ||
modifier = Modifier.align(Alignment.Center), | ||
) | ||
} | ||
} |
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
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
21 changes: 21 additions & 0 deletions
21
feature/library/src/main/java/com/ku_stacks/ku_ring/library/LibrarySeatUiState.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,21 @@ | ||
package com.ku_stacks.ku_ring.library | ||
|
||
import com.ku_stacks.ku_ring.domain.LibraryRoom | ||
|
||
data class LibrarySeatUiState( | ||
val isLoading: Boolean, | ||
val loadState: SeatLoadState, | ||
){ | ||
companion object { | ||
val Empty = LibrarySeatUiState( | ||
isLoading = false, | ||
loadState = SeatLoadState.InitialLoading, | ||
) | ||
} | ||
} | ||
|
||
sealed interface SeatLoadState { | ||
data object InitialLoading : SeatLoadState | ||
data object Error : SeatLoadState | ||
data class Success(val rooms: List<LibraryRoom>) : SeatLoadState | ||
} |
48 changes: 48 additions & 0 deletions
48
feature/library/src/main/java/com/ku_stacks/ku_ring/library/LibrarySeatViewModel.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,48 @@ | ||
package com.ku_stacks.ku_ring.library | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import com.ku_stacks.ku_ring.library.repository.LibraryRepository | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.asStateFlow | ||
import kotlinx.coroutines.flow.update | ||
import kotlinx.coroutines.launch | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class LibrarySeatViewModel @Inject constructor( | ||
private val libraryRepository: LibraryRepository, | ||
) : ViewModel() { | ||
|
||
private val _uiState = MutableStateFlow(LibrarySeatUiState.Empty) | ||
val uiState = _uiState.asStateFlow() | ||
|
||
fun getLibrarySeatStatus() = viewModelScope.launch { | ||
updateIsLoading(true) | ||
|
||
libraryRepository.getRemainingSeats() | ||
.onSuccess { rooms -> | ||
if (rooms.isNotEmpty()) { | ||
updateLoadState(SeatLoadState.Success(rooms)) | ||
} | ||
}.onFailure { | ||
updateLoadState(SeatLoadState.Error) | ||
} | ||
} | ||
|
||
private fun updateIsLoading(isLoading: Boolean) = _uiState.update { currentState -> | ||
currentState.copy( | ||
isLoading = isLoading | ||
) | ||
} | ||
|
||
private fun updateLoadState(loadState: SeatLoadState) { | ||
_uiState.update { currentState -> | ||
currentState.copy( | ||
loadState = loadState, | ||
isLoading = false | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.