75b350f08d
- Fix dynamic column generation issue that created 6 columns instead of 3 - Implement static 12-row grid with intelligent visual state management - Add visual-to-logical mapping system for proper end/arrow indexing - Fix sum calculations using logical end groupings instead of visual rows - Replace ends per set selector with automatic ruleset inference - Convert to percentage-based responsive layout eliminating viewport overflow - Add clean merged arrow header replacing individual column indices Core improvements: - 3-arrow (Indoor): 10 ends, sum-3 active, sum-6 on even ends - 6-arrow (Outdoor): 6 ends, sum-3 greyed, sum-6 every 2 visual rows - No more RenderFlex overflow errors with responsive column widths - Proper bounds checking prevents range errors on inactive rows - Package identifier updated to com.novoyuuparosk.archery_bookkeeper 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
110 lines
2.8 KiB
Dart
110 lines
2.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class ToggleSwitches extends StatelessWidget {
|
|
final int arrowsPerEnd;
|
|
final Function(int) onArrowsPerEndChanged;
|
|
|
|
const ToggleSwitches({
|
|
super.key,
|
|
required this.arrowsPerEnd,
|
|
required this.onArrowsPerEndChanged,
|
|
});
|
|
|
|
// Inferred ends per set based on ruleset
|
|
int get endsPerSet => arrowsPerEnd == 3 ? 10 : 6;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
_buildToggleGroup(
|
|
'Arrows per end',
|
|
[3, 6],
|
|
arrowsPerEnd,
|
|
onArrowsPerEndChanged,
|
|
),
|
|
_buildRulesetInfo(),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildToggleGroup(
|
|
String label,
|
|
List<int> options,
|
|
int currentValue,
|
|
Function(int) onChanged,
|
|
) {
|
|
return Column(
|
|
children: [
|
|
Text(
|
|
label,
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
ToggleButtons(
|
|
isSelected: options.map((option) => option == currentValue).toList(),
|
|
onPressed: (index) => onChanged(options[index]),
|
|
borderRadius: BorderRadius.circular(8),
|
|
selectedColor: Colors.white,
|
|
fillColor: Colors.green,
|
|
color: Colors.grey.shade700,
|
|
constraints: const BoxConstraints(
|
|
minHeight: 40,
|
|
minWidth: 50,
|
|
),
|
|
children: options.map((option) => Text(option.toString())).toList(),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildRulesetInfo() {
|
|
final rulesetName = arrowsPerEnd == 3 ? 'Indoor' : 'Outdoor';
|
|
return Column(
|
|
children: [
|
|
Text(
|
|
'Ruleset',
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
|
decoration: BoxDecoration(
|
|
color: Colors.blue.shade50,
|
|
border: Border.all(color: Colors.blue.shade200),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
Text(
|
|
rulesetName,
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.blue.shade700,
|
|
),
|
|
),
|
|
Text(
|
|
'$endsPerSet ends',
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.blue.shade600,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
} |