Skip to content

ריפקטור גלילה בצורת הדף: איחוד לוגיקה והעברת ניהול ל-BLoC#205

Open
Y-PLONI wants to merge 9 commits intomigrationDB_V2+YPLfrom
codex/refactor-scrolling-functions-to-avoid-duplicates
Open

ריפקטור גלילה בצורת הדף: איחוד לוגיקה והעברת ניהול ל-BLoC#205
Y-PLONI wants to merge 9 commits intomigrationDB_V2+YPLfrom
codex/refactor-scrolling-functions-to-avoid-duplicates

Conversation

@Y-PLONI
Copy link
Collaborator

@Y-PLONI Y-PLONI commented Mar 5, 2026

מה בוצע

  • בוצע ריפקטור לפונקציות הגלילה בצורת הדף כדי לצמצם כפילויות ולרכז את ניהול הגלילה ב-TextBookBloc.
  • נוספו לשכבת ה-BLoC אירוע וזרימה אחידה לגלילה ובחירת שורה בטקסט הראשי.
  • סנכרון המפרשים נשען כעת על אינדקס עוגן שמנוהל ב-state של ה-BLoC, במקום ניהול מקומי בכל pane.

שינויים עיקריים

  1. BLoC

    • נוסף event חדש: SelectAndScrollToIndex (lib/text_book/bloc/text_book_event.dart).
    • נוספה לוגיקת טיפול אחידה בגלילה לבחירה:
      • _onSelectAndScrollToIndex
      • _emitSelectedIndex
    • עדכון UpdateVisibleIndecies כך שיחשב ויעדכן pageShapeAnchorIndex באופן עקבי.
  2. State

    • נוספו לשכבת TextBookLoaded שדות ייעודיים לסנכרון גלילת page_shape:
      • pageShapeAnchorIndex
      • pageShapePreferSelectedNextSync
  3. Page Shape UI

    • ב-page_shape_screen.dart הוסר ניהול מקומי כפול של העדפת selectedIndex לסנכרון.
    • _syncWithMainText משתמש ב-state.pageShapeAnchorIndex שמגיע מה-BLoC.
  4. SimpleTextViewer

    • ריכוז קריאות גלילה דרך helper יחיד (_selectAndScrollTo) במקום כפילויות של scrollTo בכל מקש.
    • אירועי מקלדת (חיצים/PageUp/PageDown/Home/End) שולחים כעת SelectAndScrollToIndex ל-BLoC.

למה זה פותר את הבעיה

  • מקור האי-עקביות בגלילה היה פיצול לוגיקה בין ה-UI לבין state מקומי בחלוניות המפרשים.
  • כעת מקור האמת לאינדקס הסנכרון הוא ה-BLoC, ולכן גלילת הספר הראשי והמפרשים נשארת עקבית.

בדיקות

  • לא ניתן להריץ flutter analyze בסביבה זו כי flutter לא מותקן (command not found).

Codex Task

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

בקשת משיכה זו מטפלת באי-עקביות בגלילה ובסנכרון בין הטקסט הראשי לחלוניות המפרשים, שנגרמה מפיצול לוגיקת הניהול. הפתרון המיושם מרכז את כל לוגיקת הגלילה ובחירת השורות ב-TextBookBloc, ובכך הופך אותו למקור האמת היחיד לאינדקס הסנכרון. שינוי זה מבטיח חווית גלילה חלקה ועקבית יותר בכל חלקי היישום.

Highlights

  • ריפקטור לוגיקת גלילה: בוצע ריפקטור ללוגיקת הגלילה ברכיב 'צורת הדף' (page_shape) כדי לרכז את הניהול ב-TextBookBloc.
  • אירוע BLoC חדש: נוסף אירוע BLoC חדש, SelectAndScrollToIndex, לגלילה ובחירת שורה אחידה בטקסט הראשי.
  • סנכרון מפרשים: סנכרון המפרשים מתבסס כעת על pageShapeAnchorIndex המנוהל ב-BLoC state, במקום ניהול מקומי בכל חלונית.
  • הסרת ניהול מצב מקומי: הוסר ניהול מצב מקומי כפול של העדפת selectedIndex מ-page_shape_screen.dart.
  • איחוד קריאות גלילה: קריאות הגלילה המופעלות על ידי מקלדת ב-SimpleTextViewer אוחדו לשימוש בפונקציית עזר אחת ששולחת אירועי BLoC.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • lib/text_book/bloc/text_book_bloc.dart
    • נוסף handler לאירוע SelectAndScrollToIndex.
    • אותחל pageShapeAnchorIndex ו-pageShapePreferSelectedNextSync ב- _onLoadTextBook.
    • עודכן _onUpdateVisibleIndecies לחשב ולקבוע את pageShapeAnchorIndex.
    • בוצע ריפקטור ל- _onUpdateSelectedIndex לשימוש בפונקציית עזר חדשה _emitSelectedIndex.
    • יושמה פונקציית _onSelectAndScrollToIndex לטיפול בגלילה ובחירה.
    • נוצרה פונקציית עזר _emitSelectedIndex לניהול עדכוני מצב עבור אינדקס נבחר וסנכרון צורת הדף.
  • lib/text_book/bloc/text_book_event.dart
    • נוספה מחלקת אירוע SelectAndScrollToIndex חדשה.
  • lib/text_book/bloc/text_book_state.dart
    • נוספו שדות pageShapeAnchorIndex ו-pageShapePreferSelectedNextSync למצב TextBookLoaded.
    • עודכנו בנאים ומתודת copyWith לכלול את השדות החדשים.
    • עודכנו props עבור TextBookLoaded.
  • lib/text_book/view/page_shape/page_shape_screen.dart
    • הוסרו משתני מצב מקומיים _lastObservedSelectedIndex ו- _preferSelectedIndexNextSync.
    • עודכן _syncWithMainText לשימוש ב-state.pageShapeAnchorIndex מה-BLoC.
  • lib/text_book/view/page_shape/simple_text_viewer.dart
    • בוצע ריפקטור ל- _scrollToCurrentPosition לשליחת אירוע SelectAndScrollToIndex.
    • הוצגה פונקציית עזר _selectAndScrollTo לשליחת אירועי SelectAndScrollToIndex.
    • שונתה לוגיקת הטיפול באירועי מקלדת (חיצים, PageUp/Down, Home/End) לשימוש בפונקציית העזר _selectAndScrollTo.
Activity
  • לא נרשמה פעילות אנושית בבקשת משיכה זו.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

ריפקטור מצוין! איחוד לוגיקת הגלילה והעברת ניהול המצב אל ה-BLoC הוא שיפור משמעותי. השינויים הופכים את הקוד לנקי יותר, מונעים כפילויות ומבטיחים מקור אמת יחיד למצב הגלילה, מה שפותר את בעיות חוסר העקביות שהיו קיימות. העבודה שנעשתה ב-simple_text_viewer.dart לרכז את כל אירועי הגלילה דרך _selectAndScrollTo היא דוגמה מצוינת לקוד נקי וקל לתחזוקה.
מצאתי הזדמנות קטנה לפשט לוגיקה בקובץ ה-BLoC, כפי שפירטתי בהערה.

Comment on lines +454 to +460
final shouldUseSelected =
currentState.pageShapePreferSelectedNextSync && index != null;
final pageShapeAnchorIndex = shouldUseSelected
? index
: (event.visibleIndecies.isNotEmpty
? event.visibleIndecies.first
: index);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

ניתן לפשט את הלוגיקה לקביעת pageShapeAnchorIndex. הלוגיקה הנוכחית חוזרת על עצמה במקצת.
התנאי shouldUseSelected ? index : (event.visibleIndecies.isNotEmpty ? event.visibleIndecies.first : index) יכול להיכתב בצורה תמציתית יותר, כיוון שבשני המקרים (כאשר shouldUseSelected הוא true, או כאשר event.visibleIndecies ריק) התוצאה היא index.

אני מציע את השינוי הבא לשיפור הקריאות:

Suggested change
final shouldUseSelected =
currentState.pageShapePreferSelectedNextSync && index != null;
final pageShapeAnchorIndex = shouldUseSelected
? index
: (event.visibleIndecies.isNotEmpty
? event.visibleIndecies.first
: index);
final shouldUseSelected =
currentState.pageShapePreferSelectedNextSync && index != null;
final pageShapeAnchorIndex =
!shouldUseSelected && event.visibleIndecies.isNotEmpty
? event.visibleIndecies.first
: index;

@Y-PLONI Y-PLONI force-pushed the migrationDB_V2+YPL branch from b907b55 to c26aae8 Compare March 12, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants