Advertisement
mactech24

Numeric keypad

Jan 14th, 2023
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 5.52 KB | None | 0 0
  1. import 'package:credical/utile_size.dart';
  2. import 'package:flutter/material.dart';
  3.  
  4. class NumericPad extends StatelessWidget {
  5.   get context => null;
  6.  
  7.   // final Function(int) onNumberSelected;
  8.   // const NumericPad({super.key, required this.onNumberSelected});
  9.  
  10.   @override
  11.   Widget build(BuildContext context) {
  12.     SizeConfig().init(context);
  13.     Size size = MediaQuery.of(context).size;
  14.     return Padding(
  15.       padding: EdgeInsets.symmetric(
  16.         horizontal: getProportionateScreenWidth(55),
  17.       ),
  18.       child: Container(
  19.         color: Colors.transparent,
  20.         child: Column(
  21.           mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  22.           crossAxisAlignment: CrossAxisAlignment.stretch,
  23.           children: [
  24.             Container(
  25.               height: size.height * 0.09,
  26.               width: size.width * 0.06,
  27.               child: Row(
  28.                 mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  29.                 crossAxisAlignment: CrossAxisAlignment.start,
  30.                 children: [
  31.                   buildNumber(1),
  32.                   buildNumber(2),
  33.                   buildNumber(3),
  34.                 ],
  35.               ),
  36.             ),
  37.             Container(
  38.               height: size.height * 0.09,
  39.               width: size.width * 0.06,
  40.               child: Row(
  41.                 mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  42.                 crossAxisAlignment: CrossAxisAlignment.start,
  43.                 children: [
  44.                   buildNumber(4),
  45.                   buildNumber(5),
  46.                   buildNumber(6),
  47.                 ],
  48.               ),
  49.             ),
  50.             Container(
  51.               height: size.height * 0.09,
  52.               width: size.width * 0.06,
  53.               child: Row(
  54.                 mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  55.                 crossAxisAlignment: CrossAxisAlignment.start,
  56.                 children: [
  57.                   buildNumber(7),
  58.                   buildNumber(8),
  59.                   buildNumber(9),
  60.                 ],
  61.               ),
  62.             ),
  63.             Container(
  64.               height: size.height * 0.09,
  65.               width: size.width * 0.06,
  66.               child: Row(
  67.                 mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  68.                 crossAxisAlignment: CrossAxisAlignment.start,
  69.                 children: [
  70.                   buildFingerprint(),
  71.                   buildNumber(0),
  72.                   buildSignout(),
  73.                 ],
  74.               ),
  75.             ),
  76.           ],
  77.         ),
  78.       ),
  79.     );
  80.   }
  81.  
  82.   Widget buildNumber(int number) {
  83.     return Expanded(
  84.       child: GestureDetector(
  85.         onTap: () {
  86.           // onNumberSelected(number);
  87.         },
  88.         child: Padding(
  89.           padding: EdgeInsets.all(
  90.             getProportionateScreenWidth(10),
  91.           ),
  92.           child: Container(
  93.             decoration: BoxDecoration(
  94.               color: Color(0xFF0f7dff),
  95.               borderRadius: BorderRadius.circular(
  96.                 getProportionateScreenWidth(20),
  97.               ),
  98.             ),
  99.             child: Center(
  100.               child: Text(
  101.                 number.toString(),
  102.                 style: TextStyle(
  103.                   fontSize: getProportionateScreenWidth(20),
  104.                   fontWeight: FontWeight.bold,
  105.                   color: Colors.white,
  106.                 ),
  107.               ),
  108.             ),
  109.           ),
  110.         ),
  111.       ),
  112.     );
  113.   }
  114.  
  115.   Widget buildFingerprint() {
  116.     return Expanded(
  117.       child: GestureDetector(
  118.         onTap: () {
  119.           // onNumberSelected(-1);
  120.         },
  121.         child: Padding(
  122.           padding: EdgeInsets.all(
  123.             getProportionateScreenWidth(10),
  124.           ),
  125.           child: Container(
  126.             decoration: BoxDecoration(
  127.               color: Colors.transparent,
  128.               borderRadius: BorderRadius.circular(
  129.                 getProportionateScreenWidth(10),
  130.               ),
  131.             ),
  132.             child: GestureDetector(
  133.               onTap: () {
  134.                 buildDialogBox();
  135.               },
  136.               child: Center(
  137.                 child: Image.asset("assets/Fingerprint.png"),
  138.               ),
  139.             ),
  140.           ),
  141.         ),
  142.       ),
  143.     );
  144.   }
  145.  
  146.   Future<dynamic> buildDialogBox() {
  147.     return showDialog(
  148.       context: context,
  149.       builder: (context) {
  150.         return AlertDialog(
  151.           title: Text("Dialog"),
  152.           content: Icon(Icons.fingerprint),
  153.           actions: [
  154.             TextButton(
  155.               onPressed: () {},
  156.               child: Text("ok"),
  157.             ),
  158.           ],
  159.         );
  160.       },
  161.     );
  162.   }
  163.  
  164.   Widget buildSignout() {
  165.     return Expanded(
  166.       child: GestureDetector(
  167.         onTap: () {
  168.           // onNumberSelected(-1);
  169.         },
  170.         child: Padding(
  171.           padding: EdgeInsets.all(
  172.             getProportionateScreenWidth(10),
  173.           ),
  174.           child: Container(
  175.             decoration: BoxDecoration(
  176.               color: Colors.transparent,
  177.               borderRadius: BorderRadius.circular(
  178.                 getProportionateScreenWidth(10),
  179.               ),
  180.             ),
  181.             child: Center(
  182.               child: Text(
  183.                 "Sign Out",
  184.                 style: TextStyle(
  185.                   fontSize: getProportionateScreenWidth(14),
  186.                   color: Color(0xFF0f7dff),
  187.                   fontWeight: FontWeight.bold,
  188.                 ),
  189.               ),
  190.             ),
  191.           ),
  192.         ),
  193.       ),
  194.     );
  195.   }
  196. }
  197.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement