Initial commit: Flutter app + PHP/MySQL backend on Hostinger

Replaces Firebase with a self-hosted PHP/MySQL API served from
winded.prymsolutions.com. Includes full backend (schema, auth, events,
teams, brackets, suggestions, stats, media, file upload) and updated
Flutter repositories and domain models.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-14 20:13:57 -07:00
commit b239ae3e5f
208 changed files with 19187 additions and 0 deletions
@@ -0,0 +1,197 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import '../../../teams/domain/team.dart';
import '../../application/stats_notifier.dart';
/// Ranked row used in every leaderboard list on the Stats screen.
///
/// Use either [LeaderboardTile.player] for the player leaderboards or
/// [LeaderboardTile.team] for the league standings — both share the rank
/// medal styling and tap affordances.
class LeaderboardTile extends StatelessWidget {
const LeaderboardTile._({
required this.rank,
required this.title,
required this.subtitle,
required this.trailingValue,
required this.trailingLabel,
this.onTap,
});
/// Player leaderboard variant. Tapping navigates to the player's team page.
factory LeaderboardTile.player({
Key? key,
required int rank,
required PlayerWithTeam entry,
required int statValue,
required String statLabel,
BuildContext? navContext,
}) {
return LeaderboardTile._(
rank: rank,
title: entry.player.name,
subtitle: entry.team.name,
trailingValue: statValue,
trailingLabel: statLabel,
onTap: navContext == null
? null
: () => navContext.go('/teams/${entry.team.id}'),
);
}
/// Team standings variant. Tapping navigates to the team detail page.
factory LeaderboardTile.team({
Key? key,
required int rank,
required Team team,
BuildContext? navContext,
}) {
final points = team.wins * 3 + team.draws;
return LeaderboardTile._(
rank: rank,
title: team.name,
subtitle: '${team.wins}W · ${team.draws}D · ${team.losses}L',
trailingValue: points,
trailingLabel: 'pts',
onTap: navContext == null
? null
: () => navContext.go('/teams/${team.id}'),
);
}
final int rank;
final String title;
final String subtitle;
final int trailingValue;
final String trailingLabel;
final VoidCallback? onTap;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final scheme = theme.colorScheme;
return Card(
clipBehavior: Clip.antiAlias,
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
child: InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
child: Row(
children: [
_RankMedal(rank: rank),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: theme.textTheme.titleSmall?.copyWith(
fontWeight: FontWeight.w700,
),
),
const SizedBox(height: 2),
Text(
subtitle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: theme.textTheme.bodySmall?.copyWith(
color: scheme.onSurfaceVariant,
),
),
],
),
),
const SizedBox(width: 12),
_TrailingStat(value: trailingValue, label: trailingLabel),
],
),
),
),
);
}
}
class _RankMedal extends StatelessWidget {
const _RankMedal({required this.rank});
final int rank;
// Podium medal colors — only hardcoded colors in the feature.
static const _gold = Color(0xFFFFD700);
static const _silver = Color(0xFFC0C0C0);
static const _bronze = Color(0xFFCD7F32);
@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
final isPodium = rank >= 1 && rank <= 3;
final medalColor = switch (rank) {
1 => _gold,
2 => _silver,
3 => _bronze,
_ => scheme.surfaceContainerHighest,
};
final textColor = isPodium ? Colors.black : scheme.onSurfaceVariant;
return Container(
width: 34,
height: 34,
alignment: Alignment.center,
decoration: BoxDecoration(
color: medalColor,
shape: BoxShape.circle,
border: isPodium
? null
: Border.all(color: scheme.outlineVariant, width: 1),
),
child: Text(
'$rank',
style: TextStyle(
color: textColor,
fontWeight: FontWeight.w800,
fontSize: 13,
),
),
);
}
}
class _TrailingStat extends StatelessWidget {
const _TrailingStat({required this.value, required this.label});
final int value;
final String label;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final scheme = theme.colorScheme;
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: [
Text(
'$value',
style: theme.textTheme.titleMedium?.copyWith(
color: scheme.primary,
fontWeight: FontWeight.w800,
),
),
Text(
label,
style: theme.textTheme.labelSmall?.copyWith(
color: scheme.onSurfaceVariant,
letterSpacing: 0.4,
),
),
],
);
}
}
@@ -0,0 +1,214 @@
import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';
/// A single labelled bar in [StatBarChart].
class StatBarDatum {
const StatBarDatum({required this.label, required this.value});
/// Short label rendered along the X axis (kept terse so it fits).
final String label;
final int value;
}
/// Lightweight wrapper around [BarChart] for the top-6 leaderboards. Renders
/// vertical bars with a numeric Y axis and the supplied [data] labels on X.
class StatBarChart extends StatelessWidget {
const StatBarChart({
super.key,
required this.data,
required this.valueLabel,
this.height = 280,
});
/// Sorted list of bars to render (highest first); only the first 6 are used.
final List<StatBarDatum> data;
/// Used for the Y axis title, e.g. "Goals".
final String valueLabel;
final double height;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final scheme = theme.colorScheme;
final visible = data.take(6).toList(growable: false);
if (visible.isEmpty) {
return SizedBox(
height: height,
child: Center(
child: Text(
'No data yet',
style: theme.textTheme.bodyMedium?.copyWith(
color: scheme.onSurfaceVariant,
),
),
),
);
}
final maxValue = visible
.map((d) => d.value)
.fold<int>(0, (a, b) => a > b ? a : b);
// Round the y-axis ceiling up to the nearest sensible interval so the
// grid lines land on whole numbers.
final yMax = maxValue <= 4 ? 4.0 : (maxValue + 2).toDouble();
final interval = yMax <= 6 ? 1.0 : (yMax / 5).ceilToDouble();
return Padding(
padding: const EdgeInsets.fromLTRB(12, 4, 16, 8),
child: SizedBox(
height: height,
child: BarChart(
BarChartData(
alignment: BarChartAlignment.spaceAround,
maxY: yMax,
minY: 0,
barTouchData: BarTouchData(
enabled: true,
touchTooltipData: BarTouchTooltipData(
getTooltipColor: (_) => scheme.surfaceContainerHigh,
tooltipBorder: BorderSide(color: scheme.outlineVariant),
getTooltipItem: (group, _, rod, _) {
final datum = visible[group.x];
return BarTooltipItem(
'${datum.label}\n',
theme.textTheme.bodySmall!.copyWith(
color: scheme.onSurface,
fontWeight: FontWeight.w700,
),
children: [
TextSpan(
text: '${rod.toY.toInt()} $valueLabel',
style: theme.textTheme.bodySmall?.copyWith(
color: scheme.primary,
fontWeight: FontWeight.w700,
),
),
],
);
},
),
),
gridData: FlGridData(
show: true,
drawVerticalLine: false,
horizontalInterval: interval,
getDrawingHorizontalLine: (_) => FlLine(
color: scheme.outlineVariant.withValues(alpha: 0.4),
strokeWidth: 1,
),
),
borderData: FlBorderData(show: false),
titlesData: FlTitlesData(
show: true,
topTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
rightTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
leftTitles: AxisTitles(
axisNameWidget: Padding(
padding: const EdgeInsets.only(bottom: 6),
child: Text(
valueLabel,
style: theme.textTheme.labelSmall?.copyWith(
color: scheme.onSurfaceVariant,
letterSpacing: 0.5,
),
),
),
axisNameSize: 18,
sideTitles: SideTitles(
showTitles: true,
interval: interval,
reservedSize: 32,
getTitlesWidget: (value, meta) {
if (value == 0 || value > yMax) {
return const SizedBox.shrink();
}
return Padding(
padding: const EdgeInsets.only(right: 4),
child: Text(
value.toInt().toString(),
style: theme.textTheme.labelSmall?.copyWith(
color: scheme.onSurfaceVariant,
),
),
);
},
),
),
bottomTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
reservedSize: 36,
interval: 1,
getTitlesWidget: (value, meta) {
final index = value.toInt();
if (index < 0 || index >= visible.length) {
return const SizedBox.shrink();
}
return Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
_shortLabel(visible[index].label),
textAlign: TextAlign.center,
style: theme.textTheme.labelSmall?.copyWith(
color: scheme.onSurfaceVariant,
fontWeight: FontWeight.w600,
),
),
);
},
),
),
),
barGroups: [
for (var i = 0; i < visible.length; i++)
BarChartGroupData(
x: i,
barRods: [
BarChartRodData(
toY: visible[i].value.toDouble(),
color: scheme.primary,
width: 22,
borderRadius: const BorderRadius.vertical(
top: Radius.circular(6),
),
backDrawRodData: BackgroundBarChartRodData(
show: true,
toY: yMax,
color: scheme.surfaceContainerHighest
.withValues(alpha: 0.5),
),
),
],
),
],
),
),
),
);
}
/// Compresses long names like "Marcus Reed" → "M. Reed" so X-axis labels
/// don't overflow on phone widths.
static String _shortLabel(String full) {
final parts = full.trim().split(RegExp(r'\s+'));
if (parts.length < 2) {
return parts.first.length > 10
? '${parts.first.substring(0, 9)}'
: parts.first;
}
final last = parts.last;
final first = parts.first;
final initial = first.isEmpty ? '' : '${first[0]}. ';
final candidate = '$initial$last';
if (candidate.length <= 12) return candidate;
return '${candidate.substring(0, 11)}';
}
}
@@ -0,0 +1,30 @@
import 'package:flutter/material.dart';
/// Top tab strip for the Stats screen. Hosted inside an [AppBar] `bottom:`
/// slot and driven by an ambient [DefaultTabController].
class StatsFilterBar extends StatelessWidget implements PreferredSizeWidget {
const StatsFilterBar({super.key});
static const double _height = 48;
@override
Size get preferredSize => const Size.fromHeight(_height);
@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
return TabBar(
isScrollable: false,
labelColor: scheme.primary,
unselectedLabelColor: scheme.onSurfaceVariant,
indicatorColor: scheme.primary,
indicatorSize: TabBarIndicatorSize.label,
labelStyle: const TextStyle(fontWeight: FontWeight.w700),
tabs: const [
Tab(text: 'Standings'),
Tab(text: 'Top Scorers'),
Tab(text: 'Top Assists'),
],
);
}
}