import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:medcify/components/button.dart'; import 'package:medcify/models/pincode_item.dart'; import '../../../../components/custom_textfield.dart'; import '../../../../navigation/navigation.dart'; import 'edit_pincode_bloc.dart'; class EditPincodePage extends StatelessWidget { PincodeItem pincode; EditPincodePage(this.pincode); @override Widget build(BuildContext context) { return GestureDetector( behavior: HitTestBehavior.opaque, onTap: (){ FocusManager.instance.primaryFocus?.unfocus(); }, child: Scaffold( backgroundColor: Colors.white, appBar: AppBar( backgroundColor: Colors.white, elevation: 0.25, automaticallyImplyLeading: false, title: const Text("Edit Pincode",style: TextStyle(color: Colors.black,fontSize: 17),), leading: IconButton( onPressed: (){ Navigation.instance.goBack(); }, icon: const Icon(Icons.keyboard_backspace_rounded,color: Colors.black,), ), ), body: BlocProvider( create: (context) => EditPincodeCubit(), child: EditPincodeWidget(pincode), ), ), ); } } class EditPincodeWidget extends StatelessWidget { PincodeItem pincode; EditPincodeWidget(this.pincode); late EditPincodeCubit editPincodeCubit; @override Widget build(BuildContext context) { editPincodeCubit = BlocProvider.of(context); editPincodeCubit.setData(pincode); return Stack( children: [ SingleChildScrollView( padding: const EdgeInsets.only(top: 16,left: 16,right: 16,bottom: 80), physics: const BouncingScrollPhysics(), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text("Pincode",style: TextStyle(color: Colors.black,fontSize: 15, fontWeight: FontWeight.w500),), const SizedBox(height: 16,), CustomTextField( hint: "Enter pincode", controller: editPincodeCubit.pincodeController, keyboardType: TextInputType.number, inputFormatters: [ FilteringTextInputFormatter.digitsOnly ], ), const SizedBox(height: 20,), const Text("Delivery Fee",style: TextStyle(color: Colors.black,fontSize: 15, fontWeight: FontWeight.w500),), const SizedBox(height: 16,), CustomTextField( hint: "Enter delivery fee", controller: editPincodeCubit.deliveryFeeController, keyboardType: TextInputType.number, inputFormatters: [ FilteringTextInputFormatter.digitsOnly ], ), const SizedBox(height: 20,), const Text("Free Above",style: TextStyle(color: Colors.black,fontSize: 15, fontWeight: FontWeight.w500),), const SizedBox(height: 16,), CustomTextField( hint: "Enter free above", controller: editPincodeCubit.freeAboveController, keyboardType: TextInputType.number, inputFormatters: [ FilteringTextInputFormatter.digitsOnly ], ), const SizedBox(height: 16,), ], ), ), Align( alignment: Alignment.bottomCenter, child: Container( padding: const EdgeInsets.symmetric(horizontal: 16,vertical: 4), color: Colors.white, child: Button( text: "Update", onPressed: (){ editPincodeCubit.updatePincode("${pincode.id ?? 0}"); }, ), ), ) ], ); } }