217 lines
9.1 KiB
Dart
217 lines
9.1 KiB
Dart
|
import 'package:flutter/cupertino.dart';
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter/services.dart';
|
||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||
|
import 'package:intl/intl.dart';
|
||
|
import 'package:medcify/components/button.dart';
|
||
|
import 'package:medcify/components/custom_textfield.dart';
|
||
|
import 'package:medcify/helpers.dart';
|
||
|
|
||
|
import '../../../components/loader.dart';
|
||
|
import '../../../navigation/navigation.dart';
|
||
|
import 'change_profile_bloc.dart';
|
||
|
|
||
|
class ChangeProfilePage extends StatelessWidget {
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return Scaffold(
|
||
|
backgroundColor: Colors.white,
|
||
|
appBar: AppBar(
|
||
|
elevation: 0.25,
|
||
|
automaticallyImplyLeading: false,
|
||
|
backgroundColor: Colors.white,
|
||
|
title: const Text("Change Profile",style: TextStyle(color: Colors.black,fontSize: 17, fontWeight: FontWeight.w600),),
|
||
|
leading: IconButton(
|
||
|
onPressed: (){
|
||
|
Navigation.instance.goBack();
|
||
|
},
|
||
|
icon: const Icon(Icons.keyboard_backspace_rounded,color: Colors.black,),
|
||
|
),
|
||
|
),
|
||
|
body: GestureDetector(
|
||
|
behavior: HitTestBehavior.opaque,
|
||
|
onTap: (){
|
||
|
FocusManager.instance.primaryFocus?.unfocus();
|
||
|
},
|
||
|
child: BlocProvider<ChangeProfileCubit>(
|
||
|
create: (context) => ChangeProfileCubit(),
|
||
|
child: ChangeProfileWidget(),
|
||
|
),
|
||
|
)
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class ChangeProfileWidget extends StatefulWidget {
|
||
|
@override
|
||
|
State<ChangeProfileWidget> createState() => _ChangeProfileWidgetState();
|
||
|
}
|
||
|
|
||
|
class _ChangeProfileWidgetState extends State<ChangeProfileWidget> {
|
||
|
late ChangeProfileCubit changeProfileCubit;
|
||
|
|
||
|
Widget typeDropDown(){
|
||
|
return BlocBuilder<ChangeProfileCubit, ChangeProfileState>(
|
||
|
buildWhen: (prev, current){
|
||
|
return current is ChangeProfileChangeType;
|
||
|
},
|
||
|
builder: (context, state){
|
||
|
return Container(
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.grey.shade100,
|
||
|
borderRadius: BorderRadius.circular(4)
|
||
|
),
|
||
|
padding: const EdgeInsets.symmetric(horizontal: 16,),
|
||
|
alignment: Alignment.center,
|
||
|
child: DropdownButton(
|
||
|
underline: const SizedBox(),
|
||
|
isExpanded: true,
|
||
|
style: const TextStyle(fontSize: 15,fontFamily: "Montserrat",color: Colors.black),
|
||
|
icon: const Icon(Icons.keyboard_arrow_down_rounded,color: Colors.grey,size: 16,),
|
||
|
hint: const Text("Select type",style: TextStyle(fontFamily: "Montserrat",color: Colors.grey,fontSize: 14),),
|
||
|
items: changeProfileCubit.types.map((e) => DropdownMenuItem(
|
||
|
value: e,
|
||
|
child: Text(e),
|
||
|
)).toList(),
|
||
|
value: changeProfileCubit.selectedType,
|
||
|
onChanged: changeProfileCubit.changeType
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
);
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
initState(){
|
||
|
changeProfileCubit = BlocProvider.of<ChangeProfileCubit>(context);
|
||
|
changeProfileCubit.fetchMyStore();
|
||
|
super.initState();
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return BlocBuilder<ChangeProfileCubit, ChangeProfileState>(
|
||
|
buildWhen: (prev, current){
|
||
|
return current is ChangeProfileLoading || current is ChangeProfileSuccess || current is ChangeProfileFailure;
|
||
|
},
|
||
|
builder: (context, state){
|
||
|
if(state is ChangeProfileLoading){
|
||
|
return const Loader();
|
||
|
}else if(state is ChangeProfileFailure){
|
||
|
return Container(
|
||
|
alignment: Alignment.center,
|
||
|
margin: const EdgeInsets.symmetric(horizontal: 24),
|
||
|
child: Text(state.error,style: TextStyle(color: Colors.grey.shade800, fontSize: 13, height: 1.6),),
|
||
|
);
|
||
|
}
|
||
|
return Stack(
|
||
|
children: [
|
||
|
SingleChildScrollView(
|
||
|
padding: const EdgeInsets.all(16),
|
||
|
physics: const BouncingScrollPhysics(),
|
||
|
child: Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
const Text("Store Name",style: TextStyle(color: Colors.black,fontSize: 15, fontWeight: FontWeight.w500),),
|
||
|
const SizedBox(height: 16,),
|
||
|
CustomTextField(
|
||
|
hint: "Enter store name",
|
||
|
controller: changeProfileCubit.storeNameController
|
||
|
),
|
||
|
const SizedBox(height: 20,),
|
||
|
const Text("Owner Name",style: TextStyle(color: Colors.black,fontSize: 15, fontWeight: FontWeight.w500),),
|
||
|
const SizedBox(height: 16,),
|
||
|
CustomTextField(
|
||
|
hint: "Enter owner name",
|
||
|
controller: changeProfileCubit.ownerNameController
|
||
|
),
|
||
|
const SizedBox(height: 20,),
|
||
|
const Text("Whatsapp Number",style: TextStyle(color: Colors.black,fontSize: 15, fontWeight: FontWeight.w500),),
|
||
|
const SizedBox(height: 16,),
|
||
|
CustomTextField(
|
||
|
hint: "Enter whatsapp number",
|
||
|
controller: changeProfileCubit.whatsappNumberController,
|
||
|
keyboardType: TextInputType.number,
|
||
|
inputFormatters: [
|
||
|
FilteringTextInputFormatter.digitsOnly
|
||
|
],
|
||
|
),
|
||
|
const SizedBox(height: 20,),
|
||
|
const Text("Address1",style: TextStyle(color: Colors.black,fontSize: 15, fontWeight: FontWeight.w500),),
|
||
|
const SizedBox(height: 16,),
|
||
|
CustomTextField(
|
||
|
hint: "Enter address1",
|
||
|
controller: changeProfileCubit.address1Controller,
|
||
|
),
|
||
|
const SizedBox(height: 20,),
|
||
|
const Text("Address2",style: TextStyle(color: Colors.black,fontSize: 15, fontWeight: FontWeight.w500),),
|
||
|
const SizedBox(height: 16,),
|
||
|
CustomTextField(
|
||
|
hint: "Enter address2",
|
||
|
controller: changeProfileCubit.address2Controller,
|
||
|
),
|
||
|
const SizedBox(height: 20,),
|
||
|
const Text("Pincode",style: TextStyle(color: Colors.black,fontSize: 15, fontWeight: FontWeight.w500),),
|
||
|
const SizedBox(height: 16,),
|
||
|
CustomTextField(
|
||
|
hint: "Enter pincode",
|
||
|
controller: changeProfileCubit.pinCodeController,
|
||
|
keyboardType: TextInputType.number,
|
||
|
inputFormatters: [
|
||
|
FilteringTextInputFormatter.digitsOnly
|
||
|
],
|
||
|
),
|
||
|
const SizedBox(height: 20,),
|
||
|
const Text("Location",style: TextStyle(color: Colors.black,fontSize: 15, fontWeight: FontWeight.w500),),
|
||
|
const SizedBox(height: 16,),
|
||
|
CustomTextField(
|
||
|
hint: "Enter location",
|
||
|
controller: changeProfileCubit.locationController,
|
||
|
),
|
||
|
const SizedBox(height: 20,),
|
||
|
const Text("Features",style: TextStyle(color: Colors.black,fontSize: 15, fontWeight: FontWeight.w500),),
|
||
|
const SizedBox(height: 16,),
|
||
|
CustomTextField(
|
||
|
hint: "Enter features",
|
||
|
controller: changeProfileCubit.featuresController,
|
||
|
maxLines: 5,
|
||
|
keyboardType: TextInputType.multiline,
|
||
|
),
|
||
|
const SizedBox(height: 20,),
|
||
|
const Text("Disclaimer",style: TextStyle(color: Colors.black,fontSize: 15, fontWeight: FontWeight.w500),),
|
||
|
const SizedBox(height: 16,),
|
||
|
CustomTextField(
|
||
|
hint: "Enter disclaimer",
|
||
|
controller: changeProfileCubit.disclaimerController,
|
||
|
maxLines: 5,
|
||
|
keyboardType: TextInputType.multiline,
|
||
|
),
|
||
|
const SizedBox(height: 20,),
|
||
|
const Text("Store Type",style: TextStyle(color: Colors.black,fontSize: 15, fontWeight: FontWeight.w500),),
|
||
|
const SizedBox(height: 16,),
|
||
|
typeDropDown(),
|
||
|
const SizedBox(height: 80,),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
Align(
|
||
|
alignment: Alignment.bottomCenter,
|
||
|
child: Container(
|
||
|
color: Colors.white,
|
||
|
padding: const EdgeInsets.symmetric(horizontal: 16,vertical: 4),
|
||
|
child: Button(
|
||
|
text: "Submit",
|
||
|
onPressed: (){
|
||
|
FocusManager.instance.primaryFocus?.unfocus();
|
||
|
changeProfileCubit.updateStore();
|
||
|
},
|
||
|
),
|
||
|
),
|
||
|
)
|
||
|
],
|
||
|
);
|
||
|
}
|
||
|
);
|
||
|
}
|
||
|
}
|