-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix hide goals toggle #4335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix hide goals toggle #4335
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ import 'package:omi/pages/conversations/widgets/processing_capture.dart'; | |
| import 'package:omi/pages/conversations/widgets/search_result_header_widget.dart'; | ||
| import 'package:omi/pages/conversations/widgets/search_widget.dart'; | ||
| import 'package:omi/pages/conversations/widgets/today_tasks_widget.dart'; | ||
| import 'package:omi/backend/preferences.dart'; | ||
| import 'package:omi/providers/capture_provider.dart'; | ||
| import 'package:omi/providers/conversation_provider.dart'; | ||
| import 'package:omi/providers/folder_provider.dart'; | ||
|
|
@@ -207,24 +208,22 @@ class _ConversationsPageState extends State<ConversationsPage> with AutomaticKee | |
| const SliverToBoxAdapter(child: SearchResultHeaderWidget()), | ||
| getProcessingConversationsWidget(convoProvider.processingConversations), | ||
|
|
||
| // Daily Score Widget | ||
| const SliverToBoxAdapter( | ||
| child: Padding( | ||
| padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8), | ||
| child: DailyScoreWidget(), | ||
| // Daily Score, Today's Tasks, and Goals Widgets | ||
| if (SharedPreferencesUtil().showGoalTrackerEnabled) ...[ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the desktop page, calling For a responsive user experience, this setting should be managed by a reactive state manager like a Recommendation: |
||
| const SliverToBoxAdapter( | ||
| child: Padding( | ||
| padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8), | ||
| child: DailyScoreWidget(), | ||
| ), | ||
| ), | ||
| ), | ||
|
|
||
| // Today's Tasks (top 3) | ||
| const SliverToBoxAdapter( | ||
| child: Padding( | ||
| padding: EdgeInsets.only(top: 8, bottom: 8), | ||
| child: TodayTasksWidget(), | ||
| const SliverToBoxAdapter( | ||
| child: Padding( | ||
| padding: EdgeInsets.only(top: 8, bottom: 8), | ||
| child: TodayTasksWidget(), | ||
| ), | ||
| ), | ||
| ), | ||
|
|
||
| // Goals Widget (up to 3 goals) | ||
| SliverToBoxAdapter(child: GoalsWidget(key: _goalsWidgetKey)), | ||
| SliverToBoxAdapter(child: GoalsWidget(key: _goalsWidgetKey)), | ||
| ], | ||
|
|
||
| // Conversations section header | ||
| SliverToBoxAdapter( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling
SharedPreferencesUtil()directly within thebuildmethod to control UI visibility can lead to a poor user experience.SharedPreferencesis not reactive, meaning that when the user changes theshowGoalTrackerEnabledsetting (e.g., on a settings page), this widget will not automatically rebuild to reflect the change. The goals section will only hide or show after a rebuild is triggered by another state change.To fix this, you should manage this setting using a reactive state management solution like
Provider.Recommendation:
SettingsProviderthat usesChangeNotifier.SharedPreferencesin its constructor.SharedPreferences, and then callnotifyListeners().context.watch<SettingsProvider>().showGoalTrackerEnabledto reactively listen to changes.This will ensure the UI updates instantly when the user toggles the setting.