Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NT-1943: UI/UX – Empty state #1258

Merged
merged 6 commits into from May 25, 2021
Merged

Conversation

sunday-okpoluaefe
Copy link
Contributor

πŸ“² What

UI/UX – Empty state

πŸ€” Why

Someone has to be the first to comment, let's make sure they have a nice experience!

πŸ›  How

  • Added empty textview placeholder to activity_comments_layout
<androidx.appcompat.widget.AppCompatTextView
           android:id="@+id/no_comments"
           android:visibility="gone"
           android:layout_marginTop="@dimen/grid_11"
           app:layout_constraintTop_toTopOf="parent"
           app:layout_constraintStart_toStartOf="parent"
           app:layout_constraintEnd_toEndOf="parent"
           android:layout_width="wrap_content"
           android:text="@string/No_comments_yet"
           style="@style/CalloutSecondary"
           android:layout_height="wrap_content"/>
  • Subscribed to commentEnvelope, checked for totalCount . show comments if > 0; else show empty state
commentEnvelope
                .filter { ObjectUtils.isNotNull(it) }
                .compose(bindToLifecycle())
                .subscribe {
                    it.totalCount?.let { count ->
                        if (count > 0) {
                            this.setEmptyState.onNext(false)
                            commentsList.onNext(it.comments)
                        } else this.setEmptyState.onNext(true)
                    }
                }
  • Added tests
  /*
     * test when no comment available
     */
    @Test
    fun testCommentsViewModel_EmptyCommentState() {
        val env = environment().toBuilder().apolloClient(object : MockApolloClient() {
            override fun getProjectComments(slug: String, cursor: String?, limit: Int): Observable<CommentEnvelope> {
                return Observable.just(CommentEnvelopeFactory.emptyCommentsEnvelope())
            }
        }).build()
        val vm = CommentsViewModel.ViewModel(env)
        vm.outputs.setEmptyState().subscribe(showEmptyState)

        // Start the view model with an update.
        vm.intent(Intent().putExtra(IntentKey.UPDATE, UpdateFactory.update()))
        showEmptyState.assertValue(true)
    }

 /*
     * test when comment(s) available
     */
    @Test
    fun testCommentsViewModel_CommentsAvailableState() {
        val env = environment().toBuilder().apolloClient(object : MockApolloClient() {
            override fun getProjectComments(slug: String, cursor: String?, limit: Int): Observable<CommentEnvelope> {
                return Observable.just(CommentEnvelopeFactory.commentsEnvelope())
            }
        }).build()
        val vm = CommentsViewModel.ViewModel(env)
        vm.outputs.setEmptyState().subscribe(showEmptyState)

        // Start the view model with an update.
        vm.intent(Intent().putExtra(IntentKey.UPDATE, UpdateFactory.update()))
        showEmptyState.assertValue(false)
    }

πŸ‘€ See

empty

Before πŸ› After πŸ¦‹

πŸ“‹ QA

record.mp4

Story πŸ“–

https://kickstarter.atlassian.net/browse/NT-1943

@sunday-okpoluaefe sunday-okpoluaefe requested review from hadia, Arkariang, leighdouglas and jgsamudio and removed request for hadia May 25, 2021 13:48
@codecov
Copy link

codecov bot commented May 25, 2021

Codecov Report

Merging #1258 (d9b10d8) into master (0615810) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1258   +/-   ##
=========================================
  Coverage     74.50%   74.50%           
  Complexity      739      739           
=========================================
  Files           221      221           
  Lines          6632     6632           
  Branches        404      404           
=========================================
  Hits           4941     4941           
  Misses         1555     1555           
  Partials        136      136           

Continue to review full report at Codecov.

Legend - Click here to learn more
Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data
Powered by Codecov. Last update 0615810...d9b10d8. Read the comment docs.

.filter { ObjectUtils.isNotNull(it) }
.compose(bindToLifecycle())
.subscribe {
commentsList.onNext(it)
it.totalCount?.let { count ->
if (count > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could refactor these lines to be
this.setEmptyState.onNext(count > 0)
so you don't need the if condition inside the let block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great. thanks this.setEmptyState.onNext(count < 1)

Copy link
Contributor

@Arkariang Arkariang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment left, once it's addressed feel free to merge :)

@sunday-okpoluaefe sunday-okpoluaefe merged commit 0ce20f9 into master May 25, 2021
@sunday-okpoluaefe sunday-okpoluaefe deleted the sunday-nt-1943-empty-state branch May 25, 2021 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants