Added support for arbitrary lists and experience in markup
This commit is contained in:
+89
-35
@@ -19,10 +19,11 @@ Future<void> renderPdf(String tomlFilePath, {bool force = false}) async {
|
||||
stdout.writeln("Detected change:\nRendering with new dartboard data: $lastDartboardHash");
|
||||
final pdfFuture = Document()..addPage(_generatePdfPage(dartboardData: dartboardData, renderNs: 0));
|
||||
await pdfFuture.save();
|
||||
|
||||
final renderNs = DateTime.now().microsecondsSinceEpoch - start;
|
||||
|
||||
final pdf = Document();
|
||||
pdf.addPage(_generatePdfPage(dartboardData: dartboardData, renderNs: renderNs));
|
||||
|
||||
final file = File("example.pdf");
|
||||
final bytes = await pdf.save();
|
||||
|
||||
@@ -30,8 +31,10 @@ Future<void> renderPdf(String tomlFilePath, {bool force = false}) async {
|
||||
file.writeAsBytesSync(bytes);
|
||||
stdout.writeln('Reloading llpp...');
|
||||
Process.runSync('pkill', ['-HUP', 'llpp']);
|
||||
} catch (e) {
|
||||
UrlFootnotes().reset();
|
||||
} catch (e, st) {
|
||||
stderr.writeln('Encountered error: $e');
|
||||
stderr.writeln(st);
|
||||
try {
|
||||
stderr.writeln('Current toml map:\n${TomlDocument.loadSync(tomlFilePath).toMap()}');
|
||||
} catch (_) {
|
||||
@@ -41,6 +44,7 @@ Future<void> renderPdf(String tomlFilePath, {bool force = false}) async {
|
||||
}
|
||||
|
||||
Page _generatePdfPage({required DartboardData dartboardData, required int renderNs}) {
|
||||
UrlFootnotes().style = dartboardData.defaultTextStyle;
|
||||
final List<Widget> groupedExperienceList = dartboardData.groupedExperiences.entries.map<Widget>(
|
||||
(entry) {
|
||||
final String subsection = entry.key;
|
||||
@@ -57,17 +61,49 @@ Page _generatePdfPage({required DartboardData dartboardData, required int render
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(height: 2, width: 200, color: const PdfColorGrey(0.7)),
|
||||
Row(
|
||||
children: [
|
||||
Container(height: 2, width: 200, color: const PdfColorGrey(0.7)),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 3),
|
||||
...experiences.map(
|
||||
(DartboardExperience exp) => DartboardExperienceEntry(dartboardData: dartboardData, exp: exp),
|
||||
),
|
||||
DartboardFooter(dartboardData: dartboardData, renderNs: renderNs),
|
||||
],
|
||||
);
|
||||
},
|
||||
).toList();
|
||||
return Page(
|
||||
pageTheme: const PageTheme(pageFormat: PdfPageFormat.standard),
|
||||
final List<Widget> groupedMiscList = dartboardData.groupedMisc.entries.map<Widget>((entry) {
|
||||
final String subsection = entry.key;
|
||||
final List<DartboardMisc> miscs = entry.value;
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
subsection,
|
||||
style: dartboardData.subheaderTextStyle
|
||||
.merge(const TextStyle(fontSize: 18))
|
||||
.apply(color: const PdfColorGrey(0.2)),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Container(height: 2, width: 200, color: const PdfColorGrey(0.7)),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 3),
|
||||
...miscs.map(
|
||||
(DartboardMisc misc) => DartboardMiscEntry(dartboardData: dartboardData, misc: misc),
|
||||
),
|
||||
],
|
||||
);
|
||||
}).toList();
|
||||
return FullPage(
|
||||
pageTheme: PageTheme(
|
||||
buildBackground: (_) => Container(color: dartboardData.backgroundColor), pageFormat: PdfPageFormat.standard),
|
||||
build: (Context context) {
|
||||
return
|
||||
// FullPage(
|
||||
@@ -75,41 +111,59 @@ Page _generatePdfPage({required DartboardData dartboardData, required int render
|
||||
// child:
|
||||
Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 120,
|
||||
width: double.infinity,
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
left: 0,
|
||||
child: Container(
|
||||
height: 100,
|
||||
width: 100,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.contain,
|
||||
image: MemoryImage(
|
||||
File(dartboardData.imagePath).readAsBytesSync(),
|
||||
if (dartboardData.imagePath == null)
|
||||
Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Text(dartboardData.fullName, style: dartboardData.headerTextStyle),
|
||||
if (dartboardData.phoneNumber != null)
|
||||
Text(dartboardData.phoneNumber!, style: dartboardData.headerTextStyle),
|
||||
if (dartboardData.email != null) Text(dartboardData.email!, style: dartboardData.headerTextStyle),
|
||||
],
|
||||
),
|
||||
)
|
||||
else
|
||||
SizedBox(
|
||||
height: 100,
|
||||
width: double.infinity,
|
||||
child: Stack(
|
||||
children: [
|
||||
if (dartboardData.imagePath != null)
|
||||
Positioned(
|
||||
left: 0,
|
||||
child: Container(
|
||||
height: 100,
|
||||
width: 100,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.contain,
|
||||
image: MemoryImage(
|
||||
File(dartboardData.imagePath!).readAsBytesSync(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Text(dartboardData.fullName, style: dartboardData.headerTextStyle),
|
||||
if (dartboardData.phoneNumber != null)
|
||||
Text(dartboardData.phoneNumber!, style: dartboardData.headerTextStyle),
|
||||
if (dartboardData.email != null)
|
||||
Text(dartboardData.email!, style: dartboardData.headerTextStyle),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Text(dartboardData.fullName, style: dartboardData.headerTextStyle),
|
||||
Text(dartboardData.phoneNumber, style: dartboardData.headerTextStyle),
|
||||
Text(dartboardData.email, style: dartboardData.headerTextStyle),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(height: 20),
|
||||
...groupedExperienceList,
|
||||
...groupedMiscList,
|
||||
// this is quirky and gets evaluated before the actual footnotes get added up, so the original adding is done in the prerender
|
||||
...UrlFootnotes().footnotes,
|
||||
DartboardFooter(dartboardData: dartboardData, renderNs: renderNs),
|
||||
],
|
||||
// ),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user