Skip to content

Commit

Permalink
fix: overlapping text when editing contact multiline (closes #439)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bnyro committed Feb 6, 2025
1 parent ced4110 commit 6f26bd1
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.remember
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.graphics.Color
Expand All @@ -38,7 +37,6 @@ import androidx.compose.ui.text.input.KeyboardType
* @param shape The shape of the text field.
* @param onValueChange The function to call when the value of the text field changes.
*/
@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun LabeledTextField(
modifier: Modifier = Modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ import com.bnyro.contacts.util.ContactsHelper
import com.bnyro.contacts.util.ImageHelper
import com.bnyro.contacts.util.Preferences

val borderRadius = 20.dp

@OptIn(ExperimentalFoundationApi::class, ExperimentalMaterial3Api::class)
@Composable
fun ContactEditor(
Expand Down Expand Up @@ -308,7 +310,8 @@ fun ContactEditor(
imageVector = Icons.Outlined.Person2,
contentDescription = null
)
}
},
shape = RoundedCornerShape(borderRadius)
)

LabeledTextField(
Expand All @@ -319,7 +322,8 @@ fun ContactEditor(
imageVector = Icons.Outlined.Person2,
contentDescription = null
)
}
},
shape = RoundedCornerShape(borderRadius)
)

AnimatedVisibility(showAdvanced) {
Expand All @@ -332,7 +336,8 @@ fun ContactEditor(
imageVector = Icons.Outlined.Person2,
contentDescription = null
)
}
},
shape = RoundedCornerShape(borderRadius)
)
LabeledTextField(
label = R.string.organization,
Expand All @@ -342,7 +347,8 @@ fun ContactEditor(
imageVector = Icons.Outlined.Cases,
contentDescription = null
)
}
},
shape = RoundedCornerShape(borderRadius)
)
LabeledTextField(
label = R.string.title,
Expand All @@ -352,15 +358,17 @@ fun ContactEditor(
imageVector = Icons.Outlined.Cases,
contentDescription = null
)
}
},
shape = RoundedCornerShape(borderRadius)
)
TextFieldGroup(
items = websites,
label = R.string.website,
types = ContactsHelper.websiteTypes,
addActionText = R.string.add_website,
keyboardType = KeyboardType.Uri,
leadingIcon = Icons.Outlined.Web
leadingIcon = Icons.Outlined.Web,
borderRadius = borderRadius
)
}
}
Expand All @@ -387,36 +395,41 @@ fun ContactEditor(
addActionText = R.string.add_phone_number,
keyboardType = KeyboardType.Phone,
leadingIcon = Icons.Outlined.Phone,
types = ContactsHelper.phoneNumberTypes
types = ContactsHelper.phoneNumberTypes,
borderRadius = borderRadius
)
TextFieldGroup(
items = emails,
label = R.string.email,
addActionText = R.string.add_e_mail,
keyboardType = KeyboardType.Email,
leadingIcon = Icons.Outlined.Email,
types = ContactsHelper.emailTypes
types = ContactsHelper.emailTypes,
borderRadius = borderRadius
)
TextFieldGroup(
items = addresses,
label = R.string.address,
addActionText = R.string.add_address,
leadingIcon = Icons.Outlined.LocationOn,
types = ContactsHelper.addressTypes
types = ContactsHelper.addressTypes,
borderRadius = borderRadius
)

EventFieldGroup(
items = events,
label = R.string.event,
types = ContactsHelper.eventTypes,
addActionText = R.string.add_event
addActionText = R.string.add_event,
borderRadius = borderRadius
)

TextFieldGroup(
items = notes,
label = R.string.note,
addActionText = R.string.add_note,
leadingIcon = Icons.Outlined.Note
leadingIcon = Icons.Outlined.Note,
borderRadius = borderRadius
)

Column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.snapshots.SnapshotStateList
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.bnyro.contacts.domain.model.TranslatedType
import com.bnyro.contacts.domain.model.ValueWithType
Expand All @@ -36,8 +38,9 @@ fun EventFieldGroup(
@StringRes label: Int,
@StringRes addActionText: Int,
types: List<TranslatedType> = listOf(),
borderRadius: Dp
) {
Column() {
Column {
with(items) {
forEachIndexed { index, it ->
DatePickerEditor(
Expand All @@ -48,7 +51,7 @@ fun EventFieldGroup(
removeAt(index)
},
showDeleteAction = size > 1,
shape = if (index == 0) RoundedCornerShape(50, 50, 0, 0) else RectangleShape
shape = if (index == 0) RoundedCornerShape(borderRadius, borderRadius, 0.dp, 0.dp) else RectangleShape
)
}
FilledTonalButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,4 @@ fun TextFieldEditor(
) {
state.value.value = it
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.bnyro.contacts.domain.model.TranslatedType
import com.bnyro.contacts.domain.model.ValueWithType
Expand All @@ -43,8 +44,9 @@ fun TextFieldGroup(
types: List<TranslatedType> = listOf(),
leadingIcon: ImageVector,
keyboardType: KeyboardType = KeyboardType.Text,
borderRadius: Dp
) {
Column() {
Column {
with(items) {
forEachIndexed { index, it ->
TextFieldEditor(
Expand All @@ -65,7 +67,7 @@ fun TextFieldGroup(
)
}
},
shape = if (index == 0) RoundedCornerShape(50, 50, 0, 0) else RectangleShape
shape = if (index == 0) RoundedCornerShape(borderRadius, borderRadius, 0.dp, 0.dp) else RectangleShape
)
}
FilledTonalButton(
Expand Down

0 comments on commit 6f26bd1

Please sign in to comment.