From abb6964555bf6a75b023713e5f57f5660bd19afb Mon Sep 17 00:00:00 2001 From: vjrj <vjrj@comunes.org> Date: Wed, 16 Aug 2023 21:39:57 +0200 Subject: [PATCH] More work with the cards drawer --- lib/ui/widgets/card_drawer.dart | 15 +- .../first_screen/credit_card_mini.dart | 159 +++++++++--------- 2 files changed, 85 insertions(+), 89 deletions(-) diff --git a/lib/ui/widgets/card_drawer.dart b/lib/ui/widgets/card_drawer.dart index 4d6dac9b..488d6a96 100644 --- a/lib/ui/widgets/card_drawer.dart +++ b/lib/ui/widgets/card_drawer.dart @@ -10,6 +10,7 @@ import '../../data/models/cesium_card.dart'; import '../../shared_prefs.dart'; import '../screens/sandbox.dart'; import '../ui_helpers.dart'; +import 'first_screen/card_stack.dart'; class CardDrawer extends StatelessWidget { const CardDrawer({super.key}); @@ -52,17 +53,11 @@ class CardDrawer extends StatelessWidget { const SizedBox( height: 200, child: Center( - child: Text( - 'Cards', - style: TextStyle( - fontSize: 24, - fontWeight: FontWeight.bold, - ), - ), + child: CardStack(), ), ), - if (kReleaseMode) Expanded(child: Container()), - if (!kReleaseMode) + Expanded(child: Container()), + /* if (!kReleaseMode) Expanded( child: Container( decoration: const BoxDecoration( @@ -86,7 +81,7 @@ class CardDrawer extends StatelessWidget { }, ), ), - ), + ), */ if (inDevelopment) ListTile( leading: const Icon(Icons.build), diff --git a/lib/ui/widgets/first_screen/credit_card_mini.dart b/lib/ui/widgets/first_screen/credit_card_mini.dart index 5b1a6224..b38e535d 100644 --- a/lib/ui/widgets/first_screen/credit_card_mini.dart +++ b/lib/ui/widgets/first_screen/credit_card_mini.dart @@ -1,95 +1,96 @@ -import 'package:durt/durt.dart'; -import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; +import '../../../shared_prefs.dart'; import '../../ui_helpers.dart'; +import 'card_name_editable.dart'; import 'card_text_style.dart'; class CreditCardMini extends StatelessWidget { - const CreditCardMini({super.key, required this.wallet}); + const CreditCardMini({super.key, required this.pubKey}); - final CesiumWallet wallet; + final String pubKey; @override Widget build(BuildContext context) { - final String pubKey = wallet.pubkey; const double cardRadius = 10.0; final bool bigDevice = bigScreen(context); - final double cardPadding = bigDevice ? 26.0 : 16.0; - return Card( - elevation: 8.0, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(cardRadius), - ), - child: AspectRatio( - aspectRatio: 1.58, // Credit cart aspect ratio - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(cardRadius), - boxShadow: <BoxShadow>[ - BoxShadow( - color: Colors.grey[400]!, - blurRadius: 10.0, - spreadRadius: 1.0, - ) - ], - gradient: LinearGradient( - begin: Alignment.bottomLeft, - end: Alignment.topRight, - colors: <Color>[ - Color(int.parse("${dotenv.env['CARD_COLOR_LEFT']}")), - Color(int.parse("${dotenv.env['CARD_COLOR_RIGHT']}")), - ], - ), - ), - child: Stack(children: <Widget>[ - Padding( - padding: const EdgeInsets.fromLTRB(160, 10, 0, 0), - child: Opacity( - opacity: 0.1, - child: Image.asset('assets/img/gbrevedot_alt.png'))), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: <Widget>[ - Padding( - padding: EdgeInsets.all(cardPadding), - child: FittedBox( - fit: BoxFit.scaleDown, - child: Text( - dotenv.env['CARD_TEXT'] ?? tr('g1_wallet'), - style: TextStyle( - color: Colors.white, - fontSize: - MediaQuery.of(context).size.width * 0.07, - fontWeight: FontWeight.bold, - ), - )), + final double cardInternalElPadding = bigDevice ? 5 : 6.0; + return Padding( + padding: const EdgeInsets.all(10), + child: Card( + elevation: 8.0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(cardRadius), + ), + child: AspectRatio( + aspectRatio: 1.58, // Credit cart aspect ratio + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(cardRadius), + boxShadow: <BoxShadow>[ + BoxShadow( + color: Colors.grey[400]!, + blurRadius: 3.0, + spreadRadius: 1.0, + ) + ], + gradient: LinearGradient( + begin: Alignment.bottomLeft, + end: Alignment.topRight, + colors: <Color>[ + Color(int.parse("${dotenv.env['CARD_COLOR_LEFT']}")), + Color(int.parse("${dotenv.env['CARD_COLOR_RIGHT']}")), + ], ), - const SizedBox(height: 6.0), - Padding( - padding: - EdgeInsets.symmetric(horizontal: cardPadding), - child: Row(children: <Widget>[ - GestureDetector( - onTap: () => showTooltip( - context, '', tr('keys_tooltip')), - child: FittedBox( - fit: BoxFit.scaleDown, - child: Text('**** **** ', - style: cardTextStyle(context)))), - FittedBox( - fit: BoxFit.scaleDown, - child: Text( - '${pubKey.substring(0, 4)} ${pubKey.substring(4, 8)}', - style: cardTextStyle(context), - )) - ])), - if (bigDevice) const SizedBox(height: 6.0), - const SizedBox(height: 18.0), - ]), - ]), - ))); + ), + child: Padding( + padding: const EdgeInsets.all(10), + child: Stack(children: <Widget>[ + Padding( + padding: const EdgeInsets.fromLTRB(120, 10, 0, 0), + child: Opacity( + opacity: 0.1, + child: Image.asset('assets/img/gbrevedot_alt.png', + width: 100, height: 100), + )), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + // mainAxisAlignment: MainAxisAlignment.start, + children: <Widget>[ + Padding( + padding: EdgeInsets.symmetric( + horizontal: cardInternalElPadding, + vertical: cardInternalElPadding), + child: Row(children: <Widget>[ + Expanded( + child: CardNameText( + currentText: + SharedPreferencesHelper().getName(), + onTap: () {}, + )), + ])), + Padding( + padding: EdgeInsets.symmetric( + horizontal: cardInternalElPadding, + vertical: cardInternalElPadding), + child: Row(children: <Widget>[ + GestureDetector( + onTap: () => showQrDialog( + context: context, + publicKey: pubKey), + child: FittedBox( + fit: BoxFit.scaleDown, + child: Text( + '${pubKey.substring(0, 4)} ${pubKey.substring(4, 8)}', + style: cardTextStyle(context, + fontSize: 16), + ))), + ])), + if (bigDevice) const SizedBox(height: 6.0), + const SizedBox(height: 8.0), + ]), + ]), + ))))); } } -- GitLab