diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fa56fb..1ed8c69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.8.0 + +Adds comparison operators to DeviceScreenType and RefinedSize, for convenience. + ## 0.7.1 - Fixes [#53](https://github.com/FilledStacks/responsive_builder/issues/53) diff --git a/lib/src/device_screen_type.dart b/lib/src/device_screen_type.dart index 311321d..74b6afc 100644 --- a/lib/src/device_screen_type.dart +++ b/lib/src/device_screen_type.dart @@ -1,16 +1,43 @@ +import 'package:responsive_builder/responsive_builder.dart'; + enum DeviceScreenType { @Deprecated('Use lowercase version') - Mobile, + Mobile(1), @Deprecated('Use lowercase version') - Tablet, + Tablet(2), @Deprecated('Use lowercase version') - Desktop, + Desktop(3), @Deprecated('Use lowercase version') - Watch, - mobile, - tablet, - desktop, - watch + Watch(0), + mobile(1), + tablet(2), + desktop(3), + watch(0); + + const DeviceScreenType(this._ordinal); + + final int _ordinal; + + bool operator >(DeviceScreenType other) => _ordinal > other._ordinal; + + bool operator >=(DeviceScreenType other) => _ordinal >= other._ordinal; + + bool operator <(DeviceScreenType other) => _ordinal < other._ordinal; + + bool operator <=(DeviceScreenType other) => _ordinal <= other._ordinal; } -enum RefinedSize { small, normal, large, extraLarge } +enum RefinedSize { + small, + normal, + large, + extraLarge; + + bool operator >(RefinedSize other) => index > other.index; + + bool operator >=(RefinedSize other) => index >= other.index; + + bool operator <(RefinedSize other) => index < other.index; + + bool operator <=(RefinedSize other) => index <= other.index; +} diff --git a/pubspec.yaml b/pubspec.yaml index a1d8681..af4618d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: responsive_builder description: A set of widgets that can be used to define a readable responsive UI for widgets. -version: 0.7.1 +version: 0.8.0 homepage: https://github.com/FilledStacks/responsive_builder funding: