Merge pull request #5666 from vector-im/feature/aris/threads_thread_list_loader

Add loader to thread list
This commit is contained in:
Aris Kotsomitopoulos 2022-03-31 16:24:12 +03:00 committed by GitHub
commit b9934d7239
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 6 deletions

1
changelog.d/5562.bugfix Normal file
View file

@ -0,0 +1 @@
Add loader in thread list

View file

@ -113,7 +113,15 @@ class ThreadListViewModel @AssistedInject constructor(@Assisted val initialState
private fun fetchThreadList() {
viewModelScope.launch {
setLoading(true)
room?.fetchThreadSummaries()
setLoading(false)
}
}
private fun setLoading(isLoading: Boolean) {
setState {
copy(isLoading = isLoading)
}
}

View file

@ -27,6 +27,7 @@ data class ThreadListViewState(
val threadSummaryList: Async<List<ThreadSummary>> = Uninitialized,
val rootThreadEventList: Async<List<ThreadTimelineEvent>> = Uninitialized,
val shouldFilterThreads: Boolean = false,
val isLoading: Boolean = false,
val roomId: String
) : MavericksState {
constructor(args: ThreadListArgs) : this(roomId = args.roomId)

View file

@ -104,6 +104,11 @@ class ThreadListFragment @Inject constructor(
override fun invalidate() = withState(threadListViewModel) { state ->
renderEmptyStateIfNeeded(state)
threadListController.update(state)
renderLoaderIfNeeded(state)
}
private fun renderLoaderIfNeeded(state: ThreadListViewState) {
views.threadListProgressBar.isVisible = state.isLoading
}
private fun renderToolbar() {

View file

@ -37,6 +37,22 @@
tools:listitem="@layout/item_thread"
tools:visibility="gone" />
<ProgressBar
android:id="@+id/threadListProgressBar"
style="@style/Widget.Vector.ProgressBar.Horizontal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:indeterminate="true"
android:visibility="gone"
tools:ignore="NegativeMargin"
android:layout_marginTop="-6dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/threadListAppBarLayout"
tools:visibility="visible" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/threadListEmptyConstraintLayout"
android:layout_width="0dp"
@ -54,7 +70,6 @@
android:id="@+id/threadListEmptyImageView"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="24dp"
android:background="@drawable/bg_rounded_button"
@ -75,13 +90,13 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:gravity="center"
android:text="@string/thread_list_empty_title"
android:textColor="?vctr_content_primary"
app:layout_constraintBottom_toTopOf="@id/threadListEmptySubtitleTextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@id/threadListEmptyImageView"
android:text="@string/thread_list_empty_title" />
app:layout_constraintTop_toBottomOf="@id/threadListEmptyImageView" />
<TextView
android:id="@+id/threadListEmptySubtitleTextView"
@ -90,12 +105,12 @@
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:gravity="center"
android:text="@string/thread_list_empty_subtitle"
android:textColor="?vctr_content_secondary"
app:layout_constraintBottom_toTopOf="@id/threadListEmptyNoticeTextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/threadListEmptyTitleTextView"
android:text="@string/thread_list_empty_subtitle" />
app:layout_constraintTop_toBottomOf="@id/threadListEmptyTitleTextView" />
<TextView
android:id="@+id/threadListEmptyNoticeTextView"