Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
janheinrichmerker committed Apr 22, 2021
1 parent 47d195e commit 153a3f4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
8 changes: 3 additions & 5 deletions lib/model/note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ enum NoteState { Normal, Archived, Trashed }
enum NoteSort { Title, LastModified }

@immutable
/**
* Represents a note file.
*
* The file name is always in the form `<title>.<tags>.<state>.<extension>`.
*/
/// Represents a note file.
///
/// The file name is always in the form `<title>.<tags>.<state>.<extension>`.
class Note {
final File file;
final List<String> _basenameParts;
Expand Down
2 changes: 1 addition & 1 deletion lib/route/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class _MainScreenState extends State<MainScreen> {
onPressed: () {
final snackBar =
SnackBar(content: Text('Create new file.'));
Scaffold.of(context).showSnackBar(snackBar);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
},
label: Text('New draft'.toUpperCase()),
icon: Icon(TxtIcons.add),
Expand Down
6 changes: 3 additions & 3 deletions lib/route/themes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class _ColorSchemeCard extends StatelessWidget {
this.subtitle,
this.description,
this.icon,
});
}) : super(key: key);

_isThemeSelected(BuildContext context) {
return AppTheme.of(context).colorScheme == colorScheme;
Expand Down Expand Up @@ -108,7 +108,7 @@ class _ColorSchemeCard extends StatelessWidget {
padding: EdgeInsets.only(bottom: 16, left: 16, right: 16),
child: Text(
subtitle,
style: Theme.of(context).textTheme.subtitle,
style: Theme.of(context).textTheme.subtitle2,
),
),
);
Expand All @@ -119,7 +119,7 @@ class _ColorSchemeCard extends StatelessWidget {
padding: EdgeInsets.only(bottom: 16, left: 16, right: 16),
child: Text(
description,
style: Theme.of(context).textTheme.body1,
style: Theme.of(context).textTheme.bodyText2,
),
),
);
Expand Down
31 changes: 17 additions & 14 deletions lib/widget/stadium_border_notched_rectangle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,39 +50,42 @@ class StadiumBorderNotchedRectangle implements NotchedShape {
final double p2yA = sqrt(r * r - p2xA * p2xA);
final double p2yB = sqrt(r * r - p2xB * p2xB);

final List<Offset> p = List<Offset>(6);

// p0, p1, and p2 are the control points for segment A.
p[0] = Offset(a - s1, b);
p[1] = Offset(a, b);
final double cmp = b < 0 ? -1.0 : 1.0;
p[2] = cmp * p2yA > cmp * p2yB ? Offset(p2xA, p2yA) : Offset(p2xB, p2yB);
Offset p0 = Offset(a - s1, b);
Offset p1 = Offset(a, b);
double cmp = b < 0 ? -1.0 : 1.0;
Offset p2 = cmp * p2yA > cmp * p2yB ? Offset(p2xA, p2yA) : Offset(p2xB, p2yB);

// p3, p4, and p5 are the control points for segment B, which is a mirror
// of segment A around the y axis.
p[3] = Offset(-1.0 * p[2].dx, p[2].dy);
p[4] = Offset(-1.0 * p[1].dx, p[1].dy);
p[5] = Offset(-1.0 * p[0].dx, p[0].dy);
Offset p3 = Offset(-1.0 * p2.dx, p2.dy);
Offset p4 = Offset(-1.0 * p1.dx, p1.dy);
Offset p5 = Offset(-1.0 * p0.dx, p0.dy);

// translate all points back to the absolute coordinate system.
for (int i = 0; i < p.length; i += 1) p[i] += guest.center;
p0 += guest.center;
p1 += guest.center;
p2 += guest.center;
p3 += guest.center;
p4 += guest.center;
p5 += guest.center;

return Path()
..moveTo(host.left, host.top)
..lineTo(p[0].dx, p[0].dy)
..quadraticBezierTo(p[1].dx, p[1].dy, p[2].dx, p[2].dy)
..lineTo(p0.dx, p0.dy)
..quadraticBezierTo(p1.dx, p1.dy, p2.dx, p2.dy)
..arcToPoint(
guest.bottomLeft + Offset(guest.height / 2, 0),
radius: Radius.circular(guest.height / 2),
clockwise: false,
)
..lineTo(guest.right - guest.height / 2, guest.bottom)
..arcToPoint(
p[3],
p3,
radius: Radius.circular(guest.height / 2),
clockwise: false,
)
..quadraticBezierTo(p[4].dx, p[4].dy, p[5].dx, p[5].dy)
..quadraticBezierTo(p4.dx, p4.dy, p5.dx, p5.dy)
..lineTo(host.right, host.top)
..lineTo(host.right, host.bottom)
..lineTo(host.left, host.bottom)
Expand Down

0 comments on commit 153a3f4

Please sign in to comment.