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),
@ -168,6 +168,13 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
_tangheemInsideTableValueList = _tangheemInsideTableValueList =
_ayatTangheemTypeMappedData?.property?.where((element) => (!element.isInsideTable) && (element.propertyValue ?? "").isNotEmpty)?.toList() ?? []; _ayatTangheemTypeMappedData?.property?.where((element) => (!element.isInsideTable) && (element.propertyValue ?? "").isNotEmpty)?.toList() ?? [];
var _tempTangheemIndexWord = "";
if (ayatTangheemTypeMappedDataList.length == 1) {
_tempTangheemIndexWord = "";
} else {
_tempTangheemIndexWord = getArabicIndexWord(index);
}
return ListView( return ListView(
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
shrinkWrap: true, shrinkWrap: true,
@ -176,7 +183,7 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
Row( Row(
children: [ children: [
Text( Text(
" جمله ${_ayatTangheemTypeMappedData.tangheemTypeName} ${getArabicIndexWord(index)} ", " جمله ${_ayatTangheemTypeMappedData.tangheemTypeName} $_tempTangheemIndexWord",
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white, backgroundColor: ColorConsts.primaryBlue), style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white, backgroundColor: ColorConsts.primaryBlue),
), ),
Expanded( Expanded(
@ -231,7 +238,11 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
_tangheemInsideTableValueList[index].propertyValue, _tangheemInsideTableValueList[index].propertyValue,
style: TextStyle(color: ColorConsts.primaryBlack), style: TextStyle(
color: Color(
Utils.stringToHex(_tangheemInsideTableValueList[index].textColor),
),
),
), ),
color: ColorConsts.secondaryWhite, color: ColorConsts.secondaryWhite,
), ),
@ -258,7 +269,8 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
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