diff --git a/CHANGELOG.md b/CHANGELOG.md index f550d94..7952e3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.1.1 +- **FEAT**: Added a shared storage between sheet parts with a provider. + ## 0.1.1 - **FIX**: Adding export for `AstromicFieldState`. diff --git a/lib/src/form/src/form.dart b/lib/src/form/src/form.dart new file mode 100644 index 0000000..bb37b3f --- /dev/null +++ b/lib/src/form/src/form.dart @@ -0,0 +1,104 @@ +//s1 Imports +//s2 Core Package Imports +import 'package:flutter/material.dart'; +//s2 1st-party Package Imports +//s2 3rd-party Package Imports +//s2 Dependancies Imports +//s3 Routes +//s3 Services +//s3 Models & Widgets +//s1 Exports + +class AstromicForm extends StatefulWidget { + //SECTION - Widget Arguments + //!SECTION + // + const AstromicForm({ + super.key, + }); + + @override + State createState() => _AstromicFormState(); +} + +class _AstromicFormState extends State { + // + //SECTION - State Variables + //s1 --State + //s1 --State + // + //s1 --Controllers + //late AstromicFormController _formController; + //s1 --Controllers + // + //s1 --Constants + //s1 --Constants + //!SECTION + + @override + void initState() { + super.initState(); + // + //SECTION - State Variables initializations & Listeners + //s1 --State + //s1 --State + // + //s1 --Controllers & Listeners + // _formController = AstromicFormController(); + //s1 --Controllers & Listeners + // + //s1 --Late & Async Initializers + //s1 --Late & Async Initializers + //!SECTION + } + + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + // + //SECTION - State Variables initializations & Listeners + //s1 --State + //s1 --State + // + //s1 --Controllers & Listeners + //s1 --Controllers & Listeners + // + //!SECTION + } + + //SECTION - Dumb Widgets + //!SECTION + + //SECTION - Stateless functions + //!SECTION + + //SECTION - Action Callbacks + //!SECTION + + @override + Widget build(BuildContext context) { + //SECTION - Build Setup + //s1 --Values + //double w = MediaQuery.of(context).size.width; + //double h = MediaQuery.of(context).size.height; + //s1 --Values + // + //s1 --Contexted Widgets + //s1 --Contexted Widgets + //!SECTION + + //SECTION - Build Return + return Scaffold( + body: Container(), + ); + //!SECTION + } + + @override + void dispose() { + //SECTION - Disposable variables + //!SECTION + super.dispose(); + } +} diff --git a/lib/src/form/src/models/form_row.model.dart b/lib/src/form/src/models/form_row.model.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/src/sheet/sheet_helper.astromic.dart b/lib/src/sheet/sheet_helper.astromic.dart index d4dad8d..6c9978a 100644 --- a/lib/src/sheet/sheet_helper.astromic.dart +++ b/lib/src/sheet/sheet_helper.astromic.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; //s2 1st-party Package Imports //s2 3rd-party Package Imports +import 'package:provider/provider.dart'; //s2 Dependancies Imports //s3 Routes //s3 Services @@ -12,6 +13,7 @@ import '../form/form_helper.astromic.dart'; import '../sheet/src/models/models.exports.dart'; import '../sheet/src/enums/enums.exports.dart'; import '../sheet/src/widgets/widgets.exports.dart'; +import 'src/models/sheet_store.model.dart'; //s1 Exports export '../sheet/src/models/models.exports.dart'; export '../form/form_helper.astromic.dart' show AstromicFormController; @@ -60,17 +62,19 @@ class AstromicSheetHelper { reverseAnimationDuration: sheetConfigs.reverseAnimationDuration ?? const Duration(milliseconds: 250), animationCurve: sheetConfigs.animationCurve ?? Curves.easeOut, // - barrierColor: sheetStyle.maskColor , + barrierColor: sheetStyle.maskColor, radius: sheetStyle.radius, // - child: BaseSheetWidget( - sheetConfiguration: sheetConfigs, - sheetStyle: sheetStyle, - // - headSection: headSection, - contentSection: contentSection, - footerSection: footerSection, - ), + child: ChangeNotifierProvider( + create: (BuildContext c) => SheetStore(), + child: BaseSheetWidget( + sheetConfiguration: sheetConfigs, + sheetStyle: sheetStyle, + // + headSection: headSection, + contentSection: contentSection, + footerSection: footerSection, + )), ); } @@ -118,15 +122,18 @@ class AstromicSheetHelper { barrierColor: sheetStyle.maskColor, radius: sheetStyle.radius, // - child: BaseSheetWidget( - sheetType: SheetType.form, - // - sheetConfiguration: sheetConfigs, - sheetStyle: sheetStyle, - // - headSectionFormBuilder: headSectionBuilder, - contentSectionFormBuilder: contentSectionBuilder, - footerSectionFormBuilder: footerSectionBuilder, + child: ChangeNotifierProvider( + create: (BuildContext c) => SheetStore(), + child: BaseSheetWidget( + sheetType: SheetType.form, + // + sheetConfiguration: sheetConfigs, + sheetStyle: sheetStyle, + // + headSectionFormBuilder: headSectionBuilder, + contentSectionFormBuilder: contentSectionBuilder, + footerSectionFormBuilder: footerSectionBuilder, + ), ), ); } @@ -192,15 +199,18 @@ class AstromicSheetHelper { topInset: sheetStyle.topInset, // s2 -- Child builder: (BuildContext context, ScrollController scrollController, ScrollPhysics scrollPhysics, int stop) { - return BaseSheetWidget( - sheetType: SheetType.scroller, - sheetConfiguration: sheetConfigs, - sheetStyle: sheetStyle, - headSectionScrollerBuilder: headSectionBuilder, - contentSectionScrollBuilder: contentSectionBuilder, - footerSectionScrollerBuilder: footerSectionBuilder, - scrollController: scrollController, - scrollPhysics: scrollPhysics, + return ChangeNotifierProvider( + create: (BuildContext c) => SheetStore(), + child: BaseSheetWidget( + sheetType: SheetType.scroller, + sheetConfiguration: sheetConfigs, + sheetStyle: sheetStyle, + headSectionScrollerBuilder: headSectionBuilder, + contentSectionScrollBuilder: contentSectionBuilder, + footerSectionScrollerBuilder: footerSectionBuilder, + scrollController: scrollController, + scrollPhysics: scrollPhysics, + ), ); }, ); diff --git a/lib/src/sheet/src/models/sheet_store.model.dart b/lib/src/sheet/src/models/sheet_store.model.dart new file mode 100644 index 0000000..a375d2e --- /dev/null +++ b/lib/src/sheet/src/models/sheet_store.model.dart @@ -0,0 +1,38 @@ +import 'dart:collection'; + +import 'package:flutter/widgets.dart'; + +class SheetStore extends ChangeNotifier { + /// Internal, private state of the store. + final Map _items = {}; + + /// An unmodifiable view of the items in the store. + UnmodifiableMapView get items => UnmodifiableMapView(_items); + + /// Adds [item] to store. + void add(String itemID, dynamic value) { + _items.addEntries(>[MapEntry(itemID, value)]); + // This call tells the widgets that are listening to this store to rebuild. + notifyListeners(); + } + + /// Updates [item] in the store. + void update(String itemID, dynamic value) { + if (!_items.containsKey(itemID)) { + throw Exception('No item with the ID $itemID exist in the SheetStore, Are you sure you added it?'); + } + _items[itemID] = value; + // This call tells the widgets that are listening to this store to rebuild. + notifyListeners(); + } + + /// Removes [item] from the store. + void remove(String itemID, dynamic value) { + if (!_items.containsKey(itemID)) { + throw Exception('No item with the ID $itemID exist in the SheetStore, Are you sure you added it?'); + } + _items.remove(itemID); + // This call tells the widgets that are listening to this store to rebuild. + notifyListeners(); + } +} diff --git a/pubspec.lock b/pubspec.lock index 305bb80..b5f0fe1 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -224,6 +224,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.16.0" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" + source: hosted + version: "1.0.0" octo_image: dependency: transitive description: @@ -320,6 +328,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.8" + provider: + dependency: "direct main" + description: + name: provider + sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c + url: "https://pub.dev" + source: hosted + version: "6.1.2" rxdart: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index bb61af0..1f70a00 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: astromic_helpers description: The helpers module of the Astromic Presentation System publish_to: "none" -version: 0.1.1+2 +version: 0.1.2 environment: sdk: ">=3.6.0" @@ -19,6 +19,8 @@ dependencies: url: https://git.micazi.dev/micazi/astromic_elements.git ref: master ##S1 ~ 3rd-party + ## Needed for the sheet helper. + provider: ^6.1.2 ## Needed for the form helper. form_controller: ^0.8.8+2 ## Needed for the loading helper.