Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract string resources to strings.xml #211

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions ui-components/src/commonMain/composeResources/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<resources>
<!-- Common -->
<string name="lightning_talk">Lightning talk</string>
<string name="now">Now</string>

<!-- Actions -->
<string name="action_bookmark">Bookmark</string>

<!-- Components -->
<string name="feedback_form_type_something">Type something</string>
<string name="feedback_form_send">Send</string>

<string name="filter_by_tags">Filter by tags</string>
<string name="filter_label_category">Category</string>
<string name="filter_label_level">Level</string>
<string name="filter_label_session_format">Session format</string>

<string name="main_header_back">Back</string>
<string name="main_header_search_hint">Type to search</string>
<string name="main_header_search_clear">Clear</string>

<string name="talk_card_your_feedback">Your feedback</string>
<string name="talk_card_how_was_the_talk">How was the talk?</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsFocusedAsState
import androidx.compose.foundation.layout.Box
Expand All @@ -28,13 +27,15 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.unit.dp
import kotlinconfapp.ui_components.generated.resources.Res
import kotlinconfapp.ui_components.generated.resources.arrow_right_24
import kotlinconfapp.ui_components.generated.resources.feedback_form_send
import kotlinconfapp.ui_components.generated.resources.feedback_form_type_something
import org.jetbrains.compose.resources.stringResource
import org.jetbrains.compose.ui.tooling.preview.Preview
import org.jetbrains.kotlinconf.ui.theme.KotlinConfTheme
import org.jetbrains.kotlinconf.ui.theme.PreviewHelper
Expand Down Expand Up @@ -124,7 +125,7 @@ fun FeedbackForm(
exit = fadeOut(tween(10)),
) {
StyledText(
text = "Type something",
text = stringResource(Res.string.feedback_form_type_something),
style = KotlinConfTheme.typography.text1,
color = KotlinConfTheme.colors.placeholderText
)
Expand All @@ -142,7 +143,7 @@ fun FeedbackForm(
KodeeEmotion(emotion = emotion)
Spacer(Modifier.weight(1f))
Action(
label = "Send",
label = stringResource(Res.string.feedback_form_send),
icon = Res.drawable.arrow_right_24,
size = ActionSize.Large,
enabled = feedbackText.isNotEmpty(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp
import kotlinconfapp.ui_components.generated.resources.Res
import kotlinconfapp.ui_components.generated.resources.filter_by_tags
import kotlinconfapp.ui_components.generated.resources.filter_label_category
import kotlinconfapp.ui_components.generated.resources.filter_label_level
import kotlinconfapp.ui_components.generated.resources.filter_label_session_format
import kotlinconfapp.ui_components.generated.resources.up_24
import org.jetbrains.compose.resources.stringResource
import org.jetbrains.compose.ui.tooling.preview.Preview
import org.jetbrains.kotlinconf.ui.theme.KotlinConfTheme
import org.jetbrains.kotlinconf.ui.theme.PreviewHelper
Expand Down Expand Up @@ -79,7 +84,7 @@ fun Filters(
) {
val iconRotation by animateFloatAsState(if (isExpanded) 0f else 180f)
Action(
label = "Filter by tags",
label = stringResource(Res.string.filter_by_tags),
icon = Res.drawable.up_24,
size = ActionSize.Medium,
enabled = true,
Expand Down Expand Up @@ -124,9 +129,9 @@ fun Filters(
verticalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier.padding(12.dp),
) {
FilterItemGroup("Category", categories, toggleItem)
FilterItemGroup("Level", levels, toggleItem)
FilterItemGroup("Session format", sessionFormats, toggleItem)
FilterItemGroup(stringResource(Res.string.filter_label_category), categories, toggleItem)
FilterItemGroup(stringResource(Res.string.filter_label_level), levels, toggleItem)
FilterItemGroup(stringResource(Res.string.filter_label_session_format), sessionFormats, toggleItem)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ import kotlinconfapp.ui_components.generated.resources.Res
import kotlinconfapp.ui_components.generated.resources.arrow_left_24
import kotlinconfapp.ui_components.generated.resources.bookmark_24
import kotlinconfapp.ui_components.generated.resources.close_24
import kotlinconfapp.ui_components.generated.resources.main_header_back
import kotlinconfapp.ui_components.generated.resources.main_header_search_clear
import kotlinconfapp.ui_components.generated.resources.main_header_search_hint
import kotlinconfapp.ui_components.generated.resources.search_24
import org.jetbrains.compose.resources.stringResource
import org.jetbrains.compose.ui.tooling.preview.Preview
import org.jetbrains.kotlinconf.ui.theme.KotlinConfTheme
import org.jetbrains.kotlinconf.ui.theme.PreviewHelper
Expand All @@ -57,7 +61,7 @@ fun MainHeaderSearchBar(
onClose()
onSearchValueChange("")
},
contentDescription = "Back",
contentDescription = stringResource(Res.string.main_header_back),
)

val focusRequester = remember { FocusRequester() }
Expand Down Expand Up @@ -86,7 +90,7 @@ fun MainHeaderSearchBar(
exit = fadeOut(tween(10)),
) {
StyledText(
text = "Type to search",
text = stringResource(Res.string.main_header_search_hint),
style = KotlinConfTheme.typography.text1,
color = KotlinConfTheme.colors.placeholderText
)
Expand All @@ -99,7 +103,7 @@ fun MainHeaderSearchBar(
onSearchValueChange("")
focusRequester.requestFocus()
},
contentDescription = "Clear",
contentDescription = stringResource(Res.string.main_header_search_clear),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import androidx.compose.ui.draw.rotate
import androidx.compose.ui.unit.dp
import kotlinconfapp.ui_components.generated.resources.Res
import kotlinconfapp.ui_components.generated.resources.arrow_down_16
import kotlinconfapp.ui_components.generated.resources.now
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.stringResource
import org.jetbrains.compose.ui.tooling.preview.Preview
import org.jetbrains.kotlinconf.ui.components.NowButtonState.After
import org.jetbrains.kotlinconf.ui.components.NowButtonState.Before
Expand Down Expand Up @@ -72,7 +74,7 @@ fun NowButton(
horizontalArrangement = Arrangement.Center,
) {
StyledText(
text = "Now",
text = stringResource(Res.string.now),
style = KotlinConfTheme.typography.text2,
color = textColor,
)
Expand All @@ -87,7 +89,7 @@ fun NowButton(
Icon(
// TODO review icon sizing later, https://github.com/JetBrains/kotlinconf-app/issues/175
painter = painterResource(Res.drawable.arrow_down_16),
contentDescription = "Now",
contentDescription = null,
modifier = Modifier
.size(16.dp)
.rotate(if (time == Before) 0f else 180f),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,28 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp
import kotlinconfapp.ui_components.generated.resources.Res
import kotlinconfapp.ui_components.generated.resources.now
import org.jetbrains.compose.resources.stringResource
import org.jetbrains.compose.ui.tooling.preview.Preview
import org.jetbrains.kotlinconf.ui.theme.KotlinConfTheme
import org.jetbrains.kotlinconf.ui.theme.PreviewHelper


@Composable
fun NowLabel(modifier: Modifier = Modifier) {
Row(verticalAlignment = Alignment.CenterVertically) {
Row(
modifier = modifier,
verticalAlignment = Alignment.CenterVertically,
) {
Box(
Modifier.size(10.dp)
.clip(CircleShape)
.background(KotlinConfTheme.colors.accentText)
)
Spacer(Modifier.size(4.dp))
StyledText(
text = "Now",
text = stringResource(Res.string.now),
color = KotlinConfTheme.colors.accentText,
style = KotlinConfTheme.typography.text2,
maxLines = 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import kotlinconfapp.ui_components.generated.resources.Res
import kotlinconfapp.ui_components.generated.resources.action_bookmark
import kotlinconfapp.ui_components.generated.resources.bookmark_24
import kotlinconfapp.ui_components.generated.resources.bookmark_24_fill
import kotlinconfapp.ui_components.generated.resources.lightning_16_fill
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.stringResource
import org.jetbrains.compose.ui.tooling.preview.Preview
import org.jetbrains.kotlinconf.ui.theme.KotlinConfTheme
import org.jetbrains.kotlinconf.ui.theme.PreviewHelper
Expand Down Expand Up @@ -88,7 +90,7 @@ fun PageTitle(
painter = painterResource(
if (bookmarked) Res.drawable.bookmark_24_fill else Res.drawable.bookmark_24
),
contentDescription = "Bookmark",
contentDescription = stringResource(Res.string.action_bookmark),
tint = iconTint,
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
package org.jetbrains.kotlinconf.ui.components

import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import org.jetbrains.compose.ui.tooling.preview.Preview
import org.jetbrains.kotlinconf.ui.components.NowLabel
import org.jetbrains.kotlinconf.ui.components.StyledText
import org.jetbrains.kotlinconf.ui.theme.KotlinConfTheme
import org.jetbrains.kotlinconf.ui.theme.PreviewHelper

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,18 @@ import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.unit.dp
import kotlinconfapp.ui_components.generated.resources.Res
import kotlinconfapp.ui_components.generated.resources.action_bookmark
import kotlinconfapp.ui_components.generated.resources.bookmark_24
import kotlinconfapp.ui_components.generated.resources.bookmark_24_fill
import kotlinconfapp.ui_components.generated.resources.lightning_16_fill
import kotlinconfapp.ui_components.generated.resources.lightning_talk
import kotlinconfapp.ui_components.generated.resources.talk_card_how_was_the_talk
import kotlinconfapp.ui_components.generated.resources.talk_card_your_feedback
import kotlinconfapp.ui_components.generated.resources.up_24
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.stringResource
import org.jetbrains.compose.ui.tooling.preview.Preview
import org.jetbrains.kotlinconf.ui.theme.Brand
import org.jetbrains.kotlinconf.ui.theme.KotlinConfTheme
Expand Down Expand Up @@ -191,7 +196,7 @@ private fun TopBlock(
if (bookmarked) Res.drawable.bookmark_24_fill
else Res.drawable.bookmark_24
),
contentDescription = "Bookmark",
contentDescription = stringResource(Res.string.action_bookmark),
tint = iconColor,
)
}
Expand Down Expand Up @@ -250,7 +255,7 @@ private fun TimeBlock(
Icon(
modifier = Modifier.size(16.dp),
painter = painterResource(Res.drawable.lightning_16_fill),
contentDescription = "Lightning talk",
contentDescription = stringResource(Res.string.lightning_talk),
tint = KotlinConfTheme.colors.orangeText,
)
}
Expand Down Expand Up @@ -291,7 +296,7 @@ private fun FeedbackBlock(
if (emotionSelected) {
val iconRotation by animateFloatAsState(if (feedbackExpanded) 0f else 180f)
Action(
label = "Your feedback",
label = stringResource(Res.string.talk_card_your_feedback),
icon = Res.drawable.up_24,
size = ActionSize.Medium,
enabled = true,
Expand All @@ -300,7 +305,7 @@ private fun FeedbackBlock(
)
} else {
StyledText(
text = "How was the talk?",
text = stringResource(Res.string.talk_card_how_was_the_talk),
style = KotlinConfTheme.typography.text2,
color = KotlinConfTheme.colors.primaryText,
)
Expand Down
Loading