DEV: Spacing & Widgets
This commit is contained in:
7
.flutter-plugins
Normal file
7
.flutter-plugins
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# This is a generated file; do not edit or check into version control.
|
||||||
|
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/
|
||||||
1
.flutter-plugins-dependencies
Normal file
1
.flutter-plugins-dependencies
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"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-04-22 17:37:45.222080","version":"3.19.1"}
|
||||||
52
README.md
52
README.md
@@ -1,39 +1,19 @@
|
|||||||
<!--
|
## Atromic Mobile: Elements
|
||||||
This README describes the package. If you publish this package to pub.dev,
|
|
||||||
this README's contents appear on the landing page for your package.
|
|
||||||
|
|
||||||
For information about how to write a good package README, see the guide for
|
The elements module of the **Astromic Mobile** Presentation System
|
||||||
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages).
|
Developed, Maintained, and is property of Michael W. Aziz (Micazi)
|
||||||
|
|
||||||
For general information about developing packages, see the Dart guide for
|
### Content
|
||||||
[creating packages](https://dart.dev/guides/libraries/create-library-packages)
|
|
||||||
and the Flutter guide for
|
|
||||||
[developing packages and plugins](https://flutter.dev/developing-packages).
|
|
||||||
-->
|
|
||||||
|
|
||||||
TODO: Put a short description of the package here that helps potential users
|
- Spacing
|
||||||
know whether this package might be useful for them.
|
- VSB,HSB
|
||||||
|
- Flexer
|
||||||
## Features
|
- Divider
|
||||||
|
- Buttons
|
||||||
TODO: List what your package can do. Maybe include images, gifs, or videos.
|
- Fields
|
||||||
|
- Selectors
|
||||||
## Getting started
|
- Toggles
|
||||||
|
- Widgets
|
||||||
TODO: List prerequisites and provide or point to information on how to
|
- Image
|
||||||
start using the package.
|
- Scaffold
|
||||||
|
- Blur
|
||||||
## Usage
|
|
||||||
|
|
||||||
TODO: Include short and useful examples for package users. Add longer examples
|
|
||||||
to `/example` folder.
|
|
||||||
|
|
||||||
```dart
|
|
||||||
const like = 'sample';
|
|
||||||
```
|
|
||||||
|
|
||||||
## Additional information
|
|
||||||
|
|
||||||
TODO: Tell users more about the package: where to find more information, how to
|
|
||||||
contribute to the package, how to file issues, what response they can expect
|
|
||||||
from the package authors, and more.
|
|
||||||
|
|||||||
@@ -1,4 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: package:flutter_lints/flutter.yaml
|
||||||
|
|
||||||
# Additional information about this file can be found at
|
|
||||||
# https://dart.dev/guides/language/analysis-options
|
|
||||||
|
|||||||
73
lib/Infrastructure/transparent_image.dart
Normal file
73
lib/Infrastructure/transparent_image.dart
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
library transparent_image;
|
||||||
|
|
||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
final Uint8List kTransparentImage = Uint8List.fromList(<int>[
|
||||||
|
0x89,
|
||||||
|
0x50,
|
||||||
|
0x4E,
|
||||||
|
0x47,
|
||||||
|
0x0D,
|
||||||
|
0x0A,
|
||||||
|
0x1A,
|
||||||
|
0x0A,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x0D,
|
||||||
|
0x49,
|
||||||
|
0x48,
|
||||||
|
0x44,
|
||||||
|
0x52,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x01,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x01,
|
||||||
|
0x08,
|
||||||
|
0x06,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x1F,
|
||||||
|
0x15,
|
||||||
|
0xC4,
|
||||||
|
0x89,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x0A,
|
||||||
|
0x49,
|
||||||
|
0x44,
|
||||||
|
0x41,
|
||||||
|
0x54,
|
||||||
|
0x78,
|
||||||
|
0x9C,
|
||||||
|
0x63,
|
||||||
|
0x00,
|
||||||
|
0x01,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x05,
|
||||||
|
0x00,
|
||||||
|
0x01,
|
||||||
|
0x0D,
|
||||||
|
0x0A,
|
||||||
|
0x2D,
|
||||||
|
0xB4,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x49,
|
||||||
|
0x45,
|
||||||
|
0x4E,
|
||||||
|
0x44,
|
||||||
|
0xAE,
|
||||||
|
0x42,
|
||||||
|
0x60,
|
||||||
|
0x82,
|
||||||
|
]);
|
||||||
@@ -1,7 +1,12 @@
|
|||||||
library astromic_mobile_elements;
|
library astromic_mobile_elements;
|
||||||
|
|
||||||
/// A Calculator.
|
//
|
||||||
class Calculator {
|
export './src/Spacing/spacing.astromic.dart';
|
||||||
/// Returns [value] plus 1.
|
// export './src/2.Buttons/buttons.astromic.dart';
|
||||||
int addOne(int value) => value + 1;
|
// export './src/3.Selectors/selectors.astromic.dart';
|
||||||
}
|
// export './src/4.Toggles/toggles.astromic.dart';
|
||||||
|
// export './src/5.Fields/fields.astromic.dart';
|
||||||
|
// export './src/6.Widgets/Widgets.astromic.dart';
|
||||||
|
// //
|
||||||
|
// export './src/styles/styles.astromic.dart';
|
||||||
|
// export './src/configurations/configs.astromic.dart';
|
||||||
49
lib/src/Spacing/spacing.astromic.dart
Normal file
49
lib/src/Spacing/spacing.astromic.dart
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class AstromicSpacing {
|
||||||
|
//S1 -- SizedBox
|
||||||
|
static Widget vsb([double h = 0]) => SizedBox(height: h);
|
||||||
|
static Widget hsb([double w = 0]) => SizedBox(width: w);
|
||||||
|
|
||||||
|
//s1 --- FLEXER
|
||||||
|
static Widget flexer(int factor, [Widget? child]) => factor >= 0
|
||||||
|
? Expanded(
|
||||||
|
flex: factor == 0 ? 1 : factor,
|
||||||
|
child: child ?? Container(),
|
||||||
|
)
|
||||||
|
: factor == -1 && child != null
|
||||||
|
? Flexible(child: child)
|
||||||
|
: Spacer(flex: factor);
|
||||||
|
|
||||||
|
//S1 --- DIVIDER
|
||||||
|
static divider(
|
||||||
|
double thickness,
|
||||||
|
Color color, {
|
||||||
|
double length = 24.0,
|
||||||
|
double margin = 8.0,
|
||||||
|
Axis mode = Axis.horizontal,
|
||||||
|
bool rounded = true,
|
||||||
|
}) =>
|
||||||
|
SizedBox(
|
||||||
|
height: mode == Axis.horizontal
|
||||||
|
? thickness + (2 * margin)
|
||||||
|
: mode == Axis.vertical
|
||||||
|
? length
|
||||||
|
: 0,
|
||||||
|
width: mode == Axis.vertical
|
||||||
|
? thickness + (2 * margin)
|
||||||
|
: mode == Axis.horizontal
|
||||||
|
? length
|
||||||
|
: 0,
|
||||||
|
child: Container(
|
||||||
|
margin: EdgeInsets.symmetric(
|
||||||
|
horizontal: mode == Axis.vertical ? margin : 0,
|
||||||
|
vertical: mode == Axis.horizontal ? margin : 0,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: color,
|
||||||
|
borderRadius: rounded ? BorderRadius.circular(1000) : BorderRadius.zero,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
39
lib/src/Widgets/src/blur.widget.dart
Normal file
39
lib/src/Widgets/src/blur.widget.dart
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import 'dart:ui';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
Widget astromicBlurEffect(
|
||||||
|
Widget child,
|
||||||
|
double sigmaX,
|
||||||
|
double sigmaY, {
|
||||||
|
Widget? topChild,
|
||||||
|
Color? overlayColor = const Color.fromRGBO(0, 0, 0, 0.1),
|
||||||
|
TileMode? tileMode = TileMode.mirror,
|
||||||
|
List<BoxShadow>? shadow,
|
||||||
|
BorderRadius? radius,
|
||||||
|
}) =>
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
boxShadow: shadow,
|
||||||
|
),
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: radius ?? BorderRadius.zero,
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
child,
|
||||||
|
BackdropFilter(
|
||||||
|
filter: ImageFilter.blur(
|
||||||
|
sigmaX: 5.0,
|
||||||
|
sigmaY: 5.0,
|
||||||
|
tileMode: TileMode.mirror,
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: overlayColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
topChild ?? Container(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
217
lib/src/Widgets/src/image.widget.dart
Normal file
217
lib/src/Widgets/src/image.widget.dart
Normal file
@@ -0,0 +1,217 @@
|
|||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:octo_image/octo_image.dart';
|
||||||
|
|
||||||
|
import '../../../Infrastructure/transparent_image.dart';
|
||||||
|
|
||||||
|
Widget astromicImage(
|
||||||
|
BuildContext context, {
|
||||||
|
//S1 -- Asset
|
||||||
|
String? assetPath,
|
||||||
|
String? assetURL,
|
||||||
|
Uint8List? assetBytes,
|
||||||
|
String? assetFallback,
|
||||||
|
//
|
||||||
|
//S1 -- Sizing | Width
|
||||||
|
double? wFactor, // variable width ratio
|
||||||
|
double? minW, // Min width allowed
|
||||||
|
double? maxW, // Max width allowed
|
||||||
|
double? fixedWidth, // Only used when uisng height variables
|
||||||
|
//S1 -- Sizing | Width
|
||||||
|
bool useHeight = false, // use height constrains
|
||||||
|
double? hFactor, // Variable height ratio
|
||||||
|
double? minH, // Min Height allowed
|
||||||
|
double? maxH, // Max height allowed
|
||||||
|
double? fixedHeight, // Only used when using width variables
|
||||||
|
//S1 -- STYLING
|
||||||
|
bool circular = false,
|
||||||
|
double? border,
|
||||||
|
Color? borderColor,
|
||||||
|
EdgeInsetsGeometry? borderPadding,
|
||||||
|
BorderRadiusGeometry radius = BorderRadius.zero,
|
||||||
|
List<BoxShadow>? shadow,
|
||||||
|
//S1 -- SVG FILTERS
|
||||||
|
Color? color,
|
||||||
|
BlendMode? blend,
|
||||||
|
//S1 -- CONFIGS
|
||||||
|
BoxFit fit = BoxFit.cover,
|
||||||
|
Alignment alignment = Alignment.center,
|
||||||
|
LinearGradient? linearGradient,
|
||||||
|
//S1 -- STATE
|
||||||
|
Widget? loadingWidget,
|
||||||
|
Widget? errorWidget,
|
||||||
|
}) {
|
||||||
|
//
|
||||||
|
assert(minW == null || maxW == null, "Please specify only one width constrain");
|
||||||
|
assert(minH == null || maxH == null, "Please specify only one height constrain");
|
||||||
|
assert(!useHeight || (hFactor != null), "Please specify The height factor and constrains");
|
||||||
|
assert(
|
||||||
|
(assetPath != null && assetBytes == null && assetURL == null) ||
|
||||||
|
(assetPath == null && assetBytes != null && assetURL == null) ||
|
||||||
|
(assetPath == null && assetBytes == null && assetURL != null) ||
|
||||||
|
(assetFallback != null && assetFallback != ''),
|
||||||
|
"Please specify only one Asset Source");
|
||||||
|
//
|
||||||
|
//
|
||||||
|
bool fromPath = (assetPath != null && assetPath != '');
|
||||||
|
bool fromBytes = (assetBytes != null && assetBytes.isNotEmpty);
|
||||||
|
bool fromNetwork = (assetURL != null && assetURL != '' && Uri.tryParse(assetURL) != null);
|
||||||
|
//
|
||||||
|
String finalAssetKey = fromPath
|
||||||
|
? assetPath
|
||||||
|
: fromNetwork
|
||||||
|
? assetURL
|
||||||
|
: fromBytes
|
||||||
|
? assetBytes.length.toString()
|
||||||
|
: 'N/A';
|
||||||
|
//
|
||||||
|
bool isFallback = (assetBytes == null && assetURL == null && assetPath == null && assetFallback != null);
|
||||||
|
bool isSVG = fromPath
|
||||||
|
? assetPath.endsWith('.svg')
|
||||||
|
: fromNetwork
|
||||||
|
? assetURL.endsWith('.svg')
|
||||||
|
: isFallback
|
||||||
|
? assetFallback.endsWith('.svg')
|
||||||
|
: false;
|
||||||
|
//
|
||||||
|
double h = MediaQuery.of(context).size.height;
|
||||||
|
double? fh = hFactor != null ? hFactor * h : null;
|
||||||
|
double w = MediaQuery.of(context).size.width;
|
||||||
|
double? fw = wFactor != null ? wFactor * w : null;
|
||||||
|
|
||||||
|
//
|
||||||
|
double? finalW = useHeight
|
||||||
|
? fixedWidth
|
||||||
|
: fw != null
|
||||||
|
? fw > (maxW ?? double.infinity)
|
||||||
|
? maxW
|
||||||
|
: fw < (minW ?? 0)
|
||||||
|
? minW
|
||||||
|
: fw
|
||||||
|
: null;
|
||||||
|
double? finalH = !useHeight
|
||||||
|
? fixedHeight
|
||||||
|
: fh != null
|
||||||
|
? fh > (maxH ?? double.infinity)
|
||||||
|
? maxH
|
||||||
|
: fh < (minH ?? 0)
|
||||||
|
? minH
|
||||||
|
: fh
|
||||||
|
: null;
|
||||||
|
//
|
||||||
|
Widget finalError = errorWidget ??
|
||||||
|
const Center(
|
||||||
|
child: Text("Error has happened.."),
|
||||||
|
);
|
||||||
|
//
|
||||||
|
Widget finalLoading = loadingWidget ?? Container();
|
||||||
|
//
|
||||||
|
ImageProvider finalImageProvider = isFallback
|
||||||
|
? AssetImage(
|
||||||
|
assetFallback,
|
||||||
|
)
|
||||||
|
: fromPath
|
||||||
|
? AssetImage(
|
||||||
|
assetPath,
|
||||||
|
)
|
||||||
|
: fromBytes
|
||||||
|
? MemoryImage(assetBytes)
|
||||||
|
: fromNetwork
|
||||||
|
? CachedNetworkImageProvider(
|
||||||
|
assetURL,
|
||||||
|
cacheKey: assetURL,
|
||||||
|
)
|
||||||
|
: MemoryImage(kTransparentImage) as ImageProvider;
|
||||||
|
//
|
||||||
|
Widget? finalSVGWidget = fromPath
|
||||||
|
? SvgPicture.asset(
|
||||||
|
assetPath,
|
||||||
|
key: ValueKey(assetPath),
|
||||||
|
width: finalW,
|
||||||
|
height: finalH,
|
||||||
|
fit: fit,
|
||||||
|
placeholderBuilder: (_) => SizedBox(
|
||||||
|
width: finalW,
|
||||||
|
height: finalH,
|
||||||
|
child: finalLoading,
|
||||||
|
),
|
||||||
|
alignment: alignment,
|
||||||
|
colorFilter: color != null ? ColorFilter.mode(color, blend ?? BlendMode.srcATop) : null,
|
||||||
|
)
|
||||||
|
: fromNetwork
|
||||||
|
? SvgPicture.network(
|
||||||
|
assetURL,
|
||||||
|
key: ValueKey(assetURL),
|
||||||
|
width: finalW,
|
||||||
|
height: finalH,
|
||||||
|
fit: fit,
|
||||||
|
placeholderBuilder: (_) => SizedBox(
|
||||||
|
width: finalW,
|
||||||
|
height: finalH,
|
||||||
|
child: finalLoading,
|
||||||
|
),
|
||||||
|
alignment: alignment,
|
||||||
|
colorFilter: color != null ? ColorFilter.mode(color, blend ?? BlendMode.srcATop) : null,
|
||||||
|
)
|
||||||
|
: null;
|
||||||
|
//
|
||||||
|
return SizedBox(
|
||||||
|
width: finalW,
|
||||||
|
height: finalH,
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
OctoImage(
|
||||||
|
key: ValueKey(finalAssetKey),
|
||||||
|
//
|
||||||
|
width: finalW,
|
||||||
|
height: finalH,
|
||||||
|
fit: fit,
|
||||||
|
alignment: alignment,
|
||||||
|
filterQuality: FilterQuality.none,
|
||||||
|
color: color,
|
||||||
|
colorBlendMode: blend ?? (isSVG ? BlendMode.srcATop : null),
|
||||||
|
//
|
||||||
|
errorBuilder: (context, error, stackTrace) {
|
||||||
|
return finalError;
|
||||||
|
},
|
||||||
|
//
|
||||||
|
progressIndicatorBuilder: (a, b) => SizedBox(
|
||||||
|
width: finalW,
|
||||||
|
height: finalH,
|
||||||
|
child: finalLoading,
|
||||||
|
),
|
||||||
|
|
||||||
|
imageBuilder: (context, image) => Container(
|
||||||
|
width: finalW,
|
||||||
|
height: finalH,
|
||||||
|
padding: borderPadding ?? EdgeInsets.zero,
|
||||||
|
margin: EdgeInsets.zero,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: border != null
|
||||||
|
? Border.all(
|
||||||
|
strokeAlign: BorderSide.strokeAlignInside,
|
||||||
|
width: border,
|
||||||
|
color: borderColor ?? const Color(0xff000000),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
borderRadius: circular ? BorderRadius.circular(10000) : radius,
|
||||||
|
boxShadow: shadow,
|
||||||
|
),
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: circular ? BorderRadius.circular(10000) : radius,
|
||||||
|
child: isSVG ? finalSVGWidget : image,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
image: isSVG ? MemoryImage(kTransparentImage) : finalImageProvider,
|
||||||
|
),
|
||||||
|
if (linearGradient != null)
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(gradient: linearGradient),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
76
lib/src/Widgets/src/scaffold.widget.dart
Normal file
76
lib/src/Widgets/src/scaffold.widget.dart
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
//
|
||||||
|
Widget astromicScaffold({
|
||||||
|
//S1 -- AppBar
|
||||||
|
PreferredSizeWidget? appBar,
|
||||||
|
bool isAppbarStacked = false,
|
||||||
|
//S1 -- FAB
|
||||||
|
Widget? floatingActionButton,
|
||||||
|
FloatingActionButtonLocation? floatingActionButtonLocation,
|
||||||
|
//S1 -- Other Integral Components
|
||||||
|
Widget? drawer,
|
||||||
|
Widget? bottomNavigationBar,
|
||||||
|
Widget? bottomSheet,
|
||||||
|
//S1 -- Styling
|
||||||
|
Color? backgroundColor,
|
||||||
|
EdgeInsetsGeometry? padding,
|
||||||
|
ScrollPhysics? scrollPhysics = const BouncingScrollPhysics(),
|
||||||
|
//S1 -- Configs
|
||||||
|
bool withSafeArea = false,
|
||||||
|
bool extendBody = false,
|
||||||
|
bool resizeToAvoidBottomInset = true,
|
||||||
|
bool withScrollView = false,
|
||||||
|
bool closeKeyboardOnTap = true,
|
||||||
|
//
|
||||||
|
Widget? body,
|
||||||
|
//
|
||||||
|
}) {
|
||||||
|
assert(!withScrollView || (withScrollView && body is Column), 'Make sure you add a column in the body section!');
|
||||||
|
//
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: backgroundColor,
|
||||||
|
//
|
||||||
|
appBar: isAppbarStacked ? null : appBar,
|
||||||
|
floatingActionButton: floatingActionButton,
|
||||||
|
floatingActionButtonLocation: floatingActionButtonLocation,
|
||||||
|
drawer: drawer,
|
||||||
|
bottomNavigationBar: bottomNavigationBar,
|
||||||
|
bottomSheet: bottomSheet,
|
||||||
|
//
|
||||||
|
resizeToAvoidBottomInset: resizeToAvoidBottomInset,
|
||||||
|
extendBody: extendBody,
|
||||||
|
body: Stack(
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
onTap: !withScrollView && closeKeyboardOnTap ? () => FocusManager.instance.primaryFocus?.unfocus() : null,
|
||||||
|
child: withSafeArea
|
||||||
|
? SafeArea(
|
||||||
|
child: withScrollView
|
||||||
|
? SingleChildScrollView(
|
||||||
|
keyboardDismissBehavior: closeKeyboardOnTap ? ScrollViewKeyboardDismissBehavior.onDrag : ScrollViewKeyboardDismissBehavior.manual,
|
||||||
|
physics: scrollPhysics,
|
||||||
|
padding: padding ?? EdgeInsets.zero,
|
||||||
|
child: body,
|
||||||
|
)
|
||||||
|
: Padding(
|
||||||
|
padding: padding ?? EdgeInsets.zero,
|
||||||
|
child: body,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: withScrollView
|
||||||
|
? SingleChildScrollView(
|
||||||
|
keyboardDismissBehavior: closeKeyboardOnTap ? ScrollViewKeyboardDismissBehavior.onDrag : ScrollViewKeyboardDismissBehavior.manual,
|
||||||
|
padding: padding ?? EdgeInsets.zero,
|
||||||
|
child: body,
|
||||||
|
)
|
||||||
|
: Padding(
|
||||||
|
padding: padding ?? EdgeInsets.zero,
|
||||||
|
child: body,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
isAppbarStacked && appBar != null ? Wrap(children: [appBar]) : Container(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
157
lib/src/Widgets/widgets.astromic.dart
Normal file
157
lib/src/Widgets/widgets.astromic.dart
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
import 'dart:typed_data';
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
|
//s2 Core Packages Imports
|
||||||
|
import 'package:astromic_mobile_elements/src/Widgets/src/blur.widget.dart';
|
||||||
|
import 'package:astromic_mobile_elements/src/Widgets/src/scaffold.widget.dart';
|
||||||
|
import 'src/image.widget.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class AstromicWidgets {
|
||||||
|
//S1 -- SCAFFOLD
|
||||||
|
static Widget scaffold({
|
||||||
|
//S1 -- AppBar
|
||||||
|
PreferredSizeWidget? appBar,
|
||||||
|
bool isAppbarStacked = false,
|
||||||
|
//S1 -- FAB
|
||||||
|
Widget? floatingActionButton,
|
||||||
|
FloatingActionButtonLocation? floatingActionButtonLocation,
|
||||||
|
//S1 -- Other Integral Components
|
||||||
|
Widget? drawer,
|
||||||
|
Widget? bottomNavigationBar,
|
||||||
|
Widget? bottomSheet,
|
||||||
|
//S1 -- Styling
|
||||||
|
Color? backgroundColor,
|
||||||
|
EdgeInsetsGeometry? padding,
|
||||||
|
ScrollPhysics? scrollPhysics = const BouncingScrollPhysics(),
|
||||||
|
//S1 -- Configs
|
||||||
|
bool withSafeArea = false,
|
||||||
|
bool extendBody = false,
|
||||||
|
bool resizeToAvoidBottomInset = true,
|
||||||
|
bool withScrollView = false,
|
||||||
|
bool closeKeyboardOnTap = true,
|
||||||
|
//
|
||||||
|
Widget? body,
|
||||||
|
//
|
||||||
|
}) =>
|
||||||
|
astromicScaffold(
|
||||||
|
//
|
||||||
|
appBar: appBar,
|
||||||
|
isAppbarStacked: isAppbarStacked,
|
||||||
|
//
|
||||||
|
floatingActionButton: floatingActionButton,
|
||||||
|
floatingActionButtonLocation: floatingActionButtonLocation,
|
||||||
|
//
|
||||||
|
drawer: drawer,
|
||||||
|
bottomNavigationBar: bottomNavigationBar,
|
||||||
|
bottomSheet: bottomSheet,
|
||||||
|
//
|
||||||
|
backgroundColor: backgroundColor,
|
||||||
|
padding: padding,
|
||||||
|
scrollPhysics: scrollPhysics,
|
||||||
|
//
|
||||||
|
withSafeArea: withSafeArea,
|
||||||
|
extendBody: extendBody,
|
||||||
|
resizeToAvoidBottomInset: resizeToAvoidBottomInset,
|
||||||
|
withScrollView: withScrollView,
|
||||||
|
closeKeyboardOnTap: closeKeyboardOnTap,
|
||||||
|
//
|
||||||
|
body: body,
|
||||||
|
);
|
||||||
|
|
||||||
|
//S1 -- IMAGE
|
||||||
|
static Widget image(
|
||||||
|
BuildContext context, {
|
||||||
|
//S1 -- Asset
|
||||||
|
String? assetPath,
|
||||||
|
String? assetURL,
|
||||||
|
Uint8List? assetBytes,
|
||||||
|
String? assetFallback,
|
||||||
|
//S1 -- Sizing | Width
|
||||||
|
double? wFactor,
|
||||||
|
double? minW,
|
||||||
|
double? maxW,
|
||||||
|
double? fixedWidth,
|
||||||
|
//S1 -- Sizing | Width
|
||||||
|
bool useHeight = false,
|
||||||
|
double? hFactor,
|
||||||
|
double? minH,
|
||||||
|
double? maxH,
|
||||||
|
double? fixedHeight,
|
||||||
|
//S1 -- STYLING
|
||||||
|
bool circular = false,
|
||||||
|
double? border,
|
||||||
|
Color? borderColor,
|
||||||
|
EdgeInsetsGeometry? borderPadding,
|
||||||
|
BorderRadiusGeometry radius = BorderRadius.zero,
|
||||||
|
List<BoxShadow>? shadow,
|
||||||
|
//S1 -- SVG FILTERS
|
||||||
|
Color? color,
|
||||||
|
BlendMode? blend,
|
||||||
|
//S1 -- CONFIGS
|
||||||
|
BoxFit fit = BoxFit.cover,
|
||||||
|
Alignment alignment = Alignment.center,
|
||||||
|
LinearGradient? linearGradient,
|
||||||
|
//S1 -- STATE
|
||||||
|
Widget? loadingWidget,
|
||||||
|
Widget? errorWidget,
|
||||||
|
}) =>
|
||||||
|
astromicImage(
|
||||||
|
context,
|
||||||
|
//
|
||||||
|
assetPath: assetPath,
|
||||||
|
assetURL: assetURL,
|
||||||
|
assetBytes: assetBytes,
|
||||||
|
assetFallback: assetFallback,
|
||||||
|
//
|
||||||
|
wFactor: wFactor,
|
||||||
|
minW: minW,
|
||||||
|
maxW: maxW,
|
||||||
|
fixedWidth: fixedWidth,
|
||||||
|
//
|
||||||
|
useHeight: useHeight,
|
||||||
|
hFactor: hFactor,
|
||||||
|
minH: minH,
|
||||||
|
maxH: maxH,
|
||||||
|
fixedHeight: fixedHeight,
|
||||||
|
//
|
||||||
|
circular: circular,
|
||||||
|
border: border,
|
||||||
|
borderColor: borderColor,
|
||||||
|
borderPadding: borderPadding,
|
||||||
|
radius: radius,
|
||||||
|
shadow: shadow,
|
||||||
|
//
|
||||||
|
color: color,
|
||||||
|
blend: blend,
|
||||||
|
//
|
||||||
|
fit: fit,
|
||||||
|
alignment: alignment,
|
||||||
|
linearGradient: linearGradient,
|
||||||
|
//
|
||||||
|
loadingWidget: loadingWidget,
|
||||||
|
errorWidget: errorWidget,
|
||||||
|
);
|
||||||
|
|
||||||
|
//S1 -- BLUR
|
||||||
|
static Widget blur(
|
||||||
|
Widget child,
|
||||||
|
double sigmaX,
|
||||||
|
double sigmaY, {
|
||||||
|
Widget? topChild,
|
||||||
|
Color? overlayColor = const Color.fromRGBO(0, 0, 0, 0.1),
|
||||||
|
TileMode? tileMode = TileMode.mirror,
|
||||||
|
List<BoxShadow>? shadow,
|
||||||
|
BorderRadius? radius,
|
||||||
|
}) =>
|
||||||
|
astromicBlurEffect(
|
||||||
|
child,
|
||||||
|
sigmaX,
|
||||||
|
sigmaY,
|
||||||
|
topChild: topChild,
|
||||||
|
overlayColor: overlayColor,
|
||||||
|
tileMode: tileMode,
|
||||||
|
shadow: shadow,
|
||||||
|
radius: radius,
|
||||||
|
);
|
||||||
|
}
|
||||||
83
pubspec.yaml
83
pubspec.yaml
@@ -1,54 +1,47 @@
|
|||||||
|
##SECTION --Project Information
|
||||||
name: astromic_mobile_elements
|
name: astromic_mobile_elements
|
||||||
description: "A new Flutter package project."
|
description: The elements module of the Astromic Mobile Presentation System
|
||||||
version: 0.0.1
|
publish_to: "none"
|
||||||
homepage:
|
## App Version scheme: Major.Feature.Fixes+Build
|
||||||
|
version: 0.0.0+1
|
||||||
|
##!SECTION --Project Information
|
||||||
|
#
|
||||||
|
#
|
||||||
|
##SECTION --Environment Constraints
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.3.0 <4.0.0'
|
sdk: ">=3.1.1 <4.0.0"
|
||||||
flutter: ">=1.17.0"
|
flutter: ">3.10.0"
|
||||||
|
##!SECTION --Environment Constraints
|
||||||
dependencies:
|
#
|
||||||
flutter:
|
#
|
||||||
sdk: flutter
|
##SECTION -- Dependencies Overrides
|
||||||
|
# dependency_overrides:
|
||||||
|
# intl: ^0.18.1
|
||||||
|
##!SECTION -- Dependencies Overrides
|
||||||
|
#
|
||||||
|
#
|
||||||
|
##SECTION --Development Dependencies
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_lints: ^3.0.0
|
flutter_lints: ^2.0.3
|
||||||
|
##
|
||||||
# For information on the generic Dart part of this file, see the
|
##!SECTION --Development Dependencies
|
||||||
# following page: https://dart.dev/tools/pub/pubspec
|
#
|
||||||
|
#
|
||||||
# The following section is specific to Flutter packages.
|
##SECTION --Dependencies
|
||||||
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
|
sdk: flutter
|
||||||
# To add assets to your package, add an assets section, like this:
|
##S1 -- Widgets
|
||||||
# assets:
|
cached_network_image: ^3.2.3
|
||||||
# - images/a_dot_burr.jpeg
|
flutter_svg: ^2.0.5
|
||||||
# - images/a_dot_ham.jpeg
|
octo_image: ^1.0.2
|
||||||
#
|
#
|
||||||
# For details regarding assets in packages, see
|
##!SECTION --Dependencies
|
||||||
# https://flutter.dev/assets-and-images/#from-packages
|
|
||||||
#
|
#
|
||||||
# An image asset can refer to one or more resolution-specific "variants", see
|
|
||||||
# https://flutter.dev/assets-and-images/#resolution-aware
|
|
||||||
|
|
||||||
# To add custom fonts to your package, add a fonts section here,
|
|
||||||
# in this "flutter" section. Each entry in this list should have a
|
|
||||||
# "family" key with the font family name, and a "fonts" key with a
|
|
||||||
# list giving the asset and other descriptors for the font. For
|
|
||||||
# example:
|
|
||||||
# fonts:
|
|
||||||
# - family: Schyler
|
|
||||||
# fonts:
|
|
||||||
# - asset: fonts/Schyler-Regular.ttf
|
|
||||||
# - asset: fonts/Schyler-Italic.ttf
|
|
||||||
# style: italic
|
|
||||||
# - family: Trajan Pro
|
|
||||||
# fonts:
|
|
||||||
# - asset: fonts/TrajanPro.ttf
|
|
||||||
# - asset: fonts/TrajanPro_Bold.ttf
|
|
||||||
# weight: 700
|
|
||||||
#
|
#
|
||||||
# For details regarding fonts in packages, see
|
##SECTION --App Assets
|
||||||
# https://flutter.dev/custom-fonts/#from-packages
|
flutter:
|
||||||
|
uses-material-design: true
|
||||||
|
##!SECTION --App Assets
|
||||||
|
|||||||
Reference in New Issue
Block a user