Skip to content

Commit

Permalink
Minor visual fixes to Curriculum Vitae
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro-FA committed Oct 17, 2024
1 parent eb80681 commit 7ea688e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 36 deletions.
24 changes: 13 additions & 11 deletions lib/pages/cv.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dart:math';
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';

import '../utils.dart' show MaterialWindowSizeClass;
import '../utils.dart' show MaterialWindowClass;
import '../web_utils.dart' show downloadFile;
import '../widgets/base_page.dart';
import '../widgets/timeline.dart';
Expand All @@ -18,8 +18,8 @@ class CVPage extends StatelessWidget {
final textTheme = theme.textTheme;
final screenWidth = MediaQuery.of(context).size.width;
final double padding = max(
50,
(screenWidth - MaterialWindowSizeClass.large.minDP) / 2,
MaterialWindowClass.of(context) <= MaterialWindowClass.medium ? 25 : 50,
(screenWidth - MaterialWindowClass.large.minDP) / 2,
);

return BasePage(
Expand Down Expand Up @@ -174,15 +174,17 @@ class MyTimelineEvent implements TimelineEvent {
title,
style: textTheme.titleLarge?.copyWith(color: colorScheme.tertiary),
),
Text(
institution,
style: textTheme.titleMedium?.copyWith(color: colorScheme.tertiary),
Padding(
padding: const EdgeInsets.only(top: 8),
child: Text(
institution,
style:
textTheme.titleSmall?.copyWith(color: colorScheme.tertiary),
),
),
if (grade != null || awards != null || description != null)
const SizedBox(height: 12),
if (grade != null)
Padding(
padding: const EdgeInsets.symmetric(vertical: 6),
padding: const EdgeInsets.only(top: 20),
child: RichText(
text: TextSpan(
text: 'Average grade: ',
Expand All @@ -201,7 +203,7 @@ class MyTimelineEvent implements TimelineEvent {
),
if (awards != null)
Padding(
padding: const EdgeInsets.symmetric(vertical: 6),
padding: const EdgeInsets.only(top: 8),
child: RichText(
text: TextSpan(
text: 'Awards: ',
Expand All @@ -220,7 +222,7 @@ class MyTimelineEvent implements TimelineEvent {
),
if (description != null)
Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
padding: const EdgeInsets.only(top: 20),
child: Text(
description!,
style: textTheme.bodyLarge?.copyWith(height: 1.5),
Expand Down
36 changes: 18 additions & 18 deletions lib/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import 'package:url_launcher/url_launcher.dart';

/// An enumeration of the different window sizes according to the [Material
/// Design 3 guidelines](https://m3.material.io/foundations/layout/applying-layout/window-size-classes).
enum MaterialWindowSizeClass implements Comparable<MaterialWindowSizeClass> {
enum MaterialWindowClass implements Comparable<MaterialWindowClass> {
compact(minDP: 0, maxDP: 600, panes: 1),
medium(minDP: 600, maxDP: 840, panes: 1),
expanded(minDP: 840, maxDP: 1200, panes: 2),
large(minDP: 1200, maxDP: 1600, panes: 2),
extraLarge(minDP: 1600, maxDP: double.infinity, panes: 3);

const MaterialWindowSizeClass({
const MaterialWindowClass({
required this.minDP,
required this.maxDP,
required this.panes,
Expand All @@ -28,29 +28,29 @@ enum MaterialWindowSizeClass implements Comparable<MaterialWindowSizeClass> {
/// Recommended number of panes to divide the screen.
final int panes;

/// Returns the [MaterialWindowSizeClass] based on the screen width.
static MaterialWindowSizeClass of(BuildContext context) {
/// Returns the [MaterialWindowClass] based on the screen width.
static MaterialWindowClass of(BuildContext context) {
final width = MediaQuery.of(context).size.width;
if (width < MaterialWindowSizeClass.compact.maxDP) {
return MaterialWindowSizeClass.compact;
} else if (width < MaterialWindowSizeClass.medium.maxDP) {
return MaterialWindowSizeClass.medium;
} else if (width < MaterialWindowSizeClass.expanded.maxDP) {
return MaterialWindowSizeClass.expanded;
} else if (width < MaterialWindowSizeClass.large.maxDP) {
return MaterialWindowSizeClass.large;
if (width < MaterialWindowClass.compact.maxDP) {
return MaterialWindowClass.compact;
} else if (width < MaterialWindowClass.medium.maxDP) {
return MaterialWindowClass.medium;
} else if (width < MaterialWindowClass.expanded.maxDP) {
return MaterialWindowClass.expanded;
} else if (width < MaterialWindowClass.large.maxDP) {
return MaterialWindowClass.large;
} else {
return MaterialWindowSizeClass.extraLarge;
return MaterialWindowClass.extraLarge;
}
}

@override
int compareTo(MaterialWindowSizeClass other) => minDP.compareTo(other.minDP);
int compareTo(MaterialWindowClass other) => minDP.compareTo(other.minDP);

bool operator <(MaterialWindowSizeClass other) => minDP < other.minDP;
bool operator <=(MaterialWindowSizeClass other) => minDP <= other.minDP;
bool operator >(MaterialWindowSizeClass other) => minDP > other.minDP;
bool operator >=(MaterialWindowSizeClass other) => minDP >= other.minDP;
bool operator <(MaterialWindowClass other) => minDP < other.minDP;
bool operator <=(MaterialWindowClass other) => minDP <= other.minDP;
bool operator >(MaterialWindowClass other) => minDP > other.minDP;
bool operator >=(MaterialWindowClass other) => minDP >= other.minDP;
}

void openWebpage(String url) {
Expand Down
10 changes: 5 additions & 5 deletions lib/widgets/base_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ class BasePage extends StatelessWidget {
floatingActionButton: floatingActionButton,
drawer: _Drawer(menuRoutes: menuRoutes, socialMedia: socialMedia),
body: Stack(
alignment: MaterialWindowSizeClass.of(context) >=
MaterialWindowSizeClass.expanded
? AlignmentDirectional.centerEnd
: AlignmentDirectional.bottomCenter,
alignment:
MaterialWindowClass.of(context) >= MaterialWindowClass.expanded
? AlignmentDirectional.centerEnd
: AlignmentDirectional.bottomCenter,
children: [
CustomScrollView(
physics: const BouncingScrollPhysics(),
Expand Down Expand Up @@ -253,4 +253,4 @@ class _SocialMediaRail extends StatelessWidget {
}

bool _isWideScreen(BuildContext context) =>
MaterialWindowSizeClass.of(context) >= MaterialWindowSizeClass.expanded;
MaterialWindowClass.of(context) >= MaterialWindowClass.expanded;
4 changes: 2 additions & 2 deletions lib/widgets/timeline.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/widgets.dart';

import '../utils.dart' show MaterialWindowSizeClass;
import '../utils.dart' show MaterialWindowClass;

abstract class TimelineEvent {
Widget buildLeft(BuildContext context);
Expand Down Expand Up @@ -32,7 +32,7 @@ class Timeline extends StatelessWidget {

@override
Widget build(BuildContext context) =>
MaterialWindowSizeClass.of(context) >= MaterialWindowSizeClass.expanded
MaterialWindowClass.of(context) >= MaterialWindowClass.expanded
? _buildWide(context)
: _buildNarrow(context);

Expand Down

0 comments on commit 7ea688e

Please sign in to comment.