From 664e03c0fe7ca5e357a2d1667970fadadb94858f Mon Sep 17 00:00:00 2001 From: "Michael W. Aziz" Date: Wed, 2 Oct 2024 13:04:47 +0300 Subject: [PATCH] [DEV] Added infrastructure extension exports --- .flutter-plugins | 12 ++++++------ .flutter-plugins-dependencies | 2 +- lib/Infrastructure/border_extensions.dart | 7 +++++++ .../infrastructure.exports.dart | 7 +++++++ lib/Infrastructure/insets_extension.dart | 10 ++++------ lib/Infrastructure/radius_extensions.dart | 15 +++++++++++++++ lib/Infrastructure/string_extensions.dart | 19 +++++++++++++++++++ lib/astromic_mobile_elements.dart | 1 + lib/src/Fields/src/action_field.dart | 6 +++--- 9 files changed, 63 insertions(+), 16 deletions(-) create mode 100644 lib/Infrastructure/border_extensions.dart create mode 100644 lib/Infrastructure/infrastructure.exports.dart create mode 100644 lib/Infrastructure/radius_extensions.dart create mode 100644 lib/Infrastructure/string_extensions.dart diff --git a/.flutter-plugins b/.flutter-plugins index 8146a38..7adee4f 100644 --- a/.flutter-plugins +++ b/.flutter-plugins @@ -1,7 +1,7 @@ # This is a generated file; do not edit or check into version control. -path_provider=C:\\Users\\Micazi\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider-2.1.3\\ -path_provider_android=C:\\Users\\Micazi\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider_android-2.2.4\\ -path_provider_foundation=C:\\Users\\Micazi\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider_foundation-2.4.0\\ -path_provider_linux=C:\\Users\\Micazi\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider_linux-2.2.1\\ -path_provider_windows=C:\\Users\\Micazi\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider_windows-2.2.1\\ -sqflite=C:\\Users\\Micazi\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\sqflite-2.3.3+1\\ +path_provider=/Users/micazi/.pub-cache/hosted/pub.dev/path_provider-2.1.3/ +path_provider_android=/Users/micazi/.pub-cache/hosted/pub.dev/path_provider_android-2.2.4/ +path_provider_foundation=/Users/micazi/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.2/ +path_provider_linux=/Users/micazi/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/ +path_provider_windows=/Users/micazi/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.1/ +sqflite=/Users/micazi/.pub-cache/hosted/pub.dev/sqflite-2.3.3/ diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index 3cb0fa4..247267d 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Micazi\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\Micazi\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\sqflite-2.3.3+1\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"C:\\\\Users\\\\Micazi\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.4\\\\","native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\Micazi\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\sqflite-2.3.3+1\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Micazi\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\Micazi\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\sqflite-2.3.3+1\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\Users\\\\Micazi\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\Users\\\\Micazi\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.2.1\\\\","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2024-05-22 17:33:59.184180","version":"3.22.0"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"/Users/micazi/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/micazi/.pub-cache/hosted/pub.dev/sqflite-2.3.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"/Users/micazi/.pub-cache/hosted/pub.dev/path_provider_android-2.2.4/","native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/micazi/.pub-cache/hosted/pub.dev/sqflite-2.3.3/","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"/Users/micazi/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/micazi/.pub-cache/hosted/pub.dev/sqflite-2.3.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/micazi/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/micazi/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.1/","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2024-09-17 12:51:18.099992","version":"3.24.1","swift_package_manager_enabled":false} \ No newline at end of file diff --git a/lib/Infrastructure/border_extensions.dart b/lib/Infrastructure/border_extensions.dart new file mode 100644 index 0000000..58e9fb0 --- /dev/null +++ b/lib/Infrastructure/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/Infrastructure/infrastructure.exports.dart b/lib/Infrastructure/infrastructure.exports.dart new file mode 100644 index 0000000..3eb61e2 --- /dev/null +++ b/lib/Infrastructure/infrastructure.exports.dart @@ -0,0 +1,7 @@ +export './border_extensions.dart'; +export './insets_extension.dart'; +export './list_extensions.dart'; +export './misc_extensions.dart'; +export './radius_extensions.dart'; +export './string_extensions.dart'; +export './transparent_image.dart'; diff --git a/lib/Infrastructure/insets_extension.dart b/lib/Infrastructure/insets_extension.dart index 974fb6a..a557276 100644 --- a/lib/Infrastructure/insets_extension.dart +++ b/lib/Infrastructure/insets_extension.dart @@ -1,14 +1,12 @@ -import 'dart:ui' as ui; - -import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; extension InsetsExtension on EdgeInsetsGeometry { copyWith(EdgeInsetsGeometry g) => add(g); // - EdgeInsetsDirectional resolveToDirectional(ui.TextDirection direction) { + EdgeInsetsDirectional resolveToDirectional(TextDirection direction) { // - return EdgeInsetsDirectional.fromSTEB(direction == ui.TextDirection.ltr ? resolve(direction).left : resolve(direction).right, resolve(direction).top, - direction == ui.TextDirection.ltr ? resolve(direction).right : resolve(direction).left, resolve(direction).bottom); + 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/Infrastructure/radius_extensions.dart b/lib/Infrastructure/radius_extensions.dart new file mode 100644 index 0000000..0563f5a --- /dev/null +++ b/lib/Infrastructure/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/Infrastructure/string_extensions.dart b/lib/Infrastructure/string_extensions.dart new file mode 100644 index 0000000..050d38c --- /dev/null +++ b/lib/Infrastructure/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/lib/astromic_mobile_elements.dart b/lib/astromic_mobile_elements.dart index 2773a72..a817a70 100644 --- a/lib/astromic_mobile_elements.dart +++ b/lib/astromic_mobile_elements.dart @@ -6,3 +6,4 @@ export './src/Selectors/selectors.astromic.dart'; export './src/Toggles/toggles.astromic.dart'; export './src/Buttons/buttons.astromic.dart'; export './src/Fields/fields.astromic.dart'; +export './Infrastructure/infrastructure.exports.dart'; diff --git a/lib/src/Fields/src/action_field.dart b/lib/src/Fields/src/action_field.dart index 921a57b..634f065 100644 --- a/lib/src/Fields/src/action_field.dart +++ b/lib/src/Fields/src/action_field.dart @@ -4,9 +4,9 @@ //s1 PACKAGES //--------------- //s2 CORE -import 'package:astromic_mobile_elements/Infrastructure/insets_extension.dart'; -import 'package:astromic_mobile_elements/Infrastructure/misc_extensions.dart'; -import 'package:astromic_mobile_elements/astromic_mobile_elements.dart'; +import '../../../Infrastructure/insets_extension.dart'; +import '../../../Infrastructure/misc_extensions.dart'; +import '../../../astromic_mobile_elements.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:intl/intl.dart' as intl;