|
|
|
|
@ -1,7 +1,14 @@
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
import 'dart:typed_data';
|
|
|
|
|
import 'dart:ui' as ui;
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter/rendering.dart';
|
|
|
|
|
import 'package:flutter_html/flutter_html.dart';
|
|
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
|
import 'package:share/share.dart';
|
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
import 'package:tangheem/api/admin_configuration_api_client.dart';
|
|
|
|
|
import 'package:tangheem/api/tangheem_user_api_client.dart';
|
|
|
|
|
@ -63,13 +70,13 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
|
|
|
|
|
getTangheemDiscussionAndRelatedData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double fontSize = 18;
|
|
|
|
|
int fontSize = 18;
|
|
|
|
|
|
|
|
|
|
SharedPreferences prefs;
|
|
|
|
|
|
|
|
|
|
void getPrefs() async {
|
|
|
|
|
prefs = await SharedPreferences.getInstance();
|
|
|
|
|
fontSize = (prefs.getInt(GlobalConsts.fontZoomSize) ?? 18) + 0.0;
|
|
|
|
|
fontSize = (prefs.getInt(GlobalConsts.fontZoomSizeTangheem) ?? 18);
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -98,8 +105,7 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
setState(() {});
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
print(ex);
|
|
|
|
|
Utils.handleException(ex, null);
|
|
|
|
|
if (mounted) Utils.handleException(ex, null);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -132,14 +138,14 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
Utils.handleException(ex, null);
|
|
|
|
|
if (mounted) Utils.handleException(ex, null);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void filterVoiceListData() {
|
|
|
|
|
ayatTangheemTypeMappedDataList.forEach((element) {
|
|
|
|
|
voiceNoteList.addAll(element.voiceNote);
|
|
|
|
|
voiceNoteList.addAll(element?.voiceNote ?? []);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -163,14 +169,83 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
|
|
|
|
|
physics: BouncingScrollPhysics(),
|
|
|
|
|
padding: EdgeInsets.only(bottom: 16, top: 16),
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
_ayatTangheemTypeMappedFirstData.tangheemTypeName ?? "",
|
|
|
|
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20, color: ColorConsts.primaryBlue, height: 1.5),
|
|
|
|
|
Text.rich(
|
|
|
|
|
TextSpan(
|
|
|
|
|
children: [
|
|
|
|
|
TextSpan(
|
|
|
|
|
text: _ayatTangheemTypeMappedFirstData.tangheemTypeName ?? "",
|
|
|
|
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20, color: ColorConsts.primaryBlue, height: 1.5),
|
|
|
|
|
),
|
|
|
|
|
WidgetSpan(
|
|
|
|
|
child: 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(() {});
|
|
|
|
|
}),
|
|
|
|
|
SizedBox(width: 4),
|
|
|
|
|
zoomButtons("assets/icons/increase_size.svg", () {
|
|
|
|
|
if (fontSize >= 36) {
|
|
|
|
|
Utils.showToast("وصل حجم الخط إلى الحد الأقصى للحجم");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
fontSize += 2;
|
|
|
|
|
prefs.setInt(GlobalConsts.fontZoomSize, fontSize);
|
|
|
|
|
setState(() {});
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
WidgetSpan(
|
|
|
|
|
child: PopupMenuButton(
|
|
|
|
|
child: IconButton(
|
|
|
|
|
highlightColor: Colors.transparent,
|
|
|
|
|
splashColor: Colors.transparent,
|
|
|
|
|
constraints: BoxConstraints(),
|
|
|
|
|
padding: EdgeInsets.only(right: 2),
|
|
|
|
|
icon: SvgPicture.asset("assets/icons/share_aya.svg", height: 16, width: 16),
|
|
|
|
|
onPressed: 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();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
// TextSpan(text: ' world!'),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 8),
|
|
|
|
|
Text(
|
|
|
|
|
_ayatTangheemTypeMappedFirstData.tangheemTypeDescription ?? "",
|
|
|
|
|
style: TextStyle(fontSize: 14, color: ColorConsts.textGrey, height: 1),
|
|
|
|
|
style: TextStyle(fontSize: 14, color: ColorConsts.textGrey, height: 1.5),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 8),
|
|
|
|
|
Container(
|
|
|
|
|
@ -191,14 +266,16 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
itemCount: ayatTangheemTypeMappedDataList.length > 5 ? 5 : ayatTangheemTypeMappedDataList.length,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
var _ayatTangheemTypeMappedData = ayatTangheemTypeMappedDataList[index];
|
|
|
|
|
final _ayatTangheemTypeMappedData = ayatTangheemTypeMappedDataList[index];
|
|
|
|
|
|
|
|
|
|
List<TangheemProperty> _tangheemInsideTableList = [];
|
|
|
|
|
List<TangheemProperty> _tangheemAboveTableList = [];
|
|
|
|
|
List<TangheemProperty> _tangheemBelowTableList = [];
|
|
|
|
|
List<String> _tangheemWords = [];
|
|
|
|
|
List<TangheemProperty> _tempPropertyList = <TangheemProperty>[] + _ayatTangheemTypeMappedData?.property ?? <TangheemProperty>[];
|
|
|
|
|
|
|
|
|
|
List<TangheemProperty> _tempPropertyList = List<TangheemProperty>() + _ayatTangheemTypeMappedData?.property ?? [];
|
|
|
|
|
int firstIndex = _tempPropertyList.indexWhere((element) => element.isInsideTable);
|
|
|
|
|
|
|
|
|
|
if (firstIndex >= 0) {
|
|
|
|
|
var _tempPropertyListTop = _tempPropertyList.take(firstIndex);
|
|
|
|
|
_tempPropertyListTop = _tempPropertyListTop.where((element) => (element.propertyValue ?? "").isNotEmpty)?.toList() ?? [];
|
|
|
|
|
@ -254,8 +331,9 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
|
|
|
|
|
startIndex: _ayatTangheemTypeMappedData.startIndex,
|
|
|
|
|
endIndex: _ayatTangheemTypeMappedData.endIndex,
|
|
|
|
|
textAlign: TextAlign.start,
|
|
|
|
|
fontSize: fontSize.toDouble(),
|
|
|
|
|
highlightAya: _ayatTangheemTypeMappedData.highlightText,
|
|
|
|
|
highlightAyaNos: _ayatTangheemTypeMappedData.highlightAyaNos??"",
|
|
|
|
|
highlightAyaNos: _ayatTangheemTypeMappedData.highlightAyaNos ?? "",
|
|
|
|
|
ayahTextList: _ayatTangheemTypeMappedData.ayahTextList,
|
|
|
|
|
),
|
|
|
|
|
// TextHighLightWidget(
|
|
|
|
|
@ -395,6 +473,8 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
|
|
|
|
|
var removedData = list[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: _dataList[index].ayaTangheemTypeId, ayatTangheemTypeMappedDataList: list);
|
|
|
|
|
Navigator.pushNamed(context, TangheemDetailScreen.routeName, arguments: tangheem);
|
|
|
|
|
},
|
|
|
|
|
@ -416,8 +496,9 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
|
|
|
|
|
if (MediaQuery.of(context).orientation == Orientation.portrait)
|
|
|
|
|
AyaPlayerWidget(
|
|
|
|
|
surahName: _ayatTangheemTypeMappedFirstData?.surahNameAr ?? "",
|
|
|
|
|
ayaTangheemTypeId: _ayatTangheemTypeMappedFirstData?.ayaTangheemTypeId ?? "",
|
|
|
|
|
ayaTangheemTypeId: _ayatTangheemTypeMappedFirstData?.tangheemTypeId ?? "",
|
|
|
|
|
globalKey: _globalKey,
|
|
|
|
|
numberInSurah: _ayatTangheemTypeMappedFirstData?.ayatNumberInSurahs,
|
|
|
|
|
ayaNo: _ayatTangheemTypeMappedFirstData?.ayahNo,
|
|
|
|
|
surahNo: _ayatTangheemTypeMappedFirstData?.surahNo,
|
|
|
|
|
voiceNoteList: voiceNoteList),
|
|
|
|
|
@ -451,8 +532,9 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
|
|
|
|
|
if (showAyaPlayer)
|
|
|
|
|
AyaPlayerWidget(
|
|
|
|
|
surahName: _ayatTangheemTypeMappedFirstData?.surahNameAr ?? "",
|
|
|
|
|
ayaTangheemTypeId: _ayatTangheemTypeMappedFirstData?.ayaTangheemTypeId ?? "",
|
|
|
|
|
ayaTangheemTypeId: _ayatTangheemTypeMappedFirstData?.tangheemTypeId ?? "",
|
|
|
|
|
ayaNo: _ayatTangheemTypeMappedFirstData?.ayahNo,
|
|
|
|
|
numberInSurah: _ayatTangheemTypeMappedFirstData?.ayatNumberInSurahs,
|
|
|
|
|
surahNo: _ayatTangheemTypeMappedFirstData?.surahNo,
|
|
|
|
|
globalKey: _globalKey,
|
|
|
|
|
voiceNoteList: voiceNoteList),
|
|
|
|
|
@ -567,7 +649,8 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
|
|
|
|
|
return Container(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
padding: EdgeInsets.all(2),
|
|
|
|
|
child: Row(crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
child: Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
for (var property in tangheemPropertyList)
|
|
|
|
|
Expanded(
|
|
|
|
|
@ -826,4 +909,42 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _shareAyaAsLink() async {
|
|
|
|
|
String _url =
|
|
|
|
|
"${ApiConsts.baseUrl}/quran/tangheemtype?surahNo=${_ayatTangheemTypeMappedFirstData?.surahNo}&ayahNo=${_ayatTangheemTypeMappedFirstData?.ayahNo}&tanghemType=${_ayatTangheemTypeMappedFirstData?.tangheemTypeId}&numberinsurah=${_ayatTangheemTypeMappedFirstData?.ayatNumberInSurahs}";
|
|
|
|
|
await Share.share(_url);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _shareAyaAsImage() async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
try {
|
|
|
|
|
RenderRepaintBoundary boundary = _globalKey.currentContext.findRenderObject();
|
|
|
|
|
ui.Image image = await boundary.toImage(pixelRatio: 3.0);
|
|
|
|
|
ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
|
|
|
|
|
Uint8List pngBytes = byteData.buffer.asUint8List();
|
|
|
|
|
|
|
|
|
|
final tempDir = await getTemporaryDirectory();
|
|
|
|
|
final file = await File('${tempDir.path}/${DateTime.now().toString()}.png').create();
|
|
|
|
|
await file.writeAsBytes(pngBytes);
|
|
|
|
|
await TangheemUserApiClient().addStatistics(3);
|
|
|
|
|
await Share.shareFiles(['${file.path}']);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
Future.delayed(Duration(seconds: 1), () {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget zoomButtons(String icon, VoidCallback onPressed, {double size, bool isAsset = true}) {
|
|
|
|
|
return IconButton(
|
|
|
|
|
highlightColor: Colors.transparent,
|
|
|
|
|
splashColor: Colors.transparent,
|
|
|
|
|
constraints: BoxConstraints(),
|
|
|
|
|
padding: EdgeInsets.only(right: 2),
|
|
|
|
|
icon: SvgPicture.asset(icon, height: size ?? 20, width: size ?? 20),
|
|
|
|
|
onPressed: onPressed,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|