Skip to content

Commit e60893b

Browse files
authored
Merge pull request #44 from boostcampwm-2022/17-feature-alarmsettingview
[PR] μ•ŒλžŒ μ„€μ • ν™”λ©΄ λ·° κ΅¬ν˜„
2 parents 11c3848 + b58abb9 commit e60893b

File tree

9 files changed

+365
-9
lines changed

9 files changed

+365
-9
lines changed

β€Žpresentation/src/main/java/com/stop/ui/alarmsetting/AlarmSettingFragment.kt

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,90 @@
11
package com.stop.ui.alarmsetting
22

33
import android.os.Bundle
4-
import androidx.fragment.app.Fragment
4+
import android.transition.AutoTransition
5+
import android.transition.TransitionManager
56
import android.view.LayoutInflater
67
import android.view.View
78
import android.view.ViewGroup
9+
import androidx.fragment.app.Fragment
10+
import androidx.fragment.app.viewModels
811
import com.stop.R
912
import com.stop.databinding.FragmentAlarmSettingBinding
13+
import dagger.hilt.android.AndroidEntryPoint
1014

15+
@AndroidEntryPoint
1116
class AlarmSettingFragment : Fragment() {
17+
1218
private var _binding: FragmentAlarmSettingBinding? = null
1319
private val binding get() = _binding!!
1420

21+
private val alarmSettingViewModel by viewModels<AlarmSettingViewModel>()
22+
1523
override fun onCreateView(
1624
inflater: LayoutInflater, container: ViewGroup?,
1725
savedInstanceState: Bundle?
1826
): View? {
1927
_binding = FragmentAlarmSettingBinding.inflate(inflater, container, false)
2028

29+
initBinding()
30+
2131
return binding.root
2232
}
2333

34+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
35+
super.onViewCreated(view, savedInstanceState)
36+
37+
initView()
38+
setButtonListener()
39+
}
40+
41+
private fun initBinding(){
42+
binding.apply {
43+
lifecycleOwner = viewLifecycleOwner
44+
viewModel = alarmSettingViewModel
45+
}
46+
}
47+
48+
private fun initView() {
49+
with(binding){
50+
textViewLastTime.text = getString(R.string.last_transport_arrival_time, 23, 30)
51+
textViewWalk.text = getString(R.string.last_transport_walking_time, 10)
52+
53+
numberPickerAlarmTime.minValue = 0
54+
numberPickerAlarmTime.maxValue = 60
55+
}
56+
}
57+
58+
private fun setButtonListener() {
59+
with(binding) {
60+
textViewRouteContent.setOnClickListener {
61+
if (textViewTransportContent.visibility == View.VISIBLE) {
62+
setTransportViewGone()
63+
} else {
64+
setTransportViewVisible()
65+
}
66+
}
67+
}
68+
}
69+
70+
private fun setTransportViewGone() {
71+
with(binding) {
72+
TransitionManager.beginDelayedTransition(cardViewRoute, AutoTransition())
73+
textViewTransportContent.visibility = View.GONE
74+
textViewRouteContent.setCompoundDrawables(null, null, null, null)
75+
textViewRouteContent.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_baseline_keyboard_arrow_down_24, 0)
76+
}
77+
}
78+
79+
private fun setTransportViewVisible() {
80+
with(binding) {
81+
TransitionManager.beginDelayedTransition(cardViewRoute, AutoTransition())
82+
textViewTransportContent.visibility = View.VISIBLE
83+
textViewRouteContent.setCompoundDrawables(null, null, null, null)
84+
textViewRouteContent.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_baseline_keyboard_arrow_up_24, 0)
85+
}
86+
}
87+
2488
override fun onDestroyView() {
2589
_binding = null
2690
super.onDestroyView()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.stop.ui.alarmsetting
2+
3+
import androidx.lifecycle.MutableLiveData
4+
import androidx.lifecycle.ViewModel
5+
import dagger.hilt.android.lifecycle.HiltViewModel
6+
import javax.inject.Inject
7+
8+
@HiltViewModel
9+
class AlarmSettingViewModel @Inject constructor() : ViewModel() {
10+
11+
val alarmTime = MutableLiveData(0)
12+
13+
}

β€Žpresentation/src/main/java/com/stop/ui/placesearch/PlaceSearchFragment.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class PlaceSearchFragment : Fragment() {
3535
): View {
3636
_binding = DataBindingUtil.inflate(inflater, R.layout.fragment_place_search, container, false)
3737

38+
initBinding()
39+
3840
return binding.root
3941
}
4042

@@ -43,7 +45,6 @@ class PlaceSearchFragment : Fragment() {
4345

4446
initAdapter()
4547
buttonClick()
46-
initBinding()
4748
listenEditTextChange()
4849
logErrorMessage()
4950
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:autoMirrored="true" android:height="32dp"
2+
android:tint="#000000" android:viewportHeight="24"
3+
android:viewportWidth="24" android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="@android:color/white" android:pathData="M13.5,5.5c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM9.8,8.9L7,23h2.1l1.8,-8 2.1,2v6h2v-7.5l-2.1,-2 0.6,-3C14.8,12 16.8,13 19,13v-2c-1.9,0 -3.5,-1 -4.3,-2.4l-1,-1.6c-0.4,-0.6 -1,-1 -1.7,-1 -0.3,0 -0.5,0.1 -0.8,0.1L6,8.3V13h2V9.6l1.8,-0.7"/>
5+
</vector>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#000000"
2+
android:viewportHeight="24" android:viewportWidth="24"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="@android:color/white" android:pathData="M7.41,8.59L12,13.17l4.59,-4.58L18,10l-6,6 -6,-6 1.41,-1.41z"/>
5+
</vector>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#000000"
2+
android:viewportHeight="24" android:viewportWidth="24"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="@android:color/white" android:pathData="M7.41,15.41L12,10.83l4.59,4.58L18,14l-6,-6 -6,6z"/>
5+
</vector>

0 commit comments

Comments
Β (0)