Skip to content

Commit

Permalink
fix qr code
Browse files Browse the repository at this point in the history
  • Loading branch information
avan1235 committed Feb 19, 2024
1 parent 84c236b commit be3f5c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
14 changes: 2 additions & 12 deletions composeApp/src/commonMain/kotlin/in/procyk/shin/ui/QrCode.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package `in`.procyk.shin.ui

import androidx.compose.foundation.Image
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import `in`.procyk.compose.qrcode.QrData
import `in`.procyk.compose.qrcode.options.*
import `in`.procyk.compose.qrcode.rememberQrCodePainter

@Composable
internal fun QrCode(url: String) {
val primaryColor = MaterialTheme.colorScheme.primary
val secondaryColor = MaterialTheme.colorScheme.secondary
val painter = rememberQrCodePainter(
data = QrData.text(url),
) {
Expand All @@ -22,13 +18,7 @@ internal fun QrCode(url: String) {
frame = QrFrameShape.roundCorners(.25f)
}
colors {
dark = QrBrush.brush {
Brush.linearGradient(
0f to secondaryColor,
1f to primaryColor,
end = Offset(it, it)
)
}
dark = QrBrush.solid(Color.Black)
}
}
Image(painter, "QR code")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.ClickableText
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -87,11 +88,12 @@ internal fun ShortenResponse(shortenedUrl: String?) {
)
Spacer(Modifier.height(16.dp))
QrCode(uri)
Button(
OutlinedButton(
onClick = { clipboardManager.setText(AnnotatedString(uri)) },
) {
Text("Copy to Clipboard")
}
Spacer(Modifier.height(8.dp))
}
}
}
Expand Down

0 comments on commit be3f5c0

Please sign in to comment.