Skip to content

Commit

Permalink
chore: version 1
Browse files Browse the repository at this point in the history
  • Loading branch information
maxzod committed Mar 4, 2024
1 parent 4792acb commit 41447b0
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 205 deletions.
2 changes: 1 addition & 1 deletion packages/flutter_readable/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## 0.0.5
# 1.0.0

- more helpers .
4 changes: 2 additions & 2 deletions packages/flutter_readable/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.0.5"
version: "1.0.0"
material_color_utilities:
dependency: transitive
description:
Expand All @@ -59,7 +59,7 @@ packages:
path: "../../readable"
relative: true
source: path
version: "0.0.5"
version: "1.0.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down
3 changes: 0 additions & 3 deletions packages/flutter_readable/lib/src/context/navigator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ extension RContextNavigator on BuildContext {
/// shortcut for `Navigator.of(context, rootNavigator: true)`
NavigatorState get rootNavigator => Navigator.of(this, rootNavigator: true);

/// shortcut for `Navigator.of(context).canPop()`
bool get canPop => navigator.canPop();

/// shortcut for `FocusScopeNode.of(context)`
FocusScopeNode get focusScope => FocusScope.of(this);

Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_readable/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ packages:
path: "../readable"
relative: true
source: path
version: "0.0.5"
version: "1.0.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down
6 changes: 3 additions & 3 deletions packages/flutter_readable/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: flutter_readable
description: extensions and helpers for dart to save time , make the code more readable and smaller
version: 0.0.5
version: 1.0.0
homepage: https://github.com/maxzod/readable
repository: https://github.com/maxzod/readable

environment:
sdk: ">=2.12.0 <3.0.0"
sdk: ">=2.12.0 <4.0.0"
flutter: ">=1.17.0"

dependencies:
flutter:
sdk: flutter
readable: ^0.0.5
readable: ^1.0.0

dev_dependencies:
flutter_test:
Expand Down
3 changes: 0 additions & 3 deletions packages/flutter_readable/test/extensions/context_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ class TestXPage extends StatelessWidget {
'locale': (ctx) =>
identical(ctx.locale, Localizations.localeOf(context)),

/// * Navigator
'canPop': (ctx) =>
identical(ctx.canPop, Navigator.of(ctx).canPop()),
'rootNavigator': (ctx) => identical(
ctx.rootNavigator,
Navigator.of(ctx, rootNavigator: true),
Expand Down
11 changes: 1 addition & 10 deletions packages/readable/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
## 0.0.5
# 1.0.0

- more extensions and helpers

## 0.0.4

- removeWhereNull
- toNumOrZero

## 0.0.3

- initial release.
2 changes: 1 addition & 1 deletion packages/readable/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ packages:
path: ".."
relative: true
source: path
version: "0.0.5"
version: "1.0.0"
sdks:
dart: ">=3.3.0 <4.0.0"
3 changes: 3 additions & 0 deletions packages/readable/lib/readable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ export 'src/extensions/string/string_conversion.dart';
/// * helpers
export 'src/helpers/await_for.dart';
export 'src/helpers/map.dart';

/// return true if match
typedef Selector<T> = bool Function(T);
93 changes: 7 additions & 86 deletions packages/readable/lib/src/extensions/date_time.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// TODO :: uncomment only tested ones
///
extension RDateTime on DateTime {
/// * `true` if the date in the morning, `false` otherwise.
Expand All @@ -7,18 +6,17 @@ extension RDateTime on DateTime {
/// * `true` if the date in the evening, `false` otherwise.
bool get isPm => hour >= 12;

///
/// * tomorrow date for the given date
DateTime get nextDay => add(const Duration(days: 1));

///
/// * same day in the next week
DateTime get sameDayNextWeek => add(const Duration(days: 7));

/// DateTime get sameDayNextMonth => add(const Duration(days: 7));
/// * DateTime get sameDayNextMonth => add(const Duration(days: 7));
DateTime get previousDay => subtract(const Duration(days: 1));

///
/// * same day in the previous week
DateTime get sameDayPreviousWeek => subtract(const Duration(days: 7));
// DateTime get sameDayPreviousMonth => subtract(const Duration(days: 7));

/// * creates new instance of [DateTime] with the same date
/// * but overrides the values of the given parameters
Expand All @@ -44,11 +42,9 @@ extension RDateTime on DateTime {
/// * return [true] if the date is today, [false] otherwise.
bool get isToday => isSameDay(DateTime.now());

///
bool isSameDay(
DateTime date,
) =>
date.year == year && date.month == month && date.day == day;
/// * return [true] if the date is the same day as the given date, [false] otherwise.
/// ! ignores the time part
bool isSameDay(DateTime other) => dateOnly == other.dateOnly;

/// * return [true] if the date is tomorrow, [false] otherwise.
bool get isTomorrow => isSameDay(DateTime.now().nextDay);
Expand Down Expand Up @@ -171,56 +167,6 @@ extension RDateTime on DateTime {
isFriday &&
month + 1 == DateTime(year, month, day + DateTime.daysPerWeek).month;

/// * return [true] the first saturday of the month
/// TODO :: date wont work with last month of the year
// bool get isFirstSaturdayThisMonth =>
// isSaturday &&
// subtract(const Duration()).month ==
// DateTime(year, month, day - DateTime.daysPerWeek).month;

// /// * return [true] the first sunday of the month
// bool get isFirstSundayThisMonth =>
// isSunday &&
// month - 1 == DateTime(year, month, day - DateTime.daysPerWeek).month;

// /// * return [true] the first monday of the month
// bool get isFirstMondayThisMonth =>
// isMonday &&
// month - 1 == DateTime(year, month, day - DateTime.daysPerWeek).month;

// /// * return [true] the first tuesday of the month

// bool get isFirstTuesdayThisMonth =>
// isTuesday &&
// month - 1 == DateTime(year, month, day - DateTime.daysPerWeek).month;

// /// * return [true] the first wednesday of the month
// bool get isFirstWednesdayThisMonth =>
// isWednesday &&
// month - 1 == DateTime(year, month, day - DateTime.daysPerWeek).month;

// /// * return [true] the first thursday of the month
// bool get isFirstThursdayThisMonth =>
// isThursday &&
// month - 1 == DateTime(year, month, day - DateTime.daysPerWeek).month;

// /// * return [true] the first friday of the month
// bool get isFirstFridayThisMonth =>
// isFriday &&
// month - 1 == DateTime(year, month, day - DateTime.daysPerWeek).month;

// bool get isLastSaturdayOfTheYear => day == DateTime.saturday;
// bool get isLastSundayOfTheYear => day == DateTime.sunday;
// bool get isLastMondayOfTheYear => day == DateTime.monday;
// bool get isLastTuesdayOfTheYear => day == DateTime.tuesday;
// bool get isLastWednesdayOfTheYear => day == DateTime.wednesday;
// bool get isLastThursdayOfTheYear => day == DateTime.thursday;
// bool get isLastFridayOfTheYear => day == DateTime.friday;

/// returns true if date is between tow dates
// bool isBetween(DateTime start, DateTime end) =>
// start.isBefore(this) && end.isAfter(this);

/// returns true if date year is leaap year
bool get isLeapYear {
return year % 4 == 0 && year % 100 != 0 || year % 400 == 0;
Expand All @@ -229,28 +175,3 @@ extension RDateTime on DateTime {
///
DateTime get dateOnly => DateTime(year, month, day);
}

/// TODO ::
/// * firstDayOfMonth
/// * lastDayOfMonth
///
/// * firstDayOfWeek
/// * lastDayOfWeek
///
/// * firstDayNextWeek
/// * firstDayNextMonth
/// * firstDayNextYear
///
/// * lastDayNextWeek
/// * lastDayNextMonth
/// * lastDayNextYear
///
/// * firstDayPreviousWeek
/// * firstDayPreviousMonth
/// * firstDayPreviousYear
///
/// * lastDayPreviousWeek
/// * lastDayPreviousMonth
/// * lastDayPreviousYear
/// * isSameWeek
9 changes: 3 additions & 6 deletions packages/readable/lib/src/extensions/iterable/extensions.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import 'dart:async';
import 'dart:math';

import 'package:readable/readable.dart';

/// RIterable
extension RIterable<T> on Iterable<T> {
/// * alias for `length`
/// * but can filter before if needed
int count([
bool Function(T element)? mapper,
]) =>
int count([Selector<T>? mapper]) =>
mapper == null ? length : where(mapper).length;

/// * return the `length` of the NOT `null` elements
Expand Down Expand Up @@ -90,7 +90,4 @@ extension RIterable<T> on Iterable<T> {
}
return result;
}

/// return true if iterable not contains input
// bool notContains( T input) => !contains(input);
}
2 changes: 0 additions & 2 deletions packages/readable/lib/src/extensions/iterable/num.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// import 'package:readable/src/extensions/iterable/extensions.dart';

import 'package:readable/src/extensions/iterable/extensions.dart';

/// list `readableX`
Expand Down
17 changes: 0 additions & 17 deletions packages/readable/lib/src/extensions/list/list.dart
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
///
extension RList<T> on List<T?> {
/// clears the iterable
/// add all items to the iterable
// void assignAll(Iterable<T> newItems) {
// clear();
// addAll(newItems);
// }

/// clears the iterable
/// add item to the iterable
// void assignOne(T newItem) {
// clear();
// add(newItem);
// }

/// if the list contains `item` will remove it else will add it
// void toggle(T item) => contains(item) ? remove(item) : add(item);

/// remove first element of the list
T? removeFirst() => removeAt(0);
}
45 changes: 0 additions & 45 deletions packages/readable/lib/src/extensions/map/map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,49 +58,4 @@ extension RMap<K, V> on Map<K, V> {
holder.removeWhere((key, value) => value is String && value.isEmpty);
return holder;
}

/// return random key or null if map is Empty
// K? randomKeyOrNull() => isEmpty ? null : keys.random;

/// return random key or the default if map is empty
// K randomKeyOr(K def) => randomKeyOrNull() ?? def;

/// return random key or the use the builder to return the key
// K randomKeyOrBuilder(K Function() builder) => randomKeyOrNull() ?? builder();

/// return random key or throw state error
// K randomKey() =>
// randomKeyOrNull() ??
// (throw StateError('Map is Empty cant use randomKey()'));

/// return random value or null if map is Empty
// V? randomValueOrNull() => isEmpty ? null : values.random;

/// return random value or the default if map is empty
// V randomValueOr(V def) => randomValueOrNull() ?? def;

/// return random value or the use the builder to return the key
// V randomValueOrBuilder(V Function() builder) =>
// randomValueOrNull() ?? builder();

/// return random value or throw state error
// V randomValue() =>
// randomValueOrNull() ??
// (throw StateError('Map is Empty cant use randomValue()'));

/// return random Entry or null if map is Empty
// MapEntry<K, V>? randomEntryOrNull() => isEmpty ? null : entries.random;

/// return random Entry or the default if map is empty
// MapEntry<K, V> randomEntryOr(MapEntry<K, V> def) =>
// randomEntryOrNull() ?? def;

/// return random Entry or the use the builder to return the key
// MapEntry<K, V> randomEntryOrBuilder(MapEntry<K, V> Function() builder) =>
// randomEntryOrNull() ?? builder();

/// return random Entry or throw state error
// MapEntry<K, V> randomEntry() =>
// randomEntryOrNull() ??
// (throw StateError('Map is Empty cant use randomValue()'));
}
23 changes: 0 additions & 23 deletions packages/readable/lib/src/extensions/string/string.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,4 @@ extension RString on String {
/// * return the last character
/// * return `null` if isEmpty
String? get lastOrNull => isEmpty ? null : this[length - 1];

/// return last element or the default value
// String? lastOr(String def) => lastOrNull ?? def;

/// return last or calls if Absent
// String? lastOrIfAbsent(String Function() ifAbsent) =>
// lastOrNull ?? ifAbsent();

/// Returns last symbol of string or empty string if `this` is null or empty
// String get firstOrEmpty => firstOrNull ?? '';

/// * return the first character
/// * return `null` if isEmpty
// String? get firstOrNull => isEmpty ? null : this[0];

/// return first or default value
// String? firstOr(String def) => firstOrNull ?? def;

/// return first or calls if Absent
// String? firstOrIfAbsent(String Function() ifAbsent) =>
// firstOrNull ?? ifAbsent();
}
4 changes: 2 additions & 2 deletions packages/readable/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: readable
description: extensions and helpers for dart to save time , make the code more readable and smaller
version: 0.0.5
version: 1.0.0
homepage: https://github.com/maxzod/readable
repository: https://github.com/maxzod/readable

environment:
sdk: ">=2.12.0 <3.0.0"
sdk: ">=2.12.0 <4.0.0"

dev_dependencies:
lint: ^2.1.2
Expand Down

0 comments on commit 41447b0

Please sign in to comment.