-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8931ade
commit 7f8540f
Showing
5 changed files
with
65 additions
and
54 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...ss-app/src/main/kotlin/com/alfresco/content/process/ui/components/FloatingActionButton.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,25 @@ | ||
package com.alfresco.content.process.ui.components | ||
|
||
import androidx.compose.foundation.layout.navigationBarsPadding | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.PlaylistAdd | ||
import androidx.compose.material3.ExtendedFloatingActionButton | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
|
||
@Composable | ||
fun FloatingActionButton() { | ||
ExtendedFloatingActionButton( | ||
onClick = { | ||
|
||
}, | ||
containerColor = MaterialTheme.colorScheme.primary, | ||
icon = { Icon(Icons.Filled.PlaylistAdd, "Extended floating action button.") }, | ||
text = { Text(text = "Actions") }, | ||
modifier = Modifier.navigationBarsPadding() | ||
) | ||
|
||
} |
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
87 changes: 33 additions & 54 deletions
87
process-app/src/main/kotlin/com/alfresco/content/process/ui/components/HyperLinkField.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 |
---|---|---|
@@ -1,73 +1,52 @@ | ||
package com.alfresco.content.process.ui.components | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.text.ClickableText | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.text.KeyboardOptions | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Link | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalUriHandler | ||
import androidx.compose.ui.text.ExperimentalTextApi | ||
import androidx.compose.ui.text.SpanStyle | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.UrlAnnotation | ||
import androidx.compose.ui.text.buildAnnotatedString | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.input.ImeAction | ||
import androidx.compose.ui.text.input.KeyboardType | ||
import com.alfresco.content.data.payloads.FieldsData | ||
import com.alfresco.content.process.R | ||
|
||
@OptIn(ExperimentalTextApi::class) | ||
@Composable | ||
fun HyperLinkField( | ||
fieldsData: FieldsData = FieldsData(), | ||
) { | ||
val uriHandler = LocalUriHandler.current | ||
|
||
val hyperlinkData = buildAnnotatedString { | ||
append(fieldsData.displayText) | ||
addStyle( | ||
style = SpanStyle( | ||
fontSize = 16.sp, | ||
color = MaterialTheme.colorScheme.primary, | ||
), | ||
start = 0, | ||
end = fieldsData.displayText?.length ?: 0, | ||
) | ||
addUrlAnnotation( | ||
UrlAnnotation(fieldsData.hyperlinkUrl ?: ""), | ||
start = 0, | ||
end = fieldsData.displayText?.length ?: 0, | ||
val keyboardOptions = KeyboardOptions.Default.copy( | ||
imeAction = ImeAction.Next, | ||
keyboardType = KeyboardType.Text, | ||
) | ||
|
||
|
||
val leadingIcon: @Composable () -> Unit = { | ||
Icon( | ||
imageVector = Icons.Default.Link, | ||
contentDescription = stringResource(R.string.accessibility_link_icon), | ||
tint = trailingIconColor(), | ||
) | ||
} | ||
|
||
Column( | ||
|
||
InputFieldWithLeading( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(start = 16.dp, end = 16.dp, top = 16.dp, bottom = 0.dp), | ||
horizontalAlignment = Alignment.Start, | ||
) { | ||
Text( | ||
text = fieldsData.name, | ||
style = TextStyle( | ||
fontSize = 16.sp, | ||
color = MaterialTheme.colorScheme.onSurface, | ||
), | ||
) | ||
ClickableText( | ||
text = hyperlinkData, | ||
style = TextStyle( | ||
color = MaterialTheme.colorScheme.onSurface, | ||
), | ||
onClick = { | ||
hyperlinkData | ||
.getUrlAnnotations(it, it) | ||
.firstOrNull()?.let { annotation -> | ||
uriHandler.openUri(annotation.item.url) | ||
} | ||
.inputField() | ||
.clickable { | ||
uriHandler.openUri(fieldsData.hyperlinkUrl ?: "") | ||
}, | ||
) | ||
} | ||
maxLines = 1, | ||
textFieldValue = fieldsData.displayText, | ||
fieldsData = fieldsData, | ||
keyboardOptions = keyboardOptions, | ||
leadingIcon = leadingIcon, | ||
isEnabled = false, | ||
) | ||
|
||
} |
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