Skip to content

Commit d2bcda1

Browse files
committed
Cleanup code
1 parent 2ec006a commit d2bcda1

5 files changed

Lines changed: 38 additions & 45 deletions

File tree

lib/frontpage/about_section.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ class AboutMeSection extends StatelessWidget {
4646
Widget build(BuildContext context) {
4747
final WindowSize windowSize = WindowSize.of(context);
4848

49-
return Container(
49+
return Padding(
5050
padding: windowSize.margin.add(EdgeInsets.symmetric(vertical: 32)),
51-
color: Theme.of(context).colorScheme.surfaceContainer,
5251
child: _buildBody(context),
5352
);
5453
}

lib/frontpage/contact_section.dart

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,12 @@ class ContactSection extends StatelessWidget {
4242
Widget build(BuildContext context) {
4343
final WindowSize windowSize = WindowSize.of(context);
4444

45-
return Container(
46-
color: Theme.of(context).colorScheme.surfaceContainer,
47-
child: Padding(
48-
padding: windowSize.margin.add(EdgeInsets.only(
49-
top: 32,
50-
bottom: 24,
51-
)),
52-
child: _buildContent(context),
53-
),
45+
return Padding(
46+
padding: windowSize.margin.add(EdgeInsets.only(
47+
top: 32,
48+
bottom: 24,
49+
)),
50+
child: _buildContent(context),
5451
);
5552
}
5653

lib/frontpage/design_principles_section.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ class DesignPrinciplesSection extends StatelessWidget {
5151
Widget _buildBody(BuildContext context) {
5252
switch (WindowSize.of(context)) {
5353
case WindowSize.compact:
54+
case WindowSize.medium:
5455
return Column(
5556
mainAxisAlignment: MainAxisAlignment.spaceAround,
5657
crossAxisAlignment: CrossAxisAlignment.stretch,
5758
spacing: 12,
5859
children: [
5960
_buildTitle(context),
60-
const SizedBox(height: 24),
61+
const SizedBox(height: 0), // Resolves to 24px due to spacing
6162
for (final principle in designPrinciples)
6263
_buildPrinciple(context, principle),
6364
],

lib/frontpage/frontpage.dart

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,7 @@ class _FrontpageState extends State<Frontpage> {
7171
duration: Duration(milliseconds: 400),
7272
curve: Curves.easeInOut,
7373
);
74-
}
75-
76-
Future<void> _onDestinationSelected(BuildContext context, int index) async {
77-
await scrollTo(sectionKeys[index]);
78-
selectedDestinationIndex.value = index;
74+
selectedDestinationIndex.value = sectionKeys.indexOf(key);
7975
}
8076

8177
@override
@@ -107,11 +103,17 @@ class _FrontpageState extends State<Frontpage> {
107103
},
108104
),
109105
),
110-
AboutMeSection(key: aboutMeSectionKey),
106+
Container(
107+
color: Theme.of(context).colorScheme.surfaceContainer,
108+
child: AboutMeSection(key: aboutMeSectionKey),
109+
),
111110
DesignPrinciplesSection(),
112111
TimelineSection(key: timelineSectionKey),
113112
ProjectsSection(key: projectsSectionKey),
114-
ContactSection(key: contactSectionKey),
113+
Container(
114+
color: Theme.of(context).colorScheme.surfaceContainer,
115+
child: ContactSection(key: contactSectionKey),
116+
),
115117
],
116118
),
117119
),
@@ -185,10 +187,7 @@ class _FrontpageState extends State<Frontpage> {
185187

186188
return TextButton.icon(
187189
onPressed: () {
188-
_onDestinationSelected(
189-
context,
190-
Frontpage.destinations.indexOf(destination),
191-
);
190+
scrollTo(sectionKeys[Frontpage.destinations.indexOf(destination)]);
192191
},
193192
style: TextButton.styleFrom(
194193
padding: padding,
@@ -209,8 +208,8 @@ class _FrontpageState extends State<Frontpage> {
209208
builder: (context, selectedIndex, child) {
210209
return NavigationDrawer(
211210
selectedIndex: selectedDestinationIndex.value,
212-
onDestinationSelected: (value) {
213-
_onDestinationSelected(context, value);
211+
onDestinationSelected: (index) {
212+
scrollTo(sectionKeys[index]);
214213
scaffoldKey.currentState?.closeDrawer();
215214
},
216215
children: [

lib/frontpage/title_section.dart

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,23 @@ class TitleSection extends StatelessWidget {
4949
Column(
5050
children: [
5151
Expanded(
52-
child: ConstrainedBox(
53-
constraints: BoxConstraints(),
54-
child: Row(
55-
mainAxisAlignment: MainAxisAlignment.center,
56-
children: [
57-
Flexible(
58-
child: _buildButterfly(context),
59-
),
60-
const SizedBox(width: 24),
61-
Column(
62-
mainAxisSize: MainAxisSize.min,
63-
children: <Widget>[
64-
_buildTitle(context),
65-
_buildSubtitle(context),
66-
const SizedBox(height: 32),
67-
_buildContactButton(context),
68-
],
69-
),
70-
],
71-
),
52+
child: Row(
53+
mainAxisAlignment: MainAxisAlignment.center,
54+
children: [
55+
Flexible(
56+
child: _buildButterfly(context),
57+
),
58+
const SizedBox(width: 24),
59+
Column(
60+
mainAxisSize: MainAxisSize.min,
61+
children: <Widget>[
62+
_buildTitle(context),
63+
_buildSubtitle(context),
64+
const SizedBox(height: 32),
65+
_buildContactButton(context),
66+
],
67+
),
68+
],
7269
),
7370
),
7471
_buildDownArrow(context),

0 commit comments

Comments
 (0)