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
4 changes: 4 additions & 0 deletions mobile-app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,10 @@
"@temporarily_unavailable": {
"description": "snackbar shown when a curriculum item is temporarily disabled"
},
"share_challenge": "Share this challenge",
"@share_challenge": {
"description": "tooltip for the button that shares a link to the current challenge"
},
"not_available_web": "Not available use the web version",
"@not_available_web": {
"description": "snackbar shown when a curriculum item is only available on the web"
Expand Down
1 change: 1 addition & 0 deletions mobile-app/lib/l10n/app_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@
"no_blocks_available": "No blocks available right now.",
"coming_soon": "Coming Soon",
"temporarily_unavailable": "Temporarily unavailable, come back soon.",
"share_challenge": "Share this challenge",
"not_available_web": "Not available use the web version",
"stage_core": "Recommended curriculum (still in beta):",
"stage_english": "Learn English for Developers:",
Expand Down
6 changes: 6 additions & 0 deletions mobile-app/lib/l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,12 @@ abstract class AppLocalizations {
/// **'Temporarily unavailable, come back soon.'**
String get temporarily_unavailable;

/// tooltip for the button that shares a link to the current challenge
///
/// In en, this message translates to:
/// **'Share this challenge'**
String get share_challenge;

/// snackbar shown when a curriculum item is only available on the web
///
/// In en, this message translates to:
Expand Down
3 changes: 3 additions & 0 deletions mobile-app/lib/l10n/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,9 @@ class AppLocalizationsEn extends AppLocalizations {
String get temporarily_unavailable =>
'Temporarily unavailable, come back soon.';

@override
String get share_challenge => 'Share this challenge';

@override
String get not_available_web => 'Not available use the web version';

Expand Down
3 changes: 3 additions & 0 deletions mobile-app/lib/l10n/app_localizations_es.dart
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,9 @@ class AppLocalizationsEs extends AppLocalizations {
String get temporarily_unavailable =>
'Temporarily unavailable, come back soon.';

@override
String get share_challenge => 'Share this challenge';

@override
String get not_available_web => 'Not available use the web version';

Expand Down
3 changes: 3 additions & 0 deletions mobile-app/lib/l10n/app_localizations_pt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,9 @@ class AppLocalizationsPt extends AppLocalizations {
String get temporarily_unavailable =>
'Temporarily unavailable, come back soon.';

@override
String get share_challenge => 'Share this challenge';

@override
String get not_available_web => 'Not available use the web version';

Expand Down
1 change: 1 addition & 0 deletions mobile-app/lib/l10n/app_pt.arb
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@
"no_blocks_available": "No blocks available right now.",
"coming_soon": "Coming Soon",
"temporarily_unavailable": "Temporarily unavailable, come back soon.",
"share_challenge": "Share this challenge",
"not_available_web": "Not available use the web version",
"stage_core": "Recommended curriculum (still in beta):",
"stage_english": "Learn English for Developers:",
Expand Down
19 changes: 19 additions & 0 deletions mobile-app/lib/ui/views/learn/challenge/challenge_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import 'package:freecodecamp/models/learn/curriculum_model.dart';
import 'package:freecodecamp/models/learn/daily_challenge_model.dart';
import 'package:freecodecamp/ui/theme/fcc_theme.dart';
import 'package:freecodecamp/ui/views/learn/challenge/challenge_viewmodel.dart';
import 'package:freecodecamp/ui/views/learn/utils/challenge_utils.dart';
import 'package:freecodecamp/ui/views/learn/widgets/challenge_widgets/project_preview.dart';
import 'package:freecodecamp/ui/views/learn/widgets/challenge_widgets/symbol_bar.dart';
import 'package:freecodecamp/ui/views/learn/widgets/console/console_view.dart';
import 'package:freecodecamp/ui/views/news/html_handler/html_handler.dart';
import 'package:share_plus/share_plus.dart';
import 'package:stacked/stacked.dart';

class ChallengeView extends StatelessWidget {
Expand Down Expand Up @@ -268,6 +270,7 @@ class ChallengeView extends StatelessWidget {
Row(
children: [
..._panelIconButtons(
context,
model,
challenge,
block,
Expand Down Expand Up @@ -485,6 +488,7 @@ class ChallengeView extends StatelessWidget {
required bool isActive,
required IconData icon,
required VoidCallback? onPressed,
String? tooltip,
}) {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 8),
Expand All @@ -499,6 +503,7 @@ class ChallengeView extends StatelessWidget {
: Colors.white,
),
onPressed: onPressed,
tooltip: tooltip,
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
),
Expand Down Expand Up @@ -547,6 +552,7 @@ class ChallengeView extends StatelessWidget {
}

List<Widget> _panelIconButtons(
BuildContext context,
ChallengeViewModel model,
Challenge challenge,
Block block,
Expand Down Expand Up @@ -586,6 +592,19 @@ class ChallengeView extends StatelessWidget {
model.setMounted = false;
},
),
_panelIconButton(
isActive: false,
icon: Icons.share,
tooltip: context.t.share_challenge,
onPressed: () {
SharePlus.instance.share(
ShareParams(
text:
'${block.name} - ${challenge.title}\n\n${challengeUrl(challenge)}',
),
);
},
),
];
}

Expand Down
6 changes: 6 additions & 0 deletions mobile-app/lib/ui/views/learn/utils/challenge_utils.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import 'package:freecodecamp/models/learn/challenge_model.dart';
import 'package:freecodecamp/models/learn/curriculum_model.dart';

// Builds the public freeCodeCamp URL of a challenge, so campers can share the
// exact step they are on.
String challengeUrl(Challenge challenge) {
return 'https://www.freecodecamp.org/learn/${challenge.superBlock}/${challenge.block}/${challenge.dashedName}';
}

String handleChallengeTitle(Challenge challenge, Block block) {
if (block.challenges.length == 1 ||
challenge.title.contains('Dialogue') ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:freecodecamp/models/learn/challenge_model.dart';
import 'package:freecodecamp/models/learn/curriculum_model.dart';
import 'package:freecodecamp/service/learn/learn_service.dart';
import 'package:freecodecamp/ui/views/learn/challenge/challenge_viewmodel.dart';
import 'package:freecodecamp/ui/views/learn/utils/challenge_utils.dart';
import 'package:freecodecamp/ui/views/learn/widgets/hint/hint_widget_model.dart';
import 'package:freecodecamp/ui/views/news/html_handler/html_handler.dart';
import 'package:freecodecamp/utils/helpers.dart';
Expand All @@ -26,7 +27,7 @@ Future<String> genForumLink(
final titleText = '$blockTitle - ${currChallenge.title}';
final t = context.t;
final String endingText =
'**${t.forum_mobile_info}**\n```txt\n$userDeviceInfo\n```\n\n**${t.forum_challenge}** $titleText\n\n**${t.forum_challenge_link}**\nhttps://www.freecodecamp.org/learn/${currChallenge.superBlock}/${currChallenge.block}/${currChallenge.dashedName}';
'**${t.forum_mobile_info}**\n```txt\n$userDeviceInfo\n```\n\n**${t.forum_challenge}** $titleText\n\n**${t.forum_challenge_link}**\n${challengeUrl(currChallenge)}';

final String userCode = await filesToMarkdown(currChallenge, editorText);

Expand Down
11 changes: 11 additions & 0 deletions mobile-app/test/unit/challenge_utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ void main() {
);
}

group('challengeUrl', () {
test('should build the public learn URL of a challenge', () {
final challenge = createChallenge(id: '1', title: 'Step 1');

expect(
challengeUrl(challenge),
'https://www.freecodecamp.org/learn/superblock/block1/challenge-1',
);
});
});

group('handleChallengeTitle', () {
test('should return empty string if the block contains a single challenge',
() {
Expand Down