Skip to content

Commit

Permalink
navigate termsOfService to surveySelector
Browse files Browse the repository at this point in the history
  • Loading branch information
anandwana001 committed Dec 3, 2024
1 parent d3db318 commit ec3cd1c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ constructor(
}

private fun requestNavigation(request: NavigationRequest) {
coroutineScope.launch(dispatcher) { _navigateRequests.emit(request) }
CoroutineScope(dispatcher).launch { _navigateRequests.emit(request) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.fragment.findNavController
import com.google.android.ground.databinding.FragmentTermsServiceBinding
import com.google.android.ground.ui.common.AbstractFragment
import com.google.android.ground.ui.surveyselector.SurveySelectorFragmentDirections
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class TermsOfServiceFragment : AbstractFragment() {

private lateinit var viewModel: TermsOfServiceViewModel
private lateinit var binding: FragmentTermsServiceBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -39,10 +42,18 @@ class TermsOfServiceFragment : AbstractFragment() {
savedInstanceState: Bundle?,
): View {
val args = TermsOfServiceFragmentArgs.fromBundle(requireArguments())
val binding = FragmentTermsServiceBinding.inflate(inflater, container, false)
binding = FragmentTermsServiceBinding.inflate(inflater, container, false)
binding.viewModel = viewModel
binding.isViewOnly = args.isViewOnly
binding.lifecycleOwner = this
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.agreeButton.setOnClickListener {
val navController = findNavController()
navController.navigate(SurveySelectorFragmentDirections.showSurveySelectorScreen(true))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import com.google.android.ground.repository.TermsOfServiceRepository
import com.google.android.ground.system.auth.AuthenticationManager
import com.google.android.ground.ui.common.AbstractViewModel
import com.google.android.ground.ui.common.EphemeralPopups
import com.google.android.ground.ui.common.Navigator
import com.google.android.ground.ui.surveyselector.SurveySelectorFragmentDirections
import com.google.android.ground.util.isPermissionDeniedException
import javax.inject.Inject
import kotlinx.coroutines.TimeoutCancellationException
Expand All @@ -38,7 +36,6 @@ import timber.log.Timber
class TermsOfServiceViewModel
@Inject
constructor(
private val navigator: Navigator,
private val termsOfServiceRepository: TermsOfServiceRepository,
private val popups: EphemeralPopups,
private val authManager: AuthenticationManager,
Expand Down Expand Up @@ -70,9 +67,4 @@ constructor(
popups.ErrorPopup().show(R.string.load_tos_failed)
authManager.signOut()
}

fun onButtonClicked() {
termsOfServiceRepository.isTermsOfServiceAccepted = true
navigator.navigate(SurveySelectorFragmentDirections.showSurveySelectorScreen(true))
}
}
1 change: 0 additions & 1 deletion ground/src/main/res/layout/fragment_terms_service.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
android:layout_height="wrap_content"
android:layout_marginBottom="32dp"
android:enabled="@{viewModel.agreeCheckboxChecked}"
android:onClick="@{() -> viewModel.onButtonClicked()}"
android:text="@string/agree_terms"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down

0 comments on commit ec3cd1c

Please sign in to comment.