Skip to content

Commit

Permalink
feat: Added showValidFrom and showValidThru parameters for visibi…
Browse files Browse the repository at this point in the history
…lity control 👁️ (#15)
  • Loading branch information
utpal-barman authored Sep 27, 2023
1 parent 5b34167 commit 9214a9c
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 77 deletions.
71 changes: 39 additions & 32 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,80 +2,87 @@

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

## [1.0.7] 🛠️
## [1.1.0] 🚀

### Feature
### Features

- 📝 Deprecated `disableShowingCardLogo:` property
- Added `creditCardType` to override the logo, so setting `creditCardType: CreditCardTyoe.none` to disable showing card logo
- ✨ Added the ability to `showValidFrom` and `showValidThru` to hide and show the dates.
- `disableShowingCardLogo` has been completely removed. To achieve the same effect, use `creditCardType: CreditCardType.none` instead.

## [1.0.7] 🔄

### Features

- 🚀 Deprecated `disableShowingCardLogo:` property.
- ✨ Added `creditCardType` to override the logo. You can now set `creditCardType: CreditCardType.none` to disable showing the card logo.

## [1.0.6] 🛠️

### Feature
### Features

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

## [1.0.5] 🛠️

### Improvement
### Improvements

- 📝 Improved the readme.

- 📝 Readme improved
## [1.0.4] 🛠️

### Fixed
### Fixes

- 📝 Card numbers with space bug is fixed
- 🐛 Fixed a bug with card numbers containing spaces.

## [1.0.3] 🛠️

### Fixed

- 📝 Card number length is now flexible
- 🚀 Optimized grouping algorithm for improved performance and accuracy
### Fixes

- 🐛 Made card number length flexible.
- 🚀 Optimized the grouping algorithm for improved performance and accuracy.

## [1.0.2] 🖼️

### Added
### Additions

- 📝 Added Background image on card feature
- 📝 Added Card company logo adding feature
- 📝 Type of card can be now specified
- 📸 Added the background image on card feature.
- 🏢 Added the ability to specify the card company logo.
- 🆔 Type of card can now be specified.

## [1.0.1] 📗

### Added
### Additions

- 📝 Updated metadata
- 📝 Updated metadata.

## [1.0.0+5] 👏

### Added
### Additions

- 📝 Updated Documentation
- 📚 Updated documentation.

## [1.0.0+4] 🚀

### Added
### Additions

- 📝 Updated Documentation
- 🎉 Added new property `placeNfcIconAtTheEnd` to place NFC icon at the opposite side of the Chip
- 💄 Chip placed in the correct place
- 📚 Updated documentation.
- 🎉 Added the new property `placeNfcIconAtTheEnd` to place the NFC icon at the opposite side of the Chip.
- 💄 Correctly placed the Chip.

## [1.0.0+3] 🎉

### Added
### Additions

- 📝 Added image in `README.md` file
- 📸 Added an image in the `README.md` file.

## [1.0.0+2] 📝

### Added
### Additions

- 📝 Updated Documentation
- 📚 Updated documentation.

## [1.0.0+1] 🚀

### Added
### Additions

- 🎉 Initial public release
- 🎉 Initial public release.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Add `u_credit_card` to your `pubspec.yaml`:

```yaml
dependencies:
u_credit_card: ^1.0.7
u_credit_card: ^1.1.0
```
Install it:
Expand Down Expand Up @@ -78,7 +78,10 @@ This will create a credit card user interface with the cardholder's name, card n
| `creditCardType` | `CreditCardType` | Specify the type of the credit card payment network logo to display. You can set it to `CreditCardType.none` if you prefer not to specify a card type and not show on the card UI. This is optional. |
| `cardProviderLogo` | `Widget` | Provide a widget for the logo of the card provider. If this parameter is not set, the card will be displayed without a logo. This is optional. |
| `cardProviderLogoPosition` | `CardProviderLogoPosition` | Set the position of the card provider logo on the card. The default value is `CardProviderLogoPosition.right`. You can set it to `CardProviderLogoPosition.left` or `CardProviderLogoPosition.right`. This is optional. |
| `backgroundDecorationImage` | `DecorationImage` | Set a background image for the card. This parameter supports both asset and network images. If this parameter is not set, the card will be displayed without a background image. This is optional. |
| `backgroundDecorationImage` | `DecorationImage` | Set a background image for the card. This parameter supports both asset and network images. If this parameter is not set, the card will be displayed without a background image. This is optional.
| `showValidThru` | `bool` | Indicates whether to show the "Valid Thru" section on the card. If set to `false`, the "Valid Thru" section will be hidden. By default, this value is `true`. |
| `showValidFrom` | `bool` | Indicates whether to show the "Valid From" section on the card. If set to `false`, the "Valid From" section will be hidden. By default, this value is `true`. |

#### Example
``` dart
Expand Down
26 changes: 17 additions & 9 deletions lib/src/u_credit_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ class CreditCardUi extends StatelessWidget {
this.cardProviderLogo,
this.cardProviderLogoPosition = CardProviderLogoPosition.right,
this.backgroundDecorationImage,
@Deprecated('Use `creditCardType: CreditCardType.none` instead')
this.disableShowingCardLogo = false,
this.showValidFrom = true,
this.showValidThru = true,
});

/// Full Name of the Card Holder.
Expand All @@ -96,6 +96,18 @@ class CreditCardUi extends StatelessWidget {
/// Example 01/28, here 01 means month January & 28 means year 2028.
final String validThru;

/// Determines whether to show the "Valid From" segment on the card.
///
/// If set to `true`, the "Valid From" segment will be displayed.
/// If set to `false`, it will be hidden. The default value is `true`.
final bool showValidFrom;

/// Determines whether to show the "Valid Thru" segment on the card.
///
/// If set to `true`, the "Valid Thru" segment will be displayed.
/// If set to `false`, it will be hidden. The default value is `true`.
final bool showValidThru;

/// Top Left Color for the Gradient,
/// by default it's `Colors.purple`.
///
Expand Down Expand Up @@ -154,10 +166,6 @@ class CreditCardUi extends StatelessWidget {
/// Set Background image, can support both asset and network image.
final DecorationImage? backgroundDecorationImage;

/// Disable credit card type logo, just set to `true`.
@Deprecated('Use `creditCardType: CreditCardType.none` instead')
final bool disableShowingCardLogo;

@override
Widget build(BuildContext context) {
final cardNumberMasked = CreditCardHelper.maskCreditCardNumber(
Expand All @@ -184,9 +192,7 @@ class CreditCardUi extends StatelessWidget {
cardNumber: cardNumberMasked,
);

if (disableShowingCardLogo ||
cardLogoString.isEmpty ||
creditCardType == CreditCardType.none) {
if (cardLogoString.isEmpty || creditCardType == CreditCardType.none) {
cardLogoWidget = const SizedBox.shrink();
} else if (creditCardType != null) {
cardLogoWidget = Image.asset(
Expand Down Expand Up @@ -250,6 +256,8 @@ class CreditCardUi extends StatelessWidget {
child: CreditCardValidityView(
validFromMasked: validFromMasked,
validThruMasked: validThruMasked,
showValidFrom: showValidFrom,
showValidThru: showValidThru,
),
),
Positioned(
Expand Down
96 changes: 63 additions & 33 deletions lib/src/ui/credit_card_validity_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class CreditCardValidityView extends StatelessWidget {
super.key,
required this.validFromMasked,
required this.validThruMasked,
this.showValidFrom = true,
this.showValidThru = true,
});

///
Expand All @@ -16,48 +18,76 @@ class CreditCardValidityView extends StatelessWidget {
///
final String validThruMasked;

/// Determines whether to show the "Valid From" segment on the card.
///
/// If set to `true`, the "Valid From" segment will be displayed.
/// If set to `false`, it will be hidden.
/// The default value is `true`.
final bool showValidFrom;

/// Determines whether to show the "Valid Thru" segment on the card.
///
/// If set to `true`, the "Valid Thru" segment will be displayed.
/// If set to `false`, it will be hidden.
/// The default value is `true`.
final bool showValidThru;

@override
Widget build(BuildContext context) {
return Row(
children: [
const SizedBox(
width: 24,
child: Text(
'VALID FROM',
style: TextStyle(
color: Color.fromARGB(255, 200, 200, 200),
fontSize: 5,
height: 1.2,
),
textAlign: TextAlign.center,
Visibility.maintain(
visible: showValidFrom,
child: Row(
children: [
const SizedBox(
width: 24,
child: Text(
'VALID FROM',
style: TextStyle(
color: Color.fromARGB(255, 200, 200, 200),
fontSize: 5,
height: 1.2,
),
textAlign: TextAlign.center,
),
),
if (validFromMasked == null)
const SizedBox(width: 38)
else
CreditCardText(
validFromMasked!,
letterSpacing: 2,
fontSize: 9,
),
],
),
),
if (validFromMasked == null)
const SizedBox(width: 38)
else
CreditCardText(
validFromMasked!,
letterSpacing: 2,
fontSize: 9,
),
const SizedBox(width: 24),
const SizedBox(
width: 24,
child: Text(
'VALID THRU',
style: TextStyle(
color: Color.fromARGB(255, 200, 200, 200),
fontSize: 5,
height: 1.2,
),
textAlign: TextAlign.center,
Visibility.maintain(
visible: showValidThru,
child: Row(
children: [
const SizedBox(
width: 24,
child: Text(
'VALID THRU',
style: TextStyle(
color: Color.fromARGB(255, 200, 200, 200),
fontSize: 5,
height: 1.2,
),
textAlign: TextAlign.center,
),
),
CreditCardText(
validThruMasked,
letterSpacing: 2,
fontSize: 9,
),
],
),
),
CreditCardText(
validThruMasked,
letterSpacing: 2,
fontSize: 9,
),
],
);
}
Expand Down
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.7
version: 1.1.0
homepage: 'https://github.com/utpal-barman/u-credit-card-flutter'

environment:
Expand Down

0 comments on commit 9214a9c

Please sign in to comment.