|
|
|
|
@ -1,10 +1,18 @@
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
|
import 'package:tangheem/api/admin_configuration_api_client.dart';
|
|
|
|
|
import 'package:tangheem/api/tangheem_user_api_client.dart';
|
|
|
|
|
import 'package:tangheem/app_state/app_state.dart';
|
|
|
|
|
import 'package:tangheem/classes/colors.dart';
|
|
|
|
|
import 'package:tangheem/classes/utils.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';
|
|
|
|
|
import 'package:tangheem/widgets/aya_player_widget.dart';
|
|
|
|
|
import 'package:tangheem/widgets/text_highlight_widget.dart';
|
|
|
|
|
import 'package:tangheem/extensions/string_extensions.dart';
|
|
|
|
|
import 'login_screen.dart';
|
|
|
|
|
|
|
|
|
|
class TangheemDetailScreen extends StatefulWidget {
|
|
|
|
|
static const String routeName = "/tangheem_detail";
|
|
|
|
|
@ -24,9 +32,10 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
|
|
|
|
|
List<TangheemProperty> _tangheemInsideTableEmptyList = [];
|
|
|
|
|
List<String> _tangheemWords = [];
|
|
|
|
|
|
|
|
|
|
int _currentTangheemPage = -1;
|
|
|
|
|
int _discussionPage = -1;
|
|
|
|
|
AyatTangheemTypeMapped _ayatTangheemTypeMapped;
|
|
|
|
|
AyatTangheemTypeMappedData _ayatTangheemTypeMappedData;
|
|
|
|
|
DiscussionModel _discussionModel;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
@ -34,20 +43,34 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
|
|
|
|
|
_tangheemInsideTableValueList = [];
|
|
|
|
|
_tangheemInsideTableEmptyList = [];
|
|
|
|
|
filterData();
|
|
|
|
|
getTangheemDiscussion();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// void getTangheemData() async {
|
|
|
|
|
// Utils.showLoading(context);
|
|
|
|
|
// try {
|
|
|
|
|
// _ayatTangheemTypeMapped = await TangheemUserApiClient().getAyaTangheemTypeMapped(widget.surah.surahID, widget.tangheemTypeName);
|
|
|
|
|
// if (_ayatTangheemTypeMapped.data.length > 0) _currentTangheemPage = 0;
|
|
|
|
|
// } catch (ex, tr) {
|
|
|
|
|
// Utils.handleException(ex, null);
|
|
|
|
|
// } finally {
|
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
|
// }
|
|
|
|
|
// filterData();
|
|
|
|
|
// }
|
|
|
|
|
void getTangheemDiscussion() async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
try {
|
|
|
|
|
_discussionModel = await TangheemUserApiClient().getDiscussionByTangheemID(_discussionPage, widget.ayatTangheemTypeMappedData.ayaTangheemTypeId);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
setState(() {});
|
|
|
|
|
} catch (ex, tr) {
|
|
|
|
|
Utils.handleException(ex, null);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void sendComment(String discussionText) async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
try {
|
|
|
|
|
await AdminConfigurationApiClient().addDiscussion(discussionText, widget.ayatTangheemTypeMappedData.ayaTangheemTypeId);
|
|
|
|
|
Utils.showToast("تم إرسال التعليق ، سيكون مرئيًا بمجرد موافقة المسؤول عليه");
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
} catch (ex, tr) {
|
|
|
|
|
print(ex);
|
|
|
|
|
Utils.handleException(ex, null);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void filterData() {
|
|
|
|
|
_ayatTangheemTypeMappedData = widget.ayatTangheemTypeMappedData;
|
|
|
|
|
@ -83,135 +106,110 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 8),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
margin: EdgeInsets.only(top: 4, bottom: 4),
|
|
|
|
|
padding: EdgeInsets.only(top: 8, bottom: 8, right: 4, left: 4),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
physics: BouncingScrollPhysics(),
|
|
|
|
|
child: RepaintBoundary(
|
|
|
|
|
key: _globalKey,
|
|
|
|
|
child: Material(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: ListView(
|
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
padding: EdgeInsets.all(4),
|
|
|
|
|
children: [
|
|
|
|
|
TextHighLightWidget(
|
|
|
|
|
text: _ayatTangheemTypeMappedData.reverseAyatNumber() ?? "",
|
|
|
|
|
valueColor: ColorConsts.primaryBlue,
|
|
|
|
|
highlights: _tangheemWords,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontFamily: "UthmanicHafs",
|
|
|
|
|
fontSize: 18,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
child: ListView(
|
|
|
|
|
physics: BouncingScrollPhysics(),
|
|
|
|
|
padding: EdgeInsets.only(bottom: 16),
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.only(top: 4, bottom: 4),
|
|
|
|
|
padding: EdgeInsets.only(top: 8, bottom: 8, right: 4, left: 4),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
|
),
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
|
child: RepaintBoundary(
|
|
|
|
|
key: _globalKey,
|
|
|
|
|
child: Material(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: ListView(
|
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
padding: EdgeInsets.all(4),
|
|
|
|
|
children: [
|
|
|
|
|
TextHighLightWidget(
|
|
|
|
|
text: _ayatTangheemTypeMappedData.reverseAyatNumber() ?? "",
|
|
|
|
|
valueColor: ColorConsts.primaryBlue,
|
|
|
|
|
highlights: _tangheemWords,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontFamily: "UthmanicHafs",
|
|
|
|
|
fontSize: 18,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 16),
|
|
|
|
|
ListView.separated(
|
|
|
|
|
itemCount: _tangheemInsideTableValueList.length,
|
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
separatorBuilder: (context, index) {
|
|
|
|
|
return Divider(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
height: 1,
|
|
|
|
|
thickness: 0,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
return Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
height: 40,
|
|
|
|
|
padding: EdgeInsets.only(left: 4, right: 8),
|
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
|
child: Text(
|
|
|
|
|
_tangheemInsideTableValueList[index].propertyText,
|
|
|
|
|
style: TextStyle(fontWeight: FontWeight.bold, color: ColorConsts.secondaryOrange),
|
|
|
|
|
),
|
|
|
|
|
color: ColorConsts.secondaryWhite,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 16),
|
|
|
|
|
ListView.separated(
|
|
|
|
|
itemCount: _tangheemInsideTableValueList.length,
|
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
separatorBuilder: (context, index) {
|
|
|
|
|
return Divider(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
height: 1,
|
|
|
|
|
thickness: 0,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
return Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
height: 40,
|
|
|
|
|
padding: EdgeInsets.only(left: 4, right: 8),
|
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
|
child: Text(
|
|
|
|
|
_tangheemInsideTableValueList[index].propertyText,
|
|
|
|
|
style: TextStyle(fontWeight: FontWeight.bold, color: ColorConsts.secondaryOrange),
|
|
|
|
|
),
|
|
|
|
|
color: ColorConsts.secondaryWhite,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(width: 8),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
height: 40,
|
|
|
|
|
padding: EdgeInsets.only(left: 4, right: 8),
|
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
|
child: Text(
|
|
|
|
|
_tangheemInsideTableValueList[index].propertyValue,
|
|
|
|
|
style: TextStyle(color: ColorConsts.primaryBlack),
|
|
|
|
|
),
|
|
|
|
|
color: ColorConsts.secondaryWhite,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
if (_tangheemInsideTableTrueList.isNotEmpty)
|
|
|
|
|
Container(
|
|
|
|
|
color: ColorConsts.primaryBlue,
|
|
|
|
|
margin: EdgeInsets.only(top: 8, bottom: 8),
|
|
|
|
|
padding: EdgeInsets.all(8),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
_ayatTangheemTypeMappedData.tangheemTypeName ?? "",
|
|
|
|
|
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 8),
|
|
|
|
|
tangheemPropertyView(_tangheemInsideTableTrueList)
|
|
|
|
|
SizedBox(width: 8),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
height: 40,
|
|
|
|
|
padding: EdgeInsets.only(left: 4, right: 8),
|
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
|
child: Text(
|
|
|
|
|
_tangheemInsideTableValueList[index].propertyValue,
|
|
|
|
|
style: TextStyle(color: ColorConsts.primaryBlack),
|
|
|
|
|
),
|
|
|
|
|
color: ColorConsts.secondaryWhite,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
if (_tangheemInsideTableTrueList.isNotEmpty)
|
|
|
|
|
Container(
|
|
|
|
|
color: ColorConsts.primaryBlue,
|
|
|
|
|
margin: EdgeInsets.only(top: 8, bottom: 8),
|
|
|
|
|
padding: EdgeInsets.all(8),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
_ayatTangheemTypeMappedData.tangheemTypeName ?? "",
|
|
|
|
|
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 8),
|
|
|
|
|
tangheemPropertyView(_tangheemInsideTableTrueList)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
tangheemPropertyView(_tangheemInsideTableEmptyList)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
tangheemPropertyView(_tangheemInsideTableEmptyList)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
// SizedBox(height: 4),
|
|
|
|
|
// Padding(
|
|
|
|
|
// padding: EdgeInsets.only(left: 4, right: 4),
|
|
|
|
|
// child: Row(
|
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
// children: [
|
|
|
|
|
// nextOptionButton(
|
|
|
|
|
// "assets/icons/prev_single.svg",
|
|
|
|
|
// "الآيات السابقة",
|
|
|
|
|
// (_currentTangheemPage == 0 || (_ayatTangheemTypeMapped.data.length < 1))
|
|
|
|
|
// ? null
|
|
|
|
|
// : () {
|
|
|
|
|
// _currentTangheemPage = _currentTangheemPage - 1;
|
|
|
|
|
// filterData();
|
|
|
|
|
// }),سكندر
|
|
|
|
|
// previousOptionButton(
|
|
|
|
|
// "assets/icons/next_single.svg",
|
|
|
|
|
// "الآيات التالية",
|
|
|
|
|
// (_currentTangheemPage == (_ayatTangheemTypeMapped.data.length - 1) || (_ayatTangheemTypeMapped.data.length < 1))
|
|
|
|
|
// ? null
|
|
|
|
|
// : () {
|
|
|
|
|
// _currentTangheemPage = _currentTangheemPage + 1;
|
|
|
|
|
// filterData();
|
|
|
|
|
// }),
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 8),
|
|
|
|
|
discussionView(_discussionModel?.data ?? []),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
AyaPlayerWidget(surahName: _ayatTangheemTypeMappedData.surahNameAr ?? "", globalKey: _globalKey, voiceNoteList: _ayatTangheemTypeMappedData.voiceNote ?? [])
|
|
|
|
|
AyaPlayerWidget(surahName: _ayatTangheemTypeMappedData.surahNameAr ?? "", globalKey: _globalKey, voiceNoteList: _ayatTangheemTypeMappedData?.voiceNote ?? [])
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
@ -297,4 +295,116 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget discussionView(List<DiscussionModelData> _discussionList) {
|
|
|
|
|
return Stack(
|
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.only(top: 4, bottom: 25),
|
|
|
|
|
padding: EdgeInsets.all(8),
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
|
),
|
|
|
|
|
child: 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(
|
|
|
|
|
children: [
|
|
|
|
|
SvgPicture.asset(
|
|
|
|
|
"assets/icons/chat_user.svg",
|
|
|
|
|
width: 60,
|
|
|
|
|
height: 60,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(width: 8),
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
"تعليق على الآية ${widget.ayatTangheemTypeMappedData.ayatNumberInSurah}",
|
|
|
|
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16, color: ColorConsts.primaryBlue, height: 1.5),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 4),
|
|
|
|
|
Text(
|
|
|
|
|
_discussionList[index].date.toFormattedDate(),
|
|
|
|
|
style: TextStyle(fontSize: 12, color: ColorConsts.textGrey, height: 1),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 4),
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
// Text(
|
|
|
|
|
// "عنوان التعليق",
|
|
|
|
|
// 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),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Positioned(
|
|
|
|
|
bottom: 0,
|
|
|
|
|
child: InkWell(
|
|
|
|
|
borderRadius: BorderRadius.circular(30),
|
|
|
|
|
onTap: () async {
|
|
|
|
|
if (!AppState().isUserLogin) {
|
|
|
|
|
await Navigator.pushNamed(context, LoginScreen.routeName);
|
|
|
|
|
if (!AppState().isUserLogin) {
|
|
|
|
|
Utils.showToast("يجب عليك تسجيل الدخول للتعليق");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
barrierColor: ColorConsts.secondaryWhite.withOpacity(0.8),
|
|
|
|
|
builder: (BuildContext context) => DiscussionInputDialog(onCommentPress: (comment) {
|
|
|
|
|
sendComment(comment);
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
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),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|