Skip to content

Commit

Permalink
Merge pull request #12058 from nextcloud/feature/use-m3-for-file-actions
Browse files Browse the repository at this point in the history
Use Material Desing 3 For File Actions Bottom Sheet
  • Loading branch information
AndyScherzinger authored Oct 31, 2023
2 parents d0129b3 + f165db1 commit 8199408
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 57 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ class FileActionsBottomSheet : BottomSheetDialogFragment(), Injectable {
@Inject
lateinit var syncedFolderProvider: SyncedFolderProvider

lateinit var viewModel: FileActionsViewModel
private lateinit var viewModel: FileActionsViewModel

private var _binding: FileActionsBottomSheetBinding? = null
private val binding
get() = _binding!!

lateinit var componentsGetter: ComponentsGetter
private lateinit var componentsGetter: ComponentsGetter

private val thumbnailAsyncTasks = mutableListOf<ThumbnailsCacheManager.ThumbnailGenerationTask>()

Expand All @@ -109,6 +109,8 @@ class FileActionsBottomSheet : BottomSheetDialogFragment(), Injectable {
bottomSheetDialog.behavior.state = BottomSheetBehavior.STATE_EXPANDED
bottomSheetDialog.behavior.skipCollapsed = true

viewThemeUtils.platform.colorViewBackground(binding.bottomSheet, ColorRole.SURFACE)

return binding.root
}

Expand All @@ -125,11 +127,13 @@ class FileActionsBottomSheet : BottomSheetDialogFragment(), Injectable {
displayActions(state.actions)
displayTitle(state.titleFile)
}

is FileActionsViewModel.UiState.LoadedForMultipleFiles -> {
setMultipleFilesThumbnail()
displayActions(state.actions)
displayTitle(state.fileCount)
}

FileActionsViewModel.UiState.Loading -> {}
FileActionsViewModel.UiState.Error -> {
context?.let {
Expand Down Expand Up @@ -195,11 +199,11 @@ class FileActionsBottomSheet : BottomSheetDialogFragment(), Injectable {
private fun toggleLoadingOrContent(state: FileActionsViewModel.UiState) {
if (state is FileActionsViewModel.UiState.Loading) {
binding.bottomSheetLoading.isVisible = true
binding.bottomSheetContent.isVisible = false
binding.bottomSheetHeader.isVisible = false
viewThemeUtils.platform.colorCircularProgressBar(binding.bottomSheetLoading, ColorRole.PRIMARY)
} else {
binding.bottomSheetLoading.isVisible = false
binding.bottomSheetContent.isVisible = true
binding.bottomSheetHeader.isVisible = true
}
}

Expand Down
106 changes: 54 additions & 52 deletions app/src/main/res/layout/file_actions_bottom_sheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,73 +19,75 @@
~ License along with this program. If not, see <http://www.gnu.org/licenses/>.
~
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/bottom_sheet"
style="@style/Widget.Material3.BottomSheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:minHeight="@dimen/bottom_sheet_min_height"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">

<com.google.android.material.bottomsheet.BottomSheetDragHandleView
<LinearLayout
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<com.google.android.material.progressindicator.CircularProgressIndicator
android:indeterminate="true"
android:id="@+id/bottom_sheet_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
tools:visibility="gone" />
android:orientation="vertical">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/bottom_sheet_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible">
<com.google.android.material.bottomsheet.BottomSheetDragHandleView
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<FrameLayout
android:id="@+id/thumbnail_container"
<com.google.android.material.progressindicator.CircularProgressIndicator
android:id="@+id/bottom_sheet_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/standard_padding"
app:layout_constraintBottom_toBottomOf="@+id/title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/title">
android:layout_gravity="center"
android:layout_marginBottom="@dimen/standard_margin"
android:indeterminate="true"
tools:visibility="gone" />

<LinearLayout
android:id="@+id/bottom_sheet_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/standard_margin"
android:gravity="center"
android:orientation="horizontal"
android:visibility="visible">

<include
android:id="@+id/thumbnail_layout"
layout="@layout/file_thumbnail" />
</FrameLayout>
layout="@layout/file_thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp" />

<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="middle"
android:lines="1"
android:padding="@dimen/standard_padding"
android:textAppearance="@style/TextAppearance.Material3.HeadlineSmall"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/thumbnail_container"
app:layout_constraintTop_toTopOf="parent"
tools:text="Test file name which is very very very very very long.pdf" />
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:ellipsize="middle"
android:lines="1"
android:textAppearance="@style/TextAppearance.Material3.HeadlineSmall"
tools:text="Test file name which is very very very very very long.pdf" />

</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
android:id="@+id/file_actions_list"
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</androidx.core.widget.NestedScrollView>
</LinearLayout>
android:layout_height="wrap_content">

<LinearLayout
android:id="@+id/file_actions_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />

</androidx.core.widget.NestedScrollView>

</LinearLayout>

</FrameLayout>
1 change: 0 additions & 1 deletion app/src/main/res/values/dims.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<dimen name="bottom_sheet_text_start_margin">40dp</dimen>
<dimen name="bottom_sheet_item_height">56dp</dimen>
<dimen name="bottom_sheet_menu_item_divider_standard_margin">80dp</dimen>
<dimen name="bottom_sheet_min_height">112dp</dimen>
<dimen name="file_icon_size">40dp</dimen>
<dimen name="file_icon_size_grid">128dp</dimen>
<dimen name="file_icon_rounded_corner_radius">8dp</dimen>
Expand Down

0 comments on commit 8199408

Please sign in to comment.