forked from github/wulkanowy-mirror
Add arrows to student family list items (#1338)
This commit is contained in:
parent
983dcd8656
commit
05aa38b591
@ -159,7 +159,7 @@ ext {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "io.github.wulkanowy:sdk:07a21c1"
|
||||
implementation "io.github.wulkanowy:sdk:bb08354"
|
||||
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package io.github.wulkanowy.ui.modules.studentinfo
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View.GONE
|
||||
import android.view.View.VISIBLE
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import io.github.wulkanowy.databinding.ItemStudentInfoBinding
|
||||
@ -9,7 +11,7 @@ import javax.inject.Inject
|
||||
class StudentInfoAdapter @Inject constructor() :
|
||||
RecyclerView.Adapter<StudentInfoAdapter.ViewHolder>() {
|
||||
|
||||
var items = listOf<Pair<String, String>>()
|
||||
var items = listOf<StudentInfoItem>()
|
||||
|
||||
var onItemClickListener: (position: Int) -> Unit = {}
|
||||
|
||||
@ -25,8 +27,9 @@ class StudentInfoAdapter @Inject constructor() :
|
||||
val item = items[position]
|
||||
|
||||
with(holder.binding) {
|
||||
studentInfoItemTitle.text = item.first
|
||||
studentInfoItemSubtitle.text = item.second
|
||||
studentInfoItemTitle.text = item.title
|
||||
studentInfoItemSubtitle.text = item.subtitle
|
||||
studentInfoItemArrow.visibility = if (item.showArrow) VISIBLE else GONE
|
||||
|
||||
with(root) {
|
||||
setOnClickListener { onItemClickListener(position) }
|
||||
|
@ -107,7 +107,7 @@ class StudentInfoFragment :
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateData(data: List<Pair<String, String>>) {
|
||||
override fun updateData(data: List<StudentInfoItem>) {
|
||||
with(studentInfoAdapter) {
|
||||
items = data
|
||||
notifyDataSetChanged()
|
||||
@ -129,7 +129,11 @@ class StudentInfoFragment :
|
||||
getString(R.string.student_info_family_name) to studentInfo.familyName,
|
||||
getString(R.string.student_info_parents_name) to studentInfo.parentsNames
|
||||
).map {
|
||||
if (it.second.isBlank()) it.copy(second = getString(R.string.all_no_data)) else it
|
||||
StudentInfoItem(
|
||||
it.first,
|
||||
it.second.ifBlank { getString(R.string.all_no_data) },
|
||||
false,
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -141,7 +145,11 @@ class StudentInfoFragment :
|
||||
getString(R.string.student_info_cellphone) to studentInfo.cellPhoneNumber,
|
||||
getString(R.string.student_info_email) to studentInfo.email
|
||||
).map {
|
||||
if (it.second.isBlank()) it.copy(second = getString(R.string.all_no_data)) else it
|
||||
StudentInfoItem(
|
||||
it.first,
|
||||
it.second.ifBlank { getString(R.string.all_no_data) },
|
||||
false,
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -153,10 +161,11 @@ class StudentInfoFragment :
|
||||
studentInfo.firstGuardian?.let { it.kinship.capitalise() to it.fullName },
|
||||
studentInfo.secondGuardian?.let { it.kinship.capitalise() to it.fullName },
|
||||
).map { (title, value) ->
|
||||
val updatedValue = value.ifBlank { getString(R.string.all_no_data) }
|
||||
val updatedTitle = title.ifBlank { getString(R.string.all_no_data) }
|
||||
|
||||
updatedTitle to updatedValue
|
||||
StudentInfoItem(
|
||||
title.ifBlank { getString(R.string.all_no_data) },
|
||||
value.ifBlank { getString(R.string.all_no_data) },
|
||||
true,
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -168,7 +177,11 @@ class StudentInfoFragment :
|
||||
getString(R.string.student_info_registered_address) to studentInfo.registeredAddress,
|
||||
getString(R.string.student_info_correspondence_address) to studentInfo.correspondenceAddress
|
||||
).map {
|
||||
if (it.second.isBlank()) it.copy(second = getString(R.string.all_no_data)) else it
|
||||
StudentInfoItem(
|
||||
it.first,
|
||||
it.second.ifBlank { getString(R.string.all_no_data) },
|
||||
false,
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -182,7 +195,11 @@ class StudentInfoFragment :
|
||||
getString(R.string.student_info_phones) to studentGuardian.phones,
|
||||
getString(R.string.student_info_email) to studentGuardian.email
|
||||
).map {
|
||||
if (it.second.isBlank()) it.copy(second = getString(R.string.all_no_data)) else it
|
||||
StudentInfoItem(
|
||||
it.first,
|
||||
it.second.ifBlank { getString(R.string.all_no_data) },
|
||||
false,
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -196,7 +213,11 @@ class StudentInfoFragment :
|
||||
getString(R.string.student_info_phones) to studentGuardian.phones,
|
||||
getString(R.string.student_info_email) to studentGuardian.email
|
||||
).map {
|
||||
if (it.second.isBlank()) it.copy(second = getString(R.string.all_no_data)) else it
|
||||
StudentInfoItem(
|
||||
it.first,
|
||||
it.second.ifBlank { getString(R.string.all_no_data) },
|
||||
false,
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
package io.github.wulkanowy.ui.modules.studentinfo
|
||||
|
||||
data class StudentInfoItem(
|
||||
val title: String,
|
||||
val subtitle: String,
|
||||
val showArrow: Boolean
|
||||
)
|
@ -61,11 +61,11 @@ class StudentInfoPresenter @Inject constructor(
|
||||
fun onItemSelected(position: Int) {
|
||||
if (infoType != StudentInfoView.Type.FAMILY) return
|
||||
|
||||
if (position == 0) {
|
||||
view?.openStudentInfoView(StudentInfoView.Type.FIRST_GUARDIAN, studentWithSemesters)
|
||||
} else {
|
||||
view?.openStudentInfoView(StudentInfoView.Type.SECOND_GUARDIAN, studentWithSemesters)
|
||||
}
|
||||
view?.openStudentInfoView(
|
||||
if (position == 0) StudentInfoView.Type.FIRST_GUARDIAN
|
||||
else StudentInfoView.Type.SECOND_GUARDIAN,
|
||||
studentWithSemesters
|
||||
)
|
||||
}
|
||||
|
||||
fun onItemLongClick(text: String) {
|
||||
|
@ -15,7 +15,7 @@ interface StudentInfoView : BaseView {
|
||||
|
||||
fun initView()
|
||||
|
||||
fun updateData(data: List<Pair<String, String>>)
|
||||
fun updateData(data: List<StudentInfoItem>)
|
||||
|
||||
fun showPersonalTypeData(studentInfo: StudentInfo)
|
||||
|
||||
|
@ -24,7 +24,8 @@
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/student_info_recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="match_parent"
|
||||
tools:listitem="@layout/item_student_info" />
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/student_info_item_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="13dp"
|
||||
@ -19,14 +19,14 @@
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/student_info_item_arrow"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/student_info_item_subtitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
@ -34,9 +34,20 @@
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/student_info_item_arrow"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/student_info_item_title"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/student_info_item_arrow"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_chevron_right"
|
||||
app:tint="?colorOnBackground" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user