diff --git a/lib/app/pages/home/widgets/sections/advantages_section/advantages_section.dart b/lib/app/pages/home/widgets/sections/advantages_section/advantages_section.dart index d16558c..de4491c 100644 --- a/lib/app/pages/home/widgets/sections/advantages_section/advantages_section.dart +++ b/lib/app/pages/home/widgets/sections/advantages_section/advantages_section.dart @@ -4,97 +4,53 @@ import 'package:fludemy/app/core/responsive/breakpoints.dart'; import 'package:fludemy/app/core/theme/tokens/app_colors.dart'; import 'package:fludemy/app/core/values/app_texts.dart'; +import 'advantages_section_horizontal.dart'; +import 'advantages_section_vertical.dart'; + class AdvantagesSection extends StatelessWidget { const AdvantagesSection({super.key}); @override Widget build(BuildContext context) { - // TODO: Refactor this code - in widget - Widget buildHorizontalAdvantage( - IconData iconData, - String title, - String subtitle, - ) { - return Row( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - iconData, - color: AppColors.lotion, - size: 50, - ), - const SizedBox(width: 8), - Column( - children: [ - Text( - title, - textAlign: TextAlign.center, - style: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.w800, - color: AppColors.lotion, - letterSpacing: 1.1, - ), - ), - Text( - subtitle, - textAlign: TextAlign.center, - style: const TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - color: AppColors.lotion, - letterSpacing: 1.2, - ), + return LayoutBuilder( + builder: (context, constraints) { + if (constraints.maxWidth >= Breakpoints.mobileBreakpoint) { + return Container( + padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 16), + decoration: const BoxDecoration( + border: Border( + bottom: BorderSide(color: AppColors.graniteGray), ), - ], - ), - ], - ); - } - - // TODO: Refactor this code - in widget - Widget buildVerticalAdvantage( - IconData iconData, - String title, - String subtitle, - ) { - return Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - iconData, - color: AppColors.lotion, - size: 50, - ), - const SizedBox(height: 8), - Text( - title, - textAlign: TextAlign.center, - style: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.w800, - color: AppColors.lotion, - letterSpacing: 1.1, ), - ), - Text( - subtitle, - textAlign: TextAlign.center, - style: const TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - color: AppColors.lotion, - letterSpacing: 1.2, + child: Wrap( + alignment: WrapAlignment.spaceEvenly, + runSpacing: 16, + spacing: 16, + children: const [ + AdvantagesSectionHorizontal( + iconData: Icons.connect_without_contact, + title: AppTexts.moreThan100kDevelopers, + subtitle: AppTexts.awesomeExclamation, + ), + AdvantagesSectionHorizontal( + iconData: Icons.card_membership, + title: AppTexts.certificateOfComplete, + subtitle: AppTexts.sensationalExclamation, + ), + AdvantagesSectionHorizontal( + iconData: Icons.verified, + title: AppTexts.sensationalExclamation, + subtitle: AppTexts.anywhereExclamation, + ), + ], ), - ), - ], - ); - } - - return LayoutBuilder(builder: (_, constraints) { - if (constraints.maxWidth >= Breakpoints.mobileBreakpoint) { + ); + } return Container( - padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 16), + padding: const EdgeInsets.symmetric( + vertical: 20, + horizontal: 16, + ), decoration: const BoxDecoration( border: Border( bottom: BorderSide(color: AppColors.graniteGray), @@ -103,57 +59,27 @@ class AdvantagesSection extends StatelessWidget { child: Wrap( alignment: WrapAlignment.spaceEvenly, runSpacing: 16, - spacing: 16, - children: [ - buildHorizontalAdvantage( - Icons.connect_without_contact, - AppTexts.moreThan100kDevelopers, - AppTexts.awesomeExclamation, + spacing: 32, + children: const [ + AdvantagesSectionVertical( + iconData: Icons.connect_without_contact, + title: AppTexts.moreThan100kDevelopers, + subtitle: AppTexts.awesomeExclamation, ), - buildHorizontalAdvantage( - Icons.card_membership, - AppTexts.certificateOfComplete, - AppTexts.sensationalExclamation, + AdvantagesSectionVertical( + iconData: Icons.card_membership, + title: AppTexts.certificateOfComplete, + subtitle: AppTexts.sensationalExclamation, ), - buildHorizontalAdvantage( - Icons.verified, - AppTexts.sensationalExclamation, - AppTexts.anywhereExclamation, + AdvantagesSectionVertical( + iconData: Icons.verified, + title: AppTexts.sensationalExclamation, + subtitle: AppTexts.anywhereExclamation, ), ], ), ); - } - return Container( - padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 16), - decoration: const BoxDecoration( - border: Border( - bottom: BorderSide(color: AppColors.graniteGray), - ), - ), - child: Wrap( - alignment: WrapAlignment.spaceEvenly, - runSpacing: 16, - spacing: 32, - children: [ - buildVerticalAdvantage( - Icons.connect_without_contact, - AppTexts.moreThan100kDevelopers, - AppTexts.awesomeExclamation, - ), - buildVerticalAdvantage( - Icons.card_membership, - AppTexts.certificateOfComplete, - AppTexts.sensationalExclamation, - ), - buildVerticalAdvantage( - Icons.verified, - AppTexts.sensationalExclamation, - AppTexts.anywhereExclamation, - ), - ], - ), - ); - }); + }, + ); } } diff --git a/lib/app/pages/home/widgets/sections/advantages_section/advantages_section_horizontal.dart b/lib/app/pages/home/widgets/sections/advantages_section/advantages_section_horizontal.dart new file mode 100644 index 0000000..77af006 --- /dev/null +++ b/lib/app/pages/home/widgets/sections/advantages_section/advantages_section_horizontal.dart @@ -0,0 +1,54 @@ +import 'package:flutter/material.dart'; + +import 'package:fludemy/app/core/theme/tokens/app_colors.dart'; + +class AdvantagesSectionHorizontal extends StatelessWidget { + const AdvantagesSectionHorizontal({ + super.key, + required this.iconData, + required this.title, + required this.subtitle, + }); + + final IconData iconData; + final String title, subtitle; + + @override + Widget build(BuildContext context) { + return Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + iconData, + color: AppColors.lotion, + size: 50, + ), + const SizedBox(width: 8), + Column( + children: [ + Text( + title, + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w800, + color: AppColors.lotion, + letterSpacing: 1.1, + ), + ), + Text( + subtitle, + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: AppColors.lotion, + letterSpacing: 1.2, + ), + ), + ], + ), + ], + ); + } +} diff --git a/lib/app/pages/home/widgets/sections/advantages_section/advantages_section_vertical.dart b/lib/app/pages/home/widgets/sections/advantages_section/advantages_section_vertical.dart new file mode 100644 index 0000000..97f5dfc --- /dev/null +++ b/lib/app/pages/home/widgets/sections/advantages_section/advantages_section_vertical.dart @@ -0,0 +1,50 @@ +import 'package:flutter/material.dart'; + +import 'package:fludemy/app/core/theme/tokens/app_colors.dart'; + +class AdvantagesSectionVertical extends StatelessWidget { + const AdvantagesSectionVertical({ + super.key, + required this.iconData, + required this.title, + required this.subtitle, + }); + + final IconData iconData; + final String title, subtitle; + + @override + Widget build(BuildContext context) { + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + iconData, + color: AppColors.lotion, + size: 50, + ), + const SizedBox(height: 8), + Text( + title, + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w800, + color: AppColors.lotion, + letterSpacing: 1.1, + ), + ), + Text( + subtitle, + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: AppColors.lotion, + letterSpacing: 1.2, + ), + ), + ], + ); + } +} diff --git a/lib/app/pages/home/widgets/sections/course_item.dart b/lib/app/pages/home/widgets/sections/course_item.dart index 2147e45..cc33630 100644 --- a/lib/app/pages/home/widgets/sections/course_item.dart +++ b/lib/app/pages/home/widgets/sections/course_item.dart @@ -20,27 +20,29 @@ class CourseItem extends StatelessWidget { ), const SizedBox(height: 4), Flexible( - child: LayoutBuilder(builder: (_, constraints) { - return const AutoSizeText( - AppTexts.responsivenessInTheFlutterPlatforms, - maxLines: 3, - presetFontSizes: [16, 14, 12], - overflowReplacement: Text( - AppTexts.responsiveness, + child: LayoutBuilder( + builder: (context, constraints) { + return const AutoSizeText( + AppTexts.responsivenessInTheFlutterPlatforms, + maxLines: 3, + presetFontSizes: [16, 14, 12], + overflowReplacement: Text( + AppTexts.responsiveness, + style: TextStyle( + fontWeight: FontWeight.w800, + color: AppColors.cultured, + fontSize: 16, + height: 2, + ), + ), style: TextStyle( fontWeight: FontWeight.w800, - color: AppColors.cultured, fontSize: 16, - height: 2, + color: AppColors.cultured, ), - ), - style: TextStyle( - fontWeight: FontWeight.w800, - fontSize: 16, - color: AppColors.cultured, - ), - ); - }), + ); + }, + ), ), const Text( AppTexts.danielCiolfiAndFelipeSales, diff --git a/lib/app/pages/home/widgets/sections/course_section.dart b/lib/app/pages/home/widgets/sections/course_section.dart index 4def4c8..801f444 100644 --- a/lib/app/pages/home/widgets/sections/course_section.dart +++ b/lib/app/pages/home/widgets/sections/course_section.dart @@ -10,7 +10,8 @@ class CourseSection extends StatelessWidget { @override Widget build(BuildContext context) { return LayoutBuilder( - builder: (_, constraints) { + builder: (context, constraints) { + final maxWidth = constraints.maxWidth; return GridView.builder( gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: 300, @@ -19,8 +20,7 @@ class CourseSection extends StatelessWidget { ), padding: EdgeInsets.symmetric( vertical: 16, - horizontal: - constraints.maxWidth >= Breakpoints.tabletMedium ? 0 : 16, + horizontal: maxWidth >= Breakpoints.tabletMedium ? 0 : 16, ), physics: const NeverScrollableScrollPhysics(), itemCount: 20,