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

New App Layout: Adds New Chat Bottom Sheet #6801

Merged
merged 8 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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/6801.wip
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adds new chat bottom sheet as the click action of the main FAB in the new app layout
6 changes: 6 additions & 0 deletions vector/src/main/java/im/vector/app/core/di/FragmentModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import im.vector.app.features.home.room.detail.TimelineFragment
import im.vector.app.features.home.room.detail.search.SearchFragment
import im.vector.app.features.home.room.list.RoomListFragment
import im.vector.app.features.home.room.list.home.HomeRoomListFragment
import im.vector.app.features.home.room.list.home.NewChatBottomSheet
import im.vector.app.features.home.room.threads.list.views.ThreadListFragment
import im.vector.app.features.location.LocationSharingFragment
import im.vector.app.features.location.preview.LocationPreviewFragment
Expand Down Expand Up @@ -209,6 +210,11 @@ interface FragmentModule {
@FragmentKey(RoomListFragment::class)
fun bindRoomListFragment(fragment: RoomListFragment): Fragment

@Binds
@IntoMap
@FragmentKey(NewChatBottomSheet::class)
fun bindNewChatBottomSheetFragment(fragment: NewChatBottomSheet): Fragment

@Binds
@IntoMap
@FragmentKey(LocalePickerFragment::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class HomeRoomListFragment @Inject constructor(

private lateinit var stateRestorer: LayoutManagerStateRestorer

private val newChatBottomSheet = NewChatBottomSheet()

override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRoomListBinding {
return FragmentRoomListBinding.inflate(inflater, container, false)
}
Expand Down Expand Up @@ -117,7 +119,7 @@ class HomeRoomListFragment @Inject constructor(
showFABs()

views.newLayoutCreateChatButton.setOnClickListener {
// Click action for create chat modal goes here (Issue #6717)
newChatBottomSheet.show(requireActivity().supportFragmentManager, NewChatBottomSheet.TAG)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Wdyt about creating the bottom sheet instance here instead of a class variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wouldn't prefer doing it this way because we're creating new instances of the bottom sheet every time and adding it to memory

}

views.newLayoutOpenSpacesButton.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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.home.room.list.home

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.databinding.FragmentNewChatBottomSheetBinding
import im.vector.app.features.navigation.Navigator
import javax.inject.Inject

@AndroidEntryPoint
class NewChatBottomSheet @Inject constructor() : BottomSheetDialogFragment() {

@Inject lateinit var navigator: Navigator

private lateinit var binding: FragmentNewChatBottomSheetBinding

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = FragmentNewChatBottomSheetBinding.inflate(inflater, container, false)
initFABs()
return binding.root
}

private fun initFABs() {
binding.startChat.setOnClickListener {
navigator.openCreateDirectRoom(requireActivity())
}

binding.createRoom.setOnClickListener {
navigator.openCreateRoom(requireActivity(), "")
Copy link
Contributor

Choose a reason for hiding this comment

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

initialName param of openCreateRoom has default value, so you can just skip it

}
}

companion object {
const val TAG = "NewChatBottomSheet"
}
}
31 changes: 31 additions & 0 deletions vector/src/main/res/layout/fragment_new_chat_bottom_sheet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:id="@+id/start_chat"
style="@style/Widget.Vector.TextView.Subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:paddingHorizontal="16dp"
android:paddingVertical="16dp"
android:text="@string/start_chat"
android:textAppearance="@style/TextAppearance.Vector.Body"
Copy link
Contributor

Choose a reason for hiding this comment

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

you apply both style and textAppearance`. We should only apply style which fits by text size and override other params if necessary

android:textColor="?vctr_content_primary" />

<TextView
android:id="@+id/create_room"
style="@style/Widget.Vector.TextView.Subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:paddingHorizontal="16dp"
android:paddingVertical="16dp"
android:text="@string/create_room"
android:textAppearance="@style/TextAppearance.Vector.Body"
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

android:textColor="?vctr_content_primary" />

</LinearLayout>
2 changes: 2 additions & 0 deletions vector/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@

<!-- Home Screen -->
<string name="all_chats">All Chats</string>
<string name="start_chat">Start chat</string>
<string name="create_room">Create room</string>

<!-- Last seen time -->

Expand Down