mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-22 18:02:05 +02:00
Adds author picture when writing posts and replies.
This commit is contained in:
@@ -52,7 +52,6 @@ import androidx.compose.foundation.layout.width
|
|||||||
import androidx.compose.foundation.layout.windowInsetsPadding
|
import androidx.compose.foundation.layout.windowInsetsPadding
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.selection.toggleable
|
import androidx.compose.foundation.selection.toggleable
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
@@ -81,6 +80,7 @@ import androidx.compose.material3.Slider
|
|||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Switch
|
import androidx.compose.material3.Switch
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TextFieldDefaults
|
||||||
import androidx.compose.material3.TopAppBar
|
import androidx.compose.material3.TopAppBar
|
||||||
import androidx.compose.material3.TopAppBarDefaults
|
import androidx.compose.material3.TopAppBarDefaults
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@@ -158,6 +158,7 @@ import com.vitorpamplona.amethyst.ui.theme.Font14SP
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.QuoteBorder
|
import com.vitorpamplona.amethyst.ui.theme.QuoteBorder
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size10dp
|
import com.vitorpamplona.amethyst.ui.theme.Size10dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size18Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size18Modifier
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.Size35dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size55dp
|
import com.vitorpamplona.amethyst.ui.theme.Size55dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size5dp
|
import com.vitorpamplona.amethyst.ui.theme.Size5dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
|
import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
|
||||||
@@ -390,7 +391,16 @@ fun NewPostView(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageField(postViewModel)
|
Row(
|
||||||
|
modifier = Modifier.padding(vertical = Size10dp),
|
||||||
|
) {
|
||||||
|
BaseUserPicture(
|
||||||
|
accountViewModel.userProfile(),
|
||||||
|
Size35dp,
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
)
|
||||||
|
MessageField(postViewModel)
|
||||||
|
}
|
||||||
|
|
||||||
if (postViewModel.wantsPoll) {
|
if (postViewModel.wantsPoll) {
|
||||||
Row(
|
Row(
|
||||||
@@ -661,7 +671,7 @@ private fun MessageField(postViewModel: NewPostViewModel) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OutlinedTextField(
|
MyTextField(
|
||||||
value = postViewModel.message,
|
value = postViewModel.message,
|
||||||
onValueChange = { postViewModel.updateMessage(it) },
|
onValueChange = { postViewModel.updateMessage(it) },
|
||||||
keyboardOptions =
|
keyboardOptions =
|
||||||
@@ -671,11 +681,7 @@ private fun MessageField(postViewModel: NewPostViewModel) {
|
|||||||
modifier =
|
modifier =
|
||||||
Modifier
|
Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.border(
|
.focusRequester(focusRequester)
|
||||||
width = 1.dp,
|
|
||||||
color = MaterialTheme.colorScheme.surface,
|
|
||||||
shape = RoundedCornerShape(8.dp),
|
|
||||||
).focusRequester(focusRequester)
|
|
||||||
.onFocusChanged {
|
.onFocusChanged {
|
||||||
if (it.isFocused) {
|
if (it.isFocused) {
|
||||||
keyboardController?.show()
|
keyboardController?.show()
|
||||||
@@ -699,6 +705,13 @@ private fun MessageField(postViewModel: NewPostViewModel) {
|
|||||||
),
|
),
|
||||||
visualTransformation = UrlUserTagTransformation(MaterialTheme.colorScheme.primary),
|
visualTransformation = UrlUserTagTransformation(MaterialTheme.colorScheme.primary),
|
||||||
textStyle = LocalTextStyle.current.copy(textDirection = TextDirection.Content),
|
textStyle = LocalTextStyle.current.copy(textDirection = TextDirection.Content),
|
||||||
|
contentPadding =
|
||||||
|
TextFieldDefaults.contentPaddingWithoutLabel(
|
||||||
|
start = 10.dp,
|
||||||
|
top = 5.dp,
|
||||||
|
end = 10.dp,
|
||||||
|
bottom = 5.dp,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,6 +28,7 @@ import androidx.compose.foundation.interaction.MutableInteractionSource
|
|||||||
import androidx.compose.foundation.interaction.collectIsFocusedAsState
|
import androidx.compose.foundation.interaction.collectIsFocusedAsState
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.defaultMinSize
|
import androidx.compose.foundation.layout.defaultMinSize
|
||||||
@@ -60,6 +61,8 @@ import androidx.compose.material3.MaterialTheme
|
|||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TextFieldColors
|
import androidx.compose.material3.TextFieldColors
|
||||||
import androidx.compose.material3.TextFieldDefaults
|
import androidx.compose.material3.TextFieldDefaults
|
||||||
|
import androidx.compose.material3.TextFieldDefaults.contentPaddingWithLabel
|
||||||
|
import androidx.compose.material3.TextFieldDefaults.contentPaddingWithoutLabel
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.runtime.DisposableEffect
|
import androidx.compose.runtime.DisposableEffect
|
||||||
@@ -516,6 +519,22 @@ fun MyTextField(
|
|||||||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
||||||
shape: Shape = TextFieldDefaults.shape,
|
shape: Shape = TextFieldDefaults.shape,
|
||||||
colors: TextFieldColors = TextFieldDefaults.colors(),
|
colors: TextFieldColors = TextFieldDefaults.colors(),
|
||||||
|
contentPadding: PaddingValues =
|
||||||
|
if (label == null) {
|
||||||
|
TextFieldDefaults.contentPaddingWithoutLabel(
|
||||||
|
start = 10.dp,
|
||||||
|
top = 12.dp,
|
||||||
|
end = 10.dp,
|
||||||
|
bottom = 12.dp,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
TextFieldDefaults.contentPaddingWithLabel(
|
||||||
|
start = 10.dp,
|
||||||
|
top = 12.dp,
|
||||||
|
end = 10.dp,
|
||||||
|
bottom = 12.dp,
|
||||||
|
)
|
||||||
|
},
|
||||||
) {
|
) {
|
||||||
// COPIED FROM TEXT FIELD
|
// COPIED FROM TEXT FIELD
|
||||||
// The only change is the contentPadding below
|
// The only change is the contentPadding below
|
||||||
@@ -575,13 +594,7 @@ fun MyTextField(
|
|||||||
isError = isError,
|
isError = isError,
|
||||||
interactionSource = interactionSource,
|
interactionSource = interactionSource,
|
||||||
colors = colors,
|
colors = colors,
|
||||||
contentPadding =
|
contentPadding = contentPadding,
|
||||||
TextFieldDefaults.contentPaddingWithoutLabel(
|
|
||||||
start = 10.dp,
|
|
||||||
top = 12.dp,
|
|
||||||
end = 10.dp,
|
|
||||||
bottom = 12.dp,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user