Newer
Older
import 'package:easy_localization/easy_localization.dart';
import '../../../data/models/credit_card_theme_selector.dart';
class CreditCardMini extends StatelessWidget {
const CreditCardMini(
{super.key,
required this.card,
required this.cardIndex,
required this.settingsVisible});
void _showThemeSelector(BuildContext context) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(tr('card_theme_select')),
content: SizedBox(
width: double.maxFinite,
child: CardThemeSelector(
card: card,
onTap: (CreditCardTheme theme) =>
SharedPreferencesHelper().setTheme(theme: theme))),
@override
Widget build(BuildContext context) {
const double cardRadius = 10.0;
final bool bigDevice = bigScreen(context);
final double cardInternalElPadding = bigDevice ? 5 : 6.0;
return Padding(
padding: const EdgeInsets.all(10),
child: settingsVisible
? _buildCard(cardRadius, context, cardInternalElPadding, bigDevice)
: GestureDetector(
onTap: () => onCardTap(context),
child: _buildCard(
cardRadius, context, cardInternalElPadding, bigDevice)));
}
Card _buildCard(double cardRadius, BuildContext context,
double cardInternalElPadding, bool bigDevice) {
return Card(
elevation: 8.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(cardRadius),
),
child: AspectRatio(
aspectRatio: cardAspectRatio,
// 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>[
card.theme.primaryColor,
card.theme.secondaryColor
],
),
child: Padding(
padding: const EdgeInsets.all(10),
child: Stack(children: <Widget>[
if (inDevelopment)
if (!SharedPreferencesHelper().isG1nkgoCard())
Positioned(
top: 60,
right: 0,
child: Visibility(
visible: settingsVisible,
child: FloatingActionButton(
backgroundColor: Colors.transparent,
elevation: 1,
onPressed: () {
SharedPreferencesHelper()
.selectCurrentWalletIndex(0);
SharedPreferencesHelper()
.removeCesiumCard(cardIndex);
Navigator.pop(context);
},
child:
const Icon(Icons.delete, color: Colors.white),
),
Positioned(
top: 0,
right: 0,
child: Visibility(
visible: settingsVisible,
child: FloatingActionButton(
backgroundColor: Colors.transparent,
elevation: 1,
onPressed: () => _showThemeSelector(context),
child:
const Icon(Icons.settings, color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(120, 10, 0, 0),
child: Opacity(
opacity: 0.2,
child: Image.asset('assets/img/gbrevedot_alt.png',
width: 100, height: 100),
)),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
if (card.name.isNotEmpty)
padding: EdgeInsets.symmetric(
horizontal: cardInternalElPadding,
vertical: cardInternalElPadding),
child: Row(children: <Widget>[
Expanded(
child: CardNameText(
currentText: card.name,
onTap: null,
isGinkgoCard: SharedPreferencesHelper()
.isG1nkgoCard(card)),
),
])),
Padding(
padding: EdgeInsets.symmetric(
horizontal: cardInternalElPadding,
vertical: cardInternalElPadding),
child: Row(children: <Widget>[
FittedBox(
fit: BoxFit.scaleDown,
child: Text(
simplifyPubKey(
extractPublicKey(card.pubKey)),
style:
cardTextStyle(context, fontSize: 16),
)),
])),
if (bigDevice) const SizedBox(height: 6.0),
const SizedBox(height: 8.0),
]),
]),
))));
logger("Card ${card.pubKey} '${card.name}' was tapped!");
SharedPreferencesHelper().selectCurrentWallet(card);
Navigator.pop(context);
}