diff --git a/presentation/src/main/java/com/whyranoid/presentation/runningstart/RunningStartFragment.kt b/presentation/src/main/java/com/whyranoid/presentation/runningstart/RunningStartFragment.kt new file mode 100644 index 00000000..e833d5d4 --- /dev/null +++ b/presentation/src/main/java/com/whyranoid/presentation/runningstart/RunningStartFragment.kt @@ -0,0 +1,33 @@ +package com.whyranoid.presentation.runningstart + +import android.os.Bundle +import android.view.View +import androidx.fragment.app.viewModels +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.lifecycleScope +import androidx.lifecycle.repeatOnLifecycle +import com.whyranoid.presentation.R +import com.whyranoid.presentation.base.BaseFragment +import com.whyranoid.presentation.databinding.FragmentRunningStartBinding +import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.launch + +@AndroidEntryPoint +internal class RunningStartFragment : + BaseFragment(R.layout.fragment_running_start) { + + private val viewModel by viewModels() + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + binding.vm = viewModel + + lifecycleScope.launch { + viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) { + viewModel.runnerCount.collect { runnerCount -> + binding.tvRunnerCountNumber.text = runnerCount.toString() + } + } + } + } +} diff --git a/presentation/src/main/java/com/whyranoid/presentation/runningstart/RunningStartViewModel.kt b/presentation/src/main/java/com/whyranoid/presentation/runningstart/RunningStartViewModel.kt new file mode 100644 index 00000000..1e1c354f --- /dev/null +++ b/presentation/src/main/java/com/whyranoid/presentation/runningstart/RunningStartViewModel.kt @@ -0,0 +1,14 @@ +package com.whyranoid.presentation.runningstart + +import androidx.lifecycle.ViewModel +import com.whyranoid.domain.usecase.GetRunnerCountUseCase +import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject + +@HiltViewModel +class RunningStartViewModel @Inject constructor( + getRunnerCountUseCase: GetRunnerCountUseCase +) : ViewModel() { + + val runnerCount = getRunnerCountUseCase() +}