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

          Line data    Source code
       1             : import 'package:cwtch/models/appstate.dart';
       2             : import 'package:cwtch/models/contactlist.dart';
       3             : import 'package:cwtch/models/profile.dart';
       4             : import 'package:cwtch/models/search.dart';
       5             : import 'package:flutter/material.dart';
       6             : import 'package:cwtch/views/addeditprofileview.dart';
       7             : import 'package:cwtch/views/contactsview.dart';
       8             : import 'package:cwtch/views/doublecolview.dart';
       9             : import 'package:cwtch/widgets/profileimage.dart';
      10             : import 'package:provider/provider.dart';
      11             : import 'package:cwtch/l10n/app_localizations.dart';
      12             : 
      13             : import '../main.dart';
      14             : import '../settings.dart';
      15             : 
      16             : class ProfileRow extends StatefulWidget {
      17           0 :   @override
      18           0 :   _ProfileRowState createState() => _ProfileRowState();
      19             : }
      20             : 
      21             : class _ProfileRowState extends State<ProfileRow> {
      22           0 :   @override
      23             :   Widget build(BuildContext context) {
      24           0 :     var profile = Provider.of<ProfileInfoState>(context);
      25           0 :     return InkWell(
      26             :       enableFeedback: true,
      27             :       splashFactory: InkSplash.splashFactory,
      28           0 :       child: Ink(
      29             :         color: Colors.transparent,
      30           0 :         child: Container(
      31           0 :           child: Row(
      32             :             mainAxisAlignment: MainAxisAlignment.spaceBetween,
      33             :             crossAxisAlignment: CrossAxisAlignment.center,
      34           0 :             children: [
      35           0 :               Padding(
      36             :                 padding: const EdgeInsets.all(6.0), //border size
      37           0 :                 child: ProfileImage(
      38           0 :                   badgeCount: profile.unreadMessages,
      39           0 :                   badgeColor: Provider.of<Settings>(context).theme.portraitProfileBadgeColor,
      40           0 :                   badgeTextColor: Provider.of<Settings>(context).theme.portraitProfileBadgeTextColor,
      41           0 :                   disabled: !profile.enabled,
      42             :                   diameter: 64.0,
      43           0 :                   imagePath: Provider.of<Settings>(context).isExperimentEnabled(ImagePreviewsExperiment) ? profile.imagePath : profile.defaultImagePath,
      44           0 :                   border: profile.isOnline ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor : Provider.of<Settings>(context).theme.portraitOfflineBorderColor,
      45             :                 ),
      46             :               ),
      47           0 :               Expanded(
      48           0 :                 child: Column(
      49             :                   mainAxisAlignment: MainAxisAlignment.spaceBetween,
      50             :                   mainAxisSize: MainAxisSize.min,
      51           0 :                   children: [
      52           0 :                     Container(
      53           0 :                       height: 18.0 * Provider.of<Settings>(context).fontScaling + 18.0,
      54             :                       clipBehavior: Clip.hardEdge,
      55           0 :                       decoration: BoxDecoration(),
      56           0 :                       padding: EdgeInsets.fromLTRB(0, 5, 0, 0),
      57           0 :                       child: Text(
      58           0 :                         profile.nickname,
      59           0 :                         semanticsLabel: profile.nickname,
      60           0 :                         style: TextStyle(fontFamily: "Inter", fontSize: 18.0 * Provider.of<Settings>(context).fontScaling, fontWeight: FontWeight.bold),
      61             :                         softWrap: true,
      62             :                         overflow: TextOverflow.ellipsis,
      63             :                       ),
      64             :                     ),
      65           0 :                     Visibility(
      66           0 :                       visible: profile.getPrivateName().isNotEmpty,
      67           0 :                       child: Container(
      68           0 :                         height: 16.0 * Provider.of<Settings>(context).fontScaling + 16.0,
      69             :                         clipBehavior: Clip.hardEdge,
      70           0 :                         decoration: BoxDecoration(),
      71           0 :                         padding: EdgeInsets.fromLTRB(10, 0, 10, 0), // side padding because Container clip and text + italics has problems
      72           0 :                         child: Text(
      73           0 :                           profile.getPrivateName(),
      74           0 :                           semanticsLabel: profile.getPrivateName(),
      75           0 :                           style: TextStyle(fontFamily: "Inter", fontStyle: FontStyle.italic, fontSize: 16.0 * Provider.of<Settings>(context).fontScaling, fontWeight: FontWeight.bold),
      76             :                           softWrap: true,
      77             :                           overflow: TextOverflow.ellipsis,
      78             :                         ),
      79             :                       ),
      80             :                     ),
      81           0 :                     Visibility(
      82           0 :                       visible: !Provider.of<Settings>(context).streamerMode,
      83           0 :                       child: Container(
      84             :                         clipBehavior: Clip.hardEdge,
      85           0 :                         decoration: BoxDecoration(),
      86           0 :                         height: 14.0 * Provider.of<Settings>(context).fontScaling + 14.0,
      87           0 :                         padding: EdgeInsets.fromLTRB(0, 0, 0, 0),
      88           0 :                         child: ExcludeSemantics(
      89           0 :                           child: Text(
      90           0 :                             profile.onion,
      91             :                             softWrap: true,
      92           0 :                             style: TextStyle(
      93             :                               fontFamily: "RobotoMono",
      94           0 :                               fontSize: 14.0 * Provider.of<Settings>(context).fontScaling,
      95           0 :                               color: ((Provider.of<Settings>(context).theme.mainTextColor) as Color).withOpacity(0.8),
      96             :                             ),
      97             :                             overflow: TextOverflow.ellipsis,
      98             :                           ),
      99             :                         ),
     100             :                       ),
     101             :                     ),
     102             :                   ],
     103             :                 ),
     104             :               ),
     105           0 :               IconButton(
     106             :                 enableFeedback: true,
     107           0 :                 splashRadius: Material.defaultSplashRadius / 2,
     108           0 :                 tooltip: AppLocalizations.of(context)!.editProfile + " " + profile.nickname,
     109           0 :                 icon: Icon(Icons.create, color: Provider.of<Settings>(context).current().mainTextColor),
     110           0 :                 onPressed: () {
     111           0 :                   _pushEditProfile(onion: profile.onion, displayName: profile.nickname, profileImage: profile.imagePath, encrypted: profile.isEncrypted);
     112             :                 },
     113             :               ),
     114             :             ],
     115             :           ),
     116             :         ),
     117             :       ),
     118           0 :       onTap: () {
     119           0 :         setState(() {
     120           0 :           var appState = Provider.of<AppState>(context, listen: false);
     121           0 :           appState.selectedProfile = profile.onion;
     122           0 :           appState.selectedConversation = null;
     123             : 
     124           0 :           _pushContactList(profile, appState.isLandscape(context)); //orientation == Orientation.landscape);
     125             :         });
     126             :       },
     127             :     );
     128             :   }
     129             : 
     130           0 :   void _pushContactList(ProfileInfoState profile, bool isLandscape) {
     131           0 :     Navigator.of(context).push(
     132           0 :       PageRouteBuilder(
     133           0 :         settings: RouteSettings(name: "conversations"),
     134           0 :         pageBuilder: (c, a1, a2) {
     135           0 :           return OrientationBuilder(
     136           0 :             builder: (orientationBuilderContext, orientation) {
     137           0 :               return MultiProvider(
     138           0 :                 providers: [
     139           0 :                   ChangeNotifierProvider<ProfileInfoState>.value(value: profile),
     140           0 :                   ChangeNotifierProvider<ContactListState>.value(value: profile.contactList),
     141           0 :                   ChangeNotifierProvider<SearchState>.value(value: profile.searchState),
     142             :                 ],
     143           0 :                 builder: (innercontext, widget) {
     144           0 :                   var appState = Provider.of<AppState>(context);
     145           0 :                   var settings = Provider.of<Settings>(context);
     146           0 :                   return settings.uiColumns(appState.isLandscape(innercontext)).length > 1 ? DoubleColumnView() : ContactsView();
     147             :                 },
     148             :               );
     149             :             },
     150             :           );
     151             :         },
     152           0 :         transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
     153           0 :         transitionDuration: Duration(milliseconds: 200),
     154             :       ),
     155             :     );
     156             :   }
     157             : 
     158           0 :   void _pushEditProfile({onion = "", displayName = "", profileImage = "", encrypted = true}) {
     159           0 :     Navigator.of(context).push(
     160           0 :       PageRouteBuilder(
     161           0 :         pageBuilder: (bcontext, a1, a2) {
     162           0 :           var profile = Provider.of<FlwtchState>(bcontext).profs.getProfile(onion)!;
     163           0 :           return MultiProvider(
     164           0 :             providers: [ChangeNotifierProvider<ProfileInfoState>.value(value: profile)],
     165           0 :             builder: (context, widget) => AddEditProfileView(),
     166             :           );
     167             :         },
     168           0 :         transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
     169           0 :         transitionDuration: Duration(milliseconds: 200),
     170             :       ),
     171             :     );
     172             :   }
     173             : }

Generated by: LCOV version 1.14