Commit 550991cc authored by Konstantin Tskhovrebov's avatar Konstantin Tskhovrebov 🤖

Add NewNoteView.

parent bc63f32d
package ru.terrakok.gitlabclient.ui.global
package ru.terrakok.gitlabclient.ui.global.view.custom
import android.content.Context
import android.support.constraint.ConstraintLayout
import android.text.Editable
import android.text.TextWatcher
import android.view.ViewGroup
import android.widget.EditText
import android.widget.ImageView
import android.util.AttributeSet
import kotlinx.android.synthetic.main.view_new_note.view.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.extension.getTintDrawable
class NewNoteViewController(
root: ViewGroup,
onSendClickListener: (String) -> Unit
) {
private val newNoteEditText = root.findViewById<EditText>(R.id.newNoteEditText)
private val newNoteSend = root.findViewById<ImageView>(R.id.newNoteSend)
class NewNoteView(context: Context, attrs: AttributeSet) : ConstraintLayout(context, attrs) {
init {
inflate(context, R.layout.view_new_note, this)
}
fun init(onSendClickListener: (String) -> Unit) {
newNoteEditText.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable) {
......@@ -30,7 +29,7 @@ class NewNoteViewController(
}
})
newNoteSend.setImageDrawable(
root.context.getTintDrawable(
context.getTintDrawable(
R.drawable.ic_send_24dp,
intArrayOf(R.color.grey_30, R.color.grey),
arrayOf(intArrayOf(-android.R.attr.state_enabled), intArrayOf(android.R.attr.state_enabled))
......
......@@ -5,7 +5,6 @@ import android.support.transition.Fade
import android.support.transition.TransitionManager
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.ViewGroup
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import kotlinx.android.synthetic.main.fragment_issue_notes.*
......@@ -16,7 +15,6 @@ import ru.terrakok.gitlabclient.presentation.global.NoteWithFormattedBody
import ru.terrakok.gitlabclient.presentation.issue.notes.IssueNotesPresenter
import ru.terrakok.gitlabclient.presentation.issue.notes.IssueNotesView
import ru.terrakok.gitlabclient.ui.global.BaseFragment
import ru.terrakok.gitlabclient.ui.global.NewNoteViewController
import ru.terrakok.gitlabclient.ui.global.list.SimpleDividerDecorator
import ru.terrakok.gitlabclient.ui.global.list.TargetNotesAdapter
......@@ -33,7 +31,6 @@ class IssueNotesFragment : BaseFragment(), IssueNotesView {
addTarget(fabScrollToBottom)
}
}
private lateinit var newNoteViewController: NewNoteViewController
@InjectPresenter
lateinit var presenter: IssueNotesPresenter
......@@ -63,7 +60,7 @@ class IssueNotesFragment : BaseFragment(), IssueNotesView {
recyclerView.scrollToPosition(adapter.itemCount - 1)
setFabScrollVisible(false)
}
newNoteViewController = NewNoteViewController(noteInputLayout as ViewGroup, { presenter.onSendClicked(it) })
newNoteView.init { presenter.onSendClicked(it) }
}
private fun setFabScrollVisible(visible: Boolean) {
......@@ -73,7 +70,7 @@ class IssueNotesFragment : BaseFragment(), IssueNotesView {
override fun showEmptyProgress(show: Boolean) {
fullscreenProgressView.visible(show)
noteInputLayout.visible(!show)
newNoteView.visible(!show)
}
override fun showBlockingProgress(show: Boolean) {
......@@ -84,7 +81,7 @@ class IssueNotesFragment : BaseFragment(), IssueNotesView {
adapter.setData(notes)
if (scrollToEnd) {
recyclerView.scrollToPosition(adapter.itemCount - 1)
newNoteViewController.clearInput()
newNoteView.clearInput()
}
}
......
......@@ -5,10 +5,9 @@ import android.support.transition.Fade
import android.support.transition.TransitionManager
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.ViewGroup
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import kotlinx.android.synthetic.main.fragment_issue_notes.*
import kotlinx.android.synthetic.main.fragment_mr_notes.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.extension.visible
......@@ -16,7 +15,6 @@ import ru.terrakok.gitlabclient.presentation.global.NoteWithFormattedBody
import ru.terrakok.gitlabclient.presentation.mergerequest.notes.MergeRequestNotesPresenter
import ru.terrakok.gitlabclient.presentation.mergerequest.notes.MergeRequestNotesView
import ru.terrakok.gitlabclient.ui.global.BaseFragment
import ru.terrakok.gitlabclient.ui.global.NewNoteViewController
import ru.terrakok.gitlabclient.ui.global.list.SimpleDividerDecorator
import ru.terrakok.gitlabclient.ui.global.list.TargetNotesAdapter
......@@ -33,7 +31,6 @@ class MergeRequestNotesFragment : BaseFragment(), MergeRequestNotesView {
addTarget(fabScrollToBottom)
}
}
private lateinit var newNoteViewController: NewNoteViewController
@InjectPresenter
lateinit var presenter: MergeRequestNotesPresenter
......@@ -63,7 +60,7 @@ class MergeRequestNotesFragment : BaseFragment(), MergeRequestNotesView {
recyclerView.scrollToPosition(adapter.itemCount - 1)
setFabScrollVisible(false)
}
newNoteViewController = NewNoteViewController(noteInputLayout as ViewGroup, { presenter.onSendClicked(it) })
newNoteView.init { presenter.onSendClicked(it) }
}
private fun setFabScrollVisible(visible: Boolean) {
......@@ -73,7 +70,7 @@ class MergeRequestNotesFragment : BaseFragment(), MergeRequestNotesView {
override fun showEmptyProgress(show: Boolean) {
fullscreenProgressView.visible(show)
noteInputLayout.visible(!show)
newNoteView.visible(!show)
}
override fun showBlockingProgress(show: Boolean) {
......@@ -84,7 +81,7 @@ class MergeRequestNotesFragment : BaseFragment(), MergeRequestNotesView {
adapter.setData(notes)
if (scrollToEnd) {
recyclerView.scrollToPosition(adapter.itemCount - 1)
newNoteViewController.clearInput()
newNoteView.clearInput()
}
}
......
......@@ -10,7 +10,7 @@
android:id="@+id/recyclerView"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/noteInputLayout"
app:layout_constraintBottom_toTopOf="@id/newNoteView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
......@@ -30,9 +30,8 @@
app:layout_constraintEnd_toEndOf="@id/recyclerView"
tools:visibility="visible" />
<include
android:id="@+id/noteInputLayout"
layout="@layout/layout_new_note"
<ru.terrakok.gitlabclient.ui.global.view.custom.NewNoteView
android:id="@+id/newNoteView"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
......
......@@ -10,7 +10,7 @@
android:id="@+id/recyclerView"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/noteInputLayout"
app:layout_constraintBottom_toTopOf="@id/newNoteView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
......@@ -30,9 +30,8 @@
app:layout_constraintEnd_toEndOf="@id/recyclerView"
tools:visibility="visible" />
<include
android:id="@+id/noteInputLayout"
layout="@layout/layout_new_note"
<ru.terrakok.gitlabclient.ui.global.view.custom.NewNoteView
android:id="@+id/newNoteView"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
......
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:parentTag="android.support.constraint.ConstraintLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
......@@ -49,4 +50,4 @@
app:layout_constraintStart_toEndOf="@id/newNoteEditText"
tools:src="@drawable/ic_send_24dp" />
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
</merge>
\ No newline at end of file
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