Skip to content

Commit e06a7b0

Browse files
nyunn2wjshim2003kevin990222
authored
필터 디자인 수정 (#139)
* 여백 수정, 말풍선 변경 * 글꼴 수정 * 여백 수정 * Remove unnecessary files from PR * gradle 관련 파일 복구 * Revert "gradle 관련 파일 복구" This reverts commit a5ad318. * fix gitignore * Revert "Remove unnecessary files from PR" This reverts commit 6c285d4. * fix gitignore * Delete .idea/deploymentTargetSelector.xml * Delete .idea/kotlinc.xml * Delete .idea/migrations.xml * 거리 슬라이더 말풍선 연결 * Conlict 해결하다 놓친것들 * 거리 랭지 text 해결 * lint * 거리 말풍선 수정 * 초기 위치 수정 * lint --------- Co-authored-by: Shim Woojin <wjshim@snu.ac.kr> Co-authored-by: kevin990222 <113081855+kevin990222@users.noreply.github.com>
1 parent 8411b16 commit e06a7b0

File tree

12 files changed

+440
-217
lines changed

12 files changed

+440
-217
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ captures/
4343

4444
# IntelliJ
4545
*.iml
46+
.idea/*
4647
.idea/workspace.xml
4748
.idea/tasks.xml
4849
.idea/gradle.xml
@@ -245,4 +246,5 @@ fabric.properties
245246

246247
.idea/codeStyles/Project.xml
247248
.idea/codeStyles/codeStyleConfig.xml
248-
.idea/runConfigurations.xml
249+
.idea/runConfigurations.xml
250+
/.idea/deploymentTargetSelector.xml

.idea/kotlinc.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

app/src/main/java/com/wafflestudio/siksha2/ui/main/restaurant/FilterDialogFragment.kt

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ import android.content.res.Resources
66
import android.graphics.Color
77
import android.graphics.Outline
88
import android.os.Bundle
9+
import android.os.Handler
10+
import android.os.Looper
911
import android.util.TypedValue
1012
import android.view.LayoutInflater
1113
import android.view.View
1214
import android.view.ViewGroup
1315
import android.view.ViewOutlineProvider
1416
import android.widget.GridLayout
1517
import androidx.core.content.ContextCompat
18+
import androidx.core.content.res.ResourcesCompat
1619
import androidx.core.os.bundleOf
1720
import androidx.core.view.children
1821
import androidx.fragment.app.activityViewModels
@@ -21,6 +24,7 @@ import androidx.lifecycle.lifecycleScope
2124
import com.google.android.material.bottomsheet.BottomSheetDialog
2225
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
2326
import com.google.android.material.chip.Chip
27+
import com.google.android.material.slider.RangeSlider
2428
import com.wafflestudio.siksha2.R
2529
import com.wafflestudio.siksha2.databinding.DialogFilterBinding
2630
import kotlinx.coroutines.launch
@@ -109,10 +113,22 @@ class FilterDialogFragment(
109113
}
110114

111115
private fun setupDistanceSelection() {
116+
val initialValue = listOf(selectedCondition.distance)
117+
binding.distanceRangeSlider.setValues(initialValue)
118+
updateDistanceText(selectedCondition.distance.toInt())
119+
updateDistanceBubblePosition(binding.distanceRangeSlider)
120+
121+
binding.distanceRangeSlider.post {
122+
updateDistanceBubblePosition(binding.distanceRangeSlider)
123+
}
124+
112125
binding.distanceRangeSlider.addOnChangeListener { slider, _, _ ->
113126
val value = slider.values[0]
114127
selectedCondition = selectedCondition.copy(distance = value)
115128
updateDistanceText(selectedCondition.distance.toInt())
129+
Handler(Looper.getMainLooper()).post {
130+
updateDistanceBubblePosition(slider)
131+
}
116132
}
117133
}
118134

@@ -159,6 +175,8 @@ class FilterDialogFragment(
159175
private fun setupCategorySelection() {
160176
binding.gridCategory.removeAllViews()
161177

178+
val nanumSquareBold = ResourcesCompat.getFont(requireContext(), R.font.nanum_square_bold)
179+
162180
categorySet.forEachIndexed { index, category ->
163181
val chip = Chip(requireContext()).apply {
164182
text = category
@@ -167,6 +185,8 @@ class FilterDialogFragment(
167185
isFocusable = true
168186
checkedIcon = null
169187

188+
typeface = nanumSquareBold
189+
170190
layoutParams = GridLayout.LayoutParams().apply {
171191
width = dpToPx(56) // 56dp
172192
height = dpToPx(48) // 34dp
@@ -285,7 +305,23 @@ class FilterDialogFragment(
285305
}
286306

287307
private fun updateDistanceText(distance: Int) {
288-
binding.tvDistance.text = if (distance >= defaultCondition.distance.toInt()) "1km 이상" else "${distance}m 이내"
308+
binding.tvDistanceRange.text = if (distance >= defaultCondition.distance.toInt()) {
309+
"1km 이상"
310+
} else {
311+
"${distance}m 이내"
312+
}
313+
}
314+
315+
private fun updateDistanceBubblePosition(rangeSlider: RangeSlider) {
316+
val valueRangeSize = rangeSlider.valueTo - rangeSlider.valueFrom
317+
val valuePercent = (rangeSlider.values[0] - rangeSlider.valueFrom) / valueRangeSize
318+
val valueXDistance = valuePercent * rangeSlider.trackWidth
319+
val offset = rangeSlider.x + rangeSlider.trackSidePadding - (binding.distanceBubble.width / 2f)
320+
321+
val minX = rangeSlider.x + rangeSlider.trackSidePadding + 10f
322+
val maxX = minX + rangeSlider.trackWidth - binding.distanceBubble.width + 10f
323+
324+
binding.distanceBubble.x = valueXDistance.coerceIn(minX, maxX) + offset
289325
}
290326

291327
private fun updatePriceRangeText(minPrice: Int, maxPrice: Int) {

app/src/main/res/drawable/bg_speech_bubble.xml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,8 @@
33
<item>
44
<shape android:shape="rectangle">
55
<solid android:color="#F0F0F0"/>
6-
<corners android:radius="4dp"/>
6+
<corners android:radius="2dp"/>
77
</shape>
88
</item>
9-
<!-- 말풍선 화살표 -->
10-
<item android:gravity="bottom|center_horizontal">
11-
<rotate android:fromDegrees="45" android:toDegrees="45" android:pivotX="50%" android:pivotY="0%">
12-
<shape android:shape="rectangle">
13-
<size android:width="8dp" android:height="8dp"/>
14-
<solid android:color="#F0F0F0"/>
15-
</shape>
16-
</rotate>
17-
</item>
18-
</layer-list>
9+
</layer-list>
10+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:width="8dp"
4+
android:height="5dp"
5+
android:viewportWidth="8"
6+
android:viewportHeight="5">
7+
8+
<!-- 아래쪽 역삼각형 모양 -->
9+
<path
10+
android:fillColor="#F0F0F0"
11+
android:pathData="M0,0 L4,5 L8,0 Z" />
12+
</vector>
13+
14+

0 commit comments

Comments
 (0)