Skip to content
Open
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
15 changes: 13 additions & 2 deletions mobile-app/integration_test/learn/learn_landing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,18 @@ void main() {

String baseUrl = LearnService.baseUrl;
final Response res = await dio.get('$baseUrl/available-superblocks.json');
List superBlocks = res.data['superblocks'];
Map<String, dynamic> superBlockStages = res.data['superblocks'];

List<Map<String, dynamic>> superBlocks = [];
for (var stage in superBlockStages.keys) {
List stageBlocks = superBlockStages[stage];
for (var superBlock in stageBlocks) {
if (!superBlock['dashedName'].toString().contains('full-stack')) {
superBlocks.add(superBlock);
}
}
}

int publicSuperBlocks = 0;

for (int i = 0; i < superBlocks.length; i++) {
Expand All @@ -39,7 +50,7 @@ void main() {
);
expect(
superBlockButtons,
findsNWidgets(superBlocks.length - 1), // Exclude 'full-stack' superblock
findsNWidgets(superBlocks.length),
);
expect(publicSuperBlockButtons, findsNWidgets(publicSuperBlocks));

Expand Down
7 changes: 2 additions & 5 deletions mobile-app/lib/service/learn/learn_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ class LearnService {

final Dio _dio = DioService.dio;

// TODO: change this to v2 and remove baseUrlV2 once the migration is complete
static final baseUrl = '${AuthenticationService.baseURL}/curriculum-data/v1';
static final baseUrlV2 =
'${AuthenticationService.baseURL}/curriculum-data/v2';
static final baseUrl = '${AuthenticationService.baseURL}/curriculum-data/v2';

final LearnOfflineService learnOfflineService =
locator<LearnOfflineService>();
Expand Down Expand Up @@ -62,7 +59,7 @@ class LearnService {
String challengeId = challenge.id;
int challengeType = challenge.challengeType;

Response submitTypesRes = await _dio.get('$baseUrlV2/submit-types.json');
Response submitTypesRes = await _dio.get('$baseUrl/submit-types.json');
Map<String, dynamic> submitTypes = submitTypesRes.data;

switch (submitTypes[challengeType.toString()]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ class ChallengeViewModel extends BaseViewModel {
);

String slug = block!.challengeTiles[challengeIndex].id;
String url = LearnService.baseUrlV2;
String url = LearnService.baseUrl;
String challengeUrl =
'$url/challenges/${block!.superBlock.dashedName}/${block!.dashedName}/$slug.json';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ChallengeTemplateViewModel extends BaseViewModel {

void initiate(Block block, String challengeId, DateTime? challengeDate) {
if (challengeDate == null) {
final String base = LearnService.baseUrlV2;
final String base = LearnService.baseUrl;

String url =
'$base/challenges/${block.superBlock.dashedName}/${block.dashedName}/$challengeId.json';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ChapterViewModel extends BaseViewModel {
}

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

final Response res = await _dio.get('$baseUrl/full-stack-developer.json');
if (res.statusCode == 200) {
Expand Down
75 changes: 40 additions & 35 deletions mobile-app/lib/ui/views/learn/landing/landing_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -220,44 +220,49 @@ class LearnLandingViewModel extends BaseViewModel {
bool showAllSB =
dotenv.get('SHOWALLSB', fallback: 'false').toLowerCase() == 'true';

// Map<String, dynamic> superBlockStages = res.data['superblocks'];
// for (var superBlockStage in superBlockStages.keys) {
// layout.add(Padding(
// padding: const EdgeInsets.all(8.0),
// child: handleStageTitle(superBlockStage),
// ));

// for (var superBlock in superBlockStages[superBlockStage]) {
// layout.add(
// SuperBlockButton(
// button: SuperBlockButtonData(
// path: superBlock['dashedName'],
// name: superBlock['title'],
// public: !showAllSB ? superBlock['public'] : true,
// ),
// model: this,
// ),
// );
// }
// }

List superBlocks = res.data['superblocks'];
for (int i = 0; i < superBlocks.length; i++) {
if (superBlocks[i]['dashedName'].toString().contains('full-stack')) {
continue;
Map<String, dynamic> superBlockStages = res.data['superblocks'];

List<String> stageOrder = [
'legacy',
'professional',
'extra',
'core',
'english'
];

List<Widget> publicButtons = [];
List<Widget> nonPublicButtons = [];

for (var stage in stageOrder) {
if (superBlockStages.containsKey(stage)) {
List stageBlocks = superBlockStages[stage];

for (var superBlock in stageBlocks) {
if (superBlock['dashedName'].toString().contains('full-stack')) {
continue;
}

bool isPublic = superBlock['public'] ?? false;
Widget button = SuperBlockButton(
button: SuperBlockButtonData(
path: superBlock['dashedName'],
name: superBlock['title'],
public: !showAllSB ? superBlock['public'] : true,
),
model: this,
);

if (isPublic) {
publicButtons.add(button);
} else {
nonPublicButtons.add(button);
}
}
}
layout.add(
SuperBlockButton(
button: SuperBlockButtonData(
path: superBlocks[i]['dashedName'],
name: superBlocks[i]['title'],
public: !showAllSB ? superBlocks[i]['public'] : true,
),
model: this,
),
);
}

layout = [...publicButtons, ...nonPublicButtons];

return layout;
}
return [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class SuperBlockViewModel extends BaseViewModel {
String name,
bool hasInternet,
) async {
String baseUrl = LearnService.baseUrlV2;
String baseUrl = LearnService.baseUrl;

if (!hasInternet) {
return SuperBlock(
Expand Down
Loading