-
Notifications
You must be signed in to change notification settings - Fork 239
feat: add badge scan mode selection and filtering support #1357
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
base: development
Are you sure you want to change the base?
Changes from all commits
3547d8b
c0d5c8e
21a66bb
7de40ad
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:flutter/material.dart'; | ||
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. @samruddhi-Rahegaonkar If we are saving the added badge using provider then if the app closes and starts it will be gone is this how this functionality is spossed to be ? 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. Yeah! for now it should work like this if we need to maintain the persistant storage then we need to use shared preferences or any other alternative. |
||
|
||
enum BadgeScanMode { any, specific } | ||
|
||
class BadgeScanProvider with ChangeNotifier { | ||
BadgeScanMode _mode = BadgeScanMode.any; | ||
List<String> _badgeNames = ['LSLED', 'VBLAB']; | ||
|
||
BadgeScanMode get mode => _mode; | ||
List<String> get badgeNames => List.unmodifiable(_badgeNames); | ||
|
||
void setMode(BadgeScanMode mode) { | ||
_mode = mode; | ||
notifyListeners(); | ||
} | ||
|
||
void setBadgeNames(List<String> names) { | ||
_badgeNames = names.where((name) => name.trim().isNotEmpty).toList(); | ||
notifyListeners(); | ||
} | ||
|
||
void addBadgeName(String name) { | ||
_badgeNames.add(name); | ||
notifyListeners(); | ||
} | ||
|
||
void removeBadgeNameAt(int index) { | ||
_badgeNames.removeAt(index); | ||
notifyListeners(); | ||
} | ||
|
||
void updateBadgeName(int index, String newName) { | ||
_badgeNames[index] = newName; | ||
notifyListeners(); | ||
} | ||
} |
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.
@samruddhi-Rahegaonkar try to avoid global providers if possible the BadgeScanProviders are only needed when there is ascanning or connecting to the badge happens rest of the files does not need it.
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.
However, for now I've kept it global to simplify access across the current implementation and avoid extra wiring.Since it's a lightweight provider and doesn’t hold heavy state or long-lived connections, the impact should be minimal.