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: 2024-11-29 02:34:16 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:flutter_gen/gen_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           0 :               Expanded(
      46           0 :                   child: Column(
      47             :                 mainAxisAlignment: MainAxisAlignment.spaceBetween,
      48             :                 mainAxisSize: MainAxisSize.min,
      49           0 :                 children: [
      50           0 :                   Container(
      51           0 :                       height: 18.0 * Provider.of<Settings>(context).fontScaling + 18.0,
      52             :                       clipBehavior: Clip.hardEdge,
      53           0 :                       decoration: BoxDecoration(),
      54           0 :                       padding: EdgeInsets.fromLTRB(0, 5, 0, 0),
      55           0 :                       child: Text(
      56           0 :                         profile.nickname,
      57           0 :                         semanticsLabel: profile.nickname,
      58           0 :                         style: TextStyle(fontFamily: "Inter", fontSize: 18.0 * Provider.of<Settings>(context).fontScaling, fontWeight: FontWeight.bold),
      59             :                         softWrap: true,
      60             :                         overflow: TextOverflow.ellipsis,
      61             :                       )),
      62           0 :                   Visibility(
      63           0 :                       visible: profile.getPrivateName().isNotEmpty,
      64           0 :                       child: Container(
      65           0 :                           height: 16.0 * Provider.of<Settings>(context).fontScaling + 16.0,
      66             :                           clipBehavior: Clip.hardEdge,
      67           0 :                           decoration: BoxDecoration(),
      68           0 :                           padding: EdgeInsets.fromLTRB(10, 0, 10, 0), // side padding because Container clip and text + italics has problems
      69           0 :                           child: Text(
      70           0 :                             profile.getPrivateName(),
      71           0 :                             semanticsLabel: profile.getPrivateName(),
      72           0 :                             style: TextStyle(fontFamily: "Inter", fontStyle: FontStyle.italic, fontSize: 16.0 * Provider.of<Settings>(context).fontScaling, fontWeight: FontWeight.bold),
      73             :                             softWrap: true,
      74             :                             overflow: TextOverflow.ellipsis,
      75             :                           ))),
      76           0 :                   Visibility(
      77           0 :                       visible: !Provider.of<Settings>(context).streamerMode,
      78           0 :                       child: Container(
      79             :                           clipBehavior: Clip.hardEdge,
      80           0 :                           decoration: BoxDecoration(),
      81           0 :                           height: 14.0 * Provider.of<Settings>(context).fontScaling + 14.0,
      82           0 :                           padding: EdgeInsets.fromLTRB(0, 0, 0, 0),
      83           0 :                           child: ExcludeSemantics(
      84           0 :                               child: Text(
      85           0 :                             profile.onion,
      86             :                             softWrap: true,
      87           0 :                             style: TextStyle(
      88             :                                 fontFamily: "RobotoMono",
      89           0 :                                 fontSize: 14.0 * Provider.of<Settings>(context).fontScaling,
      90           0 :                                 color: ((Provider.of<Settings>(context).theme.mainTextColor) as Color).withOpacity(0.8)),
      91             :                             overflow: TextOverflow.ellipsis,
      92             :                           ))))
      93             :                 ],
      94             :               )),
      95           0 :               IconButton(
      96             :                 enableFeedback: true,
      97           0 :                 splashRadius: Material.defaultSplashRadius / 2,
      98           0 :                 tooltip: AppLocalizations.of(context)!.editProfile + " " + profile.nickname,
      99           0 :                 icon: Icon(Icons.create, color: Provider.of<Settings>(context).current().mainTextColor),
     100           0 :                 onPressed: () {
     101           0 :                   _pushEditProfile(onion: profile.onion, displayName: profile.nickname, profileImage: profile.imagePath, encrypted: profile.isEncrypted);
     102             :                 },
     103             :               )
     104             :             ],
     105             :           ))),
     106           0 :       onTap: () {
     107           0 :         setState(() {
     108           0 :           var appState = Provider.of<AppState>(context, listen: false);
     109           0 :           appState.selectedProfile = profile.onion;
     110           0 :           appState.selectedConversation = null;
     111             : 
     112           0 :           _pushContactList(profile, appState.isLandscape(context)); //orientation == Orientation.landscape);
     113             :         });
     114             :       },
     115             :     );
     116             :   }
     117             : 
     118           0 :   void _pushContactList(ProfileInfoState profile, bool isLandscape) {
     119           0 :     Navigator.of(context).push(
     120           0 :       PageRouteBuilder(
     121           0 :         settings: RouteSettings(name: "conversations"),
     122           0 :         pageBuilder: (c, a1, a2) {
     123           0 :           return OrientationBuilder(builder: (orientationBuilderContext, orientation) {
     124           0 :             return MultiProvider(
     125           0 :                 providers: [
     126           0 :                   ChangeNotifierProvider<ProfileInfoState>.value(value: profile),
     127           0 :                   ChangeNotifierProvider<ContactListState>.value(value: profile.contactList),
     128           0 :                   ChangeNotifierProvider<SearchState>.value(value: profile.searchState)
     129             :                 ],
     130           0 :                 builder: (innercontext, widget) {
     131           0 :                   var appState = Provider.of<AppState>(context);
     132           0 :                   var settings = Provider.of<Settings>(context);
     133           0 :                   return settings.uiColumns(appState.isLandscape(innercontext)).length > 1 ? DoubleColumnView() : ContactsView();
     134             :                 });
     135             :           });
     136             :         },
     137           0 :         transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
     138           0 :         transitionDuration: Duration(milliseconds: 200),
     139             :       ),
     140             :     );
     141             :   }
     142             : 
     143           0 :   void _pushEditProfile({onion = "", displayName = "", profileImage = "", encrypted = true}) {
     144           0 :     Navigator.of(context).push(
     145           0 :       PageRouteBuilder(
     146           0 :         pageBuilder: (bcontext, a1, a2) {
     147           0 :           var profile = Provider.of<FlwtchState>(bcontext).profs.getProfile(onion)!;
     148           0 :           return MultiProvider(
     149           0 :             providers: [
     150           0 :               ChangeNotifierProvider<ProfileInfoState>.value(
     151             :                 value: profile,
     152             :               ),
     153             :             ],
     154           0 :             builder: (context, widget) => AddEditProfileView(),
     155             :           );
     156             :         },
     157           0 :         transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
     158           0 :         transitionDuration: Duration(milliseconds: 200),
     159             :       ),
     160             :     );
     161             :   }
     162             : }

Generated by: LCOV version 1.14