Commit 600101eb authored by Maxim Myalkin's avatar Maxim Myalkin

Select discussion MR tab on routing from comment.

parent bcdfde79
......@@ -4,6 +4,7 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import ru.terrakok.cicerone.android.support.SupportAppScreen
import ru.terrakok.gitlabclient.entity.event.EventAction
import ru.terrakok.gitlabclient.entity.issue.IssueState
import ru.terrakok.gitlabclient.entity.mergerequest.MergeRequestState
import ru.terrakok.gitlabclient.ui.about.AboutFragment
......@@ -11,7 +12,6 @@ import ru.terrakok.gitlabclient.ui.auth.AuthFlowFragment
import ru.terrakok.gitlabclient.ui.auth.AuthFragment
import ru.terrakok.gitlabclient.ui.drawer.DrawerFlowFragment
import ru.terrakok.gitlabclient.ui.file.ProjectFileFragment
import ru.terrakok.gitlabclient.ui.global.StubFragment
import ru.terrakok.gitlabclient.ui.issue.IssueFlowFragment
import ru.terrakok.gitlabclient.ui.issue.IssueInfoFragment
import ru.terrakok.gitlabclient.ui.issue.IssueNotesFragment
......@@ -79,9 +79,10 @@ object Screens {
data class MergeRequestFlow(
val projectId: Long,
val mrId: Long
val mrId: Long,
val eventAction: EventAction?
) : SupportAppScreen() {
override fun getFragment() = MergeRequestFlowFragment.create(projectId, mrId)
override fun getFragment() = MergeRequestFlowFragment.create(projectId, mrId, eventAction)
}
//screens
......
package ru.terrakok.gitlabclient.entity.app.target
/**
* @author Maxim Myalkin (MaxMyalkin) on 19.05.2019.
*/
class TargetAdditionalInfo {
}
\ No newline at end of file
......@@ -33,6 +33,7 @@ import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.entity.app.target.AppTarget
import ru.terrakok.gitlabclient.entity.app.target.TargetHeader
import ru.terrakok.gitlabclient.entity.app.target.TargetHeaderTitle
import ru.terrakok.gitlabclient.model.system.flow.FlowRouter
import timber.log.Timber
......@@ -160,8 +161,15 @@ fun TargetHeader.Public.openInfo(router: FlowRouter) {
router.startFlow(Screens.UserFlow(targetId))
}
AppTarget.MERGE_REQUEST -> {
val eventAction = (title as? TargetHeaderTitle.Event)?.action
internal?.let { targetInternal ->
router.startFlow(Screens.MergeRequestFlow(targetInternal.projectId, targetInternal.targetIid))
router.startFlow(
Screens.MergeRequestFlow(
targetInternal.projectId,
targetInternal.targetIid,
eventAction
)
)
}
}
AppTarget.ISSUE -> {
......
......@@ -8,6 +8,7 @@ import ru.terrakok.gitlabclient.di.MergeRequestId
import ru.terrakok.gitlabclient.di.PrimitiveWrapper
import ru.terrakok.gitlabclient.di.ProjectId
import ru.terrakok.gitlabclient.entity.Project
import ru.terrakok.gitlabclient.entity.event.EventAction
import ru.terrakok.gitlabclient.entity.mergerequest.MergeRequest
import ru.terrakok.gitlabclient.model.interactor.mergerequest.MergeRequestInteractor
import ru.terrakok.gitlabclient.model.interactor.project.ProjectInteractor
......@@ -24,6 +25,7 @@ import javax.inject.Inject
class MergeRequestPresenter @Inject constructor(
@ProjectId projectIdWrapper: PrimitiveWrapper<Long>,
@MergeRequestId mrIdWrapper: PrimitiveWrapper<Long>,
private val eventAction: EventAction?,
private val mrInteractor: MergeRequestInteractor,
private val projectInteractor: ProjectInteractor,
private val resourceManager: ResourceManager,
......@@ -36,7 +38,11 @@ class MergeRequestPresenter @Inject constructor(
override fun onFirstViewAttach() {
super.onFirstViewAttach()
updateToolbarTitle()
selectActionTab()
}
private fun updateToolbarTitle() {
Single
.zip(
mrInteractor.getMergeRequest(projectId, mrId),
......@@ -56,5 +62,9 @@ class MergeRequestPresenter @Inject constructor(
.connect()
}
private fun selectActionTab() {
eventAction?.let(viewState::selectActionTab)
}
fun onBackPressed() = flowRouter.exit()
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import com.arellomobile.mvp.MvpView
import com.arellomobile.mvp.viewstate.strategy.AddToEndSingleStrategy
import com.arellomobile.mvp.viewstate.strategy.OneExecutionStateStrategy
import com.arellomobile.mvp.viewstate.strategy.StateStrategyType
import ru.terrakok.gitlabclient.entity.event.EventAction
/**
* Created by Eugene Shapovalov (@CraggyHaggy) on 27.10.18.
......@@ -15,4 +16,7 @@ interface MergeRequestView : MvpView {
@StateStrategyType(OneExecutionStateStrategy::class)
fun showMessage(message: String)
@StateStrategyType(OneExecutionStateStrategy::class)
fun selectActionTab(eventAction: EventAction)
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ import com.arellomobile.mvp.presenter.ProvidePresenter
import kotlinx.android.synthetic.main.fragment_main_mr.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.entity.event.EventAction
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.presentation.mergerequest.MergeRequestPresenter
import ru.terrakok.gitlabclient.presentation.mergerequest.MergeRequestView
......@@ -52,22 +53,36 @@ class MainMergeRequestFragment : BaseFragment(), MergeRequestView {
showSnackMessage(message)
}
override fun selectActionTab(eventAction: EventAction) {
when(eventAction) {
EventAction.COMMENTED_ON -> { viewPager.currentItem = TAB_NOTES }
else -> {}
}
}
private inner class MergeRequestPagesAdapter : FragmentPagerAdapter(childFragmentManager) {
override fun getItem(position: Int): BaseFragment = when (position) {
0 -> Screens.MergeRequestInfo.fragment
1 -> Screens.MergeRequestCommits.fragment
2 -> Screens.MergeRequestNotes.fragment
TAB_DETAILS -> Screens.MergeRequestInfo.fragment
TAB_COMMITS -> Screens.MergeRequestCommits.fragment
TAB_NOTES -> Screens.MergeRequestNotes.fragment
else -> Screens.MergeRequestChanges.fragment
}
override fun getCount() = 4
override fun getPageTitle(position: Int) = when (position) {
0 -> getString(R.string.merge_request_info_tab)
1 -> getString(R.string.merge_request_commits_tab)
2 -> getString(R.string.merge_request_discussion_tab)
3 -> getString(R.string.merge_request_changes_tab)
TAB_DETAILS -> getString(R.string.merge_request_info_tab)
TAB_COMMITS -> getString(R.string.merge_request_commits_tab)
TAB_NOTES -> getString(R.string.merge_request_discussion_tab)
TAB_CHANGES -> getString(R.string.merge_request_changes_tab)
else -> null
}
}
companion object {
private const val TAB_DETAILS = 0
private const val TAB_COMMITS = 1
private const val TAB_NOTES = 2
private const val TAB_CHANGES = 3
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.di.MergeRequestId
import ru.terrakok.gitlabclient.di.PrimitiveWrapper
import ru.terrakok.gitlabclient.di.ProjectId
import ru.terrakok.gitlabclient.entity.event.EventAction
import ru.terrakok.gitlabclient.extension.argument
import ru.terrakok.gitlabclient.ui.global.FlowFragment
import toothpick.Scope
......@@ -14,6 +15,7 @@ class MergeRequestFlowFragment : FlowFragment() {
private val mrId by argument(ARG_MR_ID, 0L)
private val projectId by argument(ARG_PROJECT_ID, 0L)
private val eventAction by argument<EventAction>(ARG_EVENT_ACTION)
override fun installModules(scope: Scope) {
super.installModules(scope)
......@@ -26,6 +28,7 @@ class MergeRequestFlowFragment : FlowFragment() {
bind(PrimitiveWrapper::class.java)
.withName(MergeRequestId::class.java)
.toInstance(PrimitiveWrapper(mrId))
bind(EventAction::class.java).toInstance(eventAction)
}
}
)
......@@ -36,11 +39,13 @@ class MergeRequestFlowFragment : FlowFragment() {
companion object {
private const val ARG_PROJECT_ID = "arg_project_id"
private const val ARG_MR_ID = "arg_mr_id"
fun create(projectId: Long, mrId: Long) =
private const val ARG_EVENT_ACTION = "arg_event_action"
fun create(projectId: Long, mrId: Long, eventAction: EventAction?) =
MergeRequestFlowFragment().apply {
arguments = Bundle().apply {
putLong(ARG_PROJECT_ID, projectId)
putLong(ARG_MR_ID, mrId)
putSerializable(ARG_EVENT_ACTION, eventAction)
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment