Refactors
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
// TODO this lays out long text lines on a newline after a uilink rather than soft wrapping it.
|
||||
import 'package:dartboard_resume/annotation_manager.dart';
|
||||
import 'package:dartboard_resume/models/document_text.dart';
|
||||
import 'package:dartboard_resume/models/theme.dart';
|
||||
import 'package:pdf/pdf.dart';
|
||||
import 'package:pdf/widgets.dart';
|
||||
|
||||
class AnnotatedText extends StatelessWidget {
|
||||
AnnotatedText({this.bulletString, required this.stringSections, this.style});
|
||||
|
||||
final String? bulletString;
|
||||
final List<DocumentTextLinkData> stringSections;
|
||||
final TextStyle? style;
|
||||
|
||||
@override
|
||||
Widget build(Context context) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(bulletString == null ? '' : '$bulletString ', style: style),
|
||||
SizedBox(
|
||||
width: DocumentTheme.width - DocumentTheme.margin * 2 - 20.0,
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
...stringSections.map((s) {
|
||||
return TextSpan(text: s.text, style: style);
|
||||
// switch (s.type) {
|
||||
// case DartboardTextType.normal:
|
||||
// return [Text(s.text, style: style)];
|
||||
// case DartboardTextType.linkText:
|
||||
// final number = UrlFootnotes().add(url: s.url!);
|
||||
// return [
|
||||
// Text(s.text, style: style),
|
||||
// UrlLink(
|
||||
// destination: s.url!,
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.only(bottom: 4.0, left: 2.0, right: 2.0),
|
||||
// child: Text(
|
||||
// number.toString(),
|
||||
// style: style?.copyWith(color: PdfColors.blue, fontSize: 8),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ];
|
||||
// }
|
||||
}),
|
||||
...stringSections.map((s) {
|
||||
switch (s.type) {
|
||||
case DocumentTextType.normal:
|
||||
return null;
|
||||
case DocumentTextType.linkText:
|
||||
final number = AnnotationManager().add(url: s.url!);
|
||||
return TextSpan(
|
||||
text: ' [$number]',
|
||||
style: style?.copyWith(color: PdfColors.blue, fontSize: 8),
|
||||
);
|
||||
// return UrlLink(
|
||||
// destination: s.url!,
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.only(bottom: 4.0, left: 2.0, right: 2.0),
|
||||
// child: Text(
|
||||
// number.toString(),
|
||||
// style: style?.copyWith(color: PdfColors.blue, fontSize: 8),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
}).nonNulls,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import 'package:dartboard_resume/models/dartboard_data.dart';
|
||||
import 'package:dartboard_resume/models/dartboard_misc.dart';
|
||||
import 'package:dartboard_resume/widgets/annotated_text.dart';
|
||||
import 'package:pdf/pdf.dart';
|
||||
import 'package:pdf/widgets.dart';
|
||||
|
||||
class DartboardMiscEntry extends StatelessWidget {
|
||||
DartboardMiscEntry({required this.dartboardData, required this.misc});
|
||||
final DartboardData dartboardData;
|
||||
final DartboardMisc misc;
|
||||
|
||||
@override
|
||||
Widget build(Context context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
...misc.attributes.map(
|
||||
(a) => Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, bottom: 4.0),
|
||||
child: AnnotatedText(
|
||||
stringSections: a.toTextLinkList(),
|
||||
bulletString: dartboardData.dartboardTheme.bulletPoint,
|
||||
style: dartboardData.defaultTextStyle.apply(
|
||||
color: const PdfColorGrey(0.55),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 12),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import 'package:dartboard_resume/models/dartboard_data.dart';
|
||||
import 'package:dartboard_resume/models/experience.dart';
|
||||
import 'package:dartboard_resume/widgets/annotated_text.dart';
|
||||
import 'package:pdf/pdf.dart';
|
||||
import 'package:pdf/widgets.dart';
|
||||
|
||||
class ExperienceEntry extends StatelessWidget {
|
||||
ExperienceEntry({required this.dartboardData, required this.exp});
|
||||
final DartboardData dartboardData;
|
||||
final Experience exp;
|
||||
|
||||
@override
|
||||
Widget build(Context context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 4.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(exp.title, style: dartboardData.subheaderTextStyle.apply(color: const PdfColorGrey(0.3))),
|
||||
Container(height: 1, width: 60, color: const PdfColorGrey(0.75)),
|
||||
],
|
||||
),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
exp.range.toString(),
|
||||
style: dartboardData.defaultTextStyle.copyWith(color: const PdfColorGrey(0.42), fontSize: 8.0),
|
||||
),
|
||||
if (exp.location != null)
|
||||
Text(
|
||||
exp.location!,
|
||||
style: dartboardData.defaultTextStyle.copyWith(color: const PdfColorGrey(0.42), fontSize: 8.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 6),
|
||||
...exp.attributes.map(
|
||||
(a) => Padding(
|
||||
child: AnnotatedText(
|
||||
stringSections: a.toTextLinkList(),
|
||||
bulletString: dartboardData.dartboardTheme.bulletPoint,
|
||||
style: dartboardData.defaultTextStyle.apply(
|
||||
color: const PdfColorGrey(0.55),
|
||||
),
|
||||
),
|
||||
padding: const EdgeInsets.only(left: 8.0, bottom: 4.0),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 12),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import 'package:dartboard_resume/models/dartboard_data.dart';
|
||||
import 'package:pdf/widgets.dart';
|
||||
|
||||
class DartboardFooter extends StatelessWidget {
|
||||
DartboardFooter({required this.dartboardData, required this.renderNs});
|
||||
final int renderNs;
|
||||
final DartboardData dartboardData;
|
||||
|
||||
@override
|
||||
Widget build(Context context) {
|
||||
final double renderTimeMs = renderNs.toDouble() / 1000.0;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text(
|
||||
'This resume was generated with DartBoard Resume',
|
||||
style: dartboardData.defaultTextStyle.copyWith(fontSize: 10),
|
||||
),
|
||||
Text(
|
||||
'Rendered in ${renderTimeMs.toStringAsFixed(2)}ms',
|
||||
style: dartboardData.defaultTextStyle.copyWith(fontSize: 10),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import 'package:pdf/pdf.dart';
|
||||
import 'package:pdf/widgets.dart';
|
||||
|
||||
class Footnote extends StatelessWidget {
|
||||
Footnote({required this.number, required this.url, required this.style});
|
||||
|
||||
final String url;
|
||||
final int number;
|
||||
final TextStyle style;
|
||||
|
||||
@override
|
||||
Widget build(Context context) {
|
||||
return Row(
|
||||
children: [
|
||||
UrlLink(
|
||||
destination: url,
|
||||
child: Text(
|
||||
'[$number]',
|
||||
style: style.copyWith(color: PdfColors.blue, fontSize: 8),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
' $url',
|
||||
style: style.copyWith(fontSize: 8),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user