Skip to content

Commit

Permalink
Merge pull request #88 from shalva97/add_toolbar
Browse files Browse the repository at this point in the history
add copy button
  • Loading branch information
shalva97 authored Mar 30, 2023
2 parents bde35eb + eb84d29 commit 61ad4ed
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions multiplatform-ui/src/commonMain/kotlin/ui/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ package ui
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.CopyAll
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.unit.dp
import data.HistoryFilesRepository
import di.kodein
Expand All @@ -31,8 +35,21 @@ fun HomeScreen() {
var selectedTab by remember { mutableStateOf(HomeTab.HISTORY) }
val localScope = rememberCoroutineScope()

Scaffold {
Row {
Scaffold(topBar = {
TopAppBar({
Text("Youtube History Parser")
}, actions = {
if (selectedTab == HomeTab.HISTORY) {
val clipboardManager = LocalClipboardManager.current
IconButton({
clipboardManager.setText(AnnotatedString(viewModel.getHistoryAsMarkdown()))
}) {
Icon(Icons.Filled.CopyAll, contentDescription = "Copy all")
}
}
})
}) {
Row(modifier = Modifier.padding(it)) {
NavigationRail {
FloatingActionButton(onClick = {
localScope.launch {
Expand Down Expand Up @@ -71,5 +88,7 @@ class HomeScreenViewModel : DIAware {
historyFilesRepository.selectedFiles.tryEmit(files)
}

fun getHistoryAsMarkdown() = historyFilesRepository.markdownText.value

override val di: DI = kodein
}
}

0 comments on commit 61ad4ed

Please sign in to comment.