LCOV - code coverage report
Current view: top level - lib/widgets - conversation_options.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 45 0.0 %
Date: 2024-11-29 20:17:41 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:cwtch/cwtch_icons_icons.dart';
       2             : import 'package:cwtch/main.dart';
       3             : import 'package:cwtch/models/contact.dart';
       4             : import 'package:cwtch/models/profile.dart';
       5             : import 'package:cwtch/settings.dart';
       6             : import 'package:cwtch/themes/opaque.dart';
       7             : import 'package:flutter/material.dart';
       8             : import 'package:flutter_gen/gen_l10n/app_localizations.dart';
       9             : import 'package:provider/provider.dart';
      10             : 
      11             : enum ConversationOptionsMenu { settings, disconnect, manage_shares }
      12             : 
      13             : class ConversationOptions extends StatefulWidget {
      14             :   final void Function() SelectSettings;
      15             :   final void Function() ManageFiles;
      16             : 
      17           0 :   ConversationOptions(this.SelectSettings, this.ManageFiles);
      18           0 :   @override
      19           0 :   _ConversationOptionsState createState() => _ConversationOptionsState();
      20             : }
      21             : 
      22             : class _ConversationOptionsState extends State<ConversationOptions> {
      23           0 :   @override
      24             :   Widget build(BuildContext context) {
      25           0 :     return PopupMenuButton<ConversationOptionsMenu>(
      26           0 :         icon: Provider.of<ContactInfoState>(context, listen: false).isGroup == true ? Icon(CwtchIcons.group_settings_24px) : Icon(CwtchIcons.peer_settings_24px),
      27             :         iconSize: 24,
      28           0 :         tooltip: AppLocalizations.of(context)!.availabilityStatusTooltip,
      29           0 :         splashRadius: Material.defaultSplashRadius / 2,
      30           0 :         onSelected: (ConversationOptionsMenu item) {
      31             :           switch (item) {
      32           0 :             case ConversationOptionsMenu.settings:
      33           0 :               widget.SelectSettings();
      34             :               break;
      35           0 :             case ConversationOptionsMenu.disconnect:
      36           0 :               if (Provider.of<ContactInfoState>(context, listen: false).isGroup) {
      37           0 :                 Provider.of<FlwtchState>(context, listen: false)
      38           0 :                     .cwtch
      39           0 :                     .DisconnectFromServer(Provider.of<ProfileInfoState>(context, listen: false).onion, Provider.of<ContactInfoState>(context, listen: false).server!);
      40             :               } else {
      41           0 :                 Provider.of<FlwtchState>(context, listen: false)
      42           0 :                     .cwtch
      43           0 :                     .DisconnectFromPeer(Provider.of<ProfileInfoState>(context, listen: false).onion, Provider.of<ContactInfoState>(context, listen: false).onion);
      44             :               }
      45             :               // reset the disconnect button to allow for immediate connection...
      46           0 :               Provider.of<ContactInfoState>(context, listen: false).lastRetryTime = DateTime.now().subtract(Duration(minutes: 2));
      47           0 :               Provider.of<ContactInfoState>(context, listen: false).contactEvents.add(ContactEvent("Disconnect from Peer"));
      48             :               break;
      49           0 :             case ConversationOptionsMenu.manage_shares:
      50           0 :               widget.ManageFiles();
      51             :               break;
      52             :           }
      53             :         },
      54           0 :         itemBuilder: (context) {
      55           0 :           return <PopupMenuEntry<ConversationOptionsMenu>>[
      56           0 :             PopupMenuItem<ConversationOptionsMenu>(
      57             :               value: ConversationOptionsMenu.settings,
      58           0 :               enabled: Provider.of<ContactInfoState>(context, listen: false).isOnline(),
      59           0 :               child: Row(children: [
      60           0 :                 Icon(
      61             :                   CwtchIcons.account_circle_24px,
      62             :                   color: Colors.white,
      63             :                 ),
      64           0 :                 Expanded(
      65             :                     child:
      66           0 :                         Text(AppLocalizations.of(context)!.conversationSettings, textAlign: TextAlign.right, style: Provider.of<Settings>(context, listen: false).scaleFonts(defaultTextButtonStyle)))
      67             :               ]),
      68             :             ),
      69           0 :             PopupMenuItem<ConversationOptionsMenu>(
      70             :                 value: ConversationOptionsMenu.disconnect,
      71             :                 enabled: true,
      72           0 :                 child: Tooltip(
      73           0 :                   message: AppLocalizations.of(context)!.contactDisconnect,
      74           0 :                   child: Row(children: [
      75           0 :                     Icon(
      76             :                       CwtchIcons.disconnect_from_contact,
      77             :                       color: Colors.white,
      78             :                     ),
      79           0 :                     Expanded(
      80           0 :                         child: Text(AppLocalizations.of(context)!.contactDisconnectSummary,
      81           0 :                             textAlign: TextAlign.right, style: Provider.of<Settings>(context, listen: false).scaleFonts(defaultTextButtonStyle)))
      82             :                   ]),
      83             :                 )),
      84           0 :             PopupMenuItem<ConversationOptionsMenu>(
      85             :               value: ConversationOptionsMenu.manage_shares,
      86           0 :               enabled: Provider.of<Settings>(context, listen: false).isExperimentEnabled(FileSharingExperiment),
      87           0 :               child: Row(children: [
      88           0 :                 Icon(
      89             :                   CwtchIcons.manage_files,
      90             :                   color: Colors.white,
      91             :                 ),
      92           0 :                 Expanded(
      93           0 :                     child: Text(AppLocalizations.of(context)!.manageSharedFiles, textAlign: TextAlign.right, style: Provider.of<Settings>(context, listen: false).scaleFonts(defaultTextButtonStyle)))
      94             :               ]),
      95             :             ),
      96             :           ];
      97             :         });
      98             :   }
      99             : }

Generated by: LCOV version 1.14