Skip to content

Commit

Permalink
added printing option
Browse files Browse the repository at this point in the history
  • Loading branch information
Sivan22 committed Jul 11, 2024
1 parent d143426 commit d4db2fb
Show file tree
Hide file tree
Showing 47 changed files with 88 additions and 62 deletions.
Binary file removed isolate.pdf
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions lib/main.dart → lib/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ class OtzariaApp extends StatelessWidget {
"he", "IL"), // OR Locale('ar', 'AE') OR Other RTL locales,
title: 'אוצריא',
theme: appModel.isDarkMode.value
? ThemeData.dark(useMaterial3: true).copyWith(
colorScheme: ColorScheme.fromSeed(
seedColor: appModel.seedColor.value))
? ThemeData.dark(useMaterial3: true)
: ThemeData(
visualDensity: VisualDensity.adaptivePlatformDensity,
fontFamily: 'Roboto',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class MainWindowScreenState extends State<MainWindowScreen>
));
return jsonDecode(data.body)["body"];
},
currentVersion: '0.1.7+7',
currentVersion: '0.1.8-dev.0',
updateChipBuilder: flatChip,

callback: (status) {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,14 @@ class _PdfBookViewrState extends State<PdfBookViewr>
pageNumber: widget.tab.pdfViewerController.pages.length),
),
IconButton(
icon: const Icon(Icons.print),
tooltip: 'הדפסה',
icon: const Icon(Icons.share),
tooltip: 'שיתוף',
onPressed: () async {
//display dialog to choose the pages to print

if (widget.tab.pdfViewerController.isReady) {
final pages = await showNumberOfPagesDialog(context);
if (pages != null) {
await Printing.layoutPdf(
onLayout: (PdfPageFormat format) async =>
File(widget.tab.book.path).readAsBytes(),
);
}
}
await Printing.sharePdf(
bytes: File(widget.tab.book.path).readAsBytesSync(),
);
}),
],
),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:io';
import 'dart:isolate';
import 'dart:math';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -38,7 +39,12 @@ class _PrintingScreenState extends State<PrintingScreen> {
void initState() {
super.initState();
startLine = widget.startLine;
endLine = startLine + 3;
endLine = startLine;
() async {
endLine = min(startLine + 3, (await widget.data).split('\n').length);
setState(() {});
}();

pdf = createPdf(format);
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,25 @@ class _MySettingsScreenState extends State<MySettingsScreen> {
titleTextStyle: TextStyle(fontSize: 25),
children: [
DropDownSettingsTile<String>(
selected: 'ctrl+b',
settingKey: 'key-shortcut-open-book-browser',
title: 'דפדוף בספריה',
selected: 'ctrl+o',
settingKey: 'key-shortcut-open-library-browser',
title: 'ספרייה',
values: shortcuctsList,
leading: Icon(Icons.library_books),
),
DropDownSettingsTile<String>(
selected: 'ctrl+r',
settingKey: 'key-shortcut-open-reading-screen',
title: 'עיון',
leading: Icon(Icons.menu_book_rounded),
values: shortcuctsList,
),
DropDownSettingsTile<String>(
selected: 'ctrl+q',
settingKey: 'key-shortcut-open-new-search',
title: 'חלון חיפוש חדש',
leading: Icon(Icons.search),
values: shortcuctsList,
leading: Icon(Icons.folder),
),
DropDownSettingsTile<String>(
selected: 'ctrl+w',
Expand All @@ -157,20 +171,6 @@ class _MySettingsScreenState extends State<MySettingsScreen> {
leading: Icon(Icons.close),
values: shortcuctsList,
),
DropDownSettingsTile<String>(
selected: 'ctrl+o',
settingKey: 'key-shortcut-open-book-search',
title: 'איתור ספר',
leading: Icon(Icons.library_books),
values: shortcuctsList,
),
DropDownSettingsTile<String>(
selected: 'ctrl+q',
settingKey: 'key-shortcut-open-new-search',
title: 'חלון חיפוש חדש',
leading: Icon(Icons.search),
values: shortcuctsList,
),
]),
const SettingsGroup(
title: 'הגדרות ממשק',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ String docxToText(Uint8List bytes, String title) {
final paragraphNodes = document.findAllElements('w:p');

for (final paragraph in paragraphNodes) {
final textNodes = paragraph.findAllElements('w:t');
var text = textNodes.map((node) => node.innerText).join();
final textNodes = paragraph.findAllElements('w:r');
var text = textNodes.map((node) {
final innerText = node.getElement('w:t')?.innerText ?? '';
//mark bold text
if (node.getElement('w:rPr')?.getElement('w:b') != null) {
return '<b>$innerText</b>';
}
return innerText;
}).join();

//mark up headings
var style = paragraph
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 24 additions & 6 deletions lib/widgets/grid_items.dart → lib/lib/widgets/grid_items.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,30 @@ class BookGridItem extends StatelessWidget {
Expanded(
child: ListTile(
mouseCursor: SystemMouseCursors.click,
title: Text(
showCategory
? '${book.category?.parent?.title}/${book.category?.title}/${book.title}'
: book.title,
style: const TextStyle(
fontSize: 14, fontWeight: FontWeight.bold),
title: RichText(
text: TextSpan(
children: [
TextSpan(
text: '${book.title} ',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.onSurface),
),
showCategory
? TextSpan(
text:
'(בתוך ${book.category?.parent?.title}/${book.category?.title})',
style: TextStyle(
fontSize: 11,
color: Theme.of(context)
.colorScheme
.onSurface
.withOpacity(0.7)),
)
: TextSpan()
],
),
),
subtitle: Text(
(book.author == "" || book.author == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,13 @@ class KeyboardShortcuts extends StatelessWidget {
return Consumer<AppModel>(
builder: (context, appModel, child) => CallbackShortcuts(
bindings: <ShortcutActivator, VoidCallback>{
shortcuts[
Settings.getValue<String>('key-shortcut-open-book-browser') !=
null
? Settings.getValue<String>('key-shortcut-open-book-browser')
: 'ctrl+b']!: () {
shortcuts[Settings.getValue<String>(
'key-shortcut-open-library-browser') !=
null
? Settings.getValue<String>('key-shortcut-open-library-browser')
: 'ctrl+o']!: () {
appModel.currentView.value = Screens.library;
appModel.bookLocatorFocusNode.requestFocus();
},
shortcuts[Settings.getValue<String>('key-shortcut-close-tab') != null
? Settings.getValue<String>('key-shortcut-close-tab')
Expand All @@ -111,12 +112,12 @@ class KeyboardShortcuts extends StatelessWidget {
: 'ctrl+x']!: () {
appModel.closeAllTabs();
},
shortcuts[
Settings.getValue<String>('key-shortcut-open-book-search') != null
? Settings.getValue<String>('key-shortcut-open-book-search')
: 'ctrl+o']!: () {
appModel.currentView.value = Screens.library;
appModel.bookLocatorFocusNode.requestFocus();
shortcuts[Settings.getValue<String>(
'key-shortcut-open-reading-screen') !=
null
? Settings.getValue<String>('key-shortcut-open-reading-screen')
: 'ctrl+r']!: () {
appModel.currentView.value = Screens.reading;
},
shortcuts[
Settings.getValue<String>('key-shortcut-open-new-search') != null
Expand Down
File renamed without changes.
6 changes: 1 addition & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ msix_config:
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 0.1.7
version: 0.1.8-dev.0

environment:
sdk: ">=3.2.6 <4.0.0"
Expand Down Expand Up @@ -73,7 +73,6 @@ dependencies:
printing:
pdf: ^3.10.8


flutter_launcher_icons:
android: true
ios: true
Expand Down Expand Up @@ -110,7 +109,6 @@ flutter:
assets:
- assets/metadata.json


# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware

Expand Down Expand Up @@ -150,5 +148,3 @@ flutter:
- family: NotoSerifHebrew
fonts:
- asset: fonts/NotoSerifHebrew-VariableFont_wdth,wght.ttf


14 changes: 10 additions & 4 deletions test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:otzaria/screens/main_window_screen.dart';

void main() {
testWidgets('showing app test', (WidgetTester tester) async {
testWidgets('finds main window', (WidgetTester tester) async {
await Settings.init();

// Build our app and trigger a frame.
await tester.pumpWidget(const MainWindowScreen());
await tester.pumpWidget(const MaterialApp(home: MainWindowScreen()));

// Verify that main window is shown
expect(find.byType(MainWindowScreen), findsOneWidget);

//verify that the navigation sidebar is visible
expect(find.byType(NavigationRail), findsOneWidget);

//if the oriention is landscape Verify that the navigation bar is shown
expect(find.byType(Scaffold), findsOneWidget);

});
}

0 comments on commit d4db2fb

Please sign in to comment.