Some checks are pending
Build & Deploy iOS to TestFlight / build-and-deploy (push) Waiting to run
176 lines
5.1 KiB
Dart
176 lines
5.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../../common/extension/extension.dart';
|
|
import '../../../../common/theme/theme.dart';
|
|
import '../../../../domain/analytic/analytic.dart';
|
|
import '../../../components/spacer/spacer.dart';
|
|
|
|
class HomeStats extends StatelessWidget {
|
|
final DashboardOverview overview;
|
|
const HomeStats({super.key, required this.overview});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
vertical: 24,
|
|
horizontal: AppValue.padding,
|
|
).copyWith(bottom: 0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
context.lang.today_condition,
|
|
style: AppStyle.xl.copyWith(
|
|
fontWeight: FontWeight.w800,
|
|
color: AppColor.textPrimary,
|
|
),
|
|
),
|
|
const SpaceHeight(16),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: _StatCard(
|
|
icon: Icons.credit_card_rounded,
|
|
iconColor: const Color(0xFF00BCD4),
|
|
blobColor: const Color(0xFF00BCD4),
|
|
value: overview.totalOrders.toString(),
|
|
label: context.lang.transaction,
|
|
),
|
|
),
|
|
const SpaceWidth(12),
|
|
Expanded(
|
|
child: _StatCard(
|
|
icon: Icons.hexagon_outlined,
|
|
iconColor: const Color(0xFF4CAF50),
|
|
blobColor: const Color(0xFF4CAF50),
|
|
value: overview.totalItemSold.toString(),
|
|
label: context.lang.items_sold,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SpaceHeight(12),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: _StatCard(
|
|
icon: Icons.warning_amber_rounded,
|
|
iconColor: const Color(0xFFFF9800),
|
|
blobColor: const Color(0xFFFF9800),
|
|
value: overview.totalLowStock.toString(),
|
|
label: context.lang.low_stock_warning,
|
|
),
|
|
),
|
|
const SpaceWidth(12),
|
|
Expanded(
|
|
child: _StatCard(
|
|
icon: Icons.hexagon_outlined,
|
|
iconColor: const Color(0xFFE53935),
|
|
blobColor: const Color(0xFFE53935),
|
|
value: overview.totalProductActive.toString(),
|
|
label: context.lang.active_products,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _StatCard extends StatelessWidget {
|
|
final IconData icon;
|
|
final Color iconColor;
|
|
final Color blobColor;
|
|
final String value;
|
|
final String label;
|
|
|
|
const _StatCard({
|
|
required this.icon,
|
|
required this.iconColor,
|
|
required this.blobColor,
|
|
required this.value,
|
|
required this.label,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
clipBehavior: Clip.hardEdge,
|
|
decoration: BoxDecoration(
|
|
color: AppColor.white,
|
|
borderRadius: BorderRadius.circular(16),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withOpacity(0.04),
|
|
blurRadius: 10,
|
|
offset: const Offset(0, 4),
|
|
),
|
|
],
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Stack(
|
|
clipBehavior: Clip.none,
|
|
children: [
|
|
// Decorative blob top-right (quarter circle)
|
|
Positioned(
|
|
top: -16,
|
|
right: -16,
|
|
child: Container(
|
|
width: 70,
|
|
height: 70,
|
|
decoration: BoxDecoration(
|
|
borderRadius: const BorderRadius.only(
|
|
bottomLeft: Radius.circular(70),
|
|
),
|
|
color: blobColor.withOpacity(0.10),
|
|
),
|
|
),
|
|
),
|
|
|
|
// Content
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Icon
|
|
Container(
|
|
padding: const EdgeInsets.all(10),
|
|
decoration: BoxDecoration(
|
|
color: iconColor,
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Icon(icon, color: Colors.white, size: 20),
|
|
),
|
|
const SpaceHeight(16),
|
|
|
|
// Value
|
|
Text(
|
|
value,
|
|
style: AppStyle.h1.copyWith(
|
|
fontWeight: FontWeight.w900,
|
|
color: AppColor.textPrimary,
|
|
fontSize: 28,
|
|
),
|
|
),
|
|
const SpaceHeight(4),
|
|
|
|
// Label
|
|
Text(
|
|
label,
|
|
style: AppStyle.sm.copyWith(
|
|
color: AppColor.textSecondary,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|