Skip to content
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c91cf88
experiment - removing attribute support
lesleysin Apr 30, 2025
762cf89
wip
lesleysin May 2, 2025
f6fd89c
wip
lesleysin May 4, 2025
69425f7
wip
lesleysin May 4, 2025
b6d0847
refacror ViewAttributes class
lesleysin May 4, 2025
38df8a7
Added tests
lesleysin May 4, 2025
91f9432
wip
lesleysin May 6, 2025
35e0051
Added early exit from methods
lesleysin Jun 7, 2025
d8b4622
Added new functions for handling JSON parsing results, improved defau…
lesleysin Jun 17, 2025
ca44241
docs
lesleysin Jun 17, 2025
17697e3
add tests
lesleysin Jun 17, 2025
d59ce6c
Added tests
lesleysin Jun 17, 2025
96a84a0
Removed static mapping tables for Clip, TextAlign, TextOverflow and T…
lesleysin Jun 17, 2025
7bedbcd
Added new methods for JSON processing, including support for textDeco…
lesleysin Jun 17, 2025
fcda96e
Added tests
lesleysin Jun 17, 2025
8fecb45
Removed unused methods and added new functions to handle theme rules …
lesleysin Jun 20, 2025
30d2cf7
Upd .gitignore
lesleysin Jun 20, 2025
df2791e
wip
lesleysin Jun 22, 2025
7df84be
Upd tests, added Tween parser
lesleysin Jun 26, 2025
e952645
Removed ventilation methods, added new functions for widget handling.…
lesleysin Jun 30, 2025
f46e840
Refactored functions for creating InputBorder and ShapeBorder from a …
lesleysin Jun 30, 2025
39c900f
Added docs
lesleysin Jun 30, 2025
e7bd80c
upd actions config
lesleysin Jun 30, 2025
b71f6c0
wip
lesleysin Jun 30, 2025
94a9876
wip
lesleysin Jun 30, 2025
76e0bba
Update test/theme_test.dart
lesleysin Jun 30, 2025
93b09e8
clean dead code
lesleysin Jun 30, 2025
43d7888
fix
lesleysin Jun 30, 2025
e4ae9cf
Update lib/src/view_attributes/lookup.dart
lesleysin Jun 30, 2025
0e092a1
Added export of Command.dart file to action_api and removed it from a…
lesleysin Jul 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/post-merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
flutter-version: [ '3.22.3', '3.24.3', '3.27.3' ]
flutter-version: [ '3.24.3', '3.27.3' ]
Comment thread
lesleysin marked this conversation as resolved.
steps:
- uses: actions/checkout@v3

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
flutter-version: [ '3.22.3', '3.24.3', '3.27.3' ]
flutter-version: [ '3.24.3', '3.27.3' ]
Comment thread
lesleysin marked this conversation as resolved.
steps:
- uses: actions/checkout@v3

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
.history
.svn/
migrate_working_dir/
coverage/
Comment thread
lesleysin marked this conversation as resolved.

# IntelliJ related
*.iml
Expand Down
14 changes: 7 additions & 7 deletions lib/src/action_api/action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ final class TransportAction extends ServerAction implements DependentAction {
);

factory TransportAction.fromJson(Map<String, dynamic> json) {
final view = ServerActionJsonView(json);
final source = DuitDataSource(json);

return TransportAction(
eventName: view.eventName,
dependsOn: view.dependsOn,
meta: view.meta,
eventName: source.getString(key: "event"),
dependsOn: source.getActionDependencies(),
meta: source.meta,
);
}
}
Expand All @@ -131,11 +131,11 @@ final class ScriptAction extends ServerAction implements DependentAction {
);

factory ScriptAction.fromJson(Map<String, dynamic> json) {
final view = ServerActionJsonView(json);
final source = DuitDataSource(json);

return ScriptAction(
script: view.script!,
dependsOn: view.dependsOn,
script: source.script,
dependsOn: source.getActionDependencies(),
);
}
}
10 changes: 5 additions & 5 deletions lib/src/action_api/action_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ final class DefaultActionParser implements Parser<ServerAction> {

@override
ServerAction parse(Map<String, dynamic> json) {
final view = ServerActionJsonView(json);
final source = DuitDataSource(json);

return switch (view.executionType) {
0 => TransportAction.fromJson(json),
1 => LocalAction.fromJson(json),
2 => ScriptAction.fromJson(json),
return switch (source.executionType) {
0 => TransportAction.fromJson(source),
1 => LocalAction.fromJson(source),
2 => ScriptAction.fromJson(source),
_ => UnknownAction(),
};
}
Expand Down
14 changes: 14 additions & 0 deletions lib/src/action_api/command.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/// A command that is sent to control an action by interacting with an
/// action controller identified by [controllerId]. The command specifies
/// the [type] of action to be executed.
base class RemoteCommand {
final String controllerId;
final String type;
final Map<String, dynamic> payload;

const RemoteCommand({
required this.controllerId,
required this.type,
required this.payload,
});
}
100 changes: 54 additions & 46 deletions lib/src/action_api/event.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:duit_kernel/duit_kernel.dart';
import 'package:duit_kernel/src/action_api/command.dart';

/// The [ServerEvent] class represents an event that was sent by the server.
///
Expand All @@ -15,7 +16,7 @@ base class ServerEvent {

final String type;

ServerEvent({
const ServerEvent({
required this.type,
});

Expand Down Expand Up @@ -45,13 +46,14 @@ final class UpdateEvent extends ServerEvent {
/// The [json] parameter is a JSON object representing the update event.
/// Returns an [UpdateEvent] object if the JSON object is valid, otherwise throws an exception.
factory UpdateEvent.fromJson(Map<String, dynamic> json) {
return UpdateEvent(updates: json["updates"]);
return UpdateEvent(
updates: json["updates"] ?? const <String, dynamic>{},
);
}
}

final class NavigationEvent extends ServerEvent {
final String path;

final Map<String, dynamic> extra;

NavigationEvent({
Expand All @@ -60,9 +62,10 @@ final class NavigationEvent extends ServerEvent {
}) : super(type: "navigation");

factory NavigationEvent.fromJson(Map<String, dynamic> json) {
final source = DuitDataSource(json);
return NavigationEvent(
path: json["path"] ?? "",
extra: json["extra"] ?? {},
path: source.getString(key: "path"),
extra: source["extra"] ?? const <String, dynamic>{},
);
}
}
Expand All @@ -76,14 +79,13 @@ final class OpenUrlEvent extends ServerEvent {

factory OpenUrlEvent.fromJson(Map<String, dynamic> json) {
return OpenUrlEvent(
url: json["url"] ?? "",
url: DuitDataSource(json).getString(key: "url"),
);
}
}

final class CustomEvent extends ServerEvent {
final String key;

final Map<String, dynamic> extra;

CustomEvent({
Expand All @@ -92,9 +94,10 @@ final class CustomEvent extends ServerEvent {
}) : super(type: "custom");

factory CustomEvent.fromJson(Map<String, dynamic> json) {
final source = DuitDataSource(json);
return CustomEvent(
key: json["key"] ?? "",
extra: json["extra"] ?? {},
key: source.getString(key: "key"),
extra: source["extra"] ?? const <String, dynamic>{},
);
}
}
Expand Down Expand Up @@ -124,10 +127,16 @@ final class CommonEventGroup extends ServerEvent {
}) : super(type: "grouped");

factory CommonEventGroup.fromJson(Map<String, dynamic> json) {
final list = List.from(json["events"] ?? []);
final list = List<Map<String, dynamic>>.from(json["events"] ?? []);

final events = list.map(
(model) => GroupMember(event: ServerEvent.parseEvent(model)),
(model) {
return GroupMember(
event: ServerEvent.parseEvent(
model["event"],
),
);
},
);
return CommonEventGroup(events: events.toList());
}
Expand All @@ -141,41 +150,20 @@ final class SequencedEventGroup extends ServerEvent {
}) : super(type: "sequenced");

factory SequencedEventGroup.fromJson(Map<String, dynamic> json) {
final list = List.from(json["events"] ?? []);

final events = list.map((model) {
final delay = Duration(milliseconds: model["delay"] ?? 0);

return SequencedGroupMember(
event: ServerEvent.parseEvent(model["event"]),
delay: delay,
);
});
return SequencedEventGroup(events: events.toList());
}
}
final list = List<Map<String, dynamic>>.from(json["events"] ?? []);

final class AnimationTriggerEvent extends ServerEvent {
final AnimationCommand command;

AnimationTriggerEvent({
required this.command,
}) : super(type: "animationTrigger");

factory AnimationTriggerEvent.fromJson(Map<String, dynamic> json) {
return AnimationTriggerEvent(
command: AnimationCommand(
method: switch (json["method"]) {
0 => AnimationMethod.forward,
1 => AnimationMethod.repeat,
2 => AnimationMethod.reverse,
3 => AnimationMethod.toggle,
Object() || null => AnimationMethod.forward,
},
controllerId: json["controllerId"],
animatedPropKey: json["animatedPropKey"],
),
final events = list.map(
(model) {
final source = DuitDataSource(model);
final delay = source.duration(key: "delay");

return SequencedGroupMember(
event: ServerEvent.parseEvent(source["event"]),
delay: delay,
);
},
);
return SequencedEventGroup(events: events.toList());
}
}

Expand All @@ -189,9 +177,29 @@ final class TimerEvent extends ServerEvent {
}) : super(type: "timer");

factory TimerEvent.fromJson(Map<String, dynamic> json) {
final source = DuitDataSource(json);
return TimerEvent(
timerDelay: Duration(milliseconds: json["timerDelay"] ?? 0),
payload: ServerEvent.parseEvent(json["event"]),
timerDelay: source.duration(key: "timerDelay"),
payload: ServerEvent.parseEvent(source["event"]),
);
}
}

final class CommandEvent extends ServerEvent {
final RemoteCommand command;

const CommandEvent({
required this.command,
}) : super(type: "command");

factory CommandEvent.fromJson(Map<String, dynamic> json) {
final source = DuitDataSource(json);
return CommandEvent(
command: RemoteCommand(
controllerId: source.getString(key: "controllerId"),
type: source.getString(key: "type"),
payload: source["payload"] ?? const <String, dynamic>{},
),
);
}
Comment thread
lesleysin marked this conversation as resolved.
}
2 changes: 1 addition & 1 deletion lib/src/action_api/event_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ final class DefaultEventParser implements Parser<ServerEvent> {
"custom" => CustomEvent.fromJson(json),
"sequenced" => SequencedEventGroup.fromJson(json),
"grouped" => CommonEventGroup.fromJson(json),
"animationTrigger" => AnimationTriggerEvent.fromJson(json),
"timer" => TimerEvent.fromJson(json),
"command" => CommandEvent.fromJson(json),
String() || Object() || null => NullEvent(),
};
}
Expand Down
4 changes: 3 additions & 1 deletion lib/src/action_api/event_resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ final class DefaultEventResolver extends EventResolver {
await resolveEvent(context, entry.event);
}
break;
case AnimationTriggerEvent():
case CommandEvent():
final c = driver.getController(event.command.controllerId);
await c?.emitCommand(event.command);
break;
Expand All @@ -92,6 +92,8 @@ final class DefaultEventResolver extends EventResolver {
},
);
break;
default:
break;
}
} catch (e, s) {
logger?.error(
Expand Down
1 change: 0 additions & 1 deletion lib/src/action_api/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ export 'action_executor.dart';
export 'event.dart';
export 'event_resolver.dart';
export 'external_event_handler.dart';
export 'server_action_view.dart';
export 'event_parser.dart';
export 'action_parser.dart';
73 changes: 0 additions & 73 deletions lib/src/action_api/server_action_view.dart

This file was deleted.

2 changes: 2 additions & 0 deletions lib/src/animation_api/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ export 'method.dart';
export 'interval.dart';
export 'trigger.dart';
export 'command.dart';
export 'tween_description.dart';
export 'tween_type.dart';
Loading