diff --git a/assets/icons/new/arrow_up.svg b/assets/icons/new/arrow_up.svg new file mode 100644 index 0000000..5afeaa9 --- /dev/null +++ b/assets/icons/new/arrow_up.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/assets/icons/new/bookmark.svg b/assets/icons/new/bookmark.svg new file mode 100644 index 0000000..b78cb61 --- /dev/null +++ b/assets/icons/new/bookmark.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/assets/icons/new/dimension.svg b/assets/icons/new/dimension.svg new file mode 100644 index 0000000..24f774b --- /dev/null +++ b/assets/icons/new/dimension.svg @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/assets/icons/new/members.svg b/assets/icons/new/members.svg new file mode 100644 index 0000000..b1268ee --- /dev/null +++ b/assets/icons/new/members.svg @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/assets/icons/new/mic.svg b/assets/icons/new/mic.svg new file mode 100644 index 0000000..6a36834 --- /dev/null +++ b/assets/icons/new/mic.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/assets/icons/new/share.svg b/assets/icons/new/share.svg new file mode 100644 index 0000000..dd4aa54 --- /dev/null +++ b/assets/icons/new/share.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/icons/new/surah_left.svg b/assets/icons/new/surah_left.svg index ba6133b..b339472 100644 --- a/assets/icons/new/surah_left.svg +++ b/assets/icons/new/surah_left.svg @@ -1,11 +1,6 @@ - - - - - + + \ No newline at end of file diff --git a/assets/icons/new/surah_right.svg b/assets/icons/new/surah_right.svg index 45134d7..0c073ff 100644 --- a/assets/icons/new/surah_right.svg +++ b/assets/icons/new/surah_right.svg @@ -1,11 +1,7 @@ - - - - - + + + \ No newline at end of file diff --git a/assets/icons/new/user_acount.svg b/assets/icons/new/user_acount.svg new file mode 100644 index 0000000..5c9bd4f --- /dev/null +++ b/assets/icons/new/user_acount.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/assets/icons/new/zoom_in.svg b/assets/icons/new/zoom_in.svg new file mode 100644 index 0000000..99d6c32 --- /dev/null +++ b/assets/icons/new/zoom_in.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/assets/icons/new/zoom_out.svg b/assets/icons/new/zoom_out.svg new file mode 100644 index 0000000..4b21940 --- /dev/null +++ b/assets/icons/new/zoom_out.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/lib/app_state/app_state.dart b/lib/app_state/app_state.dart index 80f6d0c..7b77c14 100644 --- a/lib/app_state/app_state.dart +++ b/lib/app_state/app_state.dart @@ -46,6 +46,8 @@ class AppState { String get userEmail => _authenticationUser?.result?.data?.email; + String get userName => _authenticationUser?.result?.data?.userName; + void setAuthenticationModel(AuthenticationUserModel _authenticationUser) { this._authenticationUser = _authenticationUser; } @@ -70,5 +72,5 @@ class AppState { List haqooqAlMosasa; List tareefAlMosasa; - + String tangheemDiscription; } diff --git a/lib/classes/colors.dart b/lib/classes/colors.dart index 62b4a7f..17a70de 100644 --- a/lib/classes/colors.dart +++ b/lib/classes/colors.dart @@ -23,18 +23,29 @@ class ColorConsts { static const Color darkText = Color(0xff416A6C); + static const Color dark2Text = Color(0xff2B484A); + static const Color dark99Text = Color(0xff99C5C7); static const Color borderDarkText = Color(0xff03A67B); static const Color borderDark2Text = Color(0xff2CB9B0); static const Color borderColor = Color(0xffDDDDDD); + static const Color greyE0Color = Color(0xffE0E0E0); + static const Color greenLightColor = Color(0xff9BB195); static const Color brownColor = Color(0xffDAE8646); static const Color brownLightColor = Color(0xffAE8646); + static const Color brownLightECColor = Color(0xffECE9DB); + static const Color brownB7CColor = Color(0xffB78438); + static const Color brownB1CColor = Color(0xffB1A995); + static const Color brownB6CColor = Color(0xffB68439); static const Color greyLightColor = Color(0xffB7B7B7); static const Color greyHintColor = Color(0xffD1D1D1); static const Color grey9FColor = Color(0xff9F9F9F); static const Color greyF4Color = Color(0xffF4F4F4); + static const Color greyB5Color = Color(0xffB5B5B5); + static const Color greyBAColor = Color(0xffBABABA); static const Color greyF8Color = Color(0xffF8F8F8); static const Color greyC4Color = Color(0xffC4C4C4); static const Color redLightColor = Color(0xffED9696); + static const Color greyA7Color = Color(0xffA7A7A7); diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart index 98902be..f363b79 100644 --- a/lib/extensions/string_extensions.dart +++ b/lib/extensions/string_extensions.dart @@ -42,8 +42,8 @@ extension StringExtension on String { } } - Widget toText(double fontSize, {Color color, bool isBold = false, int maxLines, FontStyle fontStyle, TextAlign textAlign}) { - double heightVal = (fontSize == 13) ? 16 : ((fontSize == 18) ? 22 : 14); + Widget toText(double fontSize, {Color color, bool isBold = false, int maxLines, FontStyle fontStyle, TextAlign textAlign, double height}) { + double heightVal = height ?? ((fontSize == 13) ? 16 : ((fontSize == 18 || fontSize == 30) ? 22 : 14)); return Text( this, maxLines: maxLines, diff --git a/lib/main.dart b/lib/main.dart index 752969e..2423909 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -7,10 +7,12 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:tangheem/new_ui/common_home_parent.dart'; import 'package:tangheem/ui/screens/bookmark_screen.dart'; +import 'package:tangheem/ui/screens/change_password_screen.dart'; import 'package:tangheem/ui/screens/contact_us_screen.dart'; import 'package:tangheem/ui/screens/content_info_screen.dart'; import 'package:tangheem/ui/screens/member_screen.dart'; import 'package:tangheem/ui/screens/pdf_viewer_screen.dart'; +import 'package:tangheem/ui/screens/user_profile_screen.dart'; import 'classes/colors.dart'; import 'ui/common_appbar.dart'; @@ -44,9 +46,15 @@ class Application extends StatelessWidget { onGenerateRoute: (settings) { var className; switch (settings.name) { + case UserProfileScreen.routeName: + className = CommonAppbar(child: UserProfileScreen()); + break; case LoginScreen.routeName: className = CommonAppbar(child: LoginScreen()); break; + case ChangePasswordScreen.routeName: + className = CommonAppbar(child: ChangePasswordScreen()); + break; case RegistrationScreen.routeName: className = CommonAppbar(child: RegistrationScreen()); break; diff --git a/lib/new_ui/common_home_parent.dart b/lib/new_ui/common_home_parent.dart index 820c430..94a339a 100644 --- a/lib/new_ui/common_home_parent.dart +++ b/lib/new_ui/common_home_parent.dart @@ -16,6 +16,7 @@ import 'package:tangheem/models/content_info_model.dart'; import 'package:tangheem/models/navigation_model.dart'; import 'package:tangheem/models/quick_links_model.dart'; import 'package:tangheem/new_ui/screens/about_screen.dart'; +import 'package:tangheem/ui/dialogs/app_menu_dialog.dart'; import 'package:tangheem/ui/dialogs/change_password_dialog.dart'; import 'package:tangheem/ui/dialogs/general_dialog.dart'; import 'package:tangheem/ui/screens/bookmark_screen.dart'; @@ -53,6 +54,20 @@ class _CommonHomeParentState extends State { @override void initState() { super.initState(); + checkScreenMode(); + getPrefs(); + } + + int fontSize; + + void getPrefs() async { + prefs = await SharedPreferences.getInstance(); + fontSize = prefs.getInt(GlobalConsts.fontZoomSize) ?? 18; + String userAuth = prefs.getString(GlobalConsts.userAuthData); + if (userAuth != null) { + AuthenticationUserModel authenticationUserModel = AuthenticationUserModel.fromJson(jsonDecode(userAuth)); + AppState().setAuthenticationModel(authenticationUserModel); + } } @override @@ -65,7 +80,7 @@ class _CommonHomeParentState extends State { if (MediaQuery.of(context).orientation == Orientation.portrait) { await showDialog( context: context, - barrierColor: ColorConsts.secondaryWhite.withOpacity(0.8), + barrierColor: Colors.white.withOpacity(0.2), builder: (BuildContext context) => GeneralDialog(), ); } @@ -89,7 +104,7 @@ class _CommonHomeParentState extends State { await prefs.setBool(GlobalConsts.doNotShowWelcomeVideo, false); showDialog( context: context, - barrierColor: ColorConsts.secondaryWhite.withOpacity(0.8), + barrierColor: Colors.white.withOpacity(0.2), builder: (BuildContext context) => VideoPlayerWidget(permLink), ); } @@ -159,7 +174,7 @@ class _CommonHomeParentState extends State { "assets/icons/new/intro.svg", "assets/icons/new/quran.svg", "assets/icons/new/search.svg", - "assets/icons/new/search.svg", + "assets/icons/new/members.svg", ]; List sizes = [26, 26, 36, 26, 26]; @@ -181,510 +196,48 @@ class _CommonHomeParentState extends State { ), ], ).onPress(() { + if (_index == 3) { + showMenu(); + return; + } if (index != _index) setState(() { index = _index; }); }); } -} -// -// class CommonHomeParent extends StatefulWidget { -// final bool showDrawer; -// final Widget child; -// final bool isFirst; -// -// CommonHomeParent({Key key, this.showDrawer = false, @required this.child, this.isFirst = false}) : super(key: key); -// -// @override -// _CommonHomeParentState createState() { -// return _CommonHomeParentState(); -// } -// } -// -// class _CommonHomeParentState extends State { -// // final GlobalKey _scaffoldKey = new GlobalKey(); -// // List quickLinks = []; -// // List navigationList = []; -// // ContentInfoDataModel _userCopyRight; -// -// @override -// void initState() { -// super.initState(); -// // getPrefs(); -// // getNavigation(); -// // getQuickLinks(); -// // getCopyRight(); -// } -// -// // void getCopyRight() async { -// // if (AppState().getCopyRightContentInfoModel == null) { -// // try { -// // ContentInfoModel _userCopyRight = await TangheemUserApiClient().getContentInfo(3); -// // this._userCopyRight = _userCopyRight.data.first; -// // AppState().setCopyRightContentInfoModel(this._userCopyRight); -// // } catch (ex) {} -// // } else { -// // _userCopyRight = AppState().getCopyRightContentInfoModel; -// // } -// // setState(() {}); -// // } -// // -// // void getNavigation() async { -// // if (AppState().getNavigationModel?.data == null) { -// // try { -// // var model = await TangheemUserApiClient().getNavigation(); -// // navigationList = model?.data ?? []; -// // navigationList.removeWhere((element) => element.navigationId == 9); // this is for temporary, to release app on app store as file size are about 100 mbs -// // navigationList.sort((a, b) => a.orderNo.compareTo(b.orderNo)); -// // AppState().setNavigationModel(model); -// // } catch (ex) {} -// // } else { -// // navigationList = AppState().getNavigationModel.data; -// // } -// // setState(() {}); -// // } -// // -// // void getQuickLinks() async { -// // if (widget.showDrawer) { -// // try { -// // quickLinks = (await TangheemUserApiClient().quickLinks())?.data ?? []; -// // quickLinks = quickLinks.where((element) => element.position == "down").toList(); -// // quickLinks.sort((a, b) => a.orderNo.compareTo(b.orderNo)); -// // } catch (ex) {} -// // setState(() {}); -// // } -// // } -// // -// // int fontSize; -// // SharedPreferences prefs; -// // -// // void getPrefs() async { -// // prefs = await SharedPreferences.getInstance(); -// // fontSize = prefs.getInt(GlobalConsts.fontZoomSize) ?? 18; -// // String userAuth = prefs.getString(GlobalConsts.userAuthData); -// // if (userAuth != null) { -// // AuthenticationUserModel authenticationUserModel = AuthenticationUserModel.fromJson(jsonDecode(userAuth)); -// // AppState().setAuthenticationModel(authenticationUserModel); -// // } -// // } -// -// // void deleteUserAccount() async { -// // Utils.showLoading(context); -// // try { -// // await UserApiClient().deleteAccount(AppState().userId); -// // SharedPreferences prefs = await SharedPreferences.getInstance(); -// // await prefs.remove(GlobalConsts.userAuthData); -// // AppState().setAuthenticationModel(null); -// // Utils.showToast("تم حذف الحساب"); -// // Navigator.pop(context); -// // Utils.hideLoading(context); -// // } catch (ex) { -// // if (mounted) { -// // Utils.hideLoading(context); -// // Utils.handleException(ex, null); -// // } -// // } -// // } -// -// @override -// void dispose() { -// super.dispose(); -// } -// -// @override -// Widget build(BuildContext context) { -// -// return Scaffold( -// key: widget.showDrawer ? _scaffoldKey : null, -// drawer: widget.showDrawer ? drawerView() : null, -// resizeToAvoidBottomInset: true, -// drawerScrimColor: Colors.black.withOpacity(.3), -// body: SafeArea( -// child: Column( -// children: [ -// Container( -// color: Colors.white, -// height: 100, -// padding: EdgeInsets.only(top: 8, bottom: 8, right: 16), -// child: Row( -// crossAxisAlignment: CrossAxisAlignment.center, -// children: [ -// if (!widget.isFirst) -// IconButton( -// icon: Icon(widget.showDrawer ? Icons.menu : Icons.arrow_back_ios, color: ColorConsts.textGrey), -// padding: EdgeInsets.only(left: 16), -// onPressed: () { -// if (widget.showDrawer) { -// _scaffoldKey.currentState.openDrawer(); -// } else { -// Navigator.pop(context); -// } -// }, -// ), -// if (!widget.showDrawer) -// IconButton( -// icon: Icon(Icons.home, color: ColorConsts.textGrey), -// padding: EdgeInsets.only(left: 16), -// onPressed: () { -// Navigator.popUntil(context, ModalRoute.withName(HomeScreen.routeName)); -// }, -// ), -// Expanded(child: SizedBox()), -// Hero( -// tag: "logo", -// child: SvgPicture.asset( -// "assets/logos/tangheem_logo.svg", -// height: 100, -// width: 100, -// alignment: Alignment.centerRight, -// ), -// ) -// ], -// ), -// ), -// Expanded( -// child: Directionality(textDirection: TextDirection.rtl, child: widget.child), -// ), -// ], -// ), -// ), -// ); -// } -// -// void updatePassword(String email, String oldPassword, String password) async { -// Utils.showLoading(context); -// try { -// await UserApiClient().updatePassword(email, oldPassword, password); -// } catch (ex) { -// if (mounted) Utils.handleException(ex, null); -// Utils.hideLoading(context); -// return; -// } finally { -// Utils.hideLoading(context); -// } -// SharedPreferences prefs = await SharedPreferences.getInstance(); -// await prefs.remove(GlobalConsts.userAuthData); -// AppState().setAuthenticationModel(null); -// await showDialog( -// context: context, -// barrierColor: ColorConsts.secondaryWhite.withOpacity(0.8), -// builder: (BuildContext context) => GeneralDialog(message: "تم تغيير كلمة المرور بنجاح , الرجاء إعادة تسجيل الدخول من خلال الرابط المرسل إلى بريدك الإلكتروني"), -// ); -// Navigator.pop(context); -// } -// -// Widget drawerView() { -// var height = MediaQuery.of(context).padding.top; -// return Drawer( -// elevation: 0, -// child: Container( -// color: Colors.white, -// child: SafeArea( -// bottom: true, -// top: false, -// right: false, -// left: false, -// maintainBottomViewPadding: true, -// child: Builder( -// builder: (context) { -// bool isPortrait = MediaQuery.of(context).orientation == Orientation.portrait; -// Widget listContents = ListView.builder( -// shrinkWrap: true, -// physics: BouncingScrollPhysics(), -// padding: EdgeInsets.only(left: 24, right: 24), -// itemCount: navigationList.length, -// itemBuilder: (context, index) { -// String icon = "assets/icons/${navigationList[index].mobileFontIcon}.svg"; -// var subList = navigationList.where((element) => element.parentId == navigationList[index].navigationId).toList(); -// return Column( -// mainAxisSize: MainAxisSize.min, -// children: [ -// if (navigationList[index].parentId == 1) -// myListItem(icon, navigationList[index].navigationText, navigationList[index].orderNo == 1 ? true : false, onTap: () { -// String url = navigationList[index]?.mobileNavigationUrl ?? ""; -// if (url.isEmpty || url.length < 2) { -// return; -// } -// Navigator.pushNamed(context, url, arguments: null); -// }), -// for (var subItem in subList) -// Container( -// width: double.infinity, -// child: Row( -// children: [ -// Expanded( -// child: myListItem("assets/icons/${subItem.mobileFontIcon}.svg", subItem.navigationText, false, onTap: () { -// String url = subItem.mobileNavigationUrl ?? ""; -// if (url.isEmpty) { -// return; -// } -// var contentId; -// if (subItem.mobileNavigationUrl == "/introduction") { -// url = ContentInfoScreen.routeName; -// contentId = 2; -// } else if (subItem.mobileNavigationUrl == "/encyclopedia") { -// url = ContentInfoScreen.routeName; -// contentId = 1; -// } else if (subItem.mobileNavigationUrl == "/tangheempdf") { -// url = PdfListScreen.routeName; -// contentId = 8; -// } -// Navigator.pushNamed(context, url, arguments: contentId); -// }), -// ), -// Container( -// height: 40, -// margin: EdgeInsets.only(right: 17, left: 10), -// child: VerticalDivider(color: ColorConsts.primaryBlack, thickness: .7, width: 1), -// ), -// ], -// ), -// ) -// ], -// ); -// }); -// if (isPortrait) { -// listContents = Expanded(child: listContents); -// } -// List list = [ -// Container( -// height: 100 + height, -// padding: EdgeInsets.only(left: 0, top: height), -// alignment: Alignment.centerLeft, -// child: IconButton( -// icon: Icon(Icons.clear, color: ColorConsts.textGrey), -// onPressed: () { -// if (_scaffoldKey.currentState.isDrawerOpen) { -// Navigator.pop(context); -// } -// }, -// ), -// ), -// Container( -// margin: EdgeInsets.only(top: 8, bottom: 16), -// padding: EdgeInsets.only(left: 16, right: 16), -// child: Row( -// mainAxisAlignment: MainAxisAlignment.spaceEvenly, -// children: [ -// commonIconButton("assets/icons/bookmark.svg", () { -// Navigator.pushNamed(context, BookmarkScreen.routeName); -// }), -// commonIconButton("assets/icons/increase_size.svg", () { -// if (fontSize >= 36) { -// Utils.showToast("وصل حجم الخط إلى الحد الأقصى للحجم"); -// return; -// } -// fontSize += 2; -// prefs.setInt(GlobalConsts.fontZoomSize, fontSize); -// Utils.showToast("زيادة حجم الخط"); -// }), -// commonIconButton("assets/icons/reduce_size.svg", () { -// if (fontSize <= 12) { -// Utils.showToast("وصل حجم الخط إلى الحد الأدنى للحجم"); -// return; -// } -// fontSize -= 2; -// prefs.setInt(GlobalConsts.fontZoomSize, fontSize); -// Utils.showToast("تم تقليل حجم الخط"); -// }), -// commonIconButton("assets/icons/user_logged.svg", () { -// if (AppState().isUserLogin) { -// Utils.showToast("أنت بالفعل تسجيل الدخول"); -// return; -// } -// Navigator.pushNamed(context, LoginScreen.routeName); -// }), -// if (AppState().isUserLogin) -// Expanded( -// child: PopupMenuButton( -// padding: EdgeInsets.fromLTRB(0, 0, 0, 0), -// onSelected: (int index) async { -// if (index == 0) { -// Navigator.pop(context); -// Future.delayed(Duration(milliseconds: 200), () { -// showDialog( -// context: context, -// barrierColor: ColorConsts.secondaryWhite.withOpacity(0.8), -// builder: (BuildContext context) => ChangePasswordDialog( -// onPassword: (oldPassword, password) => updatePassword(AppState().userEmail, oldPassword, password), -// ), -// ); -// }); -// } else if (index == 1) { -// SharedPreferences prefs = await SharedPreferences.getInstance(); -// await prefs.remove(GlobalConsts.userAuthData); -// AppState().setAuthenticationModel(null); -// Utils.showToast("تسجيل خروج المستخدم"); -// Navigator.pop(context); -// } else { -// await showDialog( -// context: context, -// barrierColor: ColorConsts.secondaryWhite.withOpacity(0.8), -// builder: (BuildContext context) => GeneralDialog( -// message: 'بحذف حسابك ، ستتم إزالة بياناتك ولن تتمكن من استرداد حسابك. \ n انقر فوق "نعم" لحذف حسابك.', -// onTap: () { -// Navigator.pop(context); -// deleteUserAccount(); -// }, -// showCancelButton: true, -// ), -// ); -// } -// }, -// icon: SvgPicture.asset("assets/icons/fa_key.svg", height: 25, width: 30, color: ColorConsts.textGrey1), -// itemBuilder: (_) => >[ -// PopupMenuItem( -// value: 0, -// padding: EdgeInsets.fromLTRB(4, 0, 4, 0), -// height: 36, -// child: Center( -// child: Text( -// 'تغيير كلمة المرور', -// style: TextStyle(color: ColorConsts.primaryBlack, fontSize: 16), -// ), -// ), -// ), -// PopupMenuItem( -// value: 1, -// padding: EdgeInsets.fromLTRB(4, 0, 4, 0), -// height: 36, -// child: Center( -// child: Text( -// 'تسجيل خروج', -// style: TextStyle(color: ColorConsts.primaryBlack, fontSize: 16), -// ), -// ), -// ), -// PopupMenuItem( -// value: 2, -// padding: EdgeInsets.fromLTRB(4, 0, 4, 0), -// height: 36, -// child: Center( -// child: Text( -// 'حذف الحساب', -// style: TextStyle(color: ColorConsts.primaryBlack, fontSize: 16), -// ), -// ), -// ), -// ]), -// ), -// ], -// ), -// ), -// listContents, -// Container( -// margin: EdgeInsets.only(top: 16, bottom: 12), -// padding: EdgeInsets.only(left: 32, right: 32), -// child: Row( -// children: [ -// for (QuickLinksData _quickLink in quickLinks) -// commonIconButton(ApiConsts.baseUrl + _quickLink.exposeFilePath, () { -// //for live production server -// // commonIconButton( _quickLink.exposeFilePath, () { -// _launchURL(_quickLink.imageUrl); -// }, size: 35, isAsset: false), -// ], -// ), -// ), -// Padding( -// padding: EdgeInsets.only(left: 32, right: 32, bottom: 8), -// child: Column( -// mainAxisSize: MainAxisSize.min, -// children: [ -// if (_userCopyRight != null) ...[ -// Row( -// crossAxisAlignment: CrossAxisAlignment.center, -// mainAxisAlignment: MainAxisAlignment.center, -// children: [ -// Text( -// _userCopyRight.content, -// maxLines: 1, -// textAlign: TextAlign.right, -// style: TextStyle(fontSize: 12, color: Colors.black87), -// ), -// SizedBox(width: 8), -// Image.network(ApiConsts.baseUrl + _userCopyRight.exposeFilePath, height: 25, width: 30) -// ], -// ), -// SizedBox(height: 8), -// ], -// Row( -// crossAxisAlignment: CrossAxisAlignment.center, -// mainAxisAlignment: MainAxisAlignment.center, -// children: [ -// Text( -// "Powered by Cloud Solutions", -// maxLines: 1, -// textAlign: TextAlign.right, -// style: TextStyle(fontSize: 14, color: Colors.black87), -// ), -// SizedBox(width: 8), -// SvgPicture.asset("assets/logos/cloud_logo.svg", width: 30, height: 30) -// ], -// ), -// ], -// ), -// ) -// ]; -// return isPortrait ? Column(children: list) : ListView(children: list); -// }, -// ), -// ), -// ), -// ); -// } -// -// void _launchURL(String _url) async => await canLaunch(_url) ? await launch(_url) : throw 'Could not launch $_url'; -// -// Widget commonIconButton(String icon, VoidCallback onPressed, {double size, bool isAsset = true}) { -// return Expanded( -// child: IconButton( -// padding: EdgeInsets.zero, -// icon: isAsset ? SvgPicture.asset(icon, height: size ?? 25, width: size ?? 30) : Image.network(icon, height: size ?? 25, width: size ?? 30), -// onPressed: () { -// Navigator.pop(context); -// Future.delayed(Duration(milliseconds: 200), () => onPressed()); -// }), -// ); -// } -// -// Widget myListItem(String icon, String title, bool isSelected, {VoidCallback onTap}) { -// return InkWell( -// onTap: () { -// Navigator.pop(context); -// if (onTap != null) { -// Future.delayed(Duration(milliseconds: 200), () => onTap()); -// } -// }, -// child: Container( -// height: 40, -// padding: EdgeInsets.only(left: 8, right: 8), -// alignment: Alignment.centerRight, -// decoration: BoxDecoration( -// borderRadius: BorderRadius.circular(6), -// gradient: isSelected -// ? LinearGradient( -// stops: [0.0, 0.5], -// begin: Alignment.topCenter, -// end: Alignment.bottomCenter, -// colors: [ColorConsts.gradientPink, ColorConsts.gradientOrange], -// ) -// : null, -// ), -// child: Row( -// mainAxisSize: MainAxisSize.min, -// children: [ -// Text( -// title, -// style: TextStyle(fontSize: 14, color: isSelected ? Colors.white : ColorConsts.textGrey), -// ), -// SizedBox(width: 8), -// SvgPicture.asset(icon, height: 20, width: 20, color: isSelected ? Colors.white : ColorConsts.textGrey), -// ], -// ), -// ), -// ); -// } -// } + void showMenu() { + showDialog( + context: context, + barrierColor: Colors.white.withOpacity(0.2), + builder: (BuildContext context) => AppMenuDialog( + onFontDecrease: () { + if (fontSize <= 12) { + Utils.showToast("وصل حجم الخط إلى الحد الأدنى للحجم"); + return; + } + fontSize -= 2; + prefs.setInt(GlobalConsts.fontZoomSize, fontSize); + Utils.showToast("تم تقليل حجم الخط"); + }, + onFontIncrease: () { + if (fontSize >= 36) { + Utils.showToast("وصل حجم الخط إلى الحد الأقصى للحجم"); + return; + } + fontSize += 2; + prefs.setInt(GlobalConsts.fontZoomSize, fontSize); + Utils.showToast("زيادة حجم الخط"); + }, + goToIndex: (_index) { + Navigator.pop(context); + if (index != _index) + setState(() { + index = _index; + }); + }, + ), + ); + } +} diff --git a/lib/new_ui/screens/home_screen.dart b/lib/new_ui/screens/home_screen.dart index 0bca7f6..c2e64b3 100644 --- a/lib/new_ui/screens/home_screen.dart +++ b/lib/new_ui/screens/home_screen.dart @@ -45,7 +45,7 @@ class _HomeScreenState extends State { SurahModel _surahModel; TangheemType _tangheemType; - ContentInfoModel _contentInfoModel; + String _tangheemDiscription; @override void initState() { @@ -57,9 +57,21 @@ class _HomeScreenState extends State { void getSurahAndTangheemTypes() async { Utils.showLoading(context); try { - _contentInfoModel = await TangheemUserApiClient().getContentInfo(4); - _surahModel = await TangheemUserApiClient().getSurahs(); - AppState().setSurahModel(_surahModel); + if (AppState().tangheemDiscription == null) { + ContentInfoModel _contentInfoModel = await TangheemUserApiClient().getContentInfo(4); + _tangheemDiscription = _contentInfoModel.data.first.content; + AppState().tangheemDiscription = _tangheemDiscription; + } else { + _tangheemDiscription = AppState().tangheemDiscription; + } + + if (AppState().getSurahModel == null) { + _surahModel = await TangheemUserApiClient().getSurahs(); + AppState().setSurahModel(_surahModel); + } else { + _surahModel = AppState().getSurahModel; + } + _surahList = _surahModel.data.map((element) => element.nameAR).toList(); await getTangheemTypes(); TangheemUserApiClient().addStatistics(1); @@ -194,8 +206,7 @@ class _HomeScreenState extends State { 30.height, "موسوعة النبر والتنغيم في الأداء القرآني للأساليب اللغوية".toText(18, color: ColorConsts.darkText, textAlign: TextAlign.center), 10.height, - "تساعدك موسوعة “تنغيم” على أداء الأساليب اللغوية القرآنية (كالاستفهام والإتمام والشرط والقسم) بما يخدم معنى الآية و قد أشرف عليها متخصصون في اللغة العربية والدراسات القرآنية" - .toText(12, color: ColorConsts.brownColor, textAlign: TextAlign.center), + (_tangheemDiscription ?? "").toText(12, color: ColorConsts.brownColor, textAlign: TextAlign.center), SizedBox(height: 20), ValueListenableBuilder( valueListenable: _tangheemListNotifier, diff --git a/lib/ui/common_appbar.dart b/lib/ui/common_appbar.dart index 8e65d35..49369f1 100644 --- a/lib/ui/common_appbar.dart +++ b/lib/ui/common_appbar.dart @@ -133,6 +133,7 @@ class _CommonAppbarState extends State { // drawer: widget.showDrawer ? drawerView() : null, // resizeToAvoidBottomInset: true, // drawerScrimColor: Colors.black.withOpacity(.3), + backgroundColor: ColorConsts.greyF4Color, body: Stack( children: [ // Container( diff --git a/lib/ui/dialogs/app_menu_dialog.dart b/lib/ui/dialogs/app_menu_dialog.dart new file mode 100644 index 0000000..12e53ac --- /dev/null +++ b/lib/ui/dialogs/app_menu_dialog.dart @@ -0,0 +1,119 @@ +import 'dart:ui'; + +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:tangheem/app_state/app_state.dart'; +import 'package:tangheem/classes/colors.dart'; +import 'package:tangheem/extensions/int_extensions.dart'; +import 'package:tangheem/extensions/string_extensions.dart'; +import 'package:tangheem/extensions/widget_extensions.dart'; +import 'package:tangheem/ui/screens/bookmark_screen.dart'; +import 'package:tangheem/ui/screens/login_screen.dart'; +import 'package:tangheem/ui/screens/user_profile_screen.dart'; + +class AppMenuDialog extends StatelessWidget { + final VoidCallback onTap; + final Function(int) goToIndex; + final VoidCallback onFontIncrease; + final VoidCallback onFontDecrease; + + AppMenuDialog({Key key, this.onTap, this.goToIndex, this.onFontIncrease, this.onFontDecrease}) : super(key: key); + + @override + Widget build(BuildContext context) { + return BackdropFilter( + filter: ImageFilter.blur(sigmaX: 4, sigmaY: 4), + child: Dialog( + insetPadding: EdgeInsets.symmetric(horizontal: 60.0, vertical: 24.0), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20), + ), + elevation: 0, + backgroundColor: Colors.transparent, + child: Container( + width: MediaQuery.of(context).size.width * 245 / 375, + padding: EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.white.withOpacity(.91), + borderRadius: BorderRadius.circular(20), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + 58.height, + menuItem("الرئيسية", "assets/icons/new/home.svg", 0), + Container(width: 50, height: 1, color: ColorConsts.greyB5Color).paddingOnly(top: 16, bottom: 16), + menuItem("عن الموسوعة", "assets/icons/new/intro.svg", 1), + Container(width: 50, height: 1, color: ColorConsts.greyB5Color).paddingOnly(top: 16, bottom: 16), + menuItem("اللجنة الإشرافية", "assets/icons/new/members.svg", 4), + Container(width: 50, height: 1, color: ColorConsts.greyB5Color).paddingOnly(top: 16, bottom: 16), + menuItem("قراءة القرآن الكريم", "assets/icons/new/quran.svg", 2), + Row( + mainAxisSize: MainAxisSize.min, + children: [ + menuOptions("assets/icons/new/bookmark.svg").onPress(() { + Navigator.pop(context); + Navigator.pushNamed(context, BookmarkScreen.routeName); + }), + 14.width, + menuOptions("assets/icons/new/zoom_in.svg").onPress(onFontIncrease), + 14.width, + menuOptions("assets/icons/new/zoom_out.svg").onPress(onFontDecrease), + 14.width, + menuOptions("assets/icons/new/user_acount.svg").onPress(() { + Navigator.pop(context); + if (AppState().isUserLogin) { + Navigator.pushNamed(context, UserProfileScreen.routeName); + } else + Navigator.pushNamed(context, LoginScreen.routeName); + }), + ], + ).paddingOnly(top: 32, bottom: 32), + Container( + height: 26, + padding: EdgeInsets.only(right: 16, left: 12), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(32.0), + color: ColorConsts.brownLightColor, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Icon(Icons.play_arrow_outlined, size: 20, color: Colors.white), + "تصفح وتحميل الموسوعة".toText(13), + ], + ), + ).onPress(() { + goToIndex(5); + }) + ], + ), + ), + ), + ); + } + + Widget menuOptions(String icon) { + return SvgPicture.asset( + icon, + width: 25, + height: 25, + color: ColorConsts.greyBAColor, + ); + } + + Widget menuItem(String title, String icon, int index) { + return Column( + children: [ + SvgPicture.asset( + icon, + width: 25, + height: 25, + color: ColorConsts.darkText, + ), + 6.height, + title.toText(13, color: ColorConsts.darkText) + ], + ).onPress(() => goToIndex(index)); + } +} diff --git a/lib/ui/dialogs/general_dialog.dart b/lib/ui/dialogs/general_dialog.dart index 718ca23..df61718 100644 --- a/lib/ui/dialogs/general_dialog.dart +++ b/lib/ui/dialogs/general_dialog.dart @@ -1,82 +1,102 @@ +import 'dart:ui'; + import 'package:flutter/material.dart'; import 'package:tangheem/classes/colors.dart'; +import 'package:tangheem/extensions/int_extensions.dart'; +import 'package:tangheem/extensions/string_extensions.dart'; +import 'package:tangheem/extensions/widget_extensions.dart'; class GeneralDialog extends StatelessWidget { final String message; + final String buttonTitle; final VoidCallback onTap; final bool showCancelButton; + final Color backgroundColor; + final Color buttonBorderColor; - GeneralDialog({Key key, this.message, this.onTap, this.showCancelButton = false}) : super(key: key); + GeneralDialog({Key key, this.message, this.buttonTitle, this.onTap, this.showCancelButton = false, this.backgroundColor,this.buttonBorderColor}) : super(key: key); @override Widget build(BuildContext context) { - return Dialog( - insetPadding: EdgeInsets.symmetric(horizontal: 60.0, vertical: 24.0), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12), - ), - elevation: 0, - backgroundColor: Colors.transparent, - child: Container( - width: double.infinity, - decoration: BoxDecoration( - color: ColorConsts.primaryBlue, - borderRadius: BorderRadius.circular(16), + return BackdropFilter( + filter: ImageFilter.blur(sigmaX: 4, sigmaY: 4), + child: Dialog( + insetPadding: EdgeInsets.symmetric(horizontal: 60.0, vertical: 24.0), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(25), ), - padding: EdgeInsets.symmetric(vertical: 32, horizontal: 16), - child: Column( - mainAxisSize: MainAxisSize.min, + elevation: 0, + backgroundColor: Colors.transparent, + child: Stack( children: [ - Text( - message ?? "للحصول على تجربة أفضل ، يرجى إمالة هاتفك واستخدام التطبيق في الوضع الأفقي", - textAlign: TextAlign.center, - style: TextStyle(color: Colors.white), - ), - SizedBox(height: 32), - Row( - children: [ - if (showCancelButton) - Expanded( - child: SizedBox( - width: double.infinity, - height: 40, - child: TextButton( - onPressed: () => Navigator.pop(context), - style: TextButton.styleFrom( - primary: Colors.black87, - padding: EdgeInsets.all(2), - backgroundColor: ColorConsts.textHintGrey, - textStyle: TextStyle(fontSize: 14, fontFamily: "DroidKufi"), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(6.0), + Container( + width: MediaQuery.of(context).size.width * 239 / 375, + decoration: BoxDecoration( + color: backgroundColor ?? ColorConsts.brownLightColor.withOpacity(0.60), + borderRadius: BorderRadius.circular(16), + ), + padding: EdgeInsets.symmetric(vertical: 24, horizontal: 16), + margin: EdgeInsets.only(top: 11), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + (message ?? "للحصول على تجربة أفضل ، يرجى إمالة هاتفك واستخدام التطبيق في الوضع الأفقي").toText(17, textAlign: TextAlign.center, height: 22), + 18.height, + Row( + mainAxisSize: MainAxisSize.min, + children: [ + if (showCancelButton) + Expanded( + child: SizedBox( + width: double.infinity, + height: 36, + child: TextButton( + onPressed: () => Navigator.pop(context), + style: TextButton.styleFrom( + primary: Colors.black87, + padding: EdgeInsets.all(2), + backgroundColor: ColorConsts.textHintGrey, + textStyle: TextStyle(fontSize: 14, fontFamily: "DroidKufi"), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(6.0), + ), + ), + child: Text("لا"), + ), ), ), - child: Text("لا"), - ), - ), - ), - if (showCancelButton) SizedBox(width: 16), - Expanded( - child: SizedBox( - width: double.infinity, - height: 40, - child: TextButton( - onPressed: onTap ?? () => Navigator.pop(context), - style: TextButton.styleFrom( - primary: Colors.white, - padding: EdgeInsets.all(2), - backgroundColor: ColorConsts.secondaryPink, - textStyle: TextStyle(fontSize: 14, fontFamily: "DroidKufi"), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(6.0), + if (showCancelButton) SizedBox(width: 16), + SizedBox( + width: double.infinity, + height: 36, + child: TextButton( + onPressed: onTap ?? () => Navigator.pop(context), + style: TextButton.styleFrom( + // primary: Colors.white, + padding: EdgeInsets.all(0), + backgroundColor: Colors.transparent, + textStyle: TextStyle(fontSize: 14, fontFamily: "DroidKufi"), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(25.0), side: BorderSide(color: buttonBorderColor ?? Colors.white, width: 2)), + ), + child: (buttonTitle ?? "تأكيد").toText(14), ), - ), - child: Text("نعم"), - ), + ).paddingOnly(left: 50, right: 50).expanded, + ], ), - ), - ], + ], + ), ), + Container( + height: 22, + width: 22, + margin: EdgeInsets.only(left: 16), + decoration: BoxDecoration(shape: BoxShape.circle, color: ColorConsts.brownLightColor), + child: Icon( + Icons.clear, + size: 16, + color: Colors.white, + ), + ).onPress(() => Navigator.pop(context)), ], ), ), diff --git a/lib/ui/screens/bookmark_screen.dart b/lib/ui/screens/bookmark_screen.dart index b449898..c895466 100644 --- a/lib/ui/screens/bookmark_screen.dart +++ b/lib/ui/screens/bookmark_screen.dart @@ -3,6 +3,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:tangheem/classes/colors.dart'; import 'package:tangheem/classes/utils.dart'; +import 'package:tangheem/extensions/int_extensions.dart'; +import 'package:tangheem/extensions/string_extensions.dart'; +import 'package:tangheem/extensions/widget_extensions.dart'; import 'package:tangheem/models/bookmark_model.dart'; import 'package:tangheem/models/surah_model.dart'; import 'package:tangheem/ui/misc/no_data_ui.dart'; @@ -55,67 +58,95 @@ class _BookmarkScreenState extends State { @override Widget build(BuildContext context) { - return _bookMarkList.isEmpty - ? NoDataUI() - : ListView.separated( - physics: BouncingScrollPhysics(), - padding: EdgeInsets.all(16), - itemCount: _bookMarkList.length, - separatorBuilder: (context, index) { - return SizedBox(height: 8); - }, - itemBuilder: (context, index) { - return Slidable( - controller: _slidableController, - actionPane: SlidableBehindActionPane(), - secondaryActions: [ - IconSlideAction( - color: Colors.redAccent, - icon: Icons.delete, - closeOnTap: true, - onTap: () { - _bookMarkList.removeAt(index); - BookMarkModel.saveToPrefs(_bookMarkList); - Utils.showToast("تم حذف المرجع"); - setState(() {}); - }, - ), - ], - child: ListTile( - tileColor: Colors.white, - contentPadding: EdgeInsets.fromLTRB(12, 8, 12, 8), - onTap: () { - Navigator.pushNamed(context, QuranScreen.routeName, arguments: _bookMarkList[index]); - }, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(4), - ), - title: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - _bookMarkList[index].surahNameAR + ":", - style: TextStyle(fontSize: 12, color: ColorConsts.primaryBlue), - ), - Text( - " ${_bookMarkList[index].numberInSurah}", - style: TextStyle(fontSize: 14, fontFamily: "BArabics", color: ColorConsts.secondaryOrange), + return Stack( + children: [ + Stack( + alignment: Alignment.center, + children: [ + AspectRatio( + aspectRatio: 375 / 215, + child: Image.asset("assets/icons/new/quran_bg.jpg", fit: BoxFit.cover, alignment: Alignment(-0.3, 0.5)), + ), + Column( + mainAxisSize: MainAxisSize.min, + children: [ + Image.asset('assets/icons/new/Tangeem-logo-W.png', width: 50), + 26.height, + "المرجعية".toText(30), + ], + ).paddingOnly(top: 16), + ], + ), + _bookMarkList.isEmpty + ? NoDataUI().paddingOnly(top: 215) + : ListView.separated( + physics: BouncingScrollPhysics(), + padding: EdgeInsets.only(left: 24, right: 24, top: 215, bottom: 24), + itemCount: _bookMarkList.length, + separatorBuilder: (context, index) { + return SizedBox(height: 8); + }, + itemBuilder: (context, index) { + return Slidable( + controller: _slidableController, + actionPane: SlidableBehindActionPane(), + secondaryActions: [ + ClipRRect( + borderRadius: BorderRadius.circular(20), + child: IconSlideAction( + color: Colors.redAccent, + icon: Icons.delete, + closeOnTap: true, + onTap: () { + _bookMarkList.removeAt(index); + BookMarkModel.saveToPrefs(_bookMarkList); + Utils.showToast("تم حذف المرجع"); + setState(() {}); + }, + ), ), ], - ), - subtitle: Text( - _bookMarkList[index].reverseAyatNumber(), - textAlign: TextAlign.start, - style: TextStyle( - fontFamily: "UthmanicHafs", - fontSize: 16, - color: ColorConsts.primaryBlue, - fontWeight: FontWeight.bold, - ), - ), - ), - ); - }, - ); + child: Container( + width: double.infinity, + padding: EdgeInsets.fromLTRB(12, 12, 12, 12), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + border: Border.all(color: ColorConsts.greyE0Color, width: 1), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Row( + mainAxisSize: MainAxisSize.min, + children: [ + (_bookMarkList[index].surahNameAR + ":").toText(12, color: ColorConsts.primaryBlue), + Text( + " ${_bookMarkList[index].numberInSurah}", + style: TextStyle(fontSize: 14, fontFamily: "BArabics", color: ColorConsts.secondaryOrange), + ), + ], + ), + Text( + _bookMarkList[index].reverseAyatNumber(), + textAlign: TextAlign.start, + style: TextStyle( + fontFamily: "UthmanicHafs", + fontSize: 16, + color: ColorConsts.primaryBlue, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ).onPress(() { + Navigator.pushNamed(context, QuranScreen.routeName, arguments: _bookMarkList[index]); + }), + ); + }, + ), + ], + ); } } diff --git a/lib/ui/screens/change_password_screen.dart b/lib/ui/screens/change_password_screen.dart new file mode 100644 index 0000000..129bd84 --- /dev/null +++ b/lib/ui/screens/change_password_screen.dart @@ -0,0 +1,143 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:tangheem/api/user_api_client.dart'; +import 'package:tangheem/app_state/app_state.dart'; +import 'package:tangheem/classes/colors.dart'; +import 'package:tangheem/classes/consts.dart'; +import 'package:tangheem/classes/utils.dart'; +import 'package:tangheem/extensions/int_extensions.dart'; +import 'package:tangheem/extensions/string_extensions.dart'; +import 'package:tangheem/extensions/widget_extensions.dart'; +import 'package:tangheem/ui/dialogs/general_dialog.dart'; +import 'package:tangheem/widgets/login_textfield_widget.dart'; + +class ChangePasswordScreen extends StatefulWidget { + static const String routeName = "/changePassword"; + + ChangePasswordScreen({Key key}) : super(key: key); + + @override + _ChangePasswordScreenState createState() { + return _ChangePasswordScreenState(); + } +} + +class _ChangePasswordScreenState extends State { + final TextEditingController _currentPasswordController = TextEditingController(); + final TextEditingController _passwordController = TextEditingController(); + final TextEditingController _confirmPasswordController = TextEditingController(); + + @override + void initState() { + super.initState(); + } + + @override + void dispose() { + super.dispose(); + } + + void updatePassword(String email, String oldPassword, String password) async { + Utils.showLoading(context); + try { + await UserApiClient().updatePassword(email, oldPassword, password); + } catch (ex) { + if (mounted) Utils.handleException(ex, null); + Utils.hideLoading(context); + return; + } finally { + Utils.hideLoading(context); + } + SharedPreferences prefs = await SharedPreferences.getInstance(); + await prefs.remove(GlobalConsts.userAuthData); + AppState().setAuthenticationModel(null); + await showDialog( + context: context, + barrierColor: Colors.white.withOpacity(0.2), + builder: (BuildContext context) => GeneralDialog( + message: "تم تغيير كلمة المرور بنجاح , الرجاء إعادة تسجيل الدخول من خلال الرابط المرسل إلى بريدك الإلكتروني", + backgroundColor: Color(0xff598A8D), + ), + ); + Navigator.pop(context); + } + + @override + Widget build(BuildContext context) { + return SizedBox( + width: double.infinity, + child: Stack( + alignment: Alignment.topCenter, + children: [ + Image.asset( + "assets/icons/new/home_dark.jpg", + fit: BoxFit.cover, + height: double.infinity, + opacity: const AlwaysStoppedAnimation(1), + ), + Container(color: ColorConsts.darkText.withOpacity(0.8)), + Column( + mainAxisSize: MainAxisSize.min, + children: [ + 100.height, + Image.asset('assets/icons/new/Tangeem-logo-W.png', width: 50), + 100.height, + Container( + width: 54, + height: 54, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: ColorConsts.dark2Text, + ), + child: SvgPicture.asset( + "assets/icons/new/user_acount.svg", + color: Colors.white, + ), + ), + 14.height, + (AppState().userName ?? "").toText(18), + 50.height, + "تغيير كلمة المرور".toText(20), + 24.height, + LoginTextFieldWidget(hint: "كلمة المرور الحالية", controller: _currentPasswordController, iconData: Icons.lock_rounded, isPassword: true, isForChangePassword: true), + 10.height, + LoginTextFieldWidget(hint: "كلمة المرور الجديدة", controller: _passwordController, iconData: Icons.lock_rounded, isForChangePassword: true), + 10.height, + LoginTextFieldWidget(hint: "تأكيد كلمة المرور الجديدة", controller: _confirmPasswordController, iconData: Icons.lock_rounded, isPassword: true, isForChangePassword: true), + 16.height, + Container( + height: 45, + // width: 165, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(32), + border: Border.all(color: ColorConsts.brownLightColor, width: 2), + ), + child: "إعادة تعيين كلمة لمرور".toText(13), + ).onPress(() { + if (_currentPasswordController.text.length < 1) { + Utils.showToast("يرجى إاخال كلمة المرور"); + return; + } + if (_passwordController.text.length < 1) { + Utils.showToast("يرجى إاخال كلمة المرور"); + return; + } + if (_confirmPasswordController.text.length < 1) { + Utils.showToast("يرجى تأكيد كلمة المرور"); + return; + } + if (_passwordController.text != _confirmPasswordController.text) { + Utils.showToast("خطأ في تطابق كلمات المرور"); + return; + } + updatePassword(AppState().userEmail, _currentPasswordController.text, _passwordController.text); + }) + ], + ).paddingOnly(left: 65, right: 65), + ], + ), + ); + } +} diff --git a/lib/ui/screens/quran_screen.dart b/lib/ui/screens/quran_screen.dart index f00511a..dccd342 100644 --- a/lib/ui/screens/quran_screen.dart +++ b/lib/ui/screens/quran_screen.dart @@ -9,11 +9,15 @@ import 'package:tangheem/app_state/app_state.dart'; import 'package:tangheem/classes/colors.dart'; import 'package:tangheem/classes/consts.dart'; import 'package:tangheem/classes/utils.dart'; +import 'package:tangheem/extensions/int_extensions.dart'; +import 'package:tangheem/extensions/string_extensions.dart'; +import 'package:tangheem/extensions/widget_extensions.dart'; import 'package:tangheem/models/aya_model.dart'; import 'package:tangheem/models/aya_tangheem_type_mapped.dart'; import 'package:tangheem/models/bookmark_model.dart'; import 'package:tangheem/models/surah_model.dart'; import 'package:tangheem/widgets/common_dropdown_button.dart'; +import 'package:tangheem/widgets/new/CommonHeader.dart'; import 'tangheem_detail_screen.dart'; @@ -191,7 +195,6 @@ class _QuranScreenState extends State { _currentSurahIndex = index; } String _surahAya = ""; - _ayaModel?.data?.forEach((element) { var temp = element.numberInSurah == 1 ? getBismillahWithSurahName(element.surahID, element.surahNameAR, element.surahID != 1, _surahAya.length <= 1) + element.reverseAyatNumber() @@ -200,108 +203,76 @@ class _QuranScreenState extends State { }); _surahAya = _surahAya + "\n" + "$_currentPage"; + // _surahAya = _surahAya + "\n" + "$_currentPage"; List widList = [ - Text( - "اقرأ القرآن الكريم", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20, color: ColorConsts.primaryBlue, height: 1), - ), - SizedBox(height: 4), - Text( - "قراءة وسماع آيات القرآن الكريم", - style: TextStyle(fontWeight: FontWeight.w600, fontSize: 16, color: ColorConsts.primaryBlue), - ), - SizedBox(height: 4), - Text( - "اضغط الآية المرغوبة لمزيد من التفاصيل", - style: TextStyle( - fontSize: 12, - color: ColorConsts.primaryBlue, - ), - ), - SizedBox(height: 16), + "اقرأ القرآن الكريم".toText(30), + 8.height, + "اختر السورة والآيات التي تريد قراءتها".toText(14), + 16.height, + CommonDropDownButton( + index: _selectedSurah, + hintText: "اختر السورة", + list: _surahList, + onSelect: (index) { + if (_selectedSurah != index) { + _selectedSurah = index; + _selectedToAya = -1; + _selectedFromAya = -1; + _toAyaList = []; + filterData(); + } + }).paddingOnly(left: 41, right: 41), + 10.height, Row( children: [ Expanded( - child: CommonDropDownButton(_selectedSurah, hintText: "اختر السورة", list: _surahList, onSelect: (index) { - if (_selectedSurah != index) { - _selectedSurah = index; - _selectedToAya = -1; - _selectedFromAya = -1; - _toAyaList = []; - filterData(); - } - }), + child: CommonDropDownButton( + index: _selectedToAya, + hintText: "إلى الآية", + list: _toAyaList.map((e) => "إلى الآية" + " $e").toList(), + onSelect: (index) { + if (_selectedToAya != index) { + _selectedToAya = index; + setState(() {}); + } + }), ), - SizedBox(width: 4), + 12.width, Expanded( - child: CommonDropDownButton(_selectedFromAya, hintText: "من الآية", list: _fromAyaList.map((e) => "من الآية" + " $e").toList(), onSelect: (index) { - if (_selectedFromAya != index) { - _selectedFromAya = index; - _selectedToAya = -1; - filteredAyahList.indexOf(_selectedFromAya); - _toAyaList = filteredAyahList.getRange(_selectedFromAya + 1, filteredAyahList.length)?.toList() ?? []; - setState(() {}); - } - }), - ), - SizedBox(width: 4), - Expanded( - child: CommonDropDownButton(_selectedToAya, hintText: "إلى الآية", list: _toAyaList.map((e) => "إلى الآية" + " $e").toList(), onSelect: (index) { - if (_selectedToAya != index) { - _selectedToAya = index; - setState(() {}); - } - }), + child: CommonDropDownButton( + index: _selectedFromAya, + hintText: "من الآية", + list: _fromAyaList.map((e) => "من الآية" + " $e").toList(), + onSelect: (index) { + if (_selectedFromAya != index) { + _selectedFromAya = index; + _selectedToAya = -1; + filteredAyahList.indexOf(_selectedFromAya); + _toAyaList = filteredAyahList.getRange(_selectedFromAya + 1, filteredAyahList.length)?.toList() ?? []; + setState(() {}); + } + }), ), ], - ), - SizedBox(height: 8), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - commonIconButton("عرض", "assets/icons/go_forward.svg", () { - if (_selectedSurah < 0) { - Utils.showToast("يرجى اختيار السورة"); - return; - } else { - if (_selectedFromAya < 0 && _selectedToAya < 0) { - _currentPage = _surahModel?.data[_selectedSurah]?.startPageNo; - getQuranByPageNo(); - return; - } - if (_selectedFromAya >= 0 && _selectedToAya >= 0) { - getAyaByRange(); - return; - } - } - }), - Row( - mainAxisSize: MainAxisSize.min, - children: [ - zoomButtons("assets/icons/reduce_size.svg", () { - if (fontSize <= 12) { - Utils.showToast("وصل حجم الخط إلى الحد الأدنى للحجم"); - return; - } - fontSize -= 2; - prefs.setInt(GlobalConsts.fontZoomSize, fontSize); - setState(() {}); - }), - zoomButtons("assets/icons/increase_size.svg", () { - if (fontSize >= 36) { - Utils.showToast("وصل حجم الخط إلى الحد الأقصى للحجم"); - return; - } - fontSize += 2; - prefs.setInt(GlobalConsts.fontZoomSize, fontSize); - setState(() {}); - }), - ], - ) - ], - ), - SizedBox(height: 16), + ).paddingOnly(left: 41, right: 41), + 10.height, + commonIconButton(() { + if (_selectedSurah < 0) { + Utils.showToast("يرجى اختيار السورة"); + return; + } else { + if (_selectedFromAya < 0 && _selectedToAya < 0) { + _currentPage = _surahModel?.data[_selectedSurah]?.startPageNo; + getQuranByPageNo(); + return; + } + if (_selectedFromAya >= 0 && _selectedToAya >= 0) { + getAyaByRange(); + return; + } + } + }).paddingOnly(left: 41, right: 41), ]; Widget quranTextView = SingleChildScrollView( @@ -311,16 +282,17 @@ class _QuranScreenState extends State { child: quranText(), ), ); - if (MediaQuery.of(context).orientation == Orientation.portrait) { - quranTextView = Expanded(child: quranTextView); - } + // if (MediaQuery.of(context).orientation == Orientation.portrait) { + // quranTextView = Expanded(child: quranTextView); + // } Widget quranView = Container( - margin: EdgeInsets.only(top: 4, bottom: 4), - padding: EdgeInsets.only(top: 16, bottom: 4, right: 16, left: 16), + margin: EdgeInsets.only(top: 28, bottom: 14), + padding: EdgeInsets.only(top: 16, bottom: 12, right: 16, left: 16), decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), + color: ColorConsts.brownLightECColor, + borderRadius: BorderRadius.circular(20), + border: Border.all(color: ColorConsts.brownB7CColor, width: 0.35), ), child: Column( mainAxisSize: MainAxisSize.min, @@ -328,17 +300,8 @@ class _QuranScreenState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - nextOptionButton( - "assets/icons/prev.svg", - _currentSurahIndex <= 0 ? "" : Utils.getNotNullValue(_surahList, _currentSurahIndex - 1) ?? "", - _currentSurahIndex <= 0 - ? null - : (value) { - _currentPage = _surahModel?.data?.elementAt(_surahList.indexOf(value))?.startPageNo ?? _currentPage; - _clearFilterAndRefreshData(); - }), previousOptionButton( - "assets/icons/next.svg", + Icons.arrow_back_ios_rounded, _currentSurahIndex >= (_surahList.isNotEmpty ? (_surahList.length - 1) : 0) ? "" : Utils.getNotNullValue(_surahList, _currentSurahIndex + 1) ?? "", _currentSurahIndex >= (_surahList.isNotEmpty ? (_surahList.length - 1) : 0) ? null @@ -346,93 +309,156 @@ class _QuranScreenState extends State { _currentPage = _surahModel?.data?.singleWhere((element) => element.nameAR == value)?.startPageNo ?? _currentPage; _clearFilterAndRefreshData(); }), + nextOptionButton( + Icons.arrow_forward_ios_rounded, + _currentSurahIndex <= 0 ? "" : Utils.getNotNullValue(_surahList, _currentSurahIndex - 1) ?? "", + _currentSurahIndex <= 0 + ? null + : (value) { + _currentPage = _surahModel?.data?.elementAt(_surahList.indexOf(value))?.startPageNo ?? _currentPage; + _clearFilterAndRefreshData(); + }), ], ), - quranTextView, - SizedBox(height: 4), - if (_selectedFromAya == -1 && _selectedToAya == -1) - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - nextOptionButton( - "assets/icons/prev_single.svg", - "الصفحة السابقة", - _currentPage <= 1 - ? null - : (value) { - _currentPage = _currentPage - 1; - _clearFilterAndRefreshData(); - }), - previousOptionButton( - "assets/icons/next_single.svg", - "الصفحة التالية", - _currentPage == 604 - ? null - : (value) { - _currentPage = _currentPage + 1; - _clearFilterAndRefreshData(); - }), - ], - ), + quranText(), + Row( + children: [ + Column( + mainAxisSize: MainAxisSize.min, + children: [ + SvgPicture.asset("assets/icons/new/dimension.svg", width: 12, color: ColorConsts.brownLightColor), + "ت".toText(12, color: ColorConsts.brownLightColor), + ], + ).onPress(() { + if (fontSize <= 12) { + Utils.showToast("وصل حجم الخط إلى الحد الأدنى للحجم"); + return; + } + fontSize -= 2; + prefs.setInt(GlobalConsts.fontZoomSize, fontSize); + setState(() {}); + }), + 12.width, + Column( + mainAxisSize: MainAxisSize.min, + children: [ + SvgPicture.asset("assets/icons/new/dimension.svg", width: 16, color: ColorConsts.brownLightColor), + "ت".toText(16, color: ColorConsts.brownLightColor), + ], + ).onPress(() { + if (fontSize >= 36) { + Utils.showToast("وصل حجم الخط إلى الحد الأقصى للحجم"); + return; + } + fontSize += 2; + prefs.setInt(GlobalConsts.fontZoomSize, fontSize); + setState(() {}); + }) + ], + ) + // quranTextView, ], ), ); - if (MediaQuery.of(context).orientation == Orientation.portrait) { - quranView = Expanded(child: quranView); - } - - List finalViewList = [] + widList + [if (_surahAya.isNotEmpty) quranView]; + // if (MediaQuery.of(context).orientation == Orientation.portrait) { + // quranView = Expanded(child: quranView); + // } + List finalViewList = [] + + widList + + [ + if (_surahAya.isNotEmpty && _surahAya.length > 2) ...[ + quranView, + if (_selectedFromAya == -1 && _selectedToAya == -1) + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + previousOptionButton( + Icons.arrow_back_ios_rounded, + "الصفحة التالية", + _currentPage == 604 + ? null + : (value) { + _currentPage = _currentPage + 1; + _clearFilterAndRefreshData(); + }), + nextOptionButton( + Icons.arrow_forward_ios_rounded, + "الصفحة السابقة", + _currentPage <= 1 + ? null + : (value) { + _currentPage = _currentPage - 1; + _clearFilterAndRefreshData(); + }), + ], + ), + ] + ]; var multiModeView; - if (MediaQuery.of(context).orientation == Orientation.portrait) { - multiModeView = Padding( - padding: EdgeInsets.fromLTRB(16, 24, 16, 0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: finalViewList, - ), - ); - } else { - multiModeView = ListView( - padding: EdgeInsets.fromLTRB(16, 24, 16, 0), - physics: BouncingScrollPhysics(), - children: finalViewList, - ); - } - return SizedBox(width: double.infinity, child: multiModeView); + // if (MediaQuery.of(context).orientation != Orientation.portrait) { + // multiModeView = Padding( + // padding: EdgeInsets.fromLTRB(16, 24, 16, 0), + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.center, + // children: finalViewList, + // ), + // ); + // } else { + // multiModeView = ListView( + // padding: EdgeInsets.fromLTRB(16, 24, 16, 0), + // physics: BouncingScrollPhysics(), + // children: finalViewList, + // ); + // } + + multiModeView = SingleChildScrollView( + padding: EdgeInsets.fromLTRB(24, 96, 24, 140), + physics: BouncingScrollPhysics(), + child: Column(children: finalViewList), + ); + + return SizedBox( + width: double.infinity, + child: Stack( + children: [ + AspectRatio( + aspectRatio: 375 / 345, + child: Image.asset("assets/icons/new/quran_bg.jpg", fit: BoxFit.cover, alignment: Alignment(-0.7, 0.5)), + ), + multiModeView + ], + ), + ); } - Widget commonIconButton(String title, String iconString, VoidCallback callback) { + Widget commonIconButton(VoidCallback callback) { return InkWell( splashColor: Colors.transparent, highlightColor: Colors.transparent, onTap: callback, child: Container( height: 36, + alignment: Alignment.center, decoration: BoxDecoration( - color: callback == null ? ColorConsts.secondaryPink.withOpacity(.5) : ColorConsts.secondaryPink, - borderRadius: BorderRadius.circular(6), + color: callback == null ? ColorConsts.brownLightColor.withOpacity(.5) : ColorConsts.brownLightColor.withOpacity(.5), + borderRadius: BorderRadius.circular(10), ), padding: EdgeInsets.fromLTRB(8, 2, 8, 2), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - Text( - title, - maxLines: 1, - style: TextStyle(fontSize: 12, color: Colors.white), - ), - SizedBox(width: 12), - SvgPicture.asset(iconString, width: 20, height: 20, color: Colors.white), + Transform.rotate(angle: 1, child: Icon(Icons.play_arrow_outlined, size: 20, color: ColorConsts.brownLightColor)), + 8.width, + "البحث".toText(14, color: ColorConsts.brownLightColor), ], ), ), ); } - Widget nextOptionButton(String icon, String text, Function(String) onPressed) { + Widget nextOptionButton(IconData icon, String text, Function(String) onPressed) { return InkWell( onTap: () => onPressed(text), child: onPressed == null @@ -441,12 +467,8 @@ class _QuranScreenState extends State { crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - SvgPicture.asset(icon, height: 12, width: 12), - SizedBox(width: 4), - Text( - text, - style: TextStyle(color: ColorConsts.textGrey), - ), + text.toText(10, color: ColorConsts.greyA7Color), + Icon(icon, color: ColorConsts.greyA7Color, size: 10), ], ), ); @@ -486,7 +508,7 @@ class _QuranScreenState extends State { ); } - Widget previousOptionButton(String icon, String text, Function(String) onPressed) { + Widget previousOptionButton(IconData icon, String text, Function(String) onPressed) { return InkWell( onTap: () => onPressed(text), child: onPressed == null @@ -495,12 +517,8 @@ class _QuranScreenState extends State { crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - Text( - text, - style: TextStyle(color: ColorConsts.textGrey), - ), - SizedBox(width: 4), - SvgPicture.asset(icon, height: 12, width: 12), + Icon(icon, color: ColorConsts.greyA7Color, size: 10), + text.toText(10, color: ColorConsts.greyA7Color), ], ), ); @@ -521,7 +539,7 @@ class _QuranScreenState extends State { backgroundColor: _selectedAyaForBookmark?.ayahID == element.ayahID ? ColorConsts.secondaryOrange.withOpacity(.4) : Colors.transparent, fontFamily: "UthmanicHafs", fontSize: fontSize.toDouble(), - color: ColorConsts.primaryBlue, + color: ColorConsts.brownB6CColor, fontWeight: FontWeight.bold, ), recognizer: TapGestureRecognizer() @@ -540,17 +558,17 @@ class _QuranScreenState extends State { _surahAya = _surahAya + temp + " "; }); - textSpanList.add( - TextSpan( - text: "\n" + "$_currentPage", - style: TextStyle( - fontFamily: "BArabics", - fontSize: fontSize.toDouble(), - color: ColorConsts.primaryBlue, - fontWeight: FontWeight.bold, - ), - ), - ); + // textSpanList.add( // comment fot test + // TextSpan( + // text: "\n" + "$_currentPage", + // style: TextStyle( + // fontFamily: "BArabics", + // fontSize: fontSize.toDouble(), + // color: ColorConsts.primaryBlue, + // fontWeight: FontWeight.bold, + // ), + // ), + // ); _surahAya = _surahAya + "\n" + "$_currentPage"; @@ -639,6 +657,65 @@ class _QuranScreenState extends State { onPressed: onPressed, ); } + + Widget CommonDropDownButton( + {int index = 0, String hintText = "", String icon, Color iconColor, Color color, bool isDropDown = true, VoidCallback onPressed, Function(int) onSelect, double widthHeight, List list}) { + return InkWell( + splashColor: Colors.transparent, + highlightColor: Colors.transparent, + onTap: onPressed, + child: Container( + height: 34, + decoration: BoxDecoration( + color: Colors.transparent, + borderRadius: BorderRadius.circular(10), + border: Border.all(color: ColorConsts.borderDarkText, width: .75), + ), + padding: EdgeInsets.only(left: 17, right: 17), + child: DropdownButtonHideUnderline( + child: DropdownButton( + isExpanded: isDropDown, + dropdownColor: ColorConsts.secondaryWhite, + iconSize: 0, + hint: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Icon(Icons.arrow_drop_down_sharp, color: ColorConsts.borderDarkText), + Text( + (list.isEmpty || index < 0) ? hintText : list[index], + maxLines: 1, + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.end, + style: TextStyle(fontSize: 14, color: ColorConsts.brownColor), + ).expanded, + ], + ), + focusColor: Colors.white, + style: TextStyle(color: Colors.white), + items: !isDropDown + ? [] + : [ + for (int i = 0; i < list.length; i++) + DropdownMenuItem( + value: i, + child: SizedBox( + width: double.infinity, + child: Text( + list[i], + maxLines: 1, + textDirection: TextDirection.rtl, + overflow: TextOverflow.ellipsis, + style: TextStyle(fontSize: 14, color: ColorConsts.primaryBlack), + ), + ), + ) + ], + onChanged: onSelect, + ), + ), + ), + ); + } } class TangheemTemp { diff --git a/lib/ui/screens/tangheem_detail_screen.dart b/lib/ui/screens/tangheem_detail_screen.dart index 41fc617..d35c616 100644 --- a/lib/ui/screens/tangheem_detail_screen.dart +++ b/lib/ui/screens/tangheem_detail_screen.dart @@ -16,7 +16,9 @@ import 'package:tangheem/app_state/app_state.dart'; import 'package:tangheem/classes/colors.dart'; import 'package:tangheem/classes/consts.dart'; import 'package:tangheem/classes/utils.dart'; +import 'package:tangheem/extensions/int_extensions.dart'; import 'package:tangheem/extensions/string_extensions.dart'; +import 'package:tangheem/extensions/widget_extensions.dart'; import 'package:tangheem/models/aya_tangheem_type_mapped.dart'; import 'package:tangheem/models/discussion_model.dart'; import 'package:tangheem/ui/dialogs/discussion_input_dialog.dart'; @@ -431,43 +433,40 @@ class _TangheemDetailScreenState extends State { ), ), ), - SizedBox(height: 8), - discussionView(_discussionModel?.data ?? []), if (_dataList.isNotEmpty) - Container( - margin: EdgeInsets.only(top: 8), - padding: EdgeInsets.only(bottom: 20), - width: double.infinity, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - ), - child: Column( - children: [ - Container( - height: 60, - width: double.infinity, - margin: EdgeInsets.only(bottom: 8), - alignment: Alignment.center, - decoration: BoxDecoration( - color: ColorConsts.primaryBlue, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8), - topRight: Radius.circular(8), - ), + Column( + children: [ + 16.height, + Container( + height: 38, + width: double.infinity, + alignment: Alignment.center, + decoration: BoxDecoration( + color: ColorConsts.brownB1CColor, + borderRadius: BorderRadius.only( + topRight: Radius.circular(20.0), + topLeft: Radius.circular(20.0), ), - child: Text( - "قائمة الأساليب اللغوية في هذه الآية", - style: TextStyle(fontSize: 16, color: Colors.white), + ), + child: "قائمة الأساليب اللغوية في هذه الآية".toText(16), + ), + Container( + decoration: BoxDecoration( + color: Colors.transparent, + border: Border.all(width: 1, color: ColorConsts.greyE0Color), + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), + bottomRight: Radius.circular(20), ), ), - ListView.separated( - padding: EdgeInsets.fromLTRB(4, 8, 4, 4), + child: ListView.separated( + padding: EdgeInsets.all(16), shrinkWrap: true, physics: NeverScrollableScrollPhysics(), itemCount: _dataList.length, - separatorBuilder: (context, index) => SizedBox(height: 16), + separatorBuilder: (context, index) => Divider(height: 1, thickness: 1, color: ColorConsts.greyE0Color).paddingOnly(top: 12, bottom: 12), itemBuilder: (context, index) { + print(index); return InkWell( onTap: () { List list = _dataList; @@ -486,11 +485,13 @@ class _TangheemDetailScreenState extends State { ); }, ), - ], - ), + ), + ], ), SizedBox(height: 16), - AyaRecordWidget() + AyaRecordWidget(), + SizedBox(height: 16), + discussionView(_discussionModel?.data ?? []), ], ), ), @@ -762,80 +763,80 @@ class _TangheemDetailScreenState extends State { children: [ Container( margin: EdgeInsets.only(top: 4, bottom: 25), - padding: EdgeInsets.all(8), + padding: EdgeInsets.all(0), width: double.infinity, decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), + color: Colors.transparent, + borderRadius: BorderRadius.circular(20), + border: Border.all(color: ColorConsts.greyE0Color, width: 1), ), - child: _discussionList.length > 0 - ? ListView.separated( - padding: EdgeInsets.only(top: 4, bottom: 24), - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - itemCount: _discussionList.length, - separatorBuilder: (context, index) => SizedBox(height: 16), - itemBuilder: (context, index) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Row( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + height: 38, + width: double.infinity, + alignment: Alignment.center, + decoration: BoxDecoration( + color: ColorConsts.brownB1CColor, + borderRadius: BorderRadius.only( + topRight: Radius.circular(20.0), + topLeft: Radius.circular(20.0), + ), + ), + child: "التعليقات".toText(16), + ), + _discussionList.isNotEmpty + ? ListView.separated( + padding: EdgeInsets.only(top: 4, bottom: 24, left: 8, right: 8), + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemCount: _discussionList.length, + separatorBuilder: (context, index) => Divider(height: 1, thickness: 1, color: ColorConsts.greyE0Color).paddingOnly(top: 12, bottom: 12), + itemBuilder: (context, index) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, children: [ - SvgPicture.asset( - "assets/icons/chat_user.svg", - width: 60, - height: 60, + Row( + children: [ + SvgPicture.asset( + "assets/icons/chat_user.svg", + width: 60, + height: 60, + ), + SizedBox(width: 8), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + "تعليق على الآية ${_ayatTangheemTypeMappedFirstData.ayatNumberInSurahs}".toText(16, color: ColorConsts.primaryBlue, isBold: true), + SizedBox(height: 4), + Directionality( + textDirection: TextDirection.ltr, + child: _discussionList[index].date.toFormattedDate().toText(12, color: ColorConsts.textGrey), + ), + ], + ), + ], ), - SizedBox(width: 8), + SizedBox(height: 4), Column( crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, children: [ - Text( - "تعليق على الآية ${_ayatTangheemTypeMappedFirstData.ayatNumberInSurahs}", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16, color: ColorConsts.primaryBlue, height: 1.5), - ), - SizedBox(height: 4), - Directionality( - textDirection: TextDirection.ltr, - child: Text( - _discussionList[index].date.toFormattedDate(), - style: TextStyle(fontSize: 12, color: ColorConsts.textGrey, height: 1), - ), - ), + ("تعليق من: " + _discussionList[index].userName).toText(14, isBold: true, color: ColorConsts.primaryBlue), + _discussionList[index].discussionText.toText(14, color: ColorConsts.textGrey), + if ((_discussionList[index]?.adminResponse ?? "").isNotEmpty) SizedBox(height: 4), + if ((_discussionList[index]?.adminResponse ?? "").isNotEmpty) ("رد من المسؤول: " + _discussionList[index].adminResponse).toText(14, color: ColorConsts.textGrey), ], ) ], - ), - SizedBox(height: 4), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "تعليق من: " + _discussionList[index].userName, - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: ColorConsts.primaryBlue, height: 1.5), - ), - Text( - _discussionList[index].discussionText, - style: TextStyle(fontSize: 14, color: ColorConsts.textGrey, height: 1.4), - ), - if ((_discussionList[index]?.adminResponse ?? "").isNotEmpty) SizedBox(height: 4), - if ((_discussionList[index]?.adminResponse ?? "").isNotEmpty) - Text( - "رد من المسؤول: " + _discussionList[index].adminResponse, - style: TextStyle(fontSize: 14, color: ColorConsts.textGrey, height: 1.4), - ), - ], - ) - ], - ); - }, - ) - : Text( - "لا يوجد تعليقات", - style: TextStyle(fontSize: 12, color: ColorConsts.primaryBlue, height: 1.5), - ), + ); + }, + ) + : "لا يوجد تعليقات".toText(14, color: ColorConsts.primaryBlue).paddingOnly(bottom: 24, top: 12), + ], + ), ), Positioned( bottom: 0, @@ -843,7 +844,8 @@ class _TangheemDetailScreenState extends State { borderRadius: BorderRadius.circular(30), onTap: () async { if (!AppState().isUserLogin) { - Widget cancelButton = TextButton(style: TextButton.styleFrom(backgroundColor: ColorConsts.sliderBackground,foregroundColor: ColorConsts.primaryBlack), + Widget cancelButton = TextButton( + style: TextButton.styleFrom(backgroundColor: ColorConsts.sliderBackground, foregroundColor: ColorConsts.primaryBlack), child: Text("أرغب بالتسجيل"), onPressed: () async { Navigator.pop(context); @@ -853,7 +855,8 @@ class _TangheemDetailScreenState extends State { } }, ); - Widget continueButton = TextButton(style: TextButton.styleFrom(backgroundColor: ColorConsts.sliderBackground,foregroundColor: ColorConsts.primaryBlack), + Widget continueButton = TextButton( + style: TextButton.styleFrom(backgroundColor: ColorConsts.sliderBackground, foregroundColor: ColorConsts.primaryBlack), child: Text("استمرار كضيف"), onPressed: () { Navigator.pop(context); @@ -862,7 +865,7 @@ class _TangheemDetailScreenState extends State { ); AlertDialog alert = AlertDialog( content: Text("هذه الخاصية متاحه فقط للأعضاء المسجلين"), - actionsAlignment:MainAxisAlignment.spaceEvenly, + actionsAlignment: MainAxisAlignment.spaceEvenly, actions: [ cancelButton, continueButton, @@ -886,24 +889,14 @@ class _TangheemDetailScreenState extends State { ); }, child: Container( - height: 40, - padding: EdgeInsets.only(left: 24, right: 24), - alignment: Alignment.centerRight, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(30), - color: ColorConsts.gradientPink, - gradient: LinearGradient( - stops: [0.0, 0.5], - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ColorConsts.gradientPink, ColorConsts.gradientOrange], + height: 40, + padding: EdgeInsets.only(left: 28, right: 28), + alignment: Alignment.centerRight, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(30), + color: ColorConsts.greenLightColor, ), - ), - child: Text( - "إضافة تعليق", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: Colors.white, height: 1.5), - ), - ), + child: "إضافة تعليق".toText(14)), ), ), ], diff --git a/lib/ui/screens/tangheem_screen.dart b/lib/ui/screens/tangheem_screen.dart index c19e84e..9f08fb3 100644 --- a/lib/ui/screens/tangheem_screen.dart +++ b/lib/ui/screens/tangheem_screen.dart @@ -3,10 +3,14 @@ import 'package:flutter/material.dart'; import 'package:tangheem/api/tangheem_user_api_client.dart'; import 'package:tangheem/classes/colors.dart'; import 'package:tangheem/classes/utils.dart'; +import 'package:tangheem/extensions/int_extensions.dart'; +import 'package:tangheem/extensions/string_extensions.dart'; +import 'package:tangheem/extensions/widget_extensions.dart'; import 'package:tangheem/models/aya_tangheem_type_mapped.dart'; import 'package:tangheem/models/surah_model.dart'; import 'package:tangheem/ui/misc/no_data_ui.dart'; import 'package:tangheem/ui/screens/tangheem_detail_screen.dart'; +import 'package:tangheem/widgets/new/CommonHeader.dart'; import 'package:tangheem/widgets/text_highlight_widget.dart'; class TangheemScreen extends StatefulWidget { @@ -108,88 +112,106 @@ class _TangheemScreenState extends State { Widget build(BuildContext context) { return _dataList == null ? SizedBox() - : _dataList.isEmpty - ? NoDataUI() - : ListView.separated( - controller: _controller, - physics: BouncingScrollPhysics(), - padding: EdgeInsets.all(16), - itemCount: _dataList.length, - separatorBuilder: (context, index) { - return SizedBox(height: 8); - }, - itemBuilder: (context, index) { - return InkWell( - onTap: () { - if (widget.tangheemQuery == null) { - List list = [] + _dataList; - var removedData = _dataList[index]; - list.remove(removedData); - list.insert(0, removedData); - list = list?.where((element) => (element.ayahNos.contains(removedData.ayahNos)) && (element.tangheemTypeId == removedData.tangheemTypeId))?.toList() ?? []; - TangheemDetailParams tangheem = TangheemDetailParams(selectedTangheemTypeId: removedData.ayaTangheemTypeId, ayatTangheemTypeMappedDataList: list); - Navigator.pushNamed(context, TangheemDetailScreen.routeName, arguments: tangheem); - } else { - var removedData = _dataList[index]; - getTangheemDataForTangheem(removedData.surahNo, removedData.ayatNumberInSurahs, removedData.tangheemTypeId, removedData.ayaTangheemTypeId); - } - }, - borderRadius: BorderRadius.circular(4), - child: Container( - padding: EdgeInsets.fromLTRB(12, 8, 12, 8), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(4), - ), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - _dataList[index].surahNameAr + ":", - style: TextStyle(fontSize: 12, color: ColorConsts.primaryBlue), - ), - Text( - " ${_dataList[index].ayatNumberInSurahs}", - style: TextStyle(fontSize: 14, fontFamily: "BArabics", color: ColorConsts.secondaryOrange), - ), - SizedBox(width: 4), - Text( - "(${_dataList[index].tangheemTypeName})", - style: TextStyle(fontSize: 12, color: ColorConsts.secondaryOrange), - ), - ], + : Stack( + children: [ + Stack( + alignment: Alignment.center, + children: [ + AspectRatio( + aspectRatio: 375 / 215, + child: Image.asset("assets/icons/new/quran_bg.jpg", fit: BoxFit.cover, alignment: Alignment(-0.3, 0.5)), + ), + Column( + mainAxisSize: MainAxisSize.min, + children: [ + Image.asset('assets/icons/new/Tangeem-logo-W.png', width: 50), + 26.height, + widget.tangheemTypeName.toText(30), + 8.height, + "${widget.surah.nameAR}".toText(12, color: ColorConsts.brownB6CColor), + ], + ).paddingOnly(top: 16), + ], + ), + _dataList.isEmpty + ? NoDataUI().paddingOnly(top: 215) + : ListView.separated( + controller: _controller, + physics: BouncingScrollPhysics(), + padding: EdgeInsets.only(left: 24, right: 24, top: 215, bottom: 138), + itemCount: _dataList.length, + separatorBuilder: (context, index) { + return SizedBox(height: 12); + }, + itemBuilder: (context, index) { + return InkWell( + onTap: () { + if (widget.tangheemQuery == null) { + List list = [] + _dataList; + var removedData = _dataList[index]; + list.remove(removedData); + list.insert(0, removedData); + list = list?.where((element) => (element.ayahNos.contains(removedData.ayahNos)) && (element.tangheemTypeId == removedData.tangheemTypeId))?.toList() ?? []; + TangheemDetailParams tangheem = TangheemDetailParams(selectedTangheemTypeId: removedData.ayaTangheemTypeId, ayatTangheemTypeMappedDataList: list); + Navigator.pushNamed(context, TangheemDetailScreen.routeName, arguments: tangheem); + } else { + var removedData = _dataList[index]; + getTangheemDataForTangheem(removedData.surahNo, removedData.ayatNumberInSurahs, removedData.tangheemTypeId, removedData.ayaTangheemTypeId); + } + }, + borderRadius: BorderRadius.circular(4), + child: Container( + padding: EdgeInsets.fromLTRB(12, 12, 12, 12), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + border: Border.all(color: ColorConsts.greyE0Color, width: 1), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + mainAxisSize: MainAxisSize.min, + children: [ + (_dataList[index].surahNameAr + ":").toText(12, color: ColorConsts.primaryBlue), + Text( + " ${_dataList[index].ayatNumberInSurahs}", + style: TextStyle(fontSize: 14, fontFamily: "BArabics", color: ColorConsts.secondaryOrange), + ), + 4.width, + "(${_dataList[index].tangheemTypeName})".toText(12, color: ColorConsts.secondaryOrange), + ], + ), + TextHighLightLengthWidget( + text: _dataList[index].reverseAyatNumber(), + startIndex: _dataList[index].startIndex, + endIndex: _dataList[index].endIndex, + textAlign: TextAlign.start, + highlightAya: _dataList[index].highlightText, + highlightAyaNos: _dataList[index].highlightAyaNos ?? "", + ayahTextList: _dataList[index].ayahTextList, + ), + // TextHighLightWidget( + // text: _dataList[index].reverseAyatNumber(), + // valueColor: ColorConsts.secondaryOrange, + // highlights: [_dataList[index].highlightText], + // textAlign: TextAlign.start, + // style: TextStyle( + // fontFamily: "UthmanicHafs", + // fontSize: 16, + // color: ColorConsts.primaryBlue, + // fontWeight: FontWeight.bold, + // ), + // ), + ], + ), ), - TextHighLightLengthWidget( - text: _dataList[index].reverseAyatNumber(), - startIndex: _dataList[index].startIndex, - endIndex: _dataList[index].endIndex, - textAlign: TextAlign.start, - highlightAya: _dataList[index].highlightText, - highlightAyaNos: _dataList[index].highlightAyaNos ?? "", - ayahTextList: _dataList[index].ayahTextList, - ), - // TextHighLightWidget( - // text: _dataList[index].reverseAyatNumber(), - // valueColor: ColorConsts.secondaryOrange, - // highlights: [_dataList[index].highlightText], - // textAlign: TextAlign.start, - // style: TextStyle( - // fontFamily: "UthmanicHafs", - // fontSize: 16, - // color: ColorConsts.primaryBlue, - // fontWeight: FontWeight.bold, - // ), - // ), - ], - ), + ); + }, ), - ); - }, - ); + ], + ); } } diff --git a/lib/ui/screens/user_profile_screen.dart b/lib/ui/screens/user_profile_screen.dart new file mode 100644 index 0000000..1d2f228 --- /dev/null +++ b/lib/ui/screens/user_profile_screen.dart @@ -0,0 +1,138 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:tangheem/api/user_api_client.dart'; +import 'package:tangheem/app_state/app_state.dart'; +import 'package:tangheem/classes/colors.dart'; +import 'package:tangheem/classes/consts.dart'; +import 'package:tangheem/classes/utils.dart'; +import 'package:tangheem/extensions/int_extensions.dart'; +import 'package:tangheem/extensions/string_extensions.dart'; +import 'package:tangheem/extensions/widget_extensions.dart'; +import 'package:tangheem/ui/dialogs/change_password_dialog.dart'; +import 'package:tangheem/ui/dialogs/general_dialog.dart'; +import 'package:tangheem/ui/screens/change_password_screen.dart'; + +class UserProfileScreen extends StatefulWidget { + static const String routeName = "/profile"; + + UserProfileScreen({Key key}) : super(key: key); + + @override + _UserProfileScreenState createState() { + return _UserProfileScreenState(); + } +} + +class _UserProfileScreenState extends State { + @override + void initState() { + super.initState(); + } + + @override + void dispose() { + super.dispose(); + } + + void deleteUserAccount() async { + Utils.showLoading(context); + try { + await UserApiClient().deleteAccount(AppState().userId); + SharedPreferences prefs = await SharedPreferences.getInstance(); + await prefs.remove(GlobalConsts.userAuthData); + AppState().setAuthenticationModel(null); + Utils.showToast("تم حذف الحساب"); + Navigator.pop(context); + Utils.hideLoading(context); + } catch (ex) { + if (mounted) { + Utils.hideLoading(context); + Utils.handleException(ex, null); + } + } + } + + @override + Widget build(BuildContext context) { + return SizedBox( + width: double.infinity, + child: Stack( + alignment: Alignment.topCenter, + children: [ + Image.asset( + "assets/icons/new/home_dark.jpg", + fit: BoxFit.cover, + height: double.infinity, + opacity: const AlwaysStoppedAnimation(1), + ), + Container(color: ColorConsts.darkText.withOpacity(0.8)), + Column( + mainAxisSize: MainAxisSize.min, + children: [ + 100.height, + Image.asset('assets/icons/new/Tangeem-logo-W.png', width: 50), + 100.height, + Container( + width: 78, + height: 78, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: ColorConsts.dark2Text, + ), + child: SvgPicture.asset( + "assets/icons/new/user_acount.svg", + color: Colors.white, + ), + ), + 14.height, + (AppState().userName ?? "").toText(25), + 50.height, + button("تغيير كلمة المرور").onPress(() { + Navigator.pushNamed(context, ChangePasswordScreen.routeName); + }), + Container(width: 50, height: 1, color: ColorConsts.dark99Text).paddingOnly(top: 15, bottom: 15), + button("تسجيل الخروج").onPress(() async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + await prefs.remove(GlobalConsts.userAuthData); + AppState().setAuthenticationModel(null); + Utils.showToast("تسجيل خروج المستخدم"); + Navigator.pop(context); + }), + Container(width: 50, height: 1, color: ColorConsts.dark99Text).paddingOnly(top: 15, bottom: 15), + button("حذف الحساب").onPress(() { + showDialog( + context: context, + barrierColor: Colors.white.withOpacity(0.2), + builder: (BuildContext context) => GeneralDialog( + message: "هل تود حذف حسابك عبر تطبيق تنغيم؟", + backgroundColor: Color(0xff598A8D), + buttonTitle: "تأكيد الحذف", + buttonBorderColor: ColorConsts.brownLightColor, + onTap: () { + Navigator.pop(context); + deleteUserAccount(); + }, + ), + ); + }), + ], + ), + ], + ), + ); + } + + Widget button(String title) { + return Container( + height: 36, + width: 165, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(32), + border: Border.all(color: Colors.white, width: 1), + ), + child: title.toText(13), + ); + } +} diff --git a/lib/widgets/aya_record_widget.dart b/lib/widgets/aya_record_widget.dart index ae90e6d..e3854b7 100644 --- a/lib/widgets/aya_record_widget.dart +++ b/lib/widgets/aya_record_widget.dart @@ -8,6 +8,8 @@ import 'package:permission_handler/permission_handler.dart'; import 'package:record_mp3/record_mp3.dart'; import 'package:tangheem/classes/colors.dart'; import 'package:tangheem/classes/utils.dart'; +import 'package:tangheem/extensions/string_extensions.dart'; +import 'package:tangheem/extensions/widget_extensions.dart'; class AyaRecordWidget extends StatefulWidget { AyaRecordWidget({Key key}) : super(key: key); @@ -100,179 +102,172 @@ class _AyaRecordWidgetState extends State { @override Widget build(BuildContext context) { - return Stack( - alignment: Alignment.bottomCenter, + return Column( children: [ Container( - margin: EdgeInsets.only(top: 4, bottom: 20), - padding: EdgeInsets.only(bottom: 20), - width: double.infinity, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - ), - child: Column( - children: [ - Container( - height: 60, - width: double.infinity, - margin: EdgeInsets.only(bottom: 8), - alignment: Alignment.center, - decoration: BoxDecoration( - color: ColorConsts.primaryBlue, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8), - topRight: Radius.circular(8), - ), + height: 38, + width: double.infinity, + alignment: Alignment.center, + decoration: BoxDecoration( + color: ColorConsts.brownB1CColor, + borderRadius: BorderRadius.only( + topRight: Radius.circular(20.0), + topLeft: Radius.circular(20.0), + ), + ), + child: "سجل الآية بصوتك".toText(16)), + Stack( + alignment: Alignment.bottomCenter, + children: [ + Container( + margin: EdgeInsets.only(bottom: 35), + padding: EdgeInsets.only(bottom: 14, top: 14, left: 16, right: 16), + width: double.infinity, + decoration: BoxDecoration( + color: Colors.transparent, + border: Border.all(width: 1, color: ColorConsts.greyE0Color), + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), + bottomRight: Radius.circular(20), ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - SvgPicture.asset( - "assets/icons/mic_icon.svg", - width: 25, - height: 25, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + // if (!(recordFilePath != null && File(recordFilePath).existsSync())) SizedBox(height: 16), + if (recordFilePath != null && File(recordFilePath).existsSync()) + Container( + height: 50, + margin: EdgeInsets.only(bottom: 14), + padding: EdgeInsets.only(left: 12, right: 12), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(30), + ), + child: Row( + children: [ + Expanded( + child: StreamBuilder( + stream: _audioPlayer.positionStream, + builder: (context, snapshot) { + final state = snapshot.data; + return SliderTheme( + data: SliderTheme.of(context).copyWith( + inactiveTrackColor: ColorConsts.sliderBackground, + activeTrackColor: ColorConsts.secondaryOrange, + trackHeight: 3.0, + thumbColor: ColorConsts.primaryBlack, + thumbShape: RoundSliderThumbShape(enabledThumbRadius: 6.0), + overlayColor: ColorConsts.primaryBlack.withAlpha(32), + overlayShape: RoundSliderOverlayShape(overlayRadius: 6.0), + ), + child: Directionality( + textDirection: TextDirection.ltr, + child: Slider( + value: (state?.inSeconds ?? 0) + 0.0, + min: 0, + max: (_audioPlayer?.duration?.inSeconds ?? 0) + 0.0, + onChanged: (value) {}, + ), + ), + ); + }, + ), + ), + SizedBox(width: 8), + StreamBuilder( + stream: _audioPlayer.positionStream, + builder: (context, snapshot) { + final state = snapshot.data; + return Text( + _durationTime(state) ?? "", + style: TextStyle(color: ColorConsts.textGrey1, height: 1.1, fontFamily: "Roboto", fontSize: 16), + ); + }, + ), + SizedBox(width: 8), + StreamBuilder( + stream: _audioPlayer.playerStateStream, + builder: (context, snapshot) { + final state = snapshot.data?.playing ?? false; + if (state) { + if (_audioPlayer?.duration?.inSeconds == _audioPlayer?.position?.inSeconds) { + _audioPlayer.pause(); + _audioPlayer.seek(Duration.zero); + } + } + return IconButton( + highlightColor: Colors.transparent, + splashColor: Colors.transparent, + constraints: BoxConstraints(), + padding: EdgeInsets.only(right: 0), + icon: SvgPicture.asset(state ? "assets/icons/pause.svg" : "assets/icons/play_aya.svg", height: 16, width: 16), + onPressed: () { + state + ? _audioPlayer.pause() + : _isAudioHaveError + ? Utils.showToast("خطأ في تحميل ملف الصوت") + : play(); + }); + }, + ), + ], + ), ), - SizedBox(width: 12), - Text( - "سجل الآية بصوتك", - style: TextStyle(fontSize: 18, color: Colors.white), + InkWell( + borderRadius: BorderRadius.circular(20), + onTap: () async { + if (await _requestStoragePermission()) { + if (recordFilePath != null && File(recordFilePath).existsSync()) { + saveToPhoneStorage(recordFilePath); + } else { + Utils.showToast("يجب عليك تسجيل صوتك أولا"); + } + } else { + Utils.showToast("يجب أن تمنح الإذن لتنزيل التسجيل"); + } + }, + child: Container( + height: 31, + width: 125, + padding: EdgeInsets.only(left: 24, right: 24), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: ColorConsts.greenLightColor, + ), + child: "تحميل التسجيل".toText(14), ), - ], - ), + ), + ], ), - InkWell( - onTap: () { + ), + Positioned( + right: 24, + child: Container( + height: 80, + width: 80, + padding: EdgeInsets.all(16), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: _isRecording ? Color(0xffe5ced3) : Color(0xffD3E5CE), + border: Border.all( + width: 1, + color: _isRecording ? Color(0xffc6b0ae) : Color(0xffAEC6B5), + ), + ), + child: SvgPicture.asset("assets/icons/new/mic.svg", color: Colors.white), + ).onPress( + () { if (_isRecording) { stopRecord(); } else { startRecord(); } }, - child: SvgPicture.asset( - _isRecording ? "assets/icons/recording_on.svg" : "assets/icons/recording_off.svg", - width: 60, - height: 60, - ), - ), - if (!(recordFilePath != null && File(recordFilePath).existsSync())) SizedBox(height: 16), - if (recordFilePath != null && File(recordFilePath).existsSync()) - Container( - height: 50, - margin: EdgeInsets.all(16), - padding: EdgeInsets.only(left: 12, right: 12), - decoration: BoxDecoration( - color: ColorConsts.secondaryWhite, - borderRadius: BorderRadius.circular(30), - ), - child: Row( - children: [ - Expanded( - child: StreamBuilder( - stream: _audioPlayer.positionStream, - builder: (context, snapshot) { - final state = snapshot.data; - return SliderTheme( - data: SliderTheme.of(context).copyWith( - inactiveTrackColor: ColorConsts.sliderBackground, - activeTrackColor: ColorConsts.secondaryOrange, - trackHeight: 3.0, - thumbColor: ColorConsts.primaryBlack, - thumbShape: RoundSliderThumbShape(enabledThumbRadius: 6.0), - overlayColor: ColorConsts.primaryBlack.withAlpha(32), - overlayShape: RoundSliderOverlayShape(overlayRadius: 6.0), - ), - child: Directionality( - textDirection: TextDirection.ltr, - child: Slider( - value: (state?.inSeconds ?? 0) + 0.0, - min: 0, - max: (_audioPlayer?.duration?.inSeconds ?? 0) + 0.0, - onChanged: (value) {}, - ), - ), - ); - }, - ), - ), - SizedBox(width: 8), - StreamBuilder( - stream: _audioPlayer.positionStream, - builder: (context, snapshot) { - final state = snapshot.data; - return Text( - _durationTime(state) ?? "", - style: TextStyle(color: ColorConsts.textGrey1, height: 1.1, fontFamily: "Roboto", fontSize: 16), - ); - }, - ), - SizedBox(width: 8), - StreamBuilder( - stream: _audioPlayer.playerStateStream, - builder: (context, snapshot) { - final state = snapshot.data?.playing ?? false; - if (state) { - if (_audioPlayer?.duration?.inSeconds == _audioPlayer?.position?.inSeconds) { - _audioPlayer.pause(); - _audioPlayer.seek(Duration.zero); - } - } - return IconButton( - highlightColor: Colors.transparent, - splashColor: Colors.transparent, - constraints: BoxConstraints(), - padding: EdgeInsets.only(right: 0), - icon: SvgPicture.asset(state ? "assets/icons/pause.svg" : "assets/icons/play_aya.svg", height: 16, width: 16), - onPressed: () { - state - ? _audioPlayer.pause() - : _isAudioHaveError - ? Utils.showToast("خطأ في تحميل ملف الصوت") - : play(); - }); - }, - ), - ], - ), - ) - ], - ), - ), - Positioned( - bottom: 0, - child: InkWell( - borderRadius: BorderRadius.circular(30), - onTap: () async { - if (await _requestStoragePermission()) { - if (recordFilePath != null && File(recordFilePath).existsSync()) { - saveToPhoneStorage(recordFilePath); - } else { - Utils.showToast("يجب عليك تسجيل صوتك أولا"); - } - } else { - Utils.showToast("يجب أن تمنح الإذن لتنزيل التسجيل"); - } - }, - child: Container( - height: 40, - padding: EdgeInsets.only(left: 24, right: 24), - alignment: Alignment.centerRight, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(30), - color: ColorConsts.gradientPink, - gradient: LinearGradient( - stops: [0.0, 0.5], - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ColorConsts.gradientPink, ColorConsts.gradientOrange], - ), - ), - child: Text( - "تنزيل التسجيل", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: Colors.white, height: 1.5), ), ), - ), + ], ), ], ); diff --git a/lib/widgets/login_textfield_widget.dart b/lib/widgets/login_textfield_widget.dart index bd86b25..56caa74 100644 --- a/lib/widgets/login_textfield_widget.dart +++ b/lib/widgets/login_textfield_widget.dart @@ -7,53 +7,102 @@ class LoginTextFieldWidget extends StatelessWidget { final TextEditingController controller; final bool isPassword; final IconData iconData; + final bool isForChangePassword; - LoginTextFieldWidget({@required this.hint, @required this.controller, this.isPassword = false, @required this.iconData, Key key}) : super(key: key); + LoginTextFieldWidget({@required this.hint, @required this.controller, this.isForChangePassword = false, this.isPassword = false, @required this.iconData, Key key}) : super(key: key); @override Widget build(BuildContext context) { - return TextField( - textAlignVertical: TextAlignVertical.center, - controller: controller, - obscureText: isPassword, - textInputAction: TextInputAction.next, - style: TextStyle(color: Colors.white, fontSize: 14, fontFamily: "Montserrat"), - cursorColor: Colors.white, - maxLines: 1, - scrollPhysics: BouncingScrollPhysics(), - decoration: InputDecoration( - contentPadding: EdgeInsets.only(top: 19, bottom: 19, right: 32, left: 4), - alignLabelWithHint: true, - fillColor: Color(0xff598A8D), - filled: true, - hintStyle: TextStyle(color: Colors.white, fontSize: 14, fontFamily: "Montserrat"), - hintText: hint, - suffixIcon: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Container( - width: 1, - height: 14, - color: Colors.white.withOpacity(.6), + return isForChangePassword + ? SizedBox( + height: 45, + child: TextField( + textAlignVertical: TextAlignVertical.center, + controller: controller, + obscureText: isPassword, + textInputAction: TextInputAction.next, + style: TextStyle(color: Colors.white, fontSize: 11, fontFamily: "Montserrat"), + cursorColor: Colors.white, + cursorWidth: 1, + maxLines: 1, + scrollPhysics: BouncingScrollPhysics(), + decoration: InputDecoration( + contentPadding: EdgeInsets.only(top: 15, bottom: 15, right: 17, left: 4), + alignLabelWithHint: true, + fillColor: Color(0xff598A8D), + filled: true, + hintStyle: TextStyle(color: Colors.white, fontSize: 11, fontFamily: "Montserrat"), + hintText: hint, + suffixIcon: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + width: 1, + height: 14, + color: Colors.white.withOpacity(.6), + ), + 12.width, + Icon( + iconData, + color: Colors.white.withOpacity(0.6), + size: 20, + ), + ], + ).paddingOnly(left: 17), + suffixIconConstraints: BoxConstraints(), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(25), + borderSide: BorderSide(color: Colors.transparent, width: 1), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(25), + borderSide: BorderSide(color: Colors.transparent, width: 1), + ), + ), ), - 14.width, - Icon( - iconData, - color: Colors.white.withOpacity(0.6), - size: 20, + ) + : TextField( + textAlignVertical: TextAlignVertical.center, + controller: controller, + obscureText: isPassword, + textInputAction: TextInputAction.next, + style: TextStyle(color: Colors.white, fontSize: 14, fontFamily: "Montserrat"), + cursorColor: Colors.white, + maxLines: 1, + scrollPhysics: BouncingScrollPhysics(), + decoration: InputDecoration( + contentPadding: EdgeInsets.only(top: 19, bottom: 19, right: 32, left: 4), + alignLabelWithHint: true, + fillColor: Color(0xff598A8D), + filled: true, + hintStyle: TextStyle(color: Colors.white, fontSize: 14, fontFamily: "Montserrat"), + hintText: hint, + suffixIcon: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + width: 1, + height: 14, + color: Colors.white.withOpacity(.6), + ), + 14.width, + Icon( + iconData, + color: Colors.white.withOpacity(0.6), + size: 20, + ), + ], + ).paddingOnly(left: 24), + suffixIconConstraints: BoxConstraints(), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: BorderSide(color: Colors.transparent, width: 1), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: BorderSide(color: Colors.transparent, width: 1), + ), ), - ], - ).paddingOnly(left: 24), - suffixIconConstraints: BoxConstraints(), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: BorderSide(color: Colors.transparent, width: 1), - ), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: BorderSide(color: Colors.transparent, width: 1), - ), - ), - ); + ); } -} \ No newline at end of file +} diff --git a/lib/widgets/new/CommonHeader.dart b/lib/widgets/new/CommonHeader.dart index 8f50eed..660f0c5 100644 --- a/lib/widgets/new/CommonHeader.dart +++ b/lib/widgets/new/CommonHeader.dart @@ -6,13 +6,14 @@ class CommonHeader extends StatelessWidget { final String title; final Color gradiantColor; final String assetImage; + final double ratio; - CommonHeader(this.title, this.assetImage, this.gradiantColor, {Key key}) : super(key: key); + CommonHeader(this.title, this.assetImage, this.gradiantColor, {Key key,this.ratio}) : super(key: key); @override Widget build(BuildContext context) { return AspectRatio( - aspectRatio: 469 / 313, + aspectRatio: ratio ?? 469 / 313, child: Stack( alignment: Alignment.center, children: [ diff --git a/lib/widgets/video_player_widget.dart b/lib/widgets/video_player_widget.dart index e9636de..a0ce5fe 100644 --- a/lib/widgets/video_player_widget.dart +++ b/lib/widgets/video_player_widget.dart @@ -1,7 +1,12 @@ +import 'dart:ui'; + import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:tangheem/classes/colors.dart'; import 'package:tangheem/classes/consts.dart'; +import 'package:tangheem/extensions/int_extensions.dart'; +import 'package:tangheem/extensions/string_extensions.dart'; +import 'package:tangheem/extensions/widget_extensions.dart'; import 'package:youtube_player_flutter/youtube_player_flutter.dart'; class VideoPlayerWidget extends StatefulWidget { @@ -38,75 +43,64 @@ class _VideoPlayerWidgetState extends State { @override Widget build(BuildContext context) { - return Dialog( - insetPadding: EdgeInsets.symmetric(horizontal: 24.0, vertical: 24.0), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12), - ), - elevation: 0, - backgroundColor: Colors.transparent, - child: Container( - width: double.infinity, - decoration: BoxDecoration( - color: ColorConsts.primaryBlue, - borderRadius: BorderRadius.circular(16), + return BackdropFilter( + filter: ImageFilter.blur(sigmaX: 4, sigmaY: 4), + child: Dialog( + insetPadding: EdgeInsets.symmetric(horizontal: 24.0, vertical: 24.0), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), ), - padding: EdgeInsets.symmetric(vertical: MediaQuery.of(context).orientation == Orientation.portrait ? 32 : 16, horizontal: 16), - child: Column( - mainAxisSize: MainAxisSize.min, + elevation: 0, + backgroundColor: Colors.transparent, + child: Stack( + alignment: Alignment.topCenter, children: [ - MediaQuery.of(context).orientation == Orientation.portrait ? videoPlayer() : Expanded(child: videoPlayer()), - SizedBox(height: 8), - Row( - children: [ - Expanded( - child: Text( - "لا تظهر مرة أخرى", - textAlign: TextAlign.right, - style: TextStyle(color: Colors.white), - ), - ), - SizedBox(width: 16), - SizedBox( - width: 12, - height: 12, - child: Checkbox( - value: doNotShowAgain, - side: BorderSide(color: Colors.white), - activeColor: ColorConsts.secondaryPink, - onChanged: (value) { - setState(() { - doNotShowAgain = value; - }); - }, - ), - ), - ], - ), - SizedBox(height: 16), - SizedBox( - width: double.infinity, - height: 40, - child: TextButton( - onPressed: () async { - if (doNotShowAgain) { - SharedPreferences prefs = await SharedPreferences.getInstance(); - await prefs.setBool(GlobalConsts.doNotShowWelcomeVideo, doNotShowAgain); - } - Navigator.pop(context); - }, - style: TextButton.styleFrom( - primary: Colors.white, - padding: EdgeInsets.all(2), - backgroundColor: ColorConsts.secondaryPink, - textStyle: TextStyle(fontSize: 14, fontFamily: "DroidKufi"), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(6.0), - ), - ), - child: Text("أغلق"), + Container( + width: MediaQuery.of(context).size.width * 273 / 375, + margin: EdgeInsets.only(top: 11), + decoration: BoxDecoration( + color: ColorConsts.darkText.withOpacity(.60), + borderRadius: BorderRadius.circular(16), + ), + padding: EdgeInsets.only(top: 24, bottom: 12), + // padding: EdgeInsets.symmetric(vertical: MediaQuery.of(context).orientation == Orientation.portrait ? 24 : 24, horizontal: 0), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + MediaQuery.of(context).orientation == Orientation.portrait ? videoPlayer() : Expanded(child: videoPlayer()), + 12.height, + SizedBox( + width: double.infinity, + height: 30, + child: TextButton( + onPressed: () async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + await prefs.setBool(GlobalConsts.doNotShowWelcomeVideo, doNotShowAgain); + Navigator.pop(context); + }, + style: TextButton.styleFrom( + // primary: Colors.white, + padding: EdgeInsets.all(0), + backgroundColor: Colors.transparent, + textStyle: TextStyle(fontSize: 14, fontFamily: "DroidKufi"), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(25.0), side: BorderSide(color: Colors.white, width: 2)), + ), + child: "لا تظهر مرة أخرى".toText(14), + ), + ).paddingOnly(left: 12, right: 12), + ], ), ), + Container( + height: 22, + width: 22, + decoration: BoxDecoration(shape: BoxShape.circle, color: ColorConsts.brownLightColor), + child: Icon( + Icons.clear, + size: 16, + color: Colors.white, + ), + ).onPress(() => Navigator.pop(context)), ], ), ),