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),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class SimpleCountriesSidebar extends StatelessWidget {
|
||||
final List<String> countries;
|
||||
@@ -25,21 +24,10 @@ class SimpleCountriesSidebar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print('🔥 SIDEBAR BUILD ============================================');
|
||||
print('🔥 SIDEBAR BUILD - Countries count: ${countries.length}');
|
||||
print('🔥 SIDEBAR BUILD - Is Loading: $isLoading');
|
||||
print('🔥 SIDEBAR BUILD - Is Organizing: $isOrganizing');
|
||||
print('🔥 SIDEBAR BUILD - Countries list: $countries');
|
||||
print('🔥 SIDEBAR BUILD - Selected country: "$selectedCountry"');
|
||||
|
||||
if (countries.isNotEmpty) {
|
||||
print('🔥 SIDEBAR BUILD - First 10 countries:');
|
||||
for (int i = 0; i < countries.length && i < 10; i++) {
|
||||
print('🔥 SIDEBAR BUILD [${i + 1}] "${countries[i]}"');
|
||||
}
|
||||
for (int i = 0; i < countries.length && i < 10; i++) {}
|
||||
}
|
||||
print('🔥 SIDEBAR BUILD ============================================');
|
||||
|
||||
|
||||
return Container(
|
||||
width: 250,
|
||||
color: Colors.grey[900],
|
||||
@@ -64,7 +52,7 @@ class SimpleCountriesSidebar extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
// List
|
||||
Expanded(
|
||||
child: isOrganizing || (isLoading && countries.isEmpty)
|
||||
@@ -82,25 +70,25 @@ class SimpleCountriesSidebar extends StatelessWidget {
|
||||
),
|
||||
)
|
||||
: countries.isEmpty
|
||||
? const Center(
|
||||
child: Text(
|
||||
'No hay países',
|
||||
style: TextStyle(color: Colors.white54),
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
itemCount: _getItemCount(),
|
||||
itemBuilder: (context, index) {
|
||||
return _buildItemAtIndex(context, index);
|
||||
},
|
||||
),
|
||||
? const Center(
|
||||
child: Text(
|
||||
'No hay países',
|
||||
style: TextStyle(color: Colors.white54),
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
itemCount: _getItemCount(),
|
||||
itemBuilder: (context, index) {
|
||||
return _buildItemAtIndex(context, index);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Widget _buildCountryItem(String name, bool isSelected, VoidCallback onTap) {
|
||||
return FocusableActionDetector(
|
||||
actions: <Type, Action<Intent>>{
|
||||
@@ -125,10 +113,16 @@ class SimpleCountriesSidebar extends StatelessWidget {
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? Colors.red : (hasFocus ? Colors.red.withValues(alpha: 0.5) : Colors.transparent),
|
||||
color: isSelected
|
||||
? Colors.red
|
||||
: (hasFocus
|
||||
? Colors.red.withValues(alpha: 0.5)
|
||||
: Colors.transparent),
|
||||
border: Border(
|
||||
left: BorderSide(
|
||||
color: isSelected ? Colors.white : (hasFocus ? Colors.white : Colors.transparent),
|
||||
color: isSelected
|
||||
? Colors.white
|
||||
: (hasFocus ? Colors.white : Colors.transparent),
|
||||
width: 4,
|
||||
),
|
||||
),
|
||||
@@ -167,7 +161,9 @@ class SimpleCountriesSidebar extends StatelessWidget {
|
||||
|
||||
// Find insertion point for "Fútbol Argentino" (after Perú)
|
||||
final peruIndex = countries.indexOf('Perú');
|
||||
final footballInsertIndex = peruIndex >= 0 ? peruIndex + 1 : countries.length;
|
||||
final footballInsertIndex = peruIndex >= 0
|
||||
? peruIndex + 1
|
||||
: countries.length;
|
||||
|
||||
if (showFootballCategory) {
|
||||
// Adjust for "Todos" at index 0 and "Fútbol Argentino" after Perú
|
||||
@@ -231,21 +227,23 @@ class SimpleCountriesSidebar extends StatelessWidget {
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? Colors.green[700] : (hasFocus ? Colors.green[700]?.withOpacity(0.8) : Colors.green[900]?.withOpacity(0.3)),
|
||||
color: isSelected
|
||||
? Colors.green[700]
|
||||
: (hasFocus
|
||||
? Colors.green[700]?.withValues(alpha: 0.8)
|
||||
: Colors.green[900]?.withValues(alpha: 0.3)),
|
||||
border: Border(
|
||||
left: BorderSide(
|
||||
color: isSelected ? Colors.white : (hasFocus ? Colors.white : Colors.green[400]!),
|
||||
color: isSelected
|
||||
? Colors.white
|
||||
: (hasFocus ? Colors.white : Colors.green[400]!),
|
||||
width: 4,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.sports_soccer,
|
||||
color: Colors.white,
|
||||
size: 20,
|
||||
),
|
||||
Icon(Icons.sports_soccer, color: Colors.white, size: 20),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
@@ -253,7 +251,9 @@ class SimpleCountriesSidebar extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
fontWeight: isSelected
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user