From 060216cd7c3f69c809b49213d676617213e4cf15 Mon Sep 17 00:00:00 2001 From: Hitesh Ale Date: Sun, 26 Feb 2023 00:19:20 -0500 Subject: [PATCH] bullshit --- android/app/build.gradle | 2 +- lib/credit_view.dart | 258 +++++++++++++++++++++++++++++++++ lib/profile_screen_custom.dart | 10 ++ pubspec.lock | 48 ++++++ pubspec.yaml | 1 + 5 files changed, 318 insertions(+), 1 deletion(-) create mode 100644 lib/credit_view.dart diff --git a/android/app/build.gradle b/android/app/build.gradle index a67aa5f..0ad32a5 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -49,7 +49,7 @@ android { applicationId "com.example.ruswipeshare" // 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. - minSdkVersion 19 + minSdkVersion 21 targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/lib/credit_view.dart b/lib/credit_view.dart new file mode 100644 index 0000000..08073f2 --- /dev/null +++ b/lib/credit_view.dart @@ -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 createState() { + return CreditViewState(); + } +} + +class CreditViewState extends State { + String cardNumber = ''; + String expiryDate = ''; + String cardHolderName = ''; + String cvvCode = ''; + bool isCvvFocused = false; + bool useGlassMorphism = false; + bool useBackgroundImage = false; + OutlineInputBorder? border; + final GlobalKey formKey = GlobalKey(); + + @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: [ + 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( + cardType: CardType.mastercard, + cardImage: Image.asset( + 'assets/mastercard.png', + height: 48, + width: 48, + ), + ), + ], + ), + Expanded( + child: SingleChildScrollView( + child: Column( + children: [ + 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: [ + 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: [ + 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(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; + }); + } +} \ No newline at end of file diff --git a/lib/profile_screen_custom.dart b/lib/profile_screen_custom.dart index d30657d..991b7a5 100644 --- a/lib/profile_screen_custom.dart +++ b/lib/profile_screen_custom.dart @@ -8,6 +8,8 @@ import 'package:firebase_auth/firebase_auth.dart' show ActionCodeSettings, Fireb import 'package:flutter/cupertino.dart' hide Title; import 'package:flutter/material.dart'; 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:flutterfire_ui/auth.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/subtitle.dart'; import 'package:flutterfire_ui/src/auth/widgets/internal/universal_icon_button.dart'; +import 'package:ruswipeshare/credit_view.dart'; class EditButton extends StatelessWidget { final bool isEditing; @@ -250,6 +253,13 @@ class ProfileScreenCustom extends MultiProviderScreen { ], ...children, const SizedBox(height: 300), + TextButton( + style: ButtonStyle( + foregroundColor: MaterialStateProperty.all(Colors.red), + ), + onPressed: () {Navigator.push(context, MaterialPageRoute(builder: (context)=> CreditView())); }, + child: Text('Setup Seller'), +), Align( alignment: Alignment.bottomCenter, child: SignOutButton( diff --git a/pubspec.lock b/pubspec.lock index b454d87..5d0bf99 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -259,6 +259,14 @@ packages: description: flutter source: sdk 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: dependency: transitive description: @@ -285,6 +293,14 @@ packages: url: "https://pub.dev" source: hosted 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: dependency: "direct main" description: @@ -405,6 +421,14 @@ packages: url: "https://pub.dev" source: hosted 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: dependency: transitive description: @@ -554,6 +578,30 @@ packages: url: "https://pub.dev" source: hosted 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: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 47a5e4d..696c976 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -42,6 +42,7 @@ dependencies: persistent_bottom_nav_bar: any geolocator: ^9.0.2 flutter_credit_card: any + flutter_stripe: any dev_dependencies: flutter_test: