diff --git a/lib/ui/profile/profile_screen.dart b/lib/ui/profile/profile_screen.dart index 0bf007e..0a78873 100644 --- a/lib/ui/profile/profile_screen.dart +++ b/lib/ui/profile/profile_screen.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:io'; import 'dart:ui'; import 'package:easy_localization/easy_localization.dart'; @@ -16,6 +17,7 @@ import 'package:mohem_flutter_app/models/get_employee_basic_details.model.dart'; import 'package:mohem_flutter_app/models/member_information_list_model.dart'; import 'package:mohem_flutter_app/ui/profile/widgets/profile_panel.dart'; import 'package:mohem_flutter_app/widgets/bottom_sheet.dart'; +import 'package:mohem_flutter_app/widgets/image_picker.dart'; class ProfileScreen extends StatefulWidget { const ProfileScreen({Key? key}) : super(key: key); @@ -28,6 +30,7 @@ class _ProfileScreenState extends State { late MemberInformationListModel memberInformationList; final ImagePicker _picker = ImagePicker(); List getEmployeeBasicDetailsList = []; + List images = []; @override void initState() { @@ -46,24 +49,25 @@ class _ProfileScreenState extends State { children: [ memberInformationList!.eMPLOYEEIMAGE != null ? Container( - height: 300, - margin: const EdgeInsets.only(top: 50), - decoration: BoxDecoration( - image: DecorationImage( - image: MemoryImage( - Utils.dataFromBase64String(memberInformationList.eMPLOYEEIMAGE!), + height: 300, + margin: const EdgeInsets.only(top: 50), + decoration: BoxDecoration( + image: DecorationImage( + image: MemoryImage( + Utils.dataFromBase64String(memberInformationList.eMPLOYEEIMAGE!), + ), + fit: BoxFit.cover), ), - fit: BoxFit.cover), - ), - child: BackdropFilter( - filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), - child: Container( - color: Colors.white.withOpacity(0.0), - ), - ), - ): Container( - decoration: BoxDecoration(color: Colors.white.withOpacity(0.0)), - ), + child: BackdropFilter( + filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), + child: Container( + color: Colors.white.withOpacity(0.0), + ), + ), + ) + : Container( + decoration: BoxDecoration(color: Colors.white.withOpacity(0.0)), + ), SingleChildScrollView( scrollDirection: Axis.vertical, child: Column( @@ -83,7 +87,14 @@ class _ProfileScreenState extends State { ), InkWell( onTap: () { - startImageSheet(); + // startImageSheet(); + ImageOptions.showImageOptionsNew(context, false, (String image, File file) { + setState(() { + // images.add(image); + Navigator.of(context).pop(); + openGallery(image); + }); + }); }, child: Container( padding: const EdgeInsets.only(left: 17, right: 17, top: 8, bottom: 8), @@ -112,7 +123,8 @@ class _ProfileScreenState extends State { } void startImageSheet() { - showMyBottomSheet(context, callBackFunc: (){}, + showMyBottomSheet(context, + callBackFunc: () {}, child: Column( children: [ Container( @@ -123,14 +135,14 @@ class _ProfileScreenState extends State { )), BottomSheetItem( onTap: () { - openGallery(false); + // openGallery(false); }, title: 'Open Gallery', icon: Icons.browse_gallery_outlined, ), BottomSheetItem( onTap: () { - openGallery(true); + // openGallery(true); }, title: 'Open Camera', icon: Icons.camera, @@ -139,19 +151,17 @@ class _ProfileScreenState extends State { )); } - void openGallery(bool isCamera) async { - XFile? image = await _picker.pickImage(source: isCamera ? ImageSource.camera : ImageSource.gallery); + void openGallery(String image) async { + // XFile? image = await _picker.pickImage(source: isCamera ? ImageSource.camera : ImageSource.gallery); - if (image != null) { - String img = base64.encode(await image!.readAsBytes()); - Utils.showLoading(context); - dynamic empImageUpdteResp = await ProfileApiClient().updateEmpImage(img); - Utils.hideLoading(context); - if (empImageUpdteResp['P_RETURN_STATUS'] == 'S') { - setState(() { - memberInformationList.eMPLOYEEIMAGE = img; - }); - } + // String img = base64.encode(await image!.readAsBytes()); + Utils.showLoading(context); + dynamic empImageUpdteResp = await ProfileApiClient().updateEmpImage(image); + Utils.hideLoading(context); + if (empImageUpdteResp['P_RETURN_STATUS'] == 'S') { + setState(() { + memberInformationList.eMPLOYEEIMAGE = image; + }); } } }