-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #336 from Ariemeth/rules_sheet
Adding rules sheet to the printed and PDF records
- Loading branch information
Showing
4 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import 'package:gearforce/models/roster/roster.dart'; | ||
import 'package:gearforce/models/rules/faction_rule.dart'; | ||
import 'package:pdf/widgets.dart' as pw; | ||
|
||
const double _headerTextSize = 12; | ||
const double _standardTextSize = 10; | ||
|
||
pw.Widget buildRulesSheet(pw.Font font, UnitRoster roster) { | ||
// Faction rules | ||
final List<(String, String)> factionRules = []; | ||
FactionRule.enabledRules(roster.rulesetNotifer.value.factionRules) | ||
.forEach((fr) { | ||
factionRules.add((fr.name, fr.description)); | ||
}); | ||
|
||
final List<(String, String)> subFactionRules = []; | ||
FactionRule.enabledRules(roster.rulesetNotifer.value.subFactionRules) | ||
.forEach((fr) { | ||
subFactionRules.add((fr.name, fr.description)); | ||
}); | ||
|
||
final sheet = pw.Column(children: [ | ||
_buildRuleTable(font, ['Faction Rule', 'Description'], factionRules), | ||
_buildRuleTable(font, ['Sub-Faction Rule', 'Description'], subFactionRules), | ||
]); | ||
|
||
return pw.Padding( | ||
padding: pw.EdgeInsets.only( | ||
left: 10.0, | ||
right: 10.0, | ||
top: 10.0, | ||
bottom: 10.0, | ||
), | ||
child: sheet, | ||
); | ||
} | ||
|
||
pw.Widget _buildRuleTable( | ||
pw.Font font, | ||
List<String> tableHeaders, | ||
List<(String, String)> rules, | ||
) { | ||
if (rules.isEmpty) { | ||
return pw.Container(); | ||
} | ||
var table = pw.TableHelper.fromTextArray( | ||
cellStyle: pw.TextStyle( | ||
font: font, | ||
fontSize: _standardTextSize, | ||
), | ||
columnWidths: { | ||
0: const pw.FixedColumnWidth(200.0), | ||
}, | ||
headers: tableHeaders, | ||
headerStyle: pw.TextStyle( | ||
font: font, | ||
fontSize: _headerTextSize, | ||
fontWeight: pw.FontWeight.bold, | ||
), | ||
data: List<List<String>>.generate( | ||
rules.length, | ||
(row) => List<String>.generate(tableHeaders.length, (col) { | ||
switch (col) { | ||
case 0: | ||
return rules[row].$1; | ||
case 1: | ||
return rules[row].$2; | ||
default: | ||
return ''; | ||
} | ||
}), | ||
), | ||
); | ||
return pw.Padding( | ||
padding: pw.EdgeInsets.only( | ||
bottom: 10.0, | ||
), | ||
child: table); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ import 'package:url_launcher/url_launcher_string.dart'; | |
const double _leftPanelWidth = 670.0; | ||
const double _titleHeight = 40.0; | ||
const double _menuTitleHeight = 50.0; | ||
const String _version = '0.100.1'; | ||
const String _version = '0.101.0'; | ||
const String _bugEmailAddress = '[email protected]'; | ||
const String _dp9URL = 'https://www.dp9.com/'; | ||
const String _sourceCodeURL = 'https://github.com/Ariemeth/gearforce-flutter'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters