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

Generated by: LCOV version 1.14