LCOV - code coverage report
Current view: top level - lib/widgets - profilerow.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 73 0.0 %
Date: 2024-02-26 20:09:01 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 Card(
      25             :         clipBehavior: Clip.antiAlias,
      26           0 :         margin: EdgeInsets.all(0.0),
      27           0 :         child: InkWell(
      28           0 :           child: Row(
      29             :             mainAxisAlignment: MainAxisAlignment.spaceBetween,
      30           0 :             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 + 10.0,
      48             :                       clipBehavior: Clip.hardEdge,
      49           0 :                       decoration: BoxDecoration(),
      50           0 :                       padding: EdgeInsets.all(5.0),
      51           0 :                       child: Text(
      52           0 :                         profile.nickname,
      53           0 :                         semanticsLabel: profile.nickname,
      54           0 :                         style: TextStyle(fontFamily: "Inter", fontSize: 18.0 * Provider.of<Settings>(context).fontScaling, fontWeight: FontWeight.bold),
      55             :                         softWrap: true,
      56             :                         overflow: TextOverflow.ellipsis,
      57             :                       )),
      58           0 :                   Visibility(
      59           0 :                       visible: !Provider.of<Settings>(context).streamerMode,
      60           0 :                       child: ExcludeSemantics(
      61           0 :                           child: Text(
      62           0 :                         profile.onion,
      63             :                         softWrap: true,
      64           0 :                         style: TextStyle(
      65             :                             fontFamily: "RobotoMono",
      66           0 :                             fontSize: 14.0 * Provider.of<Settings>(context).fontScaling,
      67           0 :                             color: ((Provider.of<Settings>(context).theme.mainTextColor) as Color).withOpacity(0.8)),
      68             :                         overflow: TextOverflow.ellipsis,
      69             :                       )))
      70             :                 ],
      71             :               )),
      72           0 :               IconButton(
      73             :                 enableFeedback: true,
      74           0 :                 splashRadius: Material.defaultSplashRadius / 2,
      75           0 :                 tooltip: AppLocalizations.of(context)!.editProfile + " " + profile.nickname,
      76           0 :                 icon: Icon(Icons.create, color: Provider.of<Settings>(context).current().mainTextColor),
      77           0 :                 onPressed: () {
      78           0 :                   _pushEditProfile(onion: profile.onion, displayName: profile.nickname, profileImage: profile.imagePath, encrypted: profile.isEncrypted);
      79             :                 },
      80             :               )
      81             :             ],
      82             :           ),
      83           0 :           onTap: () {
      84           0 :             setState(() {
      85           0 :               var appState = Provider.of<AppState>(context, listen: false);
      86           0 :               appState.selectedProfile = profile.onion;
      87           0 :               appState.selectedConversation = null;
      88             : 
      89           0 :               _pushContactList(profile, appState.isLandscape(context)); //orientation == Orientation.landscape);
      90             :             });
      91             :           },
      92             :         ));
      93             :   }
      94             : 
      95           0 :   void _pushContactList(ProfileInfoState profile, bool isLandscape) {
      96           0 :     Navigator.of(context).push(
      97           0 :       PageRouteBuilder(
      98           0 :         settings: RouteSettings(name: "conversations"),
      99           0 :         pageBuilder: (c, a1, a2) {
     100           0 :           return OrientationBuilder(builder: (orientationBuilderContext, orientation) {
     101           0 :             return MultiProvider(
     102           0 :                 providers: [ChangeNotifierProvider<ProfileInfoState>.value(value: profile), ChangeNotifierProvider<ContactListState>.value(value: profile.contactList)],
     103           0 :                 builder: (innercontext, widget) {
     104           0 :                   var appState = Provider.of<AppState>(context);
     105           0 :                   var settings = Provider.of<Settings>(context);
     106           0 :                   return settings.uiColumns(appState.isLandscape(innercontext)).length > 1 ? DoubleColumnView() : ContactsView();
     107             :                 });
     108             :           });
     109             :         },
     110           0 :         transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
     111           0 :         transitionDuration: Duration(milliseconds: 200),
     112             :       ),
     113             :     );
     114             :   }
     115             : 
     116           0 :   void _pushEditProfile({onion = "", displayName = "", profileImage = "", encrypted = true}) {
     117           0 :     Navigator.of(context).push(
     118           0 :       PageRouteBuilder(
     119           0 :         pageBuilder: (bcontext, a1, a2) {
     120           0 :           var profile = Provider.of<FlwtchState>(bcontext).profs.getProfile(onion)!;
     121           0 :           return MultiProvider(
     122           0 :             providers: [
     123           0 :               ChangeNotifierProvider<ProfileInfoState>.value(
     124             :                 value: profile,
     125             :               ),
     126             :             ],
     127           0 :             builder: (context, widget) => AddEditProfileView(),
     128             :           );
     129             :         },
     130           0 :         transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
     131           0 :         transitionDuration: Duration(milliseconds: 200),
     132             :       ),
     133             :     );
     134             :   }
     135             : }

Generated by: LCOV version 1.14