Skip to content

Commit

Permalink
v0.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanblake4 committed Oct 23, 2022
1 parent ca0bca0 commit 055203e
Show file tree
Hide file tree
Showing 14 changed files with 444 additions and 30 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.5.3
- Add Decoration, BoxDecoration, BoxBorder, Border, and BorderSide
- Improve support for Container and TextField
- Update example to use super constructor params

## 0.5.2
- Fix Flutter 3.0 incompatibility

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ Currently supported widgets and classes include:
- `Color`, `ColorSwatch`, `Colors`, `FontWeight`, `FontStyle`;
- `MaterialApp`, `MaterialColor`, `MaterialAccentColor`;
- `Theme`, `ThemeData`, `TextTheme`;
- `Decoration`, `BoxDecoration`, `BoxBorder`, `Border`, `BorderSide`;
- `IconData`, `Icons`, `Icon`;
- `Curve`, `Curves`, `SawTooth`, `Interval`, `Threshold`, `Cubic`;
- `Text`, `TextStyle`, `TextEditingController`, `TextField`;
Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class EvalExample extends StatelessWidget {
import 'package:flutter/material.dart';
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});
// This widget is the root of your application.
@override
Expand Down
22 changes: 20 additions & 2 deletions lib/flutter_eval.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ import 'package:flutter_eval/src/material/theme_data.dart';
import 'package:flutter_eval/src/painting.dart';
import 'package:flutter_eval/src/painting/alignment.dart';
import 'package:flutter_eval/src/painting/basic_types.dart';
import 'package:flutter_eval/src/painting/borders.dart';
import 'package:flutter_eval/src/painting/box_border.dart';
import 'package:flutter_eval/src/painting/box_decoration.dart';
import 'package:flutter_eval/src/painting/colors.dart';
import 'package:flutter_eval/src/painting/decoration.dart';
import 'package:flutter_eval/src/painting/edge_insets.dart';
import 'package:flutter_eval/src/painting/text_style.dart';
import 'package:flutter_eval/src/rendering.dart';
Expand Down Expand Up @@ -128,7 +132,12 @@ class FlutterEvalPlugin implements EvalPlugin {
$ElasticInOutCurve.$declaration,
$Size.$declaration,
$IconData.$declaration,
$Icon.$declaration
$Icon.$declaration,
$Decoration.$declaration,
$BoxDecoration.$declaration,
$BorderSide.$declaration,
$BoxBorder.$declaration,
$Border.$declaration,
];

compiler.defineBridgeClasses(classes);
Expand All @@ -142,6 +151,7 @@ class FlutterEvalPlugin implements EvalPlugin {
compiler.defineBridgeEnum($VerticalDirection.$declaration);
compiler.defineBridgeEnum($TextBaseline.$declaration);
compiler.defineBridgeEnum($Axis.$declaration);
compiler.defineBridgeEnum($BorderStyle.$declaration);

compiler.addSource(DartSource('dart:ui', dartUiSource));

Expand Down Expand Up @@ -174,7 +184,8 @@ class FlutterEvalPlugin implements EvalPlugin {
$TextDirection.$declaration.toJson(),
$VerticalDirection.$declaration.toJson(),
$TextBaseline.$declaration.toJson(),
$Axis.$declaration.toJson()
$Axis.$declaration.toJson(),
$BorderStyle.$declaration.toJson(),
],
'sources': [
{'uri': 'dart:ui', 'source': dartUiSource},
Expand Down Expand Up @@ -230,6 +241,13 @@ class FlutterEvalPlugin implements EvalPlugin {
'package:flutter/src/painting/edge_insets.dart', 'EdgeInsets.fromLTRB', $EdgeInsets.$fromLTRB)
..registerBridgeFunc('package:flutter/src/painting/edge_insets.dart', 'EdgeInsets.all', $EdgeInsets.$all)
..registerBridgeFunc('package:flutter/src/painting/edge_insets.dart', 'EdgeInsets.only', $EdgeInsets.$only)
..registerBridgeFunc('package:flutter/src/painting/borders.dart', 'BorderSide.', $BorderSide.$new)
..registerBridgeFunc('package:flutter/src/painting/box_border.dart', 'Border.', $Border.$new)
..registerBridgeFunc('package:flutter/src/painting/box_border.dart', 'Border.all', $Border.$all)
..registerBridgeFunc(
'package:flutter/src/painting/box_border.dart', 'Border.fromBorderSide', $Border.$fromBorderSide)
..registerBridgeFunc('package:flutter/src/painting/box_border.dart', 'Border.symmetric', $Border.$symmetric)
..registerBridgeFunc('package:flutter/src/painting/box_decoration.dart', 'BoxDecoration.', $BoxDecoration.$new)
..registerBridgeFunc(
'package:flutter/src/painting/edge_insets.dart', 'EdgeInsets.symmetric', $EdgeInsets.$symmetric)
..registerBridgeFunc('package:flutter/src/painting/text_style.dart', 'TextStyle.', $TextStyle.$new)
Expand Down
39 changes: 24 additions & 15 deletions lib/src/material/text_field.dart
Original file line number Diff line number Diff line change
@@ -1,34 +1,43 @@
import 'package:dart_eval/dart_eval.dart';
import 'package:dart_eval/dart_eval_bridge.dart';
import 'package:dart_eval/stdlib/core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_eval/src/painting/text_style.dart';
import 'package:flutter_eval/src/widgets/editable_text.dart';
import 'package:flutter_eval/src/widgets/framework.dart';

class $TextField implements $Instance {
static const $type = BridgeTypeRef.spec(BridgeTypeSpec('package:flutter/src/material/text_field.dart', 'TextField'));

static const $declaration =
BridgeClassDef(BridgeClassType($type, isAbstract: false, $extends: $StatefulWidget$bridge.$type),
constructors: {
'': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), namedParams: [
BridgeParameter('controller', BridgeTypeAnnotation($TextEditingController.$type), true),
BridgeParameter('enabled', BridgeTypeAnnotation(BridgeTypeRef.type(RuntimeTypes.boolType)), true),
BridgeParameter('onChanged', BridgeTypeAnnotation(BridgeTypeRef.type(RuntimeTypes.functionType)), true),
]))
},
methods: {},
getters: {},
setters: {},
fields: {},
wrap: true);
static const $declaration = BridgeClassDef(
BridgeClassType($type, isAbstract: false, $extends: $StatefulWidget$bridge.$type),
constructors: {
'': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), namedParams: [
BridgeParameter('controller', BridgeTypeAnnotation($TextEditingController.$type, nullable: true), true),
BridgeParameter(
'enabled', BridgeTypeAnnotation(BridgeTypeRef.type(RuntimeTypes.boolType), nullable: true), true),
BridgeParameter('style', BridgeTypeAnnotation($TextStyle.$type, nullable: true), true),
BridgeParameter(
'onChanged', BridgeTypeAnnotation(BridgeTypeRef.type(RuntimeTypes.functionType), nullable: true), true),
BridgeParameter(
'onSubmitted', BridgeTypeAnnotation(BridgeTypeRef.type(RuntimeTypes.functionType), nullable: true), true),
]))
},
methods: {},
getters: {},
setters: {},
fields: {},
wrap: true);

$TextField.wrap(this.$value);

static $Value? $new(Runtime runtime, $Value? target, List<$Value?> args) {
return $TextField.wrap(TextField(
controller: args[0]?.$value,
enabled: args[1]?.$value,
onChanged: args[2]?.$value,
style: args[2]?.$value,
onChanged: args[3] == null ? null : (value) => (args[3]! as EvalCallable).call(runtime, null, [$String(value)]),
onSubmitted: args[4] == null ? null : (value) => (args[4]! as EvalCallable).call(runtime, null, [$String(value)]),
));
}

Expand Down
4 changes: 4 additions & 0 deletions lib/src/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ library painting;
export 'package:flutter/src/painting/alignment.dart';
export 'package:flutter/src/painting/basic_types.dart';
export 'package:flutter/src/painting/borders.dart';
export 'package:flutter/src/painting/box_border.dart';
export 'package:flutter/src/painting/box_decoration.dart';
export 'package:flutter/src/painting/decoration.dart';
export 'package:flutter/src/painting/edge_insets.dart';
export 'package:flutter/src/painting/text_style.dart';
''';
115 changes: 115 additions & 0 deletions lib/src/painting/borders.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import 'package:dart_eval/dart_eval.dart';
import 'package:dart_eval/dart_eval_bridge.dart';
import 'package:dart_eval/stdlib/core.dart';
import 'package:flutter/painting.dart';
import 'package:flutter_eval/src/sky_engine/ui/painting.dart';

class $BorderStyle implements $Instance {
static const $type = BridgeTypeRef.spec(BridgeTypeSpec('package:flutter/src/painting/borders.dart', 'BorderStyle'));

static const $declaration =
BridgeEnumDef($type, values: ['solid', 'none'], methods: {}, getters: {}, setters: {}, fields: {});

static final $values = BorderStyle.values.asNameMap().map((key, value) => MapEntry(key, $BorderStyle.wrap(value)));

final $Instance _superclass;

$BorderStyle.wrap(this.$value) : _superclass = $Object($value);

@override
final BorderStyle $value;

@override
BorderStyle get $reified => $value;

@override
$Value? $getProperty(Runtime runtime, String identifier) {
return _superclass.$getProperty(runtime, identifier);
}

@override
int get $runtimeType => throw UnimplementedError();

@override
void $setProperty(Runtime runtime, String identifier, $Value value) {
return _superclass.$setProperty(runtime, identifier, value);
}
}

class $ShapeBorder implements $Instance {
static const $type = BridgeTypeRef.spec(BridgeTypeSpec('package:flutter/src/painting/borders.dart', 'ShapeBorder'));

static const $declaration = BridgeClassDef(BridgeClassType($type, isAbstract: true),
constructors: {}, methods: {}, getters: {}, setters: {}, fields: {}, wrap: true);

$ShapeBorder.wrap(this.$value) : _superclass = $Object($value);

final $Instance _superclass;

@override
final ShapeBorder $value;

@override
get $reified => $value;

@override
int get $runtimeType => throw UnimplementedError();

@override
$Value? $getProperty(Runtime runtime, String identifier) {
return _superclass.$getProperty(runtime, identifier);
}

@override
void $setProperty(Runtime runtime, String identifier, $Value value) {
_superclass.$setProperty(runtime, identifier, value);
}
}

class $BorderSide implements $Instance {
static const $type = BridgeTypeRef.spec(BridgeTypeSpec('package:flutter/src/painting/borders.dart', 'BorderSide'));

static const $declaration = BridgeClassDef(BridgeClassType($type, isAbstract: false),
constructors: {
'': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), namedParams: [
BridgeParameter('color', BridgeTypeAnnotation($Color.$type), true),
BridgeParameter('width', BridgeTypeAnnotation(BridgeTypeRef.type(RuntimeTypes.doubleType)), true),
BridgeParameter('style', BridgeTypeAnnotation($BorderStyle.$type), true)
]))
},
methods: {},
getters: {},
setters: {},
fields: {},
wrap: true);

$BorderSide.wrap(this.$value) : _superclass = $Object($value);

final $Instance _superclass;

@override
final BorderSide $value;

@override
get $reified => $value;

@override
int get $runtimeType => throw UnimplementedError();

static $Value? $new(Runtime runtime, $Value? target, List<$Value?> args) {
return $BorderSide.wrap(BorderSide(
color: args[0]?.$value ?? const Color(0xFF000000),
width: args[1]?.$value ?? 1.0,
style: args[2]?.$value ?? BorderStyle.solid));
}

@override
$Value? $getProperty(Runtime runtime, String identifier) {
return _superclass.$getProperty(runtime, identifier);
}

@override
void $setProperty(Runtime runtime, String identifier, $Value value) {
_superclass.$setProperty(runtime, identifier, value);
}
}
119 changes: 119 additions & 0 deletions lib/src/painting/box_border.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import 'package:dart_eval/dart_eval.dart';
import 'package:dart_eval/dart_eval_bridge.dart';
import 'package:flutter/painting.dart';
import 'package:flutter_eval/src/painting/borders.dart';
import 'package:flutter_eval/src/sky_engine/ui/painting.dart';

class $BoxBorder implements $Instance {
static const $type = BridgeTypeRef.spec(BridgeTypeSpec('package:flutter/src/painting/box_border.dart', 'BoxBorder'));

static const $declaration = BridgeClassDef(BridgeClassType($type, isAbstract: true),
constructors: {}, methods: {}, getters: {}, setters: {}, fields: {}, wrap: true);

$BoxBorder.wrap(this.$value) : _superclass = $ShapeBorder.wrap($value);

final $Instance _superclass;

@override
final ShapeBorder $value;

@override
get $reified => $value;

@override
int get $runtimeType => throw UnimplementedError();

@override
$Value? $getProperty(Runtime runtime, String identifier) {
return _superclass.$getProperty(runtime, identifier);
}

@override
void $setProperty(Runtime runtime, String identifier, $Value value) {
_superclass.$setProperty(runtime, identifier, value);
}
}

class $Border implements $Instance {
static const $type = BridgeTypeRef.spec(BridgeTypeSpec('package:flutter/src/painting/box_border.dart', 'Border'));

static const $declaration = BridgeClassDef(BridgeClassType($type, isAbstract: false),
constructors: {
'': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), namedParams: [
BridgeParameter('top', BridgeTypeAnnotation($BorderSide.$type), true),
BridgeParameter('right', BridgeTypeAnnotation($BorderSide.$type), true),
BridgeParameter('bottom', BridgeTypeAnnotation($BorderSide.$type), true),
BridgeParameter('left', BridgeTypeAnnotation($BorderSide.$type), true)
])),
'all': BridgeConstructorDef(
BridgeFunctionDef(returns: BridgeTypeAnnotation($type), namedParams: [
BridgeParameter('color', BridgeTypeAnnotation($Color.$type), true),
BridgeParameter('width', BridgeTypeAnnotation(BridgeTypeRef.type(RuntimeTypes.doubleType)), true),
BridgeParameter('style', BridgeTypeAnnotation($BorderStyle.$type), true)
]),
isFactory: true),
'fromBorderSide': BridgeConstructorDef(BridgeFunctionDef(
returns: BridgeTypeAnnotation($type),
namedParams: [BridgeParameter('side', BridgeTypeAnnotation($BorderSide.$type), true)])),
'symmetric': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), namedParams: [
BridgeParameter('vertical', BridgeTypeAnnotation($BorderSide.$type), true),
BridgeParameter('horizontal', BridgeTypeAnnotation($BorderSide.$type), true)
]))
},
methods: {},
getters: {},
setters: {},
fields: {},
wrap: true);

$Border.wrap(this.$value) : _superclass = $BoxBorder.wrap($value);

final $Instance _superclass;

static $Value? $new(Runtime runtime, $Value? target, List<$Value?> args) {
return $Border.wrap(Border(
top: args[0]?.$value ?? BorderSide.none,
right: args[1]?.$value ?? BorderSide.none,
bottom: args[2]?.$value ?? BorderSide.none,
left: args[3]?.$value ?? BorderSide.none,
));
}

static $Value? $all(Runtime runtime, $Value? target, List<$Value?> args) {
return $Border.wrap(Border.all(
color: args[0]?.$value ?? const Color(0xFF000000),
width: args[1]?.$value ?? 1.0,
style: args[2]?.$value ?? BorderStyle.solid,
));
}

static $Value? $fromBorderSide(Runtime runtime, $Value? target, List<$Value?> args) {
return $Border.wrap(Border.fromBorderSide(args[0]?.$value ?? BorderSide.none));
}

static $Value? $symmetric(Runtime runtime, $Value? target, List<$Value?> args) {
return $Border.wrap(Border.symmetric(
vertical: args[0]?.$value ?? BorderSide.none,
horizontal: args[1]?.$value ?? BorderSide.none,
));
}

@override
final Border $value;

@override
Border get $reified => $value;

@override
int get $runtimeType => throw UnimplementedError();

@override
$Value? $getProperty(Runtime runtime, String identifier) {
return _superclass.$getProperty(runtime, identifier);
}

@override
void $setProperty(Runtime runtime, String identifier, $Value value) {
_superclass.$setProperty(runtime, identifier, value);
}
}
Loading

0 comments on commit 055203e

Please sign in to comment.