[DEV] Separated selectors configurations

This commit is contained in:
2024-05-16 18:50:42 +03:00
parent 8fb0a7bf9e
commit c3d60dba73
5 changed files with 52 additions and 27 deletions

View File

@@ -1,12 +1,12 @@
//s2 Core Packages Imports //s2 Core Packages Imports
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'src/radio.selector.dart'; import 'src/Radio/radio.selector.dart';
import 'src/chip.selector.dart'; import 'src/Chip/chip.selector.dart';
import 'src/configuration.dart'; import 'src/Radio/configuration.dart';
import 'src/Chip/configuration.dart';
// //
export 'src/radio.selector.dart'; export 'src/Radio/configuration.dart';
export 'src/chip.selector.dart'; export 'src/Chip/configuration.dart';
export 'src/configuration.dart';
class AstromicSelectors { class AstromicSelectors {
//S1 -- Radio //S1 -- Radio
@@ -14,7 +14,7 @@ class AstromicSelectors {
T? initialSelectedValue, T? initialSelectedValue,
Function(T selectedItem)? onChanged, Function(T selectedItem)? onChanged,
// //
AstromicSelectorConfiguration? configurations, AstromicRadioSelectorConfiguration? configurations,
// //
double? itemSpacing = 4, double? itemSpacing = 4,
// //
@@ -25,7 +25,7 @@ class AstromicSelectors {
initialSelectedValue: initialSelectedValue, initialSelectedValue: initialSelectedValue,
onChanged: onChanged, onChanged: onChanged,
// //
configuration: configurations ?? const AstromicSelectorConfiguration(), configuration: configurations ?? const AstromicRadioSelectorConfiguration(),
// //
itemSpacing: itemSpacing ?? 8.0, itemSpacing: itemSpacing ?? 8.0,
// //
@@ -38,7 +38,7 @@ class AstromicSelectors {
List<T>? initialSelectedValues, List<T>? initialSelectedValues,
void Function(List<T> selectedItems)? onChanged, void Function(List<T> selectedItems)? onChanged,
// //
AstromicSelectorConfiguration? configuration, AstromicChipSelectorConfiguration? configuration,
bool isCustom = false, bool isCustom = false,
// //
double? itemSpacing = 4, double? itemSpacing = 4,

View File

@@ -10,7 +10,7 @@ import 'package:flutter/material.dart';
//--------------- //---------------
//s2 SERVICES //s2 SERVICES
//s2 MODELS //s2 MODELS
import '../../../Infrastructure/list_extensions.dart'; import '../../../../Infrastructure/list_extensions.dart';
import 'configuration.dart'; import 'configuration.dart';
//s2 MISC //s2 MISC
@@ -26,7 +26,7 @@ class AstromicChipSelector<T> extends StatefulWidget {
final Function(List<T> selectedItems)? onChanged; final Function(List<T> selectedItems)? onChanged;
//s1 -- Configuration //s1 -- Configuration
final bool isCustom; final bool isCustom;
final AstromicSelectorConfiguration? configuration; final AstromicChipSelectorConfiguration? configuration;
//s1 -- Style //s1 -- Style
final double? itemSpacing; final double? itemSpacing;
final double? runSpacing; final double? runSpacing;
@@ -71,7 +71,7 @@ class AstromicChipSelector<T> extends StatefulWidget {
final List<T>? initialSelectedValues, final List<T>? initialSelectedValues,
final Function(List<T> selectedItems)? onChanged, final Function(List<T> selectedItems)? onChanged,
//s1 -- Configuration //s1 -- Configuration
final AstromicSelectorConfiguration? configuration, final AstromicChipSelectorConfiguration? configuration,
//s1 -- Content //s1 -- Content
required final List<(T item, bool isEnabled)> items, required final List<(T item, bool isEnabled)> items,
// //
@@ -109,7 +109,7 @@ class _AstromicChipSelectorState<T> extends State<AstromicChipSelector<T>> {
//s1 --Controllers //s1 --Controllers
// //
//s1 --State //s1 --State
late AstromicSelectorConfiguration _configuration; late AstromicChipSelectorConfiguration _configuration;
late List<T> selectedItems; late List<T> selectedItems;
//s1 --State //s1 --State
// //
@@ -127,7 +127,7 @@ class _AstromicChipSelectorState<T> extends State<AstromicChipSelector<T>> {
//s1 --Controllers & Listeners //s1 --Controllers & Listeners
// //
//s1 --State //s1 --State
_configuration = widget.configuration ?? const AstromicSelectorConfiguration(); _configuration = widget.configuration ?? const AstromicChipSelectorConfiguration();
selectedItems = widget.initialSelectedValues ?? []; selectedItems = widget.initialSelectedValues ?? [];
//s1 --State //s1 --State
// //

View File

@@ -1,10 +1,8 @@
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
class AstromicSelectorConfiguration { class AstromicChipSelectorConfiguration {
//s1 Shared
final Axis axis; final Axis axis;
final bool isNullable; final bool isNullable;
//s1 Chip Specific
final bool isWrap; final bool isWrap;
final WrapAlignment wrapMainAllignment; final WrapAlignment wrapMainAllignment;
final WrapCrossAlignment wrapCrossAllignment; final WrapCrossAlignment wrapCrossAllignment;
@@ -13,9 +11,7 @@ class AstromicSelectorConfiguration {
final int maxSelectedItems; final int maxSelectedItems;
final int crossAxisCount; final int crossAxisCount;
final double? fixedRowHeight; final double? fixedRowHeight;
//s1 Radio Specific const AstromicChipSelectorConfiguration({
final bool withExpandedSpace;
const AstromicSelectorConfiguration({
this.axis = Axis.horizontal, this.axis = Axis.horizontal,
this.isNullable = true, this.isNullable = true,
// //
@@ -27,11 +23,9 @@ class AstromicSelectorConfiguration {
this.maxSelectedItems = 10000, this.maxSelectedItems = 10000,
this.crossAxisCount = 3, this.crossAxisCount = 3,
this.fixedRowHeight, this.fixedRowHeight,
//
this.withExpandedSpace = false,
}); });
AstromicSelectorConfiguration copyWith({ AstromicChipSelectorConfiguration copyWith({
Axis? axis, Axis? axis,
bool? isNullable, bool? isNullable,
bool? isWrap, bool? isWrap,
@@ -44,7 +38,7 @@ class AstromicSelectorConfiguration {
bool? withExpandedSpace, bool? withExpandedSpace,
double? fixedRowHeight, double? fixedRowHeight,
}) { }) {
return AstromicSelectorConfiguration( return AstromicChipSelectorConfiguration(
axis: axis ?? this.axis, axis: axis ?? this.axis,
isNullable: isNullable ?? this.isNullable, isNullable: isNullable ?? this.isNullable,
isWrap: isWrap ?? this.isWrap, isWrap: isWrap ?? this.isWrap,
@@ -54,7 +48,6 @@ class AstromicSelectorConfiguration {
withClearButton: withClearButton ?? this.withClearButton, withClearButton: withClearButton ?? this.withClearButton,
maxSelectedItems: maxSelectedItems ?? this.maxSelectedItems, maxSelectedItems: maxSelectedItems ?? this.maxSelectedItems,
crossAxisCount: crossAxisCount ?? this.crossAxisCount, crossAxisCount: crossAxisCount ?? this.crossAxisCount,
withExpandedSpace: withExpandedSpace ?? this.withExpandedSpace,
fixedRowHeight: fixedRowHeight ?? this.fixedRowHeight, fixedRowHeight: fixedRowHeight ?? this.fixedRowHeight,
); );
} }

View File

@@ -0,0 +1,32 @@
import 'package:flutter/widgets.dart';
class AstromicRadioSelectorConfiguration {
final Axis axis;
final bool isNullable;
final bool withExpandedSpace;
const AstromicRadioSelectorConfiguration({
this.axis = Axis.horizontal,
this.isNullable = true,
this.withExpandedSpace = false,
});
AstromicRadioSelectorConfiguration copyWith({
Axis? axis,
bool? isNullable,
bool? isWrap,
WrapAlignment? wrapMainAllignment,
WrapCrossAlignment? wrapCrossAllignment,
bool? isConsequent,
bool? withClearButton,
int? maxSelectedItems,
int? crossAxisCount,
bool? withExpandedSpace,
double? fixedRowHeight,
}) {
return AstromicRadioSelectorConfiguration(
axis: axis ?? this.axis,
isNullable: isNullable ?? this.isNullable,
withExpandedSpace: withExpandedSpace ?? this.withExpandedSpace,
);
}
}

View File

@@ -10,7 +10,7 @@ import 'package:flutter/widgets.dart';
//--------------- //---------------
//s2 SERVICES //s2 SERVICES
//s2 MODELS //s2 MODELS
import '../../Spacing/spacing.astromic.dart'; import '../../../Spacing/spacing.astromic.dart';
import 'configuration.dart'; import 'configuration.dart';
//s2 MISC //s2 MISC
//!SECTION - Imports //!SECTION - Imports
@@ -26,7 +26,7 @@ class AstromicRadioSelector<T> extends StatefulWidget {
final T? initialSelectedValue; final T? initialSelectedValue;
final Function(T selectedItem)? onChanged; final Function(T selectedItem)? onChanged;
//s1 -- Configuration //s1 -- Configuration
final AstromicSelectorConfiguration configuration; final AstromicRadioSelectorConfiguration configuration;
//s1 -- Style //s1 -- Style
final double itemSpacing; final double itemSpacing;
//s1 -- Content //s1 -- Content