From ab4eda18bfc1c489f82613ada40666870bf85be3 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 2 Aug 2022 17:44:27 +0200 Subject: [PATCH] Adds SpacesBottomSheet --- .../room/list/home/HomeRoomListFragment.kt | 2 + .../app/features/spaces/SpacesBottomSheet.kt | 46 +++++++++++++++++++ .../layout/fragment_spaces_bottom_sheet.xml | 11 +++++ 3 files changed, 59 insertions(+) create mode 100644 vector/src/main/java/im/vector/app/features/spaces/SpacesBottomSheet.kt create mode 100644 vector/src/main/res/layout/fragment_spaces_bottom_sheet.xml diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt index e7882ff36f..68143ddc7d 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt @@ -44,6 +44,7 @@ import im.vector.app.features.home.room.list.RoomSummaryPagedController import im.vector.app.features.home.room.list.actions.RoomListQuickActionsBottomSheet import im.vector.app.features.home.room.list.actions.RoomListQuickActionsSharedAction import im.vector.app.features.home.room.list.actions.RoomListQuickActionsSharedActionViewModel +import im.vector.app.features.spaces.SpacesBottomSheet import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import org.matrix.android.sdk.api.session.room.model.RoomSummary @@ -119,6 +120,7 @@ class HomeRoomListFragment @Inject constructor( views.newLayoutOpenSpacesButton.setOnClickListener { // Click action for open spaces modal goes here + SpacesBottomSheet().show(requireActivity().supportFragmentManager, SpacesBottomSheet.TAG) } // Hide FABs when list is scrolling diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpacesBottomSheet.kt b/vector/src/main/java/im/vector/app/features/spaces/SpacesBottomSheet.kt new file mode 100644 index 0000000000..c50e4b6387 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/spaces/SpacesBottomSheet.kt @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.spaces + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import com.google.android.material.bottomsheet.BottomSheetDialogFragment +import im.vector.app.R +import im.vector.app.core.extensions.replaceChildFragment +import im.vector.app.databinding.FragmentSpacesBottomSheetBinding + +class SpacesBottomSheet : BottomSheetDialogFragment() { + + private lateinit var binding: FragmentSpacesBottomSheetBinding + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { + binding = FragmentSpacesBottomSheetBinding.inflate(inflater, container, false) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + if (savedInstanceState == null) { + replaceChildFragment(R.id.space_list, SpaceListFragment::class.java) + } + } + + companion object { + const val TAG = "SpacesBottomSheet" + } +} diff --git a/vector/src/main/res/layout/fragment_spaces_bottom_sheet.xml b/vector/src/main/res/layout/fragment_spaces_bottom_sheet.xml new file mode 100644 index 0000000000..27324c852f --- /dev/null +++ b/vector/src/main/res/layout/fragment_spaces_bottom_sheet.xml @@ -0,0 +1,11 @@ + + + + + +