-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve input fields design on new post page
- Loading branch information
1 parent
7900ce0
commit da8de8d
Showing
8 changed files
with
230 additions
and
129 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
75 changes: 75 additions & 0 deletions
75
app/src/commonMain/kotlin/com/daniebeler/pfpixelix/ui/composables/newpost/NewPostPref.kt
This file contains 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,75 @@ | ||
package com.daniebeler.pfpixelix.ui.composables.newpost | ||
|
||
import androidx.compose.animation.animateContentSize | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.ColumnScope | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.defaultMinSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Card | ||
import androidx.compose.material3.CardDefaults | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.surfaceColorAtElevation | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.Shape | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.dp | ||
import org.jetbrains.compose.resources.DrawableResource | ||
import org.jetbrains.compose.resources.vectorResource | ||
|
||
@Composable | ||
fun NewPostPref( | ||
leadingIcon: DrawableResource, | ||
title: String, | ||
trailingContent: (@Composable () -> Unit)? = null, | ||
shape: Shape = MaterialTheme.shapes.medium, | ||
textColor: Color? = null, | ||
content: @Composable ColumnScope.() -> Unit = {} | ||
) { | ||
val cardColors = CardDefaults.cardColors( | ||
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(4.dp) | ||
) | ||
Card( | ||
shape = shape, | ||
colors = cardColors, | ||
modifier = Modifier.animateContentSize(), | ||
) { | ||
Card( | ||
shape = shape, | ||
colors = cardColors, | ||
modifier = Modifier.padding(horizontal = 12.dp) | ||
) { | ||
Row( | ||
verticalAlignment = Alignment.CenterVertically, | ||
modifier = Modifier.defaultMinSize(minHeight = 54.dp) | ||
) { | ||
if (leadingIcon != null) { | ||
Icon(vectorResource(leadingIcon), contentDescription = null) | ||
} | ||
Column( | ||
modifier = Modifier | ||
.weight(1f) | ||
.padding(horizontal = 10.dp, vertical = 10.dp), | ||
) { | ||
Text( | ||
text = title, | ||
style = MaterialTheme.typography.titleSmall, | ||
fontWeight = FontWeight.Medium, | ||
color = textColor ?: Color.Unspecified | ||
) | ||
} | ||
if (trailingContent != null) { | ||
trailingContent() | ||
} | ||
} | ||
} | ||
|
||
content() | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...src/commonMain/kotlin/com/daniebeler/pfpixelix/ui/composables/newpost/NewPostTextField.kt
This file contains 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,37 @@ | ||
package com.daniebeler.pfpixelix.ui.composables.newpost | ||
|
||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TextField | ||
import androidx.compose.material3.TextFieldDefaults | ||
import androidx.compose.material3.surfaceColorAtElevation | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.unit.dp | ||
import org.jetbrains.compose.resources.stringResource | ||
import pixelix.app.generated.resources.Res | ||
import pixelix.app.generated.resources.content_warning_or_spoiler_text | ||
|
||
@Composable | ||
fun NewPostTextField( | ||
value: String, | ||
onChange: (value: String) -> Unit, | ||
label: String | ||
) { | ||
TextField( | ||
value = value, | ||
onValueChange = onChange, | ||
modifier = Modifier.fillMaxWidth(), | ||
label = { Text(label) }, | ||
shape = MaterialTheme.shapes.medium, | ||
colors = TextFieldDefaults.colors( | ||
unfocusedIndicatorColor = Color.Transparent, | ||
focusedIndicatorColor = Color.Transparent, | ||
focusedContainerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(4.dp), | ||
unfocusedContainerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(4.dp) | ||
) | ||
) | ||
} |
Oops, something went wrong.