82 lines
2.1 KiB
Dart
82 lines
2.1 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:prosappco/blocs/my_user_bloc/my_user_bloc.dart';
|
|
import 'package:prosappco/screens/profile/profile_screen.dart';
|
|
|
|
class GeneralDrawerHeader extends StatelessWidget {
|
|
const GeneralDrawerHeader({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final user = context.read<MyUserBloc>().state.user!;
|
|
return ListTile(
|
|
onTap: () {
|
|
// Navigator.pop(context);
|
|
Navigator.push(
|
|
context,
|
|
CupertinoPageRoute(
|
|
builder: (BuildContext context) {
|
|
return const ProfileScreen();
|
|
},
|
|
),
|
|
);
|
|
},
|
|
title: Text(
|
|
user.name ?? '',
|
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
),
|
|
subtitle: Text(
|
|
user.drawerLabel,
|
|
style: const TextStyle(fontSize: 12),
|
|
),
|
|
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 Hero(
|
|
tag: 'picture-profile',
|
|
child: 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,
|
|
);
|
|
}
|
|
}
|