Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 14 additions & 24 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
dart_code_metrics:
extends:
- recommended
rules:
- prefer-trailing-comma: false
- prefer-single-widget-per-file: false
- unnecessary-trailing-comma: false
- avoid-shadowing: false
- prefer-match-file-name: false
- no-empty-block: false
- avoid-unsafe-collection-methods: false
- avoid-redundant-else: false
- avoid-missing-controller: false
- prefer-correct-callback-field-name: false
6 changes: 2 additions & 4 deletions lib/src/constants/breakpoints.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ double horizontalPadding(double screenWidth) {
return 0;
} else if (screenWidth > Breakpoints.mobile) {
return 28;
} else {
return 20;
}
return 20;
}

double sliverHorizontalPadding(double screenWidth) {
if (screenWidth > Breakpoints.desktop) {
return (screenWidth - Breakpoints.desktop) / 2;
} else if (screenWidth > Breakpoints.mobile) {
return 28;
} else {
return 20;
}
return 20;
}
27 changes: 14 additions & 13 deletions lib/src/features/about_me/about_me.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AboutMe extends StatelessWidget {

@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
final screenWidth = MediaQuery.sizeOf(context).width;
return Center(
child: SizedBox(
width: Breakpoints.desktop.toDouble(),
Expand Down Expand Up @@ -50,12 +50,10 @@ class AboutMeContent extends StatelessWidget {

@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
if (screenWidth > Breakpoints.tablet) {
return const AboutMeContentDesktop();
} else {
return const AboutMeContentMobile();
}
final screenWidth = MediaQuery.sizeOf(context).width;
return screenWidth > Breakpoints.tablet
? const AboutMeContentDesktop()
: const AboutMeContentMobile();
}
}

Expand All @@ -64,7 +62,7 @@ class AboutMeContentDesktop extends StatelessWidget {

@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
final screenWidth = MediaQuery.sizeOf(context).width;
final fontSize = screenWidth > Breakpoints.tablet
? 36.0
: (screenWidth > 640 ? 27.0 : 24.0);
Expand Down Expand Up @@ -106,7 +104,7 @@ class AboutMeContentDesktop extends StatelessWidget {
.copyWith(color: AppColors.neutral2),
),
),
)
),
],
),
const SizedBox(height: 96),
Expand All @@ -123,7 +121,7 @@ class AboutMeContentDesktop extends StatelessWidget {
child: AboutParagraph2(),
),
],
)
),
],
);
}
Expand All @@ -134,7 +132,7 @@ class AboutMeContentMobile extends StatelessWidget {

@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
final screenWidth = MediaQuery.sizeOf(context).width;
final fontSize = screenWidth > Breakpoints.tablet
? 36.0
: (screenWidth > 640 ? 27.0 : 24.0);
Expand Down Expand Up @@ -197,8 +195,11 @@ Happy coding!
}

class AboutParagraph extends StatelessWidget {
const AboutParagraph(
{super.key, required this.heading, required this.content});
const AboutParagraph({
super.key,
required this.heading,
required this.content,
});
final String heading;
final String content;

Expand Down
81 changes: 45 additions & 36 deletions lib/src/features/app_header/app_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AppHeader extends StatelessWidget {

@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
final screenWidth = MediaQuery.sizeOf(context).width;
bool isWide = screenWidth > Breakpoints.tablet;
return Container(
color: AppColors.neutral7,
Expand All @@ -27,7 +27,7 @@ class DesktopNavigationLayout extends StatelessWidget {

@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
final screenWidth = MediaQuery.sizeOf(context).width;
bool isVeryWide = screenWidth > Breakpoints.desktop;
return SizedBox(
height: 64,
Expand Down Expand Up @@ -60,7 +60,15 @@ class MobileNavigationLayout extends StatefulWidget {
class _MobileNavigationLayoutState extends State<MobileNavigationLayout>
with SingleTickerProviderStateMixin {
late final _menuController = AnimationController(
vsync: this, duration: const Duration(milliseconds: 150));
vsync: this,
duration: const Duration(milliseconds: 150),
);

@override
void dispose() {
_menuController.dispose();
super.dispose();
}

void _toggleMenu() {
if (_menuController.isCompleted) {
Expand All @@ -73,40 +81,41 @@ class _MobileNavigationLayoutState extends State<MobileNavigationLayout>
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: _menuController,
builder: (context, _) {
final height =
64 + _menuController.value * MobileNavigationMenu.menuHeight;
return SizedBox(
height: height,
child: Column(
children: [
SizedBox(
height: 64,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(width: 28),
Assets.appLogo.image(),
const Spacer(),
NavigationIconButton(child: Assets.search.image()),
GestureDetector(
onTap: _toggleMenu,
child: AnimatedIcon(
icon: AnimatedIcons.menu_close,
progress: _menuController,
color: AppColors.neutral2,
),
animation: _menuController,
builder: (context, _) {
final height =
64 + _menuController.value * MobileNavigationMenu.menuHeight;
return SizedBox(
height: height,
child: Column(
children: [
SizedBox(
height: 64,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(width: 28),
Assets.appLogo.image(),
const Spacer(),
NavigationIconButton(child: Assets.search.image()),
GestureDetector(
onTap: _toggleMenu,
child: AnimatedIcon(
icon: AnimatedIcons.menu_close,
progress: _menuController,
color: AppColors.neutral2,
),
//NavigationIconButton(assetName: Constants.hamburgerMenu),
const SizedBox(width: 28),
],
),
),
//NavigationIconButton(assetName: Constants.hamburgerMenu),
const SizedBox(width: 28),
],
),
const Expanded(child: MobileNavigationMenu()),
],
),
);
});
),
const Expanded(child: MobileNavigationMenu()),
],
),
);
},
);
}
}
13 changes: 7 additions & 6 deletions lib/src/features/app_header/mobile_navigation_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MobileNavigationMenu extends StatelessWidget {
height: 64.0,
alignment: Alignment.center,
child: MobileToggleButton(onPressed: () {}),
)
),
],
),
);
Expand Down Expand Up @@ -78,11 +78,12 @@ class MobileToggleButton extends StatelessWidget {
children: [
Assets.toggleDay.image(),
const SizedBox(width: 12),
Text('Switch to light mode',
style: Theme.of(context)
.textTheme
.titleSmall!
.copyWith(color: Colors.white)),
Text(
'Switch to light mode',
style: Theme.of(context).textTheme.titleSmall!.copyWith(
color: Colors.white,
),
),
],
),
),
Expand Down
11 changes: 6 additions & 5 deletions lib/src/features/app_header/navigation_link.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ class NavigationLink extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: TextButton(
child: Text(text,
style: Theme.of(context)
.textTheme
.titleSmall!
.copyWith(color: Colors.white)),
child: Text(
text,
style: Theme.of(context).textTheme.titleSmall!.copyWith(
color: Colors.white,
),
),
onPressed: () {},
),
),
Expand Down
29 changes: 15 additions & 14 deletions lib/src/features/cards/border_mouse_hover.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,23 @@ class _BorderMouseHoverState extends State<BorderMouseHover>
animation: _controller,
builder: (context, _) {
return Container(
margin: const EdgeInsets.all(2),
margin: const EdgeInsets.all(2),
decoration: BoxDecoration(
color: Colors.transparent, // AppColors.neutral5,
border: Border.all(
color: AppColors.primary.withOpacity(_controller.value),
width: 2,
),
borderRadius: BorderRadius.circular(18),
),
child: DecoratedBox(
decoration: BoxDecoration(
color: Colors.transparent, // AppColors.neutral5,
border: Border.all(
color: AppColors.primary.withOpacity(_controller.value),
width: 2,
),
borderRadius: BorderRadius.circular(18),
color: AppColors.neutral6,
borderRadius: BorderRadius.circular(16),
),
child: DecoratedBox(
decoration: BoxDecoration(
color: AppColors.neutral6,
borderRadius: BorderRadius.circular(16),
),
child: widget.builder(context, _controller.value),
));
child: widget.builder(context, _controller.value),
),
);
},
),
);
Expand Down
25 changes: 12 additions & 13 deletions lib/src/features/cards/featured_tutorials.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class FeaturedTutorialsHeader extends StatelessWidget {

@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
final screenWidth = MediaQuery.sizeOf(context).width;
return Center(
child: SizedBox(
width: Breakpoints.desktop.toDouble(),
Expand Down Expand Up @@ -51,12 +51,13 @@ class FeaturedTutorialsContent extends StatelessWidget {

@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
final screenWidth = MediaQuery.sizeOf(context).width;
final crossAxisCount =
screenWidth >= Breakpoints.twoColLayoutMinWidth ? 2 : 1;
return SliverPadding(
padding: EdgeInsets.symmetric(
horizontal: sliverHorizontalPadding(screenWidth)),
horizontal: sliverHorizontalPadding(screenWidth),
),
sliver: SliverAlignedGrid.count(
crossAxisCount: crossAxisCount,
mainAxisSpacing: 24,
Expand All @@ -75,18 +76,16 @@ class FeaturedTutorialsFooter extends StatelessWidget {

@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
final screenWidth = MediaQuery.sizeOf(context).width;
if (screenWidth <= Breakpoints.twoColLayoutMinWidth) {
return const Column(
children: [
SizedBox(height: 40),
ExploreTutorialsButton(),
],
);
} else {
// TODO: return something more lightweight
return const SizedBox();
}
return const SizedBox.shrink();
}
}

Expand All @@ -97,12 +96,12 @@ class ExploreTutorialsButton extends StatelessWidget {
Widget build(BuildContext context) {
return ElevatedButton(
style: ElevatedButton.styleFrom(
foregroundColor: AppColors.primary7,
backgroundColor: AppColors.secondary,
splashFactory: NoSplash.splashFactory,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(6))),
foregroundColor: AppColors.primary7,
backgroundColor: AppColors.secondary,
splashFactory: NoSplash.splashFactory,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(6)),
),
child: Text(
'Explore More Tutorials →',
textAlign: TextAlign.center,
Expand Down
Loading