Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autounit #146

Merged
merged 7 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ Kilian Schulte (schultek) - Creator & Lead Developer
Martin Jablečník (mjablecnik) - Contributor
Jeff Ward (fuzzybinary) - Contributor
Matthew Jaoudi (gadfly361) - Contributor
Rishabh Singh - UC Berkeley (cybertheory) - Contributor
37 changes: 19 additions & 18 deletions examples/flutter_plugin_interop/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ packages:
dependency: transitive
description:
name: build_modules
sha256: "409fc1be491612bc1e2262f4c7fec6c91c683560662a34cfeedfcd1f7c13470b"
sha256: bd2e3693a33761fce4260704fcfa519042573457c8cf61c50249a7dde2fbe5e1
url: "https://pub.dev"
source: hosted
version: "5.0.3"
version: "5.0.5"
build_resolvers:
dependency: transitive
description:
Expand Down Expand Up @@ -205,10 +205,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.17.2"
version: "1.18.0"
convert:
dependency: transitive
description:
Expand Down Expand Up @@ -425,9 +425,10 @@ packages:
jaspr_web_compilers:
dependency: "direct dev"
description:
path: "../../modules/build/jaspr_web_compilers"
relative: true
source: path
name: jaspr_web_compilers
sha256: "2c3818585e12f88008f0ffd84ff847743ce4d0096df50cc8b59584e69fa75b56"
url: "https://pub.dev"
source: hosted
version: "4.0.7"
js:
dependency: transitive
Expand Down Expand Up @@ -481,10 +482,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.10.0"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -726,18 +727,18 @@ packages:
dependency: transitive
description:
name: stack_trace
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
stream_transform:
dependency: transitive
description:
Expand Down Expand Up @@ -766,10 +767,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.6.0"
version: "0.6.1"
timing:
dependency: transitive
description:
Expand Down Expand Up @@ -814,10 +815,10 @@ packages:
dependency: transitive
description:
name: web
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
url: "https://pub.dev"
source: hosted
version: "0.1.4-beta"
version: "0.3.0"
web_socket_channel:
dependency: transitive
description:
Expand Down Expand Up @@ -851,5 +852,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.1.0-185.0.dev <3.2.0"
dart: ">=3.2.0-194.0.dev <3.4.0"
flutter: ">=3.3.0"
7 changes: 0 additions & 7 deletions examples/package_riverpod/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,6 @@ packages:
relative: true
source: path
version: "0.3.8"
jaspr_web_compilers:
dependency: "direct overridden"
description:
path: "../../modules/build/jaspr_web_compilers"
relative: true
source: path
version: "4.0.7"
js:
dependency: transitive
description:
Expand Down
10 changes: 5 additions & 5 deletions experiments/mobx_hooks/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ packages:
dependency: transitive
description:
name: build_modules
sha256: "017226b2fd3eef4e5f31839c930efad33110cdfe71b6255c7dca298b38dba61c"
sha256: bd2e3693a33761fce4260704fcfa519042573457c8cf61c50249a7dde2fbe5e1
url: "https://pub.dev"
source: hosted
version: "5.0.2"
version: "5.0.5"
build_resolvers:
dependency: transitive
description:
Expand Down Expand Up @@ -125,10 +125,10 @@ packages:
dependency: "direct dev"
description:
name: build_web_compilers
sha256: e614f5e1317fe9b2574429e3e651951a1c38943416c047e02815a7d6ade264c9
sha256: ebd3db74f0d53ae9b91a214016e35733add484a1a3014e188754954e8d69843c
url: "https://pub.dev"
source: hosted
version: "4.0.3"
version: "4.0.8"
built_collection:
dependency: transitive
description:
Expand Down Expand Up @@ -640,4 +640,4 @@ packages:
source: hosted
version: "3.1.1"
sdks:
dart: ">=3.0.0 <3.2.0"
dart: ">=3.1.0 <3.4.0"
10 changes: 5 additions & 5 deletions experiments/preload_images/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ packages:
dependency: transitive
description:
name: build_modules
sha256: "017226b2fd3eef4e5f31839c930efad33110cdfe71b6255c7dca298b38dba61c"
sha256: bd2e3693a33761fce4260704fcfa519042573457c8cf61c50249a7dde2fbe5e1
url: "https://pub.dev"
source: hosted
version: "5.0.2"
version: "5.0.5"
build_resolvers:
dependency: transitive
description:
Expand Down Expand Up @@ -117,10 +117,10 @@ packages:
dependency: "direct dev"
description:
name: build_web_compilers
sha256: e614f5e1317fe9b2574429e3e651951a1c38943416c047e02815a7d6ade264c9
sha256: ebd3db74f0d53ae9b91a214016e35733add484a1a3014e188754954e8d69843c
url: "https://pub.dev"
source: hosted
version: "4.0.3"
version: "4.0.8"
built_collection:
dependency: transitive
description:
Expand Down Expand Up @@ -560,4 +560,4 @@ packages:
source: hosted
version: "3.1.1"
sdks:
dart: ">=3.0.0 <3.2.0"
dart: ">=3.1.0 <3.4.0"
10 changes: 5 additions & 5 deletions experiments/scoped_styles/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ packages:
dependency: transitive
description:
name: build_modules
sha256: "017226b2fd3eef4e5f31839c930efad33110cdfe71b6255c7dca298b38dba61c"
sha256: bd2e3693a33761fce4260704fcfa519042573457c8cf61c50249a7dde2fbe5e1
url: "https://pub.dev"
source: hosted
version: "5.0.2"
version: "5.0.5"
build_resolvers:
dependency: transitive
description:
Expand Down Expand Up @@ -117,10 +117,10 @@ packages:
dependency: "direct dev"
description:
name: build_web_compilers
sha256: e614f5e1317fe9b2574429e3e651951a1c38943416c047e02815a7d6ade264c9
sha256: ebd3db74f0d53ae9b91a214016e35733add484a1a3014e188754954e8d69843c
url: "https://pub.dev"
source: hosted
version: "4.0.3"
version: "4.0.8"
built_collection:
dependency: transitive
description:
Expand Down Expand Up @@ -569,4 +569,4 @@ packages:
source: hosted
version: "3.1.1"
sdks:
dart: ">=3.0.0 <3.2.0"
dart: ">=3.1.0 <3.4.0"
5 changes: 5 additions & 0 deletions packages/jaspr/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Unreleased minor

- Had to resort for using Style.Raw for this, So I added a new Unit called Unit.auto
- Simply emmits the value 'auto', use this for responsive styling
schultek marked this conversation as resolved.
Show resolved Hide resolved

## 0.9.3

- Fixed `melos format` on Windows.
Expand Down
29 changes: 26 additions & 3 deletions packages/jaspr/lib/src/ui/styles/properties/unit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ extension UnitExt on num {
abstract class Unit {
static const Unit zero = _ZeroUnit();

///auto represents the style attribute unit 'auto'
static const Unit auto = _AutoUnit();

/// Constructs a [Unit] in the form '100%'
const factory Unit.percent(double value) = _PercentUnit;

Expand All @@ -35,7 +38,23 @@ class _ZeroUnit implements Unit {
String get value => '0';

@override
bool operator ==(Object other) => identical(this, other) || other is _Unit && other._value == 0;
bool operator ==(Object other) =>
identical(this, other) || other is _Unit && other._value == 0;

@override
int get hashCode => 0;
}

///_AutoUnit represents the style attribute unit 'auto'
class _AutoUnit implements Unit {
const _AutoUnit();

@override
String get value => 'auto';

@override
bool operator ==(Object other) =>
identical(this, other) || other is _AutoUnit;

@override
int get hashCode => 0;
Expand All @@ -53,8 +72,12 @@ class _Unit implements Unit {
@override
bool operator ==(Object other) =>
identical(this, other) ||
_value == 0 && (other is _ZeroUnit || (other is _Unit && other._value == 0)) ||
other is _Unit && runtimeType == other.runtimeType && _unit == other._unit && _value == other._value;
_value == 0 &&
(other is _ZeroUnit || (other is _Unit && other._value == 0)) ||
other is _Unit &&
runtimeType == other.runtimeType &&
_unit == other._unit &&
_value == other._value;

@override
int get hashCode => _value == 0 ? 0 : _unit.hashCode ^ _value.hashCode;
Expand Down