Skip to content

Commit

Permalink
fix git commit id and allow deleting triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed Feb 28, 2024
1 parent 0867cce commit b190208
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 51 deletions.
104 changes: 55 additions & 49 deletions lib/Frontend/pages/triggers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,61 @@ class _TriggersState extends ConsumerState<Triggers> {
},
),
),
...getTriggerOptions(triggersList[index])
ListTile(
title: Text(deviceType()),
subtitle: SegmentedButton<DeviceType>(
multiSelectionEnabled: true,
selected: triggersList[index].deviceType.toSet(),
onSelectionChanged: (Set<DeviceType> value) {
setState(() => triggersList[index].deviceType = value.toList());
ref.read(triggerListProvider.notifier).store();
},
segments: DeviceType.values.map<ButtonSegment<DeviceType>>(
(DeviceType value) {
return ButtonSegment<DeviceType>(
value: value,
label: Text(value.name),
);
},
).toList(),
),
),
...triggersList[index].actions.map(
(TriggerAction e) => ListTile(
title: Text(triggersList[index].triggerDefinition!.actionTypes.where((element) => e.uuid == element.uuid).first.translated),
subtitle: Text(ref.read(getActionFromUUIDProvider(e.action))?.name ?? triggerActionNotSet()),
trailing: IconButton(
icon: const Icon(Icons.edit),
onPressed: () async {
BaseAction? result = await showDialog(
context: context,
builder: (BuildContext context) {
return Dialog.fullscreen(child: ActionSelector(deviceType: triggersList[index].deviceType.toSet()));
});
setState(
() {
e.action = result?.uuid;
ref.read(triggerListProvider.notifier).store();
},
);
},
),
),
),
ButtonBar(
children: [
TextButton(
onPressed: () {
setState(() {
ref.read(triggerListProvider).remove(triggersList[index]);
ref.read(triggerListProvider.notifier).store();
Navigator.of(context).pop();
});
},
child: const Text("Delete Trigger"),
),
],
)
],
);
});
Expand Down Expand Up @@ -160,52 +214,4 @@ class _TriggersState extends ConsumerState<Triggers> {
),
);
}

List<Widget> getTriggerOptions(Trigger trigger) {
List<Widget> results = [];
results.add(
ListTile(
title: Text(deviceType()),
subtitle: SegmentedButton<DeviceType>(
multiSelectionEnabled: true,
selected: trigger.deviceType.toSet(),
onSelectionChanged: (Set<DeviceType> value) {
setState(() => trigger.deviceType = value.toList());
ref.read(triggerListProvider.notifier).store();
},
segments: DeviceType.values.map<ButtonSegment<DeviceType>>(
(DeviceType value) {
return ButtonSegment<DeviceType>(
value: value,
label: Text(value.name),
);
},
).toList(),
),
),
);
results.addAll(
trigger.actions.map(
(TriggerAction e) => ListTile(
title: Text(trigger.triggerDefinition!.actionTypes.where((element) => e.uuid == element.uuid).first.translated),
subtitle: Text(ref.read(getActionFromUUIDProvider(e.action))?.name ?? triggerActionNotSet()),
trailing: IconButton(
icon: const Icon(Icons.edit),
onPressed: () async {
BaseAction? result = await showDialog(
context: context,
builder: (BuildContext context) {
return Dialog.fullscreen(child: ActionSelector(deviceType: trigger.deviceType.toSet()));
});
setState(() {
e.action = result?.uuid;
ref.read(triggerListProvider.notifier).store();
});
},
),
),
),
);
return results;
}
}
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Future<void> main() async {
options.enableAutoPerformanceTracing = true;
options.enableAppHangTracking = true;
options.beforeSend = beforeSend;
options.release = (await rootBundle.loadString('.git/HEAD')).trim();
options.release = (await rootBundle.loadString('.git/ORIG_HEAD')).trim();
},
// Init your App.
appRunner: () => runApp(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ flutter:
uses-material-design: true
generate: true
assets:
- .git/HEAD
- .git/ORIG_HEAD
sentry:
upload_debug_symbols: true
upload_source_maps: true
Expand Down

0 comments on commit b190208

Please sign in to comment.