Skip to content

Commit 0cd93bd

Browse files
committed
refactor(profile): Introduce shared Text composables and fix minor issues
This commit refactors the Developer Profile feature by centralizing text styling into new shared composables, improving code consistency and maintainability. It also includes minor bug fixes and translation updates. - **Refactor(UI)**: Replaced direct `Text` usages in the developer profile screens with new standardized composables (`GithubStoreTitleText`, `GithubStoreSubtitleText`, `GithubStoreBodyText`, etc.) from `core.presentation.components.Texts`. - **Refactor(UI)**: Replaced `ScrollableTabRow` with `SecondaryScrollableTabRow` for filter tabs. - **i18n**: Added Japanese translations for the developer profile. - **i18n**: Fixed pluralization and spacing in time-related strings for French, Spanish, Polish, and Italian. - **Fix**: Corrected code formatting in `DeveloperProfileRepositoryImpl`.
1 parent be58546 commit 0cd93bd

12 files changed

Lines changed: 298 additions & 63 deletions

File tree

composeApp/src/commonMain/composeResources/values-es/strings-es.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@
262262
<string name="has_release">Tiene lanzamiento</string>
263263

264264
<!-- Developer Profile - Relative Time -->
265-
<string name="time_years_ago">hace %1$d a</string>
266-
<string name="time_months_ago">hace %1$d m</string>
265+
<string name="time_years_ago">hace %1$d año(s)</string>
266+
<string name="time_months_ago">hace %1$d mes(es)</string>
267267
<string name="time_days_ago">hace %1$d d</string>
268268
<string name="time_hours_ago">hace %1$d h</string>
269269
<string name="time_minutes_ago">hace %1$d min</string>

composeApp/src/commonMain/composeResources/values-fr/strings-fr.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@
262262
<string name="has_release">A une version</string>
263263

264264
<!-- Developer Profile - Relative Time -->
265-
<string name="time_years_ago">il y a %1$d an</string>
265+
<string name="time_years_ago">il y a %1$d an(s)</string>
266266
<string name="time_months_ago">il y a %1$d mois</string>
267267
<string name="time_days_ago">il y a %1$d j</string>
268268
<string name="time_hours_ago">il y a %1$d h</string>

composeApp/src/commonMain/composeResources/values-it/strings-it.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@
312312

313313
<!-- Developer Profile - Relative Time -->
314314
<string name="time_years_ago">%1$d a fa</string>
315-
<string name="time_months_ago">%1$d mesi fa</string>
315+
<string name="time_months_ago">%1$d m fa</string>
316316
<string name="time_days_ago">%1$d g fa</string>
317317
<string name="time_hours_ago">%1$d h fa</string>
318318
<string name="time_minutes_ago">%1$d min fa</string>

composeApp/src/commonMain/composeResources/values-ja/strings-ja.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@
224224
<string name="dismiss">閉じる</string>
225225
<string name="sync_starred_failed">スター付きリポジトリの同期に失敗しました</string>
226226

227+
<string name="developer_profile_title">開発者プロフィール</string>
228+
<string name="open_developer_profile">開発者プロフィールを開く</string>
229+
227230
<!-- Developer Profile - General -->
228231
<string name="failed_to_load_repositories">リポジトリの読み込みに失敗しました</string>
229232
<string name="failed_to_load_profile">プロフィールの読み込みに失敗しました</string>

composeApp/src/commonMain/composeResources/values-pl/strings-pl.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@
279279
<string name="has_release">Ma wydanie</string>
280280

281281
<!-- Developer Profile - Relative Time -->
282-
<string name="time_years_ago">%1$d l temu</string>
282+
<string name="time_years_ago">%1$d lat temu</string>
283283
<string name="time_months_ago">%1$d mies temu</string>
284-
<string name="time_days_ago">%1$d dn temu</string>
284+
<string name="time_days_ago">%1$d d temu</string>
285285
<string name="time_hours_ago">%1$d h temu</string>
286286
<string name="time_minutes_ago">%1$d min temu</string>
287287

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
package zed.rainxch.githubstore.core.presentation.components
2+
3+
import androidx.compose.material3.LocalTextStyle
4+
import androidx.compose.material3.MaterialTheme
5+
import androidx.compose.material3.Text
6+
import androidx.compose.runtime.Composable
7+
import androidx.compose.ui.Modifier
8+
import androidx.compose.ui.graphics.Color
9+
import androidx.compose.ui.text.font.FontWeight
10+
import androidx.compose.ui.text.style.TextAlign
11+
import androidx.compose.ui.text.style.TextOverflow
12+
13+
@Composable
14+
fun GithubStoreTitleText(
15+
text: String,
16+
modifier: Modifier = Modifier,
17+
color: Color = MaterialTheme.colorScheme.onSurface,
18+
textAlign: TextAlign? = null,
19+
maxLines: Int = Int.MAX_VALUE,
20+
fontWeight: FontWeight = FontWeight.Bold
21+
) {
22+
Text(
23+
text = text,
24+
modifier = modifier,
25+
style = MaterialTheme.typography.titleLarge,
26+
color = color,
27+
textAlign = textAlign,
28+
maxLines = maxLines,
29+
overflow = TextOverflow.Ellipsis,
30+
fontWeight = fontWeight,
31+
softWrap = maxLines > 1
32+
)
33+
}
34+
35+
/**
36+
* Subtitle text component
37+
* Used for: Secondary headings, usernames, timestamps, metadata
38+
*/
39+
@Composable
40+
fun GithubStoreSubtitleText(
41+
text: String,
42+
modifier: Modifier = Modifier,
43+
color: Color = MaterialTheme.colorScheme.onSurfaceVariant,
44+
textAlign: TextAlign? = null,
45+
maxLines: Int = Int.MAX_VALUE,
46+
fontWeight: FontWeight? = null
47+
) {
48+
Text(
49+
text = text,
50+
modifier = modifier,
51+
style = MaterialTheme.typography.titleMedium,
52+
color = color,
53+
textAlign = textAlign,
54+
maxLines = maxLines,
55+
overflow = TextOverflow.Ellipsis,
56+
fontWeight = fontWeight,
57+
softWrap = maxLines > 1
58+
)
59+
}
60+
61+
/**
62+
* Body text component
63+
* Used for: Descriptions, messages, general content, labels
64+
*/
65+
@Composable
66+
fun GithubStoreBodyText(
67+
text: String,
68+
modifier: Modifier = Modifier,
69+
color: Color = MaterialTheme.colorScheme.onSurfaceVariant,
70+
textAlign: TextAlign? = null,
71+
maxLines: Int = Int.MAX_VALUE,
72+
fontWeight: FontWeight? = null
73+
) {
74+
Text(
75+
text = text,
76+
modifier = modifier,
77+
style = MaterialTheme.typography.bodyMedium,
78+
color = color,
79+
textAlign = textAlign,
80+
maxLines = maxLines,
81+
overflow = TextOverflow.Ellipsis,
82+
fontWeight = fontWeight,
83+
softWrap = maxLines > 1
84+
)
85+
}
86+
87+
/**
88+
* Large body text component
89+
* Used for: Prominent descriptions, highlighted content
90+
*/
91+
@Composable
92+
fun GithubStoreLargeBodyText(
93+
text: String,
94+
modifier: Modifier = Modifier,
95+
color: Color = MaterialTheme.colorScheme.onSurfaceVariant,
96+
textAlign: TextAlign? = null,
97+
maxLines: Int = Int.MAX_VALUE,
98+
fontWeight: FontWeight? = null
99+
) {
100+
Text(
101+
text = text,
102+
modifier = modifier,
103+
style = MaterialTheme.typography.bodyLarge,
104+
color = color,
105+
textAlign = textAlign,
106+
maxLines = maxLines,
107+
overflow = TextOverflow.Ellipsis,
108+
fontWeight = fontWeight,
109+
softWrap = maxLines > 1
110+
)
111+
}
112+
113+
/**
114+
* Small body text component
115+
* Used for: Fine print, secondary information, captions
116+
*/
117+
@Composable
118+
fun GithubStoreSmallBodyText(
119+
text: String,
120+
modifier: Modifier = Modifier,
121+
color: Color = MaterialTheme.colorScheme.onSurfaceVariant,
122+
textAlign: TextAlign? = null,
123+
maxLines: Int = Int.MAX_VALUE,
124+
fontWeight: FontWeight? = null
125+
) {
126+
Text(
127+
text = text,
128+
modifier = modifier,
129+
style = MaterialTheme.typography.bodySmall,
130+
color = color,
131+
textAlign = textAlign,
132+
maxLines = maxLines,
133+
overflow = TextOverflow.Ellipsis,
134+
fontWeight = fontWeight,
135+
softWrap = maxLines > 1
136+
)
137+
}
138+
139+
/**
140+
* Button text component
141+
* Used for: Button labels, action text
142+
*/
143+
@Composable
144+
fun GithubStoreButtonText(
145+
text: String,
146+
modifier: Modifier = Modifier,
147+
color: Color = LocalTextStyle.current.color,
148+
textAlign: TextAlign? = null,
149+
maxLines: Int = 1,
150+
fontWeight: FontWeight = FontWeight.SemiBold
151+
) {
152+
Text(
153+
text = text,
154+
modifier = modifier,
155+
style = MaterialTheme.typography.labelLarge,
156+
color = color,
157+
textAlign = textAlign,
158+
maxLines = maxLines,
159+
overflow = TextOverflow.Ellipsis,
160+
fontWeight = fontWeight,
161+
softWrap = false
162+
)
163+
}
164+
165+
/**
166+
* Label text component
167+
* Used for: Form labels, chip labels, small UI elements
168+
*/
169+
@Composable
170+
fun GithubStoreLabelText(
171+
text: String,
172+
modifier: Modifier = Modifier,
173+
color: Color = MaterialTheme.colorScheme.onSurface,
174+
textAlign: TextAlign? = null,
175+
maxLines: Int = 1,
176+
fontWeight: FontWeight = FontWeight.Medium
177+
) {
178+
Text(
179+
text = text,
180+
modifier = modifier,
181+
style = MaterialTheme.typography.labelMedium,
182+
color = color,
183+
textAlign = textAlign,
184+
maxLines = maxLines,
185+
overflow = TextOverflow.Ellipsis,
186+
fontWeight = fontWeight,
187+
softWrap = false
188+
)
189+
}
190+
191+
/**
192+
* Display text component (extra large)
193+
* Used for: Hero sections, splash screens, very prominent headings
194+
*/
195+
@Composable
196+
fun GithubStoreDisplayText(
197+
text: String,
198+
modifier: Modifier = Modifier,
199+
color: Color = MaterialTheme.colorScheme.onSurface,
200+
textAlign: TextAlign? = null,
201+
maxLines: Int = Int.MAX_VALUE,
202+
fontWeight: FontWeight = FontWeight.Bold
203+
) {
204+
Text(
205+
text = text,
206+
modifier = modifier,
207+
style = MaterialTheme.typography.displayMedium,
208+
color = color,
209+
textAlign = textAlign,
210+
maxLines = maxLines,
211+
overflow = TextOverflow.Ellipsis,
212+
fontWeight = fontWeight,
213+
softWrap = maxLines > 1
214+
)
215+
}
216+
217+
/**
218+
* Headline text component
219+
* Used for: Section headers, category titles
220+
*/
221+
@Composable
222+
fun GithubStoreHeadlineText(
223+
text: String,
224+
modifier: Modifier = Modifier,
225+
color: Color = MaterialTheme.colorScheme.onSurface,
226+
textAlign: TextAlign? = null,
227+
maxLines: Int = Int.MAX_VALUE,
228+
fontWeight: FontWeight = FontWeight.SemiBold
229+
) {
230+
Text(
231+
text = text,
232+
modifier = modifier,
233+
style = MaterialTheme.typography.headlineMedium,
234+
color = color,
235+
textAlign = textAlign,
236+
maxLines = maxLines,
237+
overflow = TextOverflow.Ellipsis,
238+
fontWeight = fontWeight,
239+
softWrap = maxLines > 1
240+
)
241+
}

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/feature/developer_profile/data/repository/DeveloperProfileRepositoryImpl.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,8 @@ class DeveloperProfileRepositoryImpl(
164164
PlatformType.ANDROID -> name.endsWith(".apk")
165165
PlatformType.WINDOWS -> name.endsWith(".msi") || name.endsWith(".exe")
166166
PlatformType.MACOS -> name.endsWith(".dmg") || name.endsWith(".pkg")
167-
PlatformType.LINUX -> name.endsWith(".appimage") || name.endsWith(".deb") || name.endsWith(
168-
".rpm"
169-
)
167+
PlatformType.LINUX -> name.endsWith(".appimage") || name.endsWith(".deb")
168+
|| name.endsWith(".rpm")
170169
}
171170
}
172171

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/feature/developer_profile/presentation/DeveloperProfileRoot.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ import githubstore.composeapp.generated.resources.open_repository
5353
import githubstore.composeapp.generated.resources.retry
5454
import org.jetbrains.compose.resources.stringResource
5555
import org.koin.compose.viewmodel.koinViewModel
56+
import zed.rainxch.githubstore.core.presentation.components.GithubStoreBodyText
57+
import zed.rainxch.githubstore.core.presentation.components.GithubStoreButtonText
58+
import zed.rainxch.githubstore.core.presentation.components.GithubStoreTitleText
5659
import zed.rainxch.githubstore.feature.developer_profile.domain.model.RepoFilterType
5760
import zed.rainxch.githubstore.feature.developer_profile.presentation.components.DeveloperRepoItem
5861
import zed.rainxch.githubstore.feature.developer_profile.presentation.components.FilterSortControls
@@ -254,10 +257,9 @@ private fun EmptyReposContent(
254257

255258
Spacer(modifier = Modifier.height(12.dp))
256259

257-
Text(
260+
GithubStoreBodyText(
258261
text = message,
259-
style = MaterialTheme.typography.bodyMedium,
260-
color = MaterialTheme.colorScheme.onSurfaceVariant,
262+
maxLines = 2,
261263
textAlign = TextAlign.Center
262264
)
263265
}
@@ -332,16 +334,16 @@ private fun ErrorContent(
332334

333335
Spacer(modifier = Modifier.height(16.dp))
334336

335-
Text(
337+
GithubStoreTitleText(
336338
text = stringResource(Res.string.error_generic, message),
337-
style = MaterialTheme.typography.titleLarge,
338-
color = MaterialTheme.colorScheme.onSurface
339+
maxLines = 3,
340+
textAlign = TextAlign.Center
339341
)
340342

341343
Spacer(modifier = Modifier.height(16.dp))
342344

343345
Button(onClick = onRetry) {
344-
Text(
346+
GithubStoreButtonText(
345347
text = stringResource(Res.string.retry)
346348
)
347349
}

0 commit comments

Comments
 (0)