Skip to content

Commit

Permalink
add share translated text option
Browse files Browse the repository at this point in the history
  • Loading branch information
Bnyro committed Sep 17, 2022
1 parent faa63ec commit 4506744
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/src/main/java/com/bnyro/translate/ui/views/TopBar.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.bnyro.translate.ui.views

import android.content.Intent
import androidx.compose.foundation.layout.width
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Clear
import androidx.compose.material.icons.filled.ContentCopy
import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.filled.Share
import androidx.compose.material.icons.outlined.Menu
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.ExperimentalMaterial3Api
Expand Down Expand Up @@ -83,6 +85,23 @@ fun TopBar(
)
}

if (mainModel.translatedText != "") {
StyledIconButton(
imageVector = Icons.Default.Share,
onClick = {
val sendIntent: Intent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, mainModel.translatedText)
type = "text/plain"
}

val shareIntent = Intent.createChooser(sendIntent, null)
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(shareIntent)
}
)
}

if (mainModel.insertedText != "") {
StyledIconButton(
imageVector = Icons.Default.Clear,
Expand Down

0 comments on commit 4506744

Please sign in to comment.