From e678e6d7f9b2e803fa97b51915fc595d070d1609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Borcz?= Date: Sat, 31 Jul 2021 20:19:05 +0200 Subject: [PATCH] Fix margin and attedance destination (#1414) --- .../ui/modules/dashboard/DashboardAdapter.kt | 12 ++++++++++++ .../ui/modules/dashboard/DashboardFragment.kt | 4 ++-- .../res/layout/item_dashboard_horizontal_group.xml | 9 +++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/dashboard/DashboardAdapter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/dashboard/DashboardAdapter.kt index e864eff7..9f3d546e 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/dashboard/DashboardAdapter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/dashboard/DashboardAdapter.kt @@ -9,6 +9,7 @@ import android.view.ViewGroup import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.view.isVisible import androidx.core.view.updateLayoutParams +import androidx.core.view.updateMarginsRelative import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.LinearLayoutManager 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.ItemDashboardLessonsBinding import io.github.wulkanowy.utils.createNameInitialsDrawable +import io.github.wulkanowy.utils.dpToPx import io.github.wulkanowy.utils.getThemeAttrColor import io.github.wulkanowy.utils.left import io.github.wulkanowy.utils.nickOrName @@ -187,6 +189,16 @@ class DashboardAdapter @Inject constructor() : with(dashboardHorizontalGroupItemLuckyContainer) { isVisible = error == null && !isLoading && luckyNumber != null setOnClickListener { onLuckyNumberTileClickListener() } + + updateLayoutParams { + updateMarginsRelative( + end = if (attendancePercentage == null && unreadMessagesCount == null && luckyNumber != null) { + 0 + } else { + context.dpToPx(8f).toInt() + } + ) + } } with(dashboardHorizontalGroupItemAttendanceContainer) { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/dashboard/DashboardFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/dashboard/DashboardFragment.kt index 54d3f40f..283f5745 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/dashboard/DashboardFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/dashboard/DashboardFragment.kt @@ -14,7 +14,7 @@ import io.github.wulkanowy.R import io.github.wulkanowy.databinding.FragmentDashboardBinding import io.github.wulkanowy.ui.base.BaseFragment 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.exam.ExamFragment import io.github.wulkanowy.ui.modules.grade.GradeFragment @@ -76,7 +76,7 @@ class DashboardFragment : BaseFragment(R.layout.fragme } onMessageTileClickListener = { mainActivity.pushView(MessageFragment.newInstance()) } onAttendanceTileClickListener = { - mainActivity.pushView(AttendanceFragment.newInstance()) + mainActivity.pushView(AttendanceSummaryFragment.newInstance()) } onLessonsTileClickListener = { mainActivity.pushView(TimetableFragment.newInstance()) } onGradeTileClickListener = { mainActivity.pushView(GradeFragment.newInstance()) } diff --git a/app/src/main/res/layout/item_dashboard_horizontal_group.xml b/app/src/main/res/layout/item_dashboard_horizontal_group.xml index aaf12834..a8532e6f 100644 --- a/app/src/main/res/layout/item_dashboard_horizontal_group.xml +++ b/app/src/main/res/layout/item_dashboard_horizontal_group.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginHorizontal="8dp" + android:layout_marginHorizontal="12dp" android:layout_marginVertical="2dp"> + app:layout_goneMarginEnd="0dp">