92 lines
3.1 KiB
Dart
92 lines
3.1 KiB
Dart
import 'package:cached_network_image/cached_network_image.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:medcify/constants.dart';
|
|
import 'package:medcify/helpers.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
import '../../../components/loader.dart';
|
|
import '../../../navigation/navigation.dart';
|
|
import 'change_upi_qr_bloc.dart';
|
|
|
|
class ChangeUpiQrPage extends StatelessWidget {
|
|
const ChangeUpiQrPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
appBar: AppBar(
|
|
backgroundColor: Colors.white,
|
|
elevation: 0.25,
|
|
automaticallyImplyLeading: false,
|
|
leading: IconButton(
|
|
onPressed: (){
|
|
Navigation.instance.goBack();
|
|
},
|
|
icon: const Icon(Icons.keyboard_backspace_rounded,color: Colors.black,),
|
|
),
|
|
title: const Text("Upi Qr",style: TextStyle(color: Colors.black,fontSize: 17),),
|
|
),
|
|
body: BlocProvider<ChangeUpiQrCubit>(
|
|
create: (context) => ChangeUpiQrCubit(),
|
|
child: QrWidget(),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class QrWidget extends StatelessWidget {
|
|
late ChangeUpiQrCubit changeUpiQrCubit;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
changeUpiQrCubit = BlocProvider.of<ChangeUpiQrCubit>(context);
|
|
changeUpiQrCubit.fetchUpiQr();
|
|
return BlocBuilder<ChangeUpiQrCubit, ChangeUpiQrState>(
|
|
builder: (context, state) {
|
|
if(state is ChangeUpiQrLoading){
|
|
return const Loader();
|
|
}else if(state is ChangeUpiQrFailure){
|
|
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),),
|
|
);
|
|
}else{
|
|
return Container(
|
|
alignment: Alignment.center,
|
|
padding: const EdgeInsets.all(20),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
if(changeUpiQrCubit.image != null)Expanded(
|
|
child: Center(
|
|
child: CachedNetworkImage(
|
|
imageUrl: changeUpiQrCubit.image ?? "",
|
|
)
|
|
)
|
|
),
|
|
const SizedBox(height: 24,),
|
|
MaterialButton(
|
|
onPressed: (){
|
|
Helpers.showPhotoSelectionDialog(changeUpiQrCubit.getImage);
|
|
},
|
|
elevation: 0,
|
|
height: 50,
|
|
minWidth: double.infinity,
|
|
color: Constants.primaryColor,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(30)
|
|
),
|
|
child: const Text("Update",style: TextStyle(color: Colors.white,fontWeight: FontWeight.w600, fontSize: 15),)
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
);
|
|
}
|
|
}
|