Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/6754.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[App Layout] - space switcher now has empty state
4 changes: 4 additions & 0 deletions library/ui-strings/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@
<string name="system_alerts_header">"System Alerts"</string>
<string name="suggested_header">Suggested Rooms</string>

<!-- Space List fragment -->
<string name="space_list_empty_title">No spaces yet.</string>
<string name="space_list_empty_message">Spaces are a new way to group rooms and people. Create a space to get started.</string>

<!-- Invites fragment -->
<string name="invites_title">Invites</string>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ import android.view.HapticFeedbackConstants
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import com.airbnb.epoxy.EpoxyTouchHelper
import com.airbnb.mvrx.Loading
import com.airbnb.mvrx.Success
import com.airbnb.mvrx.Uninitialized
import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState
import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.core.epoxy.onClick
import im.vector.app.core.extensions.cleanup
import im.vector.app.core.extensions.configureWith
import im.vector.app.core.platform.StateView
Expand Down Expand Up @@ -71,6 +73,7 @@ class SpaceListFragment :
homeActivitySharedActionViewModel = activityViewModelProvider[HomeSharedActionViewModel::class.java]
roomListSharedActionViewModel = activityViewModelProvider[RoomListSharedActionViewModel::class.java]
views.stateView.contentView = views.groupListView
views.spacesEmptyButton.onClick { onAddSpaceSelected() }
Copy link
Member

Choose a reason for hiding this comment

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

This is maybe not new, but when the user clicks on this button, do we want to close the bottomsheet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ericdecanini could you please verify?

Copy link
Contributor

@ericdecanini ericdecanini Sep 5, 2022

Choose a reason for hiding this comment

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

Ideally we don't want to close it immediately in case the user navigates back but we want to close it following a successful space creation.

There's already an issue for this #6950

Edit: This behaviour already works like this in this PR. It also may be that we can close the above mentioned issue if we investigate that this works too in other cases

setupSpaceController()
observeViewEvents()
}
Expand Down Expand Up @@ -147,13 +150,22 @@ class SpaceListFragment :
}

override fun invalidate() = withState(viewModel) { state ->
when (state.asyncSpaces) {
when (val spaces = state.asyncSpaces) {
Uninitialized,
is Loading -> {
views.stateView.state = StateView.State.Loading
return@withState
}
is Success -> views.stateView.state = StateView.State.Content
is Success -> {
views.stateView.state = StateView.State.Content
if (spaces.invoke().isEmpty()) {
views.spacesEmptyGroup.isVisible = true
views.groupListView.isVisible = false
} else {
views.spacesEmptyGroup.isVisible = false
views.groupListView.isVisible = true
}
}
Copy link
Member

Choose a reason for hiding this comment

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

About StateView, the correct code would be:

            is Success -> {
                if (spaces.invoke().isEmpty()) {
                    views.stateView.state = StateView.State.Empty(...)
                } else {
                    views.stateView.state = StateView.State.Content
                }
            }

But maybe there are specific needs here? If this is the spaces_empty_button, maybe we could improve the StateView to integrate it. (can be done later, to not block this.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

StateView has exact implementation for Empty state and I hadn't time to extend it to accept custom views (it rises some problems like callbacks for button). So in this case I had to place custom empty state near content view and switch between them. StateView her is mostly for loading state

Copy link
Member

Choose a reason for hiding this comment

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

OK; thanks for explaining.

else -> Unit
}

Expand Down
44 changes: 44 additions & 0 deletions vector/src/main/res/layout/fragment_space_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,48 @@
android:overScrollMode="always"
tools:listitem="@layout/item_space" />


<LinearLayout
android:id="@+id/spaces_empty_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:padding="@dimen/layout_horizontal_margin"
android:visibility="gone"
tools:visibility="visible">

<TextView
android:id="@+id/spaces_empty_title"
style="@style/Widget.Vector.TextView.Subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="@string/space_list_empty_title"
android:textColor="?vctr_content_primary"
android:textStyle="bold" />

<TextView
android:id="@+id/spaces_empty_message"
style="@style/Widget.Vector.TextView.Body"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:gravity="center"
android:text="@string/space_list_empty_message"
android:textColor="?vctr_content_secondary" />

<Button
android:id="@+id/spaces_empty_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="8dp"
android:minWidth="190dp"
android:text="@string/create_space" />

</LinearLayout>

</im.vector.app.core.platform.StateView>