Skip to content

Commit

Permalink
feat: added disableShowingCardLogo property (#10)
Browse files Browse the repository at this point in the history
utpal-barman authored Aug 10, 2023
1 parent f42c441 commit ed3166e
Showing 6 changed files with 26 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file.

## [1.0.6] 🛠️

### Feature

- 📝 Added `disableShowingCardLogo:` property to hide the card logo

## [1.0.5] 🛠️

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -150,6 +150,8 @@ CreditCardUi(
),
```

If you want to disable the card logo you can pass `disableShowingCardLogo: true`, but this property was introduced after v1.0.6

#### Additional Customizations
To further customize the card, you can add a background image by using the `backgroundDecorationImage` property. Additionally, you can include a logo for the card provider using the `cardProviderLogo` property. This logo can be positioned on either the left or the right side of the card using the `cardProviderLogoPosition` property.

2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ class MyHomePage extends StatelessWidget {
body: const Center(
child: CreditCardUi(
cardHolderFullName: 'John Doe',
cardNumber: '1234567812345678',
cardNumber: '4123456781234567',
validFrom: '01/23',
validThru: '01/28',
topLeftColor: Colors.blue,
20 changes: 16 additions & 4 deletions lib/src/u_credit_card.dart
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@ class CreditCardUi extends StatelessWidget {
this.cardProviderLogo,
this.cardProviderLogoPosition = CardProviderLogoPosition.right,
this.backgroundDecorationImage,
this.disableShowingCardLogo = false,
});

/// Full Name of the Card Holder
@@ -126,6 +127,9 @@ class CreditCardUi extends StatelessWidget {
/// Set Background image, can support both asset and network image
final DecorationImage? backgroundDecorationImage;

/// Disable card type logo, just set to `true`
final bool disableShowingCardLogo;

@override
Widget build(BuildContext context) {
final cardNumberMasked = CreditCardHelper.maskCreditCardNumber(
@@ -147,6 +151,17 @@ class CreditCardUi extends StatelessWidget {
topLeftColor,
);

Widget cardLogoWidget;
final cardLogoString = CreditCardHelper.getCardLogo(cardNumberMasked);
if (disableShowingCardLogo || cardLogoString.isEmpty) {
cardLogoWidget = const SizedBox.shrink();
} else {
cardLogoWidget = Image.asset(
CreditCardHelper.getCardLogo(cardNumberMasked),
package: UiConstants.packageName,
);
}

return Transform.scale(
scale: scale,
child: SizedBox(
@@ -207,10 +222,7 @@ class CreditCardUi extends StatelessWidget {
duration: UiConstants.animationDuration,
child: Container(
key: ValueKey(cardNumberMasked),
child: Image.asset(
CreditCardHelper.getCardLogo(cardNumberMasked),
package: UiConstants.packageName,
),
child: cardLogoWidget,
),
),
),
2 changes: 1 addition & 1 deletion lib/src/utils/credit_card_helper.dart
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ class CreditCardHelper {
case CreditCardType.discover:
return Assets.discoverLogo;
case CreditCardType.other:
return Assets.visaLogo;
return '';
}
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: u_credit_card
description: uCreditCard - Easy to use beautiful Card UI Flutter Package.
version: 1.0.5
version: 1.0.6
homepage: 'https://github.com/utpal-barman/u-credit-card-flutter'

environment:

0 comments on commit ed3166e

Please sign in to comment.