You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mohemm-flutter-app/lib/ui/screens/profile/profile_screen.dart

136 lines
5.0 KiB
Dart

3 years ago
import 'dart:ui';
3 years ago
import 'dart:convert';
3 years ago
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
3 years ago
import 'package:image_picker/image_picker.dart';
3 years ago
import 'package:mohem_flutter_app/api/profile_api_client.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/utils.dart';
import 'package:mohem_flutter_app/models/get_employee_basic_details.model.dart';
import 'package:mohem_flutter_app/models/member_information_list_model.dart';
3 years ago
import 'package:mohem_flutter_app/ui/screens/profile/widgets/header.dart';
import 'package:mohem_flutter_app/ui/screens/profile/widgets/profile_panel.dart';
3 years ago
import 'package:mohem_flutter_app/widgets/bottom_sheet.dart';
3 years ago
3 years ago
class ProfileScreen extends StatefulWidget {
const ProfileScreen({Key? key}) : super(key: key);
@override
_ProfileScreenState createState() => _ProfileScreenState();
}
class _ProfileScreenState extends State<ProfileScreen> {
late MemberInformationListModel memberInformationList;
3 years ago
final ImagePicker _picker = ImagePicker();
List<GetEmployeeBasicDetailsList> getEmployeeBasicDetailsList = [];
3 years ago
@override
void initState() {
super.initState();
memberInformationList = AppState().memberInformationList!;
//getEmployeeBasicDetails();
}
3 years ago
@override
Widget build(BuildContext context) {
return Scaffold(
extendBody: true,
backgroundColor: const Color(0xffefefef),
body: Stack(children: [
Container(
height: 300,
margin: EdgeInsets.only(top: 50),
3 years ago
decoration: BoxDecoration(image: DecorationImage(image: MemoryImage(Utils.getPostBytes(memberInformationList.eMPLOYEEIMAGE)), fit: BoxFit.cover)),
3 years ago
child: new BackdropFilter(
filter: new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0),
child: new Container(
decoration: new BoxDecoration(color: Colors.white.withOpacity(0.0)),
),
)),
SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(crossAxisAlignment: CrossAxisAlignment.center, children: [
SizedBox(
height: 80,
),
Container(
padding: EdgeInsets.only(left: 15, right: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
3 years ago
onPressed: () {
Navigator.pop(context);
},
3 years ago
icon: Icon(
Icons.arrow_back_ios,
color: Colors.white,
)),
InkWell(
3 years ago
onTap: () {
startImageSheet();
},
3 years ago
child: Container(
padding: EdgeInsets.only(left: 10, right: 10, top: 5, bottom: 5),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(15), color: Colors.black.withOpacity(.3)),
child: Row(children: [
Icon(Icons.photo, color: Colors.white),
Text(
'Edit',
style: TextStyle(color: Colors.white, fontSize: 12),
)
]))),
],
)),
3 years ago
HeaderPanel(memberInformationList),
ProfilePanle(memberInformationList)
3 years ago
]),
)
]));
}
3 years ago
3 years ago
startImageSheet() {
showMyBottomSheet(context,
child: Column(
children: [
Container(
padding: EdgeInsets.only(left: 20, right: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [Text('OK'), Text('CANCEL')],
)),
BottomSheetItem(
onTap: () {
openGallery(false);
},
title: 'Open Gallery',
icon: Icons.browse_gallery_outlined,
),
BottomSheetItem(
onTap: () {
openGallery(true);
},
title: 'Open Camera',
icon: Icons.camera,
)
],
));
}
void openGallery(bool isCamera) async {
final XFile? image = await _picker.pickImage(source: isCamera ? ImageSource.camera : ImageSource.gallery);
if (image != null) {
String img = base64.encode(await image!.readAsBytes());
3 years ago
Utils.showLoading(context);
3 years ago
dynamic empImageUpdteResp = await ProfileApiClient().updateEmpImage(img);
3 years ago
Utils.hideLoading(context);
3 years ago
if (empImageUpdteResp['P_RETURN_STATUS'] == 'S') {
setState(() {
memberInformationList.eMPLOYEEIMAGE = img;
});
}
3 years ago
}
}
3 years ago
}