1import 'package:connect/core/constants/app_values.dart';
2import 'package:connect/core/localization/app_localizations.dart';
4import '/core/ui/widgets/custom_card.dart';
5import 'package:flutter/material.dart';
6import 'package:flutter_screenutil/flutter_screenutil.dart';
7import 'package:intl/intl.dart';
10 const ThisMonthEarningCard({
12 required this.earningActualMonth,
13 required this.earningLastMonth,
16 final num? earningActualMonth;
17 final num? earningLastMonth;
20 Widget
build(BuildContext context) {
23 crossAxisAlignment: CrossAxisAlignment.start,
29 style: Theme.of(context).textTheme.bodySmall,
33 NumberFormat.currency(symbol: AppValues.currency)
34 .format(earningActualMonth),
35 style: Theme.of(context).textTheme.bodySmall?.copyWith(
36 color: Theme.of(context).primaryColor,
38 fontWeight: FontWeight.bold,
43 SizedBox(height: 12.sp),
45 earningActualMonth ?? 0,
46 earningLastMonth ?? 0,
54 RichText _compareEarnings(num current, num previous, BuildContext context) {
57 TextStyle? smallTextStyle = Theme.of(context).textTheme.bodySmall?.copyWith(
58 color: Theme.of(context).hintColor,
67 .translate(
'No earnings this month compared to last month'),
68 style: smallTextStyle,
78 style: Theme.of(context).textTheme.bodySmall?.copyWith(
79 color: Theme.of(context).primaryColor,
80 fontWeight: FontWeight.bold,
85 ' ${AppLocalizations.of(context).translate('higher
earnings than last
month')}',
86 style: smallTextStyle,
94 double difference = (current - previous) / previous;
95 bool isHigher = difference > 0;
101 text: NumberFormat.percentPattern()
105 ? Theme.of(context).primaryColor
106 : Theme.of(context).colorScheme.error,
108 fontWeight: FontWeight.bold,
113 ?
' ${AppLocalizations.of(context).translate('higher
earnings than last
month')}'
115 ?
' ${AppLocalizations.of(context).translate('lower
earnings than last
month')}'
116 :
' ${AppLocalizations.of(context).translate('Earnings are the same as last
month')}',
117 style: smallTextStyle,
AppLocalizations(this.locale)