Skip to content

Commit

Permalink
Adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
leoafarias committed Mar 25, 2024
1 parent 9d57c86 commit 588dc69
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
2 changes: 2 additions & 0 deletions lib/src/attributes/scalars/scalar_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ class OffsetUtility<T extends StyleAttribute> extends MixUtility<T, Offset> {
const OffsetUtility(super.builder);

T call(double dx, double dy) => builder(Offset(dx, dy));

T zero() => builder(Offset.zero);
}

class FontSizeUtility<T extends StyleAttribute> extends SizingUtility<T> {
Expand Down
10 changes: 8 additions & 2 deletions lib/src/factory/mix_provider_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,17 @@ M? _mergeAttributes<M extends StyleAttribute>(Iterable<M> mergeables) {
class AnimatedData with Comparable {
final Duration duration;
final Curve curve;

const AnimatedData({required this.duration, required this.curve});

factory AnimatedData.withDefaults({Duration? duration, Curve? curve}) {
return AnimatedData(
duration: duration ?? const Duration(milliseconds: 150),
curve: curve ?? Curves.linear,
);
}

@override
List<Object> get props => [duration, curve];
get props => [duration, curve];
}

Iterable<Attribute> _applyStyleBuilder(
Expand Down
8 changes: 4 additions & 4 deletions lib/src/specs/container/box_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ class BoxSpec extends Spec<BoxSpec> {
];
}

class BoxSpecTween extends Tween<BoxSpec?> {
class BoxSpecTween extends Tween<BoxSpec> {
BoxSpecTween({super.begin, super.end});

@override
BoxSpec? lerp(double t) {
if (begin == null) return end;
if (end == null) return begin;
BoxSpec lerp(double t) {
if (begin == null && end == null) return const BoxSpec.empty();
if (begin == null) return end!;

return begin!.lerp(end!, t);
}
Expand Down
3 changes: 3 additions & 0 deletions lib/src/specs/container/box_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import '../../attributes/constraints/constraints_dto.dart';
import '../../attributes/constraints/constraints_util.dart';
import '../../attributes/decoration/decoration_dto.dart';
import '../../attributes/decoration/decoration_util.dart';
import '../../attributes/gradient/gradient_util.dart';
import '../../attributes/scalars/scalar_util.dart';
import '../../attributes/shadow/shadow_util.dart';
import '../../attributes/spacing/spacing_dto.dart';
Expand Down Expand Up @@ -322,6 +323,8 @@ class BoxSpecUtility extends SpecUtility<BoxSpecAttribute> {

ElevationUtility<BoxSpecAttribute> get elevation => decoration.elevation;

GradientUtility<BoxSpecAttribute> get gradient => decoration.gradient;

ShapeDecorationUtility<BoxSpecAttribute> get shapeDecoration =>
ShapeDecorationUtility((decoration) => only(decoration: decoration));

Expand Down
13 changes: 10 additions & 3 deletions lib/src/specs/container/box_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,18 @@ class MixedBox extends StatelessWidget {
final MixData mix;
@override
Widget build(BuildContext context) {
// Get MixData from this widget or the nearest MixProvider.
return BoxSpecWidget(spec: BoxSpec.of(mix), child: child);
}
}

// Retrieve styling properties from MixData. Use default properties if MixData is not provided.
final spec = BoxSpec.of(mix);
class BoxSpecWidget extends StatelessWidget {
const BoxSpecWidget({required this.spec, super.key, this.child});

final Widget? child;
final BoxSpec spec;

@override
Widget build(BuildContext context) {
return Container(
alignment: spec.alignment,
padding: spec.padding,
Expand Down

0 comments on commit 588dc69

Please sign in to comment.