Skip to content

Commit

Permalink
chore: create dynamics widgets for AdvantagesSection and update code
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecastrosales committed Jan 19, 2023
1 parent 27fe1fe commit 16e449f
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
),
],
),
);
});
},
);
}
}
Original file line number Diff line number Diff line change
@@ -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,
),
),
],
),
],
);
}
}
Original file line number Diff line number Diff line change
@@ -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,
),
),
],
);
}
}
36 changes: 19 additions & 17 deletions lib/app/pages/home/widgets/sections/course_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions lib/app/pages/home/widgets/sections/course_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 16e449f

Please sign in to comment.