diff --git a/README.md b/README.md
index d635c48..8d0c11e 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,9 @@
# Compose QR Code
+
__A simple, flexible QR code renderer for Jetpack Compose - by *Lightspark*__
| | | | |
-| --- | --- | --- | --- |
+|------------------------------------------------------------------------------|------------------------------------------------------------------------|---------------------------------------------------------------------------------|--------------------------------------------------------------------------------|
## Usage
@@ -40,20 +41,14 @@ Meh... Let's spice it up a bit with a smiley face overlay:
fun SmileyPreview() {
QrCodeView(
data = "https://github.com/lightsparkdev/compose-qr-code",
- modifier = Modifier.size(300.dp),
- overlayContent = {
- Box(
- contentAlignment = Alignment.Center,
- modifier = Modifier.fillMaxSize()
- ) {
- Smile(
- modifier = Modifier.fillMaxSize(),
- backgroundColor = Color.Yellow,
- smileColor = Color.Black
- )
- }
- }
- )
+ modifier = Modifier.size(300.dp)
+ ) {
+ Smile(
+ modifier = Modifier.fillMaxSize(),
+ backgroundColor = Color.Yellow,
+ smileColor = Color.Black
+ )
+ }
}
```
@@ -64,7 +59,8 @@ fun SmileyPreview() {
-Cool, I guess we're getting somewhere. What about dark mode? Maybe we can also add some style with circular dots in the qr code...
+Cool, I guess we're getting somewhere. What about dark mode? Maybe we can also add some style with
+circular dots in the qr code...
@@ -80,21 +76,21 @@ fun SmileyDarkPreview() {
background = Color.Black,
foreground = Color.White
),
- dotShape = DotShape.Circle,
- overlayContent = {
- Box(
- contentAlignment = Alignment.Center,
- modifier = Modifier
- .fillMaxSize()
- .clip(RoundedCornerShape(8.dp))
- .background(Color.White)
- .padding(8.dp)
- .clip(RoundedCornerShape(8.dp))
- .background(Color.Green)
- ) {
- Smile(modifier = Modifier.fillMaxSize(0.5f))
- }
- })
+ dotShape = DotShape.Circle
+ ) {
+ Box(
+ contentAlignment = Alignment.Center,
+ modifier = Modifier
+ .fillMaxSize()
+ .clip(RoundedCornerShape(8.dp))
+ .background(Color.White)
+ .padding(8.dp)
+ .clip(RoundedCornerShape(8.dp))
+ .background(Color.Green)
+ ) {
+ Smile(modifier = Modifier.fillMaxSize(0.5f))
+ }
+ }
}
```
@@ -118,34 +114,33 @@ fun PurpleAndGold() {
val purple = Color(0xFF552583)
val gold = Color(0xFFFDB927)
QrCodeView(
- data = URL_DATA,
+ data = "https://github.com/lightsparkdev/compose-qr-code",
modifier = Modifier.size(300.dp),
colors = QrCodeColors(
background = purple,
foreground = gold
),
- dotShape = DotShape.Circle,
- overlayContent = {
- Box(
- contentAlignment = Alignment.Center,
- modifier = Modifier
- .fillMaxSize()
- .clip(CircleShape)
- .background(purple)
- ) {
- BasicText(
- text = "L",
- style = TextStyle.Default.copy(
- color = gold,
- fontSize = 42.sp,
- fontWeight = FontWeight.ExtraBold,
- fontStyle = FontStyle.Italic,
- fontFamily = FontFamily.Serif
- )
+ dotShape = DotShape.Circle
+ ) {
+ Box(
+ contentAlignment = Alignment.Center,
+ modifier = Modifier
+ .fillMaxSize()
+ .clip(CircleShape)
+ .background(purple)
+ ) {
+ BasicText(
+ text = "L",
+ style = TextStyle.Default.copy(
+ color = gold,
+ fontSize = 42.sp,
+ fontWeight = FontWeight.ExtraBold,
+ fontStyle = FontStyle.Italic,
+ fontFamily = FontFamily.Serif
)
- }
+ )
}
- )
+ }
}
```
@@ -156,6 +151,7 @@ fun PurpleAndGold() {
-## Acknowledgements
+## Acknowledgements
-This libraries relies on the great, reliable [zxing](https://github.com/zxing/zxing) library for QR code data generation.
+This libraries relies on the great, reliable [zxing](https://github.com/zxing/zxing) library for QR
+code data generation.
diff --git a/composeqrcode/src/main/java/com/lightspark/composeqr/Examples.kt b/composeqrcode/src/main/java/com/lightspark/composeqr/Examples.kt
index 36e9159..e61cee4 100644
--- a/composeqrcode/src/main/java/com/lightspark/composeqr/Examples.kt
+++ b/composeqrcode/src/main/java/com/lightspark/composeqr/Examples.kt
@@ -25,7 +25,8 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
-private const val URL_DATA = "https://lightspark.com/?doesnotmatter=this-is-a-test-of-longer-urls-to-see-how-it-looks"
+private const val URL_DATA =
+ "https://lightspark.com/?doesnotmatter=this-is-a-test-of-longer-urls-to-see-how-it-looks"
@Composable
private fun Smile(
@@ -67,6 +68,14 @@ private fun Smile(
}
}
+@Preview(showBackground = true)
+@Composable
+fun BoringPreview() {
+ QrCodeView(
+ data = URL_DATA,
+ modifier = Modifier.size(300.dp)
+ )
+}
@Preview(showBackground = true)
@Composable
@@ -78,21 +87,21 @@ fun SmileyDarkPreview() {
background = Color.Black,
foreground = Color.White
),
- dotShape = DotShape.Circle,
- overlayContent = {
- Box(
- contentAlignment = Alignment.Center,
- modifier = Modifier
- .fillMaxSize()
- .clip(RoundedCornerShape(8.dp))
- .background(Color.White)
- .padding(8.dp)
- .clip(RoundedCornerShape(8.dp))
- .background(Color.Green)
- ) {
- Smile(modifier = Modifier.fillMaxSize(0.5f))
- }
- })
+ dotShape = DotShape.Circle
+ ) {
+ Box(
+ contentAlignment = Alignment.Center,
+ modifier = Modifier
+ .fillMaxSize()
+ .clip(RoundedCornerShape(8.dp))
+ .background(Color.White)
+ .padding(8.dp)
+ .clip(RoundedCornerShape(8.dp))
+ .background(Color.Green)
+ ) {
+ Smile(modifier = Modifier.fillMaxSize(0.5f))
+ }
+ }
}
@Preview(showBackground = true)
@@ -105,28 +114,14 @@ fun SmileyLightSquarePreview() {
background = Color.White,
foreground = Color.Black
),
- dotShape = DotShape.Square,
- overlayContent = {
- Box(
- contentAlignment = Alignment.Center,
- modifier = Modifier.fillMaxSize()
- ) {
- Smile(
- modifier = Modifier.fillMaxSize(),
- backgroundColor = Color.Yellow,
- smileColor = Color.Black
- )
- }
- })
-}
-
-@Preview(showBackground = true)
-@Composable
-fun BoringPreview() {
- QrCodeView(
- data = URL_DATA,
- modifier = Modifier.size(300.dp)
- )
+ dotShape = DotShape.Square
+ ) {
+ Smile(
+ modifier = Modifier.fillMaxSize(),
+ backgroundColor = Color.Yellow,
+ smileColor = Color.Black
+ )
+ }
}
@Preview(showBackground = true)
@@ -141,25 +136,25 @@ fun PurpleAndGold() {
background = purple,
foreground = gold
),
- dotShape = DotShape.Circle,
- overlayContent = {
- Box(
- contentAlignment = Alignment.Center,
- modifier = Modifier
- .fillMaxSize()
- .clip(CircleShape)
- .background(purple)
- ) {
- BasicText(
- text = "L",
- style = TextStyle.Default.copy(
- color = gold,
- fontSize = 42.sp,
- fontWeight = FontWeight.ExtraBold,
- fontStyle = FontStyle.Italic,
- fontFamily = FontFamily.Serif
- )
+ dotShape = DotShape.Circle
+ ) {
+ Box(
+ contentAlignment = Alignment.Center,
+ modifier = Modifier
+ .fillMaxSize()
+ .clip(CircleShape)
+ .background(purple)
+ ) {
+ BasicText(
+ text = "L",
+ style = TextStyle.Default.copy(
+ color = gold,
+ fontSize = 42.sp,
+ fontWeight = FontWeight.ExtraBold,
+ fontStyle = FontStyle.Italic,
+ fontFamily = FontFamily.Serif
)
- }
- })
+ )
+ }
+ }
}