mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
space switcher empty spaces (#6988)
This commit is contained in:
parent
e81f02f433
commit
b37996e4c3
1
changelog.d/6754.bugfix
Normal file
1
changelog.d/6754.bugfix
Normal file
@ -0,0 +1 @@
|
||||
[App Layout] - space switcher now has empty state
|
@ -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>
|
||||
|
||||
|
@ -21,6 +21,7 @@ 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
|
||||
@ -28,6 +29,7 @@ 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
|
||||
@ -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() }
|
||||
setupSpaceController()
|
||||
observeViewEvents()
|
||||
}
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
else -> Unit
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user