LCOV - code coverage report
Current view: top level - lib/widgets - DropdownContacts.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 16 0.0 %
Date: 2026-07-15 19:28:30 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:cwtch/models/contact.dart';
       2             : import 'package:cwtch/models/profile.dart';
       3             : import 'package:cwtch/themes/opaque.dart';
       4             : import 'package:flutter/material.dart';
       5             : import 'package:provider/provider.dart';
       6             : 
       7             : import '../settings.dart';
       8             : 
       9           0 : bool noFilter(ContactInfoState peer) {
      10             :   return true;
      11             : }
      12             : 
      13             : // Dropdown menu populated from Provider.of<ProfileInfoState>'s contact list
      14             : // Includes both peers and groups; begins empty/nothing selected
      15             : // Displays nicknames to UI but uses handles as values
      16             : // Pass an onChanged handler to access value
      17             : class DropdownContacts extends StatefulWidget {
      18           0 :   DropdownContacts({required this.onChanged, this.filter = noFilter});
      19             :   final Function(dynamic) onChanged;
      20             :   final bool Function(ContactInfoState) filter;
      21             : 
      22           0 :   @override
      23           0 :   _DropdownContactsState createState() => _DropdownContactsState();
      24             : }
      25             : 
      26             : class _DropdownContactsState extends State<DropdownContacts> {
      27             :   String? selected;
      28             : 
      29           0 :   @override
      30             :   Widget build(BuildContext context) {
      31           0 :     return DropdownButton(
      32             :       isExpanded: true, // magic property
      33           0 :       value: this.selected,
      34           0 :       items: Provider.of<ProfileInfoState>(context, listen: false).contactList.contacts.where(widget.filter).map<DropdownMenuItem<String>>((ContactInfoState contact) {
      35           0 :         return DropdownMenuItem<String>(
      36           0 :           value: contact.onion,
      37           0 :           child: Text(contact.nickname, style: Provider.of<Settings>(context).scaleFonts(defaultTextStyle)),
      38             :         );
      39           0 :       }).toList(),
      40           0 :       onChanged: (String? newVal) {
      41           0 :         setState(() {
      42           0 :           this.selected = newVal;
      43             :         });
      44           0 :         widget.onChanged(newVal);
      45             :       },
      46             :     );
      47             :   }
      48             : }

Generated by: LCOV version 1.14