Skip to content

Commit

Permalink
Merge branch 'chore/publish-pipeline' of https://github.com/conceptad…
Browse files Browse the repository at this point in the history
…ev/mix into chore/publish-pipeline
  • Loading branch information
tilucasoli committed Jul 5, 2024
2 parents 28035db + f25fb25 commit e28f68e
Show file tree
Hide file tree
Showing 18 changed files with 286 additions and 119 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/add_label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: "Add labels"

on:
pull_request:

permissions:
pull-requests: write

jobs:
apply-label:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- uses: rogerluan/[email protected]
with:
github_token: ${{ secrets.github_token }}

- uses: actions/github-script@v7
with:
script: |
const { execSync } = require('child_process')
const { commits } = context.payload.pull_request
const rawFiles = execSync(`git diff --name-only HEAD HEAD~${commits}`).toString()
const files = rawFiles.split('\n').filter(Boolean)
// verify packages
const packagesFiles = files.filter(file => file.startsWith('packages/') && !file.includes('mix_lint_test'))
const packages = packagesFiles.map(file => file.split('/')[1])
const labels = Array.from(new Set(packages))
// verify documentation
const wasDocModified = files.filter(file => file.startsWith('website/')).length > 0
if (wasDocModified) {
labels.push('documentation')
}
// verify examples
const wasExampleModified = files.filter(file => file.startsWith('examples/')).length > 0
if (wasExampleModified) {
labels.push('examples')
}
// verify repo
const wasRepoModified = files.filter(file => !file.startsWith('website/') && !file.startsWith('packages/') && !file.startsWith('examples/')).length > 0
if (wasRepoModified) {
labels.push('repo')
}
console.log(labels)
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labels
})
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 2024-07-03

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`mix` - `v1.2.0`](#mix---v120)

---

#### `mix` - `v1.2.0`

- **FIX**: Exception when there is no children on flex (#345).
- **FIX**: Added remaining params to callable specs and modifiers (#332).
- **FIX**: Gap resolve SpaceToken in flex attribute (#327).
- **FIX**: mix - Improved merge behavior between ShapeDecoration and BoxDecoration (#316).
- **FEAT**: pressable supports keyboard events (#346).

8 changes: 8 additions & 0 deletions packages/mix/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 1.2.0

- **FIX**: Exception when there is no children on flex (#345).
- **FIX**: Added remaining params to callable specs and modifiers (#332).
- **FIX**: Gap resolve SpaceToken in flex attribute (#327).
- **FIX**: mix - Improved merge behavior between ShapeDecoration and BoxDecoration (#316).
- **FEAT**: pressable supports keyboard events (#346).

## 1.1.3

- Improved merge behavior between ShapeDecoration and BoxDecoration
Expand Down
67 changes: 25 additions & 42 deletions packages/mix/lib/src/attributes/border/shape_border_dto.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ sealed class ShapeBorderDto<T extends ShapeBorder> extends Dto<T> {
BorderSideDto? get _side =>
this is OutlinedBorderDto ? (this as OutlinedBorderDto).side : null;

BeveledRectangleBorderDto toBeveledRectangleBorder();
RoundedRectangleBorderDto toRoundedRectangleBorder();
ContinuousRectangleBorderDto toContinuousRectangleBorder();
CircleBorderDto toCircleBorder();
BeveledRectangleBorderDto toBeveled();
RoundedRectangleBorderDto toRoundedRectangle();
ContinuousRectangleBorderDto toContinuous();
CircleBorderDto toCircle();
StadiumBorderDto toStadiumBorder();
StarBorderDto toStarBorder();
LinearBorderDto toLinearBorder();
StarBorderDto toStar();
LinearBorderDto toLinear();

@override
ShapeBorderDto<T> merge(covariant ShapeBorderDto<T>? other);
Expand All @@ -71,36 +71,19 @@ sealed class OutlinedBorderDto<T extends OutlinedBorder>
return _exhaustiveMerge(a, b);
}

static OutlinedBorderDto _exhaustiveMerge(
OutlinedBorderDto a,
OutlinedBorderDto b,
) {
if (a.runtimeType == b.runtimeType) return a.merge(b);

switch (b.runtimeType) {
case BeveledRectangleBorderDto:
return a
.toBeveledRectangleBorder()
.merge(b as BeveledRectangleBorderDto);
case RoundedRectangleBorderDto:
return a
.toRoundedRectangleBorder()
.merge(b as RoundedRectangleBorderDto);
case ContinuousRectangleBorderDto:
return a
.toContinuousRectangleBorder()
.merge(b as ContinuousRectangleBorderDto);
case CircleBorderDto:
return a.toCircleBorder().merge(b as CircleBorderDto);
case StadiumBorderDto:
return a.toStadiumBorder().merge(b as StadiumBorderDto);
case StarBorderDto:
return a.toStarBorder().merge(b as StarBorderDto);
case LinearBorderDto:
return a.toLinearBorder().merge(b as LinearBorderDto);
default:
throw ArgumentError('Unknown OutlinedBorderDto type: ${b.runtimeType}');
}
static B _exhaustiveMerge<A extends OutlinedBorderDto,
B extends OutlinedBorderDto>(A a, B b) {
if (a.runtimeType == b.runtimeType) return a.merge(b) as B;

return switch (b) {
(BeveledRectangleBorderDto g) => a.toBeveled().merge(g) as B,
(RoundedRectangleBorderDto g) => a.toRoundedRectangle().merge(g) as B,
(ContinuousRectangleBorderDto g) => a.toContinuous().merge(g) as B,
(CircleBorderDto g) => a.toCircle().merge(g) as B,
(StadiumBorderDto g) => a.toStadiumBorder().merge(g) as B,
(StarBorderDto g) => a.toStar().merge(g) as B,
(LinearBorderDto g) => a.toLinear().merge(g) as B,
};
}

BoxShape? _toBoxShape() {
Expand All @@ -118,7 +101,7 @@ sealed class OutlinedBorderDto<T extends OutlinedBorder>
/// Tries to get borderRadius if available for [OutlineBorderDto]
@override
BeveledRectangleBorderDto toBeveledRectangleBorder() {
BeveledRectangleBorderDto toBeveled() {
if (this is BeveledRectangleBorderDto) {
return this as BeveledRectangleBorderDto;
}
Expand All @@ -130,15 +113,15 @@ sealed class OutlinedBorderDto<T extends OutlinedBorder>
}

@override
ContinuousRectangleBorderDto toContinuousRectangleBorder() {
ContinuousRectangleBorderDto toContinuous() {
return ContinuousRectangleBorderDto(
borderRadius: _borderRadius,
side: _side,
);
}

@override
RoundedRectangleBorderDto toRoundedRectangleBorder() {
RoundedRectangleBorderDto toRoundedRectangle() {
if (this is RoundedRectangleBorderDto) {
return this as RoundedRectangleBorderDto;
}
Expand All @@ -150,7 +133,7 @@ sealed class OutlinedBorderDto<T extends OutlinedBorder>
}

@override
CircleBorderDto toCircleBorder() {
CircleBorderDto toCircle() {
if (this is CircleBorderDto) return this as CircleBorderDto;

return CircleBorderDto(side: _side);
Expand All @@ -164,14 +147,14 @@ sealed class OutlinedBorderDto<T extends OutlinedBorder>
}

@override
LinearBorderDto toLinearBorder() {
LinearBorderDto toLinear() {
if (this is LinearBorderDto) return this as LinearBorderDto;

return LinearBorderDto(side: _side);
}

@override
StarBorderDto toStarBorder() {
StarBorderDto toStar() {
if (this is StarBorderDto) return this as StarBorderDto;

return StarBorderDto(side: _side);
Expand Down
6 changes: 3 additions & 3 deletions packages/mix/lib/src/core/factory/style_mix.dart
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,10 @@ class AnimatedStyle extends Style {
final AnimatedData animated;

const AnimatedStyle._({
required AttributeMap<StyledAttribute> styles,
required AttributeMap<VariantAttribute> variants,
required super.styles,
required super.variants,
required this.animated,
}) : super._(styles: styles, variants: variants);
}) : super._();

factory AnimatedStyle(
Style style, {
Expand Down
11 changes: 6 additions & 5 deletions packages/mix/lib/src/specs/flex/flex_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import 'package:flutter/widgets.dart';

import '../../core/factory/style_mix.dart';
import '../../core/styled_widget.dart';
import '../box/box_spec.dart';
import '../box/box_widget.dart';
Expand Down Expand Up @@ -68,6 +67,8 @@ class FlexSpecWidget extends StatelessWidget {
List<Widget> _buildChildren(double? gap) {
if (gap == null) return children;

if (children.isEmpty) return [];

return List.generate(children.length + children.length - 1, (index) {
if (index.isEven) return children[index ~/ 2];

Expand Down Expand Up @@ -211,11 +212,11 @@ class FlexBox extends StyledWidget {
/// ```
class HBox extends FlexBox {
const HBox({
Style? style,
super.style,
super.key,
super.inherit,
super.children = const <Widget>[],
}) : super(style: style, direction: Axis.horizontal);
}) : super(direction: Axis.horizontal);
}

/// A vertical flex container that uses `Style` for streamlined styling.
Expand All @@ -236,11 +237,11 @@ class HBox extends FlexBox {
/// ```
class VBox extends FlexBox {
const VBox({
Style? style,
super.style,
super.key,
super.inherit,
super.children = const <Widget>[],
}) : super(style: style, direction: Axis.vertical);
}) : super(direction: Axis.vertical);
}

final _defaultFlex = Flex(direction: Axis.horizontal, children: const []);
8 changes: 4 additions & 4 deletions packages/mix/lib/src/specs/icon/icon_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ class AnimatedIconSpecWidget extends ImplicitlyAnimatedWidget {
this.semanticLabel,
this.textDirection,
this.modifierOrder = const [],
Curve curve = Curves.linear,
required Duration duration,
VoidCallback? onEnd,
}) : super(curve: curve, duration: duration, onEnd: onEnd);
super.curve,
required super.duration,
super.onEnd,
});

final IconData? icon;
final IconSpec spec;
Expand Down
Loading

0 comments on commit e28f68e

Please sign in to comment.