-
Notifications
You must be signed in to change notification settings - Fork 1
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
검색 - 키워드 입력 #266
검색 - 키워드 입력 #266
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:pathData="M21,21L15,15M3,10C3,10.919 3.181,11.83 3.533,12.679C3.885,13.528 4.4,14.3 5.05,14.95C5.7,15.6 6.472,16.115 7.321,16.467C8.17,16.819 9.081,17 10,17C10.919,17 11.83,16.819 12.679,16.467C13.528,16.115 14.3,15.6 14.95,14.95C15.6,14.3 16.115,13.528 16.467,12.679C16.819,11.83 17,10.919 17,10C17,9.081 16.819,8.17 16.467,7.321C16.115,6.472 15.6,5.7 14.95,5.05C14.3,4.4 13.528,3.885 12.679,3.533C11.83,3.181 10.919,3 10,3C9.081,3 8.17,3.181 7.321,3.533C6.472,3.885 5.7,4.4 5.05,5.05C4.4,5.7 3.885,6.472 3.533,7.321C3.181,8.17 3,9.081 3,10Z" | ||
android:strokeLineJoin="round" | ||
android:strokeWidth="2" | ||
android:fillColor="#00000000" | ||
android:strokeColor="@color/on_surface" | ||
android:strokeLineCap="round"/> | ||
</vector> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<corners android:radius="22dp" /> | ||
</shape> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed | ||
plugins { | ||
id("catchytape.android.feature") | ||
} | ||
|
||
android { | ||
namespace = "com.ohdodok.catchytape.feature.search" | ||
|
||
defaultConfig { | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles("consumer-rules.pro") | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
kotlinOptions { | ||
jvmTarget = "17" | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.ohdodok.catchytape.feature.search | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.fragment.app.viewModels | ||
import com.ohdodok.catchytape.core.ui.BaseFragment | ||
import com.ohdodok.catchytape.feature.search.databinding.FragmentSearchBinding | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
@AndroidEntryPoint | ||
class SearchFragment : BaseFragment<FragmentSearchBinding>(R.layout.fragment_search) { | ||
|
||
private val viewModel: SearchViewModel by viewModels() | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
binding.viewModel = viewModel | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.ohdodok.catchytape.feature.search | ||
|
||
import androidx.lifecycle.ViewModel | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.asStateFlow | ||
import kotlinx.coroutines.flow.update | ||
import javax.inject.Inject | ||
|
||
data class SearchUiState( | ||
val keyword: String = "", | ||
) | ||
|
||
@HiltViewModel | ||
class SearchViewModel @Inject constructor( | ||
|
||
) : ViewModel() { | ||
|
||
private val _uiState = MutableStateFlow(SearchUiState()) | ||
val uiState: StateFlow<SearchUiState> = _uiState.asStateFlow() | ||
|
||
fun updateKeyword(newKeyword: String) { | ||
_uiState.update { it.copy(keyword = newKeyword) } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
||
<data> | ||
|
||
<variable | ||
name="viewModel" | ||
type="com.ohdodok.catchytape.feature.search.SearchViewModel" /> | ||
</data> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<EditText | ||
android:layout_width="0dp" | ||
android:layout_height="44dp" | ||
android:layout_margin="@dimen/margin_horizontal" | ||
android:background="@drawable/search_bar_background" | ||
android:backgroundTint="@color/surface_bright" | ||
android:hint="@string/input_keyword" | ||
android:text="@{viewModel.uiState.keyword}" | ||
android:onTextChanged="@{(text, s, b, c) -> viewModel.updateKeyword(text.toString())}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 텍스트가 바뀌면 viewmodel에 업데이트 하고 또 viewmodel에서 업데이트 된 텍스트를 text에 넣는 것 같은데, 위에 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ViewModel에서 text를 조작하는 경우를 고려한 코드긴 한데, 일단 제거하고 올릴게! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아항 그런 의도의 코드였군요 ! |
||
android:paddingHorizontal="@dimen/margin_horizontal" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</layout> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<navigation xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/search_nav_graph" | ||
app:startDestination="@id/search_fragment"> | ||
|
||
<fragment | ||
android:id="@+id/search_fragment" | ||
android:name="com.ohdodok.catchytape.feature.search.SearchFragment" | ||
android:label="search" | ||
tools:layout="@layout/fragment_search" /> | ||
|
||
</navigation> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="input_keyword">검색어를 입력하세요.</string> | ||
</resources> |
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.
검색 UI 구현할때,
com.google.android.material.search.SearchView
을 쓰지 않은 이유가 있으신가요? (궁금해서 여쭤봅니다)https://github.com/material-components/material-components-android/blob/master/docs/components/Search.md
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.
SearchView보다 EditText를 커스텀하는 게 더 쉬울 거라 생각했어