mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
Merge pull request #193 from SyncrowIOT/feature/make_analytics_date_picker_not_show_future_dates
Feature/make_analytics_date_picker_not_show_future_dates
This commit is contained in:
@ -45,7 +45,7 @@ class _MonthPickerWidgetState extends State<MonthPickerWidget> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Dialog(
|
return Dialog(
|
||||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
backgroundColor: ColorsManager.whiteColors,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsetsDirectional.all(20),
|
padding: const EdgeInsetsDirectional.all(20),
|
||||||
width: 320,
|
width: 320,
|
||||||
@ -121,6 +121,7 @@ class _MonthPickerWidgetState extends State<MonthPickerWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Row _buildYearSelector() {
|
Row _buildYearSelector() {
|
||||||
|
final currentYear = DateTime.now().year;
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@ -134,17 +135,35 @@ class _MonthPickerWidgetState extends State<MonthPickerWidget> {
|
|||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () => setState(() => _currentYear = _currentYear - 1),
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
_currentYear = _currentYear - 1;
|
||||||
|
});
|
||||||
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.chevron_left,
|
Icons.chevron_left,
|
||||||
color: ColorsManager.grey700,
|
color: ColorsManager.grey700,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () => setState(() => _currentYear = _currentYear + 1),
|
onPressed: _currentYear < currentYear
|
||||||
icon: const Icon(
|
? () {
|
||||||
|
setState(() {
|
||||||
|
_currentYear = _currentYear + 1;
|
||||||
|
// Clear selected month if it becomes invalid in the new year
|
||||||
|
if (_currentYear == currentYear &&
|
||||||
|
_selectedMonth != null &&
|
||||||
|
_selectedMonth! > DateTime.now().month - 1) {
|
||||||
|
_selectedMonth = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
icon: Icon(
|
||||||
Icons.chevron_right,
|
Icons.chevron_right,
|
||||||
color: ColorsManager.grey700,
|
color: _currentYear < currentYear
|
||||||
|
? ColorsManager.grey700
|
||||||
|
: ColorsManager.grey700.withValues(alpha: 0.3),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -152,6 +171,9 @@ class _MonthPickerWidgetState extends State<MonthPickerWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildMonthsGrid() {
|
Widget _buildMonthsGrid() {
|
||||||
|
final currentDate = DateTime.now();
|
||||||
|
final isCurrentYear = _currentYear == currentDate.year;
|
||||||
|
|
||||||
return GridView.builder(
|
return GridView.builder(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
itemCount: 12,
|
itemCount: 12,
|
||||||
@ -165,14 +187,18 @@ class _MonthPickerWidgetState extends State<MonthPickerWidget> {
|
|||||||
),
|
),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final isSelected = _selectedMonth == index;
|
final isSelected = _selectedMonth == index;
|
||||||
|
final isFutureMonth = isCurrentYear && index > currentDate.month - 1;
|
||||||
|
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () => setState(() => _selectedMonth = index),
|
onTap: isFutureMonth ? null : () => setState(() => _selectedMonth = index),
|
||||||
child: Container(
|
child: Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: isSelected
|
color: isSelected
|
||||||
? ColorsManager.vividBlue.withValues(alpha: 0.7)
|
? ColorsManager.vividBlue.withValues(alpha: 0.7)
|
||||||
: const Color(0xFFEDF2F7),
|
: isFutureMonth
|
||||||
|
? ColorsManager.grey700.withValues(alpha: 0.1)
|
||||||
|
: const Color(0xFFEDF2F7),
|
||||||
borderRadius:
|
borderRadius:
|
||||||
isSelected ? BorderRadius.circular(15) : BorderRadius.zero,
|
isSelected ? BorderRadius.circular(15) : BorderRadius.zero,
|
||||||
),
|
),
|
||||||
@ -182,7 +208,9 @@ class _MonthPickerWidgetState extends State<MonthPickerWidget> {
|
|||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: isSelected
|
color: isSelected
|
||||||
? ColorsManager.whiteColors
|
? ColorsManager.whiteColors
|
||||||
: ColorsManager.blackColor.withValues(alpha: 0.8),
|
: isFutureMonth
|
||||||
|
? ColorsManager.blackColor.withValues(alpha: 0.3)
|
||||||
|
: ColorsManager.blackColor.withValues(alpha: 0.8),
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -20,9 +20,9 @@ class _YearPickerWidgetState extends State<YearPickerWidget> {
|
|||||||
late int _currentYear;
|
late int _currentYear;
|
||||||
|
|
||||||
static final years = List.generate(
|
static final years = List.generate(
|
||||||
DateTime.now().year - 2020 + 1,
|
DateTime.now().year - (DateTime.now().year - 5) + 1,
|
||||||
(index) => (2020 + index),
|
(index) => (2020 + index),
|
||||||
);
|
).where((year) => year <= DateTime.now().year).toList();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -33,7 +33,7 @@ class _YearPickerWidgetState extends State<YearPickerWidget> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Dialog(
|
return Dialog(
|
||||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
backgroundColor: ColorsManager.whiteColors,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsetsDirectional.all(20),
|
padding: const EdgeInsetsDirectional.all(20),
|
||||||
width: 320,
|
width: 320,
|
||||||
|
@ -20,7 +20,8 @@ abstract final class EnergyManagementChartsHelper {
|
|||||||
interval: 1,
|
interval: 1,
|
||||||
reservedSize: 32,
|
reservedSize: 32,
|
||||||
showTitles: true,
|
showTitles: true,
|
||||||
maxIncluded: true,
|
maxIncluded: false,
|
||||||
|
minIncluded: false,
|
||||||
getTitlesWidget: (value, meta) => Padding(
|
getTitlesWidget: (value, meta) => Padding(
|
||||||
padding: const EdgeInsetsDirectional.only(top: 20.0),
|
padding: const EdgeInsetsDirectional.only(top: 20.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
@ -36,7 +37,8 @@ abstract final class EnergyManagementChartsHelper {
|
|||||||
leftTitles: AxisTitles(
|
leftTitles: AxisTitles(
|
||||||
sideTitles: SideTitles(
|
sideTitles: SideTitles(
|
||||||
showTitles: true,
|
showTitles: true,
|
||||||
maxIncluded: true,
|
maxIncluded: false,
|
||||||
|
minIncluded: false,
|
||||||
interval: leftTitlesInterval,
|
interval: leftTitlesInterval,
|
||||||
reservedSize: 110,
|
reservedSize: 110,
|
||||||
getTitlesWidget: (value, meta) => Padding(
|
getTitlesWidget: (value, meta) => Padding(
|
||||||
|
@ -12,7 +12,6 @@ import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/po
|
|||||||
import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/power_clamp_phases_data_widget.dart';
|
import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/power_clamp_phases_data_widget.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/widgets/analytics_error_widget.dart';
|
import 'package:syncrow_web/pages/analytics/widgets/analytics_error_widget.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/power_clamp/models/power_clamp_model.dart';
|
import 'package:syncrow_web/pages/device_managment/power_clamp/models/power_clamp_model.dart';
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
@ -23,7 +23,14 @@ class OccupancyChart extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
borderData: EnergyManagementChartsHelper.borderData(),
|
borderData: EnergyManagementChartsHelper.borderData(),
|
||||||
barTouchData: _barTouchData(context),
|
barTouchData: _barTouchData(context),
|
||||||
titlesData: _titlesData(context),
|
titlesData: _titlesData(context).copyWith(
|
||||||
|
leftTitles: _titlesData(context).leftTitles.copyWith(
|
||||||
|
sideTitles: _titlesData(context).leftTitles.sideTitles.copyWith(
|
||||||
|
maxIncluded: true,
|
||||||
|
minIncluded: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
barGroups: List.generate(chartData.length, (index) {
|
barGroups: List.generate(chartData.length, (index) {
|
||||||
final actual = chartData[index];
|
final actual = chartData[index];
|
||||||
return BarChartGroupData(
|
return BarChartGroupData(
|
||||||
|
Reference in New Issue
Block a user