import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:cwtch/views/addeditprofileview.dart'; import 'package:cwtch/views/contactsview.dart'; import 'package:cwtch/views/doublecolview.dart'; import 'package:cwtch/widgets/profileimage.dart'; import 'package:provider/provider.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import '../main.dart'; import '../model.dart'; import '../settings.dart'; class ProfileRow extends StatefulWidget { @override _ProfileRowState createState() => _ProfileRowState(); } class _ProfileRowState extends State { @override Widget build(BuildContext context) { var profile = Provider.of(context); return Card( clipBehavior: Clip.antiAlias, margin: EdgeInsets.all(0.0), child: InkWell( child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: const EdgeInsets.all(6.0), //border size child: ProfileImage( badgeCount: 0, badgeColor: Provider.of(context).theme.portraitProfileBadgeColor(), badgeTextColor: Provider.of(context).theme.portraitProfileBadgeTextColor(), diameter: 64.0, imagePath: profile.imagePath, border: profile.isOnline ? Provider.of(context).theme.portraitOnlineBorderColor() : Provider.of(context).theme.portraitOfflineBorderColor())), Expanded( child: Column( children: [ Text( profile.nickname, semanticsLabel: profile.nickname, style: Provider.of(context).biggerFont, softWrap: true, overflow: TextOverflow.ellipsis, ), Visibility( visible: !Provider.of(context).streamerMode, child: ExcludeSemantics( child: Text( profile.onion, softWrap: true, overflow: TextOverflow.ellipsis, ))) ], )), IconButton( enableFeedback: true, tooltip: AppLocalizations.of(context)!.editProfile + " " + profile.nickname, icon: Icon(Icons.create, color: Provider.of(context).current().mainTextColor()), onPressed: () { _pushAddEditProfile(onion: profile.onion, displayName: profile.nickname, profileImage: profile.imagePath, encrypted: profile.isEncrypted); }, ) ], ), onTap: () { setState(() { var appState = Provider.of(context, listen: false); appState.selectedProfile = profile.onion; appState.selectedConversation = null; _pushContactList(profile, appState.isLandscape(context)); //orientation == Orientation.landscape); }); }, )); } void _pushContactList(ProfileInfoState profile, bool isLandscape) { Navigator.of(context).push( MaterialPageRoute( settings: RouteSettings(name: "conversations"), builder: (BuildContext buildcontext) { return OrientationBuilder(builder: (orientationBuilderContext, orientation) { return MultiProvider( providers: [ ChangeNotifierProvider.value(value: profile), ChangeNotifierProvider.value(value: profile.contactList), ], builder: (innercontext, widget) { var appState = Provider.of(context); var settings = Provider.of(context); return settings.uiColumns(appState.isLandscape(innercontext)).length > 1 ? DoubleColumnView() : ContactsView(); }); }); }, ), ); } void _pushAddEditProfile({onion: "", displayName: "", profileImage: "", encrypted: true}) { Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) { return MultiProvider( providers: [ ChangeNotifierProvider( create: (_) => ProfileInfoState(onion: onion, nickname: displayName, imagePath: profileImage, encrypted: encrypted), ), ], builder: (context, widget) => AddEditProfileView(), ); }, )); } }