Skip to content

Commit ae38f13

Browse files
committed
SDK Dialogs #1
- Implement show dialog action. - Add show dialog action settings panel. - Implement show dialog action execution.
1 parent 1420958 commit ae38f13

14 files changed

+131
-1
lines changed

lib/src/api/models/action/action.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ enum ActionType {
3232
callApi,
3333

3434
/// Update data in local storage.
35-
setStorage;
35+
setStorage,
36+
37+
/// Show a dialog.
38+
showDialog;
3639

3740
/// Displayable string representation of the [ActionType].
3841
String get prettify {
@@ -55,6 +58,8 @@ enum ActionType {
5558
return 'Call API';
5659
case ActionType.setStorage:
5760
return 'Set Storage';
61+
case ActionType.showDialog:
62+
return 'Show Dialog';
5863
}
5964
}
6065
}
@@ -112,6 +117,8 @@ abstract class ActionModel with SerializableMixin {
112117
return ApiCallAction.fromJson(json);
113118
case ActionType.setStorage:
114119
return SetStorageAction.fromJson(json);
120+
case ActionType.showDialog:
121+
return ShowDialogAction.fromJson(json);
115122
}
116123
}
117124

lib/src/api/models/action/api_call_action.g.dart

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/models/action/call_function_action.g.dart

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/models/action/link_action.g.dart

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/models/action/navigation_action.g.dart

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/models/action/set_storage_action.g.dart

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/models/action/set_value_action.g.dart

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/models/action/set_variable_action.g.dart

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/models/action/set_variant_action.g.dart

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright (c) 2022, Codelessly.
2+
// All rights reserved. Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE.md file.
4+
5+
import 'package:codelessly_json_annotation/codelessly_json_annotation.dart';
6+
import 'package:equatable/equatable.dart';
7+
8+
import '../../mixins.dart';
9+
import '../condition.dart';
10+
import 'action.dart';
11+
12+
part 'show_dialog_action.g.dart';
13+
14+
/// An action that navigates to a new page.
15+
@JsonSerializable()
16+
class ShowDialogAction extends ActionModel
17+
with EquatableMixin, SerializableMixin {
18+
19+
/// Destination canvas node's ID.
20+
final String destinationId;
21+
22+
/// Parameters to pass to the destination page.
23+
final Map<String, dynamic> params;
24+
25+
/// Whether the dialog is dismissible by tapping outside the dialog.
26+
final bool barrierDismissible;
27+
28+
/// Creates a new [ShowDialogAction].
29+
ShowDialogAction({
30+
required this.destinationId,
31+
Map<String, String>? params,
32+
this.barrierDismissible = true,
33+
}) : params = {...params ?? {}},
34+
super(type: ActionType.showDialog);
35+
36+
@override
37+
List<Object?> get props => [destinationId, params, barrierDismissible];
38+
39+
/// Duplicates this [ShowDialogAction] with given data overrides.
40+
ShowDialogAction copyWith({
41+
String? destinationId,
42+
Map<String, String>? params,
43+
bool? barrierDismissible,
44+
}) =>
45+
ShowDialogAction(
46+
destinationId: destinationId ?? this.destinationId,
47+
params: {...this.params, ...params ?? {}},
48+
barrierDismissible: barrierDismissible ?? this.barrierDismissible,
49+
);
50+
51+
/// Creates a new [ShowDialogAction] instance from a JSON data.
52+
factory ShowDialogAction.fromJson(Map json) =>
53+
_$ShowDialogActionFromJson(json);
54+
55+
@override
56+
Map toJson() => _$ShowDialogActionToJson(this);
57+
58+
@override
59+
R? accept<R>(ActionVisitor<R> visitor) => visitor.visitShowDialogAction(this);
60+
}

0 commit comments

Comments
 (0)