File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
mobile-app/lib/ui/views/news/html_handler Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import 'dart:convert';
33import 'package:cached_network_image/cached_network_image.dart' ;
44import 'package:collection/collection.dart' ;
55import 'package:flutter/material.dart' ;
6+ import 'package:flutter/services.dart' ;
67import 'package:flutter_html/flutter_html.dart' ;
78import 'package:flutter_html_table/flutter_html_table.dart' ;
89import 'package:freecodecamp/ui/theme/fcc_theme.dart' ;
@@ -238,6 +239,49 @@ class HTMLParser {
238239 return Container ();
239240 },
240241 ),
242+ TagExtension (
243+ tagsToExtend: {'code' },
244+ builder: (child) {
245+ String ? parsed = parser.parseFragment (child.innerHtml).text ?? '' ;
246+
247+ return InkWell (
248+ onTap: () {
249+ Clipboard .setData (ClipboardData (text: parsed));
250+ ScaffoldMessenger .of (context).showSnackBar (
251+ SnackBar (
252+ content: Text .rich (
253+ TextSpan (
254+ children: [
255+ TextSpan (
256+ text: parsed,
257+ style: const TextStyle (
258+ fontWeight: FontWeight .bold,
259+ fontSize: 20 ,
260+ ),
261+ ),
262+ const TextSpan (
263+ text: ' copied to clipboard!' ,
264+ style: TextStyle (fontSize: 20 ),
265+ ),
266+ ],
267+ ),
268+ ),
269+ duration: const Duration (seconds: 1 ),
270+ ),
271+ );
272+ },
273+ child: Text (
274+ parsed,
275+ style: const TextStyle (
276+ fontFamily: 'Hack' ,
277+ color: Colors .white,
278+ fontSize: 18 ,
279+ backgroundColor: FccColors .gray75,
280+ ),
281+ ),
282+ );
283+ },
284+ ),
241285 TagExtension (
242286 tagsToExtend: {'img' },
243287 builder: (child) {
You can’t perform that action at this time.
0 commit comments