-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added cards for permission requesting
Signed-off-by: Arnau Mora <[email protected]>
- Loading branch information
1 parent
d89c3f4
commit 8ad10d9
Showing
2 changed files
with
141 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
app/src/main/java/at/bitfire/icsdroid/ui/reusable/ActionCard.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package at.bitfire.icsdroid.ui.reusable | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material.Card | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Text | ||
import androidx.compose.material.TextButton | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
|
||
/** | ||
* Provides a card with a title, a description, and a button for performing an action. | ||
*/ | ||
@Composable | ||
fun ActionCard( | ||
title: String, | ||
message: String, | ||
actionText: String, | ||
modifier: Modifier = Modifier, | ||
onAction: () -> Unit | ||
) { | ||
Card( | ||
modifier = modifier, | ||
elevation = 3.dp | ||
) { | ||
Column( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(8.dp) | ||
) { | ||
Text( | ||
text = title, | ||
modifier = Modifier.fillMaxWidth(), | ||
style = MaterialTheme.typography.h6 | ||
) | ||
Text( | ||
text = message, | ||
modifier = Modifier.fillMaxWidth(), | ||
style = MaterialTheme.typography.body2 | ||
) | ||
TextButton( | ||
onClick = onAction, | ||
modifier = Modifier.align(Alignment.End) | ||
) { | ||
Text(text = actionText) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun ActionCard_Preview() { | ||
ActionCard( | ||
title = "Testing Card", | ||
message = "This is the message shown in the card. Can be pretty long", | ||
actionText = "Action", | ||
onAction = {} | ||
) | ||
} |