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

This commit is contained in:
efrilm
2026-10-04 22:31:01 +07:00
parent 288d0d75a0
commit 243b7e02aa
23 changed files with 1349 additions and 451 deletions
@@ -6,10 +6,20 @@ import '../../../../domain/analytic/analytic.dart';
import '../../../components/spacer/spacer.dart';
/// Warna tetap untuk tiap pos bagi hasil supaya konsisten di semua bagian.
/// Sengaja pakai warna jenuh, bukan default Material yang pucat.
class ProfitSharingColor {
static const Color purchase = Color(0xFF2196F3);
static const Color owner = Color(0xFF4CAF50);
static const Color team = Color(0xFFFF9800);
static const Color owner = Color(0xFF00B341);
static const Color team = Color(0xFFFF6A00);
// Status margin (Sehat / Waspada / Tidak Sehat).
static const Color healthy = Color(0xFF00B341);
static const Color watch = Color(0xFFFF9500);
static const Color critical = Color(0xFFFF1E3C);
// Tile ringkasan.
static const Color subCategory = AppColor.primary;
static const Color product = Color(0xFF7B2FF7);
static const Color order = Color(0xFF00A3D9);
}
class ProfitSharingAllocation extends StatelessWidget {
@@ -21,11 +31,14 @@ class ProfitSharingAllocation extends StatelessWidget {
Widget build(BuildContext context) {
final total = budget.total;
final percentages = budget.percentages;
// Fee owner berbeda tiap kategori induk, jadi porsi SDL dihitung dari
// Fee owner berbeda tiap kategori induk, jadi porsi dihitung dari
// nominalnya; persentase bawaan hanya dipakai saat belum ada omzet.
final sdlPercentage = total.hasRevenue
? total.sdlPercentage
: percentages.owner;
final teamPercentage = total.hasRevenue
? total.teamPercentage
: percentages.team;
return Container(
margin: const EdgeInsets.symmetric(horizontal: 16),
@@ -55,22 +68,10 @@ class ProfitSharingAllocation extends StatelessWidget {
const SpaceHeight(16),
ProfitSharingBar(
purchase: percentages.purchase,
owner: sdlPercentage,
team: percentages.team,
),
ProfitSharingBar(owner: sdlPercentage, team: teamPercentage),
const SpaceHeight(20),
_row(
context: context,
color: ProfitSharingColor.purchase,
label: context.lang.share_purchase,
percentage: percentages.purchase,
amount: total.limitPurchase,
),
const Divider(height: 24, color: AppColor.borderLight),
_row(
context: context,
color: ProfitSharingColor.owner,
@@ -83,7 +84,7 @@ class ProfitSharingAllocation extends StatelessWidget {
context: context,
color: ProfitSharingColor.team,
label: context.lang.share_team,
percentage: percentages.team,
percentage: teamPercentage,
amount: total.limitTeam,
),
],
@@ -117,14 +118,14 @@ class ProfitSharingAllocation extends StatelessWidget {
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
decoration: BoxDecoration(
color: color.withOpacity(0.12),
color: color,
borderRadius: BorderRadius.circular(6),
),
child: Text(
'${percentage.toStringAsFixed(percentage % 1 == 0 ? 0 : 1)}%',
style: AppStyle.xs.copyWith(
color: color,
fontWeight: FontWeight.w700,
color: AppColor.textWhite,
fontWeight: FontWeight.w800,
),
),
),
@@ -145,16 +146,15 @@ class ProfitSharingAllocation extends StatelessWidget {
}
}
/// Bar proporsi belanja / SDL (owner) / tim.
/// Bar proporsi SDL (owner) / tim dalam persen omzet. Sisa yang belum terbagi
/// (backend lama masih menyisihkan porsi belanja) tampil sebagai track kosong.
class ProfitSharingBar extends StatelessWidget {
final double purchase;
final double owner;
final double team;
final double height;
const ProfitSharingBar({
super.key,
required this.purchase,
required this.owner,
required this.team,
this.height = 12,
@@ -162,7 +162,7 @@ class ProfitSharingBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
final total = purchase + owner + team;
final total = owner + team;
if (total <= 0) {
return Container(
height: height,
@@ -179,9 +179,9 @@ class ProfitSharingBar extends StatelessWidget {
height: height,
child: Row(
children: [
_segment(purchase, ProfitSharingColor.purchase),
_segment(owner, ProfitSharingColor.owner),
_segment(team, ProfitSharingColor.team),
_segment(100 - total, AppColor.borderLight),
].whereType<Widget>().toList(),
),
),
@@ -4,9 +4,10 @@ import '../../../../common/extension/extension.dart';
import '../../../../common/theme/theme.dart';
import '../../../../domain/analytic/analytic.dart';
import '../../../components/spacer/spacer.dart';
import 'profit_sharing_allocation.dart';
import 'profit_sharing_status.dart';
/// Ringkasan omzet & SDL per kategori induk (parent category).
/// Ringkasan porsi tim (omzet − SDL) per kategori induk (parent category).
/// Tiap kartu bisa diketuk untuk melihat rincian sub kategori & produknya.
class ProfitSharingCategories extends StatelessWidget {
final List<ProfitSharingCategory> categories;
@@ -21,9 +22,9 @@ class ProfitSharingCategories extends StatelessWidget {
@override
Widget build(BuildContext context) {
final sorted = [...categories]
..sort((a, b) => b.totalRevenue.compareTo(a.totalRevenue));
..sort((a, b) => b.teamShare.compareTo(a.teamShare));
final totalRevenue = sorted.fold<int>(0, (sum, e) => sum + e.totalRevenue);
final totalTeam = sorted.fold<int>(0, (sum, e) => sum + e.teamShare);
return Container(
margin: const EdgeInsets.symmetric(horizontal: 16),
@@ -75,9 +76,7 @@ class ProfitSharingCategories extends StatelessWidget {
child: _CategoryCard(
rank: i + 1,
category: sorted[i],
share: totalRevenue == 0
? 0
: sorted[i].totalRevenue / totalRevenue,
share: totalTeam == 0 ? 0 : sorted[i].teamShare / totalTeam,
onTap: () => onCategoryTap(sorted[i]),
),
),
@@ -106,18 +105,11 @@ class _CategoryCard extends StatelessWidget {
Widget build(BuildContext context) {
final isTop = rank == 1;
return Material(
color: AppColor.background,
borderRadius: BorderRadius.circular(14),
return ProfitSharingItemCard(
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(14),
child: Container(
child: Padding(
padding: const EdgeInsets.all(14),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
border: Border.all(color: AppColor.borderLight),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -188,7 +180,7 @@ class _CategoryCard extends StatelessWidget {
children: [
Expanded(
child: Text(
category.totalRevenue.currencyFormatRp,
category.teamShare.currencyFormatRp,
style: AppStyle.xl.copyWith(
color: AppColor.textPrimary,
fontWeight: FontWeight.w800,
@@ -204,21 +196,53 @@ class _CategoryCard extends StatelessWidget {
vertical: 3,
),
decoration: BoxDecoration(
color: AppColor.primary.withOpacity(0.08),
color: AppColor.primary,
borderRadius: BorderRadius.circular(20),
),
child: Text(
formatPercent(share * 100),
style: AppStyle.xs.copyWith(
color: AppColor.primary,
fontWeight: FontWeight.w700,
color: AppColor.textWhite,
fontWeight: FontWeight.w800,
),
),
),
],
),
const SpaceHeight(8),
const SpaceHeight(4),
Row(
children: [
Text(
context.lang.share_team,
style: AppStyle.xs.copyWith(
color: ProfitSharingColor.team,
fontWeight: FontWeight.w700,
),
),
const SpaceWidth(4),
ProfitSharingFeeBadge(
feePercent: category.teamPercent,
color: ProfitSharingColor.team,
),
const SpaceWidth(6),
Expanded(
child: Text(
context.lang.from_revenue(
category.totalRevenue.currencyFormatRp,
),
style: AppStyle.xs.copyWith(
color: AppColor.textSecondary,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
],
),
const SpaceHeight(10),
ClipRRect(
borderRadius: BorderRadius.circular(6),
@@ -232,15 +256,8 @@ class _CategoryCard extends StatelessWidget {
),
),
const SpaceHeight(12),
ProfitSharingSdlStrip(
amount: category.sdl,
feePercent: category.ownerFeePercent,
),
if (category.hasTopProduct) ...[
const SpaceHeight(10),
const SpaceHeight(12),
_TopProduct(product: category.topProduct),
],
],
@@ -333,7 +350,7 @@ class _TotalCard extends StatelessWidget {
0,
(sum, e) => sum + e.totalRevenue,
);
final totalSdl = categories.fold<int>(0, (sum, e) => sum + e.sdl);
final totalTeam = categories.fold<int>(0, (sum, e) => sum + e.teamShare);
return Container(
padding: const EdgeInsets.all(16),
@@ -349,7 +366,8 @@ class _TotalCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
context.lang.grand_total,
'${context.lang.grand_total} '
'${context.lang.share_team.toUpperCase()}',
style: AppStyle.xs.copyWith(
color: AppColor.textWhite.withOpacity(0.8),
fontWeight: FontWeight.w700,
@@ -358,7 +376,7 @@ class _TotalCard extends StatelessWidget {
),
const SizedBox(height: 4),
Text(
totalRevenue.currencyFormatRp,
totalTeam.currencyFormatRp,
style: AppStyle.xl.copyWith(
color: AppColor.textWhite,
fontWeight: FontWeight.w900,
@@ -369,8 +387,8 @@ class _TotalCard extends StatelessWidget {
ProfitSharingHeaderStats(
stats: [
(context.lang.revenue, totalRevenue.currencyFormatRp),
(context.lang.qty, totalQuantity.thousandFormat),
(context.lang.sdl, totalSdl.currencyFormatRp),
],
),
],
@@ -7,6 +7,7 @@ import '../../../../domain/analytic/analytic.dart';
import '../../../components/spacer/spacer.dart';
import 'period_label.dart';
import 'profit_sharing_allocation.dart';
import 'profit_sharing_status.dart';
class ProfitSharingPeriods extends StatelessWidget {
final ProfitSharingLoaderState state;
@@ -151,78 +152,73 @@ class _PeriodCard extends StatelessWidget {
? '${formatPeriodLabel(period.periodStart, period.periodEnd)} - ${context.lang.week_count(period.weekCount)}'
: context.lang.order_count_label(period.orderCount);
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: AppColor.background,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: AppColor.borderLight),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: AppStyle.md.copyWith(
fontWeight: FontWeight.w700,
color: AppColor.textPrimary,
return ProfitSharingItemCard(
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: AppStyle.md.copyWith(
fontWeight: FontWeight.w700,
color: AppColor.textPrimary,
),
),
),
const SizedBox(height: 2),
Text(
subtitle,
style: AppStyle.xs.copyWith(
color: AppColor.textSecondary,
const SizedBox(height: 2),
Text(
subtitle,
style: AppStyle.xs.copyWith(
color: AppColor.textSecondary,
),
),
),
],
],
),
),
),
const SpaceWidth(8),
Text(
period.revenue.currencyFormatRp,
style: AppStyle.md.copyWith(
fontWeight: FontWeight.w800,
color: AppColor.primary,
const SpaceWidth(8),
Text(
period.revenue.currencyFormatRp,
style: AppStyle.md.copyWith(
fontWeight: FontWeight.w800,
color: AppColor.primary,
),
),
),
],
),
],
),
const SpaceHeight(12),
const SpaceHeight(12),
ProfitSharingBar(
purchase: percentages.purchase,
owner: period.hasRevenue ? period.sdlPercentage : percentages.owner,
team: percentages.team,
height: 6,
),
ProfitSharingBar(
owner: period.hasRevenue
? period.sdlPercentage
: percentages.owner,
team: period.hasRevenue
? period.teamPercentage
: percentages.team,
height: 6,
),
const SpaceHeight(12),
const SpaceHeight(12),
Row(
children: [
_share(
context.lang.share_purchase,
period.limitPurchase,
ProfitSharingColor.purchase,
),
_share(context.lang.sdl, period.sdl, ProfitSharingColor.owner),
_share(
context.lang.share_team,
period.limitTeam,
ProfitSharingColor.team,
),
],
),
],
Row(
children: [
_share(context.lang.sdl, period.sdl, ProfitSharingColor.owner),
_share(
context.lang.share_team,
period.limitTeam,
ProfitSharingColor.team,
),
],
),
],
),
),
);
}
@@ -0,0 +1,283 @@
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';
import 'profit_sharing_status.dart';
/// Satu baris rincian SDL, bisa per kategori induk atau per periode.
class ProfitSharingSdlItem {
final String label;
final int sdl;
final int revenue;
final double? feePercent;
const ProfitSharingSdlItem({
required this.label,
required this.sdl,
required this.revenue,
this.feePercent,
});
}
/// Section khusus SDL (bagian owner): total di blok hijau, lalu rinciannya.
/// Urutan [items] ditampilkan apa adanya.
class ProfitSharingSdlSection extends StatelessWidget {
final int sdl;
final int revenue;
/// Persen di blok total: fee owner kalau satu kategori, atau persen
/// efektif terhadap omzet kalau gabungan beberapa kategori.
final double percent;
final String breakdownTitle;
final List<ProfitSharingSdlItem> items;
const ProfitSharingSdlSection({
super.key,
required this.sdl,
required this.revenue,
required this.percent,
required this.breakdownTitle,
this.items = const [],
});
@override
Widget build(BuildContext context) {
final totalSdl = items.fold<int>(0, (sum, e) => sum + e.sdl);
return Container(
margin: const EdgeInsets.symmetric(horizontal: 16),
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: AppColor.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: AppColor.textLight.withOpacity(0.08),
spreadRadius: 1,
blurRadius: 10,
offset: const Offset(0, 2),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
context.lang.sdl_summary,
style: AppStyle.lg.copyWith(
fontWeight: FontWeight.w700,
color: AppColor.textPrimary,
),
),
const SizedBox(height: 2),
Text(
context.lang.sdl_desc,
style: AppStyle.xs.copyWith(color: AppColor.textSecondary),
),
const SpaceHeight(16),
_TotalBlock(sdl: sdl, revenue: revenue, percent: percent),
if (items.isNotEmpty) ...[
const SpaceHeight(20),
Text(
breakdownTitle,
style: AppStyle.md.copyWith(
fontWeight: FontWeight.w700,
color: AppColor.textPrimary,
),
),
const SpaceHeight(12),
for (var i = 0; i < items.length; i++) ...[
if (i > 0) const Divider(height: 24, color: AppColor.borderLight),
_SdlRow(
item: items[i],
share: totalSdl == 0 ? 0 : items[i].sdl / totalSdl,
),
],
],
],
),
);
}
}
class _TotalBlock extends StatelessWidget {
final int sdl;
final int revenue;
final double percent;
const _TotalBlock({
required this.sdl,
required this.revenue,
required this.percent,
});
@override
Widget build(BuildContext context) {
const color = ProfitSharingColor.owner;
return Container(
width: double.infinity,
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [color, darken(color)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(14),
boxShadow: [
BoxShadow(
color: color.withOpacity(0.3),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
width: 36,
height: 36,
decoration: BoxDecoration(
color: AppColor.textWhite.withOpacity(0.2),
borderRadius: BorderRadius.circular(10),
),
child: const Icon(
Icons.account_balance_wallet_rounded,
color: AppColor.textWhite,
size: 20,
),
),
const SpaceWidth(10),
Expanded(
child: Text(
context.lang.sdl,
style: AppStyle.md.copyWith(
color: AppColor.textWhite,
fontWeight: FontWeight.w700,
),
),
),
ProfitSharingFeeBadge(
feePercent: percent,
onDarkBackground: true,
),
],
),
const SpaceHeight(14),
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
sdl.currencyFormatRp,
style: AppStyle.h3.copyWith(
color: AppColor.textWhite,
fontWeight: FontWeight.w900,
),
),
),
const SizedBox(height: 4),
Text(
context.lang.from_revenue(revenue.currencyFormatRp),
style: AppStyle.sm.copyWith(
color: AppColor.textWhite.withOpacity(0.85),
),
),
],
),
);
}
}
class _SdlRow extends StatelessWidget {
final ProfitSharingSdlItem item;
/// Porsi baris ini terhadap total SDL di daftar (0..1).
final double share;
const _SdlRow({required this.item, required this.share});
@override
Widget build(BuildContext context) {
final amountColor = darken(ProfitSharingColor.owner);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Row(
children: [
Flexible(
child: Text(
item.label,
style: AppStyle.md.copyWith(
color: AppColor.textPrimary,
fontWeight: FontWeight.w700,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
if (item.feePercent != null) ...[
const SpaceWidth(6),
ProfitSharingFeeBadge(feePercent: item.feePercent!),
],
],
),
),
const SpaceWidth(8),
Text(
item.sdl.currencyFormatRp,
style: AppStyle.md.copyWith(
color: amountColor,
fontWeight: FontWeight.w800,
),
),
],
),
const SpaceHeight(8),
ClipRRect(
borderRadius: BorderRadius.circular(6),
child: LinearProgressIndicator(
value: share.clamp(0.0, 1.0),
minHeight: 6,
backgroundColor: AppColor.border,
valueColor: const AlwaysStoppedAnimation<Color>(
ProfitSharingColor.owner,
),
),
),
const SpaceHeight(6),
Row(
children: [
Expanded(
child: Text(
context.lang.from_revenue(item.revenue.currencyFormatRp),
style: AppStyle.xs.copyWith(color: AppColor.textSecondary),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
Text(
formatPercent(share * 100),
style: AppStyle.xs.copyWith(
color: amountColor,
fontWeight: FontWeight.w700,
),
),
],
),
],
);
}
}
@@ -18,10 +18,16 @@ String formatPercent(double value) => '${value.toStringAsFixed(1)}%';
String formatFeePercent(double value) =>
'${value.toStringAsFixed(value % 1 == 0 ? 0 : 1)}%';
/// Versi lebih gelap dari [color], dipakai sebagai ujung gradien.
Color darken(Color color, [double amount = 0.2]) =>
Color.lerp(color, AppColor.black, amount)!;
Color statusColor(double realHppPercentage) {
if (realHppPercentage <= HppThreshold.healthy) return AppColor.success;
if (realHppPercentage <= HppThreshold.watch) return AppColor.warning;
return AppColor.error;
if (realHppPercentage <= HppThreshold.healthy) {
return ProfitSharingColor.healthy;
}
if (realHppPercentage <= HppThreshold.watch) return ProfitSharingColor.watch;
return ProfitSharingColor.critical;
}
String statusLabel(BuildContext context, double realHppPercentage) {
@@ -47,97 +53,95 @@ class ProfitSharingStatusBadge extends StatelessWidget {
Widget build(BuildContext context) {
final color = statusColor(realHppPercentage);
// Di atas header merah, pill putih supaya status merah tidak tenggelam.
return Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
decoration: BoxDecoration(
color: onDarkBackground
? AppColor.textWhite.withOpacity(0.18)
: color.withOpacity(0.12),
color: onDarkBackground ? AppColor.white : color,
borderRadius: BorderRadius.circular(20),
border: onDarkBackground
? Border.all(color: AppColor.textWhite.withOpacity(0.3))
: null,
),
child: Text(
statusLabel(context, realHppPercentage),
style: AppStyle.xs.copyWith(
color: onDarkBackground ? AppColor.textWhite : color,
fontWeight: FontWeight.w700,
color: onDarkBackground ? color : AppColor.textWhite,
fontWeight: FontWeight.w800,
),
),
);
}
}
/// Strip sorotan SDL: label + persen fee owner di kiri, nominal di kanan.
class ProfitSharingSdlStrip extends StatelessWidget {
final int amount;
final double? feePercent;
/// Kartu item di dalam section: latar putih, garis aksen berwarna di kiri.
/// Child boleh berisi InkWell; ripple-nya ikut terpotong sudut kartu.
class ProfitSharingItemCard extends StatelessWidget {
final Widget child;
final Color accentColor;
const ProfitSharingSdlStrip({
const ProfitSharingItemCard({
super.key,
required this.amount,
this.feePercent,
required this.child,
this.accentColor = AppColor.primary,
});
@override
Widget build(BuildContext context) {
const color = ProfitSharingColor.owner;
return Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
clipBehavior: Clip.antiAlias,
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,
),
color: AppColor.white,
borderRadius: BorderRadius.circular(14),
border: Border.all(color: AppColor.border),
boxShadow: [
BoxShadow(
color: AppColor.black.withOpacity(0.05),
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
child: Stack(
children: [
Material(type: MaterialType.transparency, child: child),
Positioned(
left: 0,
top: 0,
bottom: 0,
child: Container(width: 4, color: accentColor),
),
],
),
);
}
}
/// Pill persen fee owner. Di atas latar berwarna jadi putih supaya terbaca.
class ProfitSharingFeeBadge extends StatelessWidget {
final double feePercent;
final Color color;
final bool onDarkBackground;
const ProfitSharingFeeBadge({
super.key,
required this.feePercent,
this.color = ProfitSharingColor.owner,
this.onDarkBackground = false,
});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
decoration: BoxDecoration(
color: onDarkBackground ? AppColor.white : color,
borderRadius: BorderRadius.circular(6),
),
child: Text(
formatFeePercent(feePercent),
style: AppStyle.xs.copyWith(
color: onDarkBackground ? color : AppColor.textWhite,
fontWeight: FontWeight.w800,
),
),
);
}
}
@@ -205,7 +209,7 @@ class ProfitSharingHeaderStats extends StatelessWidget {
}
}
/// Kotak statistik kecil: ikon, nilai, lalu label.
/// Kartu statistik kecil berwarna solid: ikon, nilai, lalu label.
class ProfitSharingStatTile extends StatelessWidget {
final IconData icon;
final String label;
@@ -225,9 +229,19 @@ class ProfitSharingStatTile extends StatelessWidget {
return Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: AppColor.background,
gradient: LinearGradient(
colors: [color, darken(color)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(12),
border: Border.all(color: AppColor.borderLight),
boxShadow: [
BoxShadow(
color: color.withOpacity(0.3),
blurRadius: 8,
offset: const Offset(0, 3),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -236,25 +250,30 @@ class ProfitSharingStatTile extends StatelessWidget {
width: 30,
height: 30,
decoration: BoxDecoration(
color: color.withOpacity(0.1),
color: AppColor.textWhite.withOpacity(0.2),
borderRadius: BorderRadius.circular(8),
),
child: Icon(icon, color: color, size: 16),
child: Icon(icon, color: AppColor.textWhite, size: 16),
),
const SpaceHeight(10),
Text(
value,
style: AppStyle.lg.copyWith(
color: AppColor.textPrimary,
fontWeight: FontWeight.w800,
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
value,
style: AppStyle.lg.copyWith(
color: AppColor.textWhite,
fontWeight: FontWeight.w800,
),
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 2),
Text(
label,
style: AppStyle.xs.copyWith(color: AppColor.textSecondary),
style: AppStyle.xs.copyWith(
color: AppColor.textWhite.withOpacity(0.85),
fontWeight: FontWeight.w600,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
@@ -99,17 +99,11 @@ class _SubCategoryCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: AppColor.background,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: AppColor.borderLight),
),
return ProfitSharingItemCard(
child: Column(
children: [
InkWell(
onTap: onToggle,
borderRadius: BorderRadius.circular(12),
child: Padding(
padding: const EdgeInsets.all(14),
child: Column(
@@ -155,7 +149,7 @@ class _SubCategoryCard extends StatelessWidget {
child: LinearProgressIndicator(
value: share.clamp(0.0, 1.0),
minHeight: 5,
backgroundColor: AppColor.borderLight,
backgroundColor: AppColor.border,
valueColor: const AlwaysStoppedAnimation<Color>(
AppColor.primary,
),