This commit is contained in:
Hitesh Ale
2023-02-26 00:19:20 -05:00
parent c07ce52413
commit 060216cd7c
5 changed files with 318 additions and 1 deletions

View File

@@ -49,7 +49,7 @@ android {
applicationId "com.example.ruswipeshare" applicationId "com.example.ruswipeshare"
// You can update the following values to match your application needs. // You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 19 minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName

258
lib/credit_view.dart Normal file
View File

@@ -0,0 +1,258 @@
import 'package:flutter/material.dart';
import 'package:flutter_credit_card/credit_card_brand.dart';
import 'package:flutter_credit_card/flutter_credit_card.dart';
import 'package:flutter_stripe/flutter_stripe.dart';
void main() => runApp(CreditView());
class CreditView extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return CreditViewState();
}
}
class CreditViewState extends State<CreditView> {
String cardNumber = '';
String expiryDate = '';
String cardHolderName = '';
String cvvCode = '';
bool isCvvFocused = false;
bool useGlassMorphism = false;
bool useBackgroundImage = false;
OutlineInputBorder? border;
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
@override
void initState() {
border = OutlineInputBorder(
borderSide: BorderSide(
color: Colors.grey.withOpacity(0.7),
width: 2.0,
),
);
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Credit Card View Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: ExactAssetImage('assets/bg.png'),
fit: BoxFit.fill,
),
color: Colors.black,
),
child: SafeArea(
child: Column(
children: <Widget>[
const SizedBox(
height: 30,
),
CreditCardWidget(
glassmorphismConfig:
useGlassMorphism ? Glassmorphism.defaultConfig() : null,
cardNumber: cardNumber,
expiryDate: expiryDate,
cardHolderName: cardHolderName,
cvvCode: cvvCode,
bankName: 'Axis Bank',
frontCardBorder:
!useGlassMorphism ? Border.all(color: Colors.grey) : null,
backCardBorder:
!useGlassMorphism ? Border.all(color: Colors.grey) : null,
showBackView: isCvvFocused,
obscureCardNumber: true,
obscureCardCvv: true,
isHolderNameVisible: true,
backgroundImage:
useBackgroundImage ? 'assets/card_bg.png' : null,
isSwipeGestureEnabled: true,
onCreditCardWidgetChange:
(CreditCardBrand creditCardBrand) {},
customCardTypeIcons: <CustomCardTypeIcon>[
CustomCardTypeIcon(
cardType: CardType.mastercard,
cardImage: Image.asset(
'assets/mastercard.png',
height: 48,
width: 48,
),
),
],
),
Expanded(
child: SingleChildScrollView(
child: Column(
children: <Widget>[
CreditCardForm(
formKey: formKey,
obscureCvv: true,
obscureNumber: true,
cardNumber: cardNumber,
cvvCode: cvvCode,
isHolderNameVisible: true,
isCardNumberVisible: true,
isExpiryDateVisible: true,
cardHolderName: cardHolderName,
expiryDate: expiryDate,
themeColor: Colors.blue,
textColor: Colors.white,
cardNumberDecoration: InputDecoration(
labelText: 'Number',
hintText: 'XXXX XXXX XXXX XXXX',
hintStyle: const TextStyle(color: Colors.white),
labelStyle: const TextStyle(color: Colors.white),
focusedBorder: border,
enabledBorder: border,
),
expiryDateDecoration: InputDecoration(
hintStyle: const TextStyle(color: Colors.white),
labelStyle: const TextStyle(color: Colors.white),
focusedBorder: border,
enabledBorder: border,
labelText: 'Expired Date',
hintText: 'XX/XX',
),
cvvCodeDecoration: InputDecoration(
hintStyle: const TextStyle(color: Colors.white),
labelStyle: const TextStyle(color: Colors.white),
focusedBorder: border,
enabledBorder: border,
labelText: 'CVV',
hintText: 'XXX',
),
cardHolderDecoration: InputDecoration(
hintStyle: const TextStyle(color: Colors.white),
labelStyle: const TextStyle(color: Colors.white),
focusedBorder: border,
enabledBorder: border,
labelText: 'Card Holder',
),
onCreditCardModelChange: onCreditCardModelChange,
),
const SizedBox(
height: 20,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'Glassmorphism',
style: TextStyle(
color: Colors.white,
fontSize: 18,
),
),
const Spacer(),
Switch(
value: useGlassMorphism,
inactiveTrackColor: Colors.grey,
activeColor: Colors.white,
onChanged: (bool value) => setState(() {
useGlassMorphism = value;
}),
),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'Card Image',
style: TextStyle(
color: Colors.white,
fontSize: 18,
),
),
const Spacer(),
Switch(
value: useBackgroundImage,
inactiveTrackColor: Colors.grey,
activeColor: Colors.white,
onChanged: (bool value) => setState(() {
useBackgroundImage = value;
}),
),
],
),
),
const SizedBox(
height: 20,
),
GestureDetector(
onTap: _onValidate,
child: Container(
margin: const EdgeInsets.symmetric(
horizontal: 16, vertical: 8),
padding: const EdgeInsets.symmetric(vertical: 15),
width: double.infinity,
alignment: Alignment.center,
child: const Text(
'Validate',
style: TextStyle(
color: Colors.black,
fontFamily: 'halter',
fontSize: 14,
package: 'flutter_credit_card',
),
),
),
),
OutlinedButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all<Color>(Colors.red),
),
onPressed: () { },
child: Text('Complete Setup'),
),
],
),
),
),
],
),
),
),
),
);
}
void _onValidate() {
if (formKey.currentState!.validate()) {
print('valid!');
} else {
print('invalid!');
}
}
void onCreditCardModelChange(CreditCardModel? creditCardModel) {
setState(() {
cardNumber = creditCardModel!.cardNumber;
expiryDate = creditCardModel.expiryDate;
cardHolderName = creditCardModel.cardHolderName;
cvvCode = creditCardModel.cvvCode;
isCvvFocused = creditCardModel.isCvvFocused;
});
}
}

View File

@@ -8,6 +8,8 @@ import 'package:firebase_auth/firebase_auth.dart' show ActionCodeSettings, Fireb
import 'package:flutter/cupertino.dart' hide Title; import 'package:flutter/cupertino.dart' hide Title;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/material.dart' hide Title; import 'package:flutter/material.dart' hide Title;
import 'package:flutter/material.dart';
import 'package:flutter_credit_card/credit_card_brand.dart';
import 'package:flutter_credit_card/flutter_credit_card.dart'; import 'package:flutter_credit_card/flutter_credit_card.dart';
import 'package:flutterfire_ui/auth.dart'; import 'package:flutterfire_ui/auth.dart';
import 'package:flutterfire_ui/src/auth/widgets/internal/loading_button.dart'; import 'package:flutterfire_ui/src/auth/widgets/internal/loading_button.dart';
@@ -19,6 +21,7 @@ import 'package:flutterfire_ui/src/auth/screens/internal/multi_provider_screen.d
import 'package:flutterfire_ui/src/auth/widgets/internal/rebuild_scope.dart'; import 'package:flutterfire_ui/src/auth/widgets/internal/rebuild_scope.dart';
import 'package:flutterfire_ui/src/auth/widgets/internal/subtitle.dart'; import 'package:flutterfire_ui/src/auth/widgets/internal/subtitle.dart';
import 'package:flutterfire_ui/src/auth/widgets/internal/universal_icon_button.dart'; import 'package:flutterfire_ui/src/auth/widgets/internal/universal_icon_button.dart';
import 'package:ruswipeshare/credit_view.dart';
class EditButton extends StatelessWidget { class EditButton extends StatelessWidget {
final bool isEditing; final bool isEditing;
@@ -250,6 +253,13 @@ class ProfileScreenCustom extends MultiProviderScreen {
], ],
...children, ...children,
const SizedBox(height: 300), const SizedBox(height: 300),
TextButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all<Color>(Colors.red),
),
onPressed: () {Navigator.push(context, MaterialPageRoute(builder: (context)=> CreditView())); },
child: Text('Setup Seller'),
),
Align( Align(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: SignOutButton( child: SignOutButton(

View File

@@ -259,6 +259,14 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_stripe:
dependency: "direct main"
description:
name: flutter_stripe
sha256: "00e612c11ea57f9b78510e5b2aa8719022698bd8a023140e9b7f52c1dfa2e27d"
url: "https://pub.dev"
source: hosted
version: "8.0.0+1"
flutter_svg: flutter_svg:
dependency: transitive dependency: transitive
description: description:
@@ -285,6 +293,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.4.3+20" version: "0.4.3+20"
freezed_annotation:
dependency: transitive
description:
name: freezed_annotation
sha256: aeac15850ef1b38ee368d4c53ba9a847e900bb2c53a4db3f6881cbb3cb684338
url: "https://pub.dev"
source: hosted
version: "2.2.0"
geolocator: geolocator:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -405,6 +421,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.6.5" version: "0.6.5"
json_annotation:
dependency: transitive
description:
name: json_annotation
sha256: c33da08e136c3df0190bd5bbe51ae1df4a7d96e7954d1d7249fea2968a72d317
url: "https://pub.dev"
source: hosted
version: "4.8.0"
lints: lints:
dependency: transitive dependency: transitive
description: description:
@@ -554,6 +578,30 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
stripe_android:
dependency: transitive
description:
name: stripe_android
sha256: "3cf43dfb70d8011ded0730c091e741b94cd4aaccaad22732a19f5941503072d6"
url: "https://pub.dev"
source: hosted
version: "8.0.0+1"
stripe_ios:
dependency: transitive
description:
name: stripe_ios
sha256: b3da653013be8aada352b158439024963a0d5dc0648524127d3ef4fd6b0a0cc7
url: "https://pub.dev"
source: hosted
version: "8.0.0"
stripe_platform_interface:
dependency: transitive
description:
name: stripe_platform_interface
sha256: "28c409b0c0e98115c4ab38a9a34a883010811036e6d9fa8d495f67c3ba01c034"
url: "https://pub.dev"
source: hosted
version: "8.0.0"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:

View File

@@ -42,6 +42,7 @@ dependencies:
persistent_bottom_nav_bar: any persistent_bottom_nav_bar: any
geolocator: ^9.0.2 geolocator: ^9.0.2
flutter_credit_card: any flutter_credit_card: any
flutter_stripe: any
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: