Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jklein24 committed Feb 17, 2023
1 parent 1a40e6a commit 97276f4
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 112 deletions.
104 changes: 50 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Compose QR Code

__A simple, flexible QR code renderer for Jetpack Compose - by *Lightspark*__

| <img src="./docs/images/purple_and_gold.png" width="150px" height="150px" /> | <img src="./docs/images/lightning.png" width="150px" height="150px" /> | <img src="./docs/images/light_smile_square.png" width="150px" height="150px" /> | <img src="./docs/images/dark_smile_circle.png" width="150px" height="150px" /> |
| --- | --- | --- | --- |
|------------------------------------------------------------------------------|------------------------------------------------------------------------|---------------------------------------------------------------------------------|--------------------------------------------------------------------------------|

## Usage

Expand Down Expand Up @@ -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
)
}
}
```

Expand All @@ -64,7 +59,8 @@ fun SmileyPreview() {
</tr>
</table>

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...

<table>
<tr>
Expand All @@ -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))
}
}
}
```

Expand All @@ -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
)
}
)
}
)
}
}
```

Expand All @@ -156,6 +151,7 @@ fun PurpleAndGold() {
</tr>
</table>

## 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.
111 changes: 53 additions & 58 deletions composeqrcode/src/main/java/com/lightspark/composeqr/Examples.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
)
}
})
)
}
}
}

0 comments on commit 97276f4

Please sign in to comment.