Skip to content

Commit

Permalink
fixed open daf yomi
Browse files Browse the repository at this point in the history
  • Loading branch information
Sivan22 committed Aug 14, 2024
1 parent 67d50cb commit 039fa7b
Show file tree
Hide file tree
Showing 11 changed files with 233 additions and 142 deletions.
7 changes: 5 additions & 2 deletions lib/models/app_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,11 @@ class AppModel with ChangeNotifier {
.map((t) => Bookmark(
ref: '',
book: t is PdfBookTab ? (t).book : (t as TextBookTab).book,
index:
t is PdfBookTab ? (t).pageNumber : (t as TextBookTab).index,
index: t is PdfBookTab
? (t).pdfViewerController.isReady
? (t).pdfViewerController.pageNumber!
: 1
: (t as TextBookTab).index,
commentatorsToShow:
t is TextBookTab ? t.commentatorsToShow.value : [],
))
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/library_browser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class _LibraryBrowserState extends State<LibraryBrowser>
),
DafYomi(
onDafYomiTap: (tractate, daf) {
openDafYomiBook(context, tractate, daf);
openDafYomiBook(context, tractate, ' $daf.');
},
)
],
Expand Down
187 changes: 95 additions & 92 deletions lib/screens/reading_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,105 +81,108 @@ class _ReadingScreenState extends State<ReadingScreen>
try {
return Scaffold(
appBar: AppBar(
title: TabBar(
controller: controller,
isScrollable: true,
tabAlignment: TabAlignment.center,
tabs: appModel.tabs
.map((tab) => Listener(
// close tab on middle mouse button click
onPointerDown: (PointerDownEvent event) {
if (event.buttons == 4) {
appModel.closeTab(tab);
}
},
child: ContextMenuRegion(
contextMenu: ContextMenu(
entries: [
MenuItem(
label: 'סגור',
onSelected: () =>
appModel.closeTab(tab),
),
MenuItem(
label: 'סגור הכל',
onSelected: () =>
appModel.closeAllTabs(),
),
MenuItem(
label: 'סגור את האחרים',
onSelected: () =>
appModel.closeOthers(tab),
),
MenuItem(
label: 'שיכפול',
onSelected: () =>
appModel.cloneTab(tab),
),
MenuItem.submenu(
label: 'רשימת הכרטיסיות ',
items: getMenuItems(
appModel.tabs, appModel),
)
],
),
child: Draggable<OpenedTab>(
axis: Axis.horizontal,
data: tab,
childWhenDragging: SizedBox.fromSize(
size: const Size.fromWidth(2)),
feedback: Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10)),
color: Colors.white),
child: Padding(
padding: const EdgeInsets.fromLTRB(
20, 10, 20, 15),
child: Text(
tab is SearchingTab
? '${tab.title}: ${tab.searcher.queryController.text}'
: tab.title,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
decoration: TextDecoration.none,
color:
Theme.of(context).primaryColor,
),
title: Container(
constraints: BoxConstraints(maxHeight: 50),
child: TabBar(
controller: controller,
isScrollable: true,
tabAlignment: TabAlignment.center,
tabs: appModel.tabs
.map((tab) => Listener(
// close tab on middle mouse button click
onPointerDown: (PointerDownEvent event) {
if (event.buttons == 4) {
appModel.closeTab(tab);
}
},
child: ContextMenuRegion(
contextMenu: ContextMenu(
entries: [
MenuItem(
label: 'סגור',
onSelected: () =>
appModel.closeTab(tab),
),
),
MenuItem(
label: 'סגור הכל',
onSelected: () =>
appModel.closeAllTabs(),
),
MenuItem(
label: 'סגור את האחרים',
onSelected: () =>
appModel.closeOthers(tab),
),
MenuItem(
label: 'שיכפול',
onSelected: () =>
appModel.cloneTab(tab),
),
MenuItem.submenu(
label: 'רשימת הכרטיסיות ',
items: getMenuItems(
appModel.tabs, appModel),
)
],
),
child: DragTarget<OpenedTab>(
onAcceptWithDetails: (draggedTab) {
if (draggedTab.data == tab) return;
appModel.moveTab(draggedTab.data,
appModel.tabs.indexOf(tab));
setState(() {});
},
builder: (context, candidateData,
rejectedData) =>
Tab(
child: Row(children: [
Text(
child: Draggable<OpenedTab>(
axis: Axis.horizontal,
data: tab,
childWhenDragging: SizedBox.fromSize(
size: const Size(0, 0)),
feedback: Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10)),
color: Colors.white),
child: Padding(
padding: const EdgeInsets.fromLTRB(
20, 10, 20, 15),
child: Text(
tab is SearchingTab
? '${tab.title}: ${tab.searcher.queryController.text}'
: tab.title,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
decoration: TextDecoration.none,
color: Theme.of(context)
.primaryColor,
),
),
IconButton(
onPressed: () {
appModel.closeTab(tab);
},
icon: const Icon(Icons.close,
size: 10))
]),
),
),
child: DragTarget<OpenedTab>(
onAcceptWithDetails: (draggedTab) {
if (draggedTab.data == tab) return;
appModel.moveTab(draggedTab.data,
appModel.tabs.indexOf(tab));
setState(() {});
},
builder: (context, candidateData,
rejectedData) =>
Tab(
child: Row(children: [
Text(
tab is SearchingTab
? '${tab.title}: ${tab.searcher.queryController.text}'
: tab.title,
),
IconButton(
onPressed: () {
appModel.closeTab(tab);
},
icon: const Icon(Icons.close,
size: 10))
]),
),
),
),
),
),
))
.toList(),
))
.toList(),
),
),
leading: IconButton(
icon: const Icon(Icons.add_to_queue),
Expand All @@ -196,14 +199,14 @@ class _ReadingScreenState extends State<ReadingScreen>
controller: _textFieldController,
decoration: const InputDecoration(),
),
actions: <Widget>[
actions: <Widget>[
TextButton(
child: const Text('ביטול'),
onPressed: () {
Navigator.pop(context, false);
},
),
TextButton(
TextButton(
child: const Text('אישור'),
onPressed: () {
Navigator.pop(context, true);
Expand Down
23 changes: 22 additions & 1 deletion lib/screens/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'package:file_picker/file_picker.dart';
import 'dart:io';
import 'package:otzaria/models/app_model.dart';
import 'package:provider/provider.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:package_info_plus/package_info_plus.dart';

class MySettingsScreen extends StatefulWidget {
const MySettingsScreen({
Expand Down Expand Up @@ -245,7 +247,26 @@ class _MySettingsScreenState extends State<MySettingsScreen> {
'קבלת עדכונים על גרסאות בדיקה, ייתכנו באגים וחוסר יציבות',
disabledLabel: 'קבלת עדכונים על גרסאות יציבות בלבד',
leading: Icon(Icons.bug_report),
)
),
FutureBuilder(
future: PackageInfo.fromPlatform(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return SimpleSettingsTile(
title: 'גרסה נוכחית',
subtitle: 'המתן..',
leading: Icon(Icons.info_rounded),
);
}
return Align(
alignment: Alignment.centerRight,
child: SimpleSettingsTile(
title: 'גרסה נוכחית',
subtitle: snapshot.data!.version,
leading: Icon(Icons.info_rounded),
),
);
})
],
)
],
Expand Down
29 changes: 25 additions & 4 deletions lib/screens/text_book_screen.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_context_menu/flutter_context_menu.dart';
import 'package:otzaria/models/app_model.dart';
import 'package:otzaria/screens/combined_book_screen.dart';
import 'package:otzaria/screens/printing_screen.dart';
import 'package:otzaria/screens/splited_view_screen.dart';
import 'package:otzaria/utils/daf_yomi_helper.dart';
import 'package:provider/provider.dart';
import 'package:otzaria/screens/text_book_search_screen.dart';
import 'dart:io';
Expand Down Expand Up @@ -53,7 +55,6 @@ class TextBookViewer extends StatefulWidget {
class _TextBookViewerState extends State<TextBookViewer>
with TickerProviderStateMixin {
final FocusNode textSearchFocusNode = FocusNode();

late TabController tabController;

@override
Expand All @@ -80,8 +81,20 @@ class _TextBookViewerState extends State<TextBookViewer>
builder: (context, snapshot) => snapshot.hasData
? Center(
child: SelectionArea(
child: Text(snapshot.data!,
style: const TextStyle(fontSize: 17)),
child: ContextMenuRegion(
contextMenu: ContextMenu(entries: [
MenuItem(
label: 'פתח קובץ PDF מקביל',
onSelected: () {
openPdfBookFromRef(
snapshot.data!.split(',').first,
snapshot.data!.split(',')[1],
context);
}),
]),
child: Text(snapshot.data!,
style: const TextStyle(fontSize: 17)),
),
),
)
: const SizedBox.shrink(),
Expand Down Expand Up @@ -307,6 +320,7 @@ class _TextBookViewerState extends State<TextBookViewer>
LogicalKeyboardKey.keyF): () {
widget.tab.showLeftPane.value = true;
tabController.index = 1;
textSearchFocusNode.requestFocus();
},
},
child: Focus(
Expand Down Expand Up @@ -421,7 +435,14 @@ class _TextBookViewerState extends State<TextBookViewer>
controller: tabController,
children: [
buildTocViewer(),
buildSearchView(),
CallbackShortcuts(bindings: <ShortcutActivator, VoidCallback>{
LogicalKeySet(LogicalKeyboardKey.control,
LogicalKeyboardKey.keyF): () {
widget.tab.showLeftPane.value = true;
tabController.index = 1;
textSearchFocusNode.requestFocus();
},
}, child: buildSearchView()),
buildCommentaryView(),
buildLinkView(),
],
Expand Down
Loading

0 comments on commit 039fa7b

Please sign in to comment.