Tangheem description & color comes from Api.

development
Sikander Saleem 5 years ago
parent ec3aeef12a
commit d9696d873e

@ -15,6 +15,18 @@ class Utils {
msg: message, toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 1, backgroundColor: Colors.black54, textColor: Colors.white, fontSize: 16.0);
}
static dynamic getNotNullValue(List<dynamic> list, int index) {
try {
return list[index];
} catch (ex) {
return null;
}
}
static int stringToHex(String colorCode) {
return int.parse(colorCode.replaceAll("#", "0xff"));
}
static void showLoading(BuildContext context) {
WidgetsBinding.instance.addPostFrameCallback((_) {
_isLoadingVisible = true;

@ -33,6 +33,7 @@ class AyatTangheemTypeMapped {
class AyatTangheemTypeMappedData {
String tangheemTypeId;
String tangheemTypeName;
String tangheemTypeDescription;
String ayaTangheemTypeId;
int surahNo;
String surahNameEn;
@ -49,6 +50,7 @@ class AyatTangheemTypeMappedData {
AyatTangheemTypeMappedData(
{this.tangheemTypeId,
this.tangheemTypeName,
this.tangheemTypeDescription,
this.ayaTangheemTypeId,
this.surahNo,
this.surahNameEn,
@ -65,6 +67,7 @@ class AyatTangheemTypeMappedData {
AyatTangheemTypeMappedData.fromJson(Map<String, dynamic> json) {
tangheemTypeId = json['tangheemTypeId'];
tangheemTypeName = json['tangheemTypeName'];
tangheemTypeDescription = json['tangheemTypeDescription'];
ayaTangheemTypeId = json['ayaTangheemTypeId'];
surahNo = json['surahNo'];
surahNameEn = json['surahNameEn'];
@ -93,6 +96,7 @@ class AyatTangheemTypeMappedData {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['tangheemTypeId'] = this.tangheemTypeId;
data['tangheemTypeName'] = this.tangheemTypeName;
data['tangheemTypeDescription'] = this.tangheemTypeDescription;
data['ayaTangheemTypeId'] = this.ayaTangheemTypeId;
data['surahNo'] = this.surahNo;
data['surahNameEn'] = this.surahNameEn;
@ -124,16 +128,18 @@ class TangheemProperty {
String tangheemTypePropertyId;
String propertyText;
bool isInsideTable;
String textColor;
int orderNo;
String ayaTangheemTypePropertyId;
String propertyValue;
TangheemProperty({this.tangheemTypePropertyId, this.propertyText, this.isInsideTable, this.orderNo, this.ayaTangheemTypePropertyId, this.propertyValue});
TangheemProperty({this.tangheemTypePropertyId, this.propertyText, this.isInsideTable, this.textColor,this.orderNo, this.ayaTangheemTypePropertyId, this.propertyValue});
TangheemProperty.fromJson(Map<String, dynamic> json) {
tangheemTypePropertyId = json['tangheemTypePropertyId'];
propertyText = json['propertyText'];
isInsideTable = json['isInsideTable'];
textColor = json['textColor'];
orderNo = json['orderNo'];
ayaTangheemTypePropertyId = json['ayaTangheemTypePropertyId'];
propertyValue = json['propertyValue'];
@ -144,6 +150,7 @@ class TangheemProperty {
data['tangheemTypePropertyId'] = this.tangheemTypePropertyId;
data['propertyText'] = this.propertyText;
data['isInsideTable'] = this.isInsideTable;
data['textColor'] = this.textColor;
data['orderNo'] = this.orderNo;
data['ayaTangheemTypePropertyId'] = this.ayaTangheemTypePropertyId;
data['propertyValue'] = this.propertyValue;

@ -7,6 +7,7 @@ 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/content_info_model.dart';
import 'package:tangheem/models/surah_model.dart';
import 'package:tangheem/models/tangheem_type_model.dart';
import 'package:tangheem/ui/screens/tangheem_screen.dart';
@ -35,6 +36,7 @@ class _HomeScreenState extends State<HomeScreen> {
SurahModel _surahModel;
TangheemType _tangheemType;
ContentInfoModel _contentInfoModel;
@override
void initState() {
@ -46,6 +48,7 @@ class _HomeScreenState extends State<HomeScreen> {
void getSurahAndTangheemTypes() async {
Utils.showLoading(context);
try {
_contentInfoModel = await TangheemUserApiClient().getContentInfo(4);
_surahModel = await TangheemUserApiClient().getSurahs();
AppState().setSurahModel(_surahModel);
_surahList = _surahModel.data.map((element) => element.nameAR).toList();
@ -93,7 +96,7 @@ class _HomeScreenState extends State<HomeScreen> {
),
SizedBox(height: 8),
Text(
"تساعدك موسوعة \"تنغيم\" على أداء الأساليب اللغوية القرآنية (كالاستفهام والأمر والنهي والإتمام) بما يخدم معنى الآية. وقد أشرف عليها متخصصون في اللغة العربية والدراسات القرآنية.",
Utils.getNotNullValue(_contentInfoModel?.data ?? [], 0)?.content ?? "",
style: TextStyle(fontSize: 14, color: ColorConsts.textGrey, height: 1),
),
SizedBox(height: 32),

@ -170,13 +170,6 @@ class _QuranScreenState extends State<QuranScreen> {
return "" + _surahName + "\n";
}
String getNotNullValue(List<String> list, int index) {
try {
return list[index];
} catch (ex) {
return "";
}
}
void _clearFilterAndRefreshData() {
_selectedSurah = -1;
@ -289,7 +282,7 @@ class _QuranScreenState extends State<QuranScreen> {
children: [
nextOptionButton(
"assets/icons/prev.svg",
_currentSurahIndex <= 0 ? "" : getNotNullValue(_surahList, _currentSurahIndex - 1),
_currentSurahIndex <= 0 ? "" : Utils.getNotNullValue(_surahList, _currentSurahIndex - 1) ?? "",
_currentSurahIndex <= 0
? null
: (value) {
@ -298,7 +291,7 @@ class _QuranScreenState extends State<QuranScreen> {
}),
previousOptionButton(
"assets/icons/next.svg",
_currentSurahIndex >= (_surahList.isNotEmpty ? (_surahList.length - 1) : 0) ? "" : getNotNullValue(_surahList, _currentSurahIndex + 1),
_currentSurahIndex >= (_surahList.isNotEmpty ? (_surahList.length - 1) : 0) ? "" : Utils.getNotNullValue(_surahList, _currentSurahIndex + 1) ?? "",
_currentSurahIndex >= (_surahList.isNotEmpty ? (_surahList.length - 1) : 0)
? null
: (value) {

@ -129,7 +129,7 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
),
SizedBox(height: 8),
Text(
"هنا نضع\" تعريف بالاستفهام وتداخل الأساليب\"",
_ayatTangheemTypeMappedFirstData.tangheemTypeDescription ?? "",
style: TextStyle(fontSize: 14, color: ColorConsts.textGrey, height: 1),
),
SizedBox(height: 8),
@ -150,115 +150,127 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
child: RepaintBoundary(
key: _globalKey,
child: Material(
color: Colors.white,
child: ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: ayatTangheemTypeMappedDataList.length > 5 ? 5 : ayatTangheemTypeMappedDataList.length,
itemBuilder: (context, index) {
var _ayatTangheemTypeMappedData = ayatTangheemTypeMappedDataList[index];
List<TangheemProperty> _tangheemInsideTableTrueList = [];
List<TangheemProperty> _tangheemInsideTableValueList = [];
List<TangheemProperty> _tangheemInsideTableEmptyList = [];
List<String> _tangheemWords = [];
color: Colors.white,
child: ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: ayatTangheemTypeMappedDataList.length > 5 ? 5 : ayatTangheemTypeMappedDataList.length,
itemBuilder: (context, index) {
var _ayatTangheemTypeMappedData = ayatTangheemTypeMappedDataList[index];
List<TangheemProperty> _tangheemInsideTableTrueList = [];
List<TangheemProperty> _tangheemInsideTableValueList = [];
List<TangheemProperty> _tangheemInsideTableEmptyList = [];
List<String> _tangheemWords = [];
_tangheemWords.add(_ayatTangheemTypeMappedData.highlightText ?? "");
_tangheemInsideTableTrueList =
_ayatTangheemTypeMappedData?.property?.where((element) => (element.isInsideTable) && (element.propertyValue ?? "").isNotEmpty)?.toList() ?? [];
_tangheemInsideTableValueList =
_ayatTangheemTypeMappedData?.property?.where((element) => (!element.isInsideTable) && (element.propertyValue ?? "").isNotEmpty)?.toList() ?? [];
_tangheemWords.add(_ayatTangheemTypeMappedData.highlightText ?? "");
_tangheemInsideTableTrueList =
_ayatTangheemTypeMappedData?.property?.where((element) => (element.isInsideTable) && (element.propertyValue ?? "").isNotEmpty)?.toList() ?? [];
_tangheemInsideTableValueList =
_ayatTangheemTypeMappedData?.property?.where((element) => (!element.isInsideTable) && (element.propertyValue ?? "").isNotEmpty)?.toList() ?? [];
return ListView(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
padding: EdgeInsets.all(4),
children: [
Row(
children: [
Text(
" جمله ${_ayatTangheemTypeMappedData.tangheemTypeName} ${getArabicIndexWord(index)} ",
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white, backgroundColor: ColorConsts.primaryBlue),
),
Expanded(
child: Container(height: 2, color: ColorConsts.primaryBlue),
),
],
),
SizedBox(height: 8),
TextHighLightWidget(
text: _ayatTangheemTypeMappedData.reverseAyatNumber() ?? "",
valueColor: ColorConsts.primaryBlue,
highlights: _tangheemWords,
highLightFontSize: fontSize,
style: TextStyle(
fontFamily: "UthmanicHafs",
fontSize: fontSize,
fontWeight: FontWeight.bold,
var _tempTangheemIndexWord = "";
if (ayatTangheemTypeMappedDataList.length == 1) {
_tempTangheemIndexWord = "";
} else {
_tempTangheemIndexWord = getArabicIndexWord(index);
}
return ListView(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
padding: EdgeInsets.all(4),
children: [
Row(
children: [
Text(
" جمله ${_ayatTangheemTypeMappedData.tangheemTypeName} $_tempTangheemIndexWord",
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white, backgroundColor: ColorConsts.primaryBlue),
),
Expanded(
child: Container(height: 2, color: ColorConsts.primaryBlue),
),
],
),
SizedBox(height: 8),
TextHighLightWidget(
text: _ayatTangheemTypeMappedData.reverseAyatNumber() ?? "",
valueColor: ColorConsts.primaryBlue,
highlights: _tangheemWords,
highLightFontSize: fontSize,
style: TextStyle(
fontFamily: "UthmanicHafs",
fontSize: fontSize,
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),
),
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: Color(
Utils.stringToHex(_tangheemInsideTableValueList[index].textColor),
),
),
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)
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)
],
);
}),
),
),
),
),
@ -346,7 +358,12 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
SizedBox(height: 4),
Text(
tangheemPropertyList[index].propertyValue ?? "",
style: TextStyle(fontSize: 12, color: ColorConsts.secondaryPink),
style: TextStyle(
fontSize: 12,
color: Color(
Utils.stringToHex(tangheemPropertyList[index].textColor),
),
),
),
],
),

@ -40,7 +40,7 @@ dependencies:
url_launcher: ^6.0.3
flutter_slidable: ^0.6.0
record_mp3: ^2.1.0
syncfusion_flutter_pdfviewer: ^19.1.58-beta
syncfusion_flutter_pdfviewer: ^19.1.59-beta
dev_dependencies:
flutter_test:

Loading…
Cancel
Save