mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-15 01:35:25 +00:00

* set the default tab to occupancy for ease of development. * Implemented an initial design for the occupancy chart. * Add Occupacy model and service for occupancy data handling. * Created `OccupancyBloc`. * Implemented the sidebar of Occupancy view. * Moved `OccupancyEndSideBar` widget to its own file. * Removed unnecessary widgets. * Matched the `OccupancyChart` with the figma design. * Added `AnalyticsDateFilterButton` to `OccupancyChartBox`. * Hides `AnalyticsDateFilterButton` that is in the page header, when the selected tab isn't `AnalyticsPageTab.energyManagement`. * Added animation to`AnalyticsDateFilterButton`. * modified the implementation of `FakeOccupacyService` to clamp all the generated values to less than a 100. * Injected `OccupancyBloc` into `AnalyticsPage`. * Made `OccupancyChart` read its data from `OccupancyBloc`. * Refactor AnalyticsCommunitiesSidebar to load data based on selected tab and implement loadEnergyManagementData method * Refactor Analytics views to use StatefulWidget and load data in initState * Created `OccupancyHeatMapModel`. * Add FakeOccupancyHeatMapService implementation. * Created `OccupancyHeatMapBloc`. * Injected `OccupancyHeatMapBloc` into `AnalyticsPage`. * Add OccupancyHeatMapBox widget and integrate into AnalyticsOccupancyView * Matching the heat map with the design, and added week days. * Made the HeatMap cells have a dashed border. * shows months. * responsiveness. * Integrate OccupancyHeatMapBloc and update OccupancyHeatMapBox to display heat map data with error handling * Integrate OccupancyHeatMapBloc and update OccupancyHeatMapBox to display heat map data with error handling * made the heatmap loading fast af by using painters instead of individually creating a widget for every single event. * Extracted `OccupancyHeatMapMonths` into its own widgte. * Moved `OccupancyHeatMapMonths` to its own file. * Adjusted design of `OccupancyHeatMapMonths`. * Adjust layout flex properties for `OccupancyEndSideBar` and its parent column in `AnalyticsOccupancyView`. * moved `OccupancyPaintItem` to `OccupancyPainter`s file. * removed comments from `OccupancyPainter`. * used color.withValues instead of .withOpacity. * re-added `OccupancyHeatMapGradient`. * Revert initial tab to `energyManagement`. * Made datepicker dynamic for multiple states. * Add year picker functionality to date filter button and implement dynamic date selection * Align date filter button to the end in occupancy chart and heat map boxes for improved UI consistency. * Enahnced color of border in `OccupancyPainter`. * Add ClearOccupancyHeatMapEvent to reset heat map state and update occupancy data helper to trigger event on empty selections * show percentage of value in tool tip of `OccupancyChart`.
148 lines
4.7 KiB
Dart
148 lines
4.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:syncrow_web/utils/color_manager.dart';
|
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
|
|
|
class YearPickerWidget extends StatefulWidget {
|
|
const YearPickerWidget({
|
|
super.key,
|
|
required this.selectedDate,
|
|
required this.onDateSelected,
|
|
});
|
|
|
|
final DateTime selectedDate;
|
|
final ValueChanged<DateTime>? onDateSelected;
|
|
|
|
@override
|
|
State<YearPickerWidget> createState() => _YearPickerWidgetState();
|
|
}
|
|
|
|
class _YearPickerWidgetState extends State<YearPickerWidget> {
|
|
late int _currentYear;
|
|
|
|
static final years = List.generate(
|
|
DateTime.now().year - 2020 + 1,
|
|
(index) => (2020 + index),
|
|
);
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_currentYear = widget.selectedDate.year;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Dialog(
|
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
|
child: Container(
|
|
padding: const EdgeInsetsDirectional.all(20),
|
|
width: 320,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
_buildMonthsGrid(),
|
|
const SizedBox(height: 20),
|
|
Row(
|
|
spacing: 12,
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
FilledButton(
|
|
onPressed: () => Navigator.pop(context),
|
|
style: FilledButton.styleFrom(
|
|
fixedSize: const Size(106, 40),
|
|
backgroundColor: const Color(0xFFEDF2F7),
|
|
padding: const EdgeInsetsDirectional.symmetric(
|
|
vertical: 10,
|
|
horizontal: 16,
|
|
),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(20),
|
|
),
|
|
),
|
|
child: Text(
|
|
'Cancel',
|
|
style: context.textTheme.titleSmall?.copyWith(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
color: ColorsManager.grey700,
|
|
),
|
|
),
|
|
),
|
|
FilledButton(
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
final date = DateTime(_currentYear);
|
|
widget.onDateSelected?.call(date);
|
|
},
|
|
style: FilledButton.styleFrom(
|
|
fixedSize: const Size(106, 40),
|
|
backgroundColor: ColorsManager.vividBlue.withValues(
|
|
alpha: 0.7,
|
|
),
|
|
padding: const EdgeInsetsDirectional.symmetric(
|
|
vertical: 10,
|
|
horizontal: 16,
|
|
),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(20),
|
|
),
|
|
),
|
|
child: Text(
|
|
'Done',
|
|
style: context.textTheme.titleSmall?.copyWith(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
color: ColorsManager.whiteColors,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildMonthsGrid() {
|
|
return GridView.builder(
|
|
shrinkWrap: true,
|
|
itemCount: years.length,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
padding: const EdgeInsets.all(8),
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 3,
|
|
childAspectRatio: 2.5,
|
|
mainAxisSpacing: 8,
|
|
mainAxisExtent: 30,
|
|
),
|
|
itemBuilder: (context, index) {
|
|
final isSelected = _currentYear == years[index];
|
|
return InkWell(
|
|
onTap: () => setState(() => _currentYear = years[index]),
|
|
child: Container(
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: isSelected
|
|
? ColorsManager.vividBlue.withValues(alpha: 0.7)
|
|
: const Color(0xFFEDF2F7),
|
|
borderRadius:
|
|
isSelected ? BorderRadius.circular(15) : BorderRadius.zero,
|
|
),
|
|
child: Text(
|
|
years[index].toString(),
|
|
style: context.textTheme.titleSmall?.copyWith(
|
|
fontSize: 12,
|
|
color: isSelected
|
|
? ColorsManager.whiteColors
|
|
: ColorsManager.blackColor.withValues(alpha: 0.8),
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|