after rediense

This commit is contained in:
Felipe
2024-02-26 16:32:31 -05:00
parent a1e367bdf3
commit 11d9ee6d35
11 changed files with 256 additions and 223 deletions
+42 -33
View File
@@ -9,6 +9,7 @@ class GeneralDrawerHeader extends StatelessWidget {
@override
Widget build(BuildContext context) {
final user = context.read<MyUserBloc>().state.user!;
return ListTile(
onTap: () {
Navigator.pop(context);
@@ -22,46 +23,54 @@ class GeneralDrawerHeader extends StatelessWidget {
);
},
title: Text(
context.read<MyUserBloc>().state.user!.name ?? '',
user.name ?? '',
style: const TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Text(
context.read<MyUserBloc>().state.user!.email ??
context.read<MyUserBloc>().state.user!.phone ??
'',
user.drawerLabel,
style: const TextStyle(fontSize: 12),
),
leading: context.read<MyUserBloc>().state.user!.picture == "" ||
context.read<MyUserBloc>().state.user!.picture == null
? Container(
width: 80,
height: 80,
decoration: BoxDecoration(
color: Colors.grey.shade300,
shape: BoxShape.circle,
),
child: Icon(
CupertinoIcons.person,
color: Colors.grey.shade400,
size: 35,
),
)
: Container(
width: 60,
height: 60,
decoration: BoxDecoration(
color: Colors.grey,
shape: BoxShape.circle,
image: DecorationImage(
image: NetworkImage(
context.read<MyUserBloc>().state.user?.picture ?? '',
),
fit: BoxFit.cover,
),
),
),
leading: pictureWidget(user.picture, context),
trailing: const Icon(Icons.keyboard_arrow_right, color: Colors.black),
contentPadding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15),
);
}
Widget pictureWidget(String? pictureUrl, BuildContext context) {
ImageProvider<Object>? imageProvider;
if (pictureUrl != null && pictureUrl.isNotEmpty) {
imageProvider = NetworkImage(pictureUrl);
}
return pictureContainerWidget(imageProvider);
}
Widget pictureContainerWidget(ImageProvider<Object>? imageProvider) {
final image = imageProvider == null
? null
: DecorationImage(
image: imageProvider,
fit: BoxFit.contain,
);
final widget = image == null
? Icon(
CupertinoIcons.person,
color: Colors.grey.shade400,
size: 40,
)
: null;
return Container(
width: 60,
height: 60,
decoration: BoxDecoration(
color: Colors.grey.shade300,
shape: BoxShape.circle,
image: image,
),
child: widget,
);
}
}