Implement User-Initiated Scroll Detection to Control Chart Auto-Scrolling #268
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR introduces enhancements to the blood glucose chart's auto-scrolling behavior in the
MainViewController. The primary goal is to improve the user experience by allowing manual chart interactions (like scrolling to view historical data) without being interrupted by auto-scrolling to the latest data point.Changes
Date?variable namedautoScrollPauseUntiltoMainViewController. This variable tracks the time until which auto-scrolling should be paused due to user interaction.updateBGGraphmethod to checkautoScrollPauseUntilbefore executing auto-scrolling logic. Auto-scrolling now only occurs ifautoScrollPauseUntilisnilor the current time is past theautoScrollPauseUntiltimestamp.chartTranslateddelegate method to updateautoScrollPauseUntilbased on user scrolling. If the user scrolls to the latest data point,autoScrollPauseUntilis set tonil, allowing immediate resumption of auto-scrolling. If the user scrolls to view historical data,autoScrollPauseUntilis set to 5 minutes into the future, temporarily pausing auto-scrolling.Rationale
The motivation behind these changes is to strike a balance between keeping users informed of the latest blood glucose data and allowing uninterrupted exploration of historical data. By intelligently managing auto-scrolling based on user interaction, we enhance the application's usability, particularly for users who actively engage with their historical blood glucose data.
Testing
These changes have been tested in the development environment to ensure that: