This commit is contained in:
2025-03-04 13:15:11 +02:00
parent 6543a4db38
commit 029e5dfe81
7 changed files with 201 additions and 28 deletions

View File

@@ -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<T?>(
sheetConfiguration: sheetConfigs,
sheetStyle: sheetStyle,
//
headSection: headSection,
contentSection: contentSection,
footerSection: footerSection,
),
child: ChangeNotifierProvider<SheetStore>(
create: (BuildContext c) => SheetStore(),
child: BaseSheetWidget<T?>(
sheetConfiguration: sheetConfigs,
sheetStyle: sheetStyle,
//
headSection: headSection,
contentSection: contentSection,
footerSection: footerSection,
)),
);
}
@@ -118,15 +122,18 @@ class AstromicSheetHelper {
barrierColor: sheetStyle.maskColor,
radius: sheetStyle.radius,
//
child: BaseSheetWidget<T?>(
sheetType: SheetType.form,
//
sheetConfiguration: sheetConfigs,
sheetStyle: sheetStyle,
//
headSectionFormBuilder: headSectionBuilder,
contentSectionFormBuilder: contentSectionBuilder,
footerSectionFormBuilder: footerSectionBuilder,
child: ChangeNotifierProvider<SheetStore>(
create: (BuildContext c) => SheetStore(),
child: BaseSheetWidget<T?>(
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<T?>(
sheetType: SheetType.scroller,
sheetConfiguration: sheetConfigs,
sheetStyle: sheetStyle,
headSectionScrollerBuilder: headSectionBuilder,
contentSectionScrollBuilder: contentSectionBuilder,
footerSectionScrollerBuilder: footerSectionBuilder,
scrollController: scrollController,
scrollPhysics: scrollPhysics,
return ChangeNotifierProvider<SheetStore>(
create: (BuildContext c) => SheetStore(),
child: BaseSheetWidget<T?>(
sheetType: SheetType.scroller,
sheetConfiguration: sheetConfigs,
sheetStyle: sheetStyle,
headSectionScrollerBuilder: headSectionBuilder,
contentSectionScrollBuilder: contentSectionBuilder,
footerSectionScrollerBuilder: footerSectionBuilder,
scrollController: scrollController,
scrollPhysics: scrollPhysics,
),
);
},
);

View File

@@ -0,0 +1,38 @@
import 'dart:collection';
import 'package:flutter/widgets.dart';
class SheetStore extends ChangeNotifier {
/// Internal, private state of the store.
final Map<String, dynamic> _items = <String, dynamic>{};
/// An unmodifiable view of the items in the store.
UnmodifiableMapView<String, dynamic> get items => UnmodifiableMapView<String, dynamic>(_items);
/// Adds [item] to store.
void add(String itemID, dynamic value) {
_items.addEntries(<MapEntry<String, dynamic>>[MapEntry<String, dynamic>(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();
}
}