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-08-22 18:05: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: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             :         color: Colors.transparent,
      27           0 :         margin: EdgeInsets.all(0.0),
      28           0 :         child: InkWell(
      29           0 :           child: Row(
      30             :             mainAxisAlignment: MainAxisAlignment.spaceBetween,
      31           0 :             children: [
      32           0 :               Padding(
      33             :                   padding: const EdgeInsets.all(6.0), //border size
      34           0 :                   child: ProfileImage(
      35           0 :                       badgeCount: profile.unreadMessages,
      36           0 :                       badgeColor: Provider.of<Settings>(context).theme.portraitProfileBadgeColor,
      37           0 :                       badgeTextColor: Provider.of<Settings>(context).theme.portraitProfileBadgeTextColor,
      38           0 :                       disabled: !profile.enabled,
      39             :                       diameter: 64.0,
      40           0 :                       imagePath: Provider.of<Settings>(context).isExperimentEnabled(ImagePreviewsExperiment) ? profile.imagePath : profile.defaultImagePath,
      41           0 :                       border: profile.isOnline ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor : Provider.of<Settings>(context).theme.portraitOfflineBorderColor)),
      42           0 :               Expanded(
      43           0 :                   child: Column(
      44             :                 mainAxisAlignment: MainAxisAlignment.spaceBetween,
      45             :                 mainAxisSize: MainAxisSize.min,
      46           0 :                 children: [
      47           0 :                   Container(
      48           0 :                       height: 18.0 * Provider.of<Settings>(context).fontScaling + 18.0,
      49             :                       clipBehavior: Clip.hardEdge,
      50           0 :                       decoration: BoxDecoration(),
      51           0 :                       padding: EdgeInsets.all(5.0),
      52           0 :                       child: 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(
      60           0 :                       visible: !Provider.of<Settings>(context).streamerMode,
      61           0 :                       child: ExcludeSemantics(
      62           0 :                           child: Text(
      63           0 :                         profile.onion,
      64             :                         softWrap: true,
      65           0 :                         style: TextStyle(
      66             :                             fontFamily: "RobotoMono",
      67           0 :                             fontSize: 14.0 * Provider.of<Settings>(context).fontScaling,
      68           0 :                             color: ((Provider.of<Settings>(context).theme.mainTextColor) as Color).withOpacity(0.8)),
      69             :                         overflow: TextOverflow.ellipsis,
      70             :                       )))
      71             :                 ],
      72             :               )),
      73           0 :               IconButton(
      74             :                 enableFeedback: true,
      75           0 :                 splashRadius: Material.defaultSplashRadius / 2,
      76           0 :                 tooltip: AppLocalizations.of(context)!.editProfile + " " + profile.nickname,
      77           0 :                 icon: Icon(Icons.create, color: Provider.of<Settings>(context).current().mainTextColor),
      78           0 :                 onPressed: () {
      79           0 :                   _pushEditProfile(onion: profile.onion, displayName: profile.nickname, profileImage: profile.imagePath, encrypted: profile.isEncrypted);
      80             :                 },
      81             :               )
      82             :             ],
      83             :           ),
      84           0 :           onTap: () {
      85           0 :             setState(() {
      86           0 :               var appState = Provider.of<AppState>(context, listen: false);
      87           0 :               appState.selectedProfile = profile.onion;
      88           0 :               appState.selectedConversation = null;
      89             : 
      90           0 :               _pushContactList(profile, appState.isLandscape(context)); //orientation == Orientation.landscape);
      91             :             });
      92             :           },
      93             :         ));
      94             :   }
      95             : 
      96           0 :   void _pushContactList(ProfileInfoState profile, bool isLandscape) {
      97           0 :     Navigator.of(context).push(
      98           0 :       PageRouteBuilder(
      99           0 :         settings: RouteSettings(name: "conversations"),
     100           0 :         pageBuilder: (c, a1, a2) {
     101           0 :           return OrientationBuilder(builder: (orientationBuilderContext, orientation) {
     102           0 :             return MultiProvider(
     103           0 :                 providers: [ChangeNotifierProvider<ProfileInfoState>.value(value: profile), ChangeNotifierProvider<ContactListState>.value(value: profile.contactList)],
     104           0 :                 builder: (innercontext, widget) {
     105           0 :                   var appState = Provider.of<AppState>(context);
     106           0 :                   var settings = Provider.of<Settings>(context);
     107           0 :                   return settings.uiColumns(appState.isLandscape(innercontext)).length > 1 ? DoubleColumnView() : ContactsView();
     108             :                 });
     109             :           });
     110             :         },
     111           0 :         transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
     112           0 :         transitionDuration: Duration(milliseconds: 200),
     113             :       ),
     114             :     );
     115             :   }
     116             : 
     117           0 :   void _pushEditProfile({onion = "", displayName = "", profileImage = "", encrypted = true}) {
     118           0 :     Navigator.of(context).push(
     119           0 :       PageRouteBuilder(
     120           0 :         pageBuilder: (bcontext, a1, a2) {
     121           0 :           var profile = Provider.of<FlwtchState>(bcontext).profs.getProfile(onion)!;
     122           0 :           return MultiProvider(
     123           0 :             providers: [
     124           0 :               ChangeNotifierProvider<ProfileInfoState>.value(
     125             :                 value: profile,
     126             :               ),
     127             :             ],
     128           0 :             builder: (context, widget) => AddEditProfileView(),
     129             :           );
     130             :         },
     131           0 :         transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
     132           0 :         transitionDuration: Duration(milliseconds: 200),
     133             :       ),
     134             :     );
     135             :   }
     136             : }

Generated by: LCOV version 1.14