Files
fanuzu/app/lib/features/home/widgets/growth_conditions.dart
T

56 lines
2.0 KiB
Dart

import 'package:flutter/material.dart';
import '../home_data.dart';
import '../home_screen.dart' show formatPop;
import '../../../core/i18n/app_locale.dart';
/// 서버가 제공한 두 성장 조건을 각각 표시한다. 미조회는 0으로 보이지 않는다.
class GrowthConditions extends StatelessWidget {
const GrowthConditions({super.key, required this.growth, this.style});
final PlanetGrowth growth;
/// 없으면 bodySmall. HOME 성장 카드는 사본의 14 흰색을 준다.
final TextStyle? style;
String _value(num? value) => value == null
? '—'
: value == value.roundToDouble()
? formatPop(value.toInt())
: value.toString();
@override
Widget build(BuildContext context) => growth.stage == 6
? Text(
context.l10n.growthFinalReached,
style: style ?? Theme.of(context).textTheme.bodySmall,
)
: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
for (final row in [
(growth.popConditionLabel, growth.currentPop, growth.requiredPop),
// 성운은 POP + 창립 멤버(B-10), 정식 행성은 POP + sFPI(B-11) 동시 충족이다.
growth.isNebula
? (
growth.memberConditionLabel,
growth.members,
growth.requiredMembers,
)
: (
growth.sfpiConditionLabel,
growth.currentSfpi,
growth.requiredSfpi,
),
])
Text(
'${row.$1} · ${_value(row.$2)} / ${_value(row.$3)}',
style: style ?? Theme.of(context).textTheme.bodySmall,
),
if (growth.isNebula && growth.nebulaGoalPassed)
Text(
context.l10n.growthNebulaGoalPassed,
style: style ?? Theme.of(context).textTheme.bodySmall,
),
],
);
}