mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-21 17:05:39 +03:00
Merge pull request #5666 from vector-im/feature/aris/threads_thread_list_loader
Add loader to thread list
This commit is contained in:
commit
b9934d7239
5 changed files with 36 additions and 6 deletions
1
changelog.d/5562.bugfix
Normal file
1
changelog.d/5562.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Add loader in thread list
|
|
@ -113,7 +113,15 @@ class ThreadListViewModel @AssistedInject constructor(@Assisted val initialState
|
||||||
|
|
||||||
private fun fetchThreadList() {
|
private fun fetchThreadList() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
|
setLoading(true)
|
||||||
room?.fetchThreadSummaries()
|
room?.fetchThreadSummaries()
|
||||||
|
setLoading(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setLoading(isLoading: Boolean) {
|
||||||
|
setState {
|
||||||
|
copy(isLoading = isLoading)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ data class ThreadListViewState(
|
||||||
val threadSummaryList: Async<List<ThreadSummary>> = Uninitialized,
|
val threadSummaryList: Async<List<ThreadSummary>> = Uninitialized,
|
||||||
val rootThreadEventList: Async<List<ThreadTimelineEvent>> = Uninitialized,
|
val rootThreadEventList: Async<List<ThreadTimelineEvent>> = Uninitialized,
|
||||||
val shouldFilterThreads: Boolean = false,
|
val shouldFilterThreads: Boolean = false,
|
||||||
|
val isLoading: Boolean = false,
|
||||||
val roomId: String
|
val roomId: String
|
||||||
) : MavericksState {
|
) : MavericksState {
|
||||||
constructor(args: ThreadListArgs) : this(roomId = args.roomId)
|
constructor(args: ThreadListArgs) : this(roomId = args.roomId)
|
||||||
|
|
|
@ -104,6 +104,11 @@ class ThreadListFragment @Inject constructor(
|
||||||
override fun invalidate() = withState(threadListViewModel) { state ->
|
override fun invalidate() = withState(threadListViewModel) { state ->
|
||||||
renderEmptyStateIfNeeded(state)
|
renderEmptyStateIfNeeded(state)
|
||||||
threadListController.update(state)
|
threadListController.update(state)
|
||||||
|
renderLoaderIfNeeded(state)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun renderLoaderIfNeeded(state: ThreadListViewState) {
|
||||||
|
views.threadListProgressBar.isVisible = state.isLoading
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderToolbar() {
|
private fun renderToolbar() {
|
||||||
|
|
|
@ -37,6 +37,22 @@
|
||||||
tools:listitem="@layout/item_thread"
|
tools:listitem="@layout/item_thread"
|
||||||
tools:visibility="gone" />
|
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
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/threadListEmptyConstraintLayout"
|
android:id="@+id/threadListEmptyConstraintLayout"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -54,7 +70,6 @@
|
||||||
android:id="@+id/threadListEmptyImageView"
|
android:id="@+id/threadListEmptyImageView"
|
||||||
android:layout_width="64dp"
|
android:layout_width="64dp"
|
||||||
android:layout_height="64dp"
|
android:layout_height="64dp"
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:layout_marginBottom="24dp"
|
android:layout_marginBottom="24dp"
|
||||||
android:background="@drawable/bg_rounded_button"
|
android:background="@drawable/bg_rounded_button"
|
||||||
|
@ -75,13 +90,13 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="20dp"
|
android:layout_marginBottom="20dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/thread_list_empty_title"
|
||||||
android:textColor="?vctr_content_primary"
|
android:textColor="?vctr_content_primary"
|
||||||
app:layout_constraintBottom_toTopOf="@id/threadListEmptySubtitleTextView"
|
app:layout_constraintBottom_toTopOf="@id/threadListEmptySubtitleTextView"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:gravity="center"
|
app:layout_constraintTop_toBottomOf="@id/threadListEmptyImageView" />
|
||||||
app:layout_constraintTop_toBottomOf="@id/threadListEmptyImageView"
|
|
||||||
android:text="@string/thread_list_empty_title" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/threadListEmptySubtitleTextView"
|
android:id="@+id/threadListEmptySubtitleTextView"
|
||||||
|
@ -90,12 +105,12 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="20dp"
|
android:layout_marginBottom="20dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
android:text="@string/thread_list_empty_subtitle"
|
||||||
android:textColor="?vctr_content_secondary"
|
android:textColor="?vctr_content_secondary"
|
||||||
app:layout_constraintBottom_toTopOf="@id/threadListEmptyNoticeTextView"
|
app:layout_constraintBottom_toTopOf="@id/threadListEmptyNoticeTextView"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/threadListEmptyTitleTextView"
|
app:layout_constraintTop_toBottomOf="@id/threadListEmptyTitleTextView" />
|
||||||
android:text="@string/thread_list_empty_subtitle" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/threadListEmptyNoticeTextView"
|
android:id="@+id/threadListEmptyNoticeTextView"
|
||||||
|
|
Loading…
Reference in a new issue