80 lines
2.6 KiB
Dart
80 lines
2.6 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/blocs/update_user_info_bloc/update_user_info_bloc.dart';
|
|
import 'package:prosappco/screens/profile/profile_screen.dart';
|
|
|
|
class GeneralDrawerHeader extends StatefulWidget {
|
|
const GeneralDrawerHeader({super.key});
|
|
|
|
@override
|
|
State<GeneralDrawerHeader> createState() => _GeneralDrawerHeaderState();
|
|
}
|
|
|
|
class _GeneralDrawerHeaderState extends State<GeneralDrawerHeader> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocListener<UpdateUserInfoBloc, UpdateUserInfoState>(
|
|
listener: (context, state) {
|
|
if (state is UploadPictureSuccess) {
|
|
setState(() {
|
|
context.read<MyUserBloc>().state.user!.picture = state.userImage;
|
|
});
|
|
}
|
|
},
|
|
child: ListTile(
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
CupertinoPageRoute(
|
|
builder: (BuildContext context) {
|
|
return const ProfileScreen();
|
|
},
|
|
),
|
|
);
|
|
},
|
|
title: Text(
|
|
context.read<MyUserBloc>().state.user!.name,
|
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
),
|
|
subtitle: Text(
|
|
context.read<MyUserBloc>().state.user!.email,
|
|
style: const TextStyle(fontSize: 12),
|
|
),
|
|
leading: context.read<MyUserBloc>().state.user!.picture == ""
|
|
? 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,
|
|
),
|
|
),
|
|
),
|
|
trailing: const Icon(Icons.keyboard_arrow_right, color: Colors.black),
|
|
contentPadding:
|
|
const EdgeInsets.symmetric(vertical: 10, horizontal: 15),
|
|
),
|
|
);
|
|
}
|
|
}
|