Skip to content

Commit f3c6d0d

Browse files
committed
[BOOK-106] chore: 전체적인 컬러 적용, 변수 네이밍 통일
1 parent 1974c9d commit f3c6d0d

File tree

10 files changed

+82
-72
lines changed

10 files changed

+82
-72
lines changed

core/common/src/main/kotlin/com/ninecraft/booket/core/common/extensions/Modifier.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.ninecraft.booket.core.common.extensions
22

3-
import android.annotation.SuppressLint
43
import androidx.compose.foundation.clickable
54
import androidx.compose.foundation.interaction.MutableInteractionSource
65
import androidx.compose.material3.ripple
@@ -13,7 +12,6 @@ import com.ninecraft.booket.core.common.utils.MultipleEventsCutter
1312
import com.ninecraft.booket.core.common.utils.get
1413

1514
// https://stackoverflow.com/questions/66703448/how-to-disable-ripple-effect-when-clicking-in-jetpack-compose
16-
@SuppressLint("ModifierFactoryUnreferencedReceiver")
1715
inline fun Modifier.noRippleClickable(crossinline onClick: () -> Unit): Modifier = composed {
1816
clickable(
1917
indication = null,
@@ -23,7 +21,6 @@ inline fun Modifier.noRippleClickable(crossinline onClick: () -> Unit): Modifier
2321
}
2422
}
2523

26-
@Suppress("ModifierFactoryUnreferencedReceiver")
2724
fun Modifier.clickableSingle(
2825
enabled: Boolean = true,
2926
onClickLabel: String? = null,

core/common/src/main/kotlin/com/ninecraft/booket/core/common/extensions/String.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ fun String.decodeHtmlEntities(): String {
1111
.replace("/", "/")
1212
.replace("'", "'")
1313
.replace(" ", " ")
14-
}
14+
}

core/designsystem/src/main/kotlin/com/ninecraft/booket/core/designsystem/component/ReedTextField.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ val reedTextSelectionColors = TextSelectionColors(
4444

4545
@Composable
4646
fun ReedTextField(
47-
searchTextState: TextFieldState,
48-
@StringRes searchTextHintRes: Int,
47+
queryState: TextFieldState,
48+
@StringRes queryHintRes: Int,
4949
onSearch: (String) -> Unit,
5050
modifier: Modifier = Modifier,
5151
backgroundColor: Color = ReedTheme.colors.baseSecondary,
@@ -57,15 +57,15 @@ fun ReedTextField(
5757

5858
CompositionLocalProvider(LocalTextSelectionColors provides reedTextSelectionColors) {
5959
BasicTextField(
60-
state = searchTextState,
60+
state = queryState,
6161
modifier = Modifier.fillMaxWidth(),
6262
textStyle = ReedTheme.typography.body2Regular.copy(color = textColor),
6363
keyboardOptions = KeyboardOptions(
6464
keyboardType = KeyboardType.Text,
6565
imeAction = ImeAction.Search,
6666
),
6767
onKeyboardAction = {
68-
onSearch(searchTextState.text.toString())
68+
onSearch(queryState.text.toString())
6969
keyboardController?.hide()
7070
},
7171
lineLimits = TextFieldLineLimits.SingleLine,
@@ -82,9 +82,9 @@ fun ReedTextField(
8282
) {
8383
Spacer(modifier = Modifier.width(ReedTheme.spacing.spacing4))
8484
Box {
85-
if (searchTextState.text.isEmpty()) {
85+
if (queryState.text.isEmpty()) {
8686
Text(
87-
text = stringResource(id = searchTextHintRes),
87+
text = stringResource(id = queryHintRes),
8888
color = ReedTheme.colors.contentTertiary,
8989
style = ReedTheme.typography.body2Regular,
9090
)
@@ -109,8 +109,8 @@ fun ReedTextField(
109109
private fun ReedTextFieldPreview() {
110110
ReedTheme {
111111
ReedTextField(
112-
searchTextState = TextFieldState(),
113-
searchTextHintRes = R.string.search_book_hint,
112+
queryState = TextFieldState(),
113+
queryHintRes = R.string.search_book_hint,
114114
onSearch = {},
115115
modifier = Modifier
116116
.height(46.dp)

feature/main/src/main/kotlin/com/ninecraft/booket/feature/main/MainActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
1313
import com.ninecraft.booket.core.designsystem.component.ReedScaffold
1414
import com.ninecraft.booket.core.designsystem.theme.White
1515
import com.ninecraft.booket.feature.main.component.MainBottomBar
16-
import com.ninecraft.booket.screens.HomeScreen
16+
import com.ninecraft.booket.screens.LoginScreen
1717
import com.slack.circuit.backstack.rememberSaveableBackStack
1818
import com.slack.circuit.foundation.Circuit
1919
import com.slack.circuit.foundation.CircuitCompositionLocals
@@ -36,7 +36,7 @@ class MainActivity : ComponentActivity() {
3636

3737
setContent {
3838
val systemUiController = rememberSystemUiController()
39-
val backStack = rememberSaveableBackStack(root = HomeScreen)
39+
val backStack = rememberSaveableBackStack(root = LoginScreen)
4040
val navigator = rememberCircuitNavigator(backStack)
4141
val isDarkTheme = isSystemInDarkTheme()
4242

feature/main/src/main/kotlin/com/ninecraft/booket/feature/main/component/MainBottomBar.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import androidx.compose.foundation.layout.navigationBarsPadding
1919
import androidx.compose.foundation.selection.selectable
2020
import androidx.compose.material3.HorizontalDivider
2121
import androidx.compose.material3.Icon
22-
import androidx.compose.material3.MaterialTheme
2322
import androidx.compose.material3.Text
2423
import androidx.compose.runtime.Composable
2524
import androidx.compose.runtime.remember
@@ -33,7 +32,9 @@ import androidx.compose.ui.text.font.FontWeight
3332
import androidx.compose.ui.unit.IntOffset
3433
import androidx.compose.ui.unit.dp
3534
import com.ninecraft.booket.core.designsystem.ComponentPreview
35+
import com.ninecraft.booket.core.designsystem.theme.Black
3636
import com.ninecraft.booket.core.designsystem.theme.ReedTheme
37+
import com.ninecraft.booket.core.designsystem.theme.White
3738
import com.ninecraft.booket.screens.HomeScreen
3839
import com.ninecraft.booket.screens.LibraryScreen
3940
import com.ninecraft.booket.screens.SearchScreen
@@ -79,9 +80,9 @@ internal fun MainBottomBar(
7980
exit = fadeOut() + slideOut { IntOffset(0, it.height) },
8081
modifier = modifier,
8182
) {
82-
Box(modifier = Modifier.background(MaterialTheme.colorScheme.surface)) {
83+
Box(modifier = Modifier.background(White)) {
8384
Column {
84-
HorizontalDivider(color = MaterialTheme.colorScheme.outline)
85+
HorizontalDivider(color = Black)
8586
Row(
8687
modifier = Modifier
8788
.navigationBarsPadding()

feature/search/src/main/kotlin/com/ninecraft/booket/feature/search/SearchPresenter.kt

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -28,57 +28,56 @@ class SearchPresenter @AssistedInject constructor(
2828
@Assisted private val navigator: Navigator,
2929
private val bookRepository: BookRepository,
3030
) : Presenter<SearchUiState> {
31+
companion object {
32+
private const val PAGE_SIZE = 20
33+
}
3134

3235
@Composable
3336
override fun present(): SearchUiState {
3437
val scope = rememberCoroutineScope()
3538
var uiState by rememberRetained { mutableStateOf<UiState>(UiState.Idle) }
3639
var footerState by rememberRetained { mutableStateOf<FooterState>(FooterState.Idle) }
37-
val searchText = rememberTextFieldState()
40+
val queryState = rememberTextFieldState()
3841
var searchResult by rememberRetained { mutableStateOf(BookSearchModel()) }
3942
var books by rememberRetained { mutableStateOf(persistentListOf<BookSummaryModel>()) }
40-
var currentPage by rememberRetained { mutableStateOf(0) }
43+
var currentStartIndex by rememberRetained { mutableStateOf(0) }
4144
var isLastPage by rememberRetained { mutableStateOf(false) }
4245

43-
fun searchBooks(query: String, currentOffset: Int = 0) {
46+
fun searchBooks(query: String, startIndex: Int = 0) {
4447
scope.launch {
45-
try {
46-
if (currentOffset == 0) {
47-
uiState = UiState.Loading
48-
} else {
49-
footerState = FooterState.Loading
50-
}
48+
if (startIndex == 0) {
49+
uiState = UiState.Loading
50+
} else {
51+
footerState = FooterState.Loading
52+
}
5153

52-
bookRepository.searchBook(query = query, start = currentOffset)
53-
.onSuccess { result ->
54-
searchResult = result
55-
books = if (currentOffset == 0) {
56-
result.books.toPersistentList()
57-
} else {
58-
(books + result.books).toPersistentList()
59-
}
54+
bookRepository.searchBook(query = query, start = startIndex)
55+
.onSuccess { result ->
56+
searchResult = result
57+
books = if (startIndex == 0) {
58+
result.books.toPersistentList()
59+
} else {
60+
(books + result.books).toPersistentList()
61+
}
6062

61-
currentPage = currentOffset
62-
isLastPage = result.books.size < 20
63-
uiState = UiState.Idle
63+
currentStartIndex = startIndex
64+
isLastPage = result.books.size < PAGE_SIZE
65+
66+
if (startIndex == 0) {
67+
uiState = UiState.Success
68+
} else {
6469
footerState = if (isLastPage) FooterState.End else FooterState.Idle
6570
}
66-
.onFailure { exception ->
67-
Logger.d(exception)
68-
if (currentOffset == 0) {
69-
uiState = UiState.Error(exception.message ?: "알 수 없는 오류가 발생했습니다.")
70-
} else {
71-
footerState = FooterState.Error(exception.message ?: "알 수 없는 오류가 발생했습니다.")
72-
}
71+
}
72+
.onFailure { exception ->
73+
Logger.d(exception)
74+
val errorMessage = exception.message ?: "알 수 없는 오류가 발생했습니다."
75+
if (startIndex == 0) {
76+
uiState = UiState.Error(errorMessage)
77+
} else {
78+
footerState = FooterState.Error(errorMessage)
7379
}
74-
} catch (e: Exception) {
75-
Logger.d(e)
76-
if (currentOffset == 0) {
77-
uiState = UiState.Error(e.message ?: "알 수 없는 오류가 발생했습니다.")
78-
} else {
79-
footerState = FooterState.Error(e.message ?: "알 수 없는 오류가 발생했습니다.")
8080
}
81-
}
8281
}
8382
}
8483

@@ -89,18 +88,18 @@ class SearchPresenter @AssistedInject constructor(
8988
}
9089

9190
is SearchUiEvent.OnSearch -> {
92-
searchBooks(query = event.text, currentOffset = 0)
91+
searchBooks(query = event.text, startIndex = 0)
9392
}
9493

9594
is SearchUiEvent.OnLoadMore -> {
96-
if (footerState !is FooterState.Loading && !isLastPage && searchText.text.toString().isNotEmpty()) {
97-
searchBooks(query = searchText.text.toString(), currentOffset = currentPage + 1)
95+
if (footerState !is FooterState.Loading && !isLastPage && queryState.text.toString().isNotEmpty()) {
96+
searchBooks(query = queryState.text.toString(), startIndex = currentStartIndex + 1)
9897
}
9998
}
10099

101100
is SearchUiEvent.OnRetryClick -> {
102-
if (searchText.text.toString().isNotEmpty()) {
103-
searchBooks(query = searchText.text.toString(), currentOffset = 0)
101+
if (queryState.text.toString().isNotEmpty()) {
102+
searchBooks(query = queryState.text.toString(), startIndex = 0)
104103
}
105104
}
106105

@@ -111,10 +110,10 @@ class SearchPresenter @AssistedInject constructor(
111110
return SearchUiState(
112111
uiState = uiState,
113112
footerState = footerState,
114-
searchText = searchText,
113+
queryState = queryState,
115114
searchResult = searchResult,
116115
books = books,
117-
offset = currentPage,
116+
startIndex = currentStartIndex,
118117
isLastPage = isLastPage,
119118
eventSink = ::handleEvent,
120119
)

feature/search/src/main/kotlin/com/ninecraft/booket/feature/search/SearchScreen.kt

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ internal fun SearchContent(
6767
.background(White),
6868
) {
6969
ReedTextField(
70-
searchTextState = state.searchText,
70+
queryState = state.queryState,
71+
queryHintRes = designR.string.search_book_hint,
7172
onSearch = { text ->
7273
state.eventSink(SearchUiEvent.OnSearch(text))
7374
},
74-
searchTextHintRes = designR.string.search_book_hint,
7575
modifier = modifier
7676
.padding(
7777
vertical = ReedTheme.spacing.spacing3,
@@ -110,8 +110,21 @@ internal fun SearchContent(
110110
}
111111

112112
is UiState.Idle -> {
113-
if (state.isEmpty) {
114-
// TODO 최근 검색어 노출
113+
// TODO: 최근 검색어 노출
114+
}
115+
116+
is UiState.Success -> {
117+
if (state.isEmptyResult) {
118+
Box(
119+
modifier = Modifier.fillMaxSize(),
120+
contentAlignment = Alignment.Center,
121+
) {
122+
Text(
123+
text = stringResource(R.string.empty_results),
124+
color = ReedTheme.colors.contentSecondary,
125+
style = ReedTheme.typography.body1Medium,
126+
)
127+
}
115128
} else {
116129
Row(
117130
modifier = Modifier
@@ -130,8 +143,7 @@ internal fun SearchContent(
130143
text = "${state.searchResult.totalResults}",
131144
color = ReedTheme.colors.contentBrand,
132145
style = ReedTheme.typography.label1Medium,
133-
134-
)
146+
)
135147
Text(
136148
text = stringResource(R.string.search_result_suffix),
137149
color = ReedTheme.colors.contentPrimary,

feature/search/src/main/kotlin/com/ninecraft/booket/feature/search/SearchUiState.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import kotlinx.collections.immutable.persistentListOf
1111
sealed interface UiState {
1212
data object Idle : UiState
1313
data object Loading : UiState
14+
data object Success : UiState
1415
data class Error(val message: String) : UiState
1516
}
1617

@@ -24,14 +25,14 @@ sealed interface FooterState {
2425
data class SearchUiState(
2526
val uiState: UiState = UiState.Idle,
2627
val footerState: FooterState = FooterState.Idle,
27-
val searchText: TextFieldState = TextFieldState(""),
28+
val queryState: TextFieldState = TextFieldState(""),
2829
val searchResult: BookSearchModel = BookSearchModel(),
2930
val books: ImmutableList<BookSummaryModel> = persistentListOf(),
30-
val offset: Int = 0,
31+
val startIndex: Int = 0,
3132
val isLastPage: Boolean = false,
3233
val eventSink: (SearchUiEvent) -> Unit,
3334
) : CircuitUiState {
34-
val isEmpty: Boolean get() = searchResult.books.isEmpty()
35+
val isEmptyResult: Boolean get() = uiState is UiState.Success && searchResult.totalResults == 0
3536
}
3637

3738
sealed interface SearchUiEvent : CircuitUiEvent {

feature/search/src/main/kotlin/com/ninecraft/booket/feature/search/component/LoadStateFooter.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.padding
88
import androidx.compose.foundation.layout.size
99
import androidx.compose.material3.Button
1010
import androidx.compose.material3.CircularProgressIndicator
11-
import androidx.compose.material3.MaterialTheme
1211
import androidx.compose.material3.Text
1312
import androidx.compose.runtime.Composable
1413
import androidx.compose.ui.Alignment
@@ -35,7 +34,7 @@ internal fun LoadStateFooter(
3534
is FooterState.Loading -> {
3635
CircularProgressIndicator(
3736
modifier = Modifier.size(24.dp),
38-
color = MaterialTheme.colorScheme.primary,
37+
color = ReedTheme.colors.contentBrand,
3938
)
4039
}
4140

@@ -46,8 +45,8 @@ internal fun LoadStateFooter(
4645
) {
4746
Text(
4847
text = footerState.message,
48+
color = ReedTheme.colors.contentError,
4949
style = ReedTheme.typography.body2Regular,
50-
color = MaterialTheme.colorScheme.error,
5150
)
5251
Button(onClick = onRetryClick) {
5352
Text(text = stringResource(R.string.retry))
@@ -58,8 +57,8 @@ internal fun LoadStateFooter(
5857
is FooterState.End -> {
5958
Text(
6059
text = stringResource(R.string.no_more_results),
60+
color = ReedTheme.colors.contentSecondary,
6161
style = ReedTheme.typography.body2Regular,
62-
color = MaterialTheme.colorScheme.onSurfaceVariant,
6362
)
6463
}
6564

@@ -68,4 +67,4 @@ internal fun LoadStateFooter(
6867
}
6968
}
7069
}
71-
}
70+
}

feature/search/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
<string name="retry">다시 시도</string>
77
<string name="no_more_results">더 이상 결과가 없습니다</string>
88
<string name="error_message">오류가 발생했습니다</string>
9+
<string name="empty_results">검색어와 일치하는 도서가 없습니다</string>
910
</resources>

0 commit comments

Comments
 (0)