portrait mode dialog added & pagination added on tangheem screen.

development
Sikander Saleem 4 years ago
parent a8ba7467cb
commit e4919cf5d2

@ -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"
}

@ -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

@ -60,7 +60,7 @@ class TangheemUserApiClient {
return await ApiClient().postJsonForObject((json) => TangheemType.fromJson(json), url, postParams);
}
Future<AyatTangheemTypeMapped> getAyaTangheemTypeMapped(int surahNo, String tangheemTypeName, String ayaText) async {
Future<AyatTangheemTypeMapped> 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);
}

@ -274,7 +274,7 @@ class _CommonAppbarState extends State<CommonAppbar> {
child: Row(
children: [
for (QuickLinksData _quickLink in quickLinks)
commonIconButton(_quickLink.exposeFilePath, () {
commonIconButton(ApiConsts.baseUrl + _quickLink.exposeFilePath, () {
_launchURL(_quickLink.imageUrl);
}, size: 35, isAsset: false),
],

@ -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("نعم"),
),
),
],
),
),
);
}
}

@ -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<HomeScreen> {
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<void> getTangheemTypes() async {

@ -59,6 +59,9 @@ class _MemberScreenState extends State<MemberScreen> {
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<MemberScreen> {
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,

@ -105,7 +105,7 @@ class _QuranScreenState extends State<QuranScreen> {
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<QuranScreen> {
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(() {});

@ -314,7 +314,13 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
),
),
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<TangheemDetailScreen> {
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<TangheemDetailScreen> {
),
),
),
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),
],
)
],

@ -26,23 +26,39 @@ class TangheemScreen extends StatefulWidget {
class _TangheemScreenState extends State<TangheemScreen> {
AyatTangheemTypeMapped _ayatTangheemTypeMapped;
List<AyatTangheemTypeMappedData> _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 ?? <AyatTangheemTypeMappedData>[]) + (_ayatTangheemTypeMapped?.data ?? <AyatTangheemTypeMappedData>[]);
} catch (ex) {
_dataList = [];
_dataList = _dataList ?? <AyatTangheemTypeMappedData>[];
Utils.handleException(ex, null);
} finally {
Utils.hideLoading(context);
canCallApi = true;
}
setState(() {});
}
@ -59,6 +75,7 @@ class _TangheemScreenState extends State<TangheemScreen> {
: _dataList.isEmpty
? NoDataUI()
: ListView.separated(
controller: _controller,
physics: BouncingScrollPhysics(),
padding: EdgeInsets.all(16),
itemCount: _dataList.length,
@ -69,8 +86,7 @@ class _TangheemScreenState extends State<TangheemScreen> {
return InkWell(
onTap: () {
List<AyatTangheemTypeMappedData> 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);
},

@ -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<VoiceNote> 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<AyaPlayerWidget> {
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<int>>[
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<AyaPlayerWidget> {
}
}
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();

Loading…
Cancel
Save