Skip to content

Commit 353aa40

Browse files
authored
feat(viewmodel): add development mode handling in ChapterViewModel (#1612)
1 parent 75d1f4c commit 353aa40

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

mobile-app/lib/ui/views/learn/chapter/chapter_view.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class ChapterView extends StatelessWidget {
7070
ChapterViewModel model,
7171
BuildContext context,
7272
) {
73+
bool disabled = chapter.dashedName == 'frontend-libraries' && !model.isDev;
74+
7375
return Container(
7476
padding: EdgeInsets.all(8),
7577
margin: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
@@ -95,7 +97,8 @@ class ChapterView extends StatelessWidget {
9597
),
9698
),
9799
),
98-
if (chapter.comingSoon != null && chapter.comingSoon == true)
100+
if (chapter.comingSoon != null && chapter.comingSoon == true ||
101+
disabled)
99102
Container(
100103
margin: const EdgeInsets.all(8),
101104
padding: const EdgeInsets.all(3),
@@ -108,7 +111,7 @@ class ChapterView extends StatelessWidget {
108111
child: Text('Coming Soon'),
109112
),
110113
for (Module module in chapter.modules as List<Module>)
111-
chapterButton(context, module, model)
114+
chapterButton(context, module, model, chapter)
112115
],
113116
),
114117
),
@@ -121,8 +124,10 @@ class ChapterView extends StatelessWidget {
121124
BuildContext context,
122125
Module module,
123126
ChapterViewModel model,
127+
Chapter chapter,
124128
) {
125-
if (module.comingSoon != null && module.comingSoon == true) {
129+
bool disabled = chapter.dashedName == 'frontend-libraries' && !model.isDev;
130+
if (module.comingSoon != null && module.comingSoon == true || disabled) {
126131
return Container();
127132
}
128133

mobile-app/lib/ui/views/learn/chapter/chapter_viewmodel.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:dio/dio.dart';
2+
import 'package:flutter_dotenv/flutter_dotenv.dart';
23
import 'package:freecodecamp/app/app.locator.dart';
34
import 'package:freecodecamp/app/app.router.dart';
45
import 'package:freecodecamp/models/learn/completed_challenge_model.dart';
@@ -15,10 +16,19 @@ class ChapterViewModel extends BaseViewModel {
1516
final NavigationService _navigationService = locator<NavigationService>();
1617
final AuthenticationService auth = locator<AuthenticationService>();
1718

19+
bool _isDev = false;
20+
bool get isDev => _isDev;
21+
1822
Future<SuperBlock?>? superBlockFuture;
1923

24+
set setIsDev(bool value) {
25+
_isDev = value;
26+
notifyListeners();
27+
}
28+
2029
void init() async {
2130
superBlockFuture = requestChapters();
31+
developmentMode();
2232
}
2333

2434
Future<String> calculateProgress(Module module) async {
@@ -68,6 +78,11 @@ class ChapterViewModel extends BaseViewModel {
6878
return null;
6979
}
7080

81+
void developmentMode() async {
82+
await dotenv.load();
83+
setIsDev = dotenv.env['DEVELOPMENTMODE'] == 'TRUE';
84+
}
85+
7186
void routeToBlockView(
7287
List<Block> blocks,
7388
String moduleName,

0 commit comments

Comments
 (0)