2021-06-24 23:10:45 +00:00
|
|
|
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<ProfileRow> {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
var profile = Provider.of<ProfileInfoState>(context);
|
|
|
|
return Card(
|
|
|
|
clipBehavior: Clip.antiAlias,
|
2021-07-14 21:56:10 +00:00
|
|
|
margin: EdgeInsets.all(0.0),
|
2021-06-24 23:10:45 +00:00
|
|
|
child: InkWell(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Padding(
|
2021-07-14 21:56:10 +00:00
|
|
|
padding: const EdgeInsets.all(6.0), //border size
|
2021-06-24 23:10:45 +00:00
|
|
|
child: ProfileImage(
|
|
|
|
badgeCount: 0,
|
2021-06-30 20:59:52 +00:00
|
|
|
badgeColor: Provider.of<Settings>(context).theme.portraitProfileBadgeColor(),
|
|
|
|
badgeTextColor: Provider.of<Settings>(context).theme.portraitProfileBadgeTextColor(),
|
2021-06-24 23:10:45 +00:00
|
|
|
diameter: 64.0,
|
|
|
|
imagePath: profile.imagePath,
|
2021-06-30 20:59:52 +00:00
|
|
|
border: profile.isOnline ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor() : Provider.of<Settings>(context).theme.portraitOfflineBorderColor())),
|
2021-06-24 23:10:45 +00:00
|
|
|
Expanded(
|
|
|
|
child: Column(
|
2021-06-30 20:59:52 +00:00
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
profile.nickname,
|
|
|
|
semanticsLabel: profile.nickname,
|
|
|
|
style: Provider.of<FlwtchState>(context).biggerFont,
|
|
|
|
softWrap: true,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
),
|
2021-09-14 16:05:07 +00:00
|
|
|
Visibility(
|
|
|
|
visible: !Provider.of<Settings>(context).streamerMode,
|
|
|
|
child: ExcludeSemantics(
|
|
|
|
child: Text(
|
|
|
|
profile.onion,
|
|
|
|
softWrap: true,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
)))
|
2021-06-30 20:59:52 +00:00
|
|
|
],
|
|
|
|
)),
|
2021-06-24 23:10:45 +00:00
|
|
|
IconButton(
|
|
|
|
enableFeedback: true,
|
|
|
|
tooltip: AppLocalizations.of(context)!.editProfile + " " + profile.nickname,
|
|
|
|
icon: Icon(Icons.create, color: Provider.of<Settings>(context).current().mainTextColor()),
|
|
|
|
onPressed: () {
|
|
|
|
_pushAddEditProfile(onion: profile.onion, displayName: profile.nickname, profileImage: profile.imagePath, encrypted: profile.isEncrypted);
|
|
|
|
},
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
onTap: () {
|
|
|
|
setState(() {
|
|
|
|
var appState = Provider.of<AppState>(context, listen: false);
|
|
|
|
appState.selectedProfile = profile.onion;
|
|
|
|
appState.selectedConversation = null;
|
|
|
|
|
2021-06-30 20:59:52 +00:00
|
|
|
_pushContactList(profile, appState.isLandscape(context)); //orientation == Orientation.landscape);
|
2021-06-24 23:10:45 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
void _pushContactList(ProfileInfoState profile, bool isLandscape) {
|
|
|
|
Navigator.of(context).push(
|
|
|
|
MaterialPageRoute<void>(
|
|
|
|
settings: RouteSettings(name: "conversations"),
|
|
|
|
builder: (BuildContext buildcontext) {
|
2021-06-30 20:59:52 +00:00
|
|
|
return OrientationBuilder(builder: (orientationBuilderContext, orientation) {
|
|
|
|
return MultiProvider(
|
|
|
|
providers: [
|
|
|
|
ChangeNotifierProvider<ProfileInfoState>.value(value: profile),
|
|
|
|
ChangeNotifierProvider<ContactListState>.value(value: profile.contactList),
|
|
|
|
],
|
|
|
|
builder: (innercontext, widget) {
|
|
|
|
var appState = Provider.of<AppState>(context);
|
|
|
|
var settings = Provider.of<Settings>(context);
|
|
|
|
return settings.uiColumns(appState.isLandscape(innercontext)).length > 1 ? DoubleColumnView() : ContactsView();
|
|
|
|
});
|
2021-06-24 23:10:45 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _pushAddEditProfile({onion: "", displayName: "", profileImage: "", encrypted: true}) {
|
|
|
|
Navigator.of(context).push(MaterialPageRoute<void>(
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return MultiProvider(
|
|
|
|
providers: [
|
|
|
|
ChangeNotifierProvider<ProfileInfoState>(
|
|
|
|
create: (_) => ProfileInfoState(onion: onion, nickname: displayName, imagePath: profileImage, encrypted: encrypted),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
builder: (context, widget) => AddEditProfileView(),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|