Skip to content

Commit

Permalink
Settings Menu UI fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviahandrea-vsp committed Feb 26, 2024
1 parent 8e4ce16 commit 7b155f9
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<LegacyContact>()

fun setBundleArguments(legacyContact: LegacyContact?) {
val bundle = Bundle()
Expand All @@ -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()
})
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -140,6 +141,8 @@ fun SettingsMenuScreen(
stringResource(R.string.sign_out),
error500Color,
) { onSignOutClick() }

Spacer(modifier = Modifier.height(24.dp))
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/drawable/rounded_dialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/white"/>
<corners android:topLeftRadius="16dp"
android:topRightRadius="16dp"/>

</shape>
12 changes: 12 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<item name="listPreferredItemHeightSmall">54dp</item>
<item name="android:fontFamily">@font/open_sans</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="bottomSheetDialogTheme">@style/AppBottomSheetDialogTheme</item>
</style>

<!-- Theme without ActionBar -->
Expand All @@ -23,6 +24,17 @@
<item name="listPreferredItemHeightSmall">54dp</item>
<item name="android:fontFamily">@font/open_sans</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="bottomSheetDialogTheme">@style/AppBottomSheetDialogTheme</item>
</style>

<style name="AppBottomSheetDialogTheme"
parent="Theme.Design.Light.BottomSheetDialog">
<item name="bottomSheetStyle">@style/AppModalStyle</item>
</style>

<style name="AppModalStyle"
parent="Widget.Design.BottomSheet.Modal">
<item name="android:background">@drawable/rounded_dialog</item>
</style>

<style name="customMenuTextAppearance" parent="@android:style/TextAppearance.Widget.IconMenu.Item">
Expand Down

0 comments on commit 7b155f9

Please sign in to comment.