tangheem api added, and improvements
parent
a810086aef
commit
70abaa6fa7
@ -0,0 +1,93 @@
|
||||
class AyaTangheemProperty {
|
||||
int totalItemsCount;
|
||||
int statusCode;
|
||||
String message;
|
||||
List<AyaTangheemPropertyData> data;
|
||||
|
||||
AyaTangheemProperty(
|
||||
{this.totalItemsCount, this.statusCode, this.message, this.data});
|
||||
|
||||
AyaTangheemProperty.fromJson(Map<String, dynamic> json) {
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
statusCode = json['statusCode'];
|
||||
message = json['message'];
|
||||
if (json['data'] != null) {
|
||||
data = new List<AyaTangheemPropertyData>();
|
||||
json['data'].forEach((v) {
|
||||
data.add(new AyaTangheemPropertyData.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
data['statusCode'] = this.statusCode;
|
||||
data['message'] = this.message;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class AyaTangheemPropertyData {
|
||||
String ayaTangheemPropertyId;
|
||||
String ayaTangheemTypeId;
|
||||
String tangheemTypePropertyId;
|
||||
String propertyValue;
|
||||
int surahNo;
|
||||
int ayaNo;
|
||||
String ayaText;
|
||||
String propertyText;
|
||||
String tangheemTypeName;
|
||||
String tangheemTypeId;
|
||||
bool isInsideTable;
|
||||
int orderNo;
|
||||
|
||||
AyaTangheemPropertyData(
|
||||
{this.ayaTangheemPropertyId,
|
||||
this.ayaTangheemTypeId,
|
||||
this.tangheemTypePropertyId,
|
||||
this.propertyValue,
|
||||
this.surahNo,
|
||||
this.ayaNo,
|
||||
this.ayaText,
|
||||
this.propertyText,
|
||||
this.tangheemTypeName,
|
||||
this.tangheemTypeId,
|
||||
this.isInsideTable,
|
||||
this.orderNo});
|
||||
|
||||
AyaTangheemPropertyData.fromJson(Map<String, dynamic> json) {
|
||||
ayaTangheemPropertyId = json['ayaTangheemPropertyId'];
|
||||
ayaTangheemTypeId = json['ayaTangheemTypeId'];
|
||||
tangheemTypePropertyId = json['tangheemTypePropertyId'];
|
||||
propertyValue = json['propertyValue'];
|
||||
surahNo = json['surahNo'];
|
||||
ayaNo = json['ayaNo'];
|
||||
ayaText = json['ayaText'];
|
||||
propertyText = json['propertyText'];
|
||||
tangheemTypeName = json['tangheemTypeName'];
|
||||
tangheemTypeId = json['tangheemTypeId'];
|
||||
isInsideTable = json['isInsideTable'];
|
||||
orderNo = json['orderNo'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['ayaTangheemPropertyId'] = this.ayaTangheemPropertyId;
|
||||
data['ayaTangheemTypeId'] = this.ayaTangheemTypeId;
|
||||
data['tangheemTypePropertyId'] = this.tangheemTypePropertyId;
|
||||
data['propertyValue'] = this.propertyValue;
|
||||
data['surahNo'] = this.surahNo;
|
||||
data['ayaNo'] = this.ayaNo;
|
||||
data['ayaText'] = this.ayaText;
|
||||
data['propertyText'] = this.propertyText;
|
||||
data['tangheemTypeName'] = this.tangheemTypeName;
|
||||
data['tangheemTypeId'] = this.tangheemTypeId;
|
||||
data['isInsideTable'] = this.isInsideTable;
|
||||
data['orderNo'] = this.orderNo;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
class AyaTangheemType {
|
||||
int totalItemsCount;
|
||||
int statusCode;
|
||||
String message;
|
||||
List<AyaTangheemTypeData> data;
|
||||
|
||||
AyaTangheemType({this.totalItemsCount, this.statusCode, this.message, this.data});
|
||||
|
||||
AyaTangheemType.fromJson(Map<String, dynamic> json) {
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
statusCode = json['statusCode'];
|
||||
message = json['message'];
|
||||
if (json['data'] != null) {
|
||||
data = new List<AyaTangheemTypeData>();
|
||||
json['data'].forEach((v) {
|
||||
data.add(new AyaTangheemTypeData.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
data['statusCode'] = this.statusCode;
|
||||
data['message'] = this.message;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class AyaTangheemTypeData {
|
||||
String ayaTangheemTypeId;
|
||||
int surahNo;
|
||||
int ayaNo;
|
||||
String highlightText;
|
||||
bool isActive;
|
||||
String tangheemTypeId;
|
||||
String tangheemTypeName;
|
||||
int ayatNumberInSurah;
|
||||
|
||||
AyaTangheemTypeData({this.ayaTangheemTypeId, this.surahNo, this.ayaNo, this.highlightText, this.isActive, this.tangheemTypeId, this.tangheemTypeName, this.ayatNumberInSurah});
|
||||
|
||||
AyaTangheemTypeData.fromJson(Map<String, dynamic> json) {
|
||||
ayaTangheemTypeId = json['ayaTangheemTypeId'];
|
||||
surahNo = json['surahNo'];
|
||||
ayaNo = json['ayaNo'];
|
||||
highlightText = json['highlightText'];
|
||||
isActive = json['isActive'];
|
||||
tangheemTypeId = json['tangheemTypeId'];
|
||||
tangheemTypeName = json['tangheemTypeName'];
|
||||
ayatNumberInSurah = json['ayatNumberInSurah'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['ayaTangheemTypeId'] = this.ayaTangheemTypeId;
|
||||
data['surahNo'] = this.surahNo;
|
||||
data['ayaNo'] = this.ayaNo;
|
||||
data['highlightText'] = this.highlightText;
|
||||
data['isActive'] = this.isActive;
|
||||
data['tangheemTypeId'] = this.tangheemTypeId;
|
||||
data['tangheemTypeName'] = this.tangheemTypeName;
|
||||
data['ayatNumberInSurah'] = this.ayatNumberInSurah;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,178 @@
|
||||
class AyatTangheemTypeMapped {
|
||||
int totalItemsCount;
|
||||
int statusCode;
|
||||
String message;
|
||||
List<AyatTangheemTypeMappedData> data;
|
||||
|
||||
AyatTangheemTypeMapped({this.totalItemsCount, this.statusCode, this.message, this.data});
|
||||
|
||||
AyatTangheemTypeMapped.fromJson(Map<String, dynamic> json) {
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
statusCode = json['statusCode'];
|
||||
message = json['message'];
|
||||
if (json['data'] != null) {
|
||||
data = new List<AyatTangheemTypeMappedData>();
|
||||
json['data'].forEach((v) {
|
||||
data.add(new AyatTangheemTypeMappedData.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
data['statusCode'] = this.statusCode;
|
||||
data['message'] = this.message;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class AyatTangheemTypeMappedData {
|
||||
String tangheemTypeId;
|
||||
String tangheemTypeName;
|
||||
String ayaTangheemTypeId;
|
||||
int surahNo;
|
||||
String surahNameEn;
|
||||
String surahNameAr;
|
||||
int ayahNo;
|
||||
String ayahText;
|
||||
int ayatNumberInSurah;
|
||||
String highlightText;
|
||||
String userId;
|
||||
List<TangheemProperty> property;
|
||||
List<VoiceNote> voiceNote;
|
||||
|
||||
AyatTangheemTypeMappedData(
|
||||
{this.tangheemTypeId,
|
||||
this.tangheemTypeName,
|
||||
this.ayaTangheemTypeId,
|
||||
this.surahNo,
|
||||
this.surahNameEn,
|
||||
this.surahNameAr,
|
||||
this.ayahNo,
|
||||
this.ayahText,
|
||||
this.ayatNumberInSurah,
|
||||
this.highlightText,
|
||||
this.userId,
|
||||
this.property,
|
||||
this.voiceNote});
|
||||
|
||||
AyatTangheemTypeMappedData.fromJson(Map<String, dynamic> json) {
|
||||
tangheemTypeId = json['tangheemTypeId'];
|
||||
tangheemTypeName = json['tangheemTypeName'];
|
||||
ayaTangheemTypeId = json['ayaTangheemTypeId'];
|
||||
surahNo = json['surahNo'];
|
||||
surahNameEn = json['surahNameEn'];
|
||||
surahNameAr = json['surahNameAr'];
|
||||
ayahNo = json['ayahNo'];
|
||||
ayahText = json['ayahText'];
|
||||
ayatNumberInSurah = json['ayatNumberInSurah'];
|
||||
highlightText = json['highlightText'];
|
||||
userId = json['userId'];
|
||||
if (json['property'] != null) {
|
||||
property = new List<TangheemProperty>();
|
||||
json['property'].forEach((v) {
|
||||
property.add(new TangheemProperty.fromJson(v));
|
||||
});
|
||||
}
|
||||
if (json['voiceNote'] != null) {
|
||||
voiceNote = new List<VoiceNote>();
|
||||
json['voiceNote'].forEach((v) {
|
||||
voiceNote.add(new VoiceNote.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['tangheemTypeId'] = this.tangheemTypeId;
|
||||
data['tangheemTypeName'] = this.tangheemTypeName;
|
||||
data['ayaTangheemTypeId'] = this.ayaTangheemTypeId;
|
||||
data['surahNo'] = this.surahNo;
|
||||
data['surahNameEn'] = this.surahNameEn;
|
||||
data['surahNameAr'] = this.surahNameAr;
|
||||
data['ayahNo'] = this.ayahNo;
|
||||
data['ayahText'] = this.ayahText;
|
||||
data['ayatNumberInSurah'] = this.ayatNumberInSurah;
|
||||
data['highlightText'] = this.highlightText;
|
||||
data['userId'] = this.userId;
|
||||
if (this.property != null) {
|
||||
data['property'] = this.property.map((v) => v.toJson()).toList();
|
||||
}
|
||||
if (this.voiceNote != null) {
|
||||
data['voiceNote'] = this.voiceNote.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class TangheemProperty {
|
||||
String tangheemTypePropertyId;
|
||||
String propertyText;
|
||||
bool isInsideTable;
|
||||
int orderNo;
|
||||
String ayaTangheemPropertyId;
|
||||
String propertyValue;
|
||||
|
||||
TangheemProperty({this.tangheemTypePropertyId, this.propertyText, this.isInsideTable, this.orderNo, this.ayaTangheemPropertyId, this.propertyValue});
|
||||
|
||||
TangheemProperty.fromJson(Map<String, dynamic> json) {
|
||||
tangheemTypePropertyId = json['tangheemTypePropertyId'];
|
||||
propertyText = json['propertyText'];
|
||||
isInsideTable = json['isInsideTable'];
|
||||
orderNo = json['orderNo'];
|
||||
ayaTangheemPropertyId = json['ayaTangheemPropertyId'];
|
||||
propertyValue = json['propertyValue'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['tangheemTypePropertyId'] = this.tangheemTypePropertyId;
|
||||
data['propertyText'] = this.propertyText;
|
||||
data['isInsideTable'] = this.isInsideTable;
|
||||
data['orderNo'] = this.orderNo;
|
||||
data['ayaTangheemPropertyId'] = this.ayaTangheemPropertyId;
|
||||
data['propertyValue'] = this.propertyValue;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class VoiceNote {
|
||||
String voiceNoteId;
|
||||
String voiceNotePath;
|
||||
String exposeFilePath;
|
||||
String userId;
|
||||
String userName;
|
||||
String fileName;
|
||||
String fileType;
|
||||
String ayaTangheemTypeId;
|
||||
|
||||
VoiceNote({this.voiceNoteId, this.voiceNotePath, this.exposeFilePath, this.userId, this.userName, this.fileName, this.fileType, this.ayaTangheemTypeId});
|
||||
|
||||
VoiceNote.fromJson(Map<String, dynamic> json) {
|
||||
voiceNoteId = json['voiceNoteId'];
|
||||
voiceNotePath = json['voiceNotePath'];
|
||||
exposeFilePath = json['exposeFilePath'];
|
||||
userId = json['userId'];
|
||||
userName = json['userName'];
|
||||
fileName = json['fileName'];
|
||||
fileType = json['fileType'];
|
||||
ayaTangheemTypeId = json['ayaTangheemTypeId'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['voiceNoteId'] = this.voiceNoteId;
|
||||
data['voiceNotePath'] = this.voiceNotePath;
|
||||
data['exposeFilePath'] = this.exposeFilePath;
|
||||
data['userId'] = this.userId;
|
||||
data['userName'] = this.userName;
|
||||
data['fileName'] = this.fileName;
|
||||
data['fileType'] = this.fileType;
|
||||
data['ayaTangheemTypeId'] = this.ayaTangheemTypeId;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
class QuickLinksModel {
|
||||
int totalItemsCount;
|
||||
int statusCode;
|
||||
String message;
|
||||
List<QuickLinksData> data;
|
||||
|
||||
QuickLinksModel({this.totalItemsCount, this.statusCode, this.message, this.data});
|
||||
|
||||
QuickLinksModel.fromJson(Map<String, dynamic> json) {
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
statusCode = json['statusCode'];
|
||||
message = json['message'];
|
||||
if (json['data'] != null) {
|
||||
data = new List<QuickLinksData>();
|
||||
json['data'].forEach((v) {
|
||||
data.add(new QuickLinksData.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
data['statusCode'] = this.statusCode;
|
||||
data['message'] = this.message;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class QuickLinksData {
|
||||
int quickLinksId;
|
||||
String displayText;
|
||||
String description;
|
||||
String imageUrl;
|
||||
String position;
|
||||
int orderNo;
|
||||
String fileName;
|
||||
String exposeFilePath;
|
||||
|
||||
QuickLinksData(
|
||||
{this.quickLinksId,
|
||||
this.displayText,
|
||||
this.description,
|
||||
this.imageUrl,
|
||||
this.position,
|
||||
this.orderNo,
|
||||
this.fileName,
|
||||
this.exposeFilePath});
|
||||
|
||||
QuickLinksData.fromJson(Map<String, dynamic> json) {
|
||||
quickLinksId = json['quickLinksId'];
|
||||
displayText = json['displayText'];
|
||||
description = json['description'];
|
||||
imageUrl = json['imageUrl'];
|
||||
position = json['position'];
|
||||
orderNo = json['orderNo'];
|
||||
fileName = json['fileName'];
|
||||
exposeFilePath = json['exposeFilePath'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['quickLinksId'] = this.quickLinksId;
|
||||
data['displayText'] = this.displayText;
|
||||
data['description'] = this.description;
|
||||
data['imageUrl'] = this.imageUrl;
|
||||
data['position'] = this.position;
|
||||
data['orderNo'] = this.orderNo;
|
||||
data['fileName'] = this.fileName;
|
||||
data['exposeFilePath'] = this.exposeFilePath;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,120 @@
|
||||
import 'dart:math';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tangheem/classes/colors.dart';
|
||||
|
||||
class TextHighLightWidget extends StatelessWidget {
|
||||
final String text;
|
||||
final String valueText;
|
||||
final Color valueColor;
|
||||
final List<String> highlights;
|
||||
final TextStyle style;
|
||||
final Color highLightColor = ColorConsts.secondaryOrange;
|
||||
|
||||
TextHighLightWidget({
|
||||
Key key,
|
||||
this.text,
|
||||
this.valueText,
|
||||
this.valueColor,
|
||||
this.highlights,
|
||||
this.style = const TextStyle(),
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (text == '') {
|
||||
return _richText(_normalSpan(text));
|
||||
}
|
||||
if (highlights.isEmpty) {
|
||||
return _richText(_normalSpan(text));
|
||||
}
|
||||
for (int i = 0; i < highlights.length; i++) {
|
||||
if (highlights[i] == null) {
|
||||
assert(highlights[i] != null);
|
||||
return _richText(_normalSpan(text));
|
||||
}
|
||||
if (highlights[i].isEmpty) {
|
||||
assert(highlights[i].isNotEmpty);
|
||||
return _richText(_normalSpan(text));
|
||||
}
|
||||
}
|
||||
|
||||
List<TextSpan> _spans = List();
|
||||
int _start = 0;
|
||||
List<String> _lowerCaseHighlights = List();
|
||||
|
||||
highlights.forEach((element) {
|
||||
_lowerCaseHighlights.add(element.toLowerCase());
|
||||
});
|
||||
|
||||
while (true) {
|
||||
Map<int, String> _highlightsMap = Map();
|
||||
|
||||
for (int i = 0; i < highlights.length; i++) {
|
||||
int _index = text.toLowerCase().indexOf(_lowerCaseHighlights[i], _start);
|
||||
if (_index >= 0) {
|
||||
_highlightsMap.putIfAbsent(_index, () => highlights[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (_highlightsMap.isNotEmpty) {
|
||||
List<int> _indexes = List();
|
||||
_highlightsMap.forEach((key, value) => _indexes.add(key));
|
||||
|
||||
int _currentIndex = _indexes.reduce(min);
|
||||
String _currentHighlight = text.substring(_currentIndex, _currentIndex + _highlightsMap[_currentIndex].length);
|
||||
|
||||
if (_currentIndex == _start) {
|
||||
_spans.add(_highlightSpan(_currentHighlight));
|
||||
_start += _currentHighlight.length;
|
||||
} else {
|
||||
_spans.add(_normalSpan(text.substring(_start, _currentIndex)));
|
||||
_spans.add(_highlightSpan(_currentHighlight));
|
||||
_start = _currentIndex + _currentHighlight.length;
|
||||
}
|
||||
} else {
|
||||
_spans.add(_normalSpan(text.substring(_start, text.length)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (valueText != null) {
|
||||
_spans.add(TextSpan(
|
||||
text: ' ' + valueText,
|
||||
style: TextStyle(color: valueColor ?? Color(0xff170026), fontSize: 12, fontWeight: FontWeight.w800),
|
||||
));
|
||||
}
|
||||
return _richText(TextSpan(children: _spans));
|
||||
}
|
||||
|
||||
TextSpan _highlightSpan(String value) {
|
||||
if (style.color == null) {
|
||||
return TextSpan(
|
||||
text: value,
|
||||
style: style.copyWith(color: highLightColor, fontSize: 18),
|
||||
);
|
||||
} else {
|
||||
return TextSpan(text: value, style: style.copyWith(color: valueColor));
|
||||
}
|
||||
}
|
||||
|
||||
TextSpan _normalSpan(String value) {
|
||||
if (style.color == null) {
|
||||
return TextSpan(
|
||||
text: value,
|
||||
style: style.copyWith(color: valueColor),
|
||||
);
|
||||
} else {
|
||||
return TextSpan(text: value, style: style, children: [
|
||||
if (valueText != null)
|
||||
TextSpan(
|
||||
text: ' ' + valueText,
|
||||
style: style,
|
||||
)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
RichText _richText(TextSpan text) {
|
||||
return RichText(key: key, text: text, textAlign: TextAlign.center);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue