Added A scroll down button + new icon + new styles for that button

Signed-off-by: Julius Linus <juliuslinus1@gmail.com>
This commit is contained in:
rapterjet2004 2023-01-29 12:52:34 -06:00 committed by Andy Scherzinger
parent 47ec695c29
commit 7da9c475e3
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
5 changed files with 49 additions and 0 deletions

View File

@ -673,6 +673,8 @@ class ChatController(args: Bundle) :
} }
} }
binding?.scrollDownButton?.setOnClickListener { binding?.messagesListView?.smoothScrollToPosition(0) }
binding?.let { viewThemeUtils.material.colorMaterialButtonPrimaryFilled(it.popupBubbleView) } binding?.let { viewThemeUtils.material.colorMaterialButtonPrimaryFilled(it.popupBubbleView) }
binding?.messageInputView?.setPadding(0, 0, 0, 0) binding?.messageInputView?.setPadding(0, 0, 0, 0)
@ -682,6 +684,21 @@ class ChatController(args: Bundle) :
super.onScrollStateChanged(recyclerView, newState) super.onScrollStateChanged(recyclerView, newState)
if (newState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) { if (newState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
val offset = recyclerView.computeVerticalScrollOffset()
val extent = recyclerView.computeVerticalScrollExtent()
val range = recyclerView.computeVerticalScrollRange()
// 0.0 is the top of the chat, 100.0 is the bottom of the chat
val scrollPercentage = 100.0f * offset / (range - extent).toFloat()
if (scrollPercentage <= 90) {
binding?.scrollDownButton?.visibility = View.VISIBLE
} else {
binding?.scrollDownButton?.visibility = View.INVISIBLE
}
if (newMessagesCount != 0 && layoutManager != null) { if (newMessagesCount != 0 && layoutManager != null) {
if (layoutManager!!.findFirstCompletelyVisibleItemPosition() < newMessagesCount) { if (layoutManager!!.findFirstCompletelyVisibleItemPosition() < newMessagesCount) {
newMessagesCount = 0 newMessagesCount = 0

View File

@ -0,0 +1,8 @@
<vector android:height="24dp" android:tint="#000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/black"
android:pathData="M18,6.41l-1.41,-1.41l-4.59,4.58l-4.59,-4.58l-1.41,1.41l6,6z"/>
<path android:fillColor="@android:color/black"
android:pathData="M18,13l-1.41,-1.41l-4.59,4.58l-4.59,-4.58l-1.41,1.41l6,6z"/>
</vector>

View File

@ -3,6 +3,8 @@
~ ~
~ @author Mario Danic ~ @author Mario Danic
~ @author Andy Scherzinger ~ @author Andy Scherzinger
~ @author Julius Linus
~ Copyright (C) 2023 Julius Linus <juliuslinus1@gmail.com>
~ Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de> ~ Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com> ~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
~ ~
@ -108,6 +110,20 @@
app:cornerRadius="@dimen/button_corner_radius" app:cornerRadius="@dimen/button_corner_radius"
app:icon="@drawable/ic_baseline_arrow_downward_24px" /> app:icon="@drawable/ic_baseline_arrow_downward_24px" />
<ImageButton
android:id="@+id/scrollDownButton"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="6dp"
android:layout_marginBottom="16dp"
android:background="@drawable/shape_oval"
android:backgroundTint="@color/scroll_down_chat_button"
android:src="@drawable/ic_baseline_keyboard_double_arrow_down_24"
app:tint="@color/scroll_down_chat_button_icon"
android:visibility="invisible" />
</RelativeLayout> </RelativeLayout>
<LinearLayout <LinearLayout

View File

@ -76,4 +76,8 @@
<color name="dialog_background">#353535</color> <color name="dialog_background">#353535</color>
<!-- scroll down chat button -->
<color name="scroll_down_chat_button">#141F25</color>
<color name="scroll_down_chat_button_icon">#99C3DA</color>
</resources> </resources>

View File

@ -102,6 +102,10 @@
<color name="list_divider_background">#1F121212</color> <color name="list_divider_background">#1F121212</color>
<color name="grey_200">#EEEEEE</color> <color name="grey_200">#EEEEEE</color>
<!-- scroll down chat button -->
<color name="scroll_down_chat_button">#E5F0F5</color>
<color name="scroll_down_chat_button_icon">#002A41</color>
<!-- this is just a helper for status icon background because getting the background color of a dialog is not <!-- this is just a helper for status icon background because getting the background color of a dialog is not
possible?! don't use this to set the background of dialogs --> possible?! don't use this to set the background of dialogs -->
<color name="dialog_background">#FFFFFF</color> <color name="dialog_background">#FFFFFF</color>