Skip to content

Commit

Permalink
Add convenience comparison operators for DeviceScreenType and Refined…
Browse files Browse the repository at this point in the history
…Size
  • Loading branch information
tjarvstrand committed Jul 2, 2024
1 parent 62bc9ae commit f7a4745
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.8.0

Adds comparison operators to DeviceScreenType and RefinedSize, for convenience.

## 0.7.0

- Fixes #50
Expand Down
45 changes: 36 additions & 9 deletions lib/src/device_screen_type.dart
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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.0
version: 0.8.0
homepage: https://github.com/FilledStacks/responsive_builder

funding:
Expand Down

0 comments on commit f7a4745

Please sign in to comment.