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

Generated by: LCOV version 1.14