@@ -3,6 +3,7 @@ package com.stop.ui.map
3
3
import android.Manifest.permission
4
4
import android.os.Bundle
5
5
import android.util.Log
6
+ import android.util.TypedValue
6
7
import android.view.LayoutInflater
7
8
import android.view.View
8
9
import android.view.ViewGroup
@@ -12,6 +13,7 @@ import androidx.fragment.app.activityViewModels
12
13
import androidx.lifecycle.flowWithLifecycle
13
14
import androidx.lifecycle.lifecycleScope
14
15
import androidx.navigation.findNavController
16
+ import com.google.android.material.bottomsheet.BottomSheetBehavior
15
17
import com.skt.tmap.TMapPoint
16
18
import com.stop.R
17
19
import com.stop.databinding.FragmentMapBinding
@@ -49,13 +51,13 @@ class MapFragment : Fragment(), MapHandler {
49
51
initView()
50
52
clickSearchButton()
51
53
clickEndLocation()
54
+ initBottomSheetBehavior()
52
55
}
53
56
54
57
private fun initBinding () {
55
- binding.apply {
56
- lifecycleOwner = viewLifecycleOwner
57
- viewModel = placeSearchViewModel
58
- }
58
+ binding.lifecycleOwner = viewLifecycleOwner
59
+ binding.placeSearchViewModel = placeSearchViewModel
60
+ binding.alarmViewModel = alarmViewModel
59
61
}
60
62
61
63
private fun initTMap () {
@@ -66,11 +68,11 @@ class MapFragment : Fragment(), MapHandler {
66
68
}
67
69
68
70
private fun initView () {
69
- binding.imageViewCompassMode .setOnClickListener {
71
+ binding.layoutCompass .setOnClickListener {
70
72
tMap.tMapView.isCompassMode = tMap.tMapView.isCompassMode.not ()
71
73
}
72
74
73
- binding.imageViewCurrentLocation .setOnClickListener {
75
+ binding.layoutCurrent .setOnClickListener {
74
76
requestPermissionsLauncher.launch(PERMISSIONS )
75
77
tMap.tMapView.setCenterPoint(
76
78
placeSearchViewModel.currentLocation.latitude,
@@ -95,27 +97,37 @@ class MapFragment : Fragment(), MapHandler {
95
97
}
96
98
}
97
99
98
- }
99
- }
100
-
101
100
private fun clickSearchButton () {
102
101
binding.textViewSearch.setOnClickListener {
103
102
binding.root.findNavController().navigate(R .id.action_mapFragment_to_placeSearchFragment)
104
103
}
105
104
}
106
105
107
106
private fun clickEndLocation () {
108
- binding.textViewEndLocation .setOnClickListener {
107
+ binding.viewPanelEnd .setOnClickListener {
109
108
binding.root.findNavController().navigate(R .id.action_mapFragment_to_routeFragment)
110
109
}
111
110
}
112
111
112
+ private fun initBottomSheetBehavior () {
113
+ val behavior = BottomSheetBehavior .from(binding.layoutHomeBottomSheet)
114
+
115
+ alarmViewModel.bottomSheetVisibility.observe(viewLifecycleOwner) {
116
+ if (it) {
117
+ behavior.state = BottomSheetBehavior .STATE_EXPANDED
118
+ behavior.maxHeight = convertDpToPx(200 )
119
+ } else {
120
+ behavior.maxHeight = convertDpToPx(100 )
121
+ }
122
+ }
123
+ }
124
+
113
125
private fun setViewVisibility () {
114
126
with (binding) {
115
- textViewSearch .visibility = mapUIVisibility
116
- imageViewCompassMode .visibility = mapUIVisibility
117
- imageViewCurrentLocation .visibility = mapUIVisibility
118
- imageViewBookmark .visibility = mapUIVisibility
127
+ layoutSearch .visibility = mapUIVisibility
128
+ layoutCompass .visibility = mapUIVisibility
129
+ layoutCurrent .visibility = mapUIVisibility
130
+ layoutBookmark .visibility = mapUIVisibility
119
131
}
120
132
}
121
133
@@ -177,6 +189,14 @@ class MapFragment : Fragment(), MapHandler {
177
189
}
178
190
}
179
191
192
+ private fun convertDpToPx (dp : Int ): Int {
193
+ return TypedValue .applyDimension(
194
+ TypedValue .COMPLEX_UNIT_DIP ,
195
+ dp.toFloat(),
196
+ resources.displayMetrics
197
+ ).toInt()
198
+ }
199
+
180
200
override fun onDestroyView () {
181
201
_binding = null
182
202
@@ -214,14 +234,14 @@ class MapFragment : Fragment(), MapHandler {
214
234
215
235
companion object {
216
236
private const val PLACE_MARKER = " place_marker"
217
- private const val PLACE_MARKER_IMG = R .drawable.ic_baseline_location_on_32
237
+ private const val PLACE_MARKER_IMG = R .drawable.ic_point_marker
218
238
219
239
private const val PERSON_MARKER = " marker_person_pin"
220
- private const val PERSON_MARKER_IMG = R .drawable.ic_person_pin
240
+ private const val PERSON_MARKER_IMG = R .drawable.ic_person_marker
221
241
222
242
private const val SAME_POINT = 1
223
243
val PERMISSIONS = arrayOf(permission.ACCESS_FINE_LOCATION , permission.ACCESS_COARSE_LOCATION )
224
244
225
- private const val BOOKMARK_MARKER_IMG = R .drawable.ic_baseline_stars_32
245
+ private const val BOOKMARK_MARKER_IMG = R .drawable.ic_bookmark_marker
226
246
}
227
247
}
0 commit comments