Reading Position Management
The app maintains two types of reading positions:- Saved Reading Position: Your permanent bookmark (stored in
currentSavedPageatom) - Temporary Navigation: Pages you visit without changing your saved position
Current Saved Page
Your reading position is automatically saved when:- You navigate to a page without the
temporary=trueparameter - The page is within valid bounds (1 to total pages)
- You’re not in temporary navigation mode
currentSavedPage atom and persists using MMKV storage.
Reading Position Banner
When you navigate in temporary mode (e.g., from the navigation screen), a Reading Position Banner appears at the bottom of the screen.Banner Location
Component:components/ReadingPositionBanner.tsx
The banner only appears when:
- You’re in temporary navigation mode (
temporary=true) - Your current page differs from your saved reading position
Banner Features
The Reading Position Banner shows: “العودة إلى موضع القراءة (صفحة X)” - “Return to reading position (Page X)“
Collapsible Design
The banner has two states:- Collapsed
- Expanded
Height: 60px (
READING_BANNER_HEIGHT_CLOSED)Shows:- Return message with saved page number
- Chevron-down icon
Banner Actions
The expanded banner provides two actions:Save Current Position (حفظ)
Primary Button with bookmark iconWhat it does:
- Saves the current page as your reading position
- Updates
currentSavedPageto the current page - Updates
yesterdayPagewith current page and date - Removes the
temporaryparameter from the URL - Hides the banner
Using the Reading Position Banner
Browse Temporarily
Use the navigation screen to browse different pages. The banner appears automatically.
The banner’s collapsed state is saved in
readingBannerCollapsedState and persists across navigation.Yesterday Page Tracking
The app tracks your reading position from the previous day.How It Works
yesterdayPage atom stores:
- value: Last saved page number
- date: Date when it was saved
Automatic Reset
Using Jotai’sobserve effect, the app:
- Checks if the stored date matches today’s date
- If the date changed (new day), updates
yesterdayPagewith:- Current
currentSavedPageas the value - Today’s date
- Current
Yesterday page is useful for daily reading trackers and progress monitoring.
Reading Position Hook
TheuseCurrentPage hook (hooks/useCurrentPage.ts) manages reading position logic.
Hook Return Values
Temporary Navigation Detection
The hook determines if you’re in temporary mode:- URL has
temporary=trueparameter, AND - Current page differs from saved page
Saving Reading Position
ThesetCurrentPage function handles saving:
Validate Page Number
Ensures the page is within valid bounds:
- Minimum: Page 1
- Maximum: Total pages for selected Riwaya
Automatic Position Saving
Reading position is automatically saved when:Page Load from URL
- Navigate to a page via URL parameter
- The
temporaryparameter is not'true' - The page number is valid
Direct Navigation
When you navigate to a page without using the navigation screen:- The page is immediately saved as your reading position
- No banner appears
- The
temporaryparameter is absent from the URL
Integration with Daily Tracker
Reading position integrates with the daily tracker:- Yesterday Page: Starting point for tracking daily progress
- Current Page: Used to calculate how much you’ve read today
- Daily Goal: Compared against pages read since yesterday
See the Daily Tracker documentation for more details on progress tracking.
State Persistence
All reading position data is persisted using MMKV:- currentSavedPage
- yesterdayPage
Type:
numberDefault: 1Storage Key: 'CurrentSavedPage'Stores your current reading position.Navigation Patterns
Scenario 1: Casual Browsing
Open navigation to check page 200
Navigate to page 200 with
temporary=trueBanner appears showing “Return to reading position (Page 100)”Scenario 2: Finding a New Position
Scenario 3: Direct Navigation
Accessibility
The Reading Position Banner includes full accessibility support:- Collapse Button:
accessibilityLabelindicates expand/collapse state - Save Button:
accessibilityLabel: “حفظ موضع الحالي” (Save current position)accessibilityHint: Shows current page number
- Return Button:
accessibilityLabel: “العودة إلى موضع القراءة” (Return to reading position)accessibilityHint: Shows saved page number
Best Practices
Regular Reading
Navigate directly to continue where you left off. Your position saves automatically.
Looking Up References
Use the navigation screen with temporary mode to check other pages without losing your place.