LCOV - code coverage report
Current view: top level - lib/widgets - conversation_options.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 47 0.0 %
Date: 2026-07-15 19:28:30 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:cwtch/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)!.conversationSettings,
      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>(
      38             :                 context,
      39             :                 listen: false,
      40           0 :               ).cwtch.DisconnectFromServer(Provider.of<ProfileInfoState>(context, listen: false).onion, Provider.of<ContactInfoState>(context, listen: false).server!);
      41             :             } else {
      42           0 :               Provider.of<FlwtchState>(
      43             :                 context,
      44             :                 listen: false,
      45           0 :               ).cwtch.DisconnectFromPeer(Provider.of<ProfileInfoState>(context, listen: false).onion, Provider.of<ContactInfoState>(context, listen: false).onion);
      46             :             }
      47             :             // reset the disconnect button to allow for immediate connection...
      48           0 :             Provider.of<ContactInfoState>(context, listen: false).lastRetryTime = DateTime.now().subtract(Duration(minutes: 2));
      49           0 :             Provider.of<ContactInfoState>(context, listen: false).contactEvents.add(ContactEvent("Disconnect from Peer"));
      50             :             break;
      51           0 :           case ConversationOptionsMenu.manage_shares:
      52           0 :             widget.ManageFiles();
      53             :             break;
      54             :         }
      55             :       },
      56           0 :       itemBuilder: (context) {
      57           0 :         return <PopupMenuEntry<ConversationOptionsMenu>>[
      58           0 :           PopupMenuItem<ConversationOptionsMenu>(
      59             :             value: ConversationOptionsMenu.settings,
      60             :             enabled: true,
      61           0 :             child: Row(
      62           0 :               children: [
      63           0 :                 Icon(CwtchIcons.account_circle_24px, color: Colors.white),
      64           0 :                 Expanded(
      65           0 :                   child: Text(AppLocalizations.of(context)!.conversationSettings, textAlign: TextAlign.right, style: Provider.of<Settings>(context, listen: false).scaleFonts(defaultTextButtonStyle)),
      66             :                 ),
      67             :               ],
      68             :             ),
      69             :           ),
      70           0 :           PopupMenuItem<ConversationOptionsMenu>(
      71             :             value: ConversationOptionsMenu.disconnect,
      72           0 :             enabled: Provider.of<ContactInfoState>(context, listen: false).isOnline(),
      73           0 :             child: Tooltip(
      74           0 :               message: AppLocalizations.of(context)!.contactDisconnect,
      75           0 :               child: Row(
      76           0 :                 children: [
      77           0 :                   Icon(CwtchIcons.disconnect_from_contact, color: Colors.white),
      78           0 :                   Expanded(
      79           0 :                     child: Text(
      80           0 :                       AppLocalizations.of(context)!.contactDisconnectSummary,
      81             :                       textAlign: TextAlign.right,
      82           0 :                       style: Provider.of<Settings>(context, listen: false).scaleFonts(defaultTextButtonStyle),
      83             :                     ),
      84             :                   ),
      85             :                 ],
      86             :               ),
      87             :             ),
      88             :           ),
      89           0 :           PopupMenuItem<ConversationOptionsMenu>(
      90             :             value: ConversationOptionsMenu.manage_shares,
      91           0 :             enabled: Provider.of<Settings>(context, listen: false).isExperimentEnabled(FileSharingExperiment),
      92           0 :             child: Row(
      93           0 :               children: [
      94           0 :                 Icon(CwtchIcons.manage_files, color: Colors.white),
      95           0 :                 Expanded(
      96           0 :                   child: Text(AppLocalizations.of(context)!.manageSharedFiles, textAlign: TextAlign.right, style: Provider.of<Settings>(context, listen: false).scaleFonts(defaultTextButtonStyle)),
      97             :                 ),
      98             :               ],
      99             :             ),
     100             :           ),
     101             :         ];
     102             :       },
     103             :     );
     104             :   }
     105             : }

Generated by: LCOV version 1.14