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); 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) { static void showLoading(BuildContext context) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
_isLoadingVisible = true; _isLoadingVisible = true;

@ -33,6 +33,7 @@ class AyatTangheemTypeMapped {
class AyatTangheemTypeMappedData { class AyatTangheemTypeMappedData {
String tangheemTypeId; String tangheemTypeId;
String tangheemTypeName; String tangheemTypeName;
String tangheemTypeDescription;
String ayaTangheemTypeId; String ayaTangheemTypeId;
int surahNo; int surahNo;
String surahNameEn; String surahNameEn;
@ -49,6 +50,7 @@ class AyatTangheemTypeMappedData {
AyatTangheemTypeMappedData( AyatTangheemTypeMappedData(
{this.tangheemTypeId, {this.tangheemTypeId,
this.tangheemTypeName, this.tangheemTypeName,
this.tangheemTypeDescription,
this.ayaTangheemTypeId, this.ayaTangheemTypeId,
this.surahNo, this.surahNo,
this.surahNameEn, this.surahNameEn,
@ -65,6 +67,7 @@ class AyatTangheemTypeMappedData {
AyatTangheemTypeMappedData.fromJson(Map<String, dynamic> json) { AyatTangheemTypeMappedData.fromJson(Map<String, dynamic> json) {
tangheemTypeId = json['tangheemTypeId']; tangheemTypeId = json['tangheemTypeId'];
tangheemTypeName = json['tangheemTypeName']; tangheemTypeName = json['tangheemTypeName'];
tangheemTypeDescription = json['tangheemTypeDescription'];
ayaTangheemTypeId = json['ayaTangheemTypeId']; ayaTangheemTypeId = json['ayaTangheemTypeId'];
surahNo = json['surahNo']; surahNo = json['surahNo'];
surahNameEn = json['surahNameEn']; surahNameEn = json['surahNameEn'];
@ -93,6 +96,7 @@ class AyatTangheemTypeMappedData {
final Map<String, dynamic> data = new Map<String, dynamic>(); final Map<String, dynamic> data = new Map<String, dynamic>();
data['tangheemTypeId'] = this.tangheemTypeId; data['tangheemTypeId'] = this.tangheemTypeId;
data['tangheemTypeName'] = this.tangheemTypeName; data['tangheemTypeName'] = this.tangheemTypeName;
data['tangheemTypeDescription'] = this.tangheemTypeDescription;
data['ayaTangheemTypeId'] = this.ayaTangheemTypeId; data['ayaTangheemTypeId'] = this.ayaTangheemTypeId;
data['surahNo'] = this.surahNo; data['surahNo'] = this.surahNo;
data['surahNameEn'] = this.surahNameEn; data['surahNameEn'] = this.surahNameEn;
@ -124,16 +128,18 @@ class TangheemProperty {
String tangheemTypePropertyId; String tangheemTypePropertyId;
String propertyText; String propertyText;
bool isInsideTable; bool isInsideTable;
String textColor;
int orderNo; int orderNo;
String ayaTangheemTypePropertyId; String ayaTangheemTypePropertyId;
String propertyValue; 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) { TangheemProperty.fromJson(Map<String, dynamic> json) {
tangheemTypePropertyId = json['tangheemTypePropertyId']; tangheemTypePropertyId = json['tangheemTypePropertyId'];
propertyText = json['propertyText']; propertyText = json['propertyText'];
isInsideTable = json['isInsideTable']; isInsideTable = json['isInsideTable'];
textColor = json['textColor'];
orderNo = json['orderNo']; orderNo = json['orderNo'];
ayaTangheemTypePropertyId = json['ayaTangheemTypePropertyId']; ayaTangheemTypePropertyId = json['ayaTangheemTypePropertyId'];
propertyValue = json['propertyValue']; propertyValue = json['propertyValue'];
@ -144,6 +150,7 @@ class TangheemProperty {
data['tangheemTypePropertyId'] = this.tangheemTypePropertyId; data['tangheemTypePropertyId'] = this.tangheemTypePropertyId;
data['propertyText'] = this.propertyText; data['propertyText'] = this.propertyText;
data['isInsideTable'] = this.isInsideTable; data['isInsideTable'] = this.isInsideTable;
data['textColor'] = this.textColor;
data['orderNo'] = this.orderNo; data['orderNo'] = this.orderNo;
data['ayaTangheemTypePropertyId'] = this.ayaTangheemTypePropertyId; data['ayaTangheemTypePropertyId'] = this.ayaTangheemTypePropertyId;
data['propertyValue'] = this.propertyValue; 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/app_state/app_state.dart';
import 'package:tangheem/classes/colors.dart'; import 'package:tangheem/classes/colors.dart';
import 'package:tangheem/classes/utils.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/surah_model.dart';
import 'package:tangheem/models/tangheem_type_model.dart'; import 'package:tangheem/models/tangheem_type_model.dart';
import 'package:tangheem/ui/screens/tangheem_screen.dart'; import 'package:tangheem/ui/screens/tangheem_screen.dart';
@ -35,6 +36,7 @@ class _HomeScreenState extends State<HomeScreen> {
SurahModel _surahModel; SurahModel _surahModel;
TangheemType _tangheemType; TangheemType _tangheemType;
ContentInfoModel _contentInfoModel;
@override @override
void initState() { void initState() {
@ -46,6 +48,7 @@ class _HomeScreenState extends State<HomeScreen> {
void getSurahAndTangheemTypes() async { void getSurahAndTangheemTypes() async {
Utils.showLoading(context); Utils.showLoading(context);
try { try {
_contentInfoModel = await TangheemUserApiClient().getContentInfo(4);
_surahModel = await TangheemUserApiClient().getSurahs(); _surahModel = await TangheemUserApiClient().getSurahs();
AppState().setSurahModel(_surahModel); AppState().setSurahModel(_surahModel);
_surahList = _surahModel.data.map((element) => element.nameAR).toList(); _surahList = _surahModel.data.map((element) => element.nameAR).toList();
@ -93,7 +96,7 @@ class _HomeScreenState extends State<HomeScreen> {
), ),
SizedBox(height: 8), SizedBox(height: 8),
Text( Text(
"تساعدك موسوعة \"تنغيم\" على أداء الأساليب اللغوية القرآنية (كالاستفهام والأمر والنهي والإتمام) بما يخدم معنى الآية. وقد أشرف عليها متخصصون في اللغة العربية والدراسات القرآنية.", Utils.getNotNullValue(_contentInfoModel?.data ?? [], 0)?.content ?? "",
style: TextStyle(fontSize: 14, color: ColorConsts.textGrey, height: 1), style: TextStyle(fontSize: 14, color: ColorConsts.textGrey, height: 1),
), ),
SizedBox(height: 32), SizedBox(height: 32),

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

@ -129,7 +129,7 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
), ),
SizedBox(height: 8), SizedBox(height: 8),
Text( Text(
"هنا نضع\" تعريف بالاستفهام وتداخل الأساليب\"", _ayatTangheemTypeMappedFirstData.tangheemTypeDescription ?? "",
style: TextStyle(fontSize: 14, color: ColorConsts.textGrey, height: 1), style: TextStyle(fontSize: 14, color: ColorConsts.textGrey, height: 1),
), ),
SizedBox(height: 8), SizedBox(height: 8),
@ -150,115 +150,127 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
child: RepaintBoundary( child: RepaintBoundary(
key: _globalKey, key: _globalKey,
child: Material( child: Material(
color: Colors.white, color: Colors.white,
child: ListView.builder( child: ListView.builder(
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
shrinkWrap: true, shrinkWrap: true,
itemCount: ayatTangheemTypeMappedDataList.length > 5 ? 5 : ayatTangheemTypeMappedDataList.length, itemCount: ayatTangheemTypeMappedDataList.length > 5 ? 5 : ayatTangheemTypeMappedDataList.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
var _ayatTangheemTypeMappedData = ayatTangheemTypeMappedDataList[index]; var _ayatTangheemTypeMappedData = ayatTangheemTypeMappedDataList[index];
List<TangheemProperty> _tangheemInsideTableTrueList = []; List<TangheemProperty> _tangheemInsideTableTrueList = [];
List<TangheemProperty> _tangheemInsideTableValueList = []; List<TangheemProperty> _tangheemInsideTableValueList = [];
List<TangheemProperty> _tangheemInsideTableEmptyList = []; List<TangheemProperty> _tangheemInsideTableEmptyList = [];
List<String> _tangheemWords = []; List<String> _tangheemWords = [];
_tangheemWords.add(_ayatTangheemTypeMappedData.highlightText ?? ""); _tangheemWords.add(_ayatTangheemTypeMappedData.highlightText ?? "");
_tangheemInsideTableTrueList = _tangheemInsideTableTrueList =
_ayatTangheemTypeMappedData?.property?.where((element) => (element.isInsideTable) && (element.propertyValue ?? "").isNotEmpty)?.toList() ?? []; _ayatTangheemTypeMappedData?.property?.where((element) => (element.isInsideTable) && (element.propertyValue ?? "").isNotEmpty)?.toList() ?? [];
_tangheemInsideTableValueList = _tangheemInsideTableValueList =
_ayatTangheemTypeMappedData?.property?.where((element) => (!element.isInsideTable) && (element.propertyValue ?? "").isNotEmpty)?.toList() ?? []; _ayatTangheemTypeMappedData?.property?.where((element) => (!element.isInsideTable) && (element.propertyValue ?? "").isNotEmpty)?.toList() ?? [];
return ListView( var _tempTangheemIndexWord = "";
physics: NeverScrollableScrollPhysics(), if (ayatTangheemTypeMappedDataList.length == 1) {
shrinkWrap: true, _tempTangheemIndexWord = "";
padding: EdgeInsets.all(4), } else {
children: [ _tempTangheemIndexWord = getArabicIndexWord(index);
Row( }
children: [
Text( return ListView(
" جمله ${_ayatTangheemTypeMappedData.tangheemTypeName} ${getArabicIndexWord(index)} ", physics: NeverScrollableScrollPhysics(),
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white, backgroundColor: ColorConsts.primaryBlue), shrinkWrap: true,
), padding: EdgeInsets.all(4),
Expanded( children: [
child: Container(height: 2, color: ColorConsts.primaryBlue), Row(
), children: [
], Text(
), " جمله ${_ayatTangheemTypeMappedData.tangheemTypeName} $_tempTangheemIndexWord",
SizedBox(height: 8), style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white, backgroundColor: ColorConsts.primaryBlue),
TextHighLightWidget( ),
text: _ayatTangheemTypeMappedData.reverseAyatNumber() ?? "", Expanded(
valueColor: ColorConsts.primaryBlue, child: Container(height: 2, color: ColorConsts.primaryBlue),
highlights: _tangheemWords,
highLightFontSize: fontSize,
style: TextStyle(
fontFamily: "UthmanicHafs",
fontSize: fontSize,
fontWeight: FontWeight.bold,
), ),
],
),
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( SizedBox(height: 16),
itemCount: _tangheemInsideTableValueList.length, ListView.separated(
physics: NeverScrollableScrollPhysics(), itemCount: _tangheemInsideTableValueList.length,
shrinkWrap: true, physics: NeverScrollableScrollPhysics(),
separatorBuilder: (context, index) { shrinkWrap: true,
return Divider( separatorBuilder: (context, index) {
color: Colors.white, return Divider(
height: 1, color: Colors.white,
thickness: 0, height: 1,
); thickness: 0,
}, );
itemBuilder: (context, index) { },
return Row( itemBuilder: (context, index) {
children: [ return Row(
Expanded( children: [
child: Container( Expanded(
height: 40, child: Container(
padding: EdgeInsets.only(left: 4, right: 8), height: 40,
alignment: Alignment.centerRight, padding: EdgeInsets.only(left: 4, right: 8),
child: Text( alignment: Alignment.centerRight,
_tangheemInsideTableValueList[index].propertyText, child: Text(
style: TextStyle(fontWeight: FontWeight.bold, color: ColorConsts.secondaryOrange), _tangheemInsideTableValueList[index].propertyText,
), style: TextStyle(fontWeight: FontWeight.bold, color: ColorConsts.secondaryOrange),
color: ColorConsts.secondaryWhite,
), ),
color: ColorConsts.secondaryWhite,
), ),
SizedBox(width: 8), ),
Expanded( SizedBox(width: 8),
child: Container( Expanded(
height: 40, child: Container(
padding: EdgeInsets.only(left: 4, right: 8), height: 40,
alignment: Alignment.centerRight, padding: EdgeInsets.only(left: 4, right: 8),
child: Text( alignment: Alignment.centerRight,
_tangheemInsideTableValueList[index].propertyValue, child: Text(
style: TextStyle(color: ColorConsts.primaryBlack), _tangheemInsideTableValueList[index].propertyValue,
style: TextStyle(
color: Color(
Utils.stringToHex(_tangheemInsideTableValueList[index].textColor),
),
), ),
color: ColorConsts.secondaryWhite,
), ),
) 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)
], ],
), );
}),
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), SizedBox(height: 4),
Text( Text(
tangheemPropertyList[index].propertyValue ?? "", 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 url_launcher: ^6.0.3
flutter_slidable: ^0.6.0 flutter_slidable: ^0.6.0
record_mp3: ^2.1.0 record_mp3: ^2.1.0
syncfusion_flutter_pdfviewer: ^19.1.58-beta syncfusion_flutter_pdfviewer: ^19.1.59-beta
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

Loading…
Cancel
Save