diff --git a/android/build.gradle b/android/build.gradle index b5e8417..7d9dd06 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -6,7 +6,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' + classpath 'com.android.tools.build:gradle:4.0.1' classpath 'com.google.gms:google-services:4.3.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 296b146..493072b 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/lib/api/tangheem_user_api_client.dart b/lib/api/tangheem_user_api_client.dart index 7a4a0a1..b3252f0 100644 --- a/lib/api/tangheem_user_api_client.dart +++ b/lib/api/tangheem_user_api_client.dart @@ -60,7 +60,7 @@ class TangheemUserApiClient { return await ApiClient().postJsonForObject((json) => TangheemType.fromJson(json), url, postParams); } - Future getAyaTangheemTypeMapped(int surahNo, String tangheemTypeName, String ayaText) async { + Future getAyaTangheemTypeMapped(int surahNo, String tangheemTypeName, String ayaText, int itemsPerPage, int currentPageNo) async { String url = "${ApiConsts.tangheemUsers}AyatTangheemTypeMapped_Get"; var postParams = {}; if (surahNo != null) { @@ -72,6 +72,9 @@ class TangheemUserApiClient { if (ayaText != null) { postParams["ayaText"] = ayaText; } + postParams["itemsPerPage"] = itemsPerPage; + postParams["currentPageNo"] = currentPageNo; + return await ApiClient().postJsonForObject((json) => AyatTangheemTypeMapped.fromJson(json), url, postParams); } diff --git a/lib/ui/common_appbar.dart b/lib/ui/common_appbar.dart index 5db6a9f..74867ef 100644 --- a/lib/ui/common_appbar.dart +++ b/lib/ui/common_appbar.dart @@ -274,7 +274,7 @@ class _CommonAppbarState extends State { child: Row( children: [ for (QuickLinksData _quickLink in quickLinks) - commonIconButton(_quickLink.exposeFilePath, () { + commonIconButton(ApiConsts.baseUrl + _quickLink.exposeFilePath, () { _launchURL(_quickLink.imageUrl); }, size: 35, isAsset: false), ], diff --git a/lib/ui/dialogs/general_dialog.dart b/lib/ui/dialogs/general_dialog.dart new file mode 100644 index 0000000..793a372 --- /dev/null +++ b/lib/ui/dialogs/general_dialog.dart @@ -0,0 +1,55 @@ +import 'package:flutter/material.dart'; +import 'package:tangheem/classes/colors.dart'; + +class GeneralDialog extends StatelessWidget { + final String message; + GeneralDialog({Key key, this.message}) : 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), + ), + padding: EdgeInsets.symmetric(vertical: 32, horizontal: 16), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + message ?? "للحصول على تجربة أفضل ، يرجى إمالة هاتفك واستخدام التطبيق في الوضع الأفقي", + textAlign: TextAlign.center, + style: TextStyle(color: Colors.white), + ), + SizedBox(height: 32), + SizedBox( + width: double.infinity, + height: 40, + child: TextButton( + onPressed: () => 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("نعم"), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/ui/screens/home_screen.dart b/lib/ui/screens/home_screen.dart index 4aa74bc..a4b456f 100644 --- a/lib/ui/screens/home_screen.dart +++ b/lib/ui/screens/home_screen.dart @@ -11,6 +11,7 @@ import 'package:tangheem/classes/utils.dart'; import 'package:tangheem/models/content_info_model.dart'; import 'package:tangheem/models/surah_model.dart'; import 'package:tangheem/models/tangheem_type_model.dart'; +import 'package:tangheem/ui/dialogs/general_dialog.dart'; import 'package:tangheem/ui/screens/tangheem_screen.dart'; import 'package:tangheem/widgets/common_dropdown_button.dart'; @@ -64,6 +65,19 @@ class _HomeScreenState extends State { Utils.hideLoading(context); Utils.handleException(ex, null); } + checkScreenMode(); + } + + void checkScreenMode() { + WidgetsBinding.instance.addPostFrameCallback((_) { + if (MediaQuery.of(context).orientation == Orientation.portrait) { + showDialog( + context: context, + barrierColor: ColorConsts.secondaryWhite.withOpacity(0.8), + builder: (BuildContext context) => GeneralDialog(), + ); + } + }); } Future getTangheemTypes() async { diff --git a/lib/ui/screens/member_screen.dart b/lib/ui/screens/member_screen.dart index da76b2b..192a33b 100644 --- a/lib/ui/screens/member_screen.dart +++ b/lib/ui/screens/member_screen.dart @@ -59,6 +59,9 @@ class _MemberScreenState extends State { if (encodedImage.contains("data:image/png;base64,")) { encodedImage = encodedImage.replaceAll("data:image/png;base64,", ""); } + if (encodedImage.contains("data:image/jpeg;base64,")) { + encodedImage = encodedImage.replaceAll("data:image/jpeg;base64,", ""); + } var temp = base64Decode(encodedImage); return ListTile( @@ -94,7 +97,7 @@ class _MemberScreenState extends State { style: TextStyle(fontSize: 14, color: ColorConsts.primaryBlue), ), subtitle: Text( - " ${membersList[index].description}", + " ${membersList[index].description.trim()}", style: TextStyle(fontSize: 12, color: ColorConsts.primaryBlue), ), isThreeLine: true, diff --git a/lib/ui/screens/quran_screen.dart b/lib/ui/screens/quran_screen.dart index 9be2085..2d1efca 100644 --- a/lib/ui/screens/quran_screen.dart +++ b/lib/ui/screens/quran_screen.dart @@ -105,7 +105,7 @@ class _QuranScreenState extends State { void filterData() { numberOfAyah = _surahModel?.data[_selectedSurah]?.numberOfAyahs ?? 0; - filteredAyahList = List.generate(getNextMultiple(numberOfAyah), (index) => index + 1).toList().where((element) => element == 1 || (element % 5) == 0).toList() ?? []; + filteredAyahList = List.generate(numberOfAyah, (index) => index + 1).toList().where((element) => element == 1 || (element % 5) == 0 || element == numberOfAyah).toList() ?? []; _fromAyaList = filteredAyahList.getRange(0, filteredAyahList.length - 1)?.toList() ?? []; setState(() {}); @@ -234,6 +234,7 @@ class _QuranScreenState extends State { 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(() {}); diff --git a/lib/ui/screens/tangheem_detail_screen.dart b/lib/ui/screens/tangheem_detail_screen.dart index 13c57c8..bbc4a9d 100644 --- a/lib/ui/screens/tangheem_detail_screen.dart +++ b/lib/ui/screens/tangheem_detail_screen.dart @@ -314,7 +314,13 @@ class _TangheemDetailScreenState extends State { ), ), if (MediaQuery.of(context).orientation == Orientation.portrait) - AyaPlayerWidget(surahName: _ayatTangheemTypeMappedFirstData?.surahNameAr ?? "", globalKey: _globalKey, voiceNoteList: voiceNoteList), + AyaPlayerWidget( + surahName: _ayatTangheemTypeMappedFirstData?.surahNameAr ?? "", + ayaTangheemTypeId: _ayatTangheemTypeMappedFirstData?.ayaTangheemTypeId ?? "", + globalKey: _globalKey, + ayaNo: _ayatTangheemTypeMappedFirstData?.ayahNo, + surahNo: _ayatTangheemTypeMappedFirstData?.surahNo, + voiceNoteList: voiceNoteList), if (MediaQuery.of(context).orientation == Orientation.landscape) Column( mainAxisSize: MainAxisSize.min, @@ -322,7 +328,7 @@ class _TangheemDetailScreenState extends State { children: [ Container( height: 24, - margin: EdgeInsets.only(bottom: 8,top: 8), + margin: EdgeInsets.only(bottom: 8, top: 8), // color: Colors.transparent, child: TextButton( onPressed: () { @@ -342,7 +348,14 @@ class _TangheemDetailScreenState extends State { ), ), ), - if (showAyaPlayer) AyaPlayerWidget(surahName: _ayatTangheemTypeMappedFirstData?.surahNameAr ?? "", globalKey: _globalKey, voiceNoteList: voiceNoteList), + if (showAyaPlayer) + AyaPlayerWidget( + surahName: _ayatTangheemTypeMappedFirstData?.surahNameAr ?? "", + ayaTangheemTypeId: _ayatTangheemTypeMappedFirstData?.ayaTangheemTypeId ?? "", + ayaNo: _ayatTangheemTypeMappedFirstData?.ayahNo, + surahNo: _ayatTangheemTypeMappedFirstData?.surahNo, + globalKey: _globalKey, + voiceNoteList: voiceNoteList), ], ) ], diff --git a/lib/ui/screens/tangheem_screen.dart b/lib/ui/screens/tangheem_screen.dart index 8de3cb8..194b4d8 100644 --- a/lib/ui/screens/tangheem_screen.dart +++ b/lib/ui/screens/tangheem_screen.dart @@ -26,23 +26,39 @@ class TangheemScreen extends StatefulWidget { class _TangheemScreenState extends State { AyatTangheemTypeMapped _ayatTangheemTypeMapped; List _dataList; + final int itemsPerPage = 10; + int currentPageNo = 1; + ScrollController _controller; + bool canCallApi = false; @override void initState() { super.initState(); + _controller = new ScrollController()..addListener(_scrollListener); getTangheemData(); } + _scrollListener() { + if (_controller.position.extentAfter.toInt() <= 0 && canCallApi) { + if (_dataList.length < _ayatTangheemTypeMapped.totalItemsCount) { + currentPageNo++; + getTangheemData(); + } + canCallApi = false; + } + } + void getTangheemData() async { Utils.showLoading(context); try { - _ayatTangheemTypeMapped = await TangheemUserApiClient().getAyaTangheemTypeMapped(widget.surah?.surahID, widget.tangheemTypeName, widget.tangheemQuery); - _dataList = _ayatTangheemTypeMapped?.data ?? []; + _ayatTangheemTypeMapped = await TangheemUserApiClient().getAyaTangheemTypeMapped(widget.surah?.surahID, widget.tangheemTypeName, widget.tangheemQuery, itemsPerPage, currentPageNo); + _dataList = (_dataList ?? []) + (_ayatTangheemTypeMapped?.data ?? []); } catch (ex) { - _dataList = []; + _dataList = _dataList ?? []; Utils.handleException(ex, null); } finally { Utils.hideLoading(context); + canCallApi = true; } setState(() {}); } @@ -59,6 +75,7 @@ class _TangheemScreenState extends State { : _dataList.isEmpty ? NoDataUI() : ListView.separated( + controller: _controller, physics: BouncingScrollPhysics(), padding: EdgeInsets.all(16), itemCount: _dataList.length, @@ -69,8 +86,7 @@ class _TangheemScreenState extends State { return InkWell( onTap: () { List list = []; - list = - _ayatTangheemTypeMapped?.data?.where((element) => (element.ayahNo == _dataList[index].ayahNo) && (element.tangheemTypeId == _dataList[index].tangheemTypeId))?.toList() ?? []; + list = _dataList?.where((element) => (element.ayahNo == _dataList[index].ayahNo) && (element.tangheemTypeId == _dataList[index].tangheemTypeId))?.toList() ?? []; TangheemDetailParams tangheem = TangheemDetailParams(selectedTangheemTypeId: _dataList[index].ayaTangheemTypeId, ayatTangheemTypeMappedDataList: list); Navigator.pushNamed(context, TangheemDetailScreen.routeName, arguments: tangheem); }, diff --git a/lib/widgets/aya_player_widget.dart b/lib/widgets/aya_player_widget.dart index ad8667c..c9f248c 100644 --- a/lib/widgets/aya_player_widget.dart +++ b/lib/widgets/aya_player_widget.dart @@ -20,11 +20,14 @@ import 'package:tangheem/classes/utils.dart'; import 'package:tangheem/models/aya_tangheem_type_mapped.dart'; class AyaPlayerWidget extends StatefulWidget { + final int surahNo; + final int ayaNo; final String surahName; + final String ayaTangheemTypeId; final GlobalKey globalKey; final List voiceNoteList; - AyaPlayerWidget({Key key, this.surahName, this.voiceNoteList, @required this.globalKey}) : super(key: key); + AyaPlayerWidget({Key key, this.surahName, this.ayaTangheemTypeId, this.voiceNoteList, this.ayaNo, this.surahNo, @required this.globalKey}) : super(key: key); @override _AyaPlayerWidgetState createState() { @@ -201,9 +204,33 @@ class _AyaPlayerWidgetState extends State { Utils.showToast("يجب اعطاء الاذن لتنزيل الآية"); } }), - commonIconButton("assets/icons/share_aya.svg", () { - _shareAya(); - }), + PopupMenuButton( + child: commonIconButton("assets/icons/share_aya.svg", null), + padding: EdgeInsets.fromLTRB(4, 4, 0, 4), + itemBuilder: (_) => >[ + PopupMenuItem( + value: 1, + child: Text( + "مشاركة رابط", + style: TextStyle(color: ColorConsts.primaryBlack), + ), + ), + PopupMenuItem( + value: 2, + child: Text( + "مشاركة صورة", + style: TextStyle(color: ColorConsts.primaryBlack), + ), + ) + ], + onSelected: (int value) { + if (value == 1) { + _shareAyaAsLink(); + } else { + _shareAyaAsImage(); + } + }, + ) ], ), SizedBox(height: 8), @@ -331,7 +358,12 @@ class _AyaPlayerWidgetState extends State { } } - void _shareAya() async { + void _shareAyaAsLink() async { + String _url = "${ApiConsts.baseUrl}/quran/tangheemtype?surahNo=${widget.surahNo}&ayahNo=${widget.ayaNo}&tanghemType=${widget.ayaTangheemTypeId}"; + await Share.share(_url); + } + + void _shareAyaAsImage() async { Utils.showLoading(context); try { RenderRepaintBoundary boundary = widget.globalKey.currentContext.findRenderObject();