This commit is contained in:
Felipe
2024-02-16 20:43:51 -05:00
parent 159ffedc6e
commit 9e6f76e309
12 changed files with 391 additions and 263 deletions
+97
View File
@@ -0,0 +1,97 @@
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/components/general_drawer_header.dart';
import 'package:prosappco/components/general_drawer_item.dart';
class GeneralDrawer extends StatefulWidget {
const GeneralDrawer({super.key});
@override
State<GeneralDrawer> createState() => _GeneralDrawerState();
}
class _GeneralDrawerState extends State<GeneralDrawer> {
@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: Drawer(
backgroundColor: Theme.of(context).colorScheme.background,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const GeneralDrawerHeader(),
Divider(
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.1),
thickness: 0.5,
height: 1,
),
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
GeneralDrawerItem(
icon: Icons.person_outline,
label: 'Mi Perfil',
onTap: () {
Navigator.pop(context);
},
),
],
),
),
),
Divider(
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.1),
thickness: 0.5,
height: 1,
),
const SizedBox(height: 15),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.primary,
padding: const EdgeInsets.symmetric(vertical: 15),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
)),
child: const Text(
'Modo Profesional',
style: TextStyle(color: Colors.white, fontSize: 18),
),
),
),
const SizedBox(height: 15),
// Container(
// height: MediaQuery.of(context).size.height,
// color: Theme.of(context).colorScheme.background,
// child: ListView(
// children: [
// ListTile(
// onTap: () {
// context.read<SignInBloc>().add(const SignOutRequired());
// },
// title: const Text(
// 'Cerrar Sesión',
// ),
// )
// ],
// ),
// )
],
),
),
);
}
}
+79
View File
@@ -0,0 +1,79 @@
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),
),
);
}
}
+29
View File
@@ -0,0 +1,29 @@
import 'package:flutter/material.dart';
class GeneralDrawerItem extends StatelessWidget {
final String label;
final IconData icon;
final VoidCallback onTap;
const GeneralDrawerItem({
super.key,
required this.label,
required this.icon,
required this.onTap,
});
@override
Widget build(BuildContext context) {
return ListTile(
onTap: onTap,
leading: Icon(
icon,
color: Colors.black,
),
title: Text(
label,
style: const TextStyle(fontSize: 15),
),
);
}
}