Skip to content
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
5 changes: 2 additions & 3 deletions examples/stac_gallery/bin/stac_cli.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:stac_models/stac_models.dart';
import 'package:stac_models/types/stac_border/stac_border.dart';
import 'package:stac_models/types/stac_double.dart';
import 'package:stac_models/types/stac_text_types.dart';

final double fontSize = 20;
Expand All @@ -19,8 +18,8 @@ StacWidget homeScreen() {
),
body: StacCenter(
child: StacContainer(
width: StacDouble(200),
height: StacDouble(200),
width: 200,
height: 200,
decoration: StacBoxDecoration(
color: StacColors.red,
border: StacBorder(
Expand Down
23 changes: 13 additions & 10 deletions examples/stac_gallery/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'package:flutter/material.dart';
import 'package:stac/stac.dart' show Stac;
import 'package:stac_gallery/app/example/example_screen_parser.dart';
import 'package:stac_models/core/stac_model.dart';
import 'package:stac_models/painting/painting.dart';
import 'package:stac_models/painting/stac_color/stac_colors.dart';
import 'package:stac_models/types/stac_double.dart';
import 'package:stac_models/widgets/widgets.dart';
import 'package:stac_webview/stac_webview.dart';

Expand Down Expand Up @@ -52,16 +52,19 @@ StacWidget homeScreen() {
data: 'STAC dede',
),
),
body: StacCenter(
child: StacContainer(
body: StacColumn(
children: [
StacContainer(
width: double.infinity,
color: StacColors.blue,
width: StacDouble(100.0),
height: StacDouble(100.0),
child: StacCenter(
child: StacText(
data: 'Hello, World!',
),
)),
child: StacText(data: 'Hello, World!'),
),
StacContainer(
width: double.infinity,
color: StacColors.red,
child: StacText(data: 'Hello, World!'),
),
],
),
);
}
Expand Down
5 changes: 2 additions & 3 deletions examples/stac_gallery/stac/home_screen.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import 'package:stac_models/stac_models.dart';
import 'package:stac_models/types/stac_double.dart';
import 'package:stac_models/types/stac_text_types.dart';

StacWidget homeScreen() {
return StacScaffold(
body: StacCenter(
child: StacContainer(
width: StacDouble(200.0),
height: StacDouble(200.0),
width: 200,
height: 200,
decoration: StacBoxDecoration(
color: StacColors.pink,
),
Expand Down
2 changes: 2 additions & 0 deletions packages/stac/lib/src/framework/stac.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ class Stac {
StacRegistry.instance,
);
}

Log.d(resolvedJson);
final model = stacParser.getModel(resolvedJson);

return stacParser.parse(context, model);
Expand Down
41 changes: 20 additions & 21 deletions packages/stac/lib/src/parsers/types/type_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import 'package:stac_models/types/stac_box_shadow/stac_box_shadow.dart';
import 'package:stac_models/types/stac_box_shape.dart';
import 'package:stac_models/types/stac_clip.dart';
import 'package:stac_models/types/stac_cross_axis_alignment.dart';
import 'package:stac_models/types/stac_double.dart';
import 'package:stac_models/types/stac_drag_start_behavior.dart';
import 'package:stac_models/types/stac_filter_quality.dart';
import 'package:stac_models/types/stac_floating_action_button_location.dart';
Expand Down Expand Up @@ -330,24 +329,24 @@ extension StacRectParser on StacRect {
Rect? get parse {
Rect fromCenter() => Rect.fromCenter(
center: center?.parse ?? Offset.zero,
width: width?.parse ?? 0.0,
height: height?.parse ?? 0.0,
width: width ?? 0.0,
height: height ?? 0.0,
);
Rect fromCircle() => Rect.fromCircle(
center: center?.parse ?? Offset.zero,
radius: radius?.parse ?? 0.0,
radius: radius ?? 0.0,
);
Rect fromLTRB() => Rect.fromLTRB(
left?.parse ?? 0.0,
top?.parse ?? 0.0,
right?.parse ?? 0.0,
bottom?.parse ?? 0.0,
left ?? 0.0,
top ?? 0.0,
right ?? 0.0,
bottom ?? 0.0,
);
Rect fromLTWH() => Rect.fromLTWH(
left?.parse ?? 0.0,
top?.parse ?? 0.0,
width?.parse ?? 0.0,
height?.parse ?? 0.0,
left ?? 0.0,
top ?? 0.0,
width ?? 0.0,
height ?? 0.0,
);
Rect fromPoints() => Rect.fromPoints(
a?.parse ?? Offset.zero,
Expand Down Expand Up @@ -462,9 +461,9 @@ extension StacBoxShadowParser on StacBoxShadow {
BoxShadow parse(BuildContext context) {
return BoxShadow(
color: color.toColor(context) ?? const Color(0xFF000000),
blurRadius: blurRadius?.parse ?? 0.0,
blurRadius: blurRadius ?? 0.0,
offset: offset?.parse ?? Offset.zero,
spreadRadius: spreadRadius?.parse ?? 0.0,
spreadRadius: spreadRadius ?? 0.0,
blurStyle: blurStyle?.parse ?? BlurStyle.normal,
);
}
Expand Down Expand Up @@ -517,13 +516,13 @@ extension StacGradientParser on StacGradient {
colors: colors?.map((e) => e.toColor(context)!).toList() ?? [],
begin: begin?.parse ?? Alignment.centerLeft,
end: end?.parse ?? Alignment.centerRight,
stops: stops?.map((e) => e.parse).toList().toList(),
stops: stops,
tileMode: tileMode?.parse ?? TileMode.clamp,
);

Gradient radialGradient() => RadialGradient(
colors: colors?.map((e) => e.toColor(context)!).toList() ?? [],
stops: stops?.map((e) => e.parse).toList().toList(),
stops: stops,
tileMode: tileMode?.parse ?? TileMode.clamp,
focal: focal?.parse,
focalRadius: focalRadius ?? 0.0,
Expand All @@ -533,7 +532,7 @@ extension StacGradientParser on StacGradient {

Gradient sweepGradient() => SweepGradient(
colors: colors?.map((e) => e.toColor(context)!).toList() ?? [],
stops: stops?.map((e) => e.parse).toList().toList(),
stops: stops,
center: center?.parse ?? Alignment.center,
startAngle: startAngle ?? 0.0,
endAngle: endAngle ?? math.pi * 2,
Expand All @@ -556,10 +555,10 @@ extension StacGradientParser on StacGradient {
extension StacBoxConstraintsParser on StacBoxConstraints {
BoxConstraints get parse {
return BoxConstraints(
minWidth: minWidth.parse,
maxWidth: maxWidth.parse,
minHeight: minHeight.parse,
maxHeight: maxHeight.parse,
minWidth: minWidth ?? 0.0,
maxWidth: maxWidth ?? double.infinity,
minHeight: minHeight ?? 0.0,
maxHeight: maxHeight ?? double.infinity,
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:stac/src/parsers/core/stac_widget_parser.dart';
import 'package:stac/src/utils/widget_type.dart';
import 'package:stac_framework/stac_framework.dart';
import 'package:stac_models/types/stac_double.dart';
import 'package:stac_models/widgets/center/stac_center.dart';

class StacCenterParser extends StacParser<StacCenter> {
Expand All @@ -17,8 +16,8 @@ class StacCenterParser extends StacParser<StacCenter> {
@override
Widget parse(BuildContext context, StacCenter model) {
return Center(
widthFactor: model.widthFactor?.parse,
heightFactor: model.heightFactor?.parse,
widthFactor: model.widthFactor,
heightFactor: model.heightFactor,
child: model.child?.parse(context),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:stac/src/parsers/core/stac_widget_parser.dart';
import 'package:stac/src/parsers/types/type_parser.dart';
import 'package:stac_framework/stac_framework.dart';
import 'package:stac_models/stac_models.dart';
import 'package:stac_models/types/stac_double.dart';

class StacColumnParser extends StacParser<StacColumn> {
const StacColumnParser();
Expand All @@ -25,7 +24,7 @@ class StacColumnParser extends StacParser<StacColumn> {
textDirection: model.textDirection?.parse,
verticalDirection:
model.verticalDirection?.parse ?? VerticalDirection.down,
spacing: model.spacing?.parse ?? 0.0,
spacing: model.spacing ?? 0,
children: model.children.parseList(context) ?? [],
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:stac/src/parsers/types/type_parser.dart';
import 'package:stac/src/utils/widget_type.dart';
import 'package:stac/stac.dart';
import 'package:stac_models/stac_models.dart';
import 'package:stac_models/types/stac_double.dart';

class StacContainerParser extends StacParser<StacContainer> {
const StacContainerParser();
Expand All @@ -26,8 +25,8 @@ class StacContainerParser extends StacParser<StacContainer> {
color: model.color.toColor(context),
decoration: model.decoration?.parse(context),
foregroundDecoration: model.foregroundDecoration?.parse(context),
width: model.width?.parse,
height: model.height?.parse,
width: model.width,
height: model.height,
constraints: model.constraints?.parse,
margin: model.margin?.parse,
transformAlignment: model.transformAlignment?.parse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:flutter_svg/svg.dart';
import 'package:stac/src/parsers/types/type_parser.dart';
import 'package:stac/src/utils/widget_type.dart';
import 'package:stac/stac.dart';
import 'package:stac_models/types/stac_double.dart';
import 'package:stac_models/types/stac_image_type.dart';
import 'package:stac_models/widgets/image/stac_image.dart';

Expand Down Expand Up @@ -41,8 +40,8 @@ class StacImageParser extends StacParser<StacImage> {
colorFilter: model.color != null
? ColorFilter.mode(model.color.toColor(context)!, BlendMode.srcIn)
: null,
width: model.width?.parse,
height: model.height?.parse,
width: model.width,
height: model.height,
fit: model.fit?.parse ?? BoxFit.contain,
errorBuilder: (context, error, stackTrace) {
return const SizedBox();
Expand All @@ -53,8 +52,8 @@ class StacImageParser extends StacParser<StacImage> {
imageUrl: model.src,
alignment: model.alignment?.parse ?? Alignment.center,
color: model.color?.toColor(context),
width: model.width?.parse,
height: model.height?.parse,
width: model.width,
height: model.height,
fit: model.fit?.parse ?? BoxFit.contain,
errorWidget: (context, error, stackTrace) {
return const SizedBox();
Expand All @@ -69,8 +68,8 @@ class StacImageParser extends StacParser<StacImage> {
File(model.src),
alignment: model.alignment?.parse ?? Alignment.center,
color: model.color?.toColor(context),
width: model.width?.parse,
height: model.height?.parse,
width: model.width,
height: model.height,
fit: model.fit?.parse ?? BoxFit.contain,
errorBuilder: (context, error, stackTrace) {
return const SizedBox();
Expand All @@ -83,8 +82,8 @@ class StacImageParser extends StacParser<StacImage> {
colorFilter: model.color != null
? ColorFilter.mode(model.color.toColor(context)!, BlendMode.srcIn)
: null,
width: model.width?.parse,
height: model.height?.parse,
width: model.width,
height: model.height,
fit: model.fit?.parse ?? BoxFit.contain,
errorBuilder: (context, error, stackTrace) {
return const SizedBox();
Expand All @@ -99,8 +98,8 @@ class StacImageParser extends StacParser<StacImage> {
model.src,
alignment: model.alignment?.parse ?? Alignment.center,
color: model.color?.toColor(context),
width: model.width?.parse,
height: model.height?.parse,
width: model.width,
height: model.height,
fit: model.fit?.parse ?? BoxFit.contain,
errorBuilder: (context, error, stackTrace) {
return const SizedBox();
Expand All @@ -113,8 +112,8 @@ class StacImageParser extends StacParser<StacImage> {
colorFilter: model.color != null
? ColorFilter.mode(model.color.toColor(context)!, BlendMode.srcIn)
: null,
width: model.width?.parse,
height: model.height?.parse,
width: model.width,
height: model.height,
fit: model.fit?.parse ?? BoxFit.contain,
errorBuilder: (context, error, stackTrace) {
return const SizedBox();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:stac/src/parsers/types/type_parser.dart';
import 'package:stac/src/utils/widget_type.dart';
import 'package:stac/stac.dart';
import 'package:stac_logger/stac_logger.dart';
import 'package:stac_models/types/stac_double.dart';
import 'package:stac_models/types/stac_image_type.dart';
import 'package:stac_models/widgets/image/stac_image.dart';

Expand Down Expand Up @@ -40,8 +39,8 @@ class StacImageParser extends StacParser<StacImage> {
colorFilter: model.color != null
? ColorFilter.mode(model.color.toColor(context)!, BlendMode.srcIn)
: null,
width: model.width?.parse,
height: model.height?.parse,
width: model.width,
height: model.height,
fit: model.fit?.parse ?? BoxFit.contain,
errorBuilder: (context, error, stackTrace) {
return const SizedBox();
Expand All @@ -52,8 +51,8 @@ class StacImageParser extends StacParser<StacImage> {
model.src,
alignment: model.alignment?.parse ?? Alignment.center,
color: model.color?.toColor(context),
width: model.width?.parse,
height: model.height?.parse,
width: model.width,
height: model.height,
fit: model.fit?.parse,
errorBuilder: (context, error, stackTrace) {
return const SizedBox();
Expand All @@ -68,8 +67,8 @@ class StacImageParser extends StacParser<StacImage> {
model.src,
alignment: model.alignment?.parse ?? Alignment.center,
color: model.color?.toColor(context),
width: model.width?.parse,
height: model.height?.parse,
width: model.width,
height: model.height,
fit: model.fit?.parse,
errorBuilder: (context, error, stackTrace) {
return const SizedBox();
Expand All @@ -82,8 +81,8 @@ class StacImageParser extends StacParser<StacImage> {
colorFilter: model.color != null
? ColorFilter.mode(model.color.toColor(context)!, BlendMode.srcIn)
: null,
width: model.width?.parse,
height: model.height?.parse,
width: model.width,
height: model.height,
fit: model.fit?.parse ?? BoxFit.contain,
errorBuilder: (context, error, stackTrace) {
return const SizedBox();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:stac/src/parsers/core/stac_widget_parser.dart';
import 'package:stac/src/parsers/types/type_parser.dart';
import 'package:stac_framework/stac_framework.dart';
import 'package:stac_models/stac_models.dart';
import 'package:stac_models/types/stac_double.dart';

class StacRowParser extends StacParser<StacRow> {
const StacRowParser();
Expand All @@ -25,7 +24,7 @@ class StacRowParser extends StacParser<StacRow> {
textDirection: model.textDirection?.parse,
verticalDirection:
model.verticalDirection?.parse ?? VerticalDirection.down,
spacing: model.spacing?.parse ?? 0,
spacing: model.spacing ?? 0,
children: model.children.parseList(context) ?? []);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:stac/src/parsers/core/stac_widget_parser.dart';
import 'package:stac/src/utils/widget_type.dart';
import 'package:stac_framework/stac_framework.dart';
import 'package:stac_models/stac_models.dart';
import 'package:stac_models/types/stac_double.dart';

class StacSizedBoxParser extends StacParser<StacSizedBox> {
const StacSizedBoxParser();
Expand All @@ -18,8 +17,8 @@ class StacSizedBoxParser extends StacParser<StacSizedBox> {
@override
Widget parse(BuildContext context, StacSizedBox model) {
return SizedBox(
width: model.width?.parse,
height: model.height?.parse,
width: model.width,
height: model.height,
child: model.child.parse(context),
);
}
Expand Down
Loading