space switcher empty spaces (#6988)
This commit is contained in:
parent
e81f02f433
commit
b37996e4c3
|
@ -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="system_alerts_header">"System Alerts"</string>
|
||||||
<string name="suggested_header">Suggested Rooms</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 -->
|
<!-- Invites fragment -->
|
||||||
<string name="invites_title">Invites</string>
|
<string name="invites_title">Invites</string>
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import android.view.HapticFeedbackConstants
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import com.airbnb.epoxy.EpoxyTouchHelper
|
import com.airbnb.epoxy.EpoxyTouchHelper
|
||||||
import com.airbnb.mvrx.Loading
|
import com.airbnb.mvrx.Loading
|
||||||
import com.airbnb.mvrx.Success
|
import com.airbnb.mvrx.Success
|
||||||
|
@ -28,6 +29,7 @@ import com.airbnb.mvrx.Uninitialized
|
||||||
import com.airbnb.mvrx.fragmentViewModel
|
import com.airbnb.mvrx.fragmentViewModel
|
||||||
import com.airbnb.mvrx.withState
|
import com.airbnb.mvrx.withState
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
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.cleanup
|
||||||
import im.vector.app.core.extensions.configureWith
|
import im.vector.app.core.extensions.configureWith
|
||||||
import im.vector.app.core.platform.StateView
|
import im.vector.app.core.platform.StateView
|
||||||
|
@ -71,6 +73,7 @@ class SpaceListFragment :
|
||||||
homeActivitySharedActionViewModel = activityViewModelProvider[HomeSharedActionViewModel::class.java]
|
homeActivitySharedActionViewModel = activityViewModelProvider[HomeSharedActionViewModel::class.java]
|
||||||
roomListSharedActionViewModel = activityViewModelProvider[RoomListSharedActionViewModel::class.java]
|
roomListSharedActionViewModel = activityViewModelProvider[RoomListSharedActionViewModel::class.java]
|
||||||
views.stateView.contentView = views.groupListView
|
views.stateView.contentView = views.groupListView
|
||||||
|
views.spacesEmptyButton.onClick { onAddSpaceSelected() }
|
||||||
setupSpaceController()
|
setupSpaceController()
|
||||||
observeViewEvents()
|
observeViewEvents()
|
||||||
}
|
}
|
||||||
|
@ -147,13 +150,22 @@ class SpaceListFragment :
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun invalidate() = withState(viewModel) { state ->
|
override fun invalidate() = withState(viewModel) { state ->
|
||||||
when (state.asyncSpaces) {
|
when (val spaces = state.asyncSpaces) {
|
||||||
Uninitialized,
|
Uninitialized,
|
||||||
is Loading -> {
|
is Loading -> {
|
||||||
views.stateView.state = StateView.State.Loading
|
views.stateView.state = StateView.State.Loading
|
||||||
return@withState
|
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
|
else -> Unit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,4 +12,48 @@
|
||||||
android:overScrollMode="always"
|
android:overScrollMode="always"
|
||||||
tools:listitem="@layout/item_space" />
|
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>
|
</im.vector.app.core.platform.StateView>
|
||||||
|
|
Loading…
Reference in New Issue