File tree Expand file tree Collapse file tree
composeqrcode/src/main/java/com/lightspark/composeqr Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ fun QrCodeView(
3636 modifier : Modifier = Modifier ,
3737 colors : QrCodeColors = QrCodeColors .default(),
3838 dotShape : DotShape = DotShape .Square ,
39- encoder : QrEncoder = QrEncoder (),
39+ encoder : QrEncoder = ZxingQrEncoder (),
4040 overlayContent : (@Composable () -> Unit )? = null,
4141) {
4242 Box (modifier = modifier, contentAlignment = Alignment .Center ) {
@@ -70,9 +70,9 @@ fun QrCodeView(
7070 modifier : Modifier = Modifier ,
7171 colors : QrCodeColors = QrCodeColors .default(),
7272 dotShape : DotShape = DotShape .Square ,
73- encoder : QrEncoder = QrEncoder ()
73+ encoder : QrEncoder = ZxingQrEncoder ()
7474) {
75- val encodedData = remember(data, encoder) { encoder(data) }
75+ val encodedData = remember(data, encoder) { encoder.encode (data) }
7676
7777 Canvas (modifier = modifier.background(colors.background)) {
7878 encodedData?.let { matrix ->
Original file line number Diff line number Diff line change @@ -6,10 +6,18 @@ import com.google.zxing.qrcode.encoder.ByteMatrix
66import com.google.zxing.qrcode.encoder.Encoder
77
88/* *
9- * Encodes a string into a QR code ByteMatrix. This is just a small wrapper around the ZXing library with sane defaults.
9+ * Encodes a string into a QR code ByteMatrix. The default implementation, `ZxingQrEncoder` just
10+ * wraps the ZXing library with sane defaults.
1011 */
11- class QrEncoder {
12- operator fun invoke (qrData : String ): ByteMatrix ? {
12+ interface QrEncoder {
13+ fun encode (qrData : String ): ByteMatrix ?
14+ }
15+
16+ /* *
17+ * This is just a small wrapper around the ZXing library with sane defaults.
18+ */
19+ class ZxingQrEncoder : QrEncoder {
20+ override fun encode (qrData : String ): ByteMatrix ? {
1321 return Encoder .encode(
1422 qrData,
1523 ErrorCorrectionLevel .H ,
You can’t perform that action at this time.
0 commit comments