Advertisement
mactech24

pallet generator

May 29th, 2025
554
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 15.95 KB | None | 0 0
  1. // ignore_for_file: avoid_unnecessary_containers, sized_box_for_whitespace
  2.  
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_phosphor_icons/flutter_phosphor_icons.dart';
  5. import 'package:google_fonts/google_fonts.dart';
  6. import 'package:hooks_riverpod/hooks_riverpod.dart';
  7. import 'package:monita/router/app_router.dart';
  8. import 'package:monita/screens/Transfer/sendMoney/widget/send_money_model.dart';
  9. import 'package:monita/utils/utils_size.dart';
  10. import 'package:monita/widgets/appbar.dart';
  11. import 'package:monita/widgets/global_widgets.dart';
  12. import 'package:monita/widgets/icon_widget.dart';
  13. import 'package:palette_generator/palette_generator.dart';
  14. import '../../../constants/constants.dart';
  15. import '../../../controller/general_provider.dart';
  16.  
  17. class SendMoneyScreen extends StatefulWidget {
  18.   const SendMoneyScreen({super.key});
  19.   static String routeName = "/sendMoneyScreen";
  20.  
  21.   @override
  22.   _SendMoneyScreenState createState() => _SendMoneyScreenState();
  23. }
  24.  
  25. class _SendMoneyScreenState extends State<SendMoneyScreen> {
  26.   @override
  27.   Widget build(BuildContext context) {
  28.     SizeConfig().init(context);
  29.     Size size = MediaQuery.of(context).size;
  30.     return Consumer(
  31.       builder: (_, ref, __) {
  32.         return Scaffold(
  33.           backgroundColor:
  34.               ref.watch(generalNotifierProvider) ? lightBlack : darkLemond2,
  35.           appBar: AppBar(
  36.             backgroundColor:
  37.                 ref.watch(generalNotifierProvider) ? lightBlack : darkLemond2,
  38.             surfaceTintColor: transparent,
  39.             automaticallyImplyLeading: false,
  40.             elevation: 0,
  41.             title: Column(
  42.               mainAxisAlignment: MainAxisAlignment.spaceBetween,
  43.               children: [
  44.                 appBar1(context, sendMoneyToText,
  45.                     titleColor:
  46.                         ref.watch(generalNotifierProvider) ? white : white),
  47.               ],
  48.             ),
  49.             centerTitle: true,
  50.           ),
  51.           body: Column(
  52.             children: [
  53.               verticalSpace(getProportionateScreenHeight(20)),
  54.               Padding(
  55.                 padding: EdgeInsets.symmetric(
  56.                   horizontal: getProportionateScreenWidth(15),
  57.                 ),
  58.                 child: buildSearchField(
  59.                   borderColor: transparent,
  60.                   background: ref.watch(generalNotifierProvider)
  61.                       ? primaryBaseDarkmode
  62.                       : const Color(0xFF5e6c0b),
  63.                   hintText: "Search Bannk or Beneficiary",
  64.                   prifixIconColor: ref.watch(generalNotifierProvider)
  65.                       ? white.withOpacity(0.72)
  66.                       : white.withOpacity(0.72),
  67.                   hintTextColor: ref.watch(generalNotifierProvider)
  68.                       ? white.withOpacity(0.72)
  69.                       : white.withOpacity(0.72),
  70.                   textColor: ref.watch(generalNotifierProvider)
  71.                       ? white.withOpacity(0.72)
  72.                       : white.withOpacity(0.72),
  73.                   onChanged: (value) {},
  74.                 ),
  75.               ),
  76.               verticalSpace(getProportionateScreenHeight(20)),
  77.               Expanded(
  78.                 child: Container(
  79.                   width: size.width,
  80.                   decoration: BoxDecoration(
  81.                       color: ref.watch(generalNotifierProvider)
  82.                           ? primaryBaseDarkmode
  83.                           : white,
  84.                       borderRadius: const BorderRadius.vertical(
  85.                         top: Radius.circular(30),
  86.                       )),
  87.                   child: const SendMoneyContent(),
  88.                 ),
  89.               )
  90.             ],
  91.           ),
  92.         );
  93.       },
  94.     );
  95.   }
  96. }
  97.  
  98. class SendMoneyContent extends StatelessWidget {
  99.   const SendMoneyContent({super.key});
  100.  
  101.   @override
  102.   Widget build(BuildContext context) {
  103.     return ListView(
  104.       padding: const EdgeInsets.all(16),
  105.       children: [
  106.         const RecentBeneficiaries(),
  107.         const SizedBox(height: 16),
  108.         BankListSection(),
  109.       ],
  110.     );
  111.   }
  112. }
  113.  
  114. class RecentBeneficiaries extends StatefulWidget {
  115.   const RecentBeneficiaries({
  116.     super.key,
  117.   });
  118.  
  119.   @override
  120.   State<RecentBeneficiaries> createState() => _RecentBeneficiariesState();
  121. }
  122.  
  123. class _RecentBeneficiariesState extends State<RecentBeneficiaries> {
  124.   Color backgroundColor = Colors.grey.shade200;
  125.   final List<BeneficiaryBank> beneficiaryList = [
  126.     const BeneficiaryBank(
  127.       firstName: "Macsmith",
  128.       lastName: "Okorie",
  129.       imagePath: "assets/banks/firstbank.png",
  130.     ),
  131.     const BeneficiaryBank(
  132.       firstName: "Emmanuel",
  133.       lastName: "Omobude",
  134.       imagePath: "assets/banks/paycom.png",
  135.     ),
  136.     const BeneficiaryBank(
  137.       firstName: "Toheeb",
  138.       lastName: "Asuwanju",
  139.       imagePath: "assets/banks/stanbic-ibtc-bank.png",
  140.     ),
  141.     const BeneficiaryBank(
  142.       firstName: "Musa",
  143.       lastName: "Babalola",
  144.       imagePath: "assets/banks/jaiz-bank.png",
  145.     ),
  146.     const BeneficiaryBank(
  147.       firstName: "Tola",
  148.       lastName: "Timothy",
  149.       imagePath: "assets/banks/suntrust-bank.png",
  150.     ),
  151.     const BeneficiaryBank(
  152.       firstName: "Mary",
  153.       lastName: "Bisola",
  154.       imagePath: "assets/banks/gtb.png",
  155.     ),
  156.     const BeneficiaryBank(
  157.       firstName: "Tola",
  158.       lastName: "Timothy",
  159.       imagePath: "assets/banks/sterling-bank.png",
  160.     ),
  161.   ];
  162.  
  163.   @override
  164.   void initState() {
  165.     super.initState();
  166.     _updatePalette();
  167.   }
  168.  
  169.   Color lightenColor(Color color, [double amount = 0.3]) {
  170.     final hsl = HSLColor.fromColor(color);
  171.     final lightened =
  172.         hsl.withLightness((hsl.lightness + amount).clamp(0.0, 1.0));
  173.     return lightened.toColor();
  174.   }
  175.  
  176.   Future<void> _updatePalette() async {
  177.     final imageProvider = AssetImage(beneficiaryList[0].imagePath);
  178.  
  179.     final paletteGenerator = await PaletteGenerator.fromImageProvider(
  180.       imageProvider,
  181.       size: const Size(300, 300),
  182.       maximumColorCount: 20,
  183.     );
  184.  
  185.     Color? rawColor = paletteGenerator.dominantColor?.color ??
  186.         paletteGenerator.vibrantColor?.color ??
  187.         paletteGenerator.mutedColor?.color;
  188.  
  189.     setState(() {
  190.       backgroundColor = rawColor != null
  191.           ? lightenColor(rawColor, 0.4) // You can adjust brightness (0.1–0.5)
  192.           : Colors.grey.shade200;
  193.     });
  194.   }
  195.  
  196.   @override
  197.   Widget build(BuildContext context) {
  198.     return Consumer(builder: (_, ref, __) {
  199.       return Column(
  200.         crossAxisAlignment: CrossAxisAlignment.start,
  201.         children: [
  202.           verticalSpace(getProportionateScreenHeight(10)),
  203.           textWidget(
  204.             "Recents",
  205.             fontWeight: FontWeight.w700,
  206.             fontSize: getProportionateScreenWidth(17),
  207.             color: ref.watch(generalNotifierProvider) ? white : lightBlack,
  208.           ),
  209.           verticalSpace(getProportionateScreenHeight(10)),
  210.           SizedBox(
  211.             height: getProportionateScreenHeight(90),
  212.             child: ListView.separated(
  213.               scrollDirection: Axis.horizontal,
  214.               itemCount: beneficiaryList.length,
  215.               itemBuilder: (context, index) {
  216.                 final beneficiary = beneficiaryList[index];
  217.                 return RecentBeneficiaryCards(beneficiaryBank: beneficiary);
  218.               },
  219.               separatorBuilder: (_, __) => const SizedBox(width: 16),
  220.             ),
  221.           ),
  222.         ],
  223.       );
  224.     });
  225.   }
  226. }
  227.  
  228. class BankListSection extends StatelessWidget {
  229.   BankListSection({super.key});
  230.  
  231.   final List<Bank> banks = [
  232.     const Bank(name: "Kuda Bank", imagePath: "assets/banks/kuda-bank.png"),
  233.     const Bank(
  234.         name: "First Bank Of Nigeria", imagePath: "assets/banks/firstbank.png"),
  235.     const Bank(name: "Fidelity Bank", imagePath: "assets/banks/fidelity.png"),
  236.     const Bank(
  237.         name: "United Bank for Africa",
  238.         imagePath: "assets/banks/united-bank-for-africa.png"),
  239.     const Bank(
  240.         name: "Sterling Bank", imagePath: "assets/banks/sterling-bank.png"),
  241.     const Bank(name: "Jaiz Bank", imagePath: "assets/banks/jaiz-bank.png"),
  242.     const Bank(name: "Paycom", imagePath: "assets/banks/paycom.png"),
  243.     const Bank(name: "GTB", imagePath: "assets/banks/gtb.png"),
  244.     const Bank(
  245.         name: "Stanbic IBTC Bank",
  246.         imagePath: "assets/banks/stanbic-ibtc-bank.png"),
  247.     const Bank(
  248.         name: "Suntrust Bank", imagePath: "assets/banks/suntrust-bank.png"),
  249.     const Bank(name: "Zenith Bank", imagePath: "assets/banks/zenith-bank.png"),
  250.     const Bank(name: "Wema Bank", imagePath: "assets/banks/wema-bank.png"),
  251.   ];
  252.  
  253.   @override
  254.   Widget build(BuildContext context) {
  255.     return Consumer(builder: (_, ref, __) {
  256.       return Column(
  257.         crossAxisAlignment: CrossAxisAlignment.start,
  258.         children: [
  259.           textWidget(
  260.             "Select Bank",
  261.             fontWeight: FontWeight.w700,
  262.             fontSize: getProportionateScreenWidth(17),
  263.             color: ref.watch(generalNotifierProvider) ? white : lightBlack,
  264.           ),
  265.           verticalSpace(getProportionateScreenHeight(10)),
  266.           ...banks.map((bank) {
  267.             return BankTile(
  268.               bank: bank,
  269.               onTap: () {
  270.                 ref
  271.                     .read(routerProvider)
  272.                     .pushNamed(AppRoute.sendMoneyContinueScreen.name);
  273.               },
  274.             );
  275.           }),
  276.         ],
  277.       );
  278.     });
  279.   }
  280. }
  281.  
  282. class BankTile extends StatefulWidget {
  283.   final Bank bank;
  284.  
  285.   final VoidCallback? onTap;
  286.   const BankTile({
  287.     super.key,
  288.     required this.bank,
  289.     required this.onTap,
  290.   });
  291.  
  292.   @override
  293.   State<BankTile> createState() => _BankTileState();
  294. }
  295.  
  296. class _BankTileState extends State<BankTile> {
  297.   Color backgroundColor = Colors.grey.shade200;
  298.  
  299.   @override
  300.   void initState() {
  301.     super.initState();
  302.     _updatePalette();
  303.   }
  304.  
  305.   Color lightenColor(Color color, [double amount = 0.3]) {
  306.     final hsl = HSLColor.fromColor(color);
  307.     final lightened =
  308.         hsl.withLightness((hsl.lightness + amount).clamp(0.0, 1.0));
  309.     return lightened.toColor();
  310.   }
  311.  
  312.   Future<void> _updatePalette() async {
  313.     final imageProvider = AssetImage(widget.bank.imagePath);
  314.  
  315.     final paletteGenerator = await PaletteGenerator.fromImageProvider(
  316.       imageProvider,
  317.       size: const Size(300, 300),
  318.       maximumColorCount: 20,
  319.     );
  320.  
  321.     Color? rawColor = paletteGenerator.dominantColor?.color ??
  322.         paletteGenerator.vibrantColor?.color ??
  323.         paletteGenerator.mutedColor?.color;
  324.  
  325.     setState(() {
  326.       backgroundColor = rawColor != null
  327.           ? lightenColor(rawColor, 0.4) // adjust brightness (0.1–0.5)
  328.           : Colors.grey.shade200;
  329.     });
  330.   }
  331.  
  332.   @override
  333.   Widget build(BuildContext context) {
  334.     return Consumer(builder: (_, ref, __) {
  335.       return InkWell(
  336.         onTap: widget.onTap,
  337.         splashColor: transparent,
  338.         highlightColor: transparent,
  339.         child: Container(
  340.           margin: EdgeInsets.only(bottom: getProportionateScreenHeight(10)),
  341.           padding: EdgeInsets.only(bottom: getProportionateScreenHeight(15)),
  342.           decoration: BoxDecoration(
  343.               border: Border(
  344.             bottom: BorderSide(
  345.               color: ref.watch(generalNotifierProvider)
  346.                   ? white.withOpacity(0.05)
  347.                   : lightBlack.withOpacity(0.05),
  348.             ),
  349.           )),
  350.           child: Row(
  351.             children: [
  352.               Container(
  353.                 padding: const EdgeInsets.all(7),
  354.                 decoration: BoxDecoration(
  355.                   shape: BoxShape.circle,
  356.                   color: backgroundColor,
  357.                 ),
  358.                 child: Container(
  359.                   height: 25,
  360.                   width: 25,
  361.                   decoration: BoxDecoration(
  362.                     shape: BoxShape.circle,
  363.                     image: DecorationImage(
  364.                       image: AssetImage(widget.bank.imagePath),
  365.                       fit: BoxFit.cover,
  366.                     ),
  367.                   ),
  368.                 ),
  369.               ),
  370.               horizontalSpace(
  371.                 getProportionateScreenWidth(10),
  372.               ),
  373.               textWidget2(
  374.                 widget.bank.name,
  375.                 fontWeight: FontWeight.w500,
  376.                 fontSize: getProportionateScreenWidth(14),
  377.                 color: ref.watch(generalNotifierProvider)
  378.                     ? white.withOpacity(0.9)
  379.                     : lightBlack.withOpacity(0.9),
  380.               ),
  381.               const Spacer(),
  382.               Container(
  383.                 padding: const EdgeInsets.all(3),
  384.                 decoration: BoxDecoration(
  385.                   shape: BoxShape.circle,
  386.                   color: (ref.watch(generalNotifierProvider)
  387.                       ? primaryBaseDarkmode
  388.                       : primaryBaseWhite),
  389.                 ),
  390.                 child: iconWidget(PhosphorIcons.caret_right_bold,
  391.                     size: 16,
  392.                     color: ref.watch(generalNotifierProvider)
  393.                         ? white.withOpacity(0.64)
  394.                         : lightBlack.withOpacity(0.64)),
  395.               ),
  396.             ],
  397.           ),
  398.         ),
  399.       );
  400.     });
  401.   }
  402. }
  403.  
  404. class RecentBeneficiaryCards extends StatefulWidget {
  405.   final BeneficiaryBank beneficiaryBank;
  406.   const RecentBeneficiaryCards({super.key, required this.beneficiaryBank});
  407.  
  408.   @override
  409.   State<RecentBeneficiaryCards> createState() => _RecentBeneficiaryCardsState();
  410. }
  411.  
  412. class _RecentBeneficiaryCardsState extends State<RecentBeneficiaryCards> {
  413.   Color backgroundColor = Colors.grey.shade200;
  414.  
  415.   @override
  416.   void initState() {
  417.     super.initState();
  418.     _updatePalette();
  419.   }
  420.  
  421.   Color lightenColor(Color color, [double amount = 0.3]) {
  422.     final hsl = HSLColor.fromColor(color);
  423.     final lightened =
  424.         hsl.withLightness((hsl.lightness + amount).clamp(0.0, 1.0));
  425.     return lightened.toColor();
  426.   }
  427.  
  428.   Future<void> _updatePalette() async {
  429.     final imageProvider = AssetImage(widget.beneficiaryBank.imagePath);
  430.  
  431.     final paletteGenerator = await PaletteGenerator.fromImageProvider(
  432.       imageProvider,
  433.       size: const Size(300, 300),
  434.       maximumColorCount: 20,
  435.     );
  436.  
  437.     Color? rawColor = paletteGenerator.dominantColor?.color ??
  438.         paletteGenerator.vibrantColor?.color ??
  439.         paletteGenerator.mutedColor?.color;
  440.  
  441.     setState(() {
  442.       backgroundColor = rawColor != null
  443.           ? lightenColor(rawColor, 0.5) // adjust brightness–
  444.           : Colors.grey.shade200;
  445.     });
  446.   }
  447.  
  448.   @override
  449.   Widget build(BuildContext context) {
  450.     return Column(
  451.       children: [
  452.         Container(
  453.           padding: const EdgeInsets.all(7),
  454.           decoration: BoxDecoration(
  455.             shape: BoxShape.circle,
  456.             color: backgroundColor,
  457.           ),
  458.           child: Container(
  459.             height: 25,
  460.             width: 25,
  461.             decoration: BoxDecoration(
  462.               shape: BoxShape.circle,
  463.               image: DecorationImage(
  464.                 image: AssetImage(widget.beneficiaryBank.imagePath),
  465.                 fit: BoxFit.cover,
  466.               ),
  467.             ),
  468.           ),
  469.         ),
  470.         const SizedBox(height: 5),
  471.         SizedBox(
  472.           width: 70,
  473.           child: Text(
  474.             widget.beneficiaryBank.firstName,
  475.             style: GoogleFonts.poppins(
  476.               fontSize: getProportionateScreenWidth(12),
  477.               fontWeight: FontWeight.w400,
  478.             ),
  479.             overflow: TextOverflow.ellipsis,
  480.             textAlign: TextAlign.center,
  481.           ),
  482.         ),
  483.         SizedBox(
  484.           width: 70,
  485.           child: Text(
  486.             widget.beneficiaryBank.lastName,
  487.             style: GoogleFonts.poppins(
  488.               fontSize: getProportionateScreenWidth(12),
  489.               fontWeight: FontWeight.w400,
  490.             ),
  491.             overflow: TextOverflow.ellipsis,
  492.             textAlign: TextAlign.center,
  493.           ),
  494.         ),
  495.       ],
  496.     );
  497.   }
  498. }
  499.  
  500. //
  501.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement