-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve support for embedded images (creation from the composer…
…, layout) (#792) * update l10n * add feature query * add button to formatting bar * create dialog to edit image alt text * update composer contract * update composer UI * update composer BL * filter inline images from attachments * better support for inline images (vertical spacing before and after)
- Loading branch information
Showing
17 changed files
with
343 additions
and
87 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
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
115 changes: 115 additions & 0 deletions
115
...ast/eattrash/raccoonforfriendica/core/commonui/content/EditAttachmentDescriptionDialog.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,115 @@ | ||
package com.livefast.eattrash.raccoonforfriendica.core.commonui.content | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.foundation.text.KeyboardOptions | ||
import androidx.compose.material3.BasicAlertDialog | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TextField | ||
import androidx.compose.material3.TextFieldDefaults | ||
import androidx.compose.material3.surfaceColorAtElevation | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.layout.ContentScale | ||
import androidx.compose.ui.text.input.KeyboardType | ||
import androidx.compose.ui.text.input.TextFieldValue | ||
import androidx.compose.ui.unit.dp | ||
import com.livefast.eattrash.raccoonforfriendica.core.appearance.theme.CornerSize | ||
import com.livefast.eattrash.raccoonforfriendica.core.appearance.theme.Spacing | ||
import com.livefast.eattrash.raccoonforfriendica.core.commonui.components.CustomImage | ||
import com.livefast.eattrash.raccoonforfriendica.core.l10n.LocalStrings | ||
import com.livefast.eattrash.raccoonforfriendica.domain.content.data.AttachmentModel | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun EditAttachmentDescriptionDialog( | ||
attachment: AttachmentModel, | ||
onClose: ((String?) -> Unit)? = null, | ||
) { | ||
var textFieldValue by remember { | ||
mutableStateOf(TextFieldValue(text = attachment.description.orEmpty())) | ||
} | ||
|
||
BasicAlertDialog( | ||
modifier = Modifier.clip(RoundedCornerShape(CornerSize.xxl)), | ||
onDismissRequest = { | ||
onClose?.invoke(null) | ||
}, | ||
) { | ||
Column( | ||
modifier = | ||
Modifier | ||
.background(color = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp)) | ||
.padding(Spacing.m), | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
verticalArrangement = Arrangement.spacedBy(Spacing.xxs), | ||
) { | ||
Text( | ||
text = LocalStrings.current.pictureDescriptionPlaceholder, | ||
style = MaterialTheme.typography.titleMedium, | ||
color = MaterialTheme.colorScheme.onBackground, | ||
) | ||
Spacer(modifier = Modifier.height(Spacing.s)) | ||
|
||
val url = attachment.url | ||
if (url.isNotEmpty()) { | ||
CustomImage( | ||
modifier = Modifier.height(200.dp), | ||
url = url, | ||
contentScale = ContentScale.Crop, | ||
) | ||
} | ||
|
||
TextField( | ||
modifier = Modifier.fillMaxWidth(), | ||
maxLines = 4, | ||
colors = | ||
TextFieldDefaults.colors( | ||
focusedContainerColor = Color.Transparent, | ||
unfocusedContainerColor = Color.Transparent, | ||
disabledContainerColor = Color.Transparent, | ||
), | ||
label = { | ||
Text( | ||
text = LocalStrings.current.imageFieldAltText, | ||
style = MaterialTheme.typography.bodyMedium, | ||
) | ||
}, | ||
textStyle = MaterialTheme.typography.bodyMedium, | ||
value = textFieldValue, | ||
keyboardOptions = | ||
KeyboardOptions( | ||
keyboardType = KeyboardType.Text, | ||
), | ||
onValueChange = { value -> | ||
textFieldValue = value | ||
}, | ||
) | ||
|
||
Spacer(modifier = Modifier.height(Spacing.xs)) | ||
Button( | ||
onClick = { | ||
onClose?.invoke(textFieldValue.text) | ||
}, | ||
) { | ||
Text(text = LocalStrings.current.buttonConfirm) | ||
} | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.