Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions lib/src/multiselector/multiselector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class UniversalSelector extends StatefulWidget {
final bool showSubtitle;
final bool isMultiSelect;
final int? maxSelections;
final String? locale;

// UI Customization
final Color? backgroundColor;
Expand All @@ -23,12 +24,15 @@ class UniversalSelector extends StatefulWidget {
final Color? searchFieldBorderColor;
final Color? cursorColor;
final Color? hintTextColor;
final Color? previewContainerColor;
final Color? hoverColor;
final double? borderRadius;

const UniversalSelector({
super.key,
required this.items,
this.locale,
this.previewContainerColor,
this.selectedItem,
this.selectedItems = const [],
this.onItemSelected,
Expand Down Expand Up @@ -112,6 +116,7 @@ class _UniversalSelectorState extends State<UniversalSelector> {
Color get headerColor => widget.headerColor ?? _defaultHeaderColor;
Color get textColor => widget.textColor ?? _defaultTextColor;
Color get accentColor => widget.accentColor ?? _defaultAccentColor;
Color get previewContainerColor => widget.previewContainerColor ?? _defaultHeaderColor;
Color get searchFieldColor =>
widget.searchFieldColor ?? _defaultSearchFieldColor;
Color get searchFieldBorderColor =>
Expand All @@ -120,11 +125,13 @@ class _UniversalSelectorState extends State<UniversalSelector> {
Color get hintTextColor => widget.hintTextColor ?? _defaultHintTextColor;
Color get hoverColor => widget.hoverColor ?? _defaultHoverColor;
double get borderRadius => widget.borderRadius ?? _defaultBorderRadius;
String get locale => widget.locale ?? "en";

@override
void initState() {
super.initState();
_searchController.addListener(_onSearchChanged);
FocusScope.of(context).unfocus();
_allItems = ItemData.getSortedItems(widget.items);
_filteredItems = _allItems;
_selectedItems = List.from(widget.selectedItems);
Expand Down Expand Up @@ -237,7 +244,7 @@ class _UniversalSelectorState extends State<UniversalSelector> {
return _selectedItems.first.name;
}

return '${_selectedItems.length} items selected';
return '${_selectedItems.length} ${locale == "es" ? "Items seleccionados": "items selected"} ';
}

void _showItemPicker() {
Expand Down Expand Up @@ -313,7 +320,7 @@ class _UniversalSelectorState extends State<UniversalSelector> {
Navigator.of(context).pop();
},
child: Text(
'Done',
locale == "es" ? "Hecho" : 'Done',
style: TextStyle(
color: accentColor,
fontSize: 14,
Expand Down Expand Up @@ -349,7 +356,7 @@ class _UniversalSelectorState extends State<UniversalSelector> {
});
},
decoration: InputDecoration(
hintText: widget.hintText ?? 'Search items...',
hintText: widget.hintText ?? (locale == "es" ? "Buscar items..." : 'Search items...'),
hintStyle: TextStyle(
color: hintTextColor,
fontSize: 14,
Expand Down Expand Up @@ -522,7 +529,7 @@ class _UniversalSelectorState extends State<UniversalSelector> {
decoration: BoxDecoration(
border: Border.all(color: searchFieldBorderColor, width: 0.5),
borderRadius: BorderRadius.circular(borderRadius),
color: searchFieldColor,
color: Colors.orange,
),
child: Row(
children: [
Expand Down