v1.1.0: Major refactoring and improvements
This commit is contained in:
@@ -18,10 +18,6 @@ class CountriesSidebar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print('DEBUG: CountriesSidebar.build() called');
|
||||
print('DEBUG: CountriesSidebar received ${countries.length} countries: $countries');
|
||||
print('DEBUG: CountriesSidebar selectedCountry: "$selectedCountry"');
|
||||
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
final isLargeScreen = screenWidth > 900;
|
||||
final sidebarWidth = isLargeScreen ? 280.0 : 220.0;
|
||||
@@ -103,46 +99,48 @@ class CountriesSidebar extends StatelessWidget {
|
||||
),
|
||||
)
|
||||
: countries.isEmpty
|
||||
? Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(horizontalPadding),
|
||||
child: Text(
|
||||
'No hay países disponibles',
|
||||
style: TextStyle(
|
||||
color: Colors.white.withValues(alpha: 0.5),
|
||||
fontSize: fontSize,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
? Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(horizontalPadding),
|
||||
child: Text(
|
||||
'No hay países disponibles',
|
||||
style: TextStyle(
|
||||
color: Colors.white.withValues(alpha: 0.5),
|
||||
fontSize: fontSize,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: EdgeInsets.symmetric(vertical: isLargeScreen ? 12 : 8),
|
||||
itemCount: countries.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return _CountryListItem(
|
||||
name: 'Todos',
|
||||
isSelected: selectedCountry.isEmpty,
|
||||
onTap: () => onCountrySelected(''),
|
||||
itemHeight: itemHeight,
|
||||
fontSize: fontSize,
|
||||
horizontalPadding: horizontalPadding,
|
||||
icon: Icons.apps,
|
||||
);
|
||||
}
|
||||
|
||||
final country = countries[index - 1];
|
||||
return _CountryListItem(
|
||||
name: country,
|
||||
isSelected: selectedCountry == country,
|
||||
onTap: () => onCountrySelected(country),
|
||||
itemHeight: itemHeight,
|
||||
fontSize: fontSize,
|
||||
horizontalPadding: horizontalPadding,
|
||||
);
|
||||
},
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: isLargeScreen ? 12 : 8,
|
||||
),
|
||||
itemCount: countries.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return _CountryListItem(
|
||||
name: 'Todos',
|
||||
isSelected: selectedCountry.isEmpty,
|
||||
onTap: () => onCountrySelected(''),
|
||||
itemHeight: itemHeight,
|
||||
fontSize: fontSize,
|
||||
horizontalPadding: horizontalPadding,
|
||||
icon: Icons.apps,
|
||||
);
|
||||
}
|
||||
|
||||
final country = countries[index - 1];
|
||||
return _CountryListItem(
|
||||
name: country,
|
||||
isSelected: selectedCountry == country,
|
||||
onTap: () => onCountrySelected(country),
|
||||
itemHeight: itemHeight,
|
||||
fontSize: fontSize,
|
||||
horizontalPadding: horizontalPadding,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -172,10 +170,7 @@ class _CountryListItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: horizontalPadding,
|
||||
vertical: 2,
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: horizontalPadding, vertical: 2),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
@@ -211,7 +206,9 @@ class _CountryListItem extends StatelessWidget {
|
||||
if (icon != null) ...[
|
||||
Icon(
|
||||
icon,
|
||||
color: isSelected ? Colors.white : Colors.white.withValues(alpha: 0.6),
|
||||
color: isSelected
|
||||
? Colors.white
|
||||
: Colors.white.withValues(alpha: 0.6),
|
||||
size: fontSize + 2,
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
@@ -233,7 +230,9 @@ class _CountryListItem extends StatelessWidget {
|
||||
? Colors.white
|
||||
: Colors.white.withValues(alpha: 0.7),
|
||||
fontSize: fontSize,
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w400,
|
||||
fontWeight: isSelected
|
||||
? FontWeight.w600
|
||||
: FontWeight.w400,
|
||||
letterSpacing: 0.3,
|
||||
),
|
||||
maxLines: 1,
|
||||
@@ -241,11 +240,7 @@ class _CountryListItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
if (isSelected)
|
||||
Icon(
|
||||
Icons.check,
|
||||
color: Colors.white,
|
||||
size: fontSize + 2,
|
||||
),
|
||||
Icon(Icons.check, color: Colors.white, size: fontSize + 2),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user