From 24ef2a655879f6b0beb54a2bbb6b93453002a2c7 Mon Sep 17 00:00:00 2001 From: Mithul Nayagam Date: Fri, 13 Jun 2025 13:32:12 +0530 Subject: [PATCH] Added dividerColor and dividerHeight to StacTabBar --- .../widgets/stac_tab_bar/stac_tab_bar.dart | 2 + .../stac_tab_bar/stac_tab_bar.freezed.dart | 140 ++++++++++++------ .../widgets/stac_tab_bar/stac_tab_bar.g.dart | 4 + .../stac_tab_bar/stac_tab_bar_parser.dart | 2 + 4 files changed, 101 insertions(+), 47 deletions(-) diff --git a/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.dart b/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.dart index 45bf570e..330412ed 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.dart @@ -32,6 +32,8 @@ abstract class StacTabBar with _$StacTabBar { bool? enableFeedback, StacScrollPhysics? physics, TabAlignment? tabAlignment, + String? dividerColor, + double? dividerHeight, }) = _StacTabBar; factory StacTabBar.fromJson(Map json) => diff --git a/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.freezed.dart index 655be4d2..6c53444f 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.freezed.dart @@ -33,6 +33,8 @@ mixin _$StacTabBar { bool? get enableFeedback; StacScrollPhysics? get physics; TabAlignment? get tabAlignment; + String? get dividerColor; + double? get dividerHeight; /// Create a copy of StacTabBar /// with the given fields replaced by the non-null parameter values. @@ -83,35 +85,42 @@ mixin _$StacTabBar { other.enableFeedback == enableFeedback) && (identical(other.physics, physics) || other.physics == physics) && (identical(other.tabAlignment, tabAlignment) || - other.tabAlignment == tabAlignment)); + other.tabAlignment == tabAlignment) && + (identical(other.dividerColor, dividerColor) || + other.dividerColor == dividerColor) && + (identical(other.dividerHeight, dividerHeight) || + other.dividerHeight == dividerHeight)); } @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(tabs), - initialIndex, - isScrollable, - padding, - indicatorColor, - automaticIndicatorColorAdjustment, - indicatorWeight, - indicatorPadding, - indicatorSize, - labelColor, - labelStyle, - labelPadding, - unselectedLabelColor, - unselectedLabelStyle, - dragStartBehavior, - enableFeedback, - physics, - tabAlignment); + int get hashCode => Object.hashAll([ + runtimeType, + const DeepCollectionEquality().hash(tabs), + initialIndex, + isScrollable, + padding, + indicatorColor, + automaticIndicatorColorAdjustment, + indicatorWeight, + indicatorPadding, + indicatorSize, + labelColor, + labelStyle, + labelPadding, + unselectedLabelColor, + unselectedLabelStyle, + dragStartBehavior, + enableFeedback, + physics, + tabAlignment, + dividerColor, + dividerHeight + ]); @override String toString() { - return 'StacTabBar(tabs: $tabs, initialIndex: $initialIndex, isScrollable: $isScrollable, padding: $padding, indicatorColor: $indicatorColor, automaticIndicatorColorAdjustment: $automaticIndicatorColorAdjustment, indicatorWeight: $indicatorWeight, indicatorPadding: $indicatorPadding, indicatorSize: $indicatorSize, labelColor: $labelColor, labelStyle: $labelStyle, labelPadding: $labelPadding, unselectedLabelColor: $unselectedLabelColor, unselectedLabelStyle: $unselectedLabelStyle, dragStartBehavior: $dragStartBehavior, enableFeedback: $enableFeedback, physics: $physics, tabAlignment: $tabAlignment)'; + return 'StacTabBar(tabs: $tabs, initialIndex: $initialIndex, isScrollable: $isScrollable, padding: $padding, indicatorColor: $indicatorColor, automaticIndicatorColorAdjustment: $automaticIndicatorColorAdjustment, indicatorWeight: $indicatorWeight, indicatorPadding: $indicatorPadding, indicatorSize: $indicatorSize, labelColor: $labelColor, labelStyle: $labelStyle, labelPadding: $labelPadding, unselectedLabelColor: $unselectedLabelColor, unselectedLabelStyle: $unselectedLabelStyle, dragStartBehavior: $dragStartBehavior, enableFeedback: $enableFeedback, physics: $physics, tabAlignment: $tabAlignment, dividerColor: $dividerColor, dividerHeight: $dividerHeight)'; } } @@ -139,7 +148,9 @@ abstract mixin class $StacTabBarCopyWith<$Res> { DragStartBehavior dragStartBehavior, bool? enableFeedback, StacScrollPhysics? physics, - TabAlignment? tabAlignment}); + TabAlignment? tabAlignment, + String? dividerColor, + double? dividerHeight}); $StacEdgeInsetsCopyWith<$Res>? get padding; $StacEdgeInsetsCopyWith<$Res>? get indicatorPadding; @@ -178,6 +189,8 @@ class _$StacTabBarCopyWithImpl<$Res> implements $StacTabBarCopyWith<$Res> { Object? enableFeedback = freezed, Object? physics = freezed, Object? tabAlignment = freezed, + Object? dividerColor = freezed, + Object? dividerHeight = freezed, }) { return _then(_self.copyWith( tabs: null == tabs @@ -253,6 +266,14 @@ class _$StacTabBarCopyWithImpl<$Res> implements $StacTabBarCopyWith<$Res> { ? _self.tabAlignment : tabAlignment // ignore: cast_nullable_to_non_nullable as TabAlignment?, + dividerColor: freezed == dividerColor + ? _self.dividerColor + : dividerColor // ignore: cast_nullable_to_non_nullable + as String?, + dividerHeight: freezed == dividerHeight + ? _self.dividerHeight + : dividerHeight // ignore: cast_nullable_to_non_nullable + as double?, )); } @@ -348,7 +369,9 @@ class _StacTabBar implements StacTabBar { this.dragStartBehavior = DragStartBehavior.start, this.enableFeedback, this.physics, - this.tabAlignment}) + this.tabAlignment, + this.dividerColor, + this.dividerHeight}) : _tabs = tabs; factory _StacTabBar.fromJson(Map json) => _$StacTabBarFromJson(json); @@ -400,6 +423,10 @@ class _StacTabBar implements StacTabBar { final StacScrollPhysics? physics; @override final TabAlignment? tabAlignment; + @override + final String? dividerColor; + @override + final double? dividerHeight; /// Create a copy of StacTabBar /// with the given fields replaced by the non-null parameter values. @@ -455,35 +482,42 @@ class _StacTabBar implements StacTabBar { other.enableFeedback == enableFeedback) && (identical(other.physics, physics) || other.physics == physics) && (identical(other.tabAlignment, tabAlignment) || - other.tabAlignment == tabAlignment)); + other.tabAlignment == tabAlignment) && + (identical(other.dividerColor, dividerColor) || + other.dividerColor == dividerColor) && + (identical(other.dividerHeight, dividerHeight) || + other.dividerHeight == dividerHeight)); } @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(_tabs), - initialIndex, - isScrollable, - padding, - indicatorColor, - automaticIndicatorColorAdjustment, - indicatorWeight, - indicatorPadding, - indicatorSize, - labelColor, - labelStyle, - labelPadding, - unselectedLabelColor, - unselectedLabelStyle, - dragStartBehavior, - enableFeedback, - physics, - tabAlignment); + int get hashCode => Object.hashAll([ + runtimeType, + const DeepCollectionEquality().hash(_tabs), + initialIndex, + isScrollable, + padding, + indicatorColor, + automaticIndicatorColorAdjustment, + indicatorWeight, + indicatorPadding, + indicatorSize, + labelColor, + labelStyle, + labelPadding, + unselectedLabelColor, + unselectedLabelStyle, + dragStartBehavior, + enableFeedback, + physics, + tabAlignment, + dividerColor, + dividerHeight + ]); @override String toString() { - return 'StacTabBar(tabs: $tabs, initialIndex: $initialIndex, isScrollable: $isScrollable, padding: $padding, indicatorColor: $indicatorColor, automaticIndicatorColorAdjustment: $automaticIndicatorColorAdjustment, indicatorWeight: $indicatorWeight, indicatorPadding: $indicatorPadding, indicatorSize: $indicatorSize, labelColor: $labelColor, labelStyle: $labelStyle, labelPadding: $labelPadding, unselectedLabelColor: $unselectedLabelColor, unselectedLabelStyle: $unselectedLabelStyle, dragStartBehavior: $dragStartBehavior, enableFeedback: $enableFeedback, physics: $physics, tabAlignment: $tabAlignment)'; + return 'StacTabBar(tabs: $tabs, initialIndex: $initialIndex, isScrollable: $isScrollable, padding: $padding, indicatorColor: $indicatorColor, automaticIndicatorColorAdjustment: $automaticIndicatorColorAdjustment, indicatorWeight: $indicatorWeight, indicatorPadding: $indicatorPadding, indicatorSize: $indicatorSize, labelColor: $labelColor, labelStyle: $labelStyle, labelPadding: $labelPadding, unselectedLabelColor: $unselectedLabelColor, unselectedLabelStyle: $unselectedLabelStyle, dragStartBehavior: $dragStartBehavior, enableFeedback: $enableFeedback, physics: $physics, tabAlignment: $tabAlignment, dividerColor: $dividerColor, dividerHeight: $dividerHeight)'; } } @@ -513,7 +547,9 @@ abstract mixin class _$StacTabBarCopyWith<$Res> DragStartBehavior dragStartBehavior, bool? enableFeedback, StacScrollPhysics? physics, - TabAlignment? tabAlignment}); + TabAlignment? tabAlignment, + String? dividerColor, + double? dividerHeight}); @override $StacEdgeInsetsCopyWith<$Res>? get padding; @@ -557,6 +593,8 @@ class __$StacTabBarCopyWithImpl<$Res> implements _$StacTabBarCopyWith<$Res> { Object? enableFeedback = freezed, Object? physics = freezed, Object? tabAlignment = freezed, + Object? dividerColor = freezed, + Object? dividerHeight = freezed, }) { return _then(_StacTabBar( tabs: null == tabs @@ -632,6 +670,14 @@ class __$StacTabBarCopyWithImpl<$Res> implements _$StacTabBarCopyWith<$Res> { ? _self.tabAlignment : tabAlignment // ignore: cast_nullable_to_non_nullable as TabAlignment?, + dividerColor: freezed == dividerColor + ? _self.dividerColor + : dividerColor // ignore: cast_nullable_to_non_nullable + as String?, + dividerHeight: freezed == dividerHeight + ? _self.dividerHeight + : dividerHeight // ignore: cast_nullable_to_non_nullable + as double?, )); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.g.dart b/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.g.dart index 2a6a347f..1f2f70c7 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.g.dart @@ -44,6 +44,8 @@ _StacTabBar _$StacTabBarFromJson(Map json) => _StacTabBar( physics: $enumDecodeNullable(_$StacScrollPhysicsEnumMap, json['physics']), tabAlignment: $enumDecodeNullable(_$TabAlignmentEnumMap, json['tabAlignment']), + dividerColor: json['dividerColor'] as String?, + dividerHeight: (json['dividerHeight'] as num?)?.toDouble(), ); Map _$StacTabBarToJson(_StacTabBar instance) => @@ -68,6 +70,8 @@ Map _$StacTabBarToJson(_StacTabBar instance) => 'enableFeedback': instance.enableFeedback, 'physics': _$StacScrollPhysicsEnumMap[instance.physics], 'tabAlignment': _$TabAlignmentEnumMap[instance.tabAlignment], + 'dividerColor': instance.dividerColor, + 'dividerHeight': instance.dividerHeight, }; const _$TabBarIndicatorSizeEnumMap = { diff --git a/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar_parser.dart index df1cc8bf..f95e425b 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar_parser.dart @@ -44,6 +44,8 @@ class StacTabBarParser extends StacParser { onTap: (_) {}, physics: model.physics?.parse, tabAlignment: model.tabAlignment, + dividerColor: model.dividerColor.toColor(context), + dividerHeight: model.dividerHeight, ); } }