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)
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
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(
'${card.pubKey.substring(0, 4)} ${card.pubKey.substring(4, 8)}',
style:
cardTextStyle(context, fontSize: 16),
)),
])),
if (bigDevice) const SizedBox(height: 6.0),
const SizedBox(height: 8.0),
]),
]),
))));
SharedPreferencesHelper().selectCurrentWallet(card);
Navigator.pop(context);
}