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>
122 lines
3.1 KiB
Dart
122 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../widgets/scoring_grid/scoring_grid.dart';
|
|
import '../widgets/scoring_grid/scoring_keypad.dart';
|
|
import '../widgets/common/toggle_switches.dart';
|
|
|
|
class ScoringPage extends StatefulWidget {
|
|
const ScoringPage({super.key});
|
|
|
|
@override
|
|
State<ScoringPage> createState() => _ScoringPageState();
|
|
}
|
|
|
|
class _ScoringPageState extends State<ScoringPage> {
|
|
int arrowsPerEnd = 3;
|
|
int endsPerSet = 12;
|
|
int selectedRow = 0;
|
|
int selectedColumn = 0;
|
|
List<List<String>> scores = [];
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_initializeScores();
|
|
}
|
|
|
|
void _initializeScores() {
|
|
scores = List.generate(
|
|
endsPerSet,
|
|
(index) => List.generate(arrowsPerEnd, (index) => ''),
|
|
);
|
|
}
|
|
|
|
void _onArrowsPerEndChanged(int arrows) {
|
|
setState(() {
|
|
arrowsPerEnd = arrows;
|
|
// Infer ends per set based on ruleset
|
|
endsPerSet = arrows == 3 ? 10 : 6;
|
|
_initializeScores();
|
|
});
|
|
}
|
|
|
|
void _onCellSelected(int row, int column) {
|
|
setState(() {
|
|
selectedRow = row;
|
|
selectedColumn = column;
|
|
});
|
|
}
|
|
|
|
void _onScoreInput(String score) {
|
|
if (score == 'CLEAR') {
|
|
// Clear the selected cell
|
|
if (selectedRow < scores.length && selectedColumn < scores[selectedRow].length) {
|
|
setState(() {
|
|
scores[selectedRow][selectedColumn] = '';
|
|
});
|
|
}
|
|
} else {
|
|
// Input score
|
|
if (selectedRow < scores.length && selectedColumn < scores[selectedRow].length) {
|
|
setState(() {
|
|
scores[selectedRow][selectedColumn] = score;
|
|
// Auto-advance to next cell
|
|
if (selectedColumn < arrowsPerEnd - 1) {
|
|
selectedColumn++;
|
|
} else if (selectedRow < endsPerSet - 1) {
|
|
selectedRow++;
|
|
selectedColumn = 0;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Archery Scoring'),
|
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
|
),
|
|
body: Column(
|
|
children: [
|
|
// Settings toggles
|
|
Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: ToggleSwitches(
|
|
arrowsPerEnd: arrowsPerEnd,
|
|
onArrowsPerEndChanged: _onArrowsPerEndChanged,
|
|
),
|
|
),
|
|
|
|
// Scoring grid
|
|
Expanded(
|
|
flex: 2,
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
|
child: ScoringGrid(
|
|
scores: scores,
|
|
arrowsPerEnd: arrowsPerEnd,
|
|
endsPerSet: endsPerSet,
|
|
selectedRow: selectedRow,
|
|
selectedColumn: selectedColumn,
|
|
onCellSelected: _onCellSelected,
|
|
),
|
|
),
|
|
),
|
|
|
|
// Scoring keypad
|
|
Expanded(
|
|
flex: 1,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: ScoringKeypad(
|
|
onScoreInput: _onScoreInput,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
} |