Skip to content

Commit ebf389e

Browse files
Reimplement jumping to the proper verse after navigation
1 parent e586043 commit ebf389e

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

lib/models/bibles/oet_lv_bible.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class OETLiteralBibleImpl extends JsonToBible {
114114
}
115115
}
116116

117-
log(htmlText);
117+
//log(htmlText);
118118
return htmlText;
119119
}
120120
}

lib/ui/views/reader/reader_viewmodel.dart

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'package:webview_flutter_android/webview_flutter_android.dart';
1111
import '../../../app/app.locator.dart';
1212
import '../../../app/app.router.dart';
1313
import '../../../common/enums.dart';
14+
import '../../../common/oet_rv_section_start_end.dart';
1415
import '../../../common/themes.dart';
1516
import '../../../common/toast.dart';
1617
import '../../../services/bibles_service.dart';
@@ -123,8 +124,20 @@ class ReaderViewModel extends ReactiveViewModel {
123124
themeName = CurrentTheme.contrast.name;
124125
}
125126

126-
// Jump to id
127-
String id = '$bookCode$chapterNumber:1'; // TODO: set appropriate verse number
127+
// If viewBy is 'section', jump to a specific verse. Otherwise
128+
// for 'chapter' we fallback on the first verse of the chapter.
129+
String id = '$bookCode$chapterNumber:1';
130+
if (viewBy == ViewBy.section) {
131+
Map<String, dynamic>? sectionReferences = sectionStartEndMappingForOET[bookCode]?[sectionNumber];
132+
133+
if (sectionReferences != null) {
134+
Map<String, int> startReference = sectionReferences['start']!;
135+
int startChapter = startReference['chapter']!;
136+
int startVerse = startReference['verse']!;
137+
138+
id = '$bookCode$startChapter:$startVerse';
139+
}
140+
}
128141

129142
Uri htmlUri = Uri.dataFromString("""
130143
<!DOCTYPE html>

0 commit comments

Comments
 (0)