Skip to content

Commit cbf1b16

Browse files
New web-view implementation of reader
- In this commit not everything is quite working the same as before yet. Most notably, navigation will always go to verse 1 of a chapter.
1 parent 495282f commit cbf1b16

17 files changed

Lines changed: 627 additions & 1339 deletions

lib/common/enums.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ enum CurrentTheme {
1414
light,
1515
dark,
1616
sepia,
17-
highContrast,
17+
contrast,
1818
}

lib/models/bibles/kjv_bible.dart

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,39 @@
1-
import 'package:flutter/material.dart';
1+
// ignore_for_file: prefer_single_quotes
22

3+
import '../../common/enums.dart';
34
import '../json_to_bible.dart';
4-
import '../text_item.dart';
55

66
/// KJV version implementation
77
class KJVBibleImpl extends JsonToBible {
8-
KJVBibleImpl(BuildContext context, Map<String, dynamic> json) : super(context: context, json: json);
8+
KJVBibleImpl(Map<String, dynamic> json) : super(json: json);
99

10-
/// Get the KJV chapter spans for [page].
1110
@override
12-
List<Map<String, dynamic>> getChapter(int page) {
13-
List<InlineSpan> spans = [];
14-
15-
// Chapters
16-
List<dynamic> chaptersData = json['chapters'];
17-
11+
String getBook(String bookCode, ViewBy viewBy) {
12+
String htmlText = '';
1813
String chapterNumber = '';
1914
List<dynamic> chapterContents = [];
2015

16+
List<dynamic> chaptersData = json['chapters'];
17+
2118
for (Map<dynamic, dynamic> chapter in chaptersData) {
2219
chapterNumber = chapter['chapter'];
20+
chapterContents = chapter['verses'];
2321

24-
if (chapterNumber == page.toString()) {
25-
spans.add(TextSpan(
26-
text: chapterNumber == '1' ? '$chapterNumber ' : '\n$chapterNumber ',
27-
style: TextItemStyles.chapterHeading(context),
28-
));
29-
chapterContents = chapter['verses'];
30-
break;
31-
}
32-
}
22+
String chapterNumberHtml = """<span class="c" id="$bookCode$chapterNumber">$chapterNumber</span>""";
3323

34-
for (Map item in chapterContents) {
35-
spans.add(
36-
TextSpan(
37-
children: [
38-
TextSpan(
39-
text: ' ${item['verse']} ',
40-
style: TextItemStyles.bodyMedium(context),
41-
),
42-
TextSpan(
43-
text: item['text'],
44-
style: TextItemStyles.text(context),
45-
),
46-
],
47-
),
48-
);
49-
}
24+
for (Map item in chapterContents) {
25+
String verseNumber = item['verse'];
26+
String verseText = item['text'];
5027

51-
return [
52-
{
53-
'spans': spans,
54-
'page': chapterNumber,
28+
if (verseNumber == '1') {
29+
htmlText +=
30+
"""<p class="p" id="$bookCode$chapterNumber:$verseNumber">$chapterNumberHtml<sup>$verseNumber</sup> $verseText</p>""";
31+
} else {
32+
htmlText +=
33+
"""<p class="p" id="$bookCode$chapterNumber:$verseNumber"><sup>$verseNumber</sup> $verseText</p>""";
34+
}
5535
}
56-
];
36+
}
37+
return htmlText;
5738
}
5839
}

lib/models/bibles/oet_bibles.dart

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)