Fix margin and attedance destination (#1414)

This commit is contained in:
Rafał Borcz 2021-07-31 20:19:05 +02:00 committed by GitHub
parent f6f3447f1d
commit e678e6d7f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 8 deletions

View File

@ -9,6 +9,7 @@ import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams import androidx.core.view.updateLayoutParams
import androidx.core.view.updateMarginsRelative
import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.ListAdapter
@ -25,6 +26,7 @@ import io.github.wulkanowy.databinding.ItemDashboardHomeworkBinding
import io.github.wulkanowy.databinding.ItemDashboardHorizontalGroupBinding import io.github.wulkanowy.databinding.ItemDashboardHorizontalGroupBinding
import io.github.wulkanowy.databinding.ItemDashboardLessonsBinding import io.github.wulkanowy.databinding.ItemDashboardLessonsBinding
import io.github.wulkanowy.utils.createNameInitialsDrawable import io.github.wulkanowy.utils.createNameInitialsDrawable
import io.github.wulkanowy.utils.dpToPx
import io.github.wulkanowy.utils.getThemeAttrColor import io.github.wulkanowy.utils.getThemeAttrColor
import io.github.wulkanowy.utils.left import io.github.wulkanowy.utils.left
import io.github.wulkanowy.utils.nickOrName import io.github.wulkanowy.utils.nickOrName
@ -187,6 +189,16 @@ class DashboardAdapter @Inject constructor() :
with(dashboardHorizontalGroupItemLuckyContainer) { with(dashboardHorizontalGroupItemLuckyContainer) {
isVisible = error == null && !isLoading && luckyNumber != null isVisible = error == null && !isLoading && luckyNumber != null
setOnClickListener { onLuckyNumberTileClickListener() } setOnClickListener { onLuckyNumberTileClickListener() }
updateLayoutParams<ViewGroup.MarginLayoutParams> {
updateMarginsRelative(
end = if (attendancePercentage == null && unreadMessagesCount == null && luckyNumber != null) {
0
} else {
context.dpToPx(8f).toInt()
}
)
}
} }
with(dashboardHorizontalGroupItemAttendanceContainer) { with(dashboardHorizontalGroupItemAttendanceContainer) {

View File

@ -14,7 +14,7 @@ import io.github.wulkanowy.R
import io.github.wulkanowy.databinding.FragmentDashboardBinding import io.github.wulkanowy.databinding.FragmentDashboardBinding
import io.github.wulkanowy.ui.base.BaseFragment import io.github.wulkanowy.ui.base.BaseFragment
import io.github.wulkanowy.ui.modules.account.AccountFragment import io.github.wulkanowy.ui.modules.account.AccountFragment
import io.github.wulkanowy.ui.modules.attendance.AttendanceFragment import io.github.wulkanowy.ui.modules.attendance.summary.AttendanceSummaryFragment
import io.github.wulkanowy.ui.modules.conference.ConferenceFragment import io.github.wulkanowy.ui.modules.conference.ConferenceFragment
import io.github.wulkanowy.ui.modules.exam.ExamFragment import io.github.wulkanowy.ui.modules.exam.ExamFragment
import io.github.wulkanowy.ui.modules.grade.GradeFragment import io.github.wulkanowy.ui.modules.grade.GradeFragment
@ -76,7 +76,7 @@ class DashboardFragment : BaseFragment<FragmentDashboardBinding>(R.layout.fragme
} }
onMessageTileClickListener = { mainActivity.pushView(MessageFragment.newInstance()) } onMessageTileClickListener = { mainActivity.pushView(MessageFragment.newInstance()) }
onAttendanceTileClickListener = { onAttendanceTileClickListener = {
mainActivity.pushView(AttendanceFragment.newInstance()) mainActivity.pushView(AttendanceSummaryFragment.newInstance())
} }
onLessonsTileClickListener = { mainActivity.pushView(TimetableFragment.newInstance()) } onLessonsTileClickListener = { mainActivity.pushView(TimetableFragment.newInstance()) }
onGradeTileClickListener = { mainActivity.pushView(GradeFragment.newInstance()) } onGradeTileClickListener = { mainActivity.pushView(GradeFragment.newInstance()) }

View File

@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginHorizontal="8dp" android:layout_marginHorizontal="12dp"
android:layout_marginVertical="2dp"> android:layout_marginVertical="2dp">
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
@ -12,7 +12,6 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginVertical="4dp" android:layout_marginVertical="4dp"
android:layout_marginStart="4dp"
app:cardElevation="4dp" app:cardElevation="4dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/dashboard_horizontal_group_item_message_container" app:layout_constraintEnd_toStartOf="@id/dashboard_horizontal_group_item_message_container"
@ -64,13 +63,13 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginVertical="4dp" android:layout_marginVertical="4dp"
android:layout_marginStart="8dp" android:layout_marginEnd="8dp"
app:cardElevation="4dp" app:cardElevation="4dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/dashboard_horizontal_group_item_attendance_container" app:layout_constraintEnd_toStartOf="@id/dashboard_horizontal_group_item_attendance_container"
app:layout_constraintStart_toEndOf="@id/dashboard_horizontal_group_item_lucky_container" app:layout_constraintStart_toEndOf="@id/dashboard_horizontal_group_item_lucky_container"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_goneMarginStart="4dp"> app:layout_goneMarginEnd="0dp">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -121,8 +120,6 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginVertical="4dp" android:layout_marginVertical="4dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="4dp"
app:cardElevation="4dp" app:cardElevation="4dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"