This repository was archived by the owner on Aug 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Implement SharedPrivateContactInfo #74
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+32.6 KB
...ponents.SharePrivateContactInfoTest.sharePrivateContactInfo_bothSwitchesOff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+30.9 KB
...mponents.SharePrivateContactInfoTest.sharePrivateContactInfo_bothSwitchesOn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+25.2 KB
....components.SharePrivateContactInfoTest.sharePrivateContactInfo_emptyValues.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion
7
homeUi/src/main/kotlin/com/gravatar/app/homeUi/presentation/home/share/ShareEvent.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| package com.gravatar.app.homeUi.presentation.home.share | ||
|
|
||
| internal sealed class ShareEvent | ||
| internal sealed class ShareEvent { | ||
| data class OnEmailValueChanged(val value: String) : ShareEvent() | ||
| data class OnEmailSharingChanged(val isShared: Boolean) : ShareEvent() | ||
| data class OnPhoneValueChanged(val value: String) : ShareEvent() | ||
| data class OnPhoneSharingChanged(val isShared: Boolean) : ShareEvent() | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...n/kotlin/com/gravatar/app/homeUi/presentation/home/share/components/ShareEditableField.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| package com.gravatar.app.homeUi.presentation.home.share.components | ||
|
|
||
| import androidx.annotation.StringRes | ||
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.shape.RoundedCornerShape | ||
| import androidx.compose.foundation.text.BasicTextField | ||
| import androidx.compose.material3.MaterialTheme | ||
| import androidx.compose.material3.Switch | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.graphics.SolidColor | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import com.gravatar.app.homeUi.R | ||
|
|
||
| @Composable | ||
| internal fun ShareEditableField( | ||
| @StringRes placeholder: Int, | ||
| value: String, | ||
| onValueChange: (String) -> Unit, | ||
| switchChecked: Boolean, | ||
| onSwitchCheckedChange: (Boolean) -> Unit, | ||
| modifier: Modifier = Modifier | ||
| ) { | ||
| Row( | ||
| modifier = modifier.fillMaxWidth(), | ||
| verticalAlignment = Alignment.CenterVertically, | ||
| horizontalArrangement = Arrangement.spacedBy(16.dp), | ||
| ) { | ||
| BasicTextField( | ||
| value = value, | ||
| onValueChange = onValueChange, | ||
| textStyle = MaterialTheme.typography.bodyLarge.copy(color = MaterialTheme.colorScheme.onSurface), | ||
| singleLine = true, | ||
| cursorBrush = SolidColor(MaterialTheme.colorScheme.primary), | ||
| modifier = Modifier.weight(1f), | ||
| decorationBox = { innerTextField -> | ||
| Box( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .background(MaterialTheme.colorScheme.surfaceContainerHigh, RoundedCornerShape(8.dp)) | ||
| .padding(horizontal = 12.dp, vertical = 12.dp) | ||
| ) { | ||
| if (value.isEmpty()) { | ||
| Text( | ||
| text = stringResource(placeholder), | ||
| style = MaterialTheme.typography.bodyLarge, | ||
| color = MaterialTheme.colorScheme.onSurfaceVariant | ||
| ) | ||
| } | ||
| innerTextField() | ||
| } | ||
| } | ||
| ) | ||
| Switch( | ||
| checked = switchChecked, | ||
| onCheckedChange = onSwitchCheckedChange, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| @Preview | ||
| @Composable | ||
| private fun ShareEditableInfoPreview() { | ||
| ShareEditableField( | ||
| placeholder = R.string.share_tab_private_contact_email_placeholder, | ||
| value = "gravatar@a8c.com", | ||
| onValueChange = {}, | ||
| switchChecked = true, | ||
| onSwitchCheckedChange = {} | ||
| ) | ||
| } | ||
|
|
||
| @Preview | ||
| @Composable | ||
| private fun ShareEditableInfoEmptyPreview() { | ||
| ShareEditableField( | ||
| placeholder = R.string.share_tab_private_contact_phone_number_placeholder, | ||
| value = "", | ||
| onValueChange = {}, | ||
| switchChecked = false, | ||
| onSwitchCheckedChange = {} | ||
| ) | ||
| } |
61 changes: 61 additions & 0 deletions
61
...lin/com/gravatar/app/homeUi/presentation/home/share/components/SharePrivateContactInfo.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| package com.gravatar.app.homeUi.presentation.home.share.components | ||
|
|
||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import com.gravatar.app.homeUi.R | ||
| import com.gravatar.app.homeUi.presentation.home.share.PrivateContactInfo | ||
|
|
||
| @Composable | ||
| internal fun SharePrivateContactInfo( | ||
| privateContactInfo: PrivateContactInfo, | ||
| onEmailValueChange: (String) -> Unit, | ||
| onEmailSwitchCheckedChange: (Boolean) -> Unit, | ||
| onPhoneValueChange: (String) -> Unit, | ||
| onPhoneSwitchCheckedChange: (Boolean) -> Unit, | ||
| modifier: Modifier = Modifier | ||
| ) { | ||
| Column(verticalArrangement = Arrangement.spacedBy(16.dp), modifier = modifier) { | ||
| ShareSectionTitle( | ||
| leftIcon = R.drawable.share_section_title_warning, | ||
| title = R.string.share_tab_private_contact_info_title, | ||
| rightIcon = R.drawable.share_section_title_lock, | ||
| modifier = Modifier.fillMaxWidth() | ||
| ) | ||
| ShareEditableField( | ||
| placeholder = R.string.share_tab_private_contact_email_placeholder, | ||
| value = privateContactInfo.emailValue, | ||
| onValueChange = onEmailValueChange, | ||
| switchChecked = privateContactInfo.isEmailShared, | ||
| onSwitchCheckedChange = onEmailSwitchCheckedChange, | ||
| ) | ||
| ShareEditableField( | ||
| placeholder = R.string.share_tab_private_contact_phone_number_placeholder, | ||
| value = privateContactInfo.phoneValue, | ||
| onValueChange = onPhoneValueChange, | ||
| switchChecked = privateContactInfo.isPhoneShared, | ||
| onSwitchCheckedChange = onPhoneSwitchCheckedChange, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| private fun SharePrivateContactInfoPreview() { | ||
| SharePrivateContactInfo( | ||
| privateContactInfo = PrivateContactInfo( | ||
| emailValue = "example@email.com", | ||
| isEmailShared = true, | ||
| phoneValue = "123-456-7890", | ||
| isPhoneShared = false | ||
| ), | ||
| onEmailValueChange = {}, | ||
| onEmailSwitchCheckedChange = {}, | ||
| onPhoneValueChange = {}, | ||
| onPhoneSwitchCheckedChange = {} | ||
| ) | ||
| } |
76 changes: 76 additions & 0 deletions
76
...in/kotlin/com/gravatar/app/homeUi/presentation/home/share/components/ShareSectionTitle.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| package com.gravatar.app.homeUi.presentation.home.share.components | ||
|
|
||
| import androidx.annotation.DrawableRes | ||
| import androidx.annotation.StringRes | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.text.BasicText | ||
| import androidx.compose.foundation.text.TextAutoSize | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.MaterialTheme | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.text.style.TextOverflow | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.compose.ui.unit.sp | ||
| import com.gravatar.app.design.theme.GravatarAppTheme | ||
| import com.gravatar.app.homeUi.R | ||
|
|
||
| @Composable | ||
| internal fun ShareSectionTitle( | ||
| @DrawableRes leftIcon: Int?, | ||
| @StringRes title: Int, | ||
| @DrawableRes rightIcon: Int?, | ||
| modifier: Modifier = Modifier | ||
| ) { | ||
| Row( | ||
| verticalAlignment = Alignment.CenterVertically, | ||
| modifier = modifier.fillMaxWidth() | ||
| ) { | ||
| leftIcon?.let { | ||
| Icon( | ||
| painter = painterResource(id = it), | ||
| contentDescription = null, | ||
| tint = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f), | ||
| modifier = Modifier.padding(end = 6.dp) | ||
| ) | ||
| } | ||
| BasicText( | ||
| text = stringResource(title), | ||
| style = MaterialTheme.typography.bodySmall.copy( | ||
| color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f) | ||
| ), | ||
| overflow = TextOverflow.Ellipsis, | ||
| maxLines = 1, | ||
| autoSize = TextAutoSize.StepBased( | ||
| maxFontSize = 16.sp | ||
| ), | ||
| modifier = Modifier.weight(1f), | ||
| ) | ||
| rightIcon?.let { | ||
| Icon( | ||
| painter = painterResource(id = it), | ||
| contentDescription = null, | ||
| modifier = Modifier.padding(end = 12.dp), | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| private fun ShareSectionTitlePreview() { | ||
| GravatarAppTheme { | ||
| ShareSectionTitle( | ||
| leftIcon = R.drawable.share_section_title_warning, | ||
| title = R.string.share_tab_private_contact_info_title, | ||
| rightIcon = R.drawable.share_section_title_lock, | ||
| modifier = Modifier.fillMaxWidth() | ||
| ) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="24" | ||
| android:viewportHeight="24"> | ||
| <group> | ||
| <clip-path | ||
| android:pathData="M0,0h24v24h-24z"/> | ||
| <path | ||
| android:pathData="M17,10H15.8V7C15.8,4.9 14.1,3.2 12,3.2C9.9,3.2 8.2,4.9 8.2,7V10H7C6.4,10 6,10.4 6,11V19C6,19.6 6.4,20 7,20H17C17.6,20 18,19.6 18,19V11C18,10.4 17.6,10 17,10ZM14.2,10H9.8V7C9.8,5.8 10.8,4.8 12,4.8C13.2,4.8 14.2,5.8 14.2,7V10Z" | ||
| android:fillColor="#000000"/> | ||
| </group> | ||
| </vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="960" | ||
| android:viewportHeight="960"> | ||
| <path | ||
| android:pathData="M480,680q17,0 28.5,-11.5T520,640q0,-17 -11.5,-28.5T480,600q-17,0 -28.5,11.5T440,640q0,17 11.5,28.5T480,680ZM440,520h80v-240h-80v240ZM480,880q-83,0 -156,-31.5T197,763q-54,-54 -85.5,-127T80,480q0,-83 31.5,-156T197,197q54,-54 127,-85.5T480,80q83,0 156,31.5T763,197q54,54 85.5,127T880,480q0,83 -31.5,156T763,763q-54,54 -127,85.5T480,880ZM480,800q134,0 227,-93t93,-227q0,-134 -93,-227t-227,-93q-134,0 -227,93t-93,227q0,134 93,227t227,93ZM480,480Z" | ||
| android:fillColor="#e8eaed"/> | ||
| </vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.