Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 1 addition & 9 deletions .github/actions/setup-flutter/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,4 @@ runs:
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.32.6' # Set the desired Flutter version

- name: Install dependencies
run: flutter pub get
shell: bash

- name: Generate files
run: dart run build_runner build --delete-conflicting-outputs
shell: bash
flutter-version: '3.32.6' # Set the desired Flutter version
13 changes: 12 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,20 @@ jobs:

- name: Set up Flutter
uses: ./.github/actions/setup-flutter

- name: Install dependencies - Panda SVG
working-directory: ./panda_svg
run: flutter pub get
shell: bash

- name: Run tests
- name: Run tests - Panda SVG
working-directory: ./panda_svg
run: flutter test

- name: Install dependencies - Sample project
working-directory: ./sample
run: flutter pub get
shell: bash

- name: Analyze
run: dart analyze
39 changes: 0 additions & 39 deletions panda_svg/core/commander/panda_commander.dart

This file was deleted.

60 changes: 0 additions & 60 deletions panda_svg/core/panda_widget.dart

This file was deleted.

95 changes: 95 additions & 0 deletions panda_svg/test/core/commander/panda_commander_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import 'package:panda_svg/core/commander/command.dart';
import 'package:panda_svg/core/commander/panda_commander.dart';
import 'package:panda_svg/model/node_coordinate.dart';
import 'package:test/test.dart';

void main() {
late PandaCommander commander;

setUp(() {
commander = PandaCommander();
});

test('should emit correct JS for UpdateBackgroundColor', () async {
final command = UpdateBackgroundColor(
id: 'node1',
colorHex: '#FFFFFF',
);

expectLater(
commander.stream,
emits("updateBackgroundColor('node1','#FFFFFF');"),
);

commander.execute(command);
});

test('should emit correct JS for UpdateStrokeColor', () async {
final command = UpdateStrokeColor(
id: 'node2',
colorHex: '#000000',
);

expectLater(
commander.stream,
emits("updateStrokeColor('node2','#000000');"),
);

commander.execute(command);
});

test('should emit correct JS for UpdateStrokeWidth', () async {
final command = UpdateStrokeWidth(
id: 'node3',
widthInPx: 5,
);

expectLater(
commander.stream,
emits("updateStrokeWidth('node3',5);"),
);

commander.execute(command);
});

test('should emit correct JS for RemoveNode', () async {
final command = RemoveNode(id: 'node4');

expectLater(
commander.stream,
emits("removeNode('node4');"),
);

commander.execute(command);
});

test('should emit correct JS for UpdateRootBackgroundColor', () async {
final command = UpdateRootBackgroundColor(colorInHex: '#ABCDEF');

expectLater(
commander.stream,
emits("updateRootBackgroundColor('#ABCDEF');"),
);

commander.execute(command);
});

test('should emit correct JS for AddRoundedImage', () async {
final command = AddRoundedImage(
elementId: 'container',
imageId: 'img1',
imageUrl: 'http://example.com/image.png',
widthInPx: 100,
heightInPx: 200,
coordinate: NodeCoordinate(x: 50, y: 75),
);

expectLater(
commander.stream,
emits("addRoundedImage('container','img1','http://example.com/image.png',"
"'100','200','50.0','75.0');"),
);

commander.execute(command);
});
}
5 changes: 0 additions & 5 deletions sample/lib/sample_app.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:panda_svg/core/commander/command.dart';
import 'package:panda_svg/core/commander/panda_commander.dart';
import 'package:panda_svg/core/panda_widget.dart';
import 'package:panda_svg/model/node_info.dart';
Expand Down Expand Up @@ -61,10 +60,6 @@ class _SampleAppState extends State<SampleApp> {
);
}

void _onClick() {
widget.commander.execute(UpdateRootBackgroundColor(colorInHex: '#008000'));
}

_updateSelectedNode(NodeInfo nodeInfo) {
setState(() {
bottomSheetUiModels = SampleCommandsGenerator.generate(nodeInfo);
Expand Down
6 changes: 3 additions & 3 deletions sample/lib/widgets/commands_bottom_sheet_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import 'package:flutter/material.dart';
import 'package:sampleapp/widgets/bottom_sheet_ui_model.dart';

class CommandsBottomSheetWidget extends StatefulWidget {
List<BottomSheetUiModel> uiModels;
Function(CommandUiModel) onSelectCommand;
final List<BottomSheetUiModel> uiModels;
final Function(CommandUiModel) onSelectCommand;

CommandsBottomSheetWidget({
const CommandsBottomSheetWidget({
super.key,
required this.uiModels,
required this.onSelectCommand,
Expand Down