Skip to content

Commit 0e77d7d

Browse files
Disable uncomplete bible divisions for OET
1 parent bf8fc6a commit 0e77d7d

8 files changed

Lines changed: 178 additions & 62 deletions

File tree

lib/app/app.router.dart

Lines changed: 24 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/common/books.dart

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

201+
// Uncompleted OET books
202+
// 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',
209+
];
210+
201211
class BooksMapping {
202212
static String bookNameFromBookCode(String bookCode) {
203213
String bookName = '';

lib/common/toast.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:fluttertoast/fluttertoast.dart';
3+
4+
/// Shows a toast message with [msg] as the contents
5+
void showToastMsg(String msg) {
6+
Fluttertoast.showToast(
7+
msg: msg,
8+
toastLength: Toast.LENGTH_LONG,
9+
backgroundColor: Colors.white,
10+
textColor: Colors.black87,
11+
fontSize: 14.0,
12+
);
13+
}

lib/services/bibles_service.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,18 @@ class BiblesService with ListenableServiceMixin {
7979
}
8080
_settingsService.setNavRecentBooks(newHistory);
8181
}
82+
83+
bool isBibleOET(String bible) {
84+
return (bible == 'OET-RV' || bible == 'OET-LV');
85+
}
86+
87+
bool isReaderBibleOET(Area readerArea) {
88+
if (readerArea == Area.primary) {
89+
return isBibleOET(primaryBible);
90+
} else if (readerArea == Area.secondary) {
91+
return isBibleOET(secondaryBible);
92+
} else {
93+
return false;
94+
}
95+
}
8296
}

lib/ui/views/navigation_bible_divisions/navigation_bible_divisions_view.dart

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -50,64 +50,70 @@ 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);
5354
return InkWell(
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),
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+
),
6973
),
7074
),
71-
),
72-
Text(
73-
BooksMapping.bibleDivisionNameFromCode(bibleDivisionCode),
74-
style: TextStyle(
75-
color: context.theme.appColors.primary,
76-
fontSize: 16.0,
75+
Text(
76+
BooksMapping.bibleDivisionNameFromCode(bibleDivisionCode),
77+
style: TextStyle(
78+
color: context.theme.appColors.primary,
79+
fontSize: 16.0,
80+
),
7781
),
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-
],
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+
),
8892
),
8993
),
9094
);
9195
},
9296
),
9397
),
9498
Container(
95-
color: context.theme.appColors.appbarBackground,
99+
color: context.theme.brightness == Brightness.dark
100+
? context.theme.appColors.appbarBackground
101+
: context.theme.appColors.appbarBackground.withAlpha(8),
96102
padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 25.0),
97103
child: Column(
98104
children: [
99105
Row(
100106
children: [
101107
PhosphorIcon(
102108
PhosphorIcons.clockCounterClockwise(PhosphorIconsStyle.regular),
103-
color: context.theme.appColors.primaryOnDark,
109+
color: context.theme.appColors.secondary,
104110
size: 16.0,
105111
),
106112
const SizedBox(width: 4),
107113
Text(
108114
'RECENT',
109115
style: TextStyle(
110-
color: context.theme.appColors.primaryOnDark,
116+
color: context.theme.appColors.secondary,
111117
fontSize: 12.0,
112118
fontWeight: FontWeight.w500,
113119
),
@@ -137,7 +143,7 @@ class NavigationBibleDivisionsView extends StackedView<NavigationBibleDivisionsV
137143
maxLines: 1,
138144
overflow: TextOverflow.ellipsis,
139145
style: TextStyle(
140-
color: context.theme.appColors.primaryOnDark,
146+
color: context.theme.appColors.primary,
141147
fontSize: 16.0,
142148
),
143149
),
@@ -150,7 +156,7 @@ class NavigationBibleDivisionsView extends StackedView<NavigationBibleDivisionsV
150156
child: Text(
151157
'Your recent books will appear here.',
152158
style: TextStyle(
153-
color: context.theme.appColors.secondaryOnDark,
159+
color: context.theme.appColors.secondary,
154160
fontSize: 13.0,
155161
),
156162
),

lib/ui/views/navigation_bible_divisions/navigation_bible_divisions_viewmodel.dart

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ 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
import '../../../services/settings_service.dart';
811

912
class NavigationBibleDivisionsViewModel extends BaseViewModel {
13+
final _biblesService = locator<BiblesService>();
1014
final _settingsService = locator<SettingsService>();
1115
final _navigationService = locator<NavigationService>();
1216

@@ -18,26 +22,38 @@ class NavigationBibleDivisionsViewModel extends BaseViewModel {
1822
final Area readerArea;
1923

2024
String getTitle() {
21-
return '${linkReaderAreaScrolling == true ? '' : readerArea == Area.primary ? 'Primary' : 'Secondary'} Bible Nav';
25+
return '${linkReaderAreaScrolling == true ? '' : readerArea == Area.primary ? 'Primary' : 'Secondary'} Bible Navigation';
2226
}
2327

24-
void onTapBibleDivisionItem(String bibleDivisionCode) {
25-
// For Acts and Revelation, skip directly to choosing the section/chapter
26-
if (bibleDivisionCode == 'ACTS' || bibleDivisionCode == 'REVELATION') {
27-
String bookCode = '';
28-
if (bibleDivisionCode == 'ACTS') {
29-
bookCode = 'ACT';
30-
} else if (bibleDivisionCode == 'REVELATION') {
31-
bookCode = 'REV';
32-
}
33-
_navigationService.navigateToNavigationSectionsChaptersView(bookCode: bookCode);
28+
bool isBibleOET() {
29+
return _biblesService.isReaderBibleOET(readerArea);
30+
}
31+
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');
3439
} else {
35-
_navigationService.navigateToNavigationBooksView(bibleDivisionCode: bibleDivisionCode);
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);
51+
}
3652
}
3753
}
3854

3955
void onTapRecentBookItem(String bookCode) {
40-
_navigationService.navigateToNavigationSectionsChaptersView(bookCode: bookCode);
56+
_navigationService.navigateToNavigationSectionsChaptersView(readerArea: readerArea, bookCode: bookCode);
4157
}
4258

4359
void onPopInvoked(bool onPopInvoked) async {

0 commit comments

Comments
 (0)