1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-09-19 22:49:08 -05:00

Add arrows to student family list items (#1338)

This commit is contained in:
Dominik Korsa 2021-05-17 15:35:36 +02:00 committed by GitHub
parent 983dcd8656
commit 05aa38b591
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 68 additions and 25 deletions

View File

@ -159,7 +159,7 @@ ext {
} }
dependencies { dependencies {
implementation "io.github.wulkanowy:sdk:07a21c1" implementation "io.github.wulkanowy:sdk:bb08354"
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'

View File

@ -1,6 +1,8 @@
package io.github.wulkanowy.ui.modules.studentinfo package io.github.wulkanowy.ui.modules.studentinfo
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View.GONE
import android.view.View.VISIBLE
import android.view.ViewGroup import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import io.github.wulkanowy.databinding.ItemStudentInfoBinding import io.github.wulkanowy.databinding.ItemStudentInfoBinding
@ -9,7 +11,7 @@ import javax.inject.Inject
class StudentInfoAdapter @Inject constructor() : class StudentInfoAdapter @Inject constructor() :
RecyclerView.Adapter<StudentInfoAdapter.ViewHolder>() { RecyclerView.Adapter<StudentInfoAdapter.ViewHolder>() {
var items = listOf<Pair<String, String>>() var items = listOf<StudentInfoItem>()
var onItemClickListener: (position: Int) -> Unit = {} var onItemClickListener: (position: Int) -> Unit = {}
@ -25,8 +27,9 @@ class StudentInfoAdapter @Inject constructor() :
val item = items[position] val item = items[position]
with(holder.binding) { with(holder.binding) {
studentInfoItemTitle.text = item.first studentInfoItemTitle.text = item.title
studentInfoItemSubtitle.text = item.second studentInfoItemSubtitle.text = item.subtitle
studentInfoItemArrow.visibility = if (item.showArrow) VISIBLE else GONE
with(root) { with(root) {
setOnClickListener { onItemClickListener(position) } setOnClickListener { onItemClickListener(position) }

View File

@ -107,7 +107,7 @@ class StudentInfoFragment :
} }
} }
override fun updateData(data: List<Pair<String, String>>) { override fun updateData(data: List<StudentInfoItem>) {
with(studentInfoAdapter) { with(studentInfoAdapter) {
items = data items = data
notifyDataSetChanged() notifyDataSetChanged()
@ -129,7 +129,11 @@ class StudentInfoFragment :
getString(R.string.student_info_family_name) to studentInfo.familyName, getString(R.string.student_info_family_name) to studentInfo.familyName,
getString(R.string.student_info_parents_name) to studentInfo.parentsNames getString(R.string.student_info_parents_name) to studentInfo.parentsNames
).map { ).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_cellphone) to studentInfo.cellPhoneNumber,
getString(R.string.student_info_email) to studentInfo.email getString(R.string.student_info_email) to studentInfo.email
).map { ).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.firstGuardian?.let { it.kinship.capitalise() to it.fullName },
studentInfo.secondGuardian?.let { it.kinship.capitalise() to it.fullName }, studentInfo.secondGuardian?.let { it.kinship.capitalise() to it.fullName },
).map { (title, value) -> ).map { (title, value) ->
val updatedValue = value.ifBlank { getString(R.string.all_no_data) } StudentInfoItem(
val updatedTitle = title.ifBlank { getString(R.string.all_no_data) } title.ifBlank { getString(R.string.all_no_data) },
value.ifBlank { getString(R.string.all_no_data) },
updatedTitle to updatedValue true,
)
} }
) )
} }
@ -168,7 +177,11 @@ class StudentInfoFragment :
getString(R.string.student_info_registered_address) to studentInfo.registeredAddress, getString(R.string.student_info_registered_address) to studentInfo.registeredAddress,
getString(R.string.student_info_correspondence_address) to studentInfo.correspondenceAddress getString(R.string.student_info_correspondence_address) to studentInfo.correspondenceAddress
).map { ).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_phones) to studentGuardian.phones,
getString(R.string.student_info_email) to studentGuardian.email getString(R.string.student_info_email) to studentGuardian.email
).map { ).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_phones) to studentGuardian.phones,
getString(R.string.student_info_email) to studentGuardian.email getString(R.string.student_info_email) to studentGuardian.email
).map { ).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,
)
} }
) )
} }

View File

@ -0,0 +1,7 @@
package io.github.wulkanowy.ui.modules.studentinfo
data class StudentInfoItem(
val title: String,
val subtitle: String,
val showArrow: Boolean
)

View File

@ -61,11 +61,11 @@ class StudentInfoPresenter @Inject constructor(
fun onItemSelected(position: Int) { fun onItemSelected(position: Int) {
if (infoType != StudentInfoView.Type.FAMILY) return if (infoType != StudentInfoView.Type.FAMILY) return
if (position == 0) { view?.openStudentInfoView(
view?.openStudentInfoView(StudentInfoView.Type.FIRST_GUARDIAN, studentWithSemesters) if (position == 0) StudentInfoView.Type.FIRST_GUARDIAN
} else { else StudentInfoView.Type.SECOND_GUARDIAN,
view?.openStudentInfoView(StudentInfoView.Type.SECOND_GUARDIAN, studentWithSemesters) studentWithSemesters
} )
} }
fun onItemLongClick(text: String) { fun onItemLongClick(text: String) {

View File

@ -15,7 +15,7 @@ interface StudentInfoView : BaseView {
fun initView() fun initView()
fun updateData(data: List<Pair<String, String>>) fun updateData(data: List<StudentInfoItem>)
fun showPersonalTypeData(studentInfo: StudentInfo) fun showPersonalTypeData(studentInfo: StudentInfo)

View File

@ -24,7 +24,8 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/student_info_recycler" android:id="@+id/student_info_recycler"
android:layout_width="match_parent" 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> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<LinearLayout <LinearLayout

View File

@ -10,7 +10,7 @@
<TextView <TextView
android:id="@+id/student_info_item_title" android:id="@+id/student_info_item_title"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginTop="13dp" android:layout_marginTop="13dp"
@ -19,14 +19,14 @@
android:maxLines="1" android:maxLines="1"
android:textColor="?android:textColorSecondary" android:textColor="?android:textColorSecondary"
android:textSize="12sp" android:textSize="12sp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toStartOf="@id/student_info_item_arrow"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:text="@tools:sample/lorem/random" /> tools:text="@tools:sample/lorem/random" />
<TextView <TextView
android:id="@+id/student_info_item_subtitle" android:id="@+id/student_info_item_subtitle"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
@ -34,9 +34,20 @@
android:maxLines="1" android:maxLines="1"
android:textColor="?android:textColorPrimary" android:textColor="?android:textColorPrimary"
android:textSize="16sp" android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toStartOf="@id/student_info_item_arrow"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/student_info_item_title" app:layout_constraintTop_toBottomOf="@id/student_info_item_title"
tools:text="@tools:sample/lorem/random" /> 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> </androidx.constraintlayout.widget.ConstraintLayout>