fix(profile): empty consultant education

This commit is contained in:
Alex
2024-12-19 18:11:04 +03:00
parent c964ad0019
commit c6a60eccd9

View File

@@ -192,10 +192,10 @@ class _ProfileScreenState extends State<ProfileScreen> {
), ),
_subscriptionsAndSubscribers(state), _subscriptionsAndSubscribers(state),
if (state.profile.badges.isNotEmpty) Padding(padding: EdgeInsets.only(bottom: 16), child: _badges(state)), if (state.profile.badges.isNotEmpty) Padding(padding: EdgeInsets.only(bottom: 16), child: _badges(state)),
if (state.profile.role == 'consultant') Padding(padding: EdgeInsets.only(bottom: 16), child: _socialLinks(state)), if (state.profile.role == 'consultant') _socialLinks(state),
if (state.profile.role == 'consultant') Padding(padding: EdgeInsets.only(bottom: 16), child: _education(state)), if (state.profile.role == 'consultant') _education(state),
if (state.profile.role == 'consultant') Padding(padding: EdgeInsets.only(bottom: 16), child: _diplomasAndCertificates(state)), if (state.profile.role == 'consultant') _diplomasAndCertificates(state),
if (state.profile.role == 'consultant') Padding(padding: EdgeInsets.only(bottom: 16), child: _activePlans(state)), if (state.profile.role == 'consultant') _activePlans(state),
_blogPosts(state), _blogPosts(state),
], ],
), ),
@@ -228,11 +228,11 @@ class _ProfileScreenState extends State<ProfileScreen> {
), ),
_subscriptionsAndSubscribers(state), _subscriptionsAndSubscribers(state),
if (state.profile.badges.isNotEmpty) Padding(padding: EdgeInsets.only(bottom: 16), child: _badges(state)), if (state.profile.badges.isNotEmpty) Padding(padding: EdgeInsets.only(bottom: 16), child: _badges(state)),
if (state.profile.role == 'consultant') Padding(padding: EdgeInsets.only(bottom: 16), child: _socialLinks(state)), if (state.profile.role == 'consultant') _socialLinks(state),
if (state.profile.role == 'consultant') Padding(padding: EdgeInsets.only(bottom: 16), child: _education(state)), if (state.profile.role == 'consultant') _education(state),
if (state.profile.role == 'consultant') Padding(padding: EdgeInsets.only(bottom: 16), child: _diplomasAndCertificates(state)), if (state.profile.role == 'consultant') _diplomasAndCertificates(state),
Padding(padding: EdgeInsets.only(bottom: 16), child: _charts()), Padding(padding: EdgeInsets.only(bottom: 16), child: _charts()),
if (state.profile.role == 'consultant') Padding(padding: EdgeInsets.only(bottom: 16), child: _activePlans(state)), if (state.profile.role == 'consultant') _activePlans(state),
_newBlogPostButton(), _newBlogPostButton(),
_blogPosts(state), _blogPosts(state),
], ],
@@ -249,6 +249,9 @@ class _ProfileScreenState extends State<ProfileScreen> {
bloc: plansCubit, bloc: plansCubit,
builder: (BuildContext context, PlansState state) { builder: (BuildContext context, PlansState state) {
if (state is PlansStateLoaded) { if (state is PlansStateLoaded) {
if (state.plansList.isEmpty) {
return const SizedBox.shrink();
}
return Column( return Column(
children: [ children: [
Padding( Padding(
@@ -366,57 +369,60 @@ class _ProfileScreenState extends State<ProfileScreen> {
} }
_diplomasAndCertificates(ProfileStateLoaded state) { _diplomasAndCertificates(ProfileStateLoaded state) {
if (state.profile.role != 'consultant') { if (state.profile.role != 'consultant' || state.profile.diplomasAndCertificates == null || state.profile.diplomasAndCertificates!.isEmpty) {
return const SizedBox.shrink(); return const SizedBox.shrink();
} }
return Column( return Padding(
children: [ padding: const EdgeInsets.only(bottom: 16),
Padding( child: Column(
padding: const EdgeInsets.symmetric(horizontal: 16), children: [
child: Row( Padding(
mainAxisAlignment: MainAxisAlignment.spaceBetween, padding: const EdgeInsets.symmetric(horizontal: 16),
children: [ child: Row(
Text( mainAxisAlignment: MainAxisAlignment.spaceBetween,
'Дипломы\nи сертификаты', children: [
style: TextStyle( Text(
color: Color(0xFF323F4B), 'Дипломы\nи сертификаты',
fontSize: 24, style: TextStyle(
height: 1, color: Color(0xFF323F4B),
fontWeight: FontWeight.w600, fontSize: 24,
height: 1,
fontWeight: FontWeight.w600,
),
), ),
), Text(
Text( widget.author == null ? 'Редактировать' : '',
widget.author == null ? 'Редактировать' : '', style: TextStyle(
style: TextStyle( color: Color(0xFF2F80ED),
color: Color(0xFF2F80ED), fontSize: 16,
fontSize: 16, fontWeight: FontWeight.w500,
fontWeight: FontWeight.w500, ),
), ),
), ],
], ),
), ),
), const SizedBox(height: 8),
const SizedBox(height: 8), Container(
Container( width: MediaQuery.of(context).size.width - 2,
width: MediaQuery.of(context).size.width - 2, padding: const EdgeInsets.symmetric(horizontal: 4),
padding: const EdgeInsets.symmetric(horizontal: 4), child: Material(
child: Material( color: Colors.white,
color: Colors.white, borderRadius: BorderRadius.circular(12),
borderRadius: BorderRadius.circular(12), child: SingleChildScrollView(
child: SingleChildScrollView( physics: const BouncingScrollPhysics(),
physics: const BouncingScrollPhysics(), scrollDirection: Axis.horizontal,
scrollDirection: Axis.horizontal, padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), child: Row(
child: Row( children: [
children: [ if (state.profile.diplomasAndCertificates != null)
if (state.profile.diplomasAndCertificates != null) ...state.profile.diplomasAndCertificates!.map((d) => _diplomaImage(baseUrl + '/storage/' + d.path)).toList(),
...state.profile.diplomasAndCertificates!.map((d) => _diplomaImage(baseUrl + '/storage/' + d.path)).toList(), ],
], ),
), ),
), ),
), ),
), ],
], ),
); );
} }
@@ -447,53 +453,56 @@ class _ProfileScreenState extends State<ProfileScreen> {
} }
_education(ProfileStateLoaded state) { _education(ProfileStateLoaded state) {
if (state.profile.role != 'consultant') { if (state.profile.role != 'consultant' || state.profile.educationResource?.completedCourses == null) {
return const SizedBox.shrink(); return const SizedBox.shrink();
} }
return Column( return Padding(
children: [ padding: const EdgeInsets.only(bottom: 16),
Padding( child: Column(
padding: const EdgeInsets.symmetric(horizontal: 16), children: [
child: Row( Padding(
mainAxisAlignment: MainAxisAlignment.spaceBetween, padding: const EdgeInsets.symmetric(horizontal: 16),
children: [ child: Row(
Text( mainAxisAlignment: MainAxisAlignment.spaceBetween,
'Образование', children: [
style: TextStyle( Text(
color: Color(0xFF323F4B), 'Образование',
fontSize: 24, style: TextStyle(
fontWeight: FontWeight.w600, color: Color(0xFF323F4B),
fontSize: 24,
fontWeight: FontWeight.w600,
),
), ),
), Text(
Text( widget.author == null ? 'Редактировать' : '',
widget.author == null ? 'Редактировать' : '', style: TextStyle(
style: TextStyle( color: Color(0xFF2F80ED),
color: Color(0xFF2F80ED), fontSize: 16,
fontSize: 16, fontWeight: FontWeight.w500,
fontWeight: FontWeight.w500, ),
), ),
), ],
], ),
), ),
), const SizedBox(height: 8),
const SizedBox(height: 8), Padding(
Padding( padding: const EdgeInsets.symmetric(horizontal: 4),
padding: const EdgeInsets.symmetric(horizontal: 4), child: Material(
child: Material( color: Colors.white,
color: Colors.white, borderRadius: BorderRadius.circular(12),
borderRadius: BorderRadius.circular(12), child: Padding(
child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), child: Column(
child: Column( children: [
children: [ if (state.profile.educationResource?.completedCourses != null)
if (state.profile.educationResource?.completedCourses != null) ...state.profile.educationResource!.completedCourses!.map((c) => _educationBlock(c.values.first.title, c.values.first.date)).toList(),
...state.profile.educationResource!.completedCourses!.map((c) => _educationBlock(c.values.first.title, c.values.first.date)).toList(), ],
], ),
), ),
), ),
), ),
), ],
], ),
); );
} }
@@ -539,7 +548,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
return const SizedBox.shrink(); return const SizedBox.shrink();
} }
return Padding( return Padding(
padding: const EdgeInsets.symmetric(horizontal: 4), padding: const EdgeInsets.symmetric(horizontal: 4) + const EdgeInsets.only(bottom: 16),
child: Material( child: Material(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
@@ -556,17 +565,19 @@ class _ProfileScreenState extends State<ProfileScreen> {
); );
}, },
'assets/icons/vk.svg', 'assets/icons/vk.svg',
state.profile.educationResource?.vkLink == null ? true : false,
), ),
const SizedBox(width: 12), const SizedBox(width: 12),
_socialLinkButton( _socialLinkButton(
() { () {
launchUrl( launchUrl(
Uri.parse( Uri.parse(
state.profile.educationResource?.tgLink ?? '', state.profile.educationResource?.vkLink ?? '',
), ),
); );
}, },
'assets/icons/telegram.svg', 'assets/icons/telegram.svg',
state.profile.educationResource?.vkLink == null ? true : false,
), ),
const SizedBox(width: 12), const SizedBox(width: 12),
_socialLinkButton( _socialLinkButton(
@@ -578,6 +589,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
); );
}, },
'assets/icons/web.svg', 'assets/icons/web.svg',
state.profile.educationResource?.personalSiteLink == null ? true : false,
), ),
], ],
), ),
@@ -586,9 +598,9 @@ class _ProfileScreenState extends State<ProfileScreen> {
); );
} }
_socialLinkButton(Function() onTap, String icon) { _socialLinkButton(Function() onTap, String icon, bool disabled) {
return InkWell( return InkWell(
onTap: onTap, onTap: disabled ? null : onTap,
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
child: Ink( child: Ink(
width: MediaQuery.of(context).size.width / 3 - (56 / 3), width: MediaQuery.of(context).size.width / 3 - (56 / 3),
@@ -601,6 +613,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
child: SvgPicture.asset( child: SvgPicture.asset(
icon, icon,
width: 24, width: 24,
colorFilter: ColorFilter.mode(Colors.black12, BlendMode.srcIn),
), ),
), ),
), ),