8000 Add zebra stripped table functionality by ooguz · Pull Request #2 · ooguz/papyrus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add zebra stripped table functionality #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/app/modules/home/controllers/home_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class HomeController extends GetxController {
var paperSizeSelection = <bool>[true, false].obs;
final qrChecked = true.obs;
final ocrChecked = true.obs;
final zebraChecked = true.obs;
final currentStep = 0.obs;
final directoryToWrite = ".".obs;
late pw.Document pdf;
Expand All @@ -48,6 +49,9 @@ class HomeController extends GetxController {
super.onInit();
}

Function(bool?)? get zebra =>
ocrChecked.value ? (bool? value) => zebraChecked.value = value! : null;

Future<FileResult> filePicker() async {
FilePickerResult? result;
try {
Expand Down Expand Up @@ -210,6 +214,9 @@ class HomeController extends GetxController {
},
build: (pw.Context context) => [
pw.TableHelper.fromTextArray(
oddRowDecoration: zebraChecked.value
? pw.BoxDecoration(color: PdfColor.fromHex("#ededed"))
: null,
data: hashes,
border: pw.TableBorder.all(style: pw.BorderStyle.none),
cellStyle: pw.TextStyle(
Expand All @@ -219,7 +226,7 @@ class HomeController extends GetxController {
cellPadding: const pw.EdgeInsets.all(0),
headerStyle:
pw.TextStyle(font: pw.Font.ttf(fonts.courier.bold)),
)
),
]));
}
final file = File(path);
Expand Down Expand Up @@ -285,6 +292,7 @@ class HomeController extends GetxController {
ocrText: ocrChecked.value,
letterPaper: paperSizeSelection[1]);
} catch (e) {
debugPrint(e.toString());
Get.snackbar("Error", "PDF creation failed",
snackPosition: SnackPosition.BOTTOM);
loading.value = false;
Expand Down
9 changes: 9 additions & 0 deletions lib/app/modules/home/views/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ class HomeView extends GetView<HomeController> {
subtitle: const Text(
"Recommended, this option adds OCR readable text with checksums for each line"),
),
ListTile(
leading: Checkbox(
value: controller.zebraChecked.value,
onChanged: controller.zebra),
enabled: controller.ocrChecked.value,
title: const Text('Zebra-stripped table'),
subtitle: const Text(
"Make OCR page lines zebra stripped. It makes lines easy to follow by eye but may cause OCR errors."),
),
],
),
],
Expand Down
0