From 8e99f5010a7b6ab7d42384d05c70031fe70f6c8c Mon Sep 17 00:00:00 2001 From: "Michael W. Aziz" Date: Sun, 9 Feb 2025 15:18:18 +0200 Subject: [PATCH] [0.1.0] --- .dart_tool/package_config.json | 71 ++++++++++++++++++++++++++++++ .dart_tool/package_config_subset | 41 ++++++++++++++++++ .dart_tool/version | 1 + CHANGELOG.md | 21 +++++++++ COPYRIGHT | 1 + README.md | 23 ++++++++++ analysis_options.yaml | 10 +++++ lib/astromic_extensions.dart | 8 ++++ lib/src/alignment_extensions.dart | 16 +++++++ lib/src/border_extensions.dart | 7 +++ lib/src/insets_extension.dart | 12 ++++++ lib/src/list_extensions.dart | 20 +++++++++ lib/src/radius_extensions.dart | 15 +++++++ lib/src/string_extensions.dart | 19 ++++++++ pubspec.lock | 72 +++++++++++++++++++++++++++++++ pubspec.yaml | 38 ++++++++++++++++ 16 files changed, 375 insertions(+) create mode 100644 .dart_tool/package_config.json create mode 100644 .dart_tool/package_config_subset create mode 100644 .dart_tool/version create mode 100644 CHANGELOG.md create mode 100644 COPYRIGHT create mode 100644 README.md create mode 100644 analysis_options.yaml create mode 100644 lib/astromic_extensions.dart create mode 100644 lib/src/alignment_extensions.dart create mode 100644 lib/src/border_extensions.dart create mode 100644 lib/src/insets_extension.dart create mode 100644 lib/src/list_extensions.dart create mode 100644 lib/src/radius_extensions.dart create mode 100644 lib/src/string_extensions.dart create mode 100644 pubspec.lock create mode 100644 pubspec.yaml diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json new file mode 100644 index 0000000..f580d21 --- /dev/null +++ b/.dart_tool/package_config.json @@ -0,0 +1,71 @@ +{ + "configVersion": 2, + "packages": [ + { + "name": "characters", + "rootUri": "file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/characters-1.3.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "collection", + "rootUri": "file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/collection-1.19.0", + "packageUri": "lib/", + "languageVersion": "3.4" + }, + { + "name": "flutter", + "rootUri": "file:///C:/Users/micwa/fvm/versions/stable/packages/flutter", + "packageUri": "lib/", + "languageVersion": "3.3" + }, + { + "name": "flutter_lints", + "rootUri": "file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_lints-2.0.3", + "packageUri": "lib/", + "languageVersion": "2.19" + }, + { + "name": "lints", + "rootUri": "file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/lints-2.1.1", + "packageUri": "lib/", + "languageVersion": "3.0" + }, + { + "name": "material_color_utilities", + "rootUri": "file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/material_color_utilities-0.11.1", + "packageUri": "lib/", + "languageVersion": "2.17" + }, + { + "name": "meta", + "rootUri": "file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/meta-1.15.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "sky_engine", + "rootUri": "file:///C:/Users/micwa/fvm/versions/stable/bin/cache/pkg/sky_engine", + "packageUri": "lib/", + "languageVersion": "3.2" + }, + { + "name": "vector_math", + "rootUri": "file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/vector_math-2.1.4", + "packageUri": "lib/", + "languageVersion": "2.14" + }, + { + "name": "astromic_extensions", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "3.6" + } + ], + "generated": "2025-02-09T13:17:01.285423Z", + "generator": "pub", + "generatorVersion": "3.6.0", + "flutterRoot": "file:///C:/Users/micwa/fvm/versions/stable", + "flutterVersion": "3.27.1", + "pubCache": "file:///C:/Users/micwa/AppData/Local/Pub/Cache" +} diff --git a/.dart_tool/package_config_subset b/.dart_tool/package_config_subset new file mode 100644 index 0000000..1b03515 --- /dev/null +++ b/.dart_tool/package_config_subset @@ -0,0 +1,41 @@ +characters +2.12 +file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/characters-1.3.0/ +file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/characters-1.3.0/lib/ +collection +3.4 +file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/collection-1.19.0/ +file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/collection-1.19.0/lib/ +flutter_lints +2.19 +file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_lints-2.0.3/ +file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_lints-2.0.3/lib/ +lints +3.0 +file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/lints-2.1.1/ +file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/lints-2.1.1/lib/ +material_color_utilities +2.17 +file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/material_color_utilities-0.11.1/ +file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/material_color_utilities-0.11.1/lib/ +meta +2.12 +file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/meta-1.15.0/ +file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/meta-1.15.0/lib/ +vector_math +2.14 +file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/vector_math-2.1.4/ +file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/vector_math-2.1.4/lib/ +sky_engine +3.2 +file:///C:/Users/micwa/fvm/versions/stable/bin/cache/pkg/sky_engine/ +file:///C:/Users/micwa/fvm/versions/stable/bin/cache/pkg/sky_engine/lib/ +flutter +3.3 +file:///C:/Users/micwa/fvm/versions/stable/packages/flutter/ +file:///C:/Users/micwa/fvm/versions/stable/packages/flutter/lib/ +astromic_extensions +3.6 +file:///D:/Micazi/Helpers/astromic_extensions/ +file:///D:/Micazi/Helpers/astromic_extensions/lib/ +2 diff --git a/.dart_tool/version b/.dart_tool/version new file mode 100644 index 0000000..b8b1d81 --- /dev/null +++ b/.dart_tool/version @@ -0,0 +1 @@ +3.27.1 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a5a2125 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,21 @@ + + +## 0.1.0 + +- **INIT**: Initial commit in the new repo. diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 0000000..0e86da1 --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1 @@ +This repository is Developed, Maintained, and is property of Michael W. Aziz (Micazi). \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..ea3592d --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +## Atromic Extensions + +The extensions module of the **Astromic** Presentation System +Developed, Maintained, and is property of Michael W. Aziz (Micazi) + +### Content + +- on _BorderDirectional_ + - `all()` : Generate a uniform border with one borderSide. ☑️ +- on _EdgeInsetsGeometry_ + - `copyWith()` ☑️ + - `resolveToDirectional()` : Automatically reverse the EdgeInsets based on the dynamic *TextDirection*. ☑️ +- on _List_ + - `containsAll()` : Checker to see if a list contains all of the other list. ☑️ + - `getUnique()` : Get unique items only of a supplied list. ☑️ +- on _TextAlignVertical_ + - `toAllignment()` : convert a `TextAlignVertical` to an `Alignment` object. ☑️ +- on _BorderRadiusGeometry_ + - `copyWith()` ☑️ + - `resolveToDirectional()` : Automatically reverse the BorderRadius based on the dynamic *TextDirection*. ☑️ +- on _String_ + - `toColor()` : Parse a HexCode `String` into a `Color` object. ☑️ + - `capitalize()` : Capitalize the word. ☑️ diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..91cc0d7 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,10 @@ +include: package:lints/recommended.yaml + +linter: + rules: + - prefer_relative_imports + - close_sinks + - avoid_empty_else + - file_names + - prefer_const_constructors + - no_leading_underscores_for_local_identifiers diff --git a/lib/astromic_extensions.dart b/lib/astromic_extensions.dart new file mode 100644 index 0000000..6e4d2aa --- /dev/null +++ b/lib/astromic_extensions.dart @@ -0,0 +1,8 @@ +library astromic_extensions; + +export './src/border_extensions.dart'; +export './src/insets_extension.dart'; +export './src/list_extensions.dart'; +export 'src/alignment_extensions.dart'; +export './src/radius_extensions.dart'; +export './src/string_extensions.dart'; diff --git a/lib/src/alignment_extensions.dart b/lib/src/alignment_extensions.dart new file mode 100644 index 0000000..6e5e861 --- /dev/null +++ b/lib/src/alignment_extensions.dart @@ -0,0 +1,16 @@ +import 'package:flutter/material.dart'; + +extension TextAlignVerticalExtension on TextAlignVertical { + Alignment toAlignment() { + switch (this) { + case TextAlignVertical.top: + return Alignment.topCenter; + case TextAlignVertical.center: + return Alignment.center; + case TextAlignVertical.bottom: + return Alignment.bottomCenter; + default: + return Alignment.center; + } + } +} diff --git a/lib/src/border_extensions.dart b/lib/src/border_extensions.dart new file mode 100644 index 0000000..58e9fb0 --- /dev/null +++ b/lib/src/border_extensions.dart @@ -0,0 +1,7 @@ +import "package:flutter/painting.dart"; + +extension BorderExtension on BorderDirectional { + BorderDirectional all(BorderSide side) { + return BorderDirectional(top: side, bottom: side, start: side, end: side); + } +} diff --git a/lib/src/insets_extension.dart b/lib/src/insets_extension.dart new file mode 100644 index 0000000..a557276 --- /dev/null +++ b/lib/src/insets_extension.dart @@ -0,0 +1,12 @@ +import 'package:flutter/widgets.dart'; + +extension InsetsExtension on EdgeInsetsGeometry { + copyWith(EdgeInsetsGeometry g) => add(g); + // + EdgeInsetsDirectional resolveToDirectional(TextDirection direction) { + // + return EdgeInsetsDirectional.fromSTEB(direction == TextDirection.ltr ? resolve(direction).left : resolve(direction).right, resolve(direction).top, + direction == TextDirection.ltr ? resolve(direction).right : resolve(direction).left, resolve(direction).bottom); + // + } +} diff --git a/lib/src/list_extensions.dart b/lib/src/list_extensions.dart new file mode 100644 index 0000000..b6b5b3a --- /dev/null +++ b/lib/src/list_extensions.dart @@ -0,0 +1,20 @@ +extension ListExtension on List { + bool containsAll(List otherList) { + List checks = []; + // + for (E thisElement in otherList) { + checks.add(contains(thisElement)); + } + return !checks.contains(false); + } + + List getUnique() { + List uniqueItems = []; + for (E thisElement in this) { + if (!uniqueItems.contains(thisElement)) { + uniqueItems.add(thisElement); + } + } + return uniqueItems; + } +} diff --git a/lib/src/radius_extensions.dart b/lib/src/radius_extensions.dart new file mode 100644 index 0000000..0563f5a --- /dev/null +++ b/lib/src/radius_extensions.dart @@ -0,0 +1,15 @@ +import 'package:flutter/widgets.dart'; + +extension RadiusExtension on BorderRadiusGeometry { + copyWith(BorderRadiusGeometry g) => add(g); + // + BorderRadiusDirectional resolveToDirectional(TextDirection direction) { + // + return BorderRadiusDirectional.only( + topStart: direction == TextDirection.ltr ? resolve(direction).topLeft : resolve(direction).topRight, + topEnd: direction == TextDirection.rtl ? resolve(direction).topLeft : resolve(direction).topRight, + bottomEnd: direction == TextDirection.rtl ? resolve(direction).bottomRight : resolve(direction).bottomRight, + bottomStart: direction == TextDirection.ltr ? resolve(direction).bottomLeft : resolve(direction).bottomRight, + ); + } +} diff --git a/lib/src/string_extensions.dart b/lib/src/string_extensions.dart new file mode 100644 index 0000000..050d38c --- /dev/null +++ b/lib/src/string_extensions.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; + +extension StringExtensions on String { + /// Parse the HexCode to color + Color get toColor { + if (this == '') return const Color(0xFF000000); + String hexColor = replaceAll('#', ''); + hexColor = hexColor.replaceAll('0x', ''); + hexColor = hexColor.padLeft(6, '0'); + hexColor = hexColor.padLeft(8, 'F'); + final int length = hexColor.length; + return Color(int.tryParse('0x${hexColor.substring(length - 8, length)}') ?? 0xFF000000); + } + + /// Capitalize the first letter in a string. + String get capitalize { + return (length > 1) ? this[0].toUpperCase() + substring(1) : toUpperCase(); + } +} diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..d65b50e --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,72 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + characters: + dependency: transitive + description: + name: characters + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" + source: hosted + version: "1.3.0" + collection: + dependency: transitive + description: + name: collection + sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf + url: "https://pub.dev" + source: hosted + version: "1.19.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + url: "https://pub.dev" + source: hosted + version: "2.0.3" + lints: + dependency: transitive + description: + name: lints + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.dev" + source: hosted + version: "0.11.1" + meta: + dependency: transitive + description: + name: meta + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 + url: "https://pub.dev" + source: hosted + version: "1.15.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" +sdks: + dart: ">=3.6.0 <4.0.0" + flutter: ">3.27.0" diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..6c32ba9 --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,38 @@ +##SECTION --Project Information +name: astromic_extensions +description: The extensions module of the Astromic Presentation System +publish_to: "none" +## App Version scheme: Major.Feature.Fixes+Build +version: 0.1.0 +##!SECTION --Project Information +# +# +##SECTION --Environment Constraints +environment: + sdk: ">=3.6.0" + flutter: ">3.27.0" +##!SECTION --Environment Constraints +# +# +##SECTION -- Dependencies Overrides +# dependency_overrides: +##!SECTION -- Dependencies Overrides +# +# +##SECTION --Development Dependencies +dev_dependencies: + flutter_lints: ^2.0.3 + ## +##!SECTION --Development Dependencies +# +# +##SECTION --Dependencies +dependencies: + flutter: + sdk: flutter + # +##!SECTION --Dependencies +# +# +##SECTION --App Assets +##!SECTION --App Assets