Skip to content

Commit

Permalink
Merge pull request #64 from team-JMT/fix/home_ui
Browse files Browse the repository at this point in the history
UI 이슈 수정
  • Loading branch information
soopeach authored Sep 10, 2023
2 parents eb797af + 44ad4ce commit 3ba4843
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.gdsc.presentation.utils

import android.animation.Animator
import android.animation.ObjectAnimator
import android.view.View
import android.view.animation.AlphaAnimation
Expand Down Expand Up @@ -47,12 +48,12 @@ fun View.slideUp(duration: Long = 200) {
}
}

fun View.slideDown(duration: Long = 200) {
fun View.slideDown(duration: Long = 200, endListener: Animator.AnimatorListener) {
val self = this
ObjectAnimator
.ofFloat(self, "translationY", self.height.toFloat())
.apply {
setDuration(duration)
start()
}
}.addListener(endListener)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.gdsc.presentation.view

import android.Manifest
import android.animation.Animator
import android.annotation.SuppressLint
import android.content.Intent
import android.content.pm.PackageManager
Expand All @@ -10,6 +11,7 @@ import android.os.Bundle
import android.provider.Settings
import android.view.MenuItem
import android.view.View
import android.view.animation.Animation
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
Expand All @@ -26,8 +28,9 @@ import org.gdsc.presentation.databinding.ActivityMainBinding
import org.gdsc.presentation.utils.slideDown
import org.gdsc.presentation.utils.slideUp
import org.gdsc.presentation.utils.toPx
import org.gdsc.presentation.view.mypage.viewmodel.MyPageViewModel
import org.gdsc.presentation.view.home.HomeFragmentDirections
import org.gdsc.presentation.view.mypage.viewmodel.MyPageViewModel


@AndroidEntryPoint
class MainActivity : BaseActivity() {
Expand Down Expand Up @@ -172,10 +175,22 @@ class MainActivity : BaseActivity() {
}

fun slideDownBottomNavigationView() {
binding.bottomNavigationView.slideDown()
val myAnimationListener: Animator.AnimatorListener =
object : Animator.AnimatorListener {
override fun onAnimationStart(p0: Animator) {}
override fun onAnimationEnd(p0: Animator) {

binding.bottomNavigationView.visibility = View.GONE
}

override fun onAnimationCancel(p0: Animator) {}
override fun onAnimationRepeat(p0: Animator) {}
}
binding.bottomNavigationView.slideDown(endListener = myAnimationListener)
}

fun slideUpBottomNavigationView() {
binding.bottomNavigationView.visibility = View.VISIBLE
binding.bottomNavigationView.slideUp()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import androidx.navigation.fragment.findNavController
import com.bumptech.glide.Glide
import com.google.android.material.tabs.TabLayoutMediator
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.collectLatest
import org.gdsc.domain.Empty
import org.gdsc.presentation.R
import org.gdsc.presentation.databinding.FragmentMyPageBinding
Expand Down Expand Up @@ -105,8 +107,11 @@ class MyPageFragment : Fragment() {
private fun setCollapsingToolbarOffChangedCallback() {
binding.appBarLayout.addOnOffsetChangedListener { _, verticalOffset ->
if (verticalOffset == -binding.collapsingToolbar.height) {
// TODO: User Nickname From ViewModel
setToolbarTitle(viewModel.nicknameState.value)
repeatWhenUiStarted {
viewModel.nicknameState.collectLatest {
setToolbarTitle(it)
}
}
} else {
setToolbarTitle()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class RegisteredRestaurantFragment : Fragment() {

private fun observeState() {

lifecycleScope.launch {
repeatWhenUiStarted {
viewModel.idState.collectLatest { id ->

id?.let { notNullId ->
Expand All @@ -77,19 +77,19 @@ class RegisteredRestaurantFragment : Fragment() {
}
}

lifecycleScope.launch {
repeatWhenUiStarted {
viewModel.sortTypeState.collectLatest {
binding.sortSpinner.setMenuTitle(it.text)
}
}

lifecycleScope.launch {
repeatWhenUiStarted {
viewModel.foodCategoryState.collectLatest {
binding.foodCategorySpinner.setMenuTitle(it.text)
}
}

lifecycleScope.launch {
repeatWhenUiStarted {
viewModel.drinkPossibilityState.collectLatest {
binding.drinkPossibilitySpinner.setMenuTitle(it.text)
}
Expand Down

0 comments on commit 3ba4843

Please sign in to comment.