Skip to content

Commit

Permalink
Add progress bar for list of contacts on dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
ariel10aguero committed Sep 29, 2023
1 parent 9a1a000 commit 3cd52c6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import chat.sphinx.dashboard.ui.adapter.DashboardFooterAdapter
import chat.sphinx.dashboard.ui.viewstates.ChatFilter
import chat.sphinx.dashboard.ui.viewstates.ChatListFooterButtonsViewState
import chat.sphinx.dashboard.ui.viewstates.ChatListViewState
import chat.sphinx.dashboard.ui.viewstates.ChatViewState
import chat.sphinx.resources.SphinxToastUtils
import chat.sphinx.resources.inputMethodManager
import chat.sphinx.wrapper_chat.ChatType
Expand All @@ -32,6 +33,7 @@ import io.matthewnelson.android_feature_screens.navigation.CloseAppOnBackPress
import io.matthewnelson.android_feature_screens.ui.sideeffect.SideEffectFragment
import io.matthewnelson.android_feature_screens.util.gone
import io.matthewnelson.android_feature_screens.util.goneIfFalse
import io.matthewnelson.android_feature_screens.util.visible
import io.matthewnelson.concept_views.viewstate.collect
import kotlinx.coroutines.launch
import javax.inject.Inject
Expand Down Expand Up @@ -217,4 +219,21 @@ internal class ChatListFragment : SideEffectFragment<
}
}
}

override fun subscribeToViewStateFlow() {
onStopSupervisor.scope.launch(viewModel.mainImmediate) {
viewModel.chatViewStateContainer.collect { viewState ->
when {
viewState.list.isEmpty() -> {
binding.progressBarChatList.visible
}
viewState.list.isNotEmpty() -> {
binding.progressBarChatList.gone
}
}
}
}

super.subscribeToViewStateFlow()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,17 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/layout_search_bar" />

<ProgressBar
android:id="@+id/progress_bar_chat_list"
style="?android:attr/progressBarStyle"
android:layout_width="@dimen/default_large_layout_margin"
android:layout_height="@dimen/default_large_layout_margin"
android:indeterminate="true"
android:indeterminateTint="@android:color/white"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 3cd52c6

Please sign in to comment.