LCOV - code coverage report
Current view: top level - lib/widgets - serverrow.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 57 0.0 %
Date: 2024-09-10 17:47:43 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:cwtch/models/servers.dart';
       2             : import 'package:cwtch/themes/opaque.dart';
       3             : import 'package:cwtch/views/addeditservers.dart';
       4             : import 'package:flutter/material.dart';
       5             : import 'package:flutter/services.dart';
       6             : import 'package:provider/provider.dart';
       7             : import 'package:flutter_gen/gen_l10n/app_localizations.dart';
       8             : 
       9             : import '../cwtch_icons_icons.dart';
      10             : import '../errorHandler.dart';
      11             : import '../settings.dart';
      12             : 
      13             : class ServerRow extends StatefulWidget {
      14           0 :   @override
      15           0 :   _ServerRowState createState() => _ServerRowState();
      16             : }
      17             : 
      18             : class _ServerRowState extends State<ServerRow> {
      19           0 :   @override
      20             :   Widget build(BuildContext context) {
      21           0 :     var server = Provider.of<ServerInfoState>(context);
      22           0 :     return Card(
      23             :         clipBehavior: Clip.antiAlias,
      24           0 :         margin: EdgeInsets.all(0.0),
      25           0 :         child: InkWell(
      26           0 :             child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
      27           0 :               Padding(
      28             :                   padding: const EdgeInsets.all(6.0), //border size
      29           0 :                   child: Row(children: [
      30           0 :                     Icon(CwtchIcons.dns_24px,
      31           0 :                         color: server.running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor : Provider.of<Settings>(context).theme.portraitOfflineBorderColor, size: 64),
      32           0 :                     Visibility(
      33           0 :                         visible: !server.running,
      34           0 :                         child: Icon(
      35             :                           CwtchIcons.negative_heart_24px,
      36           0 :                           color: Provider.of<Settings>(context).theme.portraitOfflineBorderColor,
      37             :                         )),
      38             :                   ])),
      39           0 :               Expanded(
      40           0 :                   child: Column(
      41           0 :                 children: [
      42           0 :                   Text(
      43           0 :                     server.description,
      44           0 :                     semanticsLabel: server.description,
      45           0 :                     style: Provider.of<Settings>(context)
      46           0 :                         .scaleFonts(defaultFormLabelTextStyle)
      47           0 :                         .apply(color: server.running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor : Provider.of<Settings>(context).theme.portraitOfflineBorderColor),
      48             :                     softWrap: true,
      49             :                     overflow: TextOverflow.ellipsis,
      50             :                   ),
      51           0 :                   Visibility(
      52           0 :                       visible: !Provider.of<Settings>(context).streamerMode,
      53           0 :                       child: ExcludeSemantics(
      54           0 :                           child: Text(
      55           0 :                         server.onion,
      56             :                         softWrap: true,
      57             :                         overflow: TextOverflow.ellipsis,
      58           0 :                         style: Provider.of<Settings>(context)
      59           0 :                             .scaleFonts(defaultFormLabelTextStyle)
      60           0 :                             .copyWith(color: server.running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor : Provider.of<Settings>(context).theme.portraitOfflineBorderColor),
      61             :                       )))
      62             :                 ],
      63             :               )),
      64             : 
      65             :               // Copy server button
      66           0 :               IconButton(
      67             :                 enableFeedback: true,
      68           0 :                 splashRadius: Material.defaultSplashRadius / 2,
      69           0 :                 tooltip: AppLocalizations.of(context)!.copyServerKeys,
      70           0 :                 icon: Icon(CwtchIcons.address_copy, color: Provider.of<Settings>(context).current().mainTextColor),
      71           0 :                 onPressed: () {
      72           0 :                   Clipboard.setData(new ClipboardData(text: server.serverBundle));
      73           0 :                   final snackBar = SnackBar(content: Text(AppLocalizations.of(context)!.copiedToClipboardNotification));
      74           0 :                   ScaffoldMessenger.of(context).showSnackBar(snackBar);
      75             :                 },
      76             :               ),
      77             : 
      78             :               // Edit button
      79           0 :               IconButton(
      80             :                 enableFeedback: true,
      81           0 :                 splashRadius: Material.defaultSplashRadius / 2,
      82           0 :                 tooltip: AppLocalizations.of(context)!.editServerTitle,
      83           0 :                 icon: Icon(Icons.create, color: Provider.of<Settings>(context).current().mainTextColor),
      84           0 :                 onPressed: () {
      85           0 :                   _pushEditServer(server);
      86             :                 },
      87             :               )
      88             :             ]),
      89           0 :             onTap: () {
      90           0 :               _pushEditServer(server);
      91             :             }));
      92             :   }
      93             : 
      94           0 :   void _pushEditServer(ServerInfoState server) {
      95           0 :     Provider.of<ErrorHandler>(context, listen: false).reset();
      96           0 :     Navigator.of(context).push(MaterialPageRoute<void>(
      97           0 :       settings: RouteSettings(name: "serveraddedit"),
      98           0 :       builder: (BuildContext context) {
      99           0 :         return MultiProvider(
     100           0 :           providers: [ChangeNotifierProvider.value(value: server)],
     101           0 :           child: AddEditServerView(),
     102             :         );
     103             :       },
     104             :     ));
     105             :   }
     106             : }

Generated by: LCOV version 1.14