Skip to content

Commit

Permalink
Merge pull request #282 from boostcampwm2023/android/feature/281
Browse files Browse the repository at this point in the history
UI 개선, 바텀 내비게이션 애니메이션 적용
  • Loading branch information
HamBP authored Dec 6, 2023
2 parents 1360fde + 173f4c3 commit df582de
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
15 changes: 14 additions & 1 deletion android/app/src/main/java/com/ohdodok/catchytape/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ohdodok.catchytape

import android.animation.ObjectAnimator
import android.content.ComponentName
import android.net.ConnectivityManager
import android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED
Expand All @@ -8,6 +9,7 @@ import android.view.View
import android.widget.Toast
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.animation.doOnEnd
import androidx.core.view.WindowCompat
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
Expand Down Expand Up @@ -35,6 +37,8 @@ import kotlinx.coroutines.launch
import javax.inject.Inject
import com.ohdodok.catchytape.core.ui.R.string as uiString

private const val BOTTOM_NAV_ANIMATION_DURATION = 700L

@AndroidEntryPoint
class MainActivity : AppCompatActivity() {

Expand Down Expand Up @@ -115,11 +119,20 @@ class MainActivity : AppCompatActivity() {
}

private fun hideBottomNav() {
binding.bottomNav.visibility = View.GONE
val height = binding.bottomNav.height.toFloat()
ObjectAnimator.ofFloat(binding.bottomNav, "translationY", height).apply {
duration = BOTTOM_NAV_ANIMATION_DURATION
doOnEnd { binding.bottomNav.visibility = View.GONE }
start()
}
}

private fun showBottomNav() {
binding.bottomNav.visibility = View.VISIBLE
ObjectAnimator.ofFloat(binding.bottomNav, "translationY", 0f).apply {
duration = BOTTOM_NAV_ANIMATION_DURATION
start()
}
}

private fun hidePlayerController() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
android:id="@+id/iv_thumbnail"
android:layout_width="@dimen/music_horizontal_img"
android:layout_height="@dimen/music_horizontal_img"
android:scaleType="centerCrop"
app:imgUrl="@{music.imageUrl}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
android:id="@+id/iv_thumbnail"
android:layout_width="@dimen/music_vertical_img"
android:layout_height="@dimen/music_vertical_img"
android:scaleType="centerCrop"
app:imgUrl="@{music.imageUrl}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ interface PlayerEventListener {

fun onPlayingChanged(isPlaying: Boolean)

fun onMediaItemChanged(duration: Int)
fun onMediaItemChanged(index: Int, duration: Int)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class PlayerListener(

events.containsAny(Player.EVENT_TIMELINE_CHANGED, Player.EVENT_MEDIA_ITEM_TRANSITION) -> {
val durationMs = player.duration.toInt()
listener.onMediaItemChanged(durationMs / millisecondsPerSecond)
listener.onMediaItemChanged(player.currentMediaItemIndex, durationMs / millisecondsPerSecond)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ class PlayerViewModel @Inject constructor(
}
}

override fun onMediaItemChanged(duration: Int) {
_uiState.update { it.copy(duration = duration) }
override fun onMediaItemChanged(index: Int, duration: Int) {

_uiState.update {
it.copy(duration = duration)
}
}
}

0 comments on commit df582de

Please sign in to comment.