From cc6e7d82688b4b18be92946b6543c916b1b0e84f Mon Sep 17 00:00:00 2001 From: Bshlomecha Date: Fri, 27 Nov 2026 14:15:59 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=D7=AA=D7=99=D7=90=D7=95=D7=A8=20=D7=9E?= =?UTF-8?q?=D7=93=D7=A3:=20=D7=94=D7=A7=D7=A6=D7=A8=20=D7=95=D7=94=D7=90?= =?UTF-8?q?=D7=A8=D7=95=D7=9A=20=D7=91=D7=A8=D7=A6=D7=A3,=20=D7=91=D7=93?= =?UTF-8?q?=D7=99=D7=90=D7=9C=D7=95=D7=92=20=D7=95=D7=91=D7=AA=D7=A6=D7=95?= =?UTF-8?q?=D7=92=D7=94=20=D7=94=D7=9E=D7=A7=D7=93=D7=99=D7=9E=D7=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - בדיאלוג: הקצר (מודגש) והארוך ברצף תחת שם המדף, בלי כותרת "תיאור"; הכותרת "תיאור המדף". - בתצוגה המקדימה: הקצר והארוך בפסקאות נפרדות ולא בפסקה אחת. - סוגריים עגולות מוקטנות ובלי הדגשה, מרובעות מוקטנות מעט. - שורת המונים בתצוגה המקדימה: קטנה, דקה ואפורה. Co-Authored-By: Claude Sonnet 5.5 --- lib/library/view/category_details_dialog.dart | 30 ++---- lib/library/view/category_preview_panel.dart | 14 +-- lib/library/view/shelf_description.dart | 102 ++++++++++++++++++ test/library/view/grid_items_test.dart | 16 +-- test/library/view/shelf_description_test.dart | 86 +++++++++++++++ 5 files changed, 211 insertions(+), 37 deletions(-) create mode 100644 lib/library/view/shelf_description.dart create mode 100644 test/library/view/shelf_description_test.dart diff --git a/lib/library/view/category_details_dialog.dart b/lib/library/view/category_details_dialog.dart index 927f3939d5..578b2af127 100644 --- a/lib/library/view/category_details_dialog.dart +++ b/lib/library/view/category_details_dialog.dart @@ -1,8 +1,7 @@ import 'package:fluentui_system_icons/fluentui_system_icons.dart'; import 'package:flutter/material.dart'; -import 'package:otzaria/book_common/view/book_source_dialog.dart' - show splitShortAndFullDescription; import 'package:otzaria/library/models/library.dart'; +import 'package:otzaria/library/view/shelf_description.dart'; import 'package:otzaria/theme/app_tokens.dart'; import 'package:otzaria/widgets/dialogs/dialogs_exports.dart'; import 'package:otzaria/widgets/misc/app_selection_area.dart'; @@ -15,7 +14,7 @@ Future showCategoryDetailsDialog( ) async { await showSingleActionDialog( context: context, - title: 'אודות הקטגוריה', + title: 'תיאור המדף', icon: FluentIcons.folder_24_regular, size: AppDialogSize.medium, confirmText: 'סגור', @@ -46,16 +45,6 @@ class _CategoryDetailsDialogContentState @override Widget build(BuildContext context) { final category = widget.category; - final shortDescription = category.shortDescription.trim(); - // התיאור הקצר כבר בכותרת; כשהמורחב מתחיל בו, בכרטיס נשאר רק ההמשך. - final split = splitShortAndFullDescription( - shortDescription, - category.description, - ); - final fullDescription = split == null - ? category.description.trim() - : split.rest; - // פס גלילה קבוע: תיאור מורחב ארוך נחתך בתחתית הדיאלוג, ובלי פס אין סימן // שיש המשך. return SizedBox( @@ -70,17 +59,12 @@ class _CategoryDetailsDialogContentState mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - DetailsHeading( - title: category.title, - subtitle: shortDescription, - ), - if (fullDescription.isNotEmpty) ...[ + DetailsHeading(title: category.title), + // הקצר (מודגש) והארוך ברצף, תחת כותרת אחת. כשזה כל התוכן אין + // צורך בכותרת מקטע. + if (categoryHasDescription(category)) ...[ const SizedBox(height: AppTokens.spaceMD), - DetailsCard( - title: 'תיאור', - icon: FluentIcons.document_text_24_regular, - children: [DetailsText(fullDescription)], - ), + ShelfDescription(category: category), ], ], ), diff --git a/lib/library/view/category_preview_panel.dart b/lib/library/view/category_preview_panel.dart index bdec3e9f24..c634bada98 100644 --- a/lib/library/view/category_preview_panel.dart +++ b/lib/library/view/category_preview_panel.dart @@ -3,7 +3,7 @@ import 'package:positioned_sliver_list/positioned_sliver_list.dart' show SuperListView; import 'package:fluentui_system_icons/fluentui_system_icons.dart'; import 'package:otzaria/library/models/library.dart'; -import 'package:otzaria/library/view/grid_items.dart'; +import 'package:otzaria/library/view/shelf_description.dart'; import 'package:otzaria/models/books.dart'; import 'package:otzaria/theme/app_tokens.dart'; import 'package:otzaria/utils/ui/book_format_icon.dart'; @@ -40,7 +40,7 @@ class CategoryPreviewPanel extends StatelessWidget { Widget build(BuildContext context) { final theme = Theme.of(context); final cs = theme.colorScheme; - final description = categoryInfoText(category); + final hasDescription = categoryHasDescription(category); final counts = categoryContentCountsText( subCategories: subCategories.length, books: books.length, @@ -67,11 +67,11 @@ class CategoryPreviewPanel extends StatelessWidget { padding: headerInset, child: _header(theme, cs), ), - if (description != null) ...[ + if (hasDescription) ...[ const SizedBox(height: 16), Padding( padding: headerInset, - child: Text(description, style: theme.textTheme.bodyMedium), + child: ShelfDescription(category: category), ), ], if (counts != null) ...[ @@ -80,9 +80,11 @@ class CategoryPreviewPanel extends StatelessWidget { padding: headerInset, child: Text( counts, + // שורת סיכום: קטנה, דקה ואפורה. style: AppTextStyles.settingTitle.copyWith( - fontSize: AppTokens.fontMD, - color: cs.onSurfaceVariant, + fontSize: AppTokens.fontSM, + fontWeight: FontWeight.w300, + color: cs.onSurfaceVariant.withValues(alpha: 0.7), ), ), ), diff --git a/lib/library/view/shelf_description.dart b/lib/library/view/shelf_description.dart new file mode 100644 index 0000000000..f23088a0bf --- /dev/null +++ b/lib/library/view/shelf_description.dart @@ -0,0 +1,102 @@ +import 'package:flutter/material.dart'; +import 'package:otzaria/book_common/view/book_source_dialog.dart' + show splitShortAndFullDescription; +import 'package:otzaria/library/models/library.dart'; +import 'package:otzaria/theme/app_tokens.dart'; + +/// מחלק את תיאור הקטגוריה לקצר ([lead]) ולארוך ([paragraphs], פסקה לכל שורה). +/// +/// ארוך שפותח בקצר מוצג בלי הקצר שבראשו, וארוך הזהה לקצר אינו חוזר. +@visibleForTesting +({String lead, List paragraphs}) categoryDescriptionParts( + Category category, +) { + final lead = category.shortDescription.trim(); + final full = category.description.trim(); + final split = splitShortAndFullDescription(lead, full); + final rest = split?.rest ?? (full == lead ? '' : full); + final paragraphs = rest + .split('\n') + .map((paragraph) => paragraph.trim()) + .where((paragraph) => paragraph.isNotEmpty) + .toList(); + return (lead: lead, paragraphs: paragraphs); +} + +/// האם לקטגוריה יש תיאור כלשהו להצגה. +bool categoryHasDescription(Category category) { + final parts = categoryDescriptionParts(category); + return parts.lead.isNotEmpty || parts.paragraphs.isNotEmpty; +} + +final _bracketed = RegExp(r'\([^()]*\)|\[[^\[\]]*\]'); + +/// מפרק טקסט לקטעים: סוגריים עגולות מוקטנות משמעותית ובלי הדגשה, ומרובעות +/// מוקטנות מעט. [fontSize] הוא גודל הטקסט שסביבן. +@visibleForTesting +List shelfDescriptionSpans(String text, double fontSize) { + final spans = []; + var from = 0; + for (final match in _bracketed.allMatches(text)) { + if (match.start > from) { + spans.add(TextSpan(text: text.substring(from, match.start))); + } + final round = text.startsWith('(', match.start); + spans.add( + TextSpan( + text: match.group(0), + style: round + ? TextStyle(fontSize: fontSize * 0.76, fontWeight: FontWeight.w400) + : TextStyle(fontSize: fontSize * 0.92), + ), + ); + from = match.end; + } + if (from < text.length) spans.add(TextSpan(text: text.substring(from))); + return spans; +} + +/// תיאור קטגוריה ברצף: פסקה לקצר (מודגש), ואחריה פסקה לכל שורה בארוך. +class ShelfDescription extends StatelessWidget { + const ShelfDescription({ + super.key, + required this.category, + this.fontSize = AppTokens.fontMD, + }); + + final Category category; + final double fontSize; + + @override + Widget build(BuildContext context) { + final parts = categoryDescriptionParts(category); + final color = Theme.of(context).colorScheme.onSurface; + + Widget paragraph(String text, {bool bold = false}) => Text.rich( + TextSpan( + style: TextStyle( + fontSize: fontSize, + height: 1.4, + color: color, + fontWeight: bold ? FontWeight.bold : null, + ), + children: shelfDescriptionSpans(text, fontSize), + ), + ); + + final paragraphs = [ + if (parts.lead.isNotEmpty) paragraph(parts.lead, bold: true), + for (final text in parts.paragraphs) paragraph(text), + ]; + return Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + for (var i = 0; i < paragraphs.length; i++) ...[ + if (i > 0) const SizedBox(height: AppTokens.spaceSM), + paragraphs[i], + ], + ], + ); + } +} diff --git a/test/library/view/grid_items_test.dart b/test/library/view/grid_items_test.dart index e6da388494..d8a94725ed 100644 --- a/test/library/view/grid_items_test.dart +++ b/test/library/view/grid_items_test.dart @@ -413,7 +413,7 @@ void main() { Future closeDialog(WidgetTester tester) async { await tester.tap(find.text('סגור')); await tester.pumpAndSettle(); - expect(find.text('אודות הקטגוריה'), findsNothing); + expect(find.text('תיאור המדף'), findsNothing); } testWidgets('קצר וארוך: הקצר אינו בכרטיס (זמני), הארוך בריחוף ובדיאלוג', ( @@ -439,11 +439,11 @@ void main() { await tester.tap(infoButton()); await tester.pumpAndSettle(); - expect(find.text('אודות הקטגוריה'), findsOneWidget); - // הכותרת: שם הקטגוריה ומתחתיו התיאור הקצר; התיאור המורחב בכרטיס. + expect(find.text('תיאור המדף'), findsOneWidget); + // הכותרת: שם הקטגוריה; ומתחתיה הקצר והארוך ברצף, בלי כותרת מקטע. expect(find.text('קטגוריית בדיקה'), findsNWidgets(2)); expect(find.text('תיאור קצר'), findsOneWidget); - expect(find.text('תיאור'), findsOneWidget); + expect(find.text('תיאור'), findsNothing); expect(find.text('תיאור מורחב'), findsOneWidget); await closeDialog(tester); }); @@ -468,7 +468,7 @@ void main() { await tester.tap(infoButton()); await tester.pumpAndSettle(); - expect(find.text('אודות הקטגוריה'), findsOneWidget); + expect(find.text('תיאור המדף'), findsOneWidget); expect(find.text('תיאור קצר בלבד'), findsOneWidget); expect(find.text('תיאור'), findsNothing); await closeDialog(tester); @@ -494,8 +494,8 @@ void main() { await tester.tap(infoButton()); await tester.pumpAndSettle(); - expect(find.text('אודות הקטגוריה'), findsOneWidget); - expect(find.text('תיאור'), findsOneWidget); + expect(find.text('תיאור המדף'), findsOneWidget); + expect(find.text('תיאור'), findsNothing); expect(find.text('תיאור מורחב בלבד'), findsOneWidget); await closeDialog(tester); }); @@ -511,7 +511,7 @@ void main() { .map((tooltip) => tooltip.message), isNot(contains('')), ); - expect(find.text('אודות הקטגוריה'), findsNothing); + expect(find.text('תיאור המדף'), findsNothing); }); }); diff --git a/test/library/view/shelf_description_test.dart b/test/library/view/shelf_description_test.dart new file mode 100644 index 0000000000..b99dfbcd0a --- /dev/null +++ b/test/library/view/shelf_description_test.dart @@ -0,0 +1,86 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:otzaria/library/models/library.dart'; +import 'package:otzaria/library/view/shelf_description.dart'; + +Category _category(String shortDescription, String description) => Category( + title: 'משנה', + description: description, + shortDescription: shortDescription, + order: 0, + subCategories: [], + books: [], + parent: null, +); + +void main() { + group('categoryDescriptionParts', () { + test('ארוך שפותח בקצר: הקצר ראשון, ואחריו ההמשך בלבד', () { + final parts = categoryDescriptionParts( + _category('יסוד המסירה.', 'יסוד המסירה. והוא קיבץ הכל.'), + ); + expect(parts.lead, 'יסוד המסירה.'); + expect(parts.paragraphs, ['והוא קיבץ הכל.']); + }); + + test('ארוך שאינו פותח בקצר: שניהם, הקצר ראשון', () { + final parts = categoryDescriptionParts(_category('קצר', 'ארוך אחר')); + expect(parts.lead, 'קצר'); + expect(parts.paragraphs, ['ארוך אחר']); + }); + + test('ארוך בכמה שורות: פסקה לכל שורה', () { + final parts = categoryDescriptionParts(_category('', 'א\n\nב')); + expect(parts.lead, isEmpty); + expect(parts.paragraphs, ['א', 'ב']); + }); + + test('ארוך זהה לקצר אינו חוזר', () { + final parts = categoryDescriptionParts(_category('קצר.', 'קצר.')); + expect(parts.lead, 'קצר.'); + expect(parts.paragraphs, isEmpty); + }); + + test('בלי תיאורים: אין מה להציג', () { + expect(categoryHasDescription(_category('', '')), isFalse); + expect(categoryHasDescription(_category('קצר', '')), isTrue); + expect(categoryHasDescription(_category('', 'ארוך')), isTrue); + }); + }); + + group('shelfDescriptionSpans', () { + test('עגולות מוקטנות משמעותית ובלי הדגשה, מרובעות מוקטנות מעט', () { + final spans = shelfDescriptionSpans('א (ב) ג [ד] ה', 20); + expect(spans.map((s) => s.text), ['א ', '(ב)', ' ג ', '[ד]', ' ה']); + expect(spans[1].style?.fontSize, closeTo(15.2, 0.001)); + expect(spans[1].style?.fontWeight, FontWeight.w400); + expect(spans[3].style?.fontSize, closeTo(18.4, 0.001)); + expect(spans[3].style?.fontWeight, isNull); + }); + + test('סוגריים שלא נסגרו נשארות כטקסט רגיל', () { + final spans = shelfDescriptionSpans('א (ב', 20); + expect(spans.map((s) => s.text), ['א (ב']); + expect(spans.single.style, isNull); + }); + }); + + testWidgets('הקצר מודגש ואחריו הארוך בפסקה נפרדת', (tester) async { + await tester.pumpWidget( + MaterialApp( + home: Directionality( + textDirection: TextDirection.rtl, + child: Scaffold( + body: ShelfDescription(category: _category('קצר (עי׳ שם)', 'ארוך')), + ), + ), + ), + ); + + final lead = tester.widget(find.text('קצר (עי׳ שם)')); + expect((lead.textSpan! as TextSpan).style?.fontWeight, FontWeight.bold); + final longRect = tester.getRect(find.text('ארוך')); + final leadRect = tester.getRect(find.text('קצר (עי׳ שם)')); + expect(longRect.top, greaterThan(leadRect.bottom)); + }); +} From 738d7fbb1a8caafebfd08c6c16284733a2a0a7ae Mon Sep 17 00:00:00 2001 From: Bshlomecha Date: Sun, 29 Nov 2026 00:31:18 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=D7=A9=D7=95=D7=A8=D7=AA=20=D7=94=D7=9E?= =?UTF-8?q?=D7=95=D7=A0=D7=99=D7=9D=20=D7=91=D7=AA=D7=A6=D7=95=D7=92=D7=94?= =?UTF-8?q?=20=D7=94=D7=9E=D7=A7=D7=93=D7=99=D7=9E=D7=94:=20=D7=A1=D7=92?= =?UTF-8?q?=D7=A0=D7=95=D7=9F=20=D7=9E-textTheme=20=D7=95=D7=91=D7=9C?= =?UTF-8?q?=D7=99=20=D7=A9=D7=A7=D7=99=D7=A4=D7=95=D7=AA=20=D7=9E=D7=A7?= =?UTF-8?q?=D7=95=D7=9E=D7=99=D7=AA=20(UIL-016,=20UIL-017)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- lib/library/view/category_preview_panel.dart | 5 ++--- tool/ui_lint/baseline.json | 3 --- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/library/view/category_preview_panel.dart b/lib/library/view/category_preview_panel.dart index c634bada98..dae89ca135 100644 --- a/lib/library/view/category_preview_panel.dart +++ b/lib/library/view/category_preview_panel.dart @@ -81,10 +81,9 @@ class CategoryPreviewPanel extends StatelessWidget { child: Text( counts, // שורת סיכום: קטנה, דקה ואפורה. - style: AppTextStyles.settingTitle.copyWith( - fontSize: AppTokens.fontSM, + style: theme.textTheme.bodySmall?.copyWith( fontWeight: FontWeight.w300, - color: cs.onSurfaceVariant.withValues(alpha: 0.7), + color: cs.outline, ), ), ), diff --git a/tool/ui_lint/baseline.json b/tool/ui_lint/baseline.json index 0894ec3152..cc6386b7dc 100644 --- a/tool/ui_lint/baseline.json +++ b/tool/ui_lint/baseline.json @@ -324,9 +324,6 @@ {"scope":"_BookPreviewPanelState.build","fp":"a9c1e30c","n":1}, {"scope":"_BookPreviewPanelState.build","fp":"adc1e958","n":1} ], - "lib/library/view/category_preview_panel.dart": [ - {"scope":"CategoryPreviewPanel.build","fp":"2d3a28a0","n":1} - ], "lib/library/view/library_browser.dart": [ {"scope":"_LibraryBrowserState._libraryListTitleStyle","fp":"8d9b7249","n":1} ],