mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
@@ -20,11 +20,14 @@
|
||||
package org.isoron.uhabits.activities.habits.list.views
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Rect
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import android.view.GestureDetector
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.ItemTouchHelper.DOWN
|
||||
import androidx.recyclerview.widget.ItemTouchHelper.END
|
||||
@@ -75,9 +78,30 @@ class HabitCardListView(
|
||||
setHasFixedSize(true)
|
||||
isLongClickable = true
|
||||
layoutManager = LinearLayoutManager(context)
|
||||
applyBottomInset()
|
||||
super.setAdapter(adapter)
|
||||
}
|
||||
|
||||
private fun applyBottomInset() {
|
||||
ViewCompat.setOnApplyWindowInsetsListener(this) { _, insets ->
|
||||
val systemBarsInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
addItemDecoration(object : ItemDecoration() {
|
||||
override fun getItemOffsets(
|
||||
outRect: Rect,
|
||||
view: View,
|
||||
parent: RecyclerView,
|
||||
state: State
|
||||
) {
|
||||
val itemCount = parent.adapter?.itemCount
|
||||
if (parent.getChildAdapterPosition(view) == itemCount?.minus(1)) {
|
||||
outRect.bottom = systemBarsInsets.bottom
|
||||
}
|
||||
}
|
||||
})
|
||||
insets
|
||||
}
|
||||
}
|
||||
|
||||
fun createHabitCardView(): HabitCardView {
|
||||
return cardViewFactory.create()
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.widget.FrameLayout
|
||||
import org.isoron.uhabits.core.ui.screens.habits.show.ShowHabitPresenter
|
||||
import org.isoron.uhabits.core.ui.screens.habits.show.ShowHabitState
|
||||
import org.isoron.uhabits.databinding.ShowHabitBinding
|
||||
import org.isoron.uhabits.utils.applyBottomInset
|
||||
import org.isoron.uhabits.utils.applyToolbarInsets
|
||||
import org.isoron.uhabits.utils.setupToolbar
|
||||
|
||||
@@ -57,6 +58,7 @@ class ShowHabitView(context: Context) : FrameLayout(context) {
|
||||
} else {
|
||||
binding.targetCard.visibility = GONE
|
||||
}
|
||||
binding.linearLayout.applyBottomInset()
|
||||
}
|
||||
|
||||
fun setListener(presenter: ShowHabitPresenter) {
|
||||
|
||||
@@ -260,6 +260,14 @@ fun View.applyRootViewInsets() {
|
||||
}
|
||||
}
|
||||
|
||||
fun View.applyBottomInset() {
|
||||
ViewCompat.setOnApplyWindowInsetsListener(this) { view, insets ->
|
||||
val systemBarsInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
view.setPadding(0, 0, 0, systemBarsInsets.bottom)
|
||||
insets
|
||||
}
|
||||
}
|
||||
|
||||
fun View.applyToolbarInsets() {
|
||||
ViewCompat.setOnApplyWindowInsetsListener(this) { view, insets ->
|
||||
val systemBarsInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
~ with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/container"
|
||||
<RelativeLayout android:id="@+id/container"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
@@ -41,6 +40,7 @@
|
||||
|
||||
<LinearLayout
|
||||
style="@style/CardList"
|
||||
android:id="@+id/linearLayout"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<org.isoron.uhabits.activities.habits.show.views.SubtitleCardView
|
||||
|
||||
Reference in New Issue
Block a user