mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-24 11:36:21 +00:00
Merge pull request #752 from cake-tech/receive-screen-issue
CW-284 Fix QR code UI and logic issues
This commit is contained in:
commit
61050ac715
6 changed files with 22 additions and 86 deletions
|
@ -165,14 +165,7 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
||||||
.color!
|
.color!
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
child: QrImage(
|
child: QrImage(data: trade.inputAddress ?? fetchingLabel),
|
||||||
data: trade.inputAddress ?? fetchingLabel,
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
foregroundColor: Theme.of(context)
|
|
||||||
.accentTextTheme!
|
|
||||||
.subtitle2!
|
|
||||||
.color!,
|
|
||||||
),
|
|
||||||
)))),
|
)))),
|
||||||
Spacer(flex: 3)
|
Spacer(flex: 3)
|
||||||
]),
|
]),
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart';
|
import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart';
|
||||||
import 'package:cake_wallet/themes/theme_base.dart';
|
import 'package:cake_wallet/themes/theme_base.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||||
|
|
||||||
class FullscreenQRPage extends BasePage {
|
class FullscreenQRPage extends BasePage {
|
||||||
|
@ -69,14 +68,10 @@ class FullscreenQRPage extends BasePage {
|
||||||
child: AspectRatio(
|
child: AspectRatio(
|
||||||
aspectRatio: 1.0,
|
aspectRatio: 1.0,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.all(5),
|
padding: EdgeInsets.all(10),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(width: 3, color: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!)),
|
border: Border.all(width: 3, color: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!)),
|
||||||
child: QrImage(
|
child: QrImage(data: qrData),
|
||||||
data: qrData,
|
|
||||||
backgroundColor: isLight ? Colors.transparent : Colors.black,
|
|
||||||
foregroundColor: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,30 +1,29 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:qr/qr.dart';
|
import 'package:qr_flutter/qr_flutter.dart' as qr;
|
||||||
import 'package:cake_wallet/src/screens/receive/widgets/qr_painter.dart';
|
|
||||||
|
|
||||||
class QrImage extends StatelessWidget {
|
class QrImage extends StatelessWidget {
|
||||||
QrImage({
|
QrImage({
|
||||||
required String data,
|
required this.data,
|
||||||
this.size = 100.0,
|
this.size = 100.0,
|
||||||
this.backgroundColor,
|
this.version = 9, // Previous value: 7 something happened after flutter upgrade monero wallets addresses are longer than ver. 7 ???
|
||||||
Color foregroundColor = Colors.black,
|
this.errorCorrectionLevel = qr.QrErrorCorrectLevel.L,
|
||||||
int version = 9, // Previous value: 7 something happened after flutter upgrade monero wallets addresses are longer than ver. 7 ???
|
});
|
||||||
int errorCorrectionLevel = QrErrorCorrectLevel.L,
|
|
||||||
}) : _painter = QrPainter(data, foregroundColor, version, errorCorrectionLevel);
|
|
||||||
|
|
||||||
final QrPainter _painter;
|
|
||||||
final Color? backgroundColor;
|
|
||||||
final double size;
|
final double size;
|
||||||
|
final String data;
|
||||||
|
final int version;
|
||||||
|
final int errorCorrectionLevel;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return qr.QrImage(
|
||||||
width: size,
|
data: data,
|
||||||
height: size,
|
errorCorrectionLevel: errorCorrectionLevel,
|
||||||
color: backgroundColor,
|
version: version,
|
||||||
child: CustomPaint(
|
size: size,
|
||||||
painter: _painter,
|
foregroundColor: Colors.black,
|
||||||
),
|
backgroundColor: Colors.white,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,47 +0,0 @@
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:qr/qr.dart';
|
|
||||||
|
|
||||||
class QrPainter extends CustomPainter {
|
|
||||||
QrPainter(
|
|
||||||
String data,
|
|
||||||
this.color,
|
|
||||||
this.version,
|
|
||||||
this.errorCorrectionLevel,
|
|
||||||
) : this._qr = QrCode(version, errorCorrectionLevel)..addData(data) {
|
|
||||||
_p.color = this.color;
|
|
||||||
_qrImage = QrImage(_qr);
|
|
||||||
}
|
|
||||||
|
|
||||||
final int version;
|
|
||||||
final int errorCorrectionLevel;
|
|
||||||
final Color color;
|
|
||||||
|
|
||||||
final QrCode _qr;
|
|
||||||
final _p = Paint()..style = PaintingStyle.fill;
|
|
||||||
late QrImage _qrImage;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void paint(Canvas canvas, Size size) {
|
|
||||||
final squareSize = size.shortestSide / _qr.moduleCount;
|
|
||||||
for (int x = 0; x < _qr.moduleCount; x++) {
|
|
||||||
for (int y = 0; y < _qr.moduleCount; y++) {
|
|
||||||
if (_qrImage.isDark(y, x)) {
|
|
||||||
final squareRect = Rect.fromLTWH(
|
|
||||||
x * squareSize, y * squareSize, squareSize, squareSize);
|
|
||||||
canvas.drawRect(squareRect, _p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool shouldRepaint(CustomPainter oldDelegate) {
|
|
||||||
if (oldDelegate is QrPainter) {
|
|
||||||
return this.color != oldDelegate.color ||
|
|
||||||
this.errorCorrectionLevel != oldDelegate.errorCorrectionLevel ||
|
|
||||||
this.version != oldDelegate.version;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -89,11 +89,7 @@ class QRWidget extends StatelessWidget {
|
||||||
color: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!,
|
color: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: QrImage(
|
child: QrImage(data: addressListViewModel.uri.toString()),
|
||||||
data: addressListViewModel.uri.toString(),
|
|
||||||
backgroundColor: isLight ? Colors.transparent : Colors.black,
|
|
||||||
foregroundColor: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -6,7 +6,7 @@ dependencies:
|
||||||
flutter_cupertino_localizations: ^1.0.1
|
flutter_cupertino_localizations: ^1.0.1
|
||||||
intl: ^0.17.0
|
intl: ^0.17.0
|
||||||
url_launcher: ^6.1.4
|
url_launcher: ^6.1.4
|
||||||
qr: ^3.0.1
|
qr_flutter: ^4.0.0
|
||||||
uuid: 3.0.6
|
uuid: 3.0.6
|
||||||
shared_preferences: ^2.0.15
|
shared_preferences: ^2.0.15
|
||||||
flutter_secure_storage:
|
flutter_secure_storage:
|
||||||
|
|
Loading…
Reference in a new issue