Skip to content

Commit bb124a6

Browse files
ovitrifclaude
andcommitted
refactor: use ToastText() factory constructor
Replace ToastText.Literal() and ToastText.Resource() calls with the cleaner ToastText() factory constructor. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f50889f commit bb124a6

13 files changed

Lines changed: 66 additions & 66 deletions

File tree

app/src/main/java/to/bitkit/ui/NodeInfoScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ fun NodeInfoScreen(
9393
onCopy = { text ->
9494
app.toast(
9595
type = ToastType.SUCCESS,
96-
title = ToastText.Resource(R.string.common__copied),
97-
body = ToastText.Literal(text),
96+
title = ToastText(R.string.common__copied),
97+
body = ToastText(text),
9898
)
9999
},
100100
)

app/src/main/java/to/bitkit/ui/components/ToastView.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -309,44 +309,44 @@ private fun Preview() {
309309
ToastContent(
310310
toast = Toast(
311311
type = ToastType.WARNING,
312-
title = ToastText.Literal("You're still offline"),
313-
body = ToastText.Literal("Check your connection to keep using Bitkit."),
312+
title = ToastText("You're still offline"),
313+
body = ToastText("Check your connection to keep using Bitkit."),
314314
autoHide = true,
315315
),
316316
onDismiss = {},
317317
)
318318
ToastContent(
319319
toast = Toast(
320320
type = ToastType.LIGHTNING,
321-
title = ToastText.Literal("Instant Payments Ready"),
322-
body = ToastText.Literal("You can now pay anyone, anywhere, instantly."),
321+
title = ToastText("Instant Payments Ready"),
322+
body = ToastText("You can now pay anyone, anywhere, instantly."),
323323
autoHide = true,
324324
),
325325
onDismiss = {},
326326
)
327327
ToastContent(
328328
toast = Toast(
329329
type = ToastType.SUCCESS,
330-
title = ToastText.Literal("You're Back Online!"),
331-
body = ToastText.Literal("Successfully reconnected to the Internet."),
330+
title = ToastText("You're Back Online!"),
331+
body = ToastText("Successfully reconnected to the Internet."),
332332
autoHide = true,
333333
),
334334
onDismiss = {},
335335
)
336336
ToastContent(
337337
toast = Toast(
338338
type = ToastType.INFO,
339-
title = ToastText.Literal("General Message"),
340-
body = ToastText.Literal("Used for neutral content to inform the user."),
339+
title = ToastText("General Message"),
340+
body = ToastText("Used for neutral content to inform the user."),
341341
autoHide = false,
342342
),
343343
onDismiss = {},
344344
)
345345
ToastContent(
346346
toast = Toast(
347347
type = ToastType.ERROR,
348-
title = ToastText.Literal("Error Toast"),
349-
body = ToastText.Literal("This is a toast message."),
348+
title = ToastText("Error Toast"),
349+
body = ToastText("This is a toast message."),
350350
autoHide = true,
351351
),
352352
onDismiss = {},

app/src/main/java/to/bitkit/ui/screens/transfer/external/ExternalNodeViewModel.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ class ExternalNodeViewModel @Inject constructor(
100100
if (sats > maxAmount) {
101101
viewModelScope.launch {
102102
toaster.error(
103-
title = ToastText.Resource(R.string.lightning__spending_amount__error_max__title),
104-
body = ToastText.Literal(
103+
title = ToastText(R.string.lightning__spending_amount__error_max__title),
104+
body = ToastText(
105105
context.getString(R.string.lightning__spending_amount__error_max__description)
106106
.replace("{amount}", maxAmount.formatToModernDisplay())
107107
),
@@ -191,8 +191,8 @@ class ExternalNodeViewModel @Inject constructor(
191191
val error = e.message.orEmpty()
192192
Logger.warn("Error opening channel with peer: '${_uiState.value.peer}': '$error'")
193193
toaster.error(
194-
title = ToastText.Resource(R.string.lightning__error_channel_purchase),
195-
body = ToastText.Literal(
194+
title = ToastText(R.string.lightning__error_channel_purchase),
195+
body = ToastText(
196196
context.getString(R.string.lightning__error_channel_setup_msg)
197197
.replace("{raw}", error)
198198
),

app/src/main/java/to/bitkit/ui/screens/transfer/external/LnurlChannelViewModel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ class LnurlChannelViewModel @Inject constructor(
8484

8585
suspend fun errorToast(error: Throwable) {
8686
toaster.error(
87-
title = ToastText.Resource(R.string.other__lnurl_channel_error),
88-
body = ToastText.Literal(error.message ?: context.getString(R.string.common__error_body)),
87+
title = ToastText(R.string.other__lnurl_channel_error),
88+
body = ToastText(error.message ?: context.getString(R.string.common__error_body)),
8989
)
9090
}
9191
}

app/src/main/java/to/bitkit/ui/settings/advanced/AddressViewerScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ fun AddressViewerScreen(
8080
context.setClipboardText(text)
8181
app.toast(
8282
type = ToastType.SUCCESS,
83-
title = ToastText.Resource(R.string.common__copied),
84-
body = ToastText.Literal(text),
83+
title = ToastText(R.string.common__copied),
84+
body = ToastText(text),
8585
)
8686
}
8787
)

app/src/main/java/to/bitkit/ui/settings/advanced/ElectrumConfigScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ fun ElectrumConfigScreen(
7777
if (result.isSuccess) {
7878
app.toast(
7979
type = ToastType.SUCCESS,
80-
title = ToastText.Resource(R.string.settings__es__server_updated_title),
81-
body = ToastText.Literal(
80+
title = ToastText(R.string.settings__es__server_updated_title),
81+
body = ToastText(
8282
context.getString(R.string.settings__es__server_updated_message)
8383
.replace("{host}", uiState.host)
8484
.replace("{port}", uiState.port)

app/src/main/java/to/bitkit/ui/settings/advanced/ElectrumConfigViewModel.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ class ElectrumConfigViewModel @Inject constructor(
248248
val validationError = validateInput()
249249
if (validationError != null) {
250250
toaster.warn(
251-
title = ToastText.Resource(R.string.settings__es__error_peer),
252-
body = ToastText.Literal(validationError),
251+
title = ToastText(R.string.settings__es__error_peer),
252+
body = ToastText(validationError),
253253
)
254254
} else {
255255
connectToServer()
@@ -269,8 +269,8 @@ class ElectrumConfigViewModel @Inject constructor(
269269
val validationError = validateInput(host, port)
270270
if (validationError != null) {
271271
toaster.warn(
272-
title = ToastText.Resource(R.string.settings__es__error_peer),
273-
body = ToastText.Literal(validationError),
272+
title = ToastText(R.string.settings__es__error_peer),
273+
body = ToastText(validationError),
274274
)
275275
return@launch
276276
}

app/src/main/java/to/bitkit/ui/settings/advanced/RgsServerScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ fun RgsServerScreen(
7575
} else {
7676
app.toast(
7777
type = ToastType.ERROR,
78-
title = ToastText.Resource(R.string.wallet__ldk_start_error_title),
79-
body = ToastText.Literal(result.exceptionOrNull()?.message ?: "Unknown error"),
78+
title = ToastText(R.string.wallet__ldk_start_error_title),
79+
body = ToastText(result.exceptionOrNull()?.message ?: "Unknown error"),
8080
testTag = "RgsErrorToast",
8181
)
8282
}

app/src/main/java/to/bitkit/ui/settings/lightning/ChannelDetailScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ fun ChannelDetailScreen(
131131
context.setClipboardText(text)
132132
app.toast(
133133
type = ToastType.SUCCESS,
134-
title = ToastText.Resource(R.string.common__copied),
135-
body = ToastText.Literal(text),
134+
title = ToastText(R.string.common__copied),
135+
body = ToastText(text),
136136
)
137137
},
138138
onOpenUrl = { txId ->

app/src/main/java/to/bitkit/ui/shared/toast/Toaster.kt

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class Toaster @Inject constructor() {
4646
testTag: String? = null,
4747
) = emit(
4848
ToastType.SUCCESS,
49-
ToastText.Resource(title),
50-
body?.let { ToastText.Resource(it) },
49+
ToastText(title),
50+
body?.let { ToastText(it) },
5151
testTag = testTag
5252
)
5353

@@ -57,8 +57,8 @@ class Toaster @Inject constructor() {
5757
testTag: String? = null,
5858
) = emit(
5959
ToastType.INFO,
60-
ToastText.Resource(title),
61-
body?.let { ToastText.Resource(it) },
60+
ToastText(title),
61+
body?.let { ToastText(it) },
6262
testTag = testTag,
6363
)
6464

@@ -68,8 +68,8 @@ class Toaster @Inject constructor() {
6868
testTag: String? = null,
6969
) = emit(
7070
ToastType.LIGHTNING,
71-
ToastText.Resource(title),
72-
body?.let { ToastText.Resource(it) },
71+
ToastText(title),
72+
body?.let { ToastText(it) },
7373
testTag = testTag
7474
)
7575

@@ -79,8 +79,8 @@ class Toaster @Inject constructor() {
7979
testTag: String? = null,
8080
) = emit(
8181
ToastType.WARNING,
82-
ToastText.Resource(title),
83-
body?.let { ToastText.Resource(it) },
82+
ToastText(title),
83+
body?.let { ToastText(it) },
8484
testTag = testTag
8585
)
8686

@@ -90,8 +90,8 @@ class Toaster @Inject constructor() {
9090
testTag: String? = null,
9191
) = emit(
9292
ToastType.ERROR,
93-
ToastText.Resource(title),
94-
body?.let { ToastText.Resource(it) },
93+
ToastText(title),
94+
body?.let { ToastText(it) },
9595
testTag = testTag,
9696
)
9797
// endregion
@@ -135,8 +135,8 @@ class Toaster @Inject constructor() {
135135
testTag: String? = null,
136136
) = emit(
137137
ToastType.SUCCESS,
138-
ToastText.Literal(title),
139-
body?.let { ToastText.Literal(it) },
138+
ToastText(title),
139+
body?.let { ToastText(it) },
140140
testTag = testTag,
141141
)
142142

@@ -146,8 +146,8 @@ class Toaster @Inject constructor() {
146146
testTag: String? = null,
147147
) = emit(
148148
ToastType.INFO,
149-
ToastText.Literal(title),
150-
body?.let { ToastText.Literal(it) },
149+
ToastText(title),
150+
body?.let { ToastText(it) },
151151
testTag = testTag,
152152
)
153153

@@ -157,8 +157,8 @@ class Toaster @Inject constructor() {
157157
testTag: String? = null,
158158
) = emit(
159159
ToastType.LIGHTNING,
160-
ToastText.Literal(title),
161-
body?.let { ToastText.Literal(it) },
160+
ToastText(title),
161+
body?.let { ToastText(it) },
162162
testTag = testTag,
163163
)
164164

@@ -168,8 +168,8 @@ class Toaster @Inject constructor() {
168168
testTag: String? = null,
169169
) = emit(
170170
ToastType.WARNING,
171-
ToastText.Literal(title),
172-
body?.let { ToastText.Literal(it) },
171+
ToastText(title),
172+
body?.let { ToastText(it) },
173173
testTag = testTag,
174174
)
175175

@@ -179,16 +179,16 @@ class Toaster @Inject constructor() {
179179
testTag: String? = null,
180180
) = emit(
181181
ToastType.ERROR,
182-
ToastText.Literal(title),
183-
body?.let { ToastText.Literal(it) },
182+
ToastText(title),
183+
body?.let { ToastText(it) },
184184
testTag = testTag,
185185
)
186186

187187
suspend fun error(throwable: Throwable) = emit(
188188
type = ToastType.ERROR,
189-
title = ToastText.Resource(R.string.common__error),
190-
body = throwable.message?.let { ToastText.Literal(it) }
191-
?: ToastText.Resource(R.string.common__error_body),
189+
title = ToastText(R.string.common__error),
190+
body = throwable.message?.let { ToastText(it) }
191+
?: ToastText(R.string.common__error_body),
192192
)
193193
// endregion
194194
}

0 commit comments

Comments
 (0)