feat: update profit shareing
Build & Deploy iOS to TestFlight / build-and-deploy (push) Canceled after 0s
Build & Deploy iOS to TestFlight / build-and-deploy (push) Canceled after 0s
This commit is contained in:
@@ -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,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user