WIP: trying out bottom sheet for share activity
This commit is contained in:
@ -7,14 +7,20 @@ import androidx.activity.compose.setContent
|
||||
import androidx.activity.viewModels
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Surface
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import app.omnivore.omnivore.ui.theme.OmnivoreTheme
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@AndroidEntryPoint
|
||||
class SaveActivity : ComponentActivity() {
|
||||
@ -47,6 +53,8 @@ class SaveActivity : ComponentActivity() {
|
||||
|
||||
setContent {
|
||||
OmnivoreTheme {
|
||||
//dialog()
|
||||
// saveBottomModal()
|
||||
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colors.background) {
|
||||
Column(
|
||||
verticalArrangement = Arrangement.Center,
|
||||
@ -64,3 +72,85 @@ class SaveActivity : ComponentActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun dialog() {
|
||||
AlertDialog(
|
||||
onDismissRequest = {
|
||||
// Dismiss the dialog when the user clicks outside the dialog or on the back
|
||||
// button. If you want to disable that functionality, simply use an empty
|
||||
// onCloseRequest.
|
||||
// openDialog.value = false
|
||||
},
|
||||
title = {
|
||||
Text(text = "Dialog Title")
|
||||
},
|
||||
text = {
|
||||
Text("Here is a text ")
|
||||
},
|
||||
confirmButton = {
|
||||
Button(
|
||||
onClick = {
|
||||
// openDialog.value = false
|
||||
}) {
|
||||
Text("This is the Confirm Button")
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
Button(
|
||||
onClick = {
|
||||
// openDialog.value = false
|
||||
}) {
|
||||
Text("This is the dismiss Button")
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
@Composable
|
||||
fun saveBottomModal() {
|
||||
val scaffoldState = rememberScaffoldState()
|
||||
val modalBottomSheetState = rememberModalBottomSheetState(ModalBottomSheetValue.HalfExpanded)
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
Scaffold(
|
||||
scaffoldState = scaffoldState,
|
||||
) { innerPadding ->
|
||||
Box(modifier = Modifier.padding(innerPadding)) {
|
||||
Button(onClick = {
|
||||
coroutineScope.launch {
|
||||
modalBottomSheetState.show()
|
||||
}
|
||||
}) {
|
||||
Text(text = "Show")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ModalBottomSheetLayout(
|
||||
sheetState = modalBottomSheetState,
|
||||
sheetContent = {
|
||||
LazyColumn {
|
||||
item {
|
||||
TextButton(modifier = Modifier.fillMaxWidth(), onClick = {
|
||||
// do something
|
||||
}) {
|
||||
Row {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.Add,
|
||||
// painterResource(id = R.drawable.ic_baseline_add_24),
|
||||
contentDescription = "New Album"
|
||||
)
|
||||
Text("New Album")
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user