Skip to content

Commit

Permalink
Change the way Toast object gets created with Copy button
Browse files Browse the repository at this point in the history
  • Loading branch information
mrghosti3 committed Apr 7, 2024
1 parent 42ed507 commit d121651
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.core.content.ContextCompat.getString
import com.starry.greenstash.R
import com.starry.greenstash.utils.toToast

@ExperimentalMaterial3Api
@Composable
Expand Down Expand Up @@ -184,7 +186,8 @@ fun ExpandableTextCard(
FilledTonalButton(onClick = {
clipboardManager.setText(AnnotatedString(description))
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S_V2) {
Toast.makeText(context, R.string.info_copy_alert, Toast.LENGTH_SHORT).show()
getString(context, R.string.info_copy_alert)
.toToast(context, Toast.LENGTH_SHORT)
}
}) {
Row {
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/starry/greenstash/utils/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ fun LazyListState.isScrollingUp(): Boolean {
}.value
}


/**
* Creates and shows a toast message.
*/
fun String.toToast(context: Context, length: Int = Toast.LENGTH_SHORT) {
Toast.makeText(context, this, length).show()
}
Expand Down

0 comments on commit d121651

Please sign in to comment.