aya number was showing duplicate in text highlight

development-design-2.0
Sikander Saleem 2 years ago
parent 9f8cf6022f
commit 1e8ff95c02

@ -61,6 +61,7 @@ class TextHighLightLengthWidget extends StatelessWidget {
startIndex = 0;
}
if (actualStartIndex != 0) {
startIndex++;
startIndex = actualStartIndex + startIndex;
}
endIndex = (highlightAya.length) + startIndex;
@ -99,134 +100,4 @@ class TextHighLightLengthWidget extends StatelessWidget {
RichText _richText(TextSpan text) {
return RichText(key: key, text: text, textAlign: textAlign);
}
}
// class TextHighLightWidget extends StatelessWidget {
// final String text;
// final String valueText;
// final Color valueColor;
// final List<String> highlights;
// final TextStyle style;
// final TextAlign textAlign;
// final Color highLightColor;
// final double highLightFontSize;
// final Function(String) onTap;
// final Function(String) onAyaTap;
//
// TextHighLightWidget(
// {Key key,
// this.text,
// this.textAlign = TextAlign.center,
// this.valueText,
// this.valueColor,
// this.highlights,
// this.highLightColor = ColorConsts.secondaryOrange,
// this.style = const TextStyle(),
// this.highLightFontSize = 18,
// this.onTap,
// this.onAyaTap});
//
// @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 = [];
// int _start = 0;
// List<String> _lowerCaseHighlights = [];
//
// 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 = [];
// _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: highLightFontSize),
// recognizer: TapGestureRecognizer()
// ..onTap = () {
// if (onTap != null) {
// onTap(value);
// }
// });
// } 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);
// }
// }
}
Loading…
Cancel
Save