LCOV - code coverage report
Current view: top level - lib/controllers - open_link_modal.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 37 0.0 %
Date: 2024-09-24 21:50:54 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:cwtch/themes/opaque.dart';
       2             : import 'package:cwtch/third_party/linkify/linkify.dart';
       3             : import 'package:flutter/material.dart';
       4             : import 'package:flutter/services.dart';
       5             : import 'package:flutter_gen/gen_l10n/app_localizations.dart';
       6             : import 'package:provider/provider.dart';
       7             : import 'package:url_launcher/url_launcher_string.dart';
       8             : 
       9             : import '../settings.dart';
      10             : 
      11           0 : void modalOpenLink(BuildContext ctx, LinkableElement link) {
      12           0 :   showModalBottomSheet<void>(
      13             :       context: ctx,
      14           0 :       builder: (BuildContext bcontext) {
      15           0 :         return Container(
      16             :             height: 200,
      17           0 :             child: Center(
      18           0 :               child: Padding(
      19           0 :                   padding: EdgeInsets.all(30.0),
      20           0 :                   child: Column(
      21             :                     mainAxisAlignment: MainAxisAlignment.center,
      22             :                     mainAxisSize: MainAxisSize.min,
      23           0 :                     children: <Widget>[
      24           0 :                       Text(
      25           0 :                         AppLocalizations.of(bcontext)!.clickableLinksWarning,
      26           0 :                         style: Provider.of<Settings>(bcontext).scaleFonts(defaultTextStyle),
      27             :                       ),
      28           0 :                       Flex(direction: Axis.horizontal, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
      29           0 :                         Container(
      30           0 :                           margin: EdgeInsets.symmetric(vertical: 20, horizontal: 10),
      31           0 :                           child: ElevatedButton(
      32           0 :                             child: Text(AppLocalizations.of(bcontext)!.clickableLinksCopy,
      33           0 :                                 style: Provider.of<Settings>(bcontext).scaleFonts(defaultTextButtonStyle), semanticsLabel: AppLocalizations.of(bcontext)!.clickableLinksCopy),
      34           0 :                             onPressed: () {
      35           0 :                               Clipboard.setData(new ClipboardData(text: link.url));
      36             : 
      37           0 :                               final snackBar = SnackBar(
      38           0 :                                 content: Text(
      39           0 :                                   AppLocalizations.of(bcontext)!.copiedToClipboardNotification,
      40           0 :                                   style: Provider.of<Settings>(bcontext, listen: false).scaleFonts(defaultTextButtonStyle),
      41             :                                 ),
      42             :                               );
      43             : 
      44           0 :                               Navigator.pop(bcontext);
      45           0 :                               ScaffoldMessenger.of(bcontext).showSnackBar(snackBar);
      46             :                             },
      47             :                           ),
      48             :                         ),
      49           0 :                         Container(
      50           0 :                           margin: EdgeInsets.symmetric(vertical: 20, horizontal: 10),
      51           0 :                           child: ElevatedButton(
      52           0 :                             child: Text(AppLocalizations.of(bcontext)!.clickableLinkOpen,
      53           0 :                                 style: Provider.of<Settings>(bcontext).scaleFonts(defaultTextButtonStyle), semanticsLabel: AppLocalizations.of(bcontext)!.clickableLinkOpen),
      54           0 :                             onPressed: () async {
      55           0 :                               if (await canLaunchUrlString(link.url)) {
      56           0 :                                 await launchUrlString(link.url);
      57           0 :                                 Navigator.pop(bcontext);
      58             :                               } else {
      59           0 :                                 final snackBar = SnackBar(content: Text(AppLocalizations.of(bcontext)!.clickableLinkError, style: Provider.of<Settings>(bcontext).scaleFonts(defaultTextButtonStyle)));
      60           0 :                                 ScaffoldMessenger.of(bcontext).showSnackBar(snackBar);
      61             :                               }
      62             :                             },
      63             :                           ),
      64             :                         ),
      65             :                       ]),
      66             :                     ],
      67             :                   )),
      68             :             ));
      69             :       });
      70             : }

Generated by: LCOV version 1.14