Skip to content
Open
12 changes: 10 additions & 2 deletions lib/migration/dao/repository/seforim_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1831,6 +1831,14 @@ class SeforimRepository {
/// @param sql The SQL query to execute
Future<void> executeRawQuery(String sql) async {
final db = await _database.database;
final normalizedSql = sql.trim().toUpperCase();
final isPragma = normalizedSql.startsWith('PRAGMA ');

if (isPragma && (Platform.isAndroid || Platform.isIOS)) {
await db.rawQuery(sql);
return;
}

await db.execute(sql);
}

Expand Down Expand Up @@ -2344,9 +2352,9 @@ class SeforimRepository {
Future<void> _executeRawQuery(String sql) async {
final db = await _database.database;
final normalizedSql = sql.trim().toUpperCase();
final isJournalModePragma = normalizedSql.startsWith('PRAGMA JOURNAL_MODE');
final isPragma = normalizedSql.startsWith('PRAGMA ');

if (isJournalModePragma && (Platform.isAndroid || Platform.isIOS)) {
if (isPragma && (Platform.isAndroid || Platform.isIOS)) {
await db.rawQuery(sql);
return;
}
Expand Down
156 changes: 124 additions & 32 deletions lib/navigation/custom_title_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ class CustomTitleBar extends StatefulWidget {
}

const double _kAppBarControlsWidth = 125.0;
const double _kAppBarControlsWidthRightAligned = 105.0;
const int _kActionButtonsCount = 1; // settings בלבד
const double _kAppBarControlsWidthRightAligned = 125.0;
const double _kActionButtonWidth = 56.0;
const double _kWindowCaptionButtonsWidth = 138.0;
const double _kWindowCaptionButtonWidth = 46.0;

/// סגנון משותף לכפתורי האייקון בשורת הכותרת
final ButtonStyle _kIconButtonStyle = IconButton.styleFrom(
minimumSize: const Size(32, 32),
minimumSize: const Size(28, 28),
padding: EdgeInsets.zero,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
Expand Down Expand Up @@ -217,20 +217,22 @@ class _CustomTitleBarState extends State<CustomTitleBar>
? _kAppBarControlsWidthRightAligned
: _kAppBarControlsWidth,
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: [
IconButton(
icon: const Icon(FluentIcons.history_24_regular, size: 18),
tooltip: 'הצג היסטוריה (${historyShortcut.toUpperCase()})',
onPressed: () => _showHistoryDialog(context),
style: _kIconButtonStyle,
),
const SizedBox(width: 4),
IconButton(
icon: const Icon(FluentIcons.bookmark_24_regular, size: 18),
tooltip: 'הצג סימניות (${bookmarksShortcut.toUpperCase()})',
onPressed: () => _showBookmarksDialog(context),
style: _kIconButtonStyle,
),
const SizedBox(width: 4),
IconButton(
icon: const Icon(FluentIcons.add_square_24_regular, size: 18),
tooltip: 'החלף שולחן עבודה (${workspaceShortcut.toUpperCase()})',
Expand All @@ -248,13 +250,13 @@ class _CustomTitleBarState extends State<CustomTitleBar>
navState.currentScreen == Screen.search) {
return _buildReadingTabs(context, settingsState);
} else if (navState.currentScreen == Screen.library) {
return _buildLibraryTitle(context);
return _buildLibraryTitle(context, settingsState);
} else {
return _buildStandardTitle(context, navState);
return _buildStandardTitle(context, navState, settingsState);
}
}

Widget _buildLibraryTitle(BuildContext context) {
Widget _buildLibraryTitle(BuildContext context, SettingsState settingsState) {
return BlocBuilder<LibraryBloc, LibraryState>(
buildWhen: (previous, current) =>
previous.currentCategory != current.currentCategory,
Expand All @@ -278,14 +280,22 @@ class _CustomTitleBarState extends State<CustomTitleBar>
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 4.0),
child: IconButton(
icon: const Icon(FluentIcons.settings_24_regular, size: 18),
tooltip: 'הגדרות ספרייה',
onPressed: () => showLibrarySettingsDialog(context),
style: _kIconButtonStyle.copyWith(
foregroundColor: WidgetStatePropertyAll(
Theme.of(context).colorScheme.onSurfaceVariant),
),
child: Row(
mainAxisSize: MainAxisSize.min,
textDirection: TextDirection.ltr,
children: [
if (!kIsWeb && Platform.isAndroid)
_buildAndroidFullscreenButton(context, settingsState),
IconButton(
icon: const Icon(FluentIcons.settings_24_regular, size: 18),
tooltip: 'הגדרות ספרייה',
onPressed: () => showLibrarySettingsDialog(context),
style: _kIconButtonStyle.copyWith(
foregroundColor: WidgetStatePropertyAll(
Theme.of(context).colorScheme.onSurfaceVariant),
),
),
],
),
),
],
Expand All @@ -294,7 +304,8 @@ class _CustomTitleBarState extends State<CustomTitleBar>
);
}

Widget _buildStandardTitle(BuildContext context, NavigationState navState) {
Widget _buildStandardTitle(BuildContext context, NavigationState navState,
SettingsState settingsState) {
String title = 'אוצריא';
switch (navState.currentScreen) {
case Screen.find:
Expand All @@ -310,17 +321,54 @@ class _CustomTitleBarState extends State<CustomTitleBar>
break;
}

return DragToMoveArea(
child: Center(
child: Text(
title,
style: Theme.of(context).textTheme.titleMedium,
return Row(
children: [
Expanded(
child: DragToMoveArea(
child: Center(
child: Text(
title,
style: Theme.of(context).textTheme.titleMedium,
),
),
),
),
if (!kIsWeb && Platform.isAndroid)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 4.0),
child: _buildAndroidFullscreenButton(context, settingsState),
),
],
);
}

Widget _buildAndroidFullscreenButton(
BuildContext context, SettingsState settingsState) {
return IconButton(
icon: Icon(
settingsState.isFullscreen
? FluentIcons.full_screen_minimize_24_regular
: FluentIcons.full_screen_maximize_24_regular,
size: 18,
),
tooltip: settingsState.isFullscreen ? 'צא ממסך מלא' : 'מסך מלא',
onPressed: () async {
final newFullscreenState = !settingsState.isFullscreen;
await FullscreenHelper.toggleFullscreen(
context,
newFullscreenState,
);
},
style: _kIconButtonStyle.copyWith(
foregroundColor: WidgetStatePropertyAll(
Theme.of(context).colorScheme.onSurfaceVariant,
),
),
);
}

Widget _buildReadingTabs(BuildContext context, SettingsState settingsState) {
final showAndroidFullscreenButton = !kIsWeb && Platform.isAndroid;
return BlocBuilder<TabsBloc, TabsState>(
builder: (context, state) {
if (!state.hasOpenTabs) {
Expand All @@ -341,13 +389,20 @@ class _CustomTitleBarState extends State<CustomTitleBar>
double rightSpacerWidth = 0;

if (!settingsState.alignTabsToRight) {
final showAndroidFullscreenButton = !kIsWeb && Platform.isAndroid;
bool showWindowControls = !kIsWeb &&
(Platform.isWindows || Platform.isLinux || Platform.isMacOS);
final int readingActionButtonsCount =
1 + (showAndroidFullscreenButton ? 1 : 0);
double windowControlsWidth = showWindowControls
? _kWindowCaptionButtonsWidth + _kWindowCaptionButtonWidth
: 0.0;
double actionButtonsWidth = _kAppBarControlsWidth;
double extraButtonsWidth = _kActionButtonsCount * _kActionButtonWidth;
double actionButtonsWidth = (settingsState.alignTabsToRight
? _kAppBarControlsWidthRightAligned
: _kAppBarControlsWidth) +
(showAndroidFullscreenButton ? _kActionButtonWidth : 0);
double extraButtonsWidth =
readingActionButtonsCount * _kActionButtonWidth;

double totalLeft = actionButtonsWidth;
double totalRight = extraButtonsWidth + windowControlsWidth;
Expand All @@ -357,6 +412,12 @@ class _CustomTitleBarState extends State<CustomTitleBar>
} else {
rightSpacerWidth = totalLeft - totalRight;
}

// באנדרואיד אנחנו רוצים את כפתורי ההגדרות/מסך מלא צמודים לשמאל
// בלי spacer נוסף בצד שמאל.
if (showAndroidFullscreenButton) {
rightSpacerWidth = 0;
}
}

return Row(
Expand Down Expand Up @@ -417,17 +478,48 @@ class _CustomTitleBarState extends State<CustomTitleBar>
),
),

// כפתורים נוספים (הגדרות)
// כפתורים נוספים (הגדרות/מסך מלא באנדרואיד)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 4.0),
child: IconButton(
icon: const Icon(FluentIcons.settings_24_regular, size: 18),
tooltip: 'הגדרות תצוגת הספרים',
onPressed: () => showReadingSettingsDialog(context),
style: _kIconButtonStyle.copyWith(
foregroundColor: WidgetStatePropertyAll(
Theme.of(context).colorScheme.onSurfaceVariant),
),
child: Row(
mainAxisSize: MainAxisSize.min,
textDirection: TextDirection.ltr,
children: [
if (showAndroidFullscreenButton)
IconButton(
icon: Icon(
settingsState.isFullscreen
? FluentIcons.full_screen_minimize_24_regular
: FluentIcons.full_screen_maximize_24_regular,
size: 18,
),
tooltip: settingsState.isFullscreen
? 'צא ממסך מלא'
: 'מסך מלא',
onPressed: () async {
final newFullscreenState = !settingsState.isFullscreen;
await FullscreenHelper.toggleFullscreen(
context,
newFullscreenState,
);
},
style: _kIconButtonStyle.copyWith(
foregroundColor: WidgetStatePropertyAll(
Theme.of(context).colorScheme.onSurfaceVariant,
),
),
),
IconButton(
icon: const Icon(FluentIcons.settings_24_regular, size: 18),
tooltip: 'הגדרות תצוגת הספרים',
onPressed: () => showReadingSettingsDialog(context),
style: _kIconButtonStyle.copyWith(
foregroundColor: WidgetStatePropertyAll(
Theme.of(context).colorScheme.onSurfaceVariant,
),
),
),
],
),
),
if (rightSpacerWidth > 0) SizedBox(width: rightSpacerWidth),
Expand Down
4 changes: 2 additions & 2 deletions lib/settings/engine/settings_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class SettingsRepository {
),
'libraryShowPreview': _settings.getValue<bool>(
keyLibraryShowPreview,
defaultValue: true,
defaultValue: false,
),
'shortcuts': await getShortcuts(),
'enablePerBookSettings': _settings.getValue<bool>(
Expand Down Expand Up @@ -652,7 +652,7 @@ class SettingsRepository {
await _settings.setValue(keyCopyHeaderFormat, 'same_line_after_brackets');
await _settings.setValue(keyIsFullscreen, false);
await _settings.setValue(keyLibraryViewMode, 'grid');
await _settings.setValue(keyLibraryShowPreview, true);
await _settings.setValue(keyLibraryShowPreview, false);
await _settings.setValue(keyEnablePerBookSettings, true);
await _settings.setValue(keyAlignTabsToRight, false);
await _settings.setValue(keyPersonalNotesCollapsedByDefault, true);
Expand Down
2 changes: 1 addition & 1 deletion lib/settings/engine/settings_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class SettingsState extends Equatable {
copyHeaderFormat: 'same_line_after_brackets',
isFullscreen: false,
libraryViewMode: 'grid',
libraryShowPreview: true,
libraryShowPreview: false,
shortcuts: {},
enablePerBookSettings: true,
isOfflineMode: false,
Expand Down
Loading