From 906ebb4330344fcd1992e8c29639f3bb21227fee Mon Sep 17 00:00:00 2001 From: Felipe Date: Mon, 26 Feb 2024 18:15:06 -0500 Subject: [PATCH] hero --- lib/components/general_drawer_header.dart | 9 +- lib/screens/profile/profile_screen.dart | 207 +++++++++++----------- 2 files changed, 113 insertions(+), 103 deletions(-) diff --git a/lib/components/general_drawer_header.dart b/lib/components/general_drawer_header.dart index 952055d..d9b7374 100644 --- a/lib/components/general_drawer_header.dart +++ b/lib/components/general_drawer_header.dart @@ -12,7 +12,7 @@ class GeneralDrawerHeader extends StatelessWidget { final user = context.read().state.user!; return ListTile( onTap: () { - Navigator.pop(context); + // Navigator.pop(context); Navigator.push( context, CupertinoPageRoute( @@ -43,7 +43,12 @@ class GeneralDrawerHeader extends StatelessWidget { imageProvider = NetworkImage(pictureUrl); } - return pictureContainerWidget(imageProvider); + return Hero( + tag: 'picture-profile', + child: pictureContainerWidget( + imageProvider, + ), + ); } Widget pictureContainerWidget(ImageProvider? imageProvider) { diff --git a/lib/screens/profile/profile_screen.dart b/lib/screens/profile/profile_screen.dart index 7d7002f..318b4ed 100644 --- a/lib/screens/profile/profile_screen.dart +++ b/lib/screens/profile/profile_screen.dart @@ -68,114 +68,116 @@ class _ProfileScreenState extends State { }, label: 'Perfil', ), - body: BlocBuilder(builder: (context, state) { - if (state.status == MyUserStatus.success) { - _nameController.text = state.user!.name ?? ''; - _emailController.text = state.user!.email ?? ''; - _phoneController.text = state.user!.phone ?? ''; - _birthdayController.text = state.user!.birthday ?? ''; - _genderController.text = state.user!.gender ?? ''; + body: BlocBuilder( + builder: (context, state) { + if (state.status == MyUserStatus.success) { + _nameController.text = state.user!.name ?? ''; + _emailController.text = state.user!.email ?? ''; + _phoneController.text = state.user!.phone ?? ''; + _birthdayController.text = state.user!.birthday ?? ''; + _genderController.text = state.user!.gender ?? ''; - return SingleChildScrollView( - child: Padding( - padding: - const EdgeInsets.symmetric(horizontal: 40, vertical: 20), - child: Stack( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - pictureWidget(state, context), - const SizedBox(height: 20.0), - TextFormField( - controller: _nameController, - decoration: const InputDecoration( - labelText: 'Nombre', - prefixIcon: Icon(Icons.person), - hintText: 'Nombre (obligatorio)', - border: OutlineInputBorder( - borderRadius: BorderRadius.all( - Radius.circular(10.0), - )), - errorBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.red), + return SingleChildScrollView( + child: Padding( + padding: + const EdgeInsets.symmetric(horizontal: 40, vertical: 20), + child: Stack( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + pictureWidget(state, context), + const SizedBox(height: 20.0), + TextFormField( + controller: _nameController, + decoration: const InputDecoration( + labelText: 'Nombre', + prefixIcon: Icon(Icons.person), + hintText: 'Nombre (obligatorio)', + border: OutlineInputBorder( + borderRadius: BorderRadius.all( + Radius.circular(10.0), + )), + errorBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.red), + ), + focusedErrorBorder: OutlineInputBorder( + borderSide: + BorderSide(color: Colors.red, width: 2.0), + ), ), - focusedErrorBorder: OutlineInputBorder( - borderSide: - BorderSide(color: Colors.red, width: 2.0), + validator: (value) { + if (value == null || value.isEmpty) { + return 'Por favor, ingrese su nombre'; + } + return null; + }, + ), + const SizedBox(height: 20.0), + TextFormField( + controller: _emailController, + decoration: const InputDecoration( + labelText: 'Email', + prefixIcon: Icon(Icons.email_rounded), + hintText: 'Email', + border: OutlineInputBorder( + borderRadius: BorderRadius.all( + Radius.circular(10.0), + )), + errorBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.red), + ), + focusedErrorBorder: OutlineInputBorder( + borderSide: + BorderSide(color: Colors.red, width: 2.0), + ), ), ), - validator: (value) { - if (value == null || value.isEmpty) { - return 'Por favor, ingrese su nombre'; - } - return null; - }, - ), - const SizedBox(height: 20.0), - TextFormField( - controller: _emailController, - decoration: const InputDecoration( - labelText: 'Email', - prefixIcon: Icon(Icons.email_rounded), - hintText: 'Email', - border: OutlineInputBorder( - borderRadius: BorderRadius.all( - Radius.circular(10.0), - )), - errorBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.red), - ), - focusedErrorBorder: OutlineInputBorder( - borderSide: - BorderSide(color: Colors.red, width: 2.0), + const SizedBox(height: 20.0), + TextFormField( + controller: _phoneController, + decoration: const InputDecoration( + labelText: 'Número de Teléfono', + prefixIcon: Icon(Icons.phone_android_rounded), + hintText: '+57', + border: OutlineInputBorder( + borderRadius: BorderRadius.all( + Radius.circular(10.0), + )), + errorBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.red), + ), + focusedErrorBorder: OutlineInputBorder( + borderSide: + BorderSide(color: Colors.red, width: 2.0), + ), ), ), - ), - const SizedBox(height: 20.0), - TextFormField( - controller: _phoneController, - decoration: const InputDecoration( - labelText: 'Número de Teléfono', - prefixIcon: Icon(Icons.phone_android_rounded), - hintText: '+57', - border: OutlineInputBorder( - borderRadius: BorderRadius.all( - Radius.circular(10.0), - )), - errorBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.red), - ), - focusedErrorBorder: OutlineInputBorder( - borderSide: - BorderSide(color: Colors.red, width: 2.0), - ), + const SizedBox(height: 20.0), + BirthdayPicker( + onDateSelected: (birthDay) { + _birthdayController.text = + DateFormat('dd/MM/yyyy').format(birthDay); + }, + controller: _birthdayController, ), - ), - const SizedBox(height: 20.0), - BirthdayPicker( - onDateSelected: (birthDay) { - _birthdayController.text = - DateFormat('dd/MM/yyyy').format(birthDay); - }, - controller: _birthdayController, - ), - const SizedBox(height: 20.0), - GenderDropdown( - controller: _genderController, - ), - const SizedBox(height: 60.0), - saveButton(state, context), - ], - ), - ], + const SizedBox(height: 20.0), + GenderDropdown( + controller: _genderController, + ), + const SizedBox(height: 60.0), + saveButton(state, context), + ], + ), + ], + ), ), - ), - ); - } else { - return const Center(child: CircularProgressIndicator()); - } - }), + ); + } else { + return const Center(child: CircularProgressIndicator()); + } + }, + ), ), ); } @@ -261,7 +263,10 @@ class _ProfileScreenState extends State { }); } }, - child: pictureContainerWidget(imageProvider), + child: Hero( + tag: 'picture-profile', + child: pictureContainerWidget(imageProvider), + ), ); }