Refactors
This commit is contained in:
+75
-66
@@ -1,7 +1,13 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dartboard_resume/dartboard_parser.dart';
|
||||
import 'package:dartboard_resume/dartboard_widgets.dart';
|
||||
import 'package:dartboard_resume/annotation_manager.dart';
|
||||
import 'package:dartboard_resume/models/dartboard_data.dart';
|
||||
import 'package:dartboard_resume/models/dartboard_misc.dart';
|
||||
import 'package:dartboard_resume/models/experience.dart';
|
||||
import 'package:dartboard_resume/models/theme.dart';
|
||||
import 'package:dartboard_resume/widgets/dartboard_misc_entry.dart';
|
||||
import 'package:dartboard_resume/widgets/experience_entry.dart';
|
||||
import 'package:dartboard_resume/widgets/footer.dart';
|
||||
import 'package:pdf/pdf.dart';
|
||||
import 'package:pdf/widgets.dart';
|
||||
import 'package:toml/toml.dart';
|
||||
@@ -29,9 +35,7 @@ Future<void> renderPdf(String tomlFilePath, {bool force = false}) async {
|
||||
|
||||
stdout.writeln('New pdf file saved.');
|
||||
file.writeAsBytesSync(bytes);
|
||||
stdout.writeln('Reloading llpp...');
|
||||
Process.runSync('pkill', ['-HUP', 'llpp']);
|
||||
UrlFootnotes().reset();
|
||||
AnnotationManager().reset();
|
||||
} catch (e, st) {
|
||||
stderr.writeln('Encountered error: $e');
|
||||
stderr.writeln(st);
|
||||
@@ -44,11 +48,11 @@ Future<void> renderPdf(String tomlFilePath, {bool force = false}) async {
|
||||
}
|
||||
|
||||
Page _generatePdfPage({required DartboardData dartboardData, required int renderNs}) {
|
||||
UrlFootnotes().style = dartboardData.defaultTextStyle;
|
||||
AnnotationManager().style = dartboardData.defaultTextStyle;
|
||||
final List<Widget> groupedExperienceList = dartboardData.groupedExperiences.entries.map<Widget>(
|
||||
(entry) {
|
||||
final String subsection = entry.key;
|
||||
final List<DartboardExperience> experiences = entry.value;
|
||||
final List<Experience> experiences = entry.value;
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
@@ -68,7 +72,7 @@ Page _generatePdfPage({required DartboardData dartboardData, required int render
|
||||
),
|
||||
SizedBox(height: 3),
|
||||
...experiences.map(
|
||||
(DartboardExperience exp) => DartboardExperienceEntry(dartboardData: dartboardData, exp: exp),
|
||||
(Experience exp) => ExperienceEntry(dartboardData: dartboardData, exp: exp),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -101,71 +105,76 @@ Page _generatePdfPage({required DartboardData dartboardData, required int render
|
||||
],
|
||||
);
|
||||
}).toList();
|
||||
return FullPage(
|
||||
return Page(
|
||||
pageTheme: PageTheme(
|
||||
buildBackground: (_) => Container(color: dartboardData.backgroundColor), pageFormat: PdfPageFormat.standard),
|
||||
buildBackground: (_) => Container(color: dartboardData.backgroundColor),
|
||||
pageFormat: PdfPageFormat.standard,
|
||||
margin: EdgeInsets.zero,
|
||||
),
|
||||
build: (Context context) {
|
||||
return
|
||||
// FullPage(
|
||||
// ignoreMargins: true,
|
||||
// child:
|
||||
Column(
|
||||
children: [
|
||||
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(),
|
||||
return FullPage(
|
||||
ignoreMargins: true,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(DocumentTheme.cm * 2),
|
||||
child: Column(
|
||||
children: [
|
||||
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),
|
||||
if (dartboardData.phoneNumber != null)
|
||||
Text(dartboardData.phoneNumber!, style: dartboardData.headerTextStyle),
|
||||
if (dartboardData.email != null)
|
||||
Text(dartboardData.email!, style: dartboardData.headerTextStyle),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
...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),
|
||||
],
|
||||
// ),
|
||||
),
|
||||
...groupedExperienceList,
|
||||
...groupedMiscList,
|
||||
// this is quirky and gets evaluated before the actual footnotes get added up, so the original adding is done in the prerender
|
||||
...AnnotationManager().footnotes,
|
||||
DartboardFooter(dartboardData: dartboardData, renderNs: renderNs),
|
||||
],
|
||||
// ),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user