QR code fullscreen (#390)

* Add fullscreen qr page flow

* Add qr fullscreen text localization

* Add package to control screen brightness when navigating to qr fullscreen and revert when leaving screen

* ios fix trial 1 - Change brightness control package

* Use package imports instead of relevant path
Add Map types
This commit is contained in:
Omar Hatem 2022-06-23 11:25:00 +02:00 committed by GitHub
parent cc96e29eaf
commit 9568c5f932
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 246 additions and 104 deletions

View file

@ -5,6 +5,7 @@
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:name=".Application"

View file

@ -3,7 +3,6 @@ import 'package:cake_wallet/entities/parse_address_from_domain.dart';
import 'package:cake_wallet/entities/wake_lock.dart';
import 'package:cake_wallet/monero/monero.dart';
import 'package:cake_wallet/haven/haven.dart';
import 'package:cake_wallet/haven/haven.dart';
import 'package:cake_wallet/bitcoin/bitcoin.dart';
import 'package:cake_wallet/src/screens/dashboard/widgets/balance_page.dart';
import 'package:cw_core/unspent_coins_info.dart';
@ -125,6 +124,7 @@ import 'package:cake_wallet/entities/template.dart';
import 'package:cake_wallet/exchange/exchange_template.dart';
import 'package:cake_wallet/.secrets.g.dart' as secrets;
import 'package:cake_wallet/src/screens/dashboard/widgets/address_page.dart';
import 'package:cake_wallet/src/screens/receive/fullscreen_qr_page.dart';
final getIt = GetIt.instance;
@ -640,6 +640,9 @@ Future setup(
getIt.registerFactory(() => YatService());
getIt.registerFactory(() => AddressResolver(yatService: getIt.get<YatService>()));
getIt.registerFactoryParam<FullscreenQRPage, String, bool>(
(String qrData, bool isLight) => FullscreenQRPage(qrData: qrData, isLight: isLight,));
_isSetupFinished = true;
}

View file

@ -1,6 +1,5 @@
import 'package:cake_wallet/entities/contact_record.dart';
import 'package:cake_wallet/buy/order.dart';
import 'package:cake_wallet/entities/transaction_description.dart';
import 'package:cake_wallet/src/screens/backup/backup_page.dart';
import 'package:cake_wallet/src/screens/backup/edit_backup_password_page.dart';
import 'package:cake_wallet/src/screens/buy/buy_webview_page.dart';
@ -13,10 +12,7 @@ import 'package:cake_wallet/src/screens/seed/pre_seed_page.dart';
import 'package:cake_wallet/src/screens/support/support_page.dart';
import 'package:cake_wallet/src/screens/unspent_coins/unspent_coins_details_page.dart';
import 'package:cake_wallet/src/screens/unspent_coins/unspent_coins_list_page.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/view_model/buy/buy_view_model.dart';
import 'package:cake_wallet/view_model/monero_account_list/account_list_item.dart';
import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_item.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:cake_wallet/routes.dart';
@ -26,7 +22,6 @@ import 'package:cake_wallet/utils/language_list.dart';
import 'package:cake_wallet/view_model/wallet_new_vm.dart';
import 'package:cake_wallet/view_model/wallet_restoration_from_seed_vm.dart';
import 'package:cake_wallet/view_model/wallet_restoration_from_keys_vm.dart';
import 'package:cake_wallet/entities/contact.dart';
import 'package:cake_wallet/exchange/trade.dart';
import 'package:cw_core/transaction_info.dart';
import 'package:cw_core/wallet_type.dart';
@ -66,16 +61,15 @@ import 'package:cake_wallet/src/screens/exchange/exchange_template_page.dart';
import 'package:cake_wallet/src/screens/exchange_trade/exchange_confirm_page.dart';
import 'package:cake_wallet/src/screens/exchange_trade/exchange_trade_page.dart';
import 'package:flutter/services.dart';
import 'package:hive/hive.dart';
import 'package:cake_wallet/wallet_type_utils.dart';
import 'package:cake_wallet/wallet_types.g.dart';
import 'package:cake_wallet/src/screens/dashboard/widgets/address_page.dart';
import 'package:cake_wallet/src/screens/receive/fullscreen_qr_page.dart';
RouteSettings currentRouteSettings;
Route<dynamic> createRoute(RouteSettings settings) {
currentRouteSettings = settings;
switch (settings.name) {
case Routes.welcome:
return MaterialPageRoute<void>(builder: (_) => createWelcomePage());
@ -84,7 +78,7 @@ Route<dynamic> createRoute(RouteSettings settings) {
return CupertinoPageRoute<void>(
builder: (_) => getIt.get<SetupPinCodePage>(
param1: (PinCodeState<PinCodeWidget> context, dynamic _) {
if (availableWalletTypes.length == 1) {
if (availableWalletTypes.length == 1) {
Navigator.of(context.context).pushNamed(Routes.newWallet, arguments: availableWalletTypes.first);
} else {
Navigator.of(context.context).pushNamed(Routes.newWalletType);
@ -402,6 +396,16 @@ Route<dynamic> createRoute(RouteSettings settings) {
getIt.get<UnspentCoinsDetailsPage>(
param1: args));
case Routes.fullscreenQR:
final args = settings.arguments as Map<String, dynamic>;
return MaterialPageRoute<void>(
builder: (_) =>
getIt.get<FullscreenQRPage>(
param1: args['qrData'] as String,
param2: args['isLight'] as bool,
));
default:
return MaterialPageRoute<void>(
builder: (_) => Scaffold(

View file

@ -60,4 +60,5 @@ class Routes {
static const moneroRestoreWalletFromWelcome = '/monero_restore_wallet';
static const moneroNewWalletFromWelcome = '/monero_new_wallet';
static const addressPage = '/address_page';
static const fullscreenQR = '/fullscreen_qr';
}

View file

@ -0,0 +1,85 @@
import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart';
import 'package:cake_wallet/themes/theme_base.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
class FullscreenQRPage extends BasePage {
FullscreenQRPage({@required this.qrData, @required this.isLight});
final bool isLight;
final String qrData;
@override
Color get backgroundLightColor => currentTheme.type == ThemeType.bright ? Colors.transparent : Colors.white;
@override
Color get backgroundDarkColor => Colors.transparent;
@override
bool get resizeToAvoidBottomInset => false;
@override
Widget leading(BuildContext context) {
final _backButton = Icon(
Icons.arrow_back_ios,
color: Theme.of(context).accentTextTheme.display3.backgroundColor,
size: 16,
);
return SizedBox(
height: 37,
width: 37,
child: ButtonTheme(
minWidth: double.minPositive,
child: FlatButton(
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
padding: EdgeInsets.all(0),
onPressed: () => onClose(context),
child: _backButton,
),
),
);
}
@override
Widget Function(BuildContext, Widget) get rootWrapper => (BuildContext context, Widget scaffold) => Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Theme.of(context).accentColor,
Theme.of(context).scaffoldBackgroundColor,
Theme.of(context).primaryColor,
],
begin: Alignment.topRight,
end: Alignment.bottomLeft,
),
),
child: scaffold);
@override
Widget body(BuildContext context) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: MediaQuery.of(context).size.width * 0.05),
child: Hero(
tag: Key(qrData),
child: Center(
child: AspectRatio(
aspectRatio: 1.0,
child: Container(
padding: EdgeInsets.all(5),
decoration: BoxDecoration(
border: Border.all(width: 3, color: Theme.of(context).accentTextTheme.display3.backgroundColor)),
child: QrImage(
data: qrData,
backgroundColor: isLight ? Colors.transparent : Colors.black,
foregroundColor: Theme.of(context).accentTextTheme.display3.backgroundColor,
),
),
),
),
),
);
}
}

View file

@ -1,4 +1,6 @@
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:device_display_brightness/device_display_brightness.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
@ -38,101 +40,134 @@ class QRWidget extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Row(children: <Widget>[
Spacer(flex: 3),
Observer(
builder: (_) => Flexible(
flex: 5,
child: Center(
child: AspectRatio(
aspectRatio: 1.0,
child: Container(
padding: EdgeInsets.all(5),
decoration: BoxDecoration(
border: Border.all(
width: 3,
color: Theme.of(context).accentTextTheme.
display3.backgroundColor
)
),
child: QrImage(
data: addressListViewModel.uri.toString(),
backgroundColor: isLight ? Colors.transparent : Colors.black,
foregroundColor: Theme.of(context).accentTextTheme.
display3.backgroundColor,
),
))))),
Spacer(flex: 3)
]),
if (isAmountFieldShow)
Column(
children: [
Padding(
padding: EdgeInsets.only(top: 10),
child: Row(
children: <Widget>[
Expanded(
child: Form(
key: _formKey,
child: BaseTextFormField(
focusNode: amountTextFieldFocusNode,
controller: amountController,
keyboardType: TextInputType.numberWithOptions(
decimal: true),
inputFormatters: [
BlacklistingTextInputFormatter(
RegExp('[\\-|\\ ]'))
],
textAlign: TextAlign.center,
hintText: S.of(context).receive_amount,
textColor: Theme.of(context).accentTextTheme.
display3.backgroundColor,
borderColor: Theme.of(context)
.textTheme
.headline
.decorationColor,
validator: AmountValidator(
type: addressListViewModel.type,
isAutovalidate: true),
autovalidate: true,
placeholderTextStyle: TextStyle(
color: Theme.of(context).hoverColor,
fontSize: 18,
fontWeight: FontWeight.w500))))
],
),
padding: const EdgeInsets.only(bottom: 12),
child: Text(
S.of(context).qr_fullscreen,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Theme.of(context).accentTextTheme.display3.backgroundColor),
),
),
Row(
children: <Widget>[
Spacer(flex: 3),
Observer(
builder: (_) => Flexible(
flex: 5,
child: GestureDetector(
onTap: () async {
// Get the current brightness:
final double brightness = await DeviceDisplayBrightness.getBrightness();
// ignore: unawaited_futures
DeviceDisplayBrightness.setBrightness(1.0);
await Navigator.pushNamed(
context,
Routes.fullscreenQR,
arguments: {
'qrData': addressListViewModel.uri.toString(),
'isLight': isLight,
},
);
// ignore: unawaited_futures
DeviceDisplayBrightness.setBrightness(brightness);
},
child: Hero(
tag: Key(addressListViewModel.uri.toString()),
child: Center(
child: AspectRatio(
aspectRatio: 1.0,
child: Container(
padding: EdgeInsets.all(5),
decoration: BoxDecoration(
border: Border.all(
width: 3,
color: Theme.of(context).accentTextTheme.display3.backgroundColor,
),
),
child: QrImage(
data: addressListViewModel.uri.toString(),
backgroundColor: isLight ? Colors.transparent : Colors.black,
foregroundColor: Theme.of(context).accentTextTheme.display3.backgroundColor,
),
),
),
),
),
),
),
),
Spacer(flex: 3)
],
),
],
),
if (isAmountFieldShow)
Padding(
padding: EdgeInsets.only(top: 10),
child: Row(
children: <Widget>[
Expanded(
child: Form(
key: _formKey,
child: BaseTextFormField(
focusNode: amountTextFieldFocusNode,
controller: amountController,
keyboardType: TextInputType.numberWithOptions(decimal: true),
inputFormatters: [BlacklistingTextInputFormatter(RegExp('[\\-|\\ ]'))],
textAlign: TextAlign.center,
hintText: S.of(context).receive_amount,
textColor: Theme.of(context).accentTextTheme.display3.backgroundColor,
borderColor: Theme.of(context).textTheme.headline.decorationColor,
validator: AmountValidator(type: addressListViewModel.type, isAutovalidate: true),
autovalidate: true,
placeholderTextStyle: TextStyle(
color: Theme.of(context).hoverColor,
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
),
),
],
),
),
Padding(
padding: EdgeInsets.only(top: 8, bottom: 8),
child: Builder(
builder: (context) => Observer(
builder: (context) => GestureDetector(
onTap: () {
Clipboard.setData(ClipboardData(
text: addressListViewModel.address.address));
showBar<void>(
context, S.of(context).copied_to_clipboard);
},
child: Row(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Text(
addressListViewModel.address.address,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w500,
color: Theme.of(context).accentTextTheme.
display3.backgroundColor),
),
),
Padding(
padding: EdgeInsets.only(left: 12),
child: copyImage,
)
],
),
))),
builder: (context) => Observer(
builder: (context) => GestureDetector(
onTap: () {
Clipboard.setData(ClipboardData(text: addressListViewModel.address.address));
showBar<void>(context, S.of(context).copied_to_clipboard);
},
child: Row(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Text(
addressListViewModel.address.address,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w500,
color: Theme.of(context).accentTextTheme.display3.backgroundColor),
),
),
Padding(
padding: EdgeInsets.only(left: 12),
child: copyImage,
)
],
),
),
),
),
)
],
);

View file

@ -54,6 +54,7 @@ dependencies:
file_picker: ^3.0.0-nullsafety.2
unorm_dart: ^0.2.0
permission_handler: ^5.0.1+1
device_display_brightness: ^0.0.6
dev_dependencies:
flutter_test:

View file

@ -151,6 +151,7 @@
"subaddresses" : "Unteradressen",
"addresses" : "Adressen",
"scan_qr_code" : "Scannen Sie den QR-Code, um die Adresse zu erhalten",
"qr_fullscreen" : "Tippen Sie hier, um den QR-Code im Vollbildmodus zu öffnen",
"rename" : "Umbenennen",
"choose_account" : "Konto auswählen",
"create_new_account" : "Neues Konto erstellen",

View file

@ -151,6 +151,7 @@
"subaddresses" : "Subaddresses",
"addresses" : "Addresses",
"scan_qr_code" : "Scan the QR code to get the address",
"qr_fullscreen" : "Tap to open full screen QR code",
"rename" : "Rename",
"choose_account" : "Choose account",
"create_new_account" : "Create new account",

View file

@ -151,6 +151,7 @@
"subaddresses" : "Subdirecciones",
"addresses" : "Direcciones",
"scan_qr_code" : "Escanee el código QR para obtener la dirección",
"qr_fullscreen" : "Toque para abrir el código QR en pantalla completa",
"rename" : "Rebautizar",
"choose_account" : "Elegir cuenta",
"create_new_account" : "Crear una nueva cuenta",

View file

@ -149,6 +149,7 @@
"subaddresses" : "Sous-adresses",
"addresses" : "Adresses",
"scan_qr_code" : "Scannez le QR code pour obtenir l'adresse",
"qr_fullscreen" : "Appuyez pour ouvrir le code QR en plein écran",
"rename" : "Renommer",
"choose_account" : "Choisir le compte",
"create_new_account" : "Créer un nouveau compte",

View file

@ -151,6 +151,7 @@
"subaddresses" : "उप पते",
"addresses" : "पतों",
"scan_qr_code" : "पता प्राप्त करने के लिए QR कोड स्कैन करें",
"qr_fullscreen" : "फ़ुल स्क्रीन क्यूआर कोड खोलने के लिए टैप करें",
"rename" : "नाम बदलें",
"choose_account" : "खाता चुनें",
"create_new_account" : "नया खाता बनाएँ",

View file

@ -151,6 +151,7 @@
"subaddresses" : "Podadrese",
"addresses" : "Adrese",
"scan_qr_code" : "Skeniraj QR kod za dobivanje adrese",
"qr_fullscreen" : "Dodirnite za otvaranje QR koda preko cijelog zaslona",
"rename" : "Preimenuj",
"choose_account" : "Odaberi račun",
"create_new_account" : "Izradi novi račun",

View file

@ -151,6 +151,7 @@
"subaddresses" : "Sottoindirizzi",
"addresses" : "Indirizzi",
"scan_qr_code" : "Scansiona il codice QR per ottenere l'indirizzo",
"qr_fullscreen" : "Tocca per aprire il codice QR a schermo intero",
"rename" : "Rinomina",
"choose_account" : "Scegli account",
"create_new_account" : "Crea nuovo account",

View file

@ -151,6 +151,7 @@
"subaddresses" : "サブアドレス",
"addresses" : "住所",
"scan_qr_code" : "QRコードをスキャンして住所を取得します",
"qr_fullscreen" : "タップして全画面QRコードを開く",
"rename" : "リネーム",
"choose_account" : "アカウントを選択",
"create_new_account" : "新しいアカウントを作成する",

View file

@ -151,6 +151,7 @@
"subaddresses" : "하위 주소",
"addresses" : "구애",
"scan_qr_code" : "QR 코드를 스캔하여 주소를 얻습니다.",
"qr_fullscreen" : "전체 화면 QR 코드를 열려면 탭하세요.",
"rename" : "이름 바꾸기",
"choose_account" : "계정을 선택하십시오",
"create_new_account" : "새 계정을 만들",

View file

@ -152,6 +152,7 @@
"rename" : "Hernoemen",
"addresses" : "Adressen",
"scan_qr_code" : "Scan de QR-code om het adres te krijgen",
"qr_fullscreen" : "Tik om de QR-code op volledig scherm te openen",
"choose_account" : "Kies account",
"create_new_account" : "Creëer een nieuw account",
"accounts_subaddresses" : "Accounts en subadressen",

View file

@ -9,9 +9,6 @@
"monero_com": "Monero.com by Cake Wallet",
"monero_com_wallet_text": "Awesome wallet for Monero",
"haven_app": "Haven by Cake Wallet",
"haven_app_wallet_text": "Awesome wallet for Haven",
"haven_app": "Haven by Cake Wallet",
"haven_app_wallet_text": "Awesome wallet for Haven",
@ -154,6 +151,7 @@
"subaddresses" : "Podadresy",
"addresses" : "Adresy",
"scan_qr_code" : "Zeskanuj kod QR, aby uzyskać adres",
"qr_fullscreen" : "Dotknij, aby otworzyć pełnoekranowy kod QR",
"rename" : "Przemianować",
"choose_account" : "Wybierz konto",
"create_new_account" : "Stwórz nowe konto",

View file

@ -151,6 +151,7 @@
"subaddresses" : "Sub-endereços",
"addresses" : "Endereços",
"scan_qr_code" : "Digitalize o código QR para obter o endereço",
"qr_fullscreen" : "Toque para abrir o código QR em tela cheia",
"rename" : "Renomear",
"choose_account" : "Escolha uma conta",
"create_new_account" : "Criar nova conta",

View file

@ -151,6 +151,7 @@
"subaddresses" : "Субадреса",
"addresses" : "Адреса",
"scan_qr_code" : "Отсканируйте QR-код для получения адреса",
"qr_fullscreen" : "Нажмите, чтобы открыть полноэкранный QR-код",
"rename" : "Переименовать",
"choose_account" : "Выберите аккаунт",
"create_new_account" : "Создать новый аккаунт",

View file

@ -151,6 +151,7 @@
"subaddresses" : "Субадреси",
"addresses" : "Адреси",
"scan_qr_code" : "Скануйте QR-код для одержання адреси",
"qr_fullscreen" : "Торкніться, щоб відкрити QR-код на весь екран",
"rename" : "Перейменувати",
"choose_account" : "Оберіть акаунт",
"create_new_account" : "Створити новий акаунт",

View file

@ -151,6 +151,7 @@
"subaddresses" : "子地址",
"addresses" : "地址",
"scan_qr_code" : "扫描二维码获取地址",
"qr_fullscreen" : "点击打开全屏二维码",
"rename" : "重命名",
"choose_account" : "选择账户",
"create_new_account" : "建立新账户",