From 7b155f9c351f135c83fe1201a6c2038aeeaa8fba Mon Sep 17 00:00:00 2001 From: Flavia Handrea Date: Mon, 26 Feb 2024 16:51:42 +0200 Subject: [PATCH] Settings Menu UI fixes. --- .../permanent/ui/activities/MainActivity.kt | 3 +- .../composeComponents/PartialScreenLayout.kt | 31 ++++++++ .../ui/settings/SettingsMenuFragment.kt | 75 ++++++++++--------- .../ui/settings/compose/SettingsMenuScreen.kt | 3 + app/src/main/res/drawable/rounded_dialog.xml | 8 ++ app/src/main/res/values/styles.xml | 12 +++ 6 files changed, 93 insertions(+), 39 deletions(-) create mode 100644 app/src/main/java/org/permanent/permanent/ui/composeComponents/PartialScreenLayout.kt create mode 100644 app/src/main/res/drawable/rounded_dialog.xml diff --git a/app/src/main/java/org/permanent/permanent/ui/activities/MainActivity.kt b/app/src/main/java/org/permanent/permanent/ui/activities/MainActivity.kt index 51b1728d..4d1bce1c 100644 --- a/app/src/main/java/org/permanent/permanent/ui/activities/MainActivity.kt +++ b/app/src/main/java/org/permanent/permanent/ui/activities/MainActivity.kt @@ -102,7 +102,7 @@ class MainActivity : PermanentBaseActivity(), Toolbar.OnMenuItemClickListener { binding.toolbar.menu?.findItem(R.id.moreItem)?.isVisible = true } - R.id.legacyLoadingFragment, R.id.addStorageFragment, R.id.giftStorageFragment, R.id.redeemCodeFragment -> { + R.id.legacyLoadingFragment, R.id.storageMenuFragment, R.id.addStorageFragment, R.id.giftStorageFragment, R.id.redeemCodeFragment -> { binding.toolbar.menu?.findItem(R.id.settingsItem)?.isVisible = false } @@ -150,7 +150,6 @@ class MainActivity : PermanentBaseActivity(), Toolbar.OnMenuItemClickListener { R.id.archiveSettings, R.id.manageTagsFragment, R.id.membersFragment, - R.id.storageMenuFragment, R.id.activityFeedFragment, R.id.invitationsFragment, R.id.accountFragment, diff --git a/app/src/main/java/org/permanent/permanent/ui/composeComponents/PartialScreenLayout.kt b/app/src/main/java/org/permanent/permanent/ui/composeComponents/PartialScreenLayout.kt new file mode 100644 index 00000000..1fe58dd2 --- /dev/null +++ b/app/src/main/java/org/permanent/permanent/ui/composeComponents/PartialScreenLayout.kt @@ -0,0 +1,31 @@ +package org.permanent.permanent.ui.composeComponents + +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.layout.Layout +import androidx.compose.ui.unit.dp + +@Composable +fun PartialScreenLayout( + modifier: Modifier = Modifier, + content: @Composable () -> Unit +) { + Layout( + modifier = modifier.clip(shape = RoundedCornerShape(8.dp)), + content = content + ) { measurables, constraints -> + val placeable = measurables[0].measure(constraints) + + val width = constraints.maxWidth + val height = (constraints.maxHeight * 0.96).toInt() + + layout(width, height) { + placeable.placeRelative( + (constraints.maxWidth - width) / 2, + 0 + ) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/org/permanent/permanent/ui/settings/SettingsMenuFragment.kt b/app/src/main/java/org/permanent/permanent/ui/settings/SettingsMenuFragment.kt index 2b96fc3d..d913b227 100644 --- a/app/src/main/java/org/permanent/permanent/ui/settings/SettingsMenuFragment.kt +++ b/app/src/main/java/org/permanent/permanent/ui/settings/SettingsMenuFragment.kt @@ -20,15 +20,14 @@ import org.permanent.permanent.EventsManager import org.permanent.permanent.R import org.permanent.permanent.network.models.LegacyContact import org.permanent.permanent.ui.PermanentBottomSheetFragment +import org.permanent.permanent.ui.composeComponents.PartialScreenLayout import org.permanent.permanent.ui.login.LoginActivity import org.permanent.permanent.ui.settings.compose.SettingsMenuScreen import org.permanent.permanent.viewmodels.SettingsMenuViewModel -import org.permanent.permanent.viewmodels.SingleLiveEvent class SettingsMenuFragment : PermanentBottomSheetFragment() { private lateinit var viewModel: SettingsMenuViewModel - private val onLegacyContactUpdated = SingleLiveEvent() fun setBundleArguments(legacyContact: LegacyContact?) { val bundle = Bundle() @@ -44,41 +43,43 @@ class SettingsMenuFragment : PermanentBottomSheetFragment() { return ComposeView(requireContext()).apply { setContent { MaterialTheme { - SettingsMenuScreen( - viewModel = viewModel, - onCloseScreenClick = { this@SettingsMenuFragment.dismiss() }, - onAccountClick = { - findNavController().navigate(R.id.accountFragment) - this@SettingsMenuFragment.dismiss() - }, - onStorageClick = { - findNavController().navigate(R.id.storageMenuFragment) - this@SettingsMenuFragment.dismiss() - }, - onMyArchivesClick = { - findNavController().navigate(R.id.archivesFragment) - this@SettingsMenuFragment.dismiss() - }, - onInvitationsClick = { - findNavController().navigate(R.id.invitationsFragment) - this@SettingsMenuFragment.dismiss() - }, - onActivityFeedClick = { - findNavController().navigate(R.id.activityFeedFragment) - this@SettingsMenuFragment.dismiss() - }, - onSecurityClick = { - findNavController().navigate(R.id.securityFragment) - this@SettingsMenuFragment.dismiss() - }, - onLegacyPlanningClick = { - findNavController().navigate(R.id.legacyLoadingFragment) - this@SettingsMenuFragment.dismiss() - }, - onSignOutClick = { - viewModel.deleteDeviceToken() - EventsManager(context).resetUser() - }) + PartialScreenLayout { + SettingsMenuScreen( + viewModel = viewModel, + onCloseScreenClick = { this@SettingsMenuFragment.dismiss() }, + onAccountClick = { + findNavController().navigate(R.id.accountFragment) + this@SettingsMenuFragment.dismiss() + }, + onStorageClick = { + findNavController().navigate(R.id.storageMenuFragment) + this@SettingsMenuFragment.dismiss() + }, + onMyArchivesClick = { + findNavController().navigate(R.id.archivesFragment) + this@SettingsMenuFragment.dismiss() + }, + onInvitationsClick = { + findNavController().navigate(R.id.invitationsFragment) + this@SettingsMenuFragment.dismiss() + }, + onActivityFeedClick = { + findNavController().navigate(R.id.activityFeedFragment) + this@SettingsMenuFragment.dismiss() + }, + onSecurityClick = { + findNavController().navigate(R.id.securityFragment) + this@SettingsMenuFragment.dismiss() + }, + onLegacyPlanningClick = { + findNavController().navigate(R.id.legacyLoadingFragment) + this@SettingsMenuFragment.dismiss() + }, + onSignOutClick = { + viewModel.deleteDeviceToken() + EventsManager(context).resetUser() + }) + } } } } diff --git a/app/src/main/java/org/permanent/permanent/ui/settings/compose/SettingsMenuScreen.kt b/app/src/main/java/org/permanent/permanent/ui/settings/compose/SettingsMenuScreen.kt index e03d7fa8..0dbc1a66 100644 --- a/app/src/main/java/org/permanent/permanent/ui/settings/compose/SettingsMenuScreen.kt +++ b/app/src/main/java/org/permanent/permanent/ui/settings/compose/SettingsMenuScreen.kt @@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape @@ -140,6 +141,8 @@ fun SettingsMenuScreen( stringResource(R.string.sign_out), error500Color, ) { onSignOutClick() } + + Spacer(modifier = Modifier.height(24.dp)) } } } diff --git a/app/src/main/res/drawable/rounded_dialog.xml b/app/src/main/res/drawable/rounded_dialog.xml new file mode 100644 index 00000000..fb23872b --- /dev/null +++ b/app/src/main/res/drawable/rounded_dialog.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 169f7cb3..067b4ec6 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -10,6 +10,7 @@ 54dp @font/open_sans true + @style/AppBottomSheetDialogTheme @@ -23,6 +24,17 @@ 54dp @font/open_sans true + @style/AppBottomSheetDialogTheme + + + + +