Skip to content

Commit 97276f4

Browse files
committed
Cleanup
1 parent 1a40e6a commit 97276f4

2 files changed

Lines changed: 103 additions & 112 deletions

File tree

README.md

Lines changed: 50 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Compose QR Code
2+
23
__A simple, flexible QR code renderer for Jetpack Compose - by *Lightspark*__
34

45
| <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" /> |
5-
| --- | --- | --- | --- |
6+
|------------------------------------------------------------------------------|------------------------------------------------------------------------|---------------------------------------------------------------------------------|--------------------------------------------------------------------------------|
67

78
## Usage
89

@@ -40,20 +41,14 @@ Meh... Let's spice it up a bit with a smiley face overlay:
4041
fun SmileyPreview() {
4142
QrCodeView(
4243
data = "https://github.com/lightsparkdev/compose-qr-code",
43-
modifier = Modifier.size(300.dp),
44-
overlayContent = {
45-
Box(
46-
contentAlignment = Alignment.Center,
47-
modifier = Modifier.fillMaxSize()
48-
) {
49-
Smile(
50-
modifier = Modifier.fillMaxSize(),
51-
backgroundColor = Color.Yellow,
52-
smileColor = Color.Black
53-
)
54-
}
55-
}
56-
)
44+
modifier = Modifier.size(300.dp)
45+
) {
46+
Smile(
47+
modifier = Modifier.fillMaxSize(),
48+
backgroundColor = Color.Yellow,
49+
smileColor = Color.Black
50+
)
51+
}
5752
}
5853
```
5954

@@ -64,7 +59,8 @@ fun SmileyPreview() {
6459
</tr>
6560
</table>
6661

67-
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...
62+
Cool, I guess we're getting somewhere. What about dark mode? Maybe we can also add some style with
63+
circular dots in the qr code...
6864

6965
<table>
7066
<tr>
@@ -80,21 +76,21 @@ fun SmileyDarkPreview() {
8076
background = Color.Black,
8177
foreground = Color.White
8278
),
83-
dotShape = DotShape.Circle,
84-
overlayContent = {
85-
Box(
86-
contentAlignment = Alignment.Center,
87-
modifier = Modifier
88-
.fillMaxSize()
89-
.clip(RoundedCornerShape(8.dp))
90-
.background(Color.White)
91-
.padding(8.dp)
92-
.clip(RoundedCornerShape(8.dp))
93-
.background(Color.Green)
94-
) {
95-
Smile(modifier = Modifier.fillMaxSize(0.5f))
96-
}
97-
})
79+
dotShape = DotShape.Circle
80+
) {
81+
Box(
82+
contentAlignment = Alignment.Center,
83+
modifier = Modifier
84+
.fillMaxSize()
85+
.clip(RoundedCornerShape(8.dp))
86+
.background(Color.White)
87+
.padding(8.dp)
88+
.clip(RoundedCornerShape(8.dp))
89+
.background(Color.Green)
90+
) {
91+
Smile(modifier = Modifier.fillMaxSize(0.5f))
92+
}
93+
}
9894
}
9995
```
10096

@@ -118,34 +114,33 @@ fun PurpleAndGold() {
118114
val purple = Color(0xFF552583)
119115
val gold = Color(0xFFFDB927)
120116
QrCodeView(
121-
data = URL_DATA,
117+
data = "https://github.com/lightsparkdev/compose-qr-code",
122118
modifier = Modifier.size(300.dp),
123119
colors = QrCodeColors(
124120
background = purple,
125121
foreground = gold
126122
),
127-
dotShape = DotShape.Circle,
128-
overlayContent = {
129-
Box(
130-
contentAlignment = Alignment.Center,
131-
modifier = Modifier
132-
.fillMaxSize()
133-
.clip(CircleShape)
134-
.background(purple)
135-
) {
136-
BasicText(
137-
text = "L",
138-
style = TextStyle.Default.copy(
139-
color = gold,
140-
fontSize = 42.sp,
141-
fontWeight = FontWeight.ExtraBold,
142-
fontStyle = FontStyle.Italic,
143-
fontFamily = FontFamily.Serif
144-
)
123+
dotShape = DotShape.Circle
124+
) {
125+
Box(
126+
contentAlignment = Alignment.Center,
127+
modifier = Modifier
128+
.fillMaxSize()
129+
.clip(CircleShape)
130+
.background(purple)
131+
) {
132+
BasicText(
133+
text = "L",
134+
style = TextStyle.Default.copy(
135+
color = gold,
136+
fontSize = 42.sp,
137+
fontWeight = FontWeight.ExtraBold,
138+
fontStyle = FontStyle.Italic,
139+
fontFamily = FontFamily.Serif
145140
)
146-
}
141+
)
147142
}
148-
)
143+
}
149144
}
150145
```
151146

@@ -156,6 +151,7 @@ fun PurpleAndGold() {
156151
</tr>
157152
</table>
158153

159-
## Acknowledgements
154+
## Acknowledgements
160155

161-
This libraries relies on the great, reliable [zxing](https://github.com/zxing/zxing) library for QR code data generation.
156+
This libraries relies on the great, reliable [zxing](https://github.com/zxing/zxing) library for QR
157+
code data generation.

composeqrcode/src/main/java/com/lightspark/composeqr/Examples.kt

Lines changed: 53 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import androidx.compose.ui.tooling.preview.Preview
2525
import androidx.compose.ui.unit.dp
2626
import androidx.compose.ui.unit.sp
2727

28-
private const val URL_DATA = "https://lightspark.com/?doesnotmatter=this-is-a-test-of-longer-urls-to-see-how-it-looks"
28+
private const val URL_DATA =
29+
"https://lightspark.com/?doesnotmatter=this-is-a-test-of-longer-urls-to-see-how-it-looks"
2930

3031
@Composable
3132
private fun Smile(
@@ -67,6 +68,14 @@ private fun Smile(
6768
}
6869
}
6970

71+
@Preview(showBackground = true)
72+
@Composable
73+
fun BoringPreview() {
74+
QrCodeView(
75+
data = URL_DATA,
76+
modifier = Modifier.size(300.dp)
77+
)
78+
}
7079

7180
@Preview(showBackground = true)
7281
@Composable
@@ -78,21 +87,21 @@ fun SmileyDarkPreview() {
7887
background = Color.Black,
7988
foreground = Color.White
8089
),
81-
dotShape = DotShape.Circle,
82-
overlayContent = {
83-
Box(
84-
contentAlignment = Alignment.Center,
85-
modifier = Modifier
86-
.fillMaxSize()
87-
.clip(RoundedCornerShape(8.dp))
88-
.background(Color.White)
89-
.padding(8.dp)
90-
.clip(RoundedCornerShape(8.dp))
91-
.background(Color.Green)
92-
) {
93-
Smile(modifier = Modifier.fillMaxSize(0.5f))
94-
}
95-
})
90+
dotShape = DotShape.Circle
91+
) {
92+
Box(
93+
contentAlignment = Alignment.Center,
94+
modifier = Modifier
95+
.fillMaxSize()
96+
.clip(RoundedCornerShape(8.dp))
97+
.background(Color.White)
98+
.padding(8.dp)
99+
.clip(RoundedCornerShape(8.dp))
100+
.background(Color.Green)
101+
) {
102+
Smile(modifier = Modifier.fillMaxSize(0.5f))
103+
}
104+
}
96105
}
97106

98107
@Preview(showBackground = true)
@@ -105,28 +114,14 @@ fun SmileyLightSquarePreview() {
105114
background = Color.White,
106115
foreground = Color.Black
107116
),
108-
dotShape = DotShape.Square,
109-
overlayContent = {
110-
Box(
111-
contentAlignment = Alignment.Center,
112-
modifier = Modifier.fillMaxSize()
113-
) {
114-
Smile(
115-
modifier = Modifier.fillMaxSize(),
116-
backgroundColor = Color.Yellow,
117-
smileColor = Color.Black
118-
)
119-
}
120-
})
121-
}
122-
123-
@Preview(showBackground = true)
124-
@Composable
125-
fun BoringPreview() {
126-
QrCodeView(
127-
data = URL_DATA,
128-
modifier = Modifier.size(300.dp)
129-
)
117+
dotShape = DotShape.Square
118+
) {
119+
Smile(
120+
modifier = Modifier.fillMaxSize(),
121+
backgroundColor = Color.Yellow,
122+
smileColor = Color.Black
123+
)
124+
}
130125
}
131126

132127
@Preview(showBackground = true)
@@ -141,25 +136,25 @@ fun PurpleAndGold() {
141136
background = purple,
142137
foreground = gold
143138
),
144-
dotShape = DotShape.Circle,
145-
overlayContent = {
146-
Box(
147-
contentAlignment = Alignment.Center,
148-
modifier = Modifier
149-
.fillMaxSize()
150-
.clip(CircleShape)
151-
.background(purple)
152-
) {
153-
BasicText(
154-
text = "L",
155-
style = TextStyle.Default.copy(
156-
color = gold,
157-
fontSize = 42.sp,
158-
fontWeight = FontWeight.ExtraBold,
159-
fontStyle = FontStyle.Italic,
160-
fontFamily = FontFamily.Serif
161-
)
139+
dotShape = DotShape.Circle
140+
) {
141+
Box(
142+
contentAlignment = Alignment.Center,
143+
modifier = Modifier
144+
.fillMaxSize()
145+
.clip(CircleShape)
146+
.background(purple)
147+
) {
148+
BasicText(
149+
text = "L",
150+
style = TextStyle.Default.copy(
151+
color = gold,
152+
fontSize = 42.sp,
153+
fontWeight = FontWeight.ExtraBold,
154+
fontStyle = FontStyle.Italic,
155+
fontFamily = FontFamily.Serif
162156
)
163-
}
164-
})
157+
)
158+
}
159+
}
165160
}

0 commit comments

Comments
 (0)