mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-07-07 05:07:54 +02:00
Add new builtin profiles, better handline of initialization, bump version
This commit is contained in:
@@ -8,8 +8,19 @@ class OperatorProfileState extends ChangeNotifier {
|
||||
|
||||
List<OperatorProfile> get profiles => List.unmodifiable(_profiles);
|
||||
|
||||
Future<void> init() async {
|
||||
Future<void> init({bool addDefaults = false}) async {
|
||||
_profiles.addAll(await OperatorProfileService().load());
|
||||
|
||||
// Add default operator profiles if this is first launch
|
||||
if (addDefaults) {
|
||||
final defaults = [
|
||||
OperatorProfile.lowes(),
|
||||
OperatorProfile.homeDepot(),
|
||||
];
|
||||
|
||||
_profiles.addAll(defaults);
|
||||
await OperatorProfileService().save(_profiles);
|
||||
}
|
||||
}
|
||||
|
||||
void addOrUpdateProfile(OperatorProfile p) {
|
||||
|
||||
@@ -17,19 +17,28 @@ class ProfileState extends ChangeNotifier {
|
||||
_profiles.where(isEnabled).toList(growable: false);
|
||||
|
||||
// Initialize profiles from built-in and custom sources
|
||||
Future<void> init() async {
|
||||
// Initialize profiles: built-in + custom
|
||||
_profiles.add(NodeProfile.genericAlpr());
|
||||
_profiles.add(NodeProfile.flock());
|
||||
_profiles.add(NodeProfile.motorola());
|
||||
_profiles.add(NodeProfile.genetec());
|
||||
_profiles.add(NodeProfile.leonardo());
|
||||
_profiles.add(NodeProfile.neology());
|
||||
_profiles.add(NodeProfile.genericGunshotDetector());
|
||||
_profiles.add(NodeProfile.shotspotter());
|
||||
_profiles.add(NodeProfile.flockRaven());
|
||||
Future<void> init({bool addDefaults = false}) async {
|
||||
// Load custom profiles from storage
|
||||
_profiles.addAll(await ProfileService().load());
|
||||
|
||||
// Add built-in profiles if this is first launch
|
||||
if (addDefaults) {
|
||||
final builtinProfiles = [
|
||||
NodeProfile.genericAlpr(),
|
||||
NodeProfile.flock(),
|
||||
NodeProfile.motorola(),
|
||||
NodeProfile.genetec(),
|
||||
NodeProfile.leonardo(),
|
||||
NodeProfile.neology(),
|
||||
NodeProfile.genericGunshotDetector(),
|
||||
NodeProfile.shotspotter(),
|
||||
NodeProfile.flockRaven(),
|
||||
];
|
||||
|
||||
_profiles.addAll(builtinProfiles);
|
||||
await ProfileService().save(_profiles);
|
||||
}
|
||||
|
||||
// Load enabled profile IDs from prefs
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final enabledIds = prefs.getStringList(_enabledPrefsKey);
|
||||
|
||||
Reference in New Issue
Block a user