-
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.
* added people field * added people field
- Loading branch information
1 parent
2a29534
commit 8dd9462
Showing
8 changed files
with
213 additions
and
4 deletions.
There are no files selected for viewing
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
85 changes: 85 additions & 0 deletions
85
process-app/src/main/kotlin/com/alfresco/content/process/ui/components/InputChip.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,85 @@ | ||
package com.alfresco.content.process.ui.components | ||
|
||
import android.content.Context | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.InputChip | ||
import androidx.compose.material3.InputChipDefaults | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.drawBehind | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import com.alfresco.content.data.UserGroupDetails | ||
import com.alfresco.content.getLocalizedName | ||
import com.alfresco.content.process.ui.theme.SeparateColorGrayDT | ||
import com.alfresco.content.process.ui.theme.SeparateColorGrayLT | ||
import com.alfresco.content.process.ui.theme.chipBackgroundColorGrayDT | ||
import com.alfresco.content.process.ui.theme.chipBackgroundColorGrayLT | ||
import com.alfresco.content.process.ui.theme.chipColorGrayDT | ||
import com.alfresco.content.process.ui.theme.chipColorGrayLT | ||
import com.alfresco.content.process.ui.theme.isNightMode | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun InputChip( | ||
context: Context, | ||
userDetail: UserGroupDetails, | ||
) { | ||
val isNightMode = isNightMode() | ||
InputChip( | ||
modifier = Modifier.padding(vertical = 8.dp), | ||
onClick = { | ||
}, | ||
label = { Text(context.getLocalizedName(userDetail.name)) }, | ||
selected = true, | ||
shape = RoundedCornerShape(24.dp), | ||
border = InputChipDefaults.inputChipBorder( | ||
selectedBorderWidth = 0.dp, | ||
|
||
), | ||
colors = getInputChipColors(), | ||
leadingIcon = { | ||
Text( | ||
color = if (isNightMode) SeparateColorGrayDT else SeparateColorGrayLT, | ||
modifier = Modifier | ||
.padding(16.dp) | ||
.drawBehind { | ||
drawCircle( | ||
color = if (isNightMode) chipColorGrayDT else chipColorGrayLT, | ||
radius = this.size.maxDimension, | ||
) | ||
}, | ||
text = context.getLocalizedName(userDetail.nameInitial), | ||
fontSize = 12.sp, | ||
) | ||
}, | ||
) | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun InputChipPreview() { | ||
InputChip(LocalContext.current, UserGroupDetails()) | ||
} | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun getInputChipColors() = if (isNightMode()) { | ||
InputChipDefaults.inputChipColors( | ||
labelColor = SeparateColorGrayDT, | ||
selectedLabelColor = SeparateColorGrayDT, | ||
selectedLeadingIconColor = SeparateColorGrayDT, | ||
selectedContainerColor = chipBackgroundColorGrayDT, | ||
) | ||
} else | ||
InputChipDefaults.inputChipColors( | ||
labelColor = SeparateColorGrayLT, | ||
selectedLabelColor = SeparateColorGrayLT, | ||
selectedLeadingIconColor = SeparateColorGrayLT, | ||
selectedContainerColor = chipBackgroundColorGrayLT, | ||
) |
86 changes: 86 additions & 0 deletions
86
process-app/src/main/kotlin/com/alfresco/content/process/ui/components/PeopleField.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,86 @@ | ||
package com.alfresco.content.process.ui.components | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.text.SpanStyle | ||
import androidx.compose.ui.text.buildAnnotatedString | ||
import androidx.compose.ui.text.withStyle | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.alfresco.content.component.searchusergroup.SearchUserGroupComponentBuilder | ||
import com.alfresco.content.data.ProcessEntry | ||
import com.alfresco.content.data.UserGroupDetails | ||
import com.alfresco.content.data.payloads.FieldsData | ||
import com.alfresco.content.process.R | ||
import com.alfresco.content.process.ui.theme.AlfrescoError | ||
|
||
@Composable | ||
fun PeopleField( | ||
userDetail: UserGroupDetails? = null, | ||
onAssigneeSelected: (UserGroupDetails?) -> Unit = { }, | ||
fieldsData: FieldsData = FieldsData(), | ||
processEntry: ProcessEntry = ProcessEntry(), | ||
) { | ||
val labelWithAsterisk = buildAnnotatedString { | ||
append(fieldsData.name) | ||
if (fieldsData.required) { | ||
withStyle(style = SpanStyle(color = AlfrescoError)) { | ||
append(" *") // Adding a red asterisk for mandatory fields | ||
} | ||
} | ||
} | ||
|
||
val context = LocalContext.current | ||
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding(all = 16.dp), | ||
) { | ||
Row( | ||
horizontalArrangement = Arrangement.SpaceBetween, | ||
modifier = Modifier.fillMaxWidth(), | ||
) { | ||
Text( | ||
text = labelWithAsterisk, | ||
modifier = Modifier | ||
.padding(end = 4.dp), | ||
) | ||
|
||
IconButton(onClick = { | ||
SearchUserGroupComponentBuilder(context, processEntry) | ||
.onApply { userDetails -> | ||
onAssigneeSelected(userDetails) | ||
} | ||
.onCancel { | ||
onAssigneeSelected(null) | ||
} | ||
.show() | ||
}) { | ||
Icon( | ||
painterResource(R.drawable.ic_add), | ||
contentDescription = "", | ||
) | ||
} | ||
} | ||
if (userDetail != null) { | ||
InputChip(context, userDetail) | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun PeopleFieldPreview() { | ||
PeopleField() | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24" | ||
android:tint="#7F7F7F"> | ||
<path | ||
android:fillColor="#FF000000" | ||
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/> | ||
</vector> |