Remove VectorIcons object, inline the values.

This commit is contained in:
Benoit Marty 2023-09-20 11:45:15 +02:00 committed by Benoit Marty
parent 8f4f2f9d56
commit c652606f56
11 changed files with 51 additions and 96 deletions

View file

@ -1,49 +0,0 @@
/*
* Copyright (c) 2023 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.element.android.libraries.designsystem
object VectorIcons {
val Copy = R.drawable.ic_content_copy
val Forward = R.drawable.ic_forward
val Delete = R.drawable.ic_delete
val Reply = R.drawable.ic_reply
val Edit = R.drawable.ic_edit
val DoorOpen = R.drawable.ic_door_open_24
val DeveloperMode = R.drawable.ic_developer_mode
val ReportContent = R.drawable.ic_report_content
val Groups = R.drawable.ic_groups
val Share = R.drawable.ic_share
val Poll = R.drawable.ic_poll
val PollEnd = R.drawable.ic_poll_end
val Bold = R.drawable.ic_bold
val BulletList = R.drawable.ic_bullet_list
val CodeBlock = R.drawable.ic_code_block
val IndentIncrease = R.drawable.ic_indent_increase
val IndentDecrease = R.drawable.ic_indent_decrease
val InlineCode = R.drawable.ic_inline_code
val Italic = R.drawable.ic_italic
val Link = R.drawable.ic_link
val NumberedList = R.drawable.ic_numbered_list
val Quote = R.drawable.ic_quote
val Strikethrough = R.drawable.ic_strikethrough
val Underline = R.drawable.ic_underline
val Mention = R.drawable.ic_mention
val Mute = R.drawable.ic_mute
val ThreadDecoration = R.drawable.ic_thread_decoration
val Plus = R.drawable.ic_plus
val Cancel = R.drawable.ic_cancel
}

View file

@ -61,13 +61,13 @@ import androidx.compose.ui.unit.dp
import androidx.constraintlayout.compose.ConstraintLayout
import androidx.constraintlayout.compose.Dimension.Companion.fillToConstraints
import androidx.constraintlayout.compose.Visibility
import io.element.android.libraries.designsystem.VectorIcons
import io.element.android.libraries.designsystem.preview.DayNightPreviews
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.text.applyScaleUp
import io.element.android.libraries.designsystem.theme.components.Icon
import io.element.android.libraries.designsystem.theme.components.IconButton
import io.element.android.libraries.designsystem.theme.components.Text
import io.element.android.libraries.designsystem.utils.CommonDrawables
import io.element.android.libraries.matrix.api.core.EventId
import io.element.android.libraries.matrix.api.core.TransactionId
import io.element.android.libraries.matrix.api.media.MediaSource
@ -137,7 +137,7 @@ fun TextComposer(
) {
Icon(
modifier = Modifier.size(30.dp.applyScaleUp()),
resourceId = VectorIcons.Plus,
resourceId = CommonDrawables.ic_plus,
contentDescription = stringResource(R.string.rich_text_editor_a11y_add_attachment),
tint = ElementTheme.colors.iconPrimary,
)
@ -316,7 +316,7 @@ private fun TextFormatting(
) {
Icon(
modifier = Modifier.size(30.dp.applyScaleUp()),
resourceId = VectorIcons.Cancel,
resourceId = CommonDrawables.ic_cancel,
contentDescription = stringResource(CommonStrings.action_close),
tint = ElementTheme.colors.iconPrimary,
)
@ -339,25 +339,25 @@ private fun TextFormatting(
FormattingOption(
state = state.actions[ComposerAction.BOLD].toButtonState(),
onClick = { state.toggleInlineFormat(InlineFormat.Bold) },
imageVector = ImageVector.vectorResource(VectorIcons.Bold),
imageVector = ImageVector.vectorResource(CommonDrawables.ic_bold),
contentDescription = stringResource(R.string.rich_text_editor_format_bold)
)
FormattingOption(
state = state.actions[ComposerAction.ITALIC].toButtonState(),
onClick = { state.toggleInlineFormat(InlineFormat.Italic) },
imageVector = ImageVector.vectorResource(VectorIcons.Italic),
imageVector = ImageVector.vectorResource(CommonDrawables.ic_italic),
contentDescription = stringResource(R.string.rich_text_editor_format_italic)
)
FormattingOption(
state = state.actions[ComposerAction.UNDERLINE].toButtonState(),
onClick = { state.toggleInlineFormat(InlineFormat.Underline) },
imageVector = ImageVector.vectorResource(VectorIcons.Underline),
imageVector = ImageVector.vectorResource(CommonDrawables.ic_underline),
contentDescription = stringResource(R.string.rich_text_editor_format_underline)
)
FormattingOption(
state = state.actions[ComposerAction.STRIKE_THROUGH].toButtonState(),
onClick = { state.toggleInlineFormat(InlineFormat.StrikeThrough) },
imageVector = ImageVector.vectorResource(VectorIcons.Strikethrough),
imageVector = ImageVector.vectorResource(CommonDrawables.ic_strikethrough),
contentDescription = stringResource(R.string.rich_text_editor_format_strikethrough)
)
@ -376,50 +376,50 @@ private fun TextFormatting(
FormattingOption(
state = state.actions[ComposerAction.LINK].toButtonState(),
onClick = { linkDialogAction = state.linkAction },
imageVector = ImageVector.vectorResource(VectorIcons.Link),
imageVector = ImageVector.vectorResource(CommonDrawables.ic_link),
contentDescription = stringResource(R.string.rich_text_editor_link)
)
FormattingOption(
state = state.actions[ComposerAction.UNORDERED_LIST].toButtonState(),
onClick = { state.toggleList(ordered = false) },
imageVector = ImageVector.vectorResource(VectorIcons.BulletList),
imageVector = ImageVector.vectorResource(CommonDrawables.ic_bullet_list),
contentDescription = stringResource(R.string.rich_text_editor_bullet_list)
)
FormattingOption(
state = state.actions[ComposerAction.ORDERED_LIST].toButtonState(),
onClick = { state.toggleList(ordered = true) },
imageVector = ImageVector.vectorResource(VectorIcons.NumberedList),
imageVector = ImageVector.vectorResource(CommonDrawables.ic_numbered_list),
contentDescription = stringResource(R.string.rich_text_editor_numbered_list)
)
FormattingOption(
state = state.actions[ComposerAction.INDENT].toButtonState(),
onClick = { state.indent() },
imageVector = ImageVector.vectorResource(VectorIcons.IndentIncrease),
imageVector = ImageVector.vectorResource(CommonDrawables.ic_indent_increase),
contentDescription = stringResource(R.string.rich_text_editor_indent)
)
FormattingOption(
state = state.actions[ComposerAction.UNINDENT].toButtonState(),
onClick = { state.unindent() },
imageVector = ImageVector.vectorResource(VectorIcons.IndentDecrease),
imageVector = ImageVector.vectorResource(CommonDrawables.ic_indent_decrease),
contentDescription = stringResource(R.string.rich_text_editor_unindent)
)
FormattingOption(
state = state.actions[ComposerAction.INLINE_CODE].toButtonState(),
onClick = { state.toggleInlineFormat(InlineFormat.InlineCode) },
imageVector = ImageVector.vectorResource(VectorIcons.InlineCode),
imageVector = ImageVector.vectorResource(CommonDrawables.ic_inline_code),
contentDescription = stringResource(R.string.rich_text_editor_inline_code)
)
FormattingOption(
state = state.actions[ComposerAction.CODE_BLOCK].toButtonState(),
onClick = { state.toggleCodeBlock() },
imageVector = ImageVector.vectorResource(VectorIcons.CodeBlock),
imageVector = ImageVector.vectorResource(CommonDrawables.ic_code_block),
contentDescription = stringResource(R.string.rich_text_editor_code_block)
)
FormattingOption(
state = state.actions[ComposerAction.QUOTE].toButtonState(),
onClick = { state.toggleQuote() },
imageVector = ImageVector.vectorResource(VectorIcons.Quote),
imageVector = ImageVector.vectorResource(CommonDrawables.ic_quote),
contentDescription = stringResource(R.string.rich_text_editor_quote)
)
}
@ -477,7 +477,7 @@ private fun EditingModeView(
.padding(start = 12.dp)
) {
Icon(
resourceId = VectorIcons.Edit,
resourceId = CommonDrawables.ic_edit,
contentDescription = stringResource(CommonStrings.common_editing),
tint = ElementTheme.materialColors.secondary,
modifier = Modifier

View file

@ -32,12 +32,12 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp
import io.element.android.libraries.designsystem.VectorIcons
import io.element.android.libraries.designsystem.preview.DayNightPreviews
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.text.applyScaleUp
import io.element.android.libraries.designsystem.theme.components.Icon
import io.element.android.libraries.designsystem.theme.iconSuccessPrimaryBackground
import io.element.android.libraries.designsystem.utils.CommonDrawables
import io.element.android.libraries.theme.ElementTheme
import io.element.android.libraries.theme.compound.generated.SemanticColors
@ -96,19 +96,19 @@ internal fun FormattingButtonPreview() = ElementPreview {
FormattingOption(
state = FormattingOptionState.Default,
onClick = { },
imageVector = ImageVector.vectorResource(VectorIcons.Bold),
imageVector = ImageVector.vectorResource(CommonDrawables.ic_bold),
contentDescription = "",
)
FormattingOption(
state = FormattingOptionState.Selected,
onClick = { },
imageVector = ImageVector.vectorResource(VectorIcons.Italic),
imageVector = ImageVector.vectorResource(CommonDrawables.ic_italic),
contentDescription = "",
)
FormattingOption(
state = FormattingOptionState.Disabled,
onClick = { },
imageVector = ImageVector.vectorResource(VectorIcons.Underline),
imageVector = ImageVector.vectorResource(CommonDrawables.ic_underline),
contentDescription = "",
)
}