|
|
|
@@ -2,12 +2,15 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn
|
|
|
|
|
|
|
|
|
|
import android.widget.Toast
|
|
|
|
|
import androidx.compose.animation.animateContentSize
|
|
|
|
|
import androidx.compose.foundation.background
|
|
|
|
|
import androidx.compose.foundation.clickable
|
|
|
|
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
|
|
import androidx.compose.foundation.layout.PaddingValues
|
|
|
|
|
import androidx.compose.foundation.layout.Row
|
|
|
|
|
import androidx.compose.foundation.layout.Spacer
|
|
|
|
|
import androidx.compose.foundation.layout.defaultMinSize
|
|
|
|
|
import androidx.compose.foundation.layout.fillMaxHeight
|
|
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
|
|
import androidx.compose.foundation.layout.height
|
|
|
|
@@ -16,19 +19,23 @@ import androidx.compose.foundation.layout.size
|
|
|
|
|
import androidx.compose.foundation.layout.width
|
|
|
|
|
import androidx.compose.foundation.shape.CircleShape
|
|
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
|
|
import androidx.compose.foundation.text.BasicTextField
|
|
|
|
|
import androidx.compose.foundation.text.KeyboardActions
|
|
|
|
|
import androidx.compose.foundation.text.KeyboardOptions
|
|
|
|
|
import androidx.compose.material.Button
|
|
|
|
|
import androidx.compose.material.ButtonDefaults
|
|
|
|
|
import androidx.compose.material.Divider
|
|
|
|
|
import androidx.compose.material.DropdownMenu
|
|
|
|
|
import androidx.compose.material.DropdownMenuItem
|
|
|
|
|
import androidx.compose.material.ExperimentalMaterialApi
|
|
|
|
|
import androidx.compose.material.Icon
|
|
|
|
|
import androidx.compose.material.IconButton
|
|
|
|
|
import androidx.compose.material.LocalTextStyle
|
|
|
|
|
import androidx.compose.material.MaterialTheme
|
|
|
|
|
import androidx.compose.material.Text
|
|
|
|
|
import androidx.compose.material.TextField
|
|
|
|
|
import androidx.compose.material.TextFieldColors
|
|
|
|
|
import androidx.compose.material.TextFieldDefaults
|
|
|
|
|
import androidx.compose.material.TextFieldDefaults.indicatorLine
|
|
|
|
|
import androidx.compose.material.icons.Icons
|
|
|
|
|
import androidx.compose.material.icons.filled.Cancel
|
|
|
|
|
import androidx.compose.material.icons.filled.EditNote
|
|
|
|
@@ -47,14 +54,19 @@ import androidx.compose.ui.Alignment
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
import androidx.compose.ui.draw.clip
|
|
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
|
|
import androidx.compose.ui.graphics.Shape
|
|
|
|
|
import androidx.compose.ui.graphics.SolidColor
|
|
|
|
|
import androidx.compose.ui.graphics.takeOrElse
|
|
|
|
|
import androidx.compose.ui.platform.LocalClipboardManager
|
|
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
|
|
import androidx.compose.ui.platform.LocalLifecycleOwner
|
|
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
|
|
import androidx.compose.ui.text.AnnotatedString
|
|
|
|
|
import androidx.compose.ui.text.TextStyle
|
|
|
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
|
|
|
import androidx.compose.ui.text.input.KeyboardCapitalization
|
|
|
|
|
import androidx.compose.ui.text.input.TextFieldValue
|
|
|
|
|
import androidx.compose.ui.text.input.VisualTransformation
|
|
|
|
|
import androidx.compose.ui.text.style.TextDirection
|
|
|
|
|
import androidx.compose.ui.text.style.TextOverflow
|
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
@@ -322,7 +334,7 @@ fun EditFieldRow(
|
|
|
|
|
horizontalArrangement = Arrangement.SpaceBetween,
|
|
|
|
|
verticalAlignment = Alignment.CenterVertically
|
|
|
|
|
) {
|
|
|
|
|
TextField(
|
|
|
|
|
MyTextField(
|
|
|
|
|
value = channelScreenModel.message,
|
|
|
|
|
onValueChange = {
|
|
|
|
|
channelScreenModel.updateMessage(it)
|
|
|
|
@@ -345,14 +357,14 @@ fun EditFieldRow(
|
|
|
|
|
onSendNewMessage()
|
|
|
|
|
},
|
|
|
|
|
isActive = channelScreenModel.message.text.isNotBlank() && !channelScreenModel.isUploadingImage,
|
|
|
|
|
modifier = Modifier.padding(end = 10.dp)
|
|
|
|
|
modifier = Modifier.height(32.dp).padding(end = 10.dp)
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
leadingIcon = {
|
|
|
|
|
UploadFromGallery(
|
|
|
|
|
isUploading = channelScreenModel.isUploadingImage,
|
|
|
|
|
tint = MaterialTheme.colors.placeholderText,
|
|
|
|
|
modifier = Modifier.padding(start = 5.dp)
|
|
|
|
|
modifier = Modifier.height(32.dp).padding(start = 2.dp)
|
|
|
|
|
) {
|
|
|
|
|
val fileServer = if (isPrivate) {
|
|
|
|
|
// TODO: Make private servers
|
|
|
|
@@ -380,6 +392,85 @@ fun EditFieldRow(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun MyTextField(
|
|
|
|
|
value: TextFieldValue,
|
|
|
|
|
onValueChange: (TextFieldValue) -> Unit,
|
|
|
|
|
modifier: Modifier = Modifier,
|
|
|
|
|
enabled: Boolean = true,
|
|
|
|
|
readOnly: Boolean = false,
|
|
|
|
|
textStyle: TextStyle = LocalTextStyle.current,
|
|
|
|
|
label: @Composable (() -> Unit)? = null,
|
|
|
|
|
placeholder: @Composable (() -> Unit)? = null,
|
|
|
|
|
leadingIcon: @Composable (() -> Unit)? = null,
|
|
|
|
|
trailingIcon: @Composable (() -> Unit)? = null,
|
|
|
|
|
isError: Boolean = false,
|
|
|
|
|
visualTransformation: VisualTransformation = VisualTransformation.None,
|
|
|
|
|
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
|
|
|
|
|
keyboardActions: KeyboardActions = KeyboardActions(),
|
|
|
|
|
singleLine: Boolean = false,
|
|
|
|
|
maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE,
|
|
|
|
|
minLines: Int = 1,
|
|
|
|
|
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
|
|
|
|
shape: Shape = TextFieldDefaults.TextFieldShape,
|
|
|
|
|
colors: TextFieldColors = TextFieldDefaults.textFieldColors()
|
|
|
|
|
) {
|
|
|
|
|
// If color is not provided via the text style, use content color as a default
|
|
|
|
|
val textColor = textStyle.color.takeOrElse {
|
|
|
|
|
colors.textColor(enabled).value
|
|
|
|
|
}
|
|
|
|
|
val mergedTextStyle = textStyle.merge(TextStyle(color = textColor))
|
|
|
|
|
|
|
|
|
|
@OptIn(ExperimentalMaterialApi::class)
|
|
|
|
|
(
|
|
|
|
|
BasicTextField(
|
|
|
|
|
value = value,
|
|
|
|
|
modifier = modifier
|
|
|
|
|
.background(colors.backgroundColor(enabled).value, shape)
|
|
|
|
|
.indicatorLine(enabled, isError, interactionSource, colors)
|
|
|
|
|
.defaultMinSize(
|
|
|
|
|
minWidth = TextFieldDefaults.MinWidth,
|
|
|
|
|
minHeight = 36.dp
|
|
|
|
|
),
|
|
|
|
|
onValueChange = onValueChange,
|
|
|
|
|
enabled = enabled,
|
|
|
|
|
readOnly = readOnly,
|
|
|
|
|
textStyle = mergedTextStyle,
|
|
|
|
|
cursorBrush = SolidColor(colors.cursorColor(isError).value),
|
|
|
|
|
visualTransformation = visualTransformation,
|
|
|
|
|
keyboardOptions = keyboardOptions,
|
|
|
|
|
keyboardActions = keyboardActions,
|
|
|
|
|
interactionSource = interactionSource,
|
|
|
|
|
singleLine = singleLine,
|
|
|
|
|
maxLines = maxLines,
|
|
|
|
|
minLines = minLines,
|
|
|
|
|
decorationBox = @Composable { innerTextField ->
|
|
|
|
|
// places leading icon, text field with label and placeholder, trailing icon
|
|
|
|
|
TextFieldDefaults.TextFieldDecorationBox(
|
|
|
|
|
value = value.text,
|
|
|
|
|
visualTransformation = visualTransformation,
|
|
|
|
|
innerTextField = innerTextField,
|
|
|
|
|
placeholder = placeholder,
|
|
|
|
|
label = label,
|
|
|
|
|
leadingIcon = leadingIcon,
|
|
|
|
|
trailingIcon = trailingIcon,
|
|
|
|
|
singleLine = singleLine,
|
|
|
|
|
enabled = enabled,
|
|
|
|
|
isError = isError,
|
|
|
|
|
interactionSource = interactionSource,
|
|
|
|
|
colors = colors,
|
|
|
|
|
contentPadding = TextFieldDefaults.textFieldWithoutLabelPadding(
|
|
|
|
|
top = 12.dp,
|
|
|
|
|
bottom = 12.dp,
|
|
|
|
|
start = 10.dp,
|
|
|
|
|
end = 10.dp
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun ChannelHeader(channelHex: String, accountViewModel: AccountViewModel, nav: (String) -> Unit) {
|
|
|
|
|
var baseChannel by remember { mutableStateOf<Channel?>(null) }
|
|
|
|
|