feat: update parent category analytic
Build & Deploy iOS to TestFlight / build-and-deploy (push) Canceled after 0s

This commit is contained in:
efrilm
2026-10-03 00:38:32 +07:00
parent 36bc9e0f9e
commit 288d0d75a0
21 changed files with 1366 additions and 344 deletions
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
import '../../../../common/extension/extension.dart';
import '../../../../common/theme/theme.dart';
import '../../../components/spacer/spacer.dart';
import 'profit_sharing_allocation.dart';
/// Ambang kesehatan berdasarkan % HPP riil terhadap omzet.
/// Ubah di sini kalau target margin bisnis berubah.
@@ -12,6 +14,10 @@ class HppThreshold {
String formatPercent(double value) => '${value.toStringAsFixed(1)}%';
/// Persen fee tanpa desimal kalau nilainya bulat (20% / 22.5%).
String formatFeePercent(double value) =>
'${value.toStringAsFixed(value % 1 == 0 ? 0 : 1)}%';
Color statusColor(double realHppPercentage) {
if (realHppPercentage <= HppThreshold.healthy) return AppColor.success;
if (realHppPercentage <= HppThreshold.watch) return AppColor.warning;
@@ -63,6 +69,201 @@ class ProfitSharingStatusBadge extends StatelessWidget {
}
}
/// Strip sorotan SDL: label + persen fee owner di kiri, nominal di kanan.
class ProfitSharingSdlStrip extends StatelessWidget {
final int amount;
final double? feePercent;
const ProfitSharingSdlStrip({
super.key,
required this.amount,
this.feePercent,
});
@override
Widget build(BuildContext context) {
const color = ProfitSharingColor.owner;
return Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
decoration: BoxDecoration(
color: color.withOpacity(0.08),
borderRadius: BorderRadius.circular(10),
border: Border.all(color: color.withOpacity(0.2)),
),
child: Row(
children: [
const Icon(
Icons.account_balance_wallet_rounded,
color: color,
size: 18,
),
const SpaceWidth(8),
Text(
context.lang.sdl,
style: AppStyle.sm.copyWith(
color: AppColor.textPrimary,
fontWeight: FontWeight.w600,
),
),
if (feePercent != null) ...[
const SpaceWidth(6),
Container(
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
decoration: BoxDecoration(
color: color,
borderRadius: BorderRadius.circular(6),
),
child: Text(
formatFeePercent(feePercent!),
style: AppStyle.xs.copyWith(
color: AppColor.textWhite,
fontWeight: FontWeight.w700,
),
),
),
],
const SpaceWidth(8),
Expanded(
child: Text(
amount.currencyFormatRp,
textAlign: TextAlign.right,
style: AppStyle.md.copyWith(
color: AppColor.secondaryDark,
fontWeight: FontWeight.w800,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
],
),
);
}
}
/// Deretan angka ringkas di header (latar gelap), dipisah garis tipis.
class ProfitSharingHeaderStats extends StatelessWidget {
final List<(String label, String value)> stats;
const ProfitSharingHeaderStats({super.key, required this.stats});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 12),
decoration: BoxDecoration(
color: AppColor.textWhite.withOpacity(0.14),
borderRadius: BorderRadius.circular(14),
border: Border.all(color: AppColor.textWhite.withOpacity(0.22)),
),
child: IntrinsicHeight(
child: Row(
children: [
for (var i = 0; i < stats.length; i++) ...[
if (i > 0)
VerticalDivider(
width: 1,
thickness: 1,
color: AppColor.textWhite.withOpacity(0.22),
),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
stats[i].$1,
style: AppStyle.xs.copyWith(
color: AppColor.textWhite.withOpacity(0.75),
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 4),
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
stats[i].$2,
style: AppStyle.md.copyWith(
color: AppColor.textWhite,
fontWeight: FontWeight.w800,
),
),
),
],
),
),
),
],
],
),
),
);
}
}
/// Kotak statistik kecil: ikon, nilai, lalu label.
class ProfitSharingStatTile extends StatelessWidget {
final IconData icon;
final String label;
final String value;
final Color color;
const ProfitSharingStatTile({
super.key,
required this.icon,
required this.label,
required this.value,
this.color = AppColor.primary,
});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: AppColor.background,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: AppColor.borderLight),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 30,
height: 30,
decoration: BoxDecoration(
color: color.withOpacity(0.1),
borderRadius: BorderRadius.circular(8),
),
child: Icon(icon, color: color, size: 16),
),
const SpaceHeight(10),
Text(
value,
style: AppStyle.lg.copyWith(
color: AppColor.textPrimary,
fontWeight: FontWeight.w800,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 2),
Text(
label,
style: AppStyle.xs.copyWith(color: AppColor.textSecondary),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
);
}
}
/// Label kecil dua baris: judul di atas, nilai di bawah.
class ProfitSharingMetric extends StatelessWidget {
final String label;