Skip to content

Commit

Permalink
Finer touch: Trailing icon near bottom end of text field, not center end
Browse files Browse the repository at this point in the history
  • Loading branch information
nain-F49FF806 committed Oct 29, 2024
1 parent e10be28 commit 0c0325e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
applicationId = "alt.nainapps.sharepaste"
minSdk = 26
targetSdk = 35
versionCode = 1730211000
versionCode = 1730223000
versionName = "2024.10.29"
setProperty("archivesBaseName", "sharepaste.oo")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import alt.nainapps.sharepaste.common.units.TextModeToggleIconButton
import alt.nainapps.sharepaste.common.units.pasteFormatToggle
import alt.nainapps.sharepaste.rsnative.PrivateBinRs
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
Expand All @@ -23,15 +24,19 @@ import androidx.compose.material3.Button
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.OutlinedTextFieldDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -59,6 +64,7 @@ fun EncryptAndShareUI(
var openDiscussion by rememberSaveable { mutableStateOf(false) }
var errorString by rememberSaveable { mutableStateOf("") }
val coroutineScope = rememberCoroutineScope()
var textFieldHeight: Int? by remember { mutableStateOf(null) }

Column(
modifier =
Expand All @@ -69,6 +75,7 @@ fun EncryptAndShareUI(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
val density = LocalDensity.current
OutlinedTextField(
value = textToEncrypt,
onValueChange = { textToEncrypt = it },
Expand All @@ -79,15 +86,30 @@ fun EncryptAndShareUI(
PasteFormat.SYNTAX -> Text("Code to encrypt and share")
}
},
trailingIcon = {
TextModeToggleIconButton(
mode = pasteFormat,
onCLick = { pasteFormat = pasteFormatToggle(pasteFormat) }
)
},
modifier = Modifier.fillMaxWidth(),
singleLine = false,
minLines = 3
minLines = 3,

modifier = Modifier
.fillMaxWidth()
.onSizeChanged { textFieldHeight = it.height },
trailingIcon = {
Box(
contentAlignment = Alignment.BottomEnd,
modifier = textFieldHeight?.let {
Modifier
.height(with(density) {
it.toDp() - OutlinedTextFieldDefaults
.contentPadding()
.calculateBottomPadding()
})
} ?: Modifier
) {
TextModeToggleIconButton(
mode = pasteFormat,
onCLick = { pasteFormat = pasteFormatToggle(pasteFormat) }
)
}
}
)

Spacer(modifier = Modifier.height(16.dp))
Expand Down

0 comments on commit 0c0325e

Please sign in to comment.