bb7b1cf6b2
- Add flutter_localizations dependency and l10n configuration - Create ARB files for English (en) and Finnish (fi) translations - Localize UI strings across all major components: * Navigation drawer and page titles * Scoring interface (arrows per end, ruleset names) * Scorecard headers (End, Arrows, Sum of 3/6, Accumulative) * Keypad functional buttons (CLEAR/TYHJENNÄ, CLOSE/SULJE) * Settings page placeholder content * Dialog messages and confirmation prompts - Preserve universal archery scoring notation (X, 10, 9, M remain unlocalised) - Use authentic Finnish archery terminology throughout - Configure main app with proper localization delegates and supported locales - Generate localization classes automatically via flutter_localizations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
117 lines
3.1 KiB
Dart
117 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../../config/localization/generated/app_localizations.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) {
|
|
final l10n = AppLocalizations.of(context)!;
|
|
|
|
return Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
_buildToggleGroup(
|
|
context,
|
|
l10n.arrowsPerEnd,
|
|
[3, 6],
|
|
arrowsPerEnd,
|
|
onArrowsPerEndChanged,
|
|
),
|
|
_buildRulesetInfo(context),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildToggleGroup(
|
|
BuildContext context,
|
|
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(BuildContext context) {
|
|
final l10n = AppLocalizations.of(context)!;
|
|
final rulesetName = arrowsPerEnd == 3 ? l10n.rulesetIndoor : l10n.rulesetOutdoor;
|
|
|
|
return Column(
|
|
children: [
|
|
Text(
|
|
l10n.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(
|
|
l10n.endsCount(endsPerSet),
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.blue.shade600,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
} |