Aidra Driver 1.3.5+68
Aidra Driver - Your path to green energy
Loading...
Searching...
No Matches
stats_section.dart
Go to the documentation of this file.
1import 'package:easy_localization/easy_localization.dart';
2import 'package:flutter/material.dart';
3import 'package:flutter_screenutil/flutter_screenutil.dart';
4
5import '../../../../../../../core/ui/theme/color_palette.dart';
6import '../../../../bloc/collections_bloc/collections_bloc.dart';
7import '../../../../../../../core/ui/widgets/stats_card.dart';
8
9class StatsSection extends StatelessWidget {
11 final bool isToDoSelected;
12 const StatsSection({super.key, required this.state, required this.isToDoSelected});
13
14 @override
15 Widget build(BuildContext context) {
16 return SliverToBoxAdapter(
17 child: Padding(
18 padding: EdgeInsets.symmetric(horizontal: 16.sp, vertical: 8.sp),
19 child: Row(
20 children: [
21 Expanded(
23 title: isToDoSelected ? 'today_schedule.todo_today'.tr() : 'today_schedule.completed_today'.tr(),
26 gradient: LinearGradient(
28 // colors: [ColorPalette.blue, ColorPalette.tiffanyBlue],
29 begin: Alignment.topLeft,
30 end: Alignment.bottomRight,
31 ),
32 ),
33 ),
34 // SizedBox(width: 16.sp),
35 // const Expanded(
36 // child: StatsCard(
37 // title: 'COMPLETED',
38 // number: '10',
39 // subtitle: '250L',
40 // gradient: LinearGradient(
41 // colors: [ColorPalette.lightGreen, ColorPalette.darkGreen],
42 // begin: Alignment.topLeft,
43 // end: Alignment.bottomRight,
44 // ),
45 // ),
46 // ),
47 ],
48 ),
49 ),
50 );
51 }
52
59
61 if (state is CollectionsLoaded) {
62 return state.collections.length.toString();
63 }
64 return '0';
65 }
66
68 if (state is CollectionsLoaded) {
69 String quanitity = state.collections.fold<double>(
70 0, (prev, element) => prev + (element.volume ?? 0)
71 ).toInt().toString();
72 return quanitity;
73 }
74 return '0';
75 }
76
78 if (volume == null) return "--";
79 double volumeValue = volume is double ? volume : double.tryParse(volume.toString()) ?? 0.0;
80 if (volumeValue > 999) {
81 return '${(volumeValue / 1000).toStringAsFixed(2)} MT';
82 } else {
83 return '$volumeValue KG';
84 }
85 }
86
87}
static const lightGreen
static const darkGreen
static const blue
static const tiffanyBlue
String formatVolume(dynamic volume)
String _getCollectionsCount(CollectionsState state)
final bool isToDoSelected
final String title
final CollectionsState state
String _getCollectionQuantity(CollectionsState state)
final Widget child
List< Color > _getGradientColors(bool isToDoSelected)
final LinearGradient gradient
override Widget build(BuildContext context)
const StatsCard({ super.key, required this.title, required this.number, required this.subtitle, required this.gradient, this.unit, })
final EdgeInsets padding
const StatsSection({super.key, required this.state, required this.isToDoSelected})
final String subtitle
const CollectionsLoaded({required this.collections})
class Partner String