-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update dependency androidx.compose.ui:ui to v2024.09.00
Updated Compose BOM to version 2024 .09.00 and removed deprecated `outlinedTextFieldColors` usages. Added some IDE files.
- Loading branch information
Showing
41 changed files
with
541 additions
and
262 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
138 changes: 138 additions & 0 deletions
138
common/systemDesign/src/main/java/city/zouitel/systemDesign/CommonTextField.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,138 @@ | ||
package city.zouitel.systemDesign | ||
|
||
import android.net.Uri | ||
import androidx.compose.foundation.ExperimentalFoundationApi | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.content.MediaType | ||
import androidx.compose.foundation.content.contentReceiver | ||
import androidx.compose.foundation.content.hasMediaType | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.text.BasicTextField | ||
import androidx.compose.foundation.text.KeyboardActions | ||
import androidx.compose.foundation.text.KeyboardOptions | ||
import androidx.compose.foundation.text.input.KeyboardActionHandler | ||
import androidx.compose.foundation.text.input.TextFieldState | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.FontFamily | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.input.ImeAction | ||
import androidx.compose.ui.text.input.KeyboardCapitalization | ||
import androidx.compose.ui.text.input.KeyboardType | ||
import androidx.compose.ui.unit.TextUnit | ||
import androidx.compose.ui.unit.TextUnitType | ||
import androidx.compose.ui.unit.dp | ||
|
||
@OptIn(ExperimentalFoundationApi::class) | ||
@Composable | ||
fun CommonTextField( | ||
state: TextFieldState, | ||
receiver: (Uri) -> Unit, | ||
modifier: Modifier, | ||
placeholder: String = "...", | ||
textSize: TextUnit = TextUnit(19f, TextUnitType.Sp), | ||
textColor: Color = Color.LightGray, | ||
imeAction: ImeAction = ImeAction.Default, | ||
keyboardAction: KeyboardActionHandler = KeyboardActionHandler { } | ||
) { | ||
Box( | ||
modifier = Modifier.padding(7.dp) | ||
) { | ||
Text( | ||
modifier = Modifier.padding(10.dp), | ||
text = if (state.text.isEmpty()) placeholder else "", | ||
color = Color.Gray, | ||
fontSize = textSize, | ||
) | ||
|
||
BasicTextField( | ||
state = state, | ||
modifier = modifier | ||
.padding(10.dp) | ||
.background(Color.Transparent) | ||
.contentReceiver { content -> | ||
if(content.hasMediaType(MediaType.Image)) { | ||
val data = content.clipEntry.clipData | ||
for (index in 0 until data.itemCount) { | ||
val item = data.getItemAt(index) | ||
receiver.invoke(item.uri) | ||
} | ||
} | ||
content | ||
}, | ||
textStyle = TextStyle( | ||
fontSize = textSize, | ||
fontWeight = FontWeight.Normal, | ||
fontFamily = FontFamily.Default, | ||
color = textColor | ||
), | ||
keyboardOptions = KeyboardOptions( | ||
capitalization = KeyboardCapitalization.Sentences, | ||
autoCorrectEnabled = false, | ||
keyboardType = KeyboardType.Text, | ||
imeAction = imeAction | ||
), | ||
onKeyboardAction = keyboardAction | ||
) | ||
} | ||
} | ||
|
||
@OptIn(ExperimentalFoundationApi::class) | ||
@Composable | ||
fun CommonTextField( | ||
value: String = "", | ||
onValueChange: (String) -> Unit = {}, | ||
receiver: (Uri) -> Unit, | ||
modifier: Modifier, | ||
placeholder: String = "...", | ||
textSize: TextUnit = TextUnit(19f, TextUnitType.Sp), | ||
textColor: Color = Color.LightGray, | ||
imeAction: ImeAction = ImeAction.Default, | ||
keyboardActions: KeyboardActions = KeyboardActions { } | ||
) { | ||
Box( | ||
modifier = Modifier.padding(7.dp) | ||
) { | ||
Text( | ||
modifier = Modifier.padding(10.dp), | ||
text = if (value.isEmpty()) placeholder else "", | ||
color = Color.Gray, | ||
fontSize = textSize, | ||
) | ||
|
||
BasicTextField( | ||
value = value, | ||
onValueChange = onValueChange, | ||
modifier = modifier | ||
.padding(10.dp) | ||
.background(Color.Transparent) | ||
.contentReceiver { content -> | ||
if(content.hasMediaType(MediaType.Image)) { | ||
val data = content.clipEntry.clipData | ||
for (index in 0 until data.itemCount) { | ||
val item = data.getItemAt(index) | ||
receiver.invoke(item.uri) | ||
} | ||
} | ||
content | ||
}, | ||
textStyle = TextStyle( | ||
fontSize = textSize, | ||
fontWeight = FontWeight.Normal, | ||
fontFamily = FontFamily.Default, | ||
color = textColor | ||
), | ||
keyboardOptions = KeyboardOptions( | ||
capitalization = KeyboardCapitalization.Sentences, | ||
autoCorrectEnabled = false, | ||
keyboardType = KeyboardType.Text, | ||
imeAction = imeAction | ||
), | ||
keyboardActions = keyboardActions | ||
) | ||
} | ||
} |
Oops, something went wrong.