Skip to content

Commit

Permalink
added shortcuts support
Browse files Browse the repository at this point in the history
  • Loading branch information
Sivan22 committed Mar 5, 2024
1 parent a5caad5 commit 8830ab6
Show file tree
Hide file tree
Showing 23 changed files with 507 additions and 284 deletions.
11 changes: 4 additions & 7 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
קיצורי דרך מקשים לפי בחירת המשתמש
כותרת של המיקום בספר
תמיכה בזום באמצעות מגע

להגדיל ולהקטין את הקטע של המפרשים
הוספת כפתור גלילה מועטת
קיצורי דרך מקשים
לסדר פוקוס
לתקן גלילה רציפה
לתקן באג מילים לאורך

תפריט ניווט להפוך לעץ
5. רשימת הספרים צריכה להיות פתוחה [לפחות רמה ראשית] כברירת מחד

לברר על קופסה לדיסק קשיח
5. רשימת הספרים צריכה להיות פתוחה [לפחות רמה ראשית] כברירת מחד


בסקריפט:
Expand Down
Binary file modified app_preferences.hive
Binary file not shown.
Binary file removed fonts/BonaNova-Regular.ttf
Binary file not shown.
Binary file removed fonts/DavidLibre-Regular.ttf
Binary file not shown.
Binary file added fonts/FrankRuehlCLM-Bold.ttf
Binary file not shown.
Binary file added fonts/FrankRuehlCLM-Medium.ttf
Binary file not shown.
Binary file removed fonts/FrankRuhlLibre-Regular.ttf
Binary file not shown.
Binary file removed fonts/FrankRuhlLibre-VariableFont_wght.ttf
Binary file not shown.
Binary file added fonts/KeterYG-Medium.ttf
Binary file not shown.
Binary file added fonts/ShofarRegular.ttf
Binary file not shown.
Binary file added fonts/TaameyAshkenaz-Medium.ttf
Binary file not shown.
Binary file added fonts/TaameyDavidCLM-Medium.ttf
Binary file not shown.
10 changes: 4 additions & 6 deletions lib/book_search_view.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import 'package:flutter/widgets.dart';
import 'package:universal_io/io.dart';
import 'package:flutter/material.dart';
import 'package:fuzzywuzzy/fuzzywuzzy.dart';
import 'package:otzaria/main_window_view.dart';
import 'package:flutter_settings_screen_ex/flutter_settings_screen_ex.dart';
import 'package:file_picker/file_picker.dart';
import 'package:permission_handler/permission_handler.dart';

class BookSearchScreen extends StatefulWidget {
final void Function(TabWindow tab) openFileCallback;
Expand All @@ -15,9 +11,9 @@ class BookSearchScreen extends StatefulWidget {

const BookSearchScreen(
{Key? key,
required this.focusNode,
required this.openFileCallback,
required this.closeLeftPaneCallback,
required this.focusNode,
required this.libraryPath})
: super(key: key);

Expand All @@ -27,9 +23,10 @@ class BookSearchScreen extends StatefulWidget {

class BookSearchScreenState extends State<BookSearchScreen> {
TextEditingController searchController = TextEditingController();
// get all files from the directory "אוצריא"

late final List<String> books;

@override
initState() {
super.initState();
books = Directory(widget.libraryPath)
Expand Down Expand Up @@ -110,6 +107,7 @@ class BookSearchScreenState extends State<BookSearchScreen> {
title: Text(book.split(Platform.pathSeparator).last),
onTap: () {
widget.openFileCallback(BookTabWindow(book, 0));
//close the sidebar only if it is a narrow screen
if (MediaQuery.of(context).orientation ==
Orientation.portrait) {
widget.closeLeftPaneCallback();
Expand Down
29 changes: 9 additions & 20 deletions lib/tree_view_selectable.dart → lib/book_tree_checklist.dart
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
import 'package:flutter/material.dart';
import 'dart:io';
import 'package:path/path.dart' as path;
import 'package:file_picker/file_picker.dart';
import 'package:flutter_settings_screen_ex/flutter_settings_screen_ex.dart';

class FileTreeViewScreen extends StatefulWidget {
final String libraryRootPath;
final List<String> checkedItems;

const FileTreeViewScreen({Key? key, required this.checkedItems})
const FileTreeViewScreen(
{Key? key, required this.checkedItems, required this.libraryRootPath})
: super(key: key);

@override
FileTreeViewScreenState createState() => FileTreeViewScreenState();
}

class FileTreeViewScreenState extends State<FileTreeViewScreen> {
late Future<Directory> selectedDirectory;
late Directory selectedDirectory;

@override
void initState() {
selectedDirectory = () async {
String? path = Settings.getValue<String>('key-library-path') ??
await FilePicker.platform.getDirectoryPath();

return Directory(path!);
}();

selectedDirectory = Directory(widget.libraryRootPath);
super.initState();
}

Expand All @@ -47,6 +41,7 @@ class FileTreeViewScreenState extends State<FileTreeViewScreen> {

Widget _buildTreeView(Directory directory, int level) {
return ExpansionTile(
initiallyExpanded: level == 0,
key: Key(directory.path), // Ensure unique keys for ExpansionTiles
title: Text(path.basename(directory.path)),
backgroundColor: level % 2 != 0 ? Colors.grey[200] : Colors.white,
Expand Down Expand Up @@ -93,15 +88,9 @@ class FileTreeViewScreenState extends State<FileTreeViewScreen> {
return Scaffold(
body: Column(
children: [
FutureBuilder(
future: selectedDirectory,
builder: (context, snapshot) => Expanded(
child: snapshot.hasData
? SingleChildScrollView(
child: _buildTreeView(snapshot.data!, 0))
: const CircularProgressIndicator(),
),
)
Expanded(
child: SingleChildScrollView(
child: _buildTreeView(selectedDirectory, 0)))
],
),
);
Expand Down
93 changes: 68 additions & 25 deletions lib/combined_book_commentary_view.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// a widget that takes an html strings array and displays it as a widget
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import 'package:flutter_settings_screen_ex/flutter_settings_screen_ex.dart';
import 'links_view.dart';
import 'dart:io';
import 'dart:isolate';
import 'main_window_view.dart';

class CombinedView extends StatefulWidget {
final List<String> data;
Expand All @@ -17,6 +18,7 @@ class CombinedView extends StatefulWidget {
final ScrollOffsetController scrollOffsetController;
final ItemPositionsListener itemPositionsListener;
final String searchQuery;
final Function(TabWindow) openBookCallback;

const CombinedView(
{super.key,
Expand All @@ -28,6 +30,7 @@ class CombinedView extends StatefulWidget {
required this.itemPositionsListener,
required this.searchQuery,
required this.links,
required this.openBookCallback,
required this.textSize});

@override
Expand All @@ -36,23 +39,21 @@ class CombinedView extends StatefulWidget {

class _CombinedViewState extends State<CombinedView>
with AutomaticKeepAliveClientMixin<CombinedView> {
static const Map<String, FontWeight> fontWeights = {
'normal': FontWeight.normal,
'bold': FontWeight.bold,
'w600': FontWeight.w600,
};
FocusNode focusNode = FocusNode();

late List<String> combinedData;
bool isExpanded = false;

@override
Widget build(BuildContext context) {
super.build(context);
return buildKeyboardListener();
//return buildSelectionArea();
}

KeyboardListener buildKeyboardListener() {
return KeyboardListener(
focusNode: FocusNode(),
autofocus: true,
focusNode: focusNode,
onKeyEvent: (KeyEvent event) {
if (event.logicalKey.keyLabel == 'Arrow Down') {
widget.scrollOffsetController.animateScroll(
Expand Down Expand Up @@ -89,8 +90,6 @@ class _CombinedViewState extends State<CombinedView>
fontSize: FontSize(widget.textSize),
fontFamily:
Settings.getValue('key-font-family') ?? 'candara',
fontWeight: fontWeights[
Settings.getValue('key-font-weight') ?? 'normal'],
textAlign: TextAlign.justify),
}),
children: [buildInnerListView(index)])));
Expand Down Expand Up @@ -118,19 +117,7 @@ class _CombinedViewState extends State<CombinedView>
.compareTo(widget.commentariesToShow.value.indexOf(
b.path2.split(Platform.pathSeparator).last)));

return thisLinks.isEmpty
? const SizedBox.shrink()
: SizedBox.fromSize(
size: const Size.fromHeight(250),
child: ListView.builder(
key: PageStorageKey(thisLinks[0].heRef),
itemCount: thisLinks.length,
itemBuilder: (context, smallindex) => ListTile(
title: Text(thisLinks[smallindex].heRef),
subtitle: buildCommentaryContent(
thisLinks, smallindex)),
),
);
return buildDynamicContent(thisLinks);
}
return const Center(
child: CircularProgressIndicator(),
Expand All @@ -139,6 +126,33 @@ class _CombinedViewState extends State<CombinedView>
});
}

Widget buildDynamicContent(List<Link> thisLinks) {
return thisLinks.isEmpty
? const SizedBox.shrink()
: DynamicContent(
fixedHeight: 200.0,
listView: ListView.builder(
key: PageStorageKey(thisLinks[0].heRef),
primary: true,
shrinkWrap: true,
itemCount: thisLinks.length,
itemBuilder: (context, smallindex) => ListTile(
title: Text(thisLinks[smallindex].heRef),
subtitle: buildCommentaryContent(thisLinks, smallindex),
onTap: () {
//open the reference in a new tab
widget.openBookCallback(BookTabWindow(
thisLinks[smallindex]
.path2
.replaceFirst('..\\..\\refs\\', ''),
thisLinks[smallindex].index2 - 1,
));
},
),
),
);
}

FutureBuilder<String> buildCommentaryContent(
List<Link> thisLinks, int smallindex) {
return FutureBuilder(
Expand All @@ -150,8 +164,6 @@ class _CombinedViewState extends State<CombinedView>
'body': Style(
fontSize: FontSize(widget.textSize / 1.2),
fontFamily: Settings.getValue('key-font-family') ?? 'candara',
fontWeight: fontWeights[
Settings.getValue('key-font-weight') ?? 'normal'],
textAlign: TextAlign.justify),
});
}
Expand Down Expand Up @@ -179,3 +191,34 @@ Future<String> getContent(String path, int index) async {
String line = lines[index - 1];
return line;
}

class DynamicContent extends StatefulWidget {
final ListView listView;
final double fixedHeight;
const DynamicContent(
{Key? key, required this.listView, required this.fixedHeight})
: super(key: key);

@override
State<DynamicContent> createState() => _DynamicContentState();
}

class _DynamicContentState extends State<DynamicContent> {
bool isExpanded = true;

@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
setState(() {
isExpanded = !isExpanded;
});
},
child: AnimatedContainer(
duration: const Duration(milliseconds: 500),
curve: Curves.ease,
height: isExpanded ? null : widget.fixedHeight,
child: widget.listView),
);
}
}
92 changes: 0 additions & 92 deletions lib/html_view.dart

This file was deleted.

Loading

0 comments on commit 8830ab6

Please sign in to comment.