Skip to content

Commit

Permalink
Make a bottomsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
leecam committed Dec 3, 2024
1 parent db8939f commit 367c68a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 30 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<activity
android:name=".createcred.CreateCredentialActivity"
android:exported="true"
android:theme="@style/Theme.CMWallet">
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="androidx.credentials.registry.provider.action.CREATE_CREDENTIAL" />
<category android:name="android.intent.category.DEFAULT" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
Expand All @@ -16,13 +17,23 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.credentials.CreateCredentialRequest
import androidx.credentials.CreateCredentialRequest.DisplayInfo
import androidx.credentials.CreateCredentialResponse
Expand Down Expand Up @@ -68,60 +79,74 @@ class CreateCredentialActivity : ComponentActivity() {
@Composable
fun CreateCredentialScreen(viewModel: CreateCredentialViewModel) {
val uiState = viewModel.uiState
val sheetState = rememberModalBottomSheetState()
var showBottomSheet by remember { mutableStateOf(true) }
LaunchedEffect(uiState.state) {
handleUiResult(uiState.state)
}

Scaffold(
modifier = Modifier.fillMaxSize(),
topBar = {
TopAppBar(
title = {
Text(text = "CMWallet")
}

ModalBottomSheet(
onDismissRequest = {},
sheetState = sheetState
) {
val credential = uiState.credentialToSave

if (credential == null) {
LinearProgressIndicator(
Modifier
.fillMaxWidth()
.padding(horizontal = 2.dp)
)
}
) { innerPadding ->
Column(
modifier = Modifier.padding(innerPadding),
) {
val credential = uiState.credentialToSave
if (credential == null) {
LinearProgressIndicator(
Modifier
.fillMaxWidth()
.padding(horizontal = 2.dp))
} else {
} else {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
) {
Row(
modifier = Modifier
.padding(10.dp)
.fillMaxWidth()
) {
Text(
text = "Review and add to your wallet"
text = "Add to CMWallet",
textAlign = TextAlign.Center,
fontSize = 20.sp
)
}
Row(
modifier = Modifier
.padding(10.dp)
.fillMaxWidth()
) {
CredentialCard(credential, {})
}
// when (val credentialDetails = credential.credential) {
// is MdocCredential -> CredentialClaimList(credentialDetails)
// }

Button(
modifier = Modifier.padding(horizontal = 16.dp),
onClick = {
viewModel.onConfirm()
}
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween
) {
Text("Add to wallet")
TextButton(
modifier = Modifier.padding(20.dp, 10.dp, 10.dp, 20.dp ),
onClick = {
viewModel.onConfirm()
}
) {
Text("Cancel")
}
Button(
modifier = Modifier.padding(10.dp, 10.dp, 20.dp, 20.dp ),
onClick = {
viewModel.onConfirm()
}
) {
Text("Add to wallet")
}
}

}
}

}
}

Expand Down

0 comments on commit 367c68a

Please sign in to comment.