Skip to content

Commit b3497aa

Browse files
committed
chore(ui): use MarqueeText for button texts
1 parent 15a2d79 commit b3497aa

14 files changed

Lines changed: 56 additions & 36 deletions

File tree

ZalithLauncher/src/main/java/com/movtery/zalithlauncher/ui/components/Buttons.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.movtery.zalithlauncher.ui.components
33
import androidx.compose.animation.core.animateFloatAsState
44
import androidx.compose.animation.core.spring
55
import androidx.compose.foundation.BorderStroke
6+
import androidx.compose.foundation.basicMarquee
67
import androidx.compose.foundation.clickable
78
import androidx.compose.foundation.gestures.awaitEachGesture
89
import androidx.compose.foundation.gestures.awaitFirstDown
@@ -91,6 +92,18 @@ fun ScalingActionButton(
9192
)
9293
}
9394

95+
@Composable
96+
fun MarqueeText(
97+
modifier: Modifier = Modifier,
98+
text: String
99+
) {
100+
Text(
101+
modifier = modifier.basicMarquee(Int.MAX_VALUE),
102+
text = text,
103+
maxLines = 1
104+
)
105+
}
106+
94107
@Composable
95108
fun IconTextButton(
96109
onClick: () -> Unit,

ZalithLauncher/src/main/java/com/movtery/zalithlauncher/ui/components/ColorPicker.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,15 @@ fun ColorPickerDialog(
189189
onDismissRequest()
190190
}
191191
) {
192-
Text(text = stringResource(R.string.generic_cancel))
192+
MarqueeText(text = stringResource(R.string.generic_cancel))
193193
}
194194
Button(
195195
modifier = Modifier.weight(1f),
196196
onClick = {
197197
onConfirm(selectedColor)
198198
}
199199
) {
200-
Text(text = stringResource(R.string.generic_confirm))
200+
MarqueeText(text = stringResource(R.string.generic_confirm))
201201
}
202202
}
203203
}

ZalithLauncher/src/main/java/com/movtery/zalithlauncher/ui/components/Dialogs.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ fun SimpleAlertDialog(
7575
},
7676
confirmButton = {
7777
Button(onClick = onConfirm) {
78-
Text(text = confirmText)
78+
MarqueeText(text = confirmText)
7979
}
8080
},
8181
dismissButton = {
8282
Button(onClick = onDismiss) {
83-
Text(text = dismissText)
83+
MarqueeText(text = dismissText)
8484
}
8585
}
8686
)
@@ -115,7 +115,7 @@ fun SimpleAlertDialog(
115115
},
116116
confirmButton = {
117117
Button(onClick = onDismiss) {
118-
Text(text = confirmText)
118+
MarqueeText(text = confirmText)
119119
}
120120
}
121121
)
@@ -146,12 +146,12 @@ fun SimpleAlertDialog(
146146
},
147147
confirmButton = {
148148
Button(onClick = onConfirm) {
149-
Text(text = confirmText)
149+
MarqueeText(text = confirmText)
150150
}
151151
},
152152
dismissButton = {
153153
Button(onClick = onCancel) {
154-
Text(text = dismissText)
154+
MarqueeText(text = dismissText)
155155
}
156156
}
157157
)
@@ -233,13 +233,13 @@ fun SimpleEditDialog(
233233
modifier = Modifier.weight(1f),
234234
onClick = onDismissRequest
235235
) {
236-
Text(text = stringResource(R.string.generic_cancel))
236+
MarqueeText(text = stringResource(R.string.generic_cancel))
237237
}
238238
Button(
239239
modifier = Modifier.weight(1f),
240240
onClick = onConfirm
241241
) {
242-
Text(text = stringResource(R.string.generic_confirm))
242+
MarqueeText(text = stringResource(R.string.generic_confirm))
243243
}
244244
}
245245
}
@@ -363,7 +363,7 @@ fun <T> SimpleListDialog(
363363
}
364364
}
365365
) {
366-
Text(stringResource(R.string.generic_confirm))
366+
MarqueeText(text = stringResource(R.string.generic_confirm))
367367
}
368368
}
369369
}

ZalithLauncher/src/main/java/com/movtery/zalithlauncher/ui/screens/content/AccountManageScreen.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import com.movtery.zalithlauncher.path.UrlManager
6464
import com.movtery.zalithlauncher.state.ObjectStates
6565
import com.movtery.zalithlauncher.ui.base.BaseScreen
6666
import com.movtery.zalithlauncher.ui.components.IconTextButton
67+
import com.movtery.zalithlauncher.ui.components.MarqueeText
6768
import com.movtery.zalithlauncher.ui.components.ScalingActionButton
6869
import com.movtery.zalithlauncher.ui.components.ScalingLabel
6970
import com.movtery.zalithlauncher.ui.components.SimpleAlertDialog
@@ -234,9 +235,7 @@ private fun ServerTypeMenu(
234235
.fillMaxWidth(),
235236
onClick = { updateServerOperation(ServerOperation.AddNew) }
236237
) {
237-
Text(
238-
text = stringResource(R.string.account_add_new_server_button)
239-
)
238+
MarqueeText(text = stringResource(R.string.account_add_new_server_button))
240239
}
241240
}
242241
}
@@ -666,7 +665,7 @@ private fun AccountSkinOperation(
666665
updateOperation(AccountSkinOperation.None)
667666
}
668667
) {
669-
Text(text = stringResource(R.string.generic_go_it))
668+
MarqueeText(text = stringResource(R.string.generic_go_it))
670669
}
671670
}
672671
)

ZalithLauncher/src/main/java/com/movtery/zalithlauncher/ui/screens/content/FileSelectorScreen.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import com.movtery.zalithlauncher.R
3737
import com.movtery.zalithlauncher.state.FilePathSelectorData
3838
import com.movtery.zalithlauncher.state.MutableStates
3939
import com.movtery.zalithlauncher.ui.base.BaseScreen
40+
import com.movtery.zalithlauncher.ui.components.MarqueeText
4041
import com.movtery.zalithlauncher.ui.components.ScalingActionButton
4142
import com.movtery.zalithlauncher.ui.components.ScalingLabel
4243
import com.movtery.zalithlauncher.ui.components.itemLayoutColor
@@ -208,19 +209,19 @@ private fun LeftActionMenu(
208209
modifier = Modifier.fillMaxWidth(),
209210
onClick = backToParent
210211
) {
211-
Text(text = stringResource(R.string.files_back_to_parent))
212+
MarqueeText(text = stringResource(R.string.files_back_to_parent))
212213
}
213214
ScalingActionButton(
214215
modifier = Modifier.fillMaxWidth(),
215216
onClick = createDir
216217
) {
217-
Text(text = stringResource(R.string.files_create_dir))
218+
MarqueeText(text = stringResource(R.string.files_create_dir))
218219
}
219220
ScalingActionButton(
220221
modifier = Modifier.fillMaxWidth(),
221222
onClick = selectDir
222223
) {
223-
Text(text = stringResource(R.string.files_select_dir))
224+
MarqueeText(text = stringResource(R.string.files_select_dir))
224225
}
225226
}
226227
}

ZalithLauncher/src/main/java/com/movtery/zalithlauncher/ui/screens/content/LauncherScreen.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import com.movtery.zalithlauncher.game.version.installed.Version
4545
import com.movtery.zalithlauncher.game.version.installed.VersionsManager
4646
import com.movtery.zalithlauncher.info.InfoDistributor
4747
import com.movtery.zalithlauncher.ui.base.BaseScreen
48+
import com.movtery.zalithlauncher.ui.components.MarqueeText
4849
import com.movtery.zalithlauncher.ui.components.ScalingActionButton
4950
import com.movtery.zalithlauncher.ui.screens.NormalNavKey
5051
import com.movtery.zalithlauncher.ui.screens.content.elements.AccountAvatar
@@ -248,7 +249,7 @@ private fun RightMenu(
248249
)
249250
},
250251
) {
251-
Text(text = stringResource(R.string.main_launch_game))
252+
MarqueeText(text = stringResource(R.string.main_launch_game))
252253
}
253254
}
254255
}

ZalithLauncher/src/main/java/com/movtery/zalithlauncher/ui/screens/content/VersionsManageScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import androidx.compose.material3.Card
2222
import androidx.compose.material3.CircularProgressIndicator
2323
import androidx.compose.material3.HorizontalDivider
2424
import androidx.compose.material3.MaterialTheme
25-
import androidx.compose.material3.Text
2625
import androidx.compose.runtime.Composable
2726
import androidx.compose.runtime.collectAsState
2827
import androidx.compose.runtime.getValue
@@ -46,6 +45,7 @@ import com.movtery.zalithlauncher.state.MutableStates
4645
import com.movtery.zalithlauncher.ui.activities.MainActivity
4746
import com.movtery.zalithlauncher.ui.base.BaseScreen
4847
import com.movtery.zalithlauncher.ui.components.IconTextButton
48+
import com.movtery.zalithlauncher.ui.components.MarqueeText
4949
import com.movtery.zalithlauncher.ui.components.ScalingActionButton
5050
import com.movtery.zalithlauncher.ui.components.ScalingLabel
5151
import com.movtery.zalithlauncher.ui.screens.NormalNavKey
@@ -206,7 +206,7 @@ private fun GamePathLayout(
206206
}
207207
}
208208
) {
209-
Text(text = stringResource(R.string.versions_manage_game_path_add_new))
209+
MarqueeText(text = stringResource(R.string.versions_manage_game_path_add_new))
210210
}
211211
}
212212
}

ZalithLauncher/src/main/java/com/movtery/zalithlauncher/ui/screens/content/download/DownloadGameScreen.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import com.movtery.zalithlauncher.game.download.jvm_server.JvmCrashException
3939
import com.movtery.zalithlauncher.game.version.download.DownloadFailedException
4040
import com.movtery.zalithlauncher.game.version.installed.VersionsManager
4141
import com.movtery.zalithlauncher.notification.NotificationManager
42+
import com.movtery.zalithlauncher.ui.components.MarqueeText
4243
import com.movtery.zalithlauncher.ui.components.NotificationCheck
4344
import com.movtery.zalithlauncher.ui.components.SimpleAlertDialog
4445
import com.movtery.zalithlauncher.ui.screens.NestedNavKey
@@ -263,7 +264,7 @@ private fun GameInstallOperation(
263264
},
264265
confirmButton = {
265266
Button(onClick = dismiss) {
266-
Text(text = stringResource(R.string.generic_confirm))
267+
MarqueeText(text = stringResource(R.string.generic_confirm))
267268
}
268269
}
269270
)

ZalithLauncher/src/main/java/com/movtery/zalithlauncher/ui/screens/content/download/DownloadModPackScreen.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import com.movtery.zalithlauncher.game.download.modpack.install.ModPackInstaller
3939
import com.movtery.zalithlauncher.game.version.download.DownloadFailedException
4040
import com.movtery.zalithlauncher.game.version.installed.VersionsManager
4141
import com.movtery.zalithlauncher.notification.NotificationManager
42+
import com.movtery.zalithlauncher.ui.components.MarqueeText
4243
import com.movtery.zalithlauncher.ui.components.NotificationCheck
4344
import com.movtery.zalithlauncher.ui.components.SimpleAlertDialog
4445
import com.movtery.zalithlauncher.ui.screens.NestedNavKey
@@ -286,7 +287,7 @@ private fun ModPackInstallOperation(
286287
},
287288
confirmButton = {
288289
Button(onClick = dismiss) {
289-
Text(text = stringResource(R.string.generic_confirm))
290+
MarqueeText(text = stringResource(R.string.generic_confirm))
290291
}
291292
}
292293
)

ZalithLauncher/src/main/java/com/movtery/zalithlauncher/ui/screens/content/download/assets/elements/_Download.Single.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import androidx.compose.ui.window.Dialog
3636
import com.movtery.zalithlauncher.R
3737
import com.movtery.zalithlauncher.game.version.installed.Version
3838
import com.movtery.zalithlauncher.game.version.installed.VersionsManager
39+
import com.movtery.zalithlauncher.ui.components.MarqueeText
3940
import com.movtery.zalithlauncher.ui.components.SimpleAlertDialog
4041
import com.movtery.zalithlauncher.ui.components.itemLayoutColor
4142
import com.movtery.zalithlauncher.ui.screens.content.elements.CommonVersionInfoLayout
@@ -138,7 +139,7 @@ fun SelectVersionToDownloadDialog(
138139
modifier = Modifier.weight(0.5f),
139140
onClick = onDismiss
140141
) {
141-
Text(text = stringResource(R.string.generic_cancel))
142+
MarqueeText(text = stringResource(R.string.generic_cancel))
142143
}
143144
Button(
144145
modifier = Modifier.weight(0.5f),
@@ -148,7 +149,7 @@ fun SelectVersionToDownloadDialog(
148149
}
149150
}
150151
) {
151-
Text(text = stringResource(R.string.download_install))
152+
MarqueeText(text = stringResource(R.string.download_install))
152153
}
153154
}
154155
}

0 commit comments

Comments
 (0)