Skip to content

Commit

Permalink
Merge pull request #28 from robiness/clean_up
Browse files Browse the repository at this point in the history
  • Loading branch information
robiness authored Nov 7, 2023
2 parents 5c85b52 + 12c55f9 commit adf0e96
Show file tree
Hide file tree
Showing 28 changed files with 259 additions and 229 deletions.
11 changes: 8 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import 'package:example/stage_data/my_widget_stage.dart';
import 'package:example/stage_data/string_list_configurator_stage_data.dart';
import 'package:flutter/material.dart';
import 'package:stage_craft/stage_craft.dart';

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
class MyApp extends StatefulWidget {
const MyApp({super.key});

@override
State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
Expand All @@ -17,7 +22,7 @@ class MyApp extends StatelessWidget {
debugShowCheckedModeBanner: false,
home: Scaffold(
body: StageCraft(
stageData: MyWidgetStageData(),
stageData: StringListConfiguratorStageData(),
),
),
);
Expand Down
4 changes: 2 additions & 2 deletions example/lib/my_widget_stage.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:example/stage_data/my_widget_stage.dart';
import 'package:example/stage_data/bool_field_configurator_stage_data.dart';
import 'package:flutter/material.dart';
import 'package:stage_craft/stage_craft.dart';
import 'package:window_manager/window_manager.dart';
Expand All @@ -25,7 +25,7 @@ Future<void> main() async {
MaterialApp(
home: Scaffold(
body: StageCraft(
stageData: MyWidgetStageData(),
stageData: BoolFieldConfiguratorStageData(),
),
),
),
Expand Down
25 changes: 25 additions & 0 deletions example/lib/stage_data/bool_field_configurator_stage_data.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'package:flutter/widgets.dart';
import 'package:stage_craft/stage_craft.dart';

class BoolFieldConfiguratorStageData extends StageData {
@override
String get name => 'BoolFieldConfiguration';

final value = BoolFieldConfigurator(value: true, name: 'value');

@override
List<FieldConfigurator> get stageConfigurators => [];

@override
List<FieldConfigurator> get widgetConfigurators => [value];

@override
Widget widgetBuilder(BuildContext context) {
return BoolConfigurationWidget(
value: value.value,
updateValue: (value) {
this.value.value = value!;
},
);
}
}
25 changes: 25 additions & 0 deletions example/lib/stage_data/color_field_configurator_stage_data.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'package:flutter/widgets.dart';
import 'package:stage_craft/stage_craft.dart';

class ColorFieldConfiguratorStageData extends StageData {
@override
String get name => 'ColorFieldConfiguration';

final value = ColorFieldConfigurator(value: const Color(0xFF000000), name: 'value');

@override
List<FieldConfigurator> get stageConfigurators => [];

@override
List<FieldConfigurator> get widgetConfigurators => [value];

@override
Widget widgetBuilder(BuildContext context) {
return ColorConfigurationWidget(
value: value.value,
updateValue: (value) {
this.value.value = value!;
},
);
}
}
54 changes: 0 additions & 54 deletions example/lib/stage_data/my_widget_stage.dart

This file was deleted.

22 changes: 22 additions & 0 deletions example/lib/stage_data/string_list_configurator_stage_data.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:flutter/material.dart';
import 'package:stage_craft/stage_craft.dart';

class StringListConfiguratorStageData extends StageData {
final value = StringListConfigurator(value: ['jo', 'jojo2', 'jojojo'], name: 'value');

@override
String get name => 'StringListConfigurator';

@override
List<FieldConfigurator> get stageConfigurators => [];

@override
List<FieldConfigurator> get widgetConfigurators => [
value,
];

@override
Widget widgetBuilder(BuildContext context) {
return StringListConfiguratorWidget(configurator: value);
}
}
61 changes: 0 additions & 61 deletions example/lib/widgets/my_widget.dart

This file was deleted.

16 changes: 16 additions & 0 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.5.1"
typed_data:
dependency: transitive
description:
name: typed_data
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
url: "https://pub.dev"
source: hosted
version: "1.3.2"
universal_io:
dependency: transitive
description:
name: universal_io
sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad"
url: "https://pub.dev"
source: hosted
version: "2.2.2"
vector_math:
dependency: transitive
description:
Expand Down
6 changes: 3 additions & 3 deletions example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:example/stage_data/my_widget_stage.dart';
import 'package:example/stage_data/bool_field_configurator_stage_data.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:stage_craft/stage_craft.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
await tester.pumpWidgetData(MyWidgetStageData());
await tester.pumpWidgetData(BoolFieldConfiguratorStageData());
expect(find.text('MyOtherWidget'), findsOneWidget);
});
}

extension WidgetTesterExtension on WidgetTester {
Future<void> pumpWidgetData(
WidgetStageData stageData,
StageData stageData,
) async {
await pumpWidget(
MaterialApp(
Expand Down
8 changes: 4 additions & 4 deletions lib/src/field_configurators/bool_field_configurator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class BoolFieldConfiguratorNullable extends FieldConfigurator<bool?> {

@override
Widget build(BuildContext context) {
return BoolFieldConfigurationWidget(
return BoolConfigurationWidget(
value: value,
updateValue: updateValue,
);
Expand All @@ -25,7 +25,7 @@ class BoolFieldConfigurator extends FieldConfigurator<bool> {

@override
Widget build(BuildContext context) {
return BoolFieldConfigurationWidget(
return BoolConfigurationWidget(
value: value,
updateValue: (value) {
updateValue(value ?? false);
Expand All @@ -34,8 +34,8 @@ class BoolFieldConfigurator extends FieldConfigurator<bool> {
}
}

class BoolFieldConfigurationWidget extends ConfigurationWidget<bool?> {
const BoolFieldConfigurationWidget({
class BoolConfigurationWidget extends ConfigurationWidget<bool?> {
const BoolConfigurationWidget({
required super.value,
required super.updateValue,
});
Expand Down
43 changes: 20 additions & 23 deletions lib/src/field_configurators/color_field_configurator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,27 @@ class ColorConfigurationWidget extends ConfigurationWidget<Color?> {
},
);
},
child: Align(
alignment: Alignment.centerRight,
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Container(
height: 38,
width: 38,
foregroundDecoration: BoxDecoration(
// The actual color drawn over the chessboard pattern
color: value,
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Container(
height: 38,
width: 38,
foregroundDecoration: BoxDecoration(
// The actual color drawn over the chessboard pattern
color: value,
),
// The chessboard pattern
child: const CustomPaint(
foregroundPainter: ChessBoardPainter(
boxSize: 8,
// The color of the chessboard pattern
color: Colors.grey,
),
// The chessboard pattern
child: const CustomPaint(
foregroundPainter: ChessBoardPainter(
boxSize: 8,
// The color of the chessboard pattern
color: Colors.grey,
),
child: ColoredBox(
// Background of the chessboard pattern
color: Colors.white,
),
child: ColoredBox(
// Background of the chessboard pattern
color: Colors.white,
),
),
),
Expand Down
Loading

0 comments on commit adf0e96

Please sign in to comment.