Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 57 additions & 5 deletions mobile-app/lib/app/app.router.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions mobile-app/lib/models/learn/curriculum_model.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const chapterBasedSuperBlocks = ['full-stack-developer'];
import 'package:freecodecamp/ui/views/learn/utils/learn_globals.dart';

enum SuperBlocks {
respWebDesignV9('responsive-web-design-v9'),
Expand Down Expand Up @@ -320,7 +320,8 @@ class Chapter {

enum ModuleType {
review('review'),
exam('exam');
exam('exam'),
certProject('cert-project');

static ModuleType fromValue(String value) {
return ModuleType.values.firstWhere(
Expand Down
16 changes: 13 additions & 3 deletions mobile-app/lib/ui/views/learn/chapter/chapter_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,28 @@ import 'package:freecodecamp/ui/views/learn/chapter/chapter_viewmodel.dart';
import 'package:stacked/stacked.dart';

class ChapterView extends StatelessWidget {
const ChapterView({super.key});
const ChapterView({
super.key,
required this.superBlockDashedName,
required this.superBlockName,
});

final String superBlockDashedName;
final String superBlockName;

@override
Widget build(BuildContext context) {
return ViewModelBuilder<ChapterViewModel>.reactive(
viewModelBuilder: () => ChapterViewModel(),
onViewModelReady: (model) => model.init(),
onViewModelReady: (model) => model.init(
superBlockDashedName,
superBlockName,
),
builder: (context, model, child) {
return Scaffold(
backgroundColor: FccColors.gray90,
appBar: AppBar(
title: Text('Chapters'),
title: Text(superBlockName),
),
body: StreamBuilder(
stream: model.auth.progress.stream,
Expand Down
15 changes: 9 additions & 6 deletions mobile-app/lib/ui/views/learn/chapter/chapter_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class ChapterViewModel extends BaseViewModel {
notifyListeners();
}

void init() async {
superBlockFuture = requestChapters();
void init(String superBlockDashedName, superBlockName) async {
superBlockFuture = requestChapters(superBlockDashedName, superBlockName);
developmentMode();
}

Expand Down Expand Up @@ -63,15 +63,18 @@ class ChapterViewModel extends BaseViewModel {
return false;
}

Future<SuperBlock?> requestChapters() async {
Future<SuperBlock?> requestChapters(
String superBlockDashedName, String superBlockName) async {
String baseUrl = LearnService.baseUrl;

final Response res = await _dio.get('$baseUrl/full-stack-developer.json');
final Response res = await _dio.get(
'$baseUrl/$superBlockDashedName.json',
);
if (res.statusCode == 200) {
return SuperBlock.fromJson(
res.data,
'full-stack-developer',
'Certified Full Stack Developer Curriculum',
superBlockDashedName,
superBlockName,
);
}

Expand Down
11 changes: 9 additions & 2 deletions mobile-app/lib/ui/views/learn/landing/landing_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import 'package:freecodecamp/service/learn/daily_challenge_service.dart';
import 'package:freecodecamp/service/learn/learn_offline_service.dart';
import 'package:freecodecamp/service/learn/learn_service.dart';
import 'package:freecodecamp/ui/views/learn/landing/landing_view.dart';
import 'package:freecodecamp/ui/views/learn/utils/learn_globals.dart';
import 'package:freecodecamp/ui/widgets/setup_dialog_ui.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:stacked/stacked.dart';
Expand Down Expand Up @@ -290,8 +291,14 @@ class LearnLandingViewModel extends BaseViewModel {
}

void routeToSuperBlock(String dashedName, String name) async {
if (dashedName == 'full-stack-developer') {
_navigationService.navigateTo(Routes.chapterView);
if (chapterBasedSuperBlocks.contains(dashedName)) {
_navigationService.navigateTo(
Routes.chapterView,
arguments: ChapterViewArguments(
superBlockDashedName: dashedName,
superBlockName: name,
),
);
} else {
_navigationService.navigateTo(
Routes.superBlockView,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class SuperBlockView extends StatelessWidget {
}

if (snapshot.hasError) {
return Text(context.t.error);
return Center(child: Text(context.t.error));
}

return const Center(
Expand Down
6 changes: 6 additions & 0 deletions mobile-app/lib/ui/views/learn/utils/learn_globals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ List<String> hasDialogue = [
'a2-english-for-developers',
'b1-english-for-developers',
];

const chapterBasedSuperBlocks = [
'responsive-web-design-v9',
'javascript-v9',
'python-v9'
];
Loading