Skip to content

Commit 0941399

Browse files
authored
Stac Framework Enhancements: Navigation, Borders, Colors & Architecture Improvements (#361)
* refactor: migrate StacDefaultBottomNavigationController to stac_core - Migrate StacDefaultBottomNavigationController from legacy Freezed model to new stac_models system - Move model definition from packages/stac to packages/stac_core/lib/widgets/ - Replace Freezed-generated code with JsonSerializable-based implementation - Update parser to use new StacWidget base class and parse method - Add comprehensive documentation with Dart and JSON examples - Remove legacy Freezed files (.freezed.dart) and update imports - Update widget exports in both packages This migration follows the established pattern of moving widget models to the stac_models package while maintaining backward compatibility. The new implementation provides better type safety and follows the current architecture standards. Files changed: - Deleted: packages/stac/lib/src/parsers/widgets/stac_default_bottom_navigation_controller/*.dart - Added: packages/stac_core/lib/widgets/default_bottom_navigation_controller/stac_default_bottom_navigation_controller.dart - Updated: parser implementation and widget exports * fix: change StacSetValueAction.action type from Map to StacAction - Change action field type from Map<String, dynamic>? to StacAction? - Update JSON serialization to properly handle StacAction objects - Regenerate model files to reflect the type change - Remove trailing whitespace in actionType getter * feat: add .all and .symmetric factory methods to StacBorder - Add StacBorder.all() factory method for uniform borders on all sides - Add StacBorder.symmetric() factory method for horizontal/vertical symmetric borders - Include comprehensive documentation with Dart and JSON examples for both methods - Provide convenient constructors for common border patterns * feat: add factory constructors to StacBorderRadius - Add StacBorderRadius.only() factory for individual side styling - Add StacBorderRadius.horizontal() factory for top/bottom borders only - Add StacBorderRadius.vertical() factory for left/right borders only - Add StacBorderRadius.circular() factory for uniform circular borders - Include comprehensive documentation with Dart and JSON examples * fix: defer BottomNavigationScope access to build time in navigation parsers - Wrap StacBottomNavigationBar in _BottomNavigationBarWidget to defer controller access - Wrap StacBottomNavigationView in _BottomNavigationViewWidget to defer controller access - Move BottomNavigationScope.of(context) calls from parse() to build() methods - Fix timing issue where InheritedWidget was accessed before being created The issue was that both navigation parsers were calling BottomNavigationScope.of(context) during the parsing phase, before the BottomNavigationScope was actually created in the widget tree by StacDefaultBottomNavigationController. This caused the controller to be null and prevented proper communication between the navigation bar and view. By wrapping the widgets and deferring the BottomNavigationScope access to build time, the InheritedWidget is guaranteed to be available when needed, ensuring proper bottom navigation functionality. * feat: add withOpacity extension method to StacColor - Add StacColorExtension with withOpacity() method - Support opacity values from 0.0 to 1.0 with automatic clamping - Convert opacity to percentage format (@<opacity>) for consistency - Include comprehensive documentation with Dart and JSON examples - Enable easy opacity manipulation for both hex colors and theme colors
1 parent 47d4dfe commit 0941399

File tree

16 files changed

+494
-435
lines changed

16 files changed

+494
-435
lines changed

packages/stac/lib/src/parsers/actions/stac_set_value/stac_set_value_action_parser.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'dart:async';
22

33
import 'package:flutter/material.dart';
4+
import 'package:stac/src/parsers/core/stac_action_parser.dart';
45
import 'package:stac/stac.dart';
56
import 'package:stac_core/stac_core.dart';
67

@@ -22,6 +23,6 @@ class StacSetValueActionParser extends StacActionParser<StacSetValueAction> {
2223
for (final value in model.values ?? []) {
2324
StacRegistry.instance.setValue(value['key'] as String, value['value']);
2425
}
25-
return Stac.onCallFromJson(model.action, context);
26+
return model.action.parse(context);
2627
}
2728
}

packages/stac/lib/src/parsers/widgets/stac_bottom_navigation_bar/stac_bottom_navigation_bar_parser.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:stac/src/parsers/core/stac_widget_parser.dart';
33
import 'package:stac/src/parsers/foundation/navigation/stac_bottom_navigation_bar_landscape_layout_parser.dart';
44
import 'package:stac/src/parsers/foundation/navigation/stac_bottom_navigation_bar_type_parser.dart';
55
import 'package:stac/src/parsers/foundation/text/stac_text_style_parser.dart';
6-
import 'package:stac/src/parsers/widgets/stac_default_bottom_navigation_controller/stac_default_bottom_navigation_controller.dart';
6+
import 'package:stac/src/parsers/widgets/stac_default_bottom_navigation_controller/stac_default_bottom_navigation_controller_parser.dart';
77
import 'package:stac/src/utils/color_utils.dart';
88
import 'package:stac_core/stac_core.dart';
99
import 'package:stac_framework/stac_framework.dart';
@@ -21,6 +21,17 @@ class StacBottomNavigationBarParser
2121

2222
@override
2323
Widget parse(BuildContext context, StacBottomNavigationBar model) {
24+
return _BottomNavigationBarWidget(model: model);
25+
}
26+
}
27+
28+
class _BottomNavigationBarWidget extends StatelessWidget {
29+
const _BottomNavigationBarWidget({required this.model});
30+
31+
final StacBottomNavigationBar model;
32+
33+
@override
34+
Widget build(BuildContext context) {
2435
final controller = BottomNavigationScope.of(context)?.controller;
2536

2637
return BottomNavigationBar(

packages/stac/lib/src/parsers/widgets/stac_bottom_navigation_view/stac_bottom_navigation_view_parser.dart

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import 'package:flutter/material.dart';
22
import 'package:stac/src/parsers/core/stac_widget_parser.dart';
3+
import 'package:stac/src/parsers/widgets/stac_default_bottom_navigation_controller/stac_default_bottom_navigation_controller_parser.dart';
34
import 'package:stac_core/stac_core.dart';
45
import 'package:stac_framework/stac_framework.dart';
56

6-
import '../stac_default_bottom_navigation_controller/stac_default_bottom_navigation_controller.dart';
7-
87
class StacBottomNavigationViewParser
98
extends StacParser<StacBottomNavigationView> {
109
const StacBottomNavigationViewParser();
@@ -18,6 +17,17 @@ class StacBottomNavigationViewParser
1817

1918
@override
2019
Widget parse(BuildContext context, StacBottomNavigationView model) {
20+
return _BottomNavigationViewWidget(model: model);
21+
}
22+
}
23+
24+
class _BottomNavigationViewWidget extends StatelessWidget {
25+
const _BottomNavigationViewWidget({required this.model});
26+
27+
final StacBottomNavigationView model;
28+
29+
@override
30+
Widget build(BuildContext context) {
2131
final controller = BottomNavigationScope.of(context)?.controller;
2232
if (model.children.isEmpty) return const SizedBox();
2333
final index = controller?.index ?? 0;

packages/stac/lib/src/parsers/widgets/stac_default_bottom_navigation_controller/stac_default_bottom_navigation_controller.dart

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)