Skip to content

Commit

Permalink
add clear icons to reset fodler
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-alfresco committed May 8, 2024
1 parent 5f2fedb commit 24526ab
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ 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.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Attachment
import androidx.compose.material.icons.filled.Clear
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
Expand Down Expand Up @@ -37,6 +39,7 @@ import com.alfresco.content.process.ui.theme.AlfrescoError
fun AttachFolderField(
fieldsData: FieldsData = FieldsData(),
onUserTap: (Boolean) -> Unit = { },
onResetFolder: (Boolean) -> Unit = { },
navController: NavController,
errorData: Pair<Boolean, String> = Pair(false, ""),
) {
Expand All @@ -51,12 +54,6 @@ fun AttachFolderField(

val contentValue = (fieldsData.value as? Entry)?.name ?: stringResource(id = R.string.no_attached_folder)

/*val contentValue = if (fieldsData.value == null) {
stringResource(id = R.string.no_attached_folder)
} else {
stringResource(id = R.string.text_attached_folder, 1)
}*/

val context = LocalContext.current
Column(
modifier = Modifier
Expand Down Expand Up @@ -89,16 +86,40 @@ fun AttachFolderField(
)
}
}
Text(
text = contentValue,
style = TextStyle(
color = MaterialTheme.colorScheme.onPrimary,
fontSize = 12.sp,
),

Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
.padding(start = 4.dp, top = 0.dp)
.align(alignment = Alignment.Start),
)
.fillMaxWidth()
.padding(start = 4.dp, end = 12.dp, top = 0.dp),
) {
Text(
modifier = Modifier
.padding(top = 0.dp)
.align(alignment = Alignment.CenterVertically),
text = contentValue,
style = TextStyle(
color = MaterialTheme.colorScheme.onPrimary,
fontSize = 12.sp,
),
)
if (fieldsData.value != null) {
IconButton(
onClick = {
onResetFolder(true)
},
modifier = Modifier
.size(20.dp)
.padding(top = 0.dp),
) {
Icon(
imageVector = Icons.Default.Clear,
tint = AlfrescoBlue300,
contentDescription = "",
)
}
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.alfresco.content.process.ui.utils.amountInputError
import com.alfresco.content.process.ui.utils.booleanInputError
import com.alfresco.content.process.ui.utils.dateTimeInputError
import com.alfresco.content.process.ui.utils.dropDownRadioInputError
import com.alfresco.content.process.ui.utils.folderInputError
import com.alfresco.content.process.ui.utils.integerInputError
import com.alfresco.content.process.ui.utils.multiLineInputError
import com.alfresco.content.process.ui.utils.singleLineInputError
Expand Down Expand Up @@ -250,6 +251,12 @@ fun FormScrollContent(field: FieldsData, viewModel: FormViewModel, state: FormVi
viewModel.selectedField = field
}
},
onResetFolder = {
if (it) {
val errorData = folderInputError(null, field, context)
viewModel.updateFieldValue(field.id, null, errorData)
}
},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.alfresco.content.data.Entry
import com.alfresco.content.data.UserGroupDetails
import com.alfresco.content.data.payloads.FieldsData
import com.alfresco.content.process.R
Expand Down Expand Up @@ -145,3 +146,10 @@ fun userGroupInputError(value: UserGroupDetails?, fieldsData: FieldsData, contex

return Pair(isError, errorMessage)
}
fun folderInputError(value: Entry?, fieldsData: FieldsData, context: Context): Pair<Boolean, String> {
val isError = (fieldsData.required && value == null)

val errorMessage = ""

return Pair(isError, errorMessage)
}

0 comments on commit 24526ab

Please sign in to comment.