Skip to content

Commit 9f1cdd0

Browse files
authored
feat: '내 주변' 버튼 클릭시 버튼 및 내부 색상 변경 로직 구현 (#20)
1 parent 8902f66 commit 9f1cdd0

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

app/src/main/java/com/woozoo/menumonya/MainActivity.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import android.Manifest
44
import android.content.Intent
55
import android.content.Intent.ACTION_VIEW
66
import android.content.pm.PackageManager
7-
import android.net.Ur
7+
import android.net.Uri
88
import android.os.Bundle
99
import android.provider.Settings
1010
import android.view.View
@@ -137,6 +137,11 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
137137
}
138138
}.create().show()
139139
}
140+
is Event.MoveToCurrentLocation -> {
141+
binding.currentLocationBtn.background = resources.getDrawable(R.drawable.current_location_button_selected)
142+
binding.currentLocationTv.setTextColor(resources.getColor(R.color.colorSecondary))
143+
binding.currentLocationIv.setColorFilter(resources.getColor(R.color.colorSecondary))
144+
}
140145
}
141146

142147
override fun onStart() {
@@ -185,6 +190,10 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
185190
binding.locationYsBtn.background = applicationContext.getDrawable(R.drawable.white_button_background)
186191
binding.locationGnBtn.setTextColor(applicationContext.getColor(R.color.white))
187192
binding.locationYsBtn.setTextColor(applicationContext.getColor(R.color.gray600))
193+
194+
binding.currentLocationBtn.background = resources.getDrawable(R.drawable.current_location_button)
195+
binding.currentLocationTv.setTextColor(resources.getColor(R.color.colorPrimary))
196+
binding.currentLocationIv.setColorFilter(resources.getColor(R.color.colorPrimary))
188197
}
189198
R.id.location_ys_btn -> {
190199
viewPager.invalidate()
@@ -195,6 +204,10 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
195204
binding.locationGnBtn.background = applicationContext.getDrawable(R.drawable.white_button_background)
196205
binding.locationYsBtn.setTextColor(applicationContext.getColor(R.color.white))
197206
binding.locationGnBtn.setTextColor(applicationContext.getColor(R.color.gray600))
207+
208+
binding.currentLocationBtn.background = resources.getDrawable(R.drawable.current_location_button)
209+
binding.currentLocationTv.setTextColor(resources.getColor(R.color.colorPrimary))
210+
binding.currentLocationIv.setColorFilter(resources.getColor(R.color.colorPrimary))
198211
}
199212
R.id.feedback_iv -> {
200213
val intent = Intent(ACTION_VIEW, Uri.parse(FEEDBACK_URL))

app/src/main/java/com/woozoo/menumonya/MainViewModel.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ class MainViewModel(application: Application): AndroidViewModel(Application()) {
257257
locationSource = FusedLocationSource(activity, LOCATION_PERMISSION_REQUEST_CODE)
258258
locationTrackingMode = LocationTrackingMode.Follow
259259
}
260+
moveToCurrentLocation()
260261
})
261262
}
262263
}
@@ -281,6 +282,9 @@ class MainViewModel(application: Application): AndroidViewModel(Application()) {
281282
private fun showGpsPermissionAlert() {
282283
event(Event.ShowGpsPermissionAlert(""))
283284
}
285+
private fun moveToCurrentLocation() {
286+
event(Event.MoveToCurrentLocation(""))
287+
}
284288

285289
sealed class Event {
286290
/**
@@ -293,5 +297,6 @@ class MainViewModel(application: Application): AndroidViewModel(Application()) {
293297
data class OnMarkerClicked(val markerIndex: Int, val location: String): Event()
294298
data class RequestLocationPermission(val data: String): Event()
295299
data class ShowGpsPermissionAlert(val data: String): Event()
300+
data class MoveToCurrentLocation(val data: String): Event()
296301
}
297302
}

app/src/main/res/drawable/current_location_button.xml renamed to app/src/main/res/drawable/current_location_button_selected.xml

File renamed without changes.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
android:viewportHeight="12">
66
<path
77
android:pathData="M4.787,2V0.5L2.82,2.5L4.787,4.5V3C6.415,3 7.738,4.345 7.738,6C7.738,6.505 7.615,6.985 7.393,7.4L8.111,8.13C8.495,7.515 8.721,6.785 8.721,6C8.721,3.79 6.961,2 4.787,2ZM4.787,9C3.159,9 1.836,7.655 1.836,6C1.836,5.495 1.959,5.015 2.18,4.6L1.462,3.87C1.079,4.485 0.852,5.215 0.852,6C0.852,8.21 2.613,10 4.787,10V11.5L6.754,9.5L4.787,7.5V9Z"
8-
android:fillColor="@color/colorSecondary"/>
8+
android:fillColor="@color/colorPrimary"/>
99
</vector>

app/src/main/res/layout/activity_main.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,20 @@
8282
>
8383

8484
<ImageView
85+
android:id="@+id/current_location_iv"
8586
android:layout_width="wrap_content"
8687
android:layout_height="wrap_content"
8788
android:layout_marginEnd="@dimen/current_location_image_margin_end"
8889
android:src="@drawable/current_location_icon"
8990
/>
9091

9192
<TextView
93+
android:id="@+id/current_location_tv"
9294
android:layout_width="wrap_content"
9395
android:layout_height="wrap_content"
9496
android:text="내 주변"
9597
android:fontFamily="@font/pretendard_bold"
96-
android:textColor="@color/colorSecondary"
98+
android:textColor="@color/colorPrimary"
9799
android:textSize="@dimen/current_location_text_size"
98100
android:textStyle="bold"
99101
/>

0 commit comments

Comments
 (0)