Updated Profile screen

fatima
haroon amjad 3 years ago
parent 0051d8b97e
commit b834c52b5f

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

Loading…
Cancel
Save