Added Account Screens as per new Design
parent
6c416ef7a0
commit
f970e4a540
@ -1,67 +0,0 @@
|
|||||||
|
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
|
||||||
|
|
||||||
import 'dialogs_and_bottomsheets.dart';
|
|
||||||
|
|
||||||
enum ConfirmAction { CANCEL, ACCEPT }
|
|
||||||
|
|
||||||
Future<bool> requestPermissionGranted(
|
|
||||||
context, Permission requestPermissions) async {
|
|
||||||
var result = await requestPermissions.request();
|
|
||||||
|
|
||||||
switch (result) {
|
|
||||||
case PermissionStatus.granted:
|
|
||||||
// Application has been given permission to use the feature.
|
|
||||||
return true;
|
|
||||||
case PermissionStatus.denied:
|
|
||||||
// Application has been denied permission to use the feature.
|
|
||||||
return false;
|
|
||||||
case PermissionStatus.permanentlyDenied:
|
|
||||||
ConfirmAction? res = await showConfirmDialogs(
|
|
||||||
context,
|
|
||||||
'You was denied Permission. You have give manual permission from app setting. ',
|
|
||||||
'Open App Setting',
|
|
||||||
'Cancel');
|
|
||||||
if (res == ConfirmAction.ACCEPT) {
|
|
||||||
return false;
|
|
||||||
} else if (res == ConfirmAction.CANCEL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case PermissionStatus.restricted:
|
|
||||||
// iOS has restricted access to a specific feature.
|
|
||||||
return false;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class AppPermissions{
|
|
||||||
static void location(Function(bool) completion) {
|
|
||||||
Permission.location.isGranted.then((isGranted){
|
|
||||||
if(!isGranted){
|
|
||||||
Permission.location.request().then((granted){
|
|
||||||
completion(granted == PermissionStatus.granted);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
completion(isGranted);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void checkAll(Function(bool) completion){
|
|
||||||
[
|
|
||||||
Permission.location
|
|
||||||
].request().then((value){
|
|
||||||
|
|
||||||
bool allGranted = false;
|
|
||||||
value.values.forEach((element) {
|
|
||||||
allGranted = allGranted && element == PermissionStatus.granted;
|
|
||||||
});
|
|
||||||
|
|
||||||
completion(allGranted);
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,97 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mc_common_app/widgets/common_widgets/confirm_dialog.dart';
|
||||||
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
|
|
||||||
|
import 'dialogs_and_bottomsheets.dart';
|
||||||
|
|
||||||
|
enum ConfirmAction { CANCEL, ACCEPT }
|
||||||
|
|
||||||
|
Future<bool> requestPermissionGranted(context, Permission requestPermissions) async {
|
||||||
|
var result = await requestPermissions.request();
|
||||||
|
|
||||||
|
log("result: $result");
|
||||||
|
switch (result) {
|
||||||
|
case PermissionStatus.granted:
|
||||||
|
// Application has been given permission to use the feature.
|
||||||
|
return true;
|
||||||
|
case PermissionStatus.denied:
|
||||||
|
// Application has been denied permission to use the feature.
|
||||||
|
return false;
|
||||||
|
case PermissionStatus.permanentlyDenied:
|
||||||
|
ConfirmAction? res = await showConfirmDialogs(context, 'This permission was denied permanently, Please go to settings and allow. ', 'Open App Setting', 'Cancel');
|
||||||
|
if (res == ConfirmAction.ACCEPT) {
|
||||||
|
return false;
|
||||||
|
} else if (res == ConfirmAction.CANCEL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case PermissionStatus.restricted:
|
||||||
|
// iOS has restricted access to a specific feature.
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AppPermissions {
|
||||||
|
static void location(Function(bool) completion) {
|
||||||
|
Permission.location.isGranted.then((isGranted) {
|
||||||
|
if (!isGranted) {
|
||||||
|
Permission.location.request().then((granted) {
|
||||||
|
completion(granted == PermissionStatus.granted);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
completion(isGranted);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static void checkAll(Function(bool) completion) {
|
||||||
|
[Permission.location].request().then((value) {
|
||||||
|
bool allGranted = false;
|
||||||
|
for (var element in value.values) {
|
||||||
|
allGranted = allGranted && element == PermissionStatus.granted;
|
||||||
|
}
|
||||||
|
|
||||||
|
completion(allGranted);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static getDialog(BuildContext context) {
|
||||||
|
return showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext cxt) => ConfirmDialog(
|
||||||
|
message: "You need to give storage permission to select files.",
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<bool> checkStoragePermissions(BuildContext context) async {
|
||||||
|
bool permissionStatus;
|
||||||
|
final deviceInfo = await DeviceInfoPlugin().androidInfo;
|
||||||
|
|
||||||
|
if (deviceInfo.version.sdkInt! > 32) {
|
||||||
|
permissionStatus = await Permission.photos.request().isGranted;
|
||||||
|
if (permissionStatus) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
getDialog(context);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
permissionStatus = await Permission.storage.request().isGranted;
|
||||||
|
if (permissionStatus) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
getDialog(context);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,270 @@
|
|||||||
|
import 'dart:ui';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
import 'package:mc_common_app/classes/consts.dart';
|
||||||
|
import 'package:mc_common_app/config/routes.dart';
|
||||||
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:mc_common_app/theme/colors.dart';
|
||||||
|
import 'package:mc_common_app/utils/navigator.dart';
|
||||||
|
import 'package:mc_common_app/utils/utils.dart';
|
||||||
|
import 'package:mc_common_app/views/setting_options/widgets/custom_setting_options_tile.dart';
|
||||||
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
||||||
|
|
||||||
|
class ProfileScreen extends StatelessWidget {
|
||||||
|
const ProfileScreen({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
// final ImagePicker _picker = ImagePicker();
|
||||||
|
|
||||||
|
Widget showItem({required String icon, required String title, required VoidCallback onTap, String? subTitle}) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: onTap,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: 16,
|
||||||
|
height: 16,
|
||||||
|
child: SvgPicture.asset(
|
||||||
|
icon,
|
||||||
|
color: subTitle == null ? MyColors.black : MyColors.primaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
12.width,
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
title.toText(isBold: true, fontSize: 14),
|
||||||
|
if (subTitle != null) subTitle.toText(fontSize: 14, color: MyColors.primaryColor),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Icon(
|
||||||
|
Icons.arrow_forward,
|
||||||
|
size: 16,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
extendBody: true,
|
||||||
|
backgroundColor: const Color(0xffefefef),
|
||||||
|
body: Stack(
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
image: DecorationImage(
|
||||||
|
image: AssetImage(MyAssets.icLogoWhitePng),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: BackdropFilter(
|
||||||
|
filter: ImageFilter.blur(sigmaX: 7.0, sigmaY: 7.0),
|
||||||
|
child: Container(
|
||||||
|
// height:,
|
||||||
|
color: Colors.white.withOpacity(0.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 8,
|
||||||
|
child: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
color: Colors.white,
|
||||||
|
child: ListView(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height: 90,
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: ClipOval(
|
||||||
|
child: Image.asset(
|
||||||
|
MyAssets.carBanner,
|
||||||
|
width: 90,
|
||||||
|
height: 90,
|
||||||
|
fit: BoxFit.fill,
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
Container(
|
||||||
|
height: 35,
|
||||||
|
width: 35,
|
||||||
|
decoration: BoxDecoration(color: MyColors.white, shape: BoxShape.circle, border: Border.all(color: MyColors.darkTextColor, width: 0.1)),
|
||||||
|
child: const Icon(Icons.edit_note, color: MyColors.darkIconColor, size: 27).paddingOnly(left: 5),
|
||||||
|
).onPress(() {})
|
||||||
|
],
|
||||||
|
).horPaddingMain(),
|
||||||
|
10.height,
|
||||||
|
"Muhammad Ahmad".toText(fontSize: 20).paddingOnly(left: 25),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
CustomProfileOptionsTile(
|
||||||
|
titleText: "Country",
|
||||||
|
subtitleText: "Saudi Arabia",
|
||||||
|
needBorderBelow: true,
|
||||||
|
onTap: () {},
|
||||||
|
),
|
||||||
|
CustomProfileOptionsTile(
|
||||||
|
titleText: "Email",
|
||||||
|
subtitleText: "mail@gmail.com",
|
||||||
|
needBorderBelow: true,
|
||||||
|
onTap: () {},
|
||||||
|
),
|
||||||
|
CustomProfileOptionsTile(
|
||||||
|
titleText: "Phone Number",
|
||||||
|
subtitleText: "0504278212",
|
||||||
|
needBorderBelow: true,
|
||||||
|
onTap: () {},
|
||||||
|
),
|
||||||
|
CustomProfileOptionsTile(
|
||||||
|
titleText: "Password",
|
||||||
|
subtitleText: "************",
|
||||||
|
onTap: () {},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).toContainer(width: double.infinity, isShadowEnabled: true, paddingAll: 10, margin: const EdgeInsets.fromLTRB(24, 24, 24, 0), borderRadius: 0),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
CircleAvatar(
|
||||||
|
radius: 20,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
child: const Icon(Icons.arrow_back_ios_rounded, color: MyColors.darkIconColor, size: 18).paddingOnly(right: 4),
|
||||||
|
).onPress(() {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}).paddingOnly(left: 21, right: 21, top: 50),
|
||||||
|
|
||||||
|
// SingleChildScrollView(
|
||||||
|
// scrollDirection: Axis.vertical,
|
||||||
|
// child: Column(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
// children: [
|
||||||
|
// Row(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
// children: [
|
||||||
|
// CircleAvatar(
|
||||||
|
// radius: 20,
|
||||||
|
// backgroundColor: Colors.white,
|
||||||
|
// child: const Icon(Icons.arrow_back_ios_rounded, color: MyColors.darkIconColor, size: 18).paddingOnly(right: 4),
|
||||||
|
// ).onPress(() {
|
||||||
|
// Navigator.pop(context);
|
||||||
|
// }),
|
||||||
|
// ],
|
||||||
|
// ).paddingOnly(left: 21, right: 21, top: 50),
|
||||||
|
// Stack(
|
||||||
|
// children: [
|
||||||
|
// Column(
|
||||||
|
// children: [
|
||||||
|
// showItem(
|
||||||
|
// icon: MyAssets.icEmail,
|
||||||
|
// title: "Country",
|
||||||
|
// onTap: () {
|
||||||
|
// navigateWithName(context, AppRoutes.changeEmailPage);
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// const Divider(
|
||||||
|
// height: 1,
|
||||||
|
// ),
|
||||||
|
// showItem(
|
||||||
|
// icon: MyAssets.icPassword,
|
||||||
|
// title: "Country",
|
||||||
|
// onTap: () {
|
||||||
|
// navigateWithName(context, AppRoutes.changePassword);
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// const Divider(
|
||||||
|
// height: 1,
|
||||||
|
// ),
|
||||||
|
// showItem(
|
||||||
|
// icon: MyAssets.icPhoneNumber,
|
||||||
|
// title: "Country",
|
||||||
|
// onTap: () {
|
||||||
|
// navigateWithName(context, AppRoutes.changeMobilePage);
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// const Divider(
|
||||||
|
// height: 1,
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ).toWhiteContainer(width: double.infinity, pading: const EdgeInsets.symmetric(horizontal: 21)),
|
||||||
|
// Row(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
// children: [
|
||||||
|
// Container(
|
||||||
|
// height: 68,
|
||||||
|
// alignment: Alignment.centerLeft,
|
||||||
|
// child: ClipOval(
|
||||||
|
// child: Image.asset(
|
||||||
|
// MyAssets.carBanner,
|
||||||
|
// width: 68,
|
||||||
|
// height: 68,
|
||||||
|
// fit: BoxFit.fill,
|
||||||
|
// ),
|
||||||
|
// )),
|
||||||
|
// InkWell(
|
||||||
|
// onTap: () {},
|
||||||
|
// child: Container(
|
||||||
|
// padding: const EdgeInsets.only(left: 17, right: 17, top: 8, bottom: 8),
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// borderRadius: BorderRadius.circular(30),
|
||||||
|
// color: Colors.black.withOpacity(.21),
|
||||||
|
// ),
|
||||||
|
// child: Row(
|
||||||
|
// children: [
|
||||||
|
// const Icon(Icons.photo, color: Colors.white, size: 16),
|
||||||
|
// 4.width,
|
||||||
|
// "edit".toText(fontSize: 12, color: Colors.white),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ).horPaddingMain(),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// Container(
|
||||||
|
// height: MediaQuery.of(context).size.height,
|
||||||
|
// width: MediaQuery.of(context).size.width,
|
||||||
|
// color: Colors.white,
|
||||||
|
// child: Column(
|
||||||
|
// children: [
|
||||||
|
// CustomSettingOptionsTile(
|
||||||
|
// leadingWidget: const Icon(Icons.person, size: 20), titleText: "Invite Friends", needBorderBelow: true, onTap: () => navigateWithName(context, AppRoutes.myRequestsPage)),
|
||||||
|
// CustomSettingOptionsTile(
|
||||||
|
// leadingWidget: const Icon(Icons.help, size: 20), titleText: "Help", needBorderBelow: true, onTap: () => navigateWithName(context, AppRoutes.settingOptionsFaqs)),
|
||||||
|
// CustomSettingOptionsTile(leadingWidget: const Icon(Icons.person, size: 20), titleText: "Account", onTap: () => navigateWithName(context, AppRoutes.profileView)),
|
||||||
|
// ],
|
||||||
|
// ).toContainer(width: double.infinity, isShadowEnabled: true, paddingAll: 10, borderRadius: 0),
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:mc_common_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:mc_common_app/theme/colors.dart';
|
||||||
|
import 'package:mc_common_app/widgets/button/show_fill_button.dart';
|
||||||
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
||||||
|
|
||||||
|
class ConfirmDialog extends StatelessWidget {
|
||||||
|
final String? title;
|
||||||
|
final String message;
|
||||||
|
final String? okTitle;
|
||||||
|
final VoidCallback? onTap;
|
||||||
|
final VoidCallback? onCloseTap;
|
||||||
|
|
||||||
|
const ConfirmDialog({Key? key, this.title, required this.message, this.okTitle, this.onTap, this.onCloseTap}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Dialog(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
shape: const RoundedRectangleBorder(),
|
||||||
|
insetPadding: const EdgeInsets.only(left: 21, right: 21),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 20, right: 20, top: 18, bottom: 28),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
title ?? LocaleKeys.confirm.tr(),
|
||||||
|
style: const TextStyle(fontSize: 24, fontWeight: FontWeight.w600, color: MyColors.darkTextColor, height: 35 / 24, letterSpacing: -0.96),
|
||||||
|
).paddingOnly(top: 16),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
icon: const Icon(Icons.close),
|
||||||
|
color: MyColors.darkTextColor,
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
onPressed: () => onCloseTap ?? Navigator.pop(context),
|
||||||
|
// onPressed: () => Navigator.pop(context),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
message.toText(fontSize: 18, color: MyColors.lightTextColor),
|
||||||
|
28.height,
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: ShowFillButton(
|
||||||
|
title: okTitle ?? "OK",
|
||||||
|
onPressed: onTap ?? () => Navigator.pop(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue