Skip to content

Commit 703b1c5

Browse files
Disable uncompleted OET books on a book-level rather than division-level
1 parent 7a7a34d commit 703b1c5

5 files changed

Lines changed: 131 additions & 85 deletions

File tree

lib/common/books.dart

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,58 @@ Map<String, int> bookNumOfChaptersMapping = {
198198
'REV': 22,
199199
};
200200

201-
// Uncompleted OET books
201+
// Uncompleted OET books (RV *and* LV are not finished for the book)
202202
// TODO: update as the OET is drafted more.
203-
List<String> uncompletedOETDivisions = [
204-
'TORAH',
205-
'HISTORY',
206-
'POETRY_WISDOM',
207-
'MAJOR_PROPHETS',
208-
'MINOR_PROPHETS',
203+
List<String> uncompletedOETBooks = [
204+
'GEN',
205+
'EXO',
206+
'LEV',
207+
'NUM',
208+
'DEU',
209+
'JOS',
210+
'JDG',
211+
'RUT',
212+
'SA1',
213+
'SA2',
214+
'KI1',
215+
'KI2',
216+
'CH1',
217+
'CH2',
218+
'EZR',
219+
'NEH',
220+
'EST',
221+
'JOB',
222+
'PSA',
223+
'PRO',
224+
'ECC',
225+
'SNG',
226+
'ISA',
227+
'JER',
228+
'LAM',
229+
'EZE',
230+
'DAN',
231+
'HOS',
232+
'JOL',
233+
'AMO',
234+
'OBA',
235+
'JNA',
236+
'MIC',
237+
'NAH',
238+
'HAB',
239+
'ZEP',
240+
'HAG',
241+
'ZEC',
242+
'MAL',
243+
];
244+
245+
// Book is either missing the json file or
246+
// has incomplete text that could cause errors.
247+
List<String> noOETBookDraft = [
248+
'JOB',
249+
'PSA',
250+
'ECC',
251+
'SNG',
252+
'LAM',
209253
];
210254

211255
class BooksMapping {

lib/ui/views/navigation_bible_divisions/navigation_bible_divisions_view.dart

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -50,45 +50,41 @@ class NavigationBibleDivisionsView extends StackedView<NavigationBibleDivisionsV
5050
itemCount: booksMapping.keys.length,
5151
itemBuilder: (BuildContext context, int index) {
5252
String bibleDivisionCode = BooksMapping.bibleDivisionCodeFromIndex(index);
53-
bool isDisabled = viewModel.isItemDisabled(bibleDivisionCode);
5453
return InkWell(
55-
onTap: () => viewModel.onTapBibleDivisionItem(bibleDivisionCode, isDisabled),
56-
child: Opacity(
57-
opacity: isDisabled ? 0.5 : 1.0,
58-
child: Padding(
59-
padding: const EdgeInsets.symmetric(vertical: 15.0, horizontal: 25.0),
60-
child: Row(
61-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
62-
crossAxisAlignment: CrossAxisAlignment.center,
63-
children: [
64-
Row(
65-
children: [
66-
Align(
67-
alignment: Alignment.topLeft,
68-
child: Padding(
69-
padding: const EdgeInsets.only(bottom: 13.0, right: 8),
70-
child: BibleDivisionIndicator(
71-
color: BooksMapping.colorFromBibleDivisionCode(bibleDivisionCode),
72-
),
54+
onTap: () => viewModel.onTapBibleDivisionItem(bibleDivisionCode),
55+
child: Padding(
56+
padding: const EdgeInsets.symmetric(vertical: 15.0, horizontal: 25.0),
57+
child: Row(
58+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
59+
crossAxisAlignment: CrossAxisAlignment.center,
60+
children: [
61+
Row(
62+
children: [
63+
Align(
64+
alignment: Alignment.topLeft,
65+
child: Padding(
66+
padding: const EdgeInsets.only(bottom: 13.0, right: 8),
67+
child: BibleDivisionIndicator(
68+
color: BooksMapping.colorFromBibleDivisionCode(bibleDivisionCode),
7369
),
7470
),
75-
Text(
76-
BooksMapping.bibleDivisionNameFromCode(bibleDivisionCode),
77-
style: TextStyle(
78-
color: context.theme.appColors.primary,
79-
fontSize: 16.0,
80-
),
71+
),
72+
Text(
73+
BooksMapping.bibleDivisionNameFromCode(bibleDivisionCode),
74+
style: TextStyle(
75+
color: context.theme.appColors.primary,
76+
fontSize: 16.0,
8177
),
82-
],
83-
),
84-
PhosphorIcon(
85-
PhosphorIcons.caretRight(PhosphorIconsStyle.bold),
86-
color: context.theme.appColors.primary,
87-
size: 18.0,
88-
semanticLabel: 'Caret right',
89-
),
90-
],
91-
),
78+
),
79+
],
80+
),
81+
PhosphorIcon(
82+
PhosphorIcons.caretRight(PhosphorIconsStyle.bold),
83+
color: context.theme.appColors.primary,
84+
size: 18.0,
85+
semanticLabel: 'Caret right',
86+
),
87+
],
9288
),
9389
),
9490
);

lib/ui/views/navigation_bible_divisions/navigation_bible_divisions_viewmodel.dart

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import 'package:stacked_services/stacked_services.dart';
33

44
import '../../../app/app.locator.dart';
55
import '../../../app/app.router.dart';
6-
import '../../../common/books.dart';
76
import '../../../common/enums.dart';
8-
import '../../../common/toast.dart';
97
import '../../../services/bibles_service.dart';
108
import '../../../services/settings_service.dart';
119

@@ -29,26 +27,18 @@ class NavigationBibleDivisionsViewModel extends BaseViewModel {
2927
return _biblesService.isReaderBibleOET(readerArea);
3028
}
3129

32-
bool isItemDisabled(String bibleDivisionCode) {
33-
return uncompletedOETDivisions.contains(bibleDivisionCode) && isBibleOET();
34-
}
35-
36-
void onTapBibleDivisionItem(String bibleDivisionCode, bool isDisabled) {
37-
if (isDisabled == true) {
38-
showToastMsg('These books are not yet completely drafted in the OET');
39-
} else {
40-
// For Acts and Revelation, skip directly to choosing the section/chapter
41-
if (bibleDivisionCode == 'ACTS' || bibleDivisionCode == 'REVELATION') {
42-
String bookCode = '';
43-
if (bibleDivisionCode == 'ACTS') {
44-
bookCode = 'ACT';
45-
} else if (bibleDivisionCode == 'REVELATION') {
46-
bookCode = 'REV';
47-
}
48-
_navigationService.navigateToNavigationSectionsChaptersView(readerArea: readerArea, bookCode: bookCode);
49-
} else {
50-
_navigationService.navigateToNavigationBooksView(readerArea: readerArea, bibleDivisionCode: bibleDivisionCode);
30+
void onTapBibleDivisionItem(String bibleDivisionCode) {
31+
// For Acts and Revelation, skip directly to choosing the section/chapter
32+
if (bibleDivisionCode == 'ACTS' || bibleDivisionCode == 'REVELATION') {
33+
String bookCode = '';
34+
if (bibleDivisionCode == 'ACTS') {
35+
bookCode = 'ACT';
36+
} else if (bibleDivisionCode == 'REVELATION') {
37+
bookCode = 'REV';
5138
}
39+
_navigationService.navigateToNavigationSectionsChaptersView(readerArea: readerArea, bookCode: bookCode);
40+
} else {
41+
_navigationService.navigateToNavigationBooksView(readerArea: readerArea, bibleDivisionCode: bibleDivisionCode);
5242
}
5343
}
5444

lib/ui/views/navigation_books/navigation_books_view.dart

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,29 +80,33 @@ class NavigationBooksView extends StackedView<NavigationBooksViewModel> {
8080
itemCount: BooksMapping.numOfBooksFromBibleDivisionCode(bibleDivisionCode),
8181
itemBuilder: (BuildContext context, int index) {
8282
Map<String, String> booksMapping = BooksMapping.booksMappingFromBibleDivisionCode(bibleDivisionCode);
83-
String key = booksMapping.keys.toList()[index];
83+
String bookCode = booksMapping.keys.toList()[index];
84+
bool isDisabled = viewModel.isItemDisabled(bookCode);
8485
return InkWell(
85-
onTap: () => viewModel.onTapBookItem(key),
86-
child: Padding(
87-
padding: const EdgeInsets.symmetric(vertical: 14.0, horizontal: 25.0),
88-
child: Row(
89-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
90-
crossAxisAlignment: CrossAxisAlignment.center,
91-
children: [
92-
Text(
93-
'${booksMapping[key]}',
94-
style: TextStyle(
86+
onTap: () => viewModel.onTapBookItem(bookCode, isDisabled),
87+
child: Opacity(
88+
opacity: isDisabled ? 0.5 : 1.0,
89+
child: Padding(
90+
padding: const EdgeInsets.symmetric(vertical: 14.0, horizontal: 25.0),
91+
child: Row(
92+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
93+
crossAxisAlignment: CrossAxisAlignment.center,
94+
children: [
95+
Text(
96+
'${booksMapping[bookCode]}',
97+
style: TextStyle(
98+
color: context.theme.appColors.primary,
99+
fontSize: 16.0,
100+
),
101+
),
102+
PhosphorIcon(
103+
PhosphorIcons.caretRight(PhosphorIconsStyle.bold),
95104
color: context.theme.appColors.primary,
96-
fontSize: 16.0,
105+
size: 18.0,
106+
semanticLabel: 'Caret right',
97107
),
98-
),
99-
PhosphorIcon(
100-
PhosphorIcons.caretRight(PhosphorIconsStyle.bold),
101-
color: context.theme.appColors.primary,
102-
size: 18.0,
103-
semanticLabel: 'Caret right',
104-
),
105-
],
108+
],
109+
),
106110
),
107111
),
108112
);

lib/ui/views/navigation_books/navigation_books_viewmodel.dart

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,28 @@ import 'package:stacked_services/stacked_services.dart';
33

44
import '../../../app/app.locator.dart';
55
import '../../../app/app.router.dart';
6+
import '../../../common/books.dart';
67
import '../../../common/enums.dart';
8+
import '../../../common/toast.dart';
9+
import '../../../services/bibles_service.dart';
710

811
class NavigationBooksViewModel extends BaseViewModel {
912
final _navigationService = locator<NavigationService>();
13+
final _biblesService = locator<BiblesService>();
1014

1115
NavigationBooksViewModel({required this.readerArea});
1216

1317
final Area readerArea;
1418

15-
void onTapBookItem(String bookCode) {
16-
_navigationService.navigateToNavigationSectionsChaptersView(readerArea: readerArea, bookCode: bookCode);
19+
void onTapBookItem(String bookCode, bool isDisabled) {
20+
if (isDisabled == true) {
21+
showToastMsg('OET book has not been completed yet');
22+
} else {
23+
_navigationService.navigateToNavigationSectionsChaptersView(readerArea: readerArea, bookCode: bookCode);
24+
}
25+
}
26+
27+
bool isItemDisabled(String bookCode) {
28+
return _biblesService.isReaderBibleOET(readerArea) && uncompletedOETBooks.contains(bookCode);
1729
}
1830
}

0 commit comments

Comments
 (0)