Formatting all files (#249)

<!--
  Thanks for contributing!

Provide a description of your changes below and a general summary in the
title

Please look at the following checklist to ensure that your PR can be
accepted quickly:
-->

## Description

Formatted all files in the repository.

## Type of Change

<!--- Put an `x` in all the boxes that apply: -->

- [ ]  New feature (non-breaking change which adds functionality)
- [ ] 🛠️ Bug fix (non-breaking change which fixes an issue)
- [ ]  Breaking change (fix or feature that would cause existing
functionality to change)
- [x] 🧹 Code refactor
- [ ]  Build configuration change
- [ ] 📝 Documentation
- [ ] 🗑️ Chore
This commit is contained in:
Faris Armoush
2025-06-12 15:40:34 +03:00
committed by GitHub
474 changed files with 5425 additions and 4338 deletions

View File

@ -25,3 +25,8 @@ linter:
prefer_int_literals: false
sort_constructors_first: false
avoid_redundant_argument_values: false
always_put_required_named_parameters_first: false
unnecessary_breaks: false
avoid_catches_without_on_clauses: false
cascade_invocations: false
overridden_fields: false

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
class DialogDropdown extends StatefulWidget {
final List<String> items;
@ -7,14 +8,14 @@ class DialogDropdown extends StatefulWidget {
final String? selectedValue;
const DialogDropdown({
Key? key,
super.key,
required this.items,
required this.onSelected,
this.selectedValue,
}) : super(key: key);
});
@override
_DialogDropdownState createState() => _DialogDropdownState();
State<DialogDropdown> createState() => _DialogDropdownState();
}
class _DialogDropdownState extends State<DialogDropdown> {
@ -46,16 +47,14 @@ class _DialogDropdownState extends State<DialogDropdown> {
}
OverlayEntry _createOverlayEntry() {
final renderBox = context.findRenderObject() as RenderBox;
final renderBox = context.findRenderObject()! as RenderBox;
final size = renderBox.size;
final offset = renderBox.localToGlobal(Offset.zero);
return OverlayEntry(
builder: (context) {
return GestureDetector(
onTap: () {
_closeDropdown();
},
onTap: _closeDropdown,
behavior: HitTestBehavior.translucent,
child: Stack(
children: [
@ -87,12 +86,9 @@ class _DialogDropdownState extends State<DialogDropdown> {
child: ListTile(
title: Text(
item,
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(
color: ColorsManager.textPrimaryColor,
),
style: context.textTheme.bodyMedium?.copyWith(
color: ColorsManager.textPrimaryColor,
),
),
onTap: () {
widget.onSelected(item);

View File

@ -10,24 +10,25 @@ class EditChip extends StatelessWidget {
final double borderRadius;
const EditChip({
Key? key,
super.key,
this.label = 'Edit',
required this.onTap,
this.labelColor = ColorsManager.spaceColor,
this.backgroundColor = ColorsManager.whiteColors,
this.borderColor = ColorsManager.spaceColor,
this.borderRadius = 16.0,
}) : super(key: key);
});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Chip(
label: Text(
label,
style: Theme.of(context).textTheme.bodySmall!.copyWith(color: labelColor)
),
label: Text(label,
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(color: labelColor)),
backgroundColor: backgroundColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(borderRadius),

View File

@ -9,12 +9,12 @@ class TagDialogTextfieldDropdown extends StatefulWidget {
final String product;
const TagDialogTextfieldDropdown({
Key? key,
super.key,
required this.items,
required this.onSelected,
this.initialValue,
required this.product,
}) : super(key: key);
});
@override
_DialogTextfieldDropdownState createState() =>
@ -79,7 +79,7 @@ class _DialogTextfieldDropdownState extends State<TagDialogTextfieldDropdown> {
}
OverlayEntry _createOverlayEntry() {
final renderBox = context.findRenderObject() as RenderBox;
final renderBox = context.findRenderObject()! as RenderBox;
final size = renderBox.size;
final offset = renderBox.localToGlobal(Offset.zero);

View File

@ -10,7 +10,8 @@ class CustomExpansionTile extends StatefulWidget {
final ValueChanged<bool>? onExpansionChanged; // Notify when expansion changes
final VoidCallback? onItemSelected; // Callback for selecting the item
CustomExpansionTile({
const CustomExpansionTile({
super.key,
required this.title,
this.children,
this.initiallyExpanded = false,

View File

@ -7,7 +7,7 @@ class CustomSearchBar extends StatefulWidget {
final TextEditingController? controller;
final String hintText;
final String? searchQuery;
final Function(String)? onSearchChanged; // Callback for search input changes
final void Function(String)? onSearchChanged;
const CustomSearchBar({
super.key,
@ -37,7 +37,7 @@ class _CustomSearchBarState extends State<CustomSearchBar> {
color: ColorsManager.whiteColors,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
color: Colors.black.withValues(alpha: 0.2),
spreadRadius: 0,
blurRadius: 8,
offset: const Offset(0, 4),
@ -57,7 +57,7 @@ class _CustomSearchBarState extends State<CustomSearchBar> {
style: const TextStyle(
color: Colors.black,
),
onChanged: widget.onSearchChanged, // Call the callback on text change
onChanged: widget.onSearchChanged,
decoration: InputDecoration(
filled: true,
fillColor: ColorsManager.textFieldGreyColor,

View File

@ -1,7 +1,8 @@
// File generated by FlutterFire CLI.
// ignore_for_file: type=lint
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform;
import 'package:flutter/foundation.dart'
show defaultTargetPlatform, kIsWeb, TargetPlatform;
/// Default [FirebaseOptions] for use with your Firebase apps.
///

View File

@ -40,7 +40,7 @@ class MyApp extends StatelessWidget {
initialLocation: RoutesConst.auth,
routes: AppRoutes.getRoutes(),
redirect: (context, state) async {
String checkToken = await AuthBloc.getTokenAndValidate();
final checkToken = await AuthBloc.getTokenAndValidate();
final loggedIn = checkToken == 'Success';
final goingToLogin = state.uri.toString() == RoutesConst.auth;

View File

@ -21,7 +21,8 @@ import 'package:syncrow_web/utils/theme/theme.dart';
Future<void> main() async {
try {
const environment = String.fromEnvironment('FLAVOR', defaultValue: 'development');
const environment =
String.fromEnvironment('FLAVOR', defaultValue: 'development');
await dotenv.load(fileName: '.env.$environment');
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
@ -39,7 +40,7 @@ class MyApp extends StatelessWidget {
initialLocation: RoutesConst.auth,
routes: AppRoutes.getRoutes(),
redirect: (context, state) async {
String checkToken = await AuthBloc.getTokenAndValidate();
final checkToken = await AuthBloc.getTokenAndValidate();
final loggedIn = checkToken == 'Success';
final goingToLogin = state.uri.toString() == RoutesConst.auth;
@ -57,7 +58,8 @@ class MyApp extends StatelessWidget {
BlocProvider<CreateRoutineBloc>(
create: (context) => CreateRoutineBloc(),
),
BlocProvider(create: (context) => HomeBloc()..add(const FetchUserInfo())),
BlocProvider(
create: (context) => HomeBloc()..add(const FetchUserInfo())),
BlocProvider<VisitorPasswordBloc>(
create: (context) => VisitorPasswordBloc(),
),

View File

@ -21,7 +21,8 @@ import 'package:syncrow_web/utils/theme/theme.dart';
Future<void> main() async {
try {
const environment = String.fromEnvironment('FLAVOR', defaultValue: 'staging');
const environment =
String.fromEnvironment('FLAVOR', defaultValue: 'staging');
await dotenv.load(fileName: '.env.$environment');
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
@ -39,7 +40,7 @@ class MyApp extends StatelessWidget {
initialLocation: RoutesConst.auth,
routes: AppRoutes.getRoutes(),
redirect: (context, state) async {
String checkToken = await AuthBloc.getTokenAndValidate();
final checkToken = await AuthBloc.getTokenAndValidate();
final loggedIn = checkToken == 'Success';
final goingToLogin = state.uri.toString() == RoutesConst.auth;
@ -57,7 +58,8 @@ class MyApp extends StatelessWidget {
BlocProvider<CreateRoutineBloc>(
create: (context) => CreateRoutineBloc(),
),
BlocProvider(create: (context) => HomeBloc()..add(const FetchUserInfo())),
BlocProvider(
create: (context) => HomeBloc()..add(const FetchUserInfo())),
BlocProvider<VisitorPasswordBloc>(
create: (context) => VisitorPasswordBloc(),
),

View File

@ -11,7 +11,7 @@ import 'package:syncrow_web/utils/constants/app_enum.dart';
import 'package:syncrow_web/utils/snack_bar.dart';
class AccessBloc extends Bloc<AccessEvent, AccessState> {
AccessBloc() : super((AccessInitial())) {
AccessBloc() : super(AccessInitial()) {
on<FetchTableData>(_onFetchTableData);
on<SelectTime>(selectTime);
on<FilterDataEvent>(_filterData);
@ -43,12 +43,12 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
}
void updateTabsCount() {
int toBeEffectiveCount = data
final toBeEffectiveCount = data
.where((item) => item.passwordStatus.value == 'To be effective')
.length;
int effectiveCount =
final effectiveCount =
data.where((item) => item.passwordStatus.value == 'Effective').length;
int expiredCount =
final expiredCount =
data.where((item) => item.passwordStatus.value == 'Expired').length;
tabs[1] = 'To Be Effective ($toBeEffectiveCount)';
tabs[2] = 'Effective ($effectiveCount)';
@ -81,7 +81,7 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
Emitter<AccessState> emit,
) async {
emit(AccessLoaded());
final DateTime? picked = await showDatePicker(
final picked = await showDatePicker(
context: event.context,
initialDate: DateTime.now(),
firstDate: DateTime.now().add(const Duration(days: -5095)),
@ -89,7 +89,7 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
builder: (BuildContext context, Widget? child) {
return Theme(
data: ThemeData.light().copyWith(
colorScheme: ColorScheme.light(
colorScheme: const ColorScheme.light(
primary: ColorsManager.blackColor,
onPrimary: Colors.white,
onSurface: ColorsManager.grayColor,
@ -105,20 +105,20 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
},
);
if (picked != null) {
final TimeOfDay? timePicked = await showHourPicker(
final timePicked = await showHourPicker(
context: event.context,
initialTime: TimeOfDay.now(),
);
if (timePicked != null) {
final DateTime selectedDateTime = DateTime(
final selectedDateTime = DateTime(
picked.year,
picked.month,
picked.day,
timePicked.hour,
timePicked.minute,
);
final int selectedTimestamp =
final selectedTimestamp =
selectedDateTime.millisecondsSinceEpoch ~/ 1000;
if (event.isStart) {
if (expirationTimeTimeStamp != null &&
@ -152,39 +152,35 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
final searchText = event.passwordName?.toLowerCase() ?? '';
final searchEmailText = event.emailAuthorizer?.toLowerCase() ?? '';
filteredData = data.where((item) {
bool matchesCriteria = true;
var matchesCriteria = true;
// Convert timestamp to DateTime and extract date component
DateTime effectiveDate = DateTime.fromMillisecondsSinceEpoch(
final effectiveDate = DateTime.fromMillisecondsSinceEpoch(
int.parse(item.effectiveTime.toString()) * 1000)
.toUtc()
.toLocal();
DateTime invalidDate = DateTime.fromMillisecondsSinceEpoch(
final invalidDate = DateTime.fromMillisecondsSinceEpoch(
int.parse(item.invalidTime.toString()) * 1000)
.toUtc()
.toLocal();
DateTime effectiveDateAndTime = DateTime(
final effectiveDateAndTime = DateTime(
effectiveDate.year,
effectiveDate.month,
effectiveDate.day,
effectiveDate.hour,
effectiveDate.minute);
DateTime invalidDateAndTime = DateTime(
invalidDate.year,
invalidDate.month,
invalidDate.day,
invalidDate.hour,
invalidDate.minute);
final invalidDateAndTime = DateTime(invalidDate.year, invalidDate.month,
invalidDate.day, invalidDate.hour, invalidDate.minute);
// Filter by password name, making the search case-insensitive
if (searchText.isNotEmpty) {
final bool matchesName =
final matchesName =
item.passwordName.toString().toLowerCase().contains(searchText);
if (!matchesName) {
matchesCriteria = false;
}
}
if (searchEmailText.isNotEmpty) {
final bool matchesName = item.authorizerEmail
final matchesName = item.authorizerEmail
.toString()
.toLowerCase()
.contains(searchEmailText);
@ -194,7 +190,7 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
}
// Filter by start date only
if (event.startTime != null && event.endTime == null) {
DateTime startDateTime =
var startDateTime =
DateTime.fromMillisecondsSinceEpoch(event.startTime! * 1000)
.toUtc()
.toLocal();
@ -206,7 +202,7 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
}
// Filter by end date only
if (event.endTime != null && event.startTime == null) {
DateTime startDateTime =
var startDateTime =
DateTime.fromMillisecondsSinceEpoch(event.endTime! * 1000)
.toUtc()
.toLocal();
@ -219,11 +215,11 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
// Filter by both start date and end date
if (event.startTime != null && event.endTime != null) {
DateTime startDateTime =
var startDateTime =
DateTime.fromMillisecondsSinceEpoch(event.startTime! * 1000)
.toUtc()
.toLocal();
DateTime endDateTime =
var endDateTime =
DateTime.fromMillisecondsSinceEpoch(event.endTime! * 1000)
.toUtc()
.toLocal();
@ -258,7 +254,7 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
}
}
resetSearch(ResetSearch event, Emitter<AccessState> emit) async {
Future<void> resetSearch(ResetSearch event, Emitter<AccessState> emit) async {
emit(AccessLoaded());
startTime = 'Start Time';
endTime = 'End Time';
@ -272,7 +268,7 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
}
String timestampToDate(dynamic timestamp) {
DateTime dateTime =
final dateTime =
DateTime.fromMillisecondsSinceEpoch(int.parse(timestamp) * 1000);
return "${dateTime.year}/${dateTime.month.toString().padLeft(2, '0')}/${dateTime.day.toString().padLeft(2, '0')} "
" ${dateTime.hour.toString().padLeft(2, '0')}:${dateTime.minute.toString().padLeft(2, '0')}";
@ -289,17 +285,17 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
break;
case 1: // To Be Effective
filteredData = data
.where((item) => item.passwordStatus.value == "To Be Effective")
.where((item) => item.passwordStatus.value == 'To Be Effective')
.toList();
break;
case 2: // Effective
filteredData = data
.where((item) => item.passwordStatus.value == "Effective")
.where((item) => item.passwordStatus.value == 'Effective')
.toList();
break;
case 3: // Expired
filteredData = data
.where((item) => item.passwordStatus.value == "Expired")
.where((item) => item.passwordStatus.value == 'Expired')
.toList();
break;
default:

View File

@ -15,7 +15,7 @@ class AccessLoaded extends AccessState {}
class FailedState extends AccessState {
final String message;
FailedState(this.message);
const FailedState(this.message);
@override
List<Object> get props => [message];

View File

@ -36,7 +36,7 @@ class PasswordModel {
effectiveTime: json['effectiveTime'],
passwordCreated: json['passwordCreated'],
createdTime: json['createdTime'],
passwordName: json['passwordName']??'No Name',
passwordName: json['passwordName'] ?? 'No Name',
passwordStatus: AccessStatusExtension.fromString(json['passwordStatus']),
passwordType: AccessTypeExtension.fromString(json['passwordType']),
deviceUuid: json['deviceUuid'],

View File

@ -1,5 +1,3 @@
import 'dart:ui';
import 'package:flutter/material.dart';
class DashedBorderPainter extends CustomPainter {
@ -20,27 +18,28 @@ class DashedBorderPainter extends CustomPainter {
..strokeWidth = 0.5
..style = PaintingStyle.stroke;
final Path topPath = Path()
final topPath = Path()
..moveTo(0, 0)
..lineTo(size.width, 0);
final Path bottomPath = Path()
final bottomPath = Path()
..moveTo(0, size.height)
..lineTo(size.width, size.height);
final dashedTopPath = _createDashedPath(topPath, dashWidth, dashSpace);
final dashedBottomPath = _createDashedPath(bottomPath, dashWidth, dashSpace);
final dashedBottomPath =
_createDashedPath(bottomPath, dashWidth, dashSpace);
canvas.drawPath(dashedTopPath, paint);
canvas.drawPath(dashedBottomPath, paint);
}
Path _createDashedPath(Path source, double dashWidth, double dashSpace) {
final Path dashedPath = Path();
for (PathMetric pathMetric in source.computeMetrics()) {
double distance = 0.0;
final dashedPath = Path();
for (final pathMetric in source.computeMetrics()) {
var distance = 0.0;
while (distance < pathMetric.length) {
final double nextDistance = distance + dashWidth;
final nextDistance = distance + dashWidth;
dashedPath.addPath(
pathMetric.extractPath(distance, nextDistance),
Offset.zero,

View File

@ -16,4 +16,4 @@ extension GetMonthNameFromNumber on num {
_ => 'N/A'
};
}
}
}

View File

@ -15,7 +15,8 @@ class AirQualityDataModel extends Equatable {
return AirQualityDataModel(
date: DateTime.parse(json['date'] as String),
data: (json['data'] as List<dynamic>)
.map((e) => AirQualityPercentageData.fromJson(e as Map<String, dynamic>))
.map((e) =>
AirQualityPercentageData.fromJson(e as Map<String, dynamic>))
.toList(),
);
}
@ -46,7 +47,7 @@ class AirQualityPercentageData extends Equatable {
factory AirQualityPercentageData.fromJson(Map<String, dynamic> json) {
return AirQualityPercentageData(
type: json['type'] as String? ?? '',
type: json['type'] as String? ?? '',
name: json['name'] as String? ?? '',
percentage: (json['percentage'] as num?)?.toDouble() ?? 0,
);

View File

@ -36,11 +36,14 @@ class AnalyticsDevice {
deviceTuyaUuid: json['deviceTuyaUuid'] as String?,
isActive: json['isActive'] as bool?,
productDevice: json['productDevice'] != null
? ProductDevice.fromJson(json['productDevice'] as Map<String, dynamic>)
? ProductDevice.fromJson(
json['productDevice'] as Map<String, dynamic>)
: null,
spaceUuid: json['spaceUuid'] as String?,
latitude: json['lat'] != null ? double.parse(json['lat'] as String) : null,
longitude: json['lon'] != null ? double.parse(json['lon'] as String) : null,
latitude:
json['lat'] != null ? double.parse(json['lat'] as String) : null,
longitude:
json['lon'] != null ? double.parse(json['lon'] as String) : null,
);
}
}

View File

@ -15,7 +15,8 @@ class Occupacy extends Equatable {
factory Occupacy.fromJson(Map<String, dynamic> json) {
return Occupacy(
date: DateTime.parse(json['event_date'] as String? ?? '${DateTime.now()}'),
date:
DateTime.parse(json['event_date'] as String? ?? '${DateTime.now()}'),
occupancy: (json['occupancy_percentage'] ?? 0).toString(),
spaceUuid: json['space_uuid'] as String? ?? '',
occupiedSeconds: json['occupied_seconds'] as int? ?? 0,

View File

@ -19,7 +19,8 @@ class OccupancyHeatMapModel extends Equatable {
eventDate: DateTime.parse(
json['event_date'] as String? ?? '${DateTime.now()}',
),
countTotalPresenceDetected: json['count_total_presence_detected'] as int? ?? 0,
countTotalPresenceDetected:
json['count_total_presence_detected'] as int? ?? 0,
);
}

View File

@ -33,7 +33,8 @@ class AirQualityDistributionBloc
state.copyWith(
status: AirQualityDistributionStatus.success,
chartData: result,
filteredChartData: _arrangeChartDataByType(result, state.selectedAqiType),
filteredChartData:
_arrangeChartDataByType(result, state.selectedAqiType),
),
);
} catch (e) {
@ -61,7 +62,8 @@ class AirQualityDistributionBloc
emit(
state.copyWith(
selectedAqiType: event.aqiType,
filteredChartData: _arrangeChartDataByType(state.chartData, event.aqiType),
filteredChartData:
_arrangeChartDataByType(state.chartData, event.aqiType),
),
);
}

View File

@ -7,7 +7,8 @@ import 'package:syncrow_web/pages/analytics/services/device_location/device_loca
part 'device_location_event.dart';
part 'device_location_state.dart';
class DeviceLocationBloc extends Bloc<DeviceLocationEvent, DeviceLocationState> {
class DeviceLocationBloc
extends Bloc<DeviceLocationEvent, DeviceLocationState> {
DeviceLocationBloc(
this._deviceLocationService,
) : super(const DeviceLocationState()) {

View File

@ -53,7 +53,8 @@ class RangeOfAqiBloc extends Bloc<RangeOfAqiEvent, RangeOfAqiState> {
emit(
state.copyWith(
selectedAqiType: event.aqiType,
filteredRangeOfAqi: _arrangeChartDataByType(state.rangeOfAqi, event.aqiType),
filteredRangeOfAqi:
_arrangeChartDataByType(state.rangeOfAqi, event.aqiType),
),
);
}

View File

@ -105,7 +105,8 @@ abstract final class RangeOfAqiChartsHelper {
tooltipRoundedRadius: 16,
showOnTopOfTheChartBoxArea: false,
tooltipPadding: const EdgeInsets.all(8),
getTooltipItems: (touchedSpots) => RangeOfAqiChartsHelper.getTooltipItems(
getTooltipItems: (touchedSpots) =>
RangeOfAqiChartsHelper.getTooltipItems(
touchedSpots,
chartData,
),

View File

@ -81,7 +81,8 @@ class AqiDeviceInfo extends StatelessWidget {
aqiLevel: status
.firstWhere(
(e) => e.code == 'air_quality_index',
orElse: () => Status(code: 'air_quality_index', value: ''),
orElse: () =>
Status(code: 'air_quality_index', value: ''),
)
.value
.toString(),

View File

@ -36,23 +36,25 @@ class AqiDistributionChart extends StatelessWidget {
);
}
List<BarChartGroupData> _buildBarGroups(List<AirQualityDataModel> sortedData) {
List<BarChartGroupData> _buildBarGroups(
List<AirQualityDataModel> sortedData) {
return List.generate(sortedData.length, (index) {
final data = sortedData[index];
final stackItems = <BarChartRodData>[];
double currentY = 0;
bool isFirstElement = true;
var isFirstElement = true;
// Sort data by type to ensure consistent order
final sortedPercentageData = List<AirQualityPercentageData>.from(data.data)
..sort((a, b) => a.type.compareTo(b.type));
final sortedPercentageData =
List<AirQualityPercentageData>.from(data.data)
..sort((a, b) => a.type.compareTo(b.type));
for (final percentageData in sortedPercentageData) {
stackItems.add(
BarChartRodData(
fromY: currentY,
toY: currentY + percentageData.percentage ,
color: AirQualityDataModel.metricColors[percentageData.name]!,
toY: currentY + percentageData.percentage,
color: AirQualityDataModel.metricColors[percentageData.name],
borderRadius: isFirstElement
? const BorderRadius.only(
topLeft: Radius.circular(22),
@ -84,9 +86,9 @@ class AqiDistributionChart extends StatelessWidget {
tooltipRoundedRadius: 16,
tooltipPadding: const EdgeInsets.all(8),
getTooltipItem: (group, groupIndex, rod, rodIndex) {
final data = chartData[group.x.toInt()];
final data = chartData[group.x];
final List<TextSpan> children = [];
final children = <TextSpan>[];
final textStyle = context.textTheme.bodySmall?.copyWith(
color: ColorsManager.blackColor,
@ -94,8 +96,9 @@ class AqiDistributionChart extends StatelessWidget {
);
// Sort data by type to ensure consistent order
final sortedPercentageData = List<AirQualityPercentageData>.from(data.data)
..sort((a, b) => a.type.compareTo(b.type));
final sortedPercentageData =
List<AirQualityPercentageData>.from(data.data)
..sort((a, b) => a.type.compareTo(b.type));
for (final percentageData in sortedPercentageData) {
children.add(TextSpan(

View File

@ -49,7 +49,7 @@ class AqiSubValueWidget extends StatelessWidget {
int _getActiveSegmentByRange(double value, (double min, double max) range) {
final ranges = _getRangesForValue(range);
for (int i = 0; i < ranges.length; i++) {
for (var i = 0; i < ranges.length; i++) {
if (value <= ranges[i].max) return i;
}
return ranges.length - 1;

View File

@ -29,7 +29,8 @@ class AqiTypeDropdown extends StatefulWidget {
class _AqiTypeDropdownState extends State<AqiTypeDropdown> {
AqiType? _selectedItem = AqiType.aqi;
void _updateSelectedItem(AqiType? item) => setState(() => _selectedItem = item);
void _updateSelectedItem(AqiType? item) =>
setState(() => _selectedItem = item);
@override
Widget build(BuildContext context) {

View File

@ -63,7 +63,7 @@ class RangeOfAqiChart extends StatelessWidget {
gradient: LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
stops: [0.0, 0.2, 0.4, 0.6, 0.8, 1.0],
stops: const [0.0, 0.2, 0.4, 0.6, 0.8, 1.0],
colors: RangeOfAqiChartsHelper.gradientData.map((e) {
final (color, _) = e;
return color.withValues(alpha: 0.6);
@ -99,7 +99,8 @@ class RangeOfAqiChart extends StatelessWidget {
}) {
const invisibleDot = FlDotData(show: false);
return LineChartBarData(
spots: List.generate(values.length, (i) => FlSpot(i.toDouble(), values[i])),
spots:
List.generate(values.length, (i) => FlSpot(i.toDouble(), values[i])),
isCurved: true,
color: color,
barWidth: 4,

View File

@ -32,7 +32,8 @@ class RangeOfAqiChartBox extends StatelessWidget {
const SizedBox(height: 10),
const Divider(),
const SizedBox(height: 20),
Expanded(child: RangeOfAqiChart(chartData: state.filteredRangeOfAqi)),
Expanded(
child: RangeOfAqiChart(chartData: state.filteredRangeOfAqi)),
],
),
);

View File

@ -8,7 +8,8 @@ sealed class AnalyticsDevicesEvent extends Equatable {
}
final class LoadAnalyticsDevicesEvent extends AnalyticsDevicesEvent {
const LoadAnalyticsDevicesEvent({required this.param, required this.onSuccess});
const LoadAnalyticsDevicesEvent(
{required this.param, required this.onSuccess});
final GetAnalyticsDevicesParam param;
final void Function(AnalyticsDevice device) onSuccess;

View File

@ -7,7 +7,7 @@ sealed class AnalyticsTabEvent extends Equatable {
List<Object> get props => [];
}
class UpdateAnalyticsTabEvent extends AnalyticsTabEvent {
class UpdateAnalyticsTabEvent extends AnalyticsTabEvent {
const UpdateAnalyticsTabEvent(this.analyticsTab);
final AnalyticsPageTab analyticsTab;

View File

@ -8,7 +8,8 @@ import 'package:syncrow_web/pages/space_tree/bloc/space_tree_event.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
final class AirQualityDataLoadingStrategy implements AnalyticsDataLoadingStrategy {
final class AirQualityDataLoadingStrategy
implements AnalyticsDataLoadingStrategy {
@override
void onCommunitySelected(
BuildContext context,
@ -25,7 +26,8 @@ final class AirQualityDataLoadingStrategy implements AnalyticsDataLoadingStrateg
SpaceModel space,
) {
final spaceTreeBloc = context.read<SpaceTreeBloc>();
final isSpaceSelected = spaceTreeBloc.state.selectedSpaces.contains(space.uuid);
final isSpaceSelected =
spaceTreeBloc.state.selectedSpaces.contains(space.uuid);
final hasSelectedSpaces = spaceTreeBloc.state.selectedSpaces.isNotEmpty;
if (hasSelectedSpaces) clearData(context);
@ -34,7 +36,7 @@ final class AirQualityDataLoadingStrategy implements AnalyticsDataLoadingStrateg
spaceTreeBloc
..add(const SpaceTreeClearSelectionEvent())
..add(OnSpaceSelected(community, space.uuid ?? '', []));
..add(OnSpaceSelected(community, space.uuid ?? '', const []));
FetchAirQualityDataHelper.loadAirQualityData(
context,

View File

@ -8,7 +8,8 @@ abstract final class AnalyticsDataLoadingStrategyFactory {
const AnalyticsDataLoadingStrategyFactory._();
static AnalyticsDataLoadingStrategy getStrategy(AnalyticsPageTab tab) {
return switch (tab) {
AnalyticsPageTab.energyManagement => EnergyManagementDataLoadingStrategy(),
AnalyticsPageTab.energyManagement =>
EnergyManagementDataLoadingStrategy(),
AnalyticsPageTab.occupancy => OccupancyDataLoadingStrategy(),
AnalyticsPageTab.airQuality => AirQualityDataLoadingStrategy(),
};

View File

@ -7,7 +7,8 @@ import 'package:syncrow_web/pages/space_tree/bloc/space_tree_event.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
class EnergyManagementDataLoadingStrategy implements AnalyticsDataLoadingStrategy {
class EnergyManagementDataLoadingStrategy
implements AnalyticsDataLoadingStrategy {
@override
void onCommunitySelected(
BuildContext context,
@ -31,7 +32,8 @@ class EnergyManagementDataLoadingStrategy implements AnalyticsDataLoadingStrateg
SpaceModel space,
) {
final spaceTreeBloc = context.read<SpaceTreeBloc>();
final isSpaceSelected = spaceTreeBloc.state.selectedSpaces.contains(space.uuid);
final isSpaceSelected =
spaceTreeBloc.state.selectedSpaces.contains(space.uuid);
final hasSelectedSpaces = spaceTreeBloc.state.selectedSpaces.isNotEmpty;
if (isSpaceSelected) {

View File

@ -24,7 +24,8 @@ class OccupancyDataLoadingStrategy implements AnalyticsDataLoadingStrategy {
SpaceModel space,
) {
final spaceTreeBloc = context.read<SpaceTreeBloc>();
final isSpaceSelected = spaceTreeBloc.state.selectedSpaces.contains(space.uuid);
final isSpaceSelected =
spaceTreeBloc.state.selectedSpaces.contains(space.uuid);
final hasSelectedSpaces = spaceTreeBloc.state.selectedSpaces.isNotEmpty;
if (hasSelectedSpaces) clearData(context);
@ -33,7 +34,7 @@ class OccupancyDataLoadingStrategy implements AnalyticsDataLoadingStrategy {
spaceTreeBloc
..add(const SpaceTreeClearSelectionEvent())
..add(OnSpaceSelected(community, space.uuid ?? '', []));
..add(OnSpaceSelected(community, space.uuid ?? '', const []));
FetchOccupancyDataHelper.loadOccupancyData(
context,

View File

@ -10,7 +10,8 @@ class AnalyticsCommunitiesSidebar extends StatelessWidget {
@override
Widget build(BuildContext context) {
final selectedTab = context.watch<AnalyticsTabBloc>().state;
final strategy = AnalyticsDataLoadingStrategyFactory.getStrategy(selectedTab);
final strategy =
AnalyticsDataLoadingStrategyFactory.getStrategy(selectedTab);
return Expanded(
child: AnalyticsSpaceTreeView(

View File

@ -20,7 +20,7 @@ class AnalyticsDateFilterButton extends StatefulWidget {
final void Function(DateTime)? onDateSelected;
final DatePickerType datePickerType;
static final _color = ColorsManager.blackColor.withValues(alpha: 0.8);
static final Color _color = ColorsManager.blackColor.withValues(alpha: 0.8);
@override
State<AnalyticsDateFilterButton> createState() =>

View File

@ -21,8 +21,8 @@ class AnalyticsPageTabButton extends StatelessWidget {
onPressed: () {
AnalyticsDataLoadingStrategyFactory.getStrategy(tab).clearData(context);
context.read<AnalyticsTabBloc>().add(
UpdateAnalyticsTabEvent(tab),
);
UpdateAnalyticsTabEvent(tab),
);
},
child: Text(
tab.title,
@ -33,8 +33,9 @@ class AnalyticsPageTabButton extends StatelessWidget {
style: TextStyle(
fontWeight: isSelected ? FontWeight.w700 : FontWeight.w400,
fontSize: 16,
color:
isSelected ? ColorsManager.slidingBlueColor : ColorsManager.textGray,
color: isSelected
? ColorsManager.slidingBlueColor
: ColorsManager.textGray,
),
),
);

View File

@ -21,18 +21,18 @@ class _MonthPickerWidgetState extends State<MonthPickerWidget> {
int? _selectedMonth;
static const _monthNames = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
];
@override
@ -189,14 +189,19 @@ class _MonthPickerWidgetState extends State<MonthPickerWidget> {
final isFutureMonth = isCurrentYear && index > currentDate.month - 1;
return InkWell(
onTap: isFutureMonth ? null : () => setState(() => _selectedMonth = index),
onTap: isFutureMonth
? null
: () => setState(() => _selectedMonth = index),
child: DecoratedBox(
decoration: BoxDecoration(
color: const Color(0xFFEDF2F7),
borderRadius: BorderRadius.only(
topLeft: index % 3 == 0 ? const Radius.circular(16) : Radius.zero,
bottomLeft: index % 3 == 0 ? const Radius.circular(16) : Radius.zero,
topRight: index % 3 == 2 ? const Radius.circular(16) : Radius.zero,
topLeft:
index % 3 == 0 ? const Radius.circular(16) : Radius.zero,
bottomLeft:
index % 3 == 0 ? const Radius.circular(16) : Radius.zero,
topRight:
index % 3 == 2 ? const Radius.circular(16) : Radius.zero,
bottomRight:
index % 3 == 2 ? const Radius.circular(16) : Radius.zero,
),

View File

@ -53,7 +53,8 @@ class _AnalyticsSpaceTreeViewState extends State<AnalyticsSpaceTreeView> {
@override
Widget build(BuildContext context) {
return BlocBuilder<SpaceTreeBloc, SpaceTreeState>(builder: (context, state) {
return BlocBuilder<SpaceTreeBloc, SpaceTreeState>(
builder: (context, state) {
final communities = state.searchQuery.isNotEmpty
? state.filteredCommunity
: state.communityList;
@ -76,9 +77,10 @@ class _AnalyticsSpaceTreeViewState extends State<AnalyticsSpaceTreeView> {
),
),
CustomSearchBar(
onSearchChanged: (query) => context.read<SpaceTreeBloc>().add(
SearchQueryEvent(query),
),
onSearchChanged: (query) =>
context.read<SpaceTreeBloc>().add(
SearchQueryEvent(query),
),
),
const SizedBox(height: 16),
Expanded(
@ -113,7 +115,8 @@ class _AnalyticsSpaceTreeViewState extends State<AnalyticsSpaceTreeView> {
isExpanded: state.expandedCommunities.contains(
communities[index].uuid,
),
onItemSelected: () => widget.onSelectCommunity?.call(
onItemSelected: () =>
widget.onSelectCommunity?.call(
communities[index],
communities[index].spaces,
),
@ -121,8 +124,8 @@ class _AnalyticsSpaceTreeViewState extends State<AnalyticsSpaceTreeView> {
(space) {
return CustomExpansionTileSpaceTree(
title: space.name,
isExpanded:
state.expandedSpaces.contains(space.uuid),
isExpanded: state.expandedSpaces
.contains(space.uuid),
onItemSelected: () =>
widget.onSelectSpace?.call(
communities[index],
@ -153,7 +156,8 @@ class _AnalyticsSpaceTreeViewState extends State<AnalyticsSpaceTreeView> {
},
),
),
if (state.paginationIsLoading) const CircularProgressIndicator(),
if (state.paginationIsLoading)
const CircularProgressIndicator(),
],
),
);

View File

@ -19,9 +19,9 @@ class YearPickerWidget extends StatefulWidget {
class _YearPickerWidgetState extends State<YearPickerWidget> {
late int _currentYear;
static final years = List.generate(
static final List<int> years = List.generate(
DateTime.now().year - (DateTime.now().year - 5) + 1,
(index) => (2020 + index),
(index) => 2020 + index,
).where((year) => year <= DateTime.now().year).toList();
@override
@ -123,9 +123,12 @@ class _YearPickerWidgetState extends State<YearPickerWidget> {
decoration: BoxDecoration(
color: const Color(0xFFEDF2F7),
borderRadius: BorderRadius.only(
topLeft: index % 3 == 0 ? const Radius.circular(16) : Radius.zero,
bottomLeft: index % 3 == 0 ? const Radius.circular(16) : Radius.zero,
topRight: index % 3 == 2 ? const Radius.circular(16) : Radius.zero,
topLeft:
index % 3 == 0 ? const Radius.circular(16) : Radius.zero,
bottomLeft:
index % 3 == 0 ? const Radius.circular(16) : Radius.zero,
topRight:
index % 3 == 2 ? const Radius.circular(16) : Radius.zero,
bottomRight:
index % 3 == 2 ? const Radius.circular(16) : Radius.zero,
),

View File

@ -8,13 +8,15 @@ import 'package:syncrow_web/services/api/api_exception.dart';
part 'energy_consumption_by_phases_event.dart';
part 'energy_consumption_by_phases_state.dart';
class EnergyConsumptionByPhasesBloc
extends Bloc<EnergyConsumptionByPhasesEvent, EnergyConsumptionByPhasesState> {
class EnergyConsumptionByPhasesBloc extends Bloc<EnergyConsumptionByPhasesEvent,
EnergyConsumptionByPhasesState> {
EnergyConsumptionByPhasesBloc(
this._energyConsumptionByPhasesService,
) : super(const EnergyConsumptionByPhasesState()) {
on<LoadEnergyConsumptionByPhasesEvent>(_onLoadEnergyConsumptionByPhasesEvent);
on<ClearEnergyConsumptionByPhasesEvent>(_onClearEnergyConsumptionByPhasesEvent);
on<LoadEnergyConsumptionByPhasesEvent>(
_onLoadEnergyConsumptionByPhasesEvent);
on<ClearEnergyConsumptionByPhasesEvent>(
_onClearEnergyConsumptionByPhasesEvent);
}
final EnergyConsumptionByPhasesService _energyConsumptionByPhasesService;
@ -25,7 +27,8 @@ class EnergyConsumptionByPhasesBloc
) async {
emit(state.copyWith(status: EnergyConsumptionByPhasesStatus.loading));
try {
final chartData = await _energyConsumptionByPhasesService.load(event.param);
final chartData =
await _energyConsumptionByPhasesService.load(event.param);
emit(
state.copyWith(
status: EnergyConsumptionByPhasesStatus.loaded,
@ -49,7 +52,7 @@ class EnergyConsumptionByPhasesBloc
}
}
void _onClearEnergyConsumptionByPhasesEvent(
Future<void> _onClearEnergyConsumptionByPhasesEvent(
ClearEnergyConsumptionByPhasesEvent event,
Emitter<EnergyConsumptionByPhasesState> emit,
) async {

View File

@ -7,7 +7,8 @@ sealed class EnergyConsumptionByPhasesEvent extends Equatable {
List<Object> get props => [];
}
class LoadEnergyConsumptionByPhasesEvent extends EnergyConsumptionByPhasesEvent {
class LoadEnergyConsumptionByPhasesEvent
extends EnergyConsumptionByPhasesEvent {
const LoadEnergyConsumptionByPhasesEvent({
required this.param,
});
@ -18,6 +19,7 @@ class LoadEnergyConsumptionByPhasesEvent extends EnergyConsumptionByPhasesEvent
List<Object> get props => [param];
}
final class ClearEnergyConsumptionByPhasesEvent extends EnergyConsumptionByPhasesEvent {
final class ClearEnergyConsumptionByPhasesEvent
extends EnergyConsumptionByPhasesEvent {
const ClearEnergyConsumptionByPhasesEvent();
}

View File

@ -8,12 +8,13 @@ import 'package:syncrow_web/services/api/api_exception.dart';
part 'energy_consumption_per_device_event.dart';
part 'energy_consumption_per_device_state.dart';
class EnergyConsumptionPerDeviceBloc
extends Bloc<EnergyConsumptionPerDeviceEvent, EnergyConsumptionPerDeviceState> {
class EnergyConsumptionPerDeviceBloc extends Bloc<
EnergyConsumptionPerDeviceEvent, EnergyConsumptionPerDeviceState> {
EnergyConsumptionPerDeviceBloc(
this._energyConsumptionPerDeviceService,
) : super(const EnergyConsumptionPerDeviceState()) {
on<LoadEnergyConsumptionPerDeviceEvent>(_onLoadEnergyConsumptionPerDeviceEvent);
on<LoadEnergyConsumptionPerDeviceEvent>(
_onLoadEnergyConsumptionPerDeviceEvent);
on<ClearEnergyConsumptionPerDeviceEvent>(
_onClearEnergyConsumptionPerDeviceEvent);
}
@ -26,7 +27,8 @@ class EnergyConsumptionPerDeviceBloc
) async {
emit(state.copyWith(status: EnergyConsumptionPerDeviceStatus.loading));
try {
final chartData = await _energyConsumptionPerDeviceService.load(event.param);
final chartData =
await _energyConsumptionPerDeviceService.load(event.param);
emit(
state.copyWith(
status: EnergyConsumptionPerDeviceStatus.loaded,
@ -50,7 +52,7 @@ class EnergyConsumptionPerDeviceBloc
}
}
void _onClearEnergyConsumptionPerDeviceEvent(
Future<void> _onClearEnergyConsumptionPerDeviceEvent(
ClearEnergyConsumptionPerDeviceEvent event,
Emitter<EnergyConsumptionPerDeviceState> emit,
) async {

View File

@ -8,7 +8,8 @@ import 'package:syncrow_web/services/api/api_exception.dart';
part 'power_clamp_info_event.dart';
part 'power_clamp_info_state.dart';
class PowerClampInfoBloc extends Bloc<PowerClampInfoEvent, PowerClampInfoState> {
class PowerClampInfoBloc
extends Bloc<PowerClampInfoEvent, PowerClampInfoState> {
PowerClampInfoBloc(
this._powerClampInfoService,
) : super(const PowerClampInfoState()) {
@ -25,7 +26,8 @@ class PowerClampInfoBloc extends Bloc<PowerClampInfoEvent, PowerClampInfoState>
) async {
emit(state.copyWith(status: PowerClampInfoStatus.loading));
try {
final powerClampModel = await _powerClampInfoService.getInfo(event.deviceId);
final powerClampModel =
await _powerClampInfoService.getInfo(event.deviceId);
emit(
state.copyWith(
status: PowerClampInfoStatus.loaded,
@ -49,7 +51,7 @@ class PowerClampInfoBloc extends Bloc<PowerClampInfoEvent, PowerClampInfoState>
}
}
void _onUpdatePowerClampStatusEvent(
Future<void> _onUpdatePowerClampStatusEvent(
UpdatePowerClampStatusEvent event,
Emitter<PowerClampInfoState> emit,
) async {

View File

@ -16,7 +16,6 @@ final class LoadPowerClampInfoEvent extends PowerClampInfoEvent {
List<Object> get props => [deviceId];
}
final class UpdatePowerClampStatusEvent extends PowerClampInfoEvent {
const UpdatePowerClampStatusEvent(this.statusList);
@ -28,4 +27,4 @@ final class UpdatePowerClampStatusEvent extends PowerClampInfoEvent {
final class ClearPowerClampInfoEvent extends PowerClampInfoEvent {
const ClearPowerClampInfoEvent();
}
}

View File

@ -24,4 +24,4 @@ class _RealtimeDeviceChangesUpdated extends RealtimeDeviceChangesEvent {
final List<Status> deviceStatusList;
const _RealtimeDeviceChangesUpdated(this.deviceStatusList);
}
}

View File

@ -49,7 +49,7 @@ class TotalEnergyConsumptionBloc
}
}
void _onClearTotalEnergyConsumptionEvent(
Future<void> _onClearTotalEnergyConsumptionEvent(
ClearTotalEnergyConsumptionEvent event,
Emitter<TotalEnergyConsumptionState> emit,
) async {

View File

@ -7,7 +7,8 @@ sealed class TotalEnergyConsumptionEvent extends Equatable {
List<Object?> get props => [];
}
final class TotalEnergyConsumptionLoadEvent extends TotalEnergyConsumptionEvent {
final class TotalEnergyConsumptionLoadEvent
extends TotalEnergyConsumptionEvent {
const TotalEnergyConsumptionLoadEvent({required this.param});
final GetTotalEnergyConsumptionParam param;
@ -16,6 +17,7 @@ final class TotalEnergyConsumptionLoadEvent extends TotalEnergyConsumptionEvent
List<Object?> get props => [param];
}
final class ClearTotalEnergyConsumptionEvent extends TotalEnergyConsumptionEvent {
final class ClearTotalEnergyConsumptionEvent
extends TotalEnergyConsumptionEvent {
const ClearTotalEnergyConsumptionEvent();
}

View File

@ -69,7 +69,8 @@ abstract final class EnergyManagementChartsHelper {
return labels.where((element) => element.isNotEmpty).join(', ');
}
static List<LineTooltipItem?> getTooltipItems(List<LineBarSpot> touchedSpots) {
static List<LineTooltipItem?> getTooltipItems(
List<LineBarSpot> touchedSpots) {
return touchedSpots.map((spot) {
return LineTooltipItem(
getToolTipLabel(spot.x, spot.y),
@ -85,7 +86,8 @@ abstract final class EnergyManagementChartsHelper {
static LineTouchTooltipData lineTouchTooltipData() {
return LineTouchTooltipData(
getTooltipColor: (touchTooltipItem) => ColorsManager.whiteColors,
tooltipBorder: const BorderSide(color: ColorsManager.semiTransparentBlack),
tooltipBorder:
const BorderSide(color: ColorsManager.semiTransparentBlack),
tooltipRoundedRadius: 16,
showOnTopOfTheChartBoxArea: false,
tooltipPadding: const EdgeInsets.all(8),

View File

@ -122,7 +122,8 @@ abstract final class FetchEnergyManagementDataHelper {
final selectedDevice = getSelectedDevice(context);
context.read<RealtimeDeviceChangesBloc>().add(
RealtimeDeviceChangesStarted(deviceUuid ?? selectedDevice?.uuid ?? ''),
RealtimeDeviceChangesStarted(
deviceUuid ?? selectedDevice?.uuid ?? ''),
);
}

View File

@ -51,7 +51,8 @@ class AnalyticsEnergyManagementView extends StatelessWidget {
spacing: 20,
children: [
Expanded(child: TotalEnergyConsumptionChartBox()),
Expanded(child: EnergyConsumptionPerDeviceChartBox()),
Expanded(
child: EnergyConsumptionPerDeviceChartBox()),
],
),
),

View File

@ -52,7 +52,8 @@ class AnalyticsDeviceDropdown extends StatelessWidget {
);
}
Widget _buildDevicesDropdown(BuildContext context, AnalyticsDevicesState state) {
Widget _buildDevicesDropdown(
BuildContext context, AnalyticsDevicesState state) {
final spaceUuid = state.selectedDevice?.spaceUuid;
return DropdownButton<AnalyticsDevice?>(
value: state.selectedDevice,

View File

@ -18,7 +18,6 @@ class EnergyConsumptionByPhasesChart extends StatelessWidget {
Widget build(BuildContext context) {
return BarChart(
BarChartData(
gridData: EnergyManagementChartsHelper.gridData().copyWith(
checkToShowHorizontalLine: (value) => true,
horizontalInterval: 250,
@ -100,11 +99,11 @@ class EnergyConsumptionByPhasesChart extends StatelessWidget {
}) {
final data = energyData;
final date = DateFormat('dd/MM/yyyy').format(data[group.x.toInt()].date);
final phaseA = data[group.x.toInt()].energyConsumedA;
final phaseB = data[group.x.toInt()].energyConsumedB;
final phaseC = data[group.x.toInt()].energyConsumedC;
final total = data[group.x.toInt()].energyConsumedKw;
final date = DateFormat('dd/MM/yyyy').format(data[group.x].date);
final phaseA = data[group.x].energyConsumedA;
final phaseB = data[group.x].energyConsumedB;
final phaseC = data[group.x].energyConsumedC;
final total = data[group.x].energyConsumedKw;
return BarTooltipItem(
'$date\n',

View File

@ -22,7 +22,8 @@ class EnergyConsumptionByPhasesChartBox extends StatelessWidget {
children: [
AnalyticsErrorWidget(state.errorMessage),
EnergyConsumptionByPhasesTitle(
isLoading: state.status == EnergyConsumptionByPhasesStatus.loading,
isLoading:
state.status == EnergyConsumptionByPhasesStatus.loading,
),
const SizedBox(height: 20),
Expanded(

View File

@ -17,7 +17,6 @@ class EnergyConsumptionPerDeviceChart extends StatelessWidget {
context,
leftTitlesInterval: 250,
),
gridData: EnergyManagementChartsHelper.gridData().copyWith(
checkToShowHorizontalLine: (value) => true,
horizontalInterval: 250,

View File

@ -46,7 +46,8 @@ class EnergyConsumptionPerDeviceChartBox extends StatelessWidget {
flex: 2,
child: EnergyConsumptionPerDeviceDevicesList(
chartData: state.chartData,
devices: context.watch<AnalyticsDevicesBloc>().state.devices,
devices:
context.watch<AnalyticsDevicesBloc>().state.devices,
),
),
],
@ -55,7 +56,8 @@ class EnergyConsumptionPerDeviceChartBox extends StatelessWidget {
const Divider(height: 0),
const SizedBox(height: 20),
Expanded(
child: EnergyConsumptionPerDeviceChart(chartData: state.chartData),
child:
EnergyConsumptionPerDeviceChart(chartData: state.chartData),
),
],
),

View File

@ -43,11 +43,14 @@ class PowerClampEnergyDataWidget extends StatelessWidget {
title: 'Smart Power Clamp',
showSpaceUuidInDevicesDropdown: true,
onChanged: (device) {
FetchEnergyManagementDataHelper.loadEnergyConsumptionByPhases(
FetchEnergyManagementDataHelper
.loadEnergyConsumptionByPhases(
context,
powerClampUuid: device.uuid,
selectedDate:
context.read<AnalyticsDatePickerBloc>().state.monthlyDate,
selectedDate: context
.read<AnalyticsDatePickerBloc>()
.state
.monthlyDate,
);
},
),
@ -91,7 +94,8 @@ class PowerClampEnergyDataWidget extends StatelessWidget {
),
),
const SizedBox(height: 14),
const Expanded(flex: 3, child: EnergyConsumptionByPhasesChartBox()),
const Expanded(
flex: 3, child: EnergyConsumptionByPhasesChartBox()),
],
),
);

View File

@ -140,9 +140,9 @@ class PowerClampPhasesDataWidget extends StatelessWidget {
String _formatCurrentValue(String? value) {
if (value == null) return '--';
String str = value;
var str = value;
if (str.isEmpty || str == '--') return '--';
str = str.replaceAll(RegExp(r'[^0-9]'), '');
str = str.replaceAll(RegExp('[^0-9]'), '');
if (str.isEmpty) return '--';
if (str.length == 1) return '${str[0]}.0';
return '${str[0]}.${str.substring(1)}';
@ -150,9 +150,9 @@ class PowerClampPhasesDataWidget extends StatelessWidget {
String _formatPowerFactor(String? value) {
if (value == null) return '--';
String str = value;
var str = value;
if (str.isEmpty || str == '--') return '--';
str = str.replaceAll(RegExp(r'[^0-9]'), '');
str = str.replaceAll(RegExp('[^0-9]'), '');
if (str.isEmpty) return '--';
final intValue = int.tryParse(str);
if (intValue == null) return '--';
@ -162,9 +162,9 @@ class PowerClampPhasesDataWidget extends StatelessWidget {
String _formatVoltage(String? value) {
if (value == null) return '--';
String str = value;
var str = value;
if (str.isEmpty || str == '--') return '--';
str = str.replaceAll(RegExp(r'[^0-9]'), '');
str = str.replaceAll(RegExp('[^0-9]'), '');
if (str.isEmpty) return '--';
if (str.length == 1) return '0.${str[0]}';
return '${str.substring(0, str.length - 1)}.${str.substring(str.length - 1)}';

View File

@ -29,7 +29,6 @@ class TotalEnergyConsumptionChart extends StatelessWidget {
),
duration: Duration.zero,
curve: Curves.easeIn,
),
);
}

View File

@ -25,7 +25,8 @@ class TotalEnergyConsumptionChartBox extends StatelessWidget {
Row(
children: [
ChartsLoadingWidget(
isLoading: state.status == TotalEnergyConsumptionStatus.loading,
isLoading:
state.status == TotalEnergyConsumptionStatus.loading,
),
const Expanded(
flex: 3,

View File

@ -23,9 +23,11 @@ class OccupancyBloc extends Bloc<OccupancyEvent, OccupancyState> {
emit(state.copyWith(status: OccupancyStatus.loading));
try {
final chartData = await _occupacyService.load(event.param);
emit(state.copyWith(chartData: chartData, status: OccupancyStatus.loaded));
emit(
state.copyWith(chartData: chartData, status: OccupancyStatus.loaded));
} on APIException catch (e) {
emit(state.copyWith(status: OccupancyStatus.failure, errorMessage: e.message));
emit(state.copyWith(
status: OccupancyStatus.failure, errorMessage: e.message));
} catch (e) {
emit(state.copyWith(status: OccupancyStatus.failure, errorMessage: '$e'));
}

View File

@ -25,15 +25,18 @@ abstract final class FetchOccupancyDataHelper {
final datePickerState = context.read<AnalyticsDatePickerBloc>().state;
loadAnalyticsDevices(context, communityUuid: communityId, spaceUuid: spaceId);
final selectedDevice = context.read<AnalyticsDevicesBloc>().state.selectedDevice;
loadAnalyticsDevices(context,
communityUuid: communityId, spaceUuid: spaceId);
final selectedDevice =
context.read<AnalyticsDevicesBloc>().state.selectedDevice;
loadOccupancyChartData(
context,
spaceUuid: spaceId,
date: datePickerState.monthlyDate,
);
loadHeatMapData(context, spaceUuid: spaceId, year: datePickerState.yearlyDate);
loadHeatMapData(context,
spaceUuid: spaceId, year: datePickerState.yearlyDate);
if (selectedDevice case final AnalyticsDevice device) {
context.read<RealtimeDeviceChangesBloc>()
@ -64,7 +67,8 @@ abstract final class FetchOccupancyDataHelper {
context.read<OccupancyBloc>().add(
LoadOccupancyEvent(
GetOccupancyParam(
monthDate: '${date.year}-${date.month.toString().padLeft(2, '0')}',
monthDate:
'${date.year}-${date.month.toString().padLeft(2, '0')}',
spaceUuid: spaceUuid,
),
),

View File

@ -20,9 +20,12 @@ class AnalyticsOccupancyView extends StatelessWidget {
child: Column(
spacing: 32,
children: [
SizedBox(height: height * 0.46, child: const OccupancyEndSideBar()),
SizedBox(height: height * 0.5, child: const OccupancyChartBox()),
SizedBox(height: height * 0.5, child: const OccupancyHeatMapBox()),
SizedBox(
height: height * 0.46, child: const OccupancyEndSideBar()),
SizedBox(
height: height * 0.5, child: const OccupancyChartBox()),
SizedBox(
height: height * 0.5, child: const OccupancyHeatMapBox()),
],
),
);

View File

@ -41,7 +41,8 @@ class OccupancyChart extends StatelessWidget {
barRods: [
BarChartRodData(
toY: 100.0,
fromY: occupancyValue == 0 ? occupancyValue : occupancyValue + 2.5,
fromY:
occupancyValue == 0 ? occupancyValue : occupancyValue + 2.5,
color: ColorsManager.graysColor,
width: _chartWidth,
borderRadius: BorderRadius.circular(10),
@ -88,8 +89,8 @@ class OccupancyChart extends StatelessWidget {
}) {
final data = chartData;
final occupancyValue = double.parse(data[group.x.toInt()].occupancy);
final percentage = '${(occupancyValue).toStringAsFixed(0)}%';
final occupancyValue = double.parse(data[group.x].occupancy);
final percentage = '${occupancyValue.toStringAsFixed(0)}%';
return BarTooltipItem(
percentage,
@ -116,7 +117,7 @@ class OccupancyChart extends StatelessWidget {
alignment: AlignmentDirectional.centerStart,
fit: BoxFit.scaleDown,
child: Text(
'${(value).toStringAsFixed(0)}%',
'${value.toStringAsFixed(0)}%',
style: context.textTheme.bodySmall?.copyWith(
fontSize: 12,
color: ColorsManager.greyColor,

View File

@ -44,13 +44,15 @@ class OccupancyChartBox extends StatelessWidget {
child: AnalyticsDateFilterButton(
onDateSelected: (DateTime value) {
context.read<AnalyticsDatePickerBloc>().add(
UpdateAnalyticsDatePickerEvent(montlyDate: value),
UpdateAnalyticsDatePickerEvent(
montlyDate: value),
);
if (spaceTreeState.selectedSpaces.isNotEmpty) {
FetchOccupancyDataHelper.loadOccupancyChartData(
context,
spaceUuid:
spaceTreeState.selectedSpaces.firstOrNull ?? '',
spaceTreeState.selectedSpaces.firstOrNull ??
'',
date: value,
);
}

View File

@ -44,13 +44,15 @@ class OccupancyHeatMapBox extends StatelessWidget {
child: AnalyticsDateFilterButton(
onDateSelected: (DateTime value) {
context.read<AnalyticsDatePickerBloc>().add(
UpdateAnalyticsDatePickerEvent(yearlyDate: value),
UpdateAnalyticsDatePickerEvent(
yearlyDate: value),
);
if (spaceTreeState.selectedSpaces.isNotEmpty) {
FetchOccupancyDataHelper.loadHeatMapData(
context,
spaceUuid:
spaceTreeState.selectedSpaces.firstOrNull ?? '',
spaceTreeState.selectedSpaces.firstOrNull ??
'',
year: value,
);
}

View File

@ -28,11 +28,11 @@ class OccupancyPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final Paint fillPaint = Paint();
final Paint borderPaint = Paint()
final fillPaint = Paint();
final borderPaint = Paint()
..color = ColorsManager.grayBorder.withValues(alpha: 0.4)
..style = PaintingStyle.stroke;
final Paint hoveredBorderPaint = Paint()
final hoveredBorderPaint = Paint()
..color = Colors.black
..style = PaintingStyle.stroke
..strokeWidth = 1.5;
@ -66,24 +66,24 @@ class OccupancyPainter extends CustomPainter {
);
canvas.drawLine(Offset(x, y), Offset(x, y + cellSize), borderPaint);
canvas.drawLine(Offset(x + cellSize, y), Offset(x + cellSize, y + cellSize),
borderPaint);
canvas.drawLine(Offset(x + cellSize, y),
Offset(x + cellSize, y + cellSize), borderPaint);
}
}
}
void _drawDashedLine(Canvas canvas, Offset start, Offset end, Paint paint) {
const double dashWidth = 2.0;
const double dashSpace = 4.0;
final double totalLength = (end - start).distance;
final Offset direction = (end - start) / (end - start).distance;
const dashWidth = 2.0;
const dashSpace = 4.0;
final totalLength = (end - start).distance;
final direction = (end - start) / (end - start).distance;
double currentLength = 0.0;
var currentLength = 0.0;
while (currentLength < totalLength) {
final Offset dashStart = start + direction * currentLength;
final double nextLength = currentLength + dashWidth;
final Offset dashEnd =
start + direction * (nextLength < totalLength ? nextLength : totalLength);
final dashStart = start + direction * currentLength;
final nextLength = currentLength + dashWidth;
final dashEnd = start +
direction * (nextLength < totalLength ? nextLength : totalLength);
canvas.drawLine(dashStart, dashEnd, paint);
currentLength = nextLength + dashSpace;
}

View File

@ -5,7 +5,8 @@ import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_type
import 'package:syncrow_web/pages/analytics/params/get_air_quality_distribution_param.dart';
import 'package:syncrow_web/pages/analytics/services/air_quality_distribution/air_quality_distribution_service.dart';
class FakeAirQualityDistributionService implements AirQualityDistributionService {
class FakeAirQualityDistributionService
implements AirQualityDistributionService {
final _random = Random();
@override
@ -43,7 +44,6 @@ class FakeAirQualityDistributionService implements AirQualityDistributionService
name: 'poor',
percentage: nonNullValues[2],
type: AqiType.hcho.code,
),
AirQualityPercentageData(
name: 'unhealthy',
@ -71,7 +71,7 @@ class FakeAirQualityDistributionService implements AirQualityDistributionService
List<bool> nullMask,
) {
double nonNullSum = 0;
for (int i = 0; i < originalValues.length; i++) {
for (var i = 0; i < originalValues.length; i++) {
if (!nullMask[i]) {
nonNullSum += originalValues[i];
}

View File

@ -3,7 +3,8 @@ import 'package:syncrow_web/pages/analytics/params/get_air_quality_distribution_
import 'package:syncrow_web/pages/analytics/services/air_quality_distribution/air_quality_distribution_service.dart';
import 'package:syncrow_web/services/api/http_service.dart';
class RemoteAirQualityDistributionService implements AirQualityDistributionService {
class RemoteAirQualityDistributionService
implements AirQualityDistributionService {
RemoteAirQualityDistributionService(this._httpService);
final HTTPService _httpService;

View File

@ -16,7 +16,8 @@ class AnalyticsDevicesServiceDelegate implements AnalyticsDevicesService {
GetAnalyticsDevicesParam param,
) {
return switch (param.requestType) {
AnalyticsDeviceRequestType.occupancy => _occupancyService.getDevices(param),
AnalyticsDeviceRequestType.occupancy =>
_occupancyService.getDevices(param),
AnalyticsDeviceRequestType.energyManagement =>
_energyManagementService.getDevices(param),
};

View File

@ -14,7 +14,8 @@ final class RemoteEnergyManagementAnalyticsDevicesService
static const _defaultErrorMessage = 'Failed to load analytics devices';
@override
Future<List<AnalyticsDevice>> getDevices(GetAnalyticsDevicesParam param) async {
Future<List<AnalyticsDevice>> getDevices(
GetAnalyticsDevicesParam param) async {
try {
final response = await _httpService.get(
path: '/devices-space-community/recursive-child',
@ -37,7 +38,8 @@ final class RemoteEnergyManagementAnalyticsDevicesService
final message = e.response?.data as Map<String, dynamic>?;
final error = message?['error'] as Map<String, dynamic>?;
final errorMessage = error?['error'] as String? ?? '';
final formattedErrorMessage = [_defaultErrorMessage, errorMessage].join(': ');
final formattedErrorMessage =
[_defaultErrorMessage, errorMessage].join(': ');
throw APIException(formattedErrorMessage);
} catch (e) {
throw APIException('$_defaultErrorMessage: $e');

View File

@ -6,7 +6,8 @@ import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
import 'package:syncrow_web/services/api/api_exception.dart';
import 'package:syncrow_web/services/api/http_service.dart';
class RemoteOccupancyAnalyticsDevicesService implements AnalyticsDevicesService {
class RemoteOccupancyAnalyticsDevicesService
implements AnalyticsDevicesService {
const RemoteOccupancyAnalyticsDevicesService(this._httpService);
final HTTPService _httpService;
@ -14,7 +15,8 @@ class RemoteOccupancyAnalyticsDevicesService implements AnalyticsDevicesService
static const _defaultErrorMessage = 'Failed to load analytics devices';
@override
Future<List<AnalyticsDevice>> getDevices(GetAnalyticsDevicesParam param) async {
Future<List<AnalyticsDevice>> getDevices(
GetAnalyticsDevicesParam param) async {
try {
final requests = await Future.wait<List<AnalyticsDevice>>(
param.deviceTypes.map((e) {
@ -34,15 +36,18 @@ class RemoteOccupancyAnalyticsDevicesService implements AnalyticsDevicesService
final message = e.response?.data as Map<String, dynamic>?;
final error = message?['error'] as Map<String, dynamic>?;
final errorMessage = error?['error'] as String? ?? '';
final formattedErrorMessage = [_defaultErrorMessage, errorMessage].join(': ');
final formattedErrorMessage =
[_defaultErrorMessage, errorMessage].join(': ');
throw APIException(formattedErrorMessage);
} catch (e) {
final formattedErrorMessage = [_defaultErrorMessage, e.toString()].join(': ');
final formattedErrorMessage =
[_defaultErrorMessage, e.toString()].join(': ');
throw APIException(formattedErrorMessage);
}
}
Future<List<AnalyticsDevice>> _makeRequest(GetAnalyticsDevicesParam param) async {
Future<List<AnalyticsDevice>> _makeRequest(
GetAnalyticsDevicesParam param) async {
try {
final projectUuid = await ProjectManager.getProjectUUID();
@ -69,7 +74,8 @@ class RemoteOccupancyAnalyticsDevicesService implements AnalyticsDevicesService
final message = e.response?.data as Map<String, dynamic>?;
final error = message?['error'] as Map<String, dynamic>?;
final errorMessage = error?['error'] as String? ?? '';
final formattedErrorMessage = [_defaultErrorMessage, errorMessage].join(': ');
final formattedErrorMessage =
[_defaultErrorMessage, errorMessage].join(': ');
throw APIException(formattedErrorMessage);
} catch (e) {
throw APIException('$_defaultErrorMessage: $e');

View File

@ -34,7 +34,7 @@ class DeviceLocationDetailsServiceDecorator implements DeviceLocationService {
return deviceLocationInfo;
} catch (e) {
throw Exception('Failed to load device location info: ${e.toString()}');
throw Exception('Failed to load device location info: $e');
}
}
}

View File

@ -11,7 +11,8 @@ final class RemoteEnergyConsumptionByPhasesService
final HTTPService _httpService;
static const _defaultErrorMessage = 'Failed to load energy consumption per phase';
static const _defaultErrorMessage =
'Failed to load energy consumption per phase';
@override
Future<List<PhasesEnergyConsumption>> load(
@ -36,7 +37,8 @@ final class RemoteEnergyConsumptionByPhasesService
final message = e.response?.data as Map<String, dynamic>?;
final error = message?['error'] as Map<String, dynamic>?;
final errorMessage = error?['error'] as String? ?? '';
final formattedErrorMessage = [_defaultErrorMessage, errorMessage].join(': ');
final formattedErrorMessage =
[_defaultErrorMessage, errorMessage].join(': ');
throw APIException(formattedErrorMessage);
} catch (e) {
final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');

View File

@ -13,7 +13,8 @@ class RemoteEnergyConsumptionPerDeviceService
final HTTPService _httpService;
static const _defaultErrorMessage = 'Failed to load energy consumption per device';
static const _defaultErrorMessage =
'Failed to load energy consumption per device';
@override
Future<List<DeviceEnergyDataModel>> load(
@ -31,7 +32,8 @@ class RemoteEnergyConsumptionPerDeviceService
final message = e.response?.data as Map<String, dynamic>?;
final error = message?['error'] as Map<String, dynamic>?;
final errorMessage = error?['error'] as String? ?? '';
final formattedErrorMessage = [_defaultErrorMessage, errorMessage].join(': ');
final formattedErrorMessage =
[_defaultErrorMessage, errorMessage].join(': ');
throw APIException(formattedErrorMessage);
} catch (e) {
final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');
@ -59,7 +61,8 @@ abstract final class _EnergyConsumptionPerDeviceMapper {
final energyJson = data as Map<String, dynamic>;
return EnergyDataModel(
date: DateTime.parse(energyJson['date'] as String),
value: double.parse(energyJson['total_energy_consumed_kw'] as String),
value:
double.parse(energyJson['total_energy_consumed_kw'] as String),
);
}).toList(),
);

View File

@ -33,7 +33,8 @@ final class RemoteOccupancyService implements OccupacyService {
final message = e.response?.data as Map<String, dynamic>?;
final error = message?['error'] as Map<String, dynamic>?;
final errorMessage = error?['error'] as String? ?? '';
final formattedErrorMessage = [_defaultErrorMessage, errorMessage].join(': ');
final formattedErrorMessage =
[_defaultErrorMessage, errorMessage].join(': ');
throw APIException(formattedErrorMessage);
} catch (e) {
final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');

View File

@ -13,7 +13,8 @@ final class RemoteOccupancyHeatMapService implements OccupancyHeatMapService {
static const _defaultErrorMessage = 'Failed to load occupancy heat map';
@override
Future<List<OccupancyHeatMapModel>> load(GetOccupancyHeatMapParam param) async {
Future<List<OccupancyHeatMapModel>> load(
GetOccupancyHeatMapParam param) async {
try {
final response = await _httpService.get(
path: '/occupancy/heat-map/space/${param.spaceUuid}',
@ -24,7 +25,8 @@ final class RemoteOccupancyHeatMapService implements OccupancyHeatMapService {
final dailyData = json['data'] as List<dynamic>? ?? <dynamic>[];
final result = dailyData.map(
(json) => OccupancyHeatMapModel.fromJson(json as Map<String, dynamic>),
(json) =>
OccupancyHeatMapModel.fromJson(json as Map<String, dynamic>),
);
return result.toList();
@ -36,7 +38,8 @@ final class RemoteOccupancyHeatMapService implements OccupancyHeatMapService {
final message = e.response?.data as Map<String, dynamic>?;
final error = message?['error'] as Map<String, dynamic>?;
final errorMessage = error?['error'] as String? ?? '';
final formattedErrorMessage = [_defaultErrorMessage, errorMessage].join(': ');
final formattedErrorMessage =
[_defaultErrorMessage, errorMessage].join(': ');
throw APIException(formattedErrorMessage);
} catch (e) {
final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');

View File

@ -28,7 +28,8 @@ final class RemotePowerClampInfoService implements PowerClampInfoService {
final message = e.response?.data as Map<String, dynamic>?;
final error = message?['error'] as Map<String, dynamic>?;
final errorMessage = error?['error'] as String? ?? '';
final formattedErrorMessage = [_defaultErrorMessage, errorMessage].join(': ');
final formattedErrorMessage =
[_defaultErrorMessage, errorMessage].join(': ');
throw APIException(formattedErrorMessage);
} catch (e) {
final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');

View File

@ -6,7 +6,7 @@ import 'package:syncrow_web/pages/analytics/services/range_of_aqi/range_of_aqi_s
class FakeRangeOfAqiService implements RangeOfAqiService {
@override
Future<List<RangeOfAqi>> load(GetRangeOfAqiParam param) async {
return await Future.delayed(const Duration(milliseconds: 800), () {
return Future.delayed(const Duration(milliseconds: 800), () {
final random = DateTime.now().millisecondsSinceEpoch;
return List.generate(30, (index) {
@ -19,14 +19,20 @@ class FakeRangeOfAqiService implements RangeOfAqiService {
final avg = (min + avgDelta).clamp(0.0, 301.0);
final max = (avg + maxDelta).clamp(0.0, 301.0);
return RangeOfAqi(
return RangeOfAqi(
data: [
RangeOfAqiValue(type: AqiType.aqi.code, min: min, average: avg, max: max),
RangeOfAqiValue(type: AqiType.pm25.code, min: min, average: avg, max: max),
RangeOfAqiValue(type: AqiType.pm10.code, min: min, average: avg, max: max),
RangeOfAqiValue(type: AqiType.hcho.code, min: min, average: avg, max: max),
RangeOfAqiValue(type: AqiType.tvoc.code, min: min, average: avg, max: max),
RangeOfAqiValue(type: AqiType.co2.code, min: min, average: avg, max: max),
RangeOfAqiValue(
type: AqiType.aqi.code, min: min, average: avg, max: max),
RangeOfAqiValue(
type: AqiType.pm25.code, min: min, average: avg, max: max),
RangeOfAqiValue(
type: AqiType.pm10.code, min: min, average: avg, max: max),
RangeOfAqiValue(
type: AqiType.hcho.code, min: min, average: avg, max: max),
RangeOfAqiValue(
type: AqiType.tvoc.code, min: min, average: avg, max: max),
RangeOfAqiValue(
type: AqiType.co2.code, min: min, average: avg, max: max),
],
date: date,
);

View File

@ -3,4 +3,4 @@ import 'package:syncrow_web/pages/analytics/params/get_range_of_aqi_param.dart';
abstract interface class RangeOfAqiService {
Future<List<RangeOfAqi>> load(GetRangeOfAqiParam param);
}
}

View File

@ -2,4 +2,4 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/device_sta
abstract interface class RealtimeDeviceService {
Stream<List<Status>> subscribe(String deviceId);
}
}

View File

@ -5,7 +5,8 @@ import 'package:syncrow_web/pages/analytics/services/total_energy_consumption/to
import 'package:syncrow_web/services/api/api_exception.dart';
import 'package:syncrow_web/services/api/http_service.dart';
class RemoteTotalEnergyConsumptionService implements TotalEnergyConsumptionService {
class RemoteTotalEnergyConsumptionService
implements TotalEnergyConsumptionService {
const RemoteTotalEnergyConsumptionService(this._httpService);
final HTTPService _httpService;
@ -29,7 +30,8 @@ class RemoteTotalEnergyConsumptionService implements TotalEnergyConsumptionServi
final message = e.response?.data as Map<String, dynamic>?;
final error = message?['error'] as Map<String, dynamic>?;
final errorMessage = error?['error'] as String? ?? '';
final formattedErrorMessage = [_defaultErrorMessage, errorMessage].join(': ');
final formattedErrorMessage =
[_defaultErrorMessage, errorMessage].join(': ');
throw APIException(formattedErrorMessage);
} catch (e) {
final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');

View File

@ -75,7 +75,8 @@ class AnalyticsSidebarHeader extends StatelessWidget {
),
const SizedBox(height: 6),
SelectableText(
context.watch<AnalyticsDevicesBloc>().state.selectedDevice?.uuid ?? 'N/A',
context.watch<AnalyticsDevicesBloc>().state.selectedDevice?.uuid ??
'N/A',
style: context.textTheme.bodySmall?.copyWith(
color: ColorsManager.blackColor,
fontWeight: FontWeight.w400,

View File

@ -36,7 +36,8 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
////////////////////////////// forget password //////////////////////////////////
final TextEditingController forgetEmailController = TextEditingController();
final TextEditingController forgetPasswordController = TextEditingController();
final TextEditingController forgetPasswordController =
TextEditingController();
final TextEditingController forgetOtp = TextEditingController();
final forgetFormKey = GlobalKey<FormState>();
final forgetEmailKey = GlobalKey<FormState>();
@ -53,7 +54,8 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
return;
}
_remainingTime = 1;
add(UpdateTimerEvent(remainingTime: _remainingTime, isButtonEnabled: false));
add(UpdateTimerEvent(
remainingTime: _remainingTime, isButtonEnabled: false));
try {
forgetEmailValidate = '';
_remainingTime = (await AuthenticationAPI.sendOtp(
@ -62,7 +64,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
} on DioException catch (e) {
if (e.response!.statusCode == 400) {
final errorData = e.response!.data;
String errorMessage = errorData['message'];
final String errorMessage = errorData['message'];
if (errorMessage == 'User not found') {
validate = 'Invalid Credential';
emit(AuthInitialState());
@ -90,7 +92,8 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
_timer?.cancel();
add(const UpdateTimerEvent(remainingTime: 0, isButtonEnabled: true));
} else {
add(UpdateTimerEvent(remainingTime: _remainingTime, isButtonEnabled: false));
add(UpdateTimerEvent(
remainingTime: _remainingTime, isButtonEnabled: false));
}
});
}
@ -100,11 +103,11 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
}
Future<void> changePassword(
Future<void> changePassword(
ChangePasswordEvent event, Emitter<AuthState> emit) async {
emit(LoadingForgetState());
try {
var response = await AuthenticationAPI.verifyOtp(
final response = await AuthenticationAPI.verifyOtp(
email: forgetEmailController.text, otpCode: forgetOtp.text);
if (response == true) {
await AuthenticationAPI.forgetPassword(
@ -122,7 +125,6 @@ Future<void> changePassword(
}
}
String? validateCode(String? value) {
if (value == null || value.isEmpty) {
return 'Code is required';
@ -131,7 +133,9 @@ Future<void> changePassword(
}
void _onUpdateTimer(UpdateTimerEvent event, Emitter<AuthState> emit) {
emit(TimerState(isButtonEnabled: event.isButtonEnabled, remainingTime: event.remainingTime));
emit(TimerState(
isButtonEnabled: event.isButtonEnabled,
remainingTime: event.remainingTime));
}
///////////////////////////////////// login /////////////////////////////////////
@ -151,8 +155,7 @@ Future<void> changePassword(
static UserModel? user;
bool showValidationMessage = false;
void _login(LoginButtonPressed event, Emitter<AuthState> emit) async {
Future<void> _login(LoginButtonPressed event, Emitter<AuthState> emit) async {
emit(AuthLoading());
if (isChecked) {
try {
@ -179,7 +182,7 @@ Future<void> changePassword(
}
if (token.accessTokenIsNotEmpty) {
FlutterSecureStorage storage = const FlutterSecureStorage();
const storage = FlutterSecureStorage();
await storage.write(
key: Token.loginAccessTokenKey, value: token.accessToken);
const FlutterSecureStorage().write(
@ -197,8 +200,7 @@ Future<void> changePassword(
}
}
checkBoxToggle(
void checkBoxToggle(
CheckBoxEvent event,
Emitter<AuthState> emit,
) {
@ -277,12 +279,12 @@ Future<void> changePassword(
if (value == null || value.isEmpty) {
return 'Please enter your password';
}
List<String> validationErrors = [];
final validationErrors = <String>[];
if (!RegExp(r'^(?=.*[a-z])').hasMatch(value)) {
if (!RegExp('^(?=.*[a-z])').hasMatch(value)) {
validationErrors.add(' - one lowercase letter');
}
if (!RegExp(r'^(?=.*[A-Z])').hasMatch(value)) {
if (!RegExp('^(?=.*[A-Z])').hasMatch(value)) {
validationErrors.add(' - one uppercase letter');
}
if (!RegExp(r'^(?=.*\d)').hasMatch(value)) {
@ -304,7 +306,7 @@ Future<void> changePassword(
String? fullNameValidator(String? value) {
if (value == null) return 'Full name is required';
final withoutExtraSpaces = value.replaceAll(RegExp(r"\s+"), ' ').trim();
final withoutExtraSpaces = value.replaceAll(RegExp(r'\s+'), ' ').trim();
if (withoutExtraSpaces.length < 2 || withoutExtraSpaces.length > 30) {
return 'Full name must be between 2 and 30 characters long';
}
@ -339,12 +341,14 @@ Future<void> changePassword(
static Future<String> getTokenAndValidate() async {
try {
const storage = FlutterSecureStorage();
final firstLaunch =
await SharedPreferencesHelper.readBoolFromSP(StringsManager.firstLaunch) ?? true;
final firstLaunch = await SharedPreferencesHelper.readBoolFromSP(
StringsManager.firstLaunch) ??
true;
if (firstLaunch) {
storage.deleteAll();
}
await SharedPreferencesHelper.saveBoolToSP(StringsManager.firstLaunch, false);
await SharedPreferencesHelper.saveBoolToSP(
StringsManager.firstLaunch, false);
final value = await storage.read(key: Token.loginAccessTokenKey) ?? '';
if (value.isEmpty) {
return 'Token not found';
@ -366,7 +370,8 @@ Future<void> changePassword(
}
}
void _fetchRegion(RegionInitialEvent event, Emitter<AuthState> emit) async {
Future<void> _fetchRegion(
RegionInitialEvent event, Emitter<AuthState> emit) async {
try {
emit(AuthLoading());
regionList = await AuthenticationAPI.fetchRegion();
@ -389,15 +394,17 @@ Future<void> changePassword(
}
String formattedTime(int time) {
final int days = (time / 86400).floor(); // 86400 seconds in a day
final int hours = ((time % 86400) / 3600).floor();
final int minutes = (((time % 86400) % 3600) / 60).floor();
final int seconds = (((time % 86400) % 3600) % 60).floor();
final days = (time / 86400).floor(); // 86400 seconds in a day
final hours = ((time % 86400) / 3600).floor();
final minutes = (((time % 86400) % 3600) / 60).floor();
final seconds = ((time % 86400) % 3600) % 60;
final String formattedTime = [
final formattedTime = [
if (days > 0) '${days}d', // Append 'd' for days
if (days > 0 || hours > 0)
hours.toString().padLeft(2, '0'), // Show hours if there are days or hours
hours
.toString()
.padLeft(2, '0'), // Show hours if there are days or hours
minutes.toString().padLeft(2, '0'),
seconds.toString().padLeft(2, '0'),
].join(':');
@ -417,7 +424,7 @@ Future<void> changePassword(
return checkValidate;
}
changeValidate(
void changeValidate(
ChangeValidateEvent event,
Emitter<AuthState> emit,
) {
@ -426,7 +433,7 @@ Future<void> changePassword(
emit(LoginInitial());
}
changeForgetValidate(
void changeForgetValidate(
ChangeValidateEvent event,
Emitter<AuthState> emit,
) {

View File

@ -46,7 +46,8 @@ class StopTimerEvent extends AuthEvent {}
class UpdateTimerEvent extends AuthEvent {
final int remainingTime;
final bool isButtonEnabled;
const UpdateTimerEvent({required this.remainingTime, required this.isButtonEnabled});
const UpdateTimerEvent(
{required this.remainingTime, required this.isButtonEnabled});
}
class ChangePasswordEvent extends AuthEvent {}

View File

@ -56,7 +56,8 @@ class TimerState extends AuthState {
final bool isButtonEnabled;
final int remainingTime;
const TimerState({required this.isButtonEnabled, required this.remainingTime});
const TimerState(
{required this.isButtonEnabled, required this.remainingTime});
@override
List<Object> get props => [isButtonEnabled, remainingTime];
@ -80,7 +81,7 @@ class TimerUpdated extends AuthState {
final String formattedTime;
final bool isButtonEnabled;
TimerUpdated({
const TimerUpdated({
required this.formattedTime,
required this.isButtonEnabled,
});

View File

@ -21,9 +21,9 @@ class LoginWithEmailModel {
return {
'email': email,
'password': password,
"platform": "web"
'platform': 'web'
// 'regionUuid': regionUuid,
};
}
}
//tst@tst.com
//tst@tst.com

View File

@ -11,6 +11,14 @@ class Token {
final int iat;
final int exp;
Token(
this.accessToken,
this.refreshToken,
this.sessionId,
this.iat,
this.exp,
);
Token.emptyConstructor()
: accessToken = '',
refreshToken = '',
@ -24,14 +32,6 @@ class Token {
bool get isNotEmpty => accessToken.isNotEmpty && refreshToken.isNotEmpty;
Token(
this.accessToken,
this.refreshToken,
this.sessionId,
this.iat,
this.exp,
);
Token.refreshToken(this.refreshToken)
: accessToken = '',
sessionId = '',
@ -40,7 +40,7 @@ class Token {
factory Token.fromJson(Map<String, dynamic> json) {
//save token to secure storage
var storage = const FlutterSecureStorage();
const storage = FlutterSecureStorage();
storage.write(
key: loginAccessTokenKey, value: json[loginAccessTokenKey] ?? '');
storage.write(

View File

@ -55,22 +55,21 @@ class UserModel {
//from token
factory UserModel.fromToken(Token token) {
Map<String, dynamic> tempJson = Token.decodeToken(token.accessToken);
final tempJson = Token.decodeToken(token.accessToken);
return UserModel(
hasAcceptedWebAgreement: null,
role: null,
webAgreementAcceptedAt: null,
uuid: tempJson['uuid'].toString(),
email: tempJson['email'],
firstName: null,
lastName: null,
photoUrl: null,
phoneNumber: null,
isEmailVerified: null,
isAgreementAccepted: null,
project: null
);
hasAcceptedWebAgreement: null,
role: null,
webAgreementAcceptedAt: null,
uuid: tempJson['uuid'].toString(),
email: tempJson['email'],
firstName: null,
lastName: null,
photoUrl: null,
phoneNumber: null,
isEmailVerified: null,
isAgreementAccepted: null,
project: null);
}
Map<String, dynamic> toJson() {

View File

@ -36,20 +36,18 @@ class ForgetPasswordWebPage extends StatelessWidget {
);
}
},
builder: (context, state) {
return _buildForm(context, state);
},
builder: _buildForm,
),
),
);
}
Widget _buildForm(BuildContext context, AuthState state) {
late ScrollController _scrollController;
_scrollController = ScrollController();
void _scrollToCenter() {
final double middlePosition = _scrollController.position.maxScrollExtent / 2;
_scrollController.animateTo(
late ScrollController scrollController;
scrollController = ScrollController();
void scrollToCenter() {
final middlePosition = scrollController.position.maxScrollExtent / 2;
scrollController.animateTo(
middlePosition,
duration: const Duration(seconds: 1),
curve: Curves.easeInOut,
@ -57,24 +55,25 @@ class ForgetPasswordWebPage extends StatelessWidget {
}
WidgetsBinding.instance.addPostFrameCallback((_) {
_scrollToCenter();
scrollToCenter();
});
final forgetBloc = BlocProvider.of<AuthBloc>(context);
Size size = MediaQuery.of(context).size;
final size = MediaQuery.of(context).size;
return FirstLayer(
second: Center(
child: Stack(
children: [
if (state is AuthLoading) const Center(child: CircularProgressIndicator()),
if (state is AuthLoading)
const Center(child: CircularProgressIndicator()),
ListView(
shrinkWrap: true,
controller: _scrollController,
controller: scrollController,
children: [
Container(
padding: EdgeInsets.all(size.width * 0.02),
margin: EdgeInsets.all(size.width * 0.09),
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.3),
color: Colors.black.withValues(alpha: 0.3),
borderRadius: const BorderRadius.all(Radius.circular(20)),
),
child: Center(
@ -94,17 +93,22 @@ class ForgetPasswordWebPage extends StatelessWidget {
flex: 3,
child: Container(
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.1),
borderRadius: const BorderRadius.all(Radius.circular(30)),
border: Border.all(color: ColorsManager.graysColor.withOpacity(0.2)),
color: Colors.white.withValues(alpha: 0.1),
borderRadius:
const BorderRadius.all(Radius.circular(30)),
border: Border.all(
color: ColorsManager.graysColor
.withValues(alpha: 0.2)),
),
child: Form(
key: forgetBloc.forgetFormKey,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: size.width * 0.02, vertical: size.width * 0.003),
horizontal: size.width * 0.02,
vertical: size.width * 0.003),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const SizedBox(height: 10),
@ -121,7 +125,9 @@ class ForgetPasswordWebPage extends StatelessWidget {
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(fontSize: 14, fontWeight: FontWeight.w400),
.copyWith(
fontSize: 14,
fontWeight: FontWeight.w400),
),
const SizedBox(height: 10),
// Column(
@ -140,69 +146,90 @@ class ForgetPasswordWebPage extends StatelessWidget {
Form(
key: forgetBloc.forgetEmailKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text(
"Account",
style: Theme.of(context).textTheme.bodySmall!.copyWith(
fontSize: 14, fontWeight: FontWeight.w400),
'Account',
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(
fontSize: 14,
fontWeight:
FontWeight.w400),
),
const SizedBox(height: 10),
SizedBox(
child: TextFormField(
controller: forgetBloc.forgetEmailController,
validator: forgetBloc.validateEmail,
decoration: textBoxDecoration()!.copyWith(
controller: forgetBloc
.forgetEmailController,
validator:
forgetBloc.validateEmail,
decoration:
textBoxDecoration()!.copyWith(
hintText: 'Enter your email',
hintStyle: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(
color: ColorsManager.grayColor,
fontWeight: FontWeight.w400),
color: ColorsManager
.grayColor,
fontWeight:
FontWeight.w400),
),
style: const TextStyle(color: Colors.black),
style: const TextStyle(
color: Colors.black),
),
),
],
)),
const SizedBox(height: 20.0),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"One Time Password",
'One Time Password',
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(fontSize: 14, fontWeight: FontWeight.w400),
.copyWith(
fontSize: 14,
fontWeight: FontWeight.w400),
),
const SizedBox(height: 10),
SizedBox(
child: TextFormField(
validator: forgetBloc.validateCode,
keyboardType: TextInputType.visiblePassword,
keyboardType:
TextInputType.visiblePassword,
controller: forgetBloc.forgetOtp,
decoration: textBoxDecoration()!.copyWith(
decoration:
textBoxDecoration()!.copyWith(
hintText: 'Enter Code',
hintStyle: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(
color: ColorsManager.grayColor,
fontWeight: FontWeight.w400),
color:
ColorsManager.grayColor,
fontWeight:
FontWeight.w400),
suffixIcon: SizedBox(
width: 100,
child: Center(
child: InkWell(
onTap: state is TimerState &&
!state.isButtonEnabled &&
state.remainingTime != 1
!state
.isButtonEnabled &&
state.remainingTime !=
1
? null
:
() {
: () {
if (forgetBloc
.forgetEmailKey
.currentState!
@ -211,27 +238,31 @@ class ForgetPasswordWebPage extends StatelessWidget {
StartTimerEvent());
}
},
child: Text(
'Get Code ${state is TimerState && !state.isButtonEnabled && state.remainingTime != 1 ? "(${forgetBloc.formattedTime(state.remainingTime)}) " : ""}',
style: TextStyle(
color: state is TimerState &&
!state.isButtonEnabled
color: state
is TimerState &&
!state
.isButtonEnabled
? Colors.grey
: ColorsManager.btnColor,
: ColorsManager
.btnColor,
),
),
),
),
),
),
style: const TextStyle(color: Colors.black),
style: const TextStyle(
color: Colors.black),
),
),
if (forgetBloc.forgetValidate !=
'') // Check if there is a validation message
Padding(
padding: const EdgeInsets.only(top: 8.0),
padding:
const EdgeInsets.only(top: 8.0),
child: Text(
forgetBloc.forgetValidate,
style: const TextStyle(
@ -244,34 +275,44 @@ class ForgetPasswordWebPage extends StatelessWidget {
),
const SizedBox(height: 20.0),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Password",
'Password',
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(fontSize: 14, fontWeight: FontWeight.w400),
.copyWith(
fontSize: 14,
fontWeight: FontWeight.w400),
),
const SizedBox(height: 10),
SizedBox(
child: TextFormField(
obscureText: forgetBloc.obscureText,
keyboardType: TextInputType.visiblePassword,
validator: forgetBloc.passwordValidator,
controller: forgetBloc.forgetPasswordController,
decoration: textBoxDecoration()!.copyWith(
keyboardType:
TextInputType.visiblePassword,
validator:
forgetBloc.passwordValidator,
controller: forgetBloc
.forgetPasswordController,
decoration:
textBoxDecoration()!.copyWith(
suffixIcon: IconButton(
onPressed: () {
forgetBloc.add(PasswordVisibleEvent(
newValue: forgetBloc.obscureText));
forgetBloc.add(
PasswordVisibleEvent(
newValue: forgetBloc
.obscureText));
},
icon: SizedBox(
child: SvgPicture.asset(
forgetBloc.obscureText
? Assets.visiblePassword
: Assets.invisiblePassword,
: Assets
.invisiblePassword,
height: 15,
width: 15,
),
@ -282,10 +323,13 @@ class ForgetPasswordWebPage extends StatelessWidget {
.textTheme
.bodySmall!
.copyWith(
color: ColorsManager.grayColor,
fontWeight: FontWeight.w400),
color:
ColorsManager.grayColor,
fontWeight:
FontWeight.w400),
),
style: const TextStyle(color: Colors.black),
style: const TextStyle(
color: Colors.black),
),
),
],
@ -295,23 +339,31 @@ class ForgetPasswordWebPage extends StatelessWidget {
),
const SizedBox(height: 20.0),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: size.width * 0.2,
child: DefaultButton(
backgroundColor: ColorsManager.btnColor,
backgroundColor:
ColorsManager.btnColor,
child: const Text('Submit'),
onPressed: () {
if (forgetBloc.forgetFormKey.currentState!.validate() ||
forgetBloc.forgetEmailKey.currentState!
if (forgetBloc
.forgetFormKey.currentState!
.validate() ||
forgetBloc.forgetEmailKey
.currentState!
.validate()) {
if (forgetBloc.forgetEmailKey.currentState!
if (forgetBloc.forgetEmailKey
.currentState!
.validate() &&
forgetBloc.forgetFormKey.currentState!
forgetBloc.forgetFormKey
.currentState!
.validate()) {
forgetBloc.add(ChangePasswordEvent());
forgetBloc
.add(ChangePasswordEvent());
}
}
},
@ -325,7 +377,8 @@ class ForgetPasswordWebPage extends StatelessWidget {
child: Text(
forgetBloc.validate,
style: const TextStyle(
fontWeight: FontWeight.w700, color: ColorsManager.red),
fontWeight: FontWeight.w700,
color: ColorsManager.red),
),
),
),
@ -337,8 +390,9 @@ class ForgetPasswordWebPage extends StatelessWidget {
child: Wrap(
children: [
const Text(
"Do you have an account? ",
style: TextStyle(color: Colors.white),
'Do you have an account? ',
style:
TextStyle(color: Colors.white),
),
InkWell(
onTap: () {
@ -346,7 +400,7 @@ class ForgetPasswordWebPage extends StatelessWidget {
Navigator.pop(context);
},
child: const Text(
"Sign in",
'Sign in',
),
),
],
@ -372,14 +426,15 @@ class ForgetPasswordWebPage extends StatelessWidget {
));
}
Widget _buildDropdownField(BuildContext context, AuthBloc loginBloc, Size size) {
final TextEditingController textEditingController = TextEditingController();
Widget _buildDropdownField(
BuildContext context, AuthBloc loginBloc, Size size) {
final textEditingController = TextEditingController();
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Country/Region",
'Country/Region',
style: Theme.of(context).textTheme.bodySmall!.copyWith(
fontSize: 14,
fontWeight: FontWeight.w400,
@ -398,10 +453,13 @@ class ForgetPasswordWebPage extends StatelessWidget {
builder: (FormFieldState<String> field) {
return InputDecorator(
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(horizontal: 2, vertical: 10),
contentPadding:
const EdgeInsets.symmetric(horizontal: 2, vertical: 10),
errorText: field.errorText,
filled: true, // Ensure the dropdown is filled with the background color
fillColor: ColorsManager.boxColor, // Match the dropdown container color
filled:
true, // Ensure the dropdown is filled with the background color
fillColor: ColorsManager
.boxColor, // Match the dropdown container color
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8.0),
borderSide: BorderSide(
@ -412,14 +470,16 @@ class ForgetPasswordWebPage extends StatelessWidget {
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8.0),
borderSide: BorderSide(
color: field.hasError ? Colors.red : ColorsManager.grayColor,
color:
field.hasError ? Colors.red : ColorsManager.grayColor,
width: 1.5,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8.0),
borderSide: BorderSide(
color: field.hasError ? Colors.red : ColorsManager.grayColor,
color:
field.hasError ? Colors.red : ColorsManager.grayColor,
width: 1.5,
),
),
@ -446,10 +506,11 @@ class ForgetPasswordWebPage extends StatelessWidget {
return DropdownMenuItem<String>(
value: region.id,
child: Text(
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
fontSize: 14,
fontWeight: FontWeight.w400,
),
style:
Theme.of(context).textTheme.bodyMedium!.copyWith(
fontSize: 14,
fontWeight: FontWeight.w400,
),
region.name,
overflow: TextOverflow.ellipsis,
maxLines: 1,
@ -462,7 +523,8 @@ class ForgetPasswordWebPage extends StatelessWidget {
onChanged: (String? value) {
if (value != null) {
loginBloc.add(SelectRegionEvent(val: value));
field.didChange(value); // Notify the form field of the change
field.didChange(
value); // Notify the form field of the change
}
},
buttonStyleData: const ButtonStyleData(
@ -486,7 +548,8 @@ class ForgetPasswordWebPage extends StatelessWidget {
searchInnerWidgetHeight: 50,
searchInnerWidget: Container(
height: 50,
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
padding: const EdgeInsets.symmetric(
horizontal: 8, vertical: 4),
child: TextFormField(
style: const TextStyle(color: Colors.black),
controller: textEditingController,
@ -500,7 +563,8 @@ class ForgetPasswordWebPage extends StatelessWidget {
),
),
searchMatchFn: (item, searchValue) {
final regionName = (item.child as Text).data?.toLowerCase() ?? '';
final regionName =
(item.child as Text).data?.toLowerCase() ?? '';
final search = searchValue.toLowerCase().trim();
return regionName.contains(search);
},

View File

@ -79,7 +79,7 @@ class LoginMobilePage extends StatelessWidget {
child: Container(
margin: const EdgeInsets.all(50),
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.3),
color: Colors.black.withValues(alpha: 0.3),
borderRadius: const BorderRadius.all(Radius.circular(20))),
child: Column(
mainAxisSize: MainAxisSize.min,
@ -93,12 +93,15 @@ class LoginMobilePage extends StatelessWidget {
),
),
Container(
margin: EdgeInsets.all(30),
padding: EdgeInsets.all(20),
margin: const EdgeInsets.all(30),
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.1),
borderRadius: const BorderRadius.all(Radius.circular(30)),
border: Border.all(color: ColorsManager.graysColor.withOpacity(0.2))),
color: Colors.white.withValues(alpha: 0.1),
borderRadius:
const BorderRadius.all(Radius.circular(30)),
border: Border.all(
color: ColorsManager.graysColor
.withValues(alpha: 0.2))),
child: Form(
key: loginBloc.loginFormKey,
child: Column(
@ -109,7 +112,9 @@ class LoginMobilePage extends StatelessWidget {
const Text(
'Login',
style: TextStyle(
color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold),
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold),
),
const SizedBox(height: 30),
// Column(
@ -155,15 +160,15 @@ class LoginMobilePage extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Email",
'Email',
style: Theme.of(context).textTheme.bodySmall,
),
SizedBox(
child: TextFormField(
validator: loginBloc.validateEmail,
controller: loginBloc.loginEmailController,
decoration:
textBoxDecoration()!.copyWith(hintText: 'Enter your email'),
decoration: textBoxDecoration()!
.copyWith(hintText: 'Enter your email'),
style: const TextStyle(color: Colors.black),
),
),
@ -175,7 +180,7 @@ class LoginMobilePage extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Password",
'Password',
style: Theme.of(context).textTheme.bodySmall,
),
SizedBox(
@ -183,7 +188,8 @@ class LoginMobilePage extends StatelessWidget {
validator: loginBloc.validatePassword,
obscureText: loginBloc.obscureText,
keyboardType: TextInputType.visiblePassword,
controller: loginBloc.loginPasswordController,
controller:
loginBloc.loginPasswordController,
decoration: textBoxDecoration()!.copyWith(
hintText: 'At least 8 characters',
),
@ -201,16 +207,19 @@ class LoginMobilePage extends StatelessWidget {
children: [
InkWell(
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => const ForgetPasswordPage(),
Navigator.of(context)
.push(MaterialPageRoute(
builder: (context) =>
const ForgetPasswordPage(),
));
},
child: Text(
"Forgot Password?",
'Forgot Password?',
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(color: ColorsManager.blackColor),
.copyWith(
color: ColorsManager.blackColor),
),
),
],
@ -221,13 +230,15 @@ class LoginMobilePage extends StatelessWidget {
Transform.scale(
scale: 1.2, // Adjust the scale as needed
child: Checkbox(
fillColor: MaterialStateProperty.all<Color>(Colors.white),
fillColor: WidgetStateProperty.all<Color>(
Colors.white),
activeColor: Colors.white,
value: loginBloc.isChecked,
checkColor: Colors.black,
shape: const CircleBorder(),
onChanged: (bool? newValue) {
loginBloc.add(CheckBoxEvent(newValue: newValue));
loginBloc.add(
CheckBoxEvent(newValue: newValue));
},
),
),
@ -236,30 +247,37 @@ class LoginMobilePage extends StatelessWidget {
child: RichText(
text: TextSpan(
text: 'Agree to ',
style: const TextStyle(color: Colors.white),
style:
const TextStyle(color: Colors.white),
children: [
TextSpan(
text: '(Terms of Service)',
style: const TextStyle(color: Colors.black),
style: const TextStyle(
color: Colors.black),
recognizer: TapGestureRecognizer()
..onTap = () {
loginBloc.launchURL('https://example.com/terms');
loginBloc.launchURL(
'https://example.com/terms');
},
),
TextSpan(
text: ' (Legal Statement)',
style: const TextStyle(color: Colors.black),
style: const TextStyle(
color: Colors.black),
recognizer: TapGestureRecognizer()
..onTap = () {
loginBloc.launchURL('https://example.com/legal');
loginBloc.launchURL(
'https://example.com/legal');
},
),
TextSpan(
text: ' (Privacy Statement)',
style: const TextStyle(color: Colors.black),
style: const TextStyle(
color: Colors.black),
recognizer: TapGestureRecognizer()
..onTap = () {
loginBloc.launchURL('https://example.com/privacy');
loginBloc.launchURL(
'https://example.com/privacy');
},
),
],
@ -276,11 +294,14 @@ class LoginMobilePage extends StatelessWidget {
: ColorsManager.grayColor,
child: const Text('Sign in'),
onPressed: () {
if (loginBloc.loginFormKey.currentState!.validate()) {
if (loginBloc.loginFormKey.currentState!
.validate()) {
loginBloc.add(
LoginButtonPressed(
username: loginBloc.loginEmailController.text,
password: loginBloc.loginPasswordController.text,
username:
loginBloc.loginEmailController.text,
password: loginBloc
.loginPasswordController.text,
),
);
}
@ -295,10 +316,11 @@ class LoginMobilePage extends StatelessWidget {
Flexible(
child: Text(
"Don't you have an account? ",
style: TextStyle(color: Colors.white, fontSize: 13),
style: TextStyle(
color: Colors.white, fontSize: 13),
)),
Text(
"Sign up",
'Sign up',
),
],
),

View File

@ -24,7 +24,8 @@ class LoginWebPage extends StatefulWidget {
State<LoginWebPage> createState() => _LoginWebPageState();
}
class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout {
class _LoginWebPageState extends State<LoginWebPage>
with HelperResponsiveLayout {
@override
Widget build(BuildContext context) {
return Scaffold(
@ -42,9 +43,7 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
);
}
},
builder: (context, state) {
return _buildLoginForm(context, state);
},
builder: _buildLoginForm,
),
),
);
@ -54,12 +53,12 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
final loginBloc = BlocProvider.of<AuthBloc>(context);
final isSmallScreen = isSmallScreenSize(context);
final isMediumScreen = isMediumScreenSize(context);
Size size = MediaQuery.of(context).size;
final size = MediaQuery.of(context).size;
late ScrollController scrollController;
scrollController = ScrollController();
void scrollToCenter() {
final double middlePosition = scrollController.position.maxScrollExtent / 2;
final middlePosition = scrollController.position.maxScrollExtent / 2;
scrollController.animateTo(
middlePosition,
duration: const Duration(seconds: 1),
@ -84,7 +83,7 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
padding: EdgeInsets.all(size.width * 0.02),
margin: EdgeInsets.all(size.width * 0.05),
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.3),
color: Colors.black.withValues(alpha: 0.3),
borderRadius: const BorderRadius.all(Radius.circular(20)),
),
child: Center(
@ -121,7 +120,8 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
const Spacer(),
Expanded(
flex: 2,
child: _buildLoginFormFields(context, loginBloc, size),
child: _buildLoginFormFields(
context, loginBloc, size),
),
const Spacer(),
],
@ -132,23 +132,26 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
),
),
),
if (state is AuthLoading) const Center(child: CircularProgressIndicator())
if (state is AuthLoading)
const Center(child: CircularProgressIndicator())
],
);
}
Widget _buildLoginFormFields(BuildContext context, AuthBloc loginBloc, Size size) {
Widget _buildLoginFormFields(
BuildContext context, AuthBloc loginBloc, Size size) {
return Container(
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.1),
color: Colors.white.withValues(alpha: 0.1),
borderRadius: const BorderRadius.all(Radius.circular(30)),
border: Border.all(color: ColorsManager.graysColor.withOpacity(0.2)),
border:
Border.all(color: ColorsManager.graysColor.withValues(alpha: 0.2)),
),
child: Form(
key: loginBloc.loginFormKey,
child: Padding(
padding:
EdgeInsets.symmetric(horizontal: size.width * 0.02, vertical: size.width * 0.003),
padding: EdgeInsets.symmetric(
horizontal: size.width * 0.02, vertical: size.width * 0.003),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
@ -176,14 +179,15 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
);
}
Widget _buildDropdownField(BuildContext context, AuthBloc loginBloc, Size size) {
final TextEditingController textEditingController = TextEditingController();
Widget _buildDropdownField(
BuildContext context, AuthBloc loginBloc, Size size) {
final textEditingController = TextEditingController();
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Country/Region",
'Country/Region',
style: Theme.of(context).textTheme.bodySmall!.copyWith(
fontSize: 14,
fontWeight: FontWeight.w400,
@ -246,7 +250,8 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
searchInnerWidgetHeight: 50,
searchInnerWidget: Container(
height: 50,
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
padding:
const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
child: TextFormField(
style: const TextStyle(color: Colors.black),
controller: textEditingController,
@ -261,7 +266,8 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
),
searchMatchFn: (item, searchValue) {
// Use the item's child text (region name) for searching.
final regionName = (item.child as Text).data?.toLowerCase() ?? '';
final regionName =
(item.child as Text).data?.toLowerCase() ?? '';
final search = searchValue.toLowerCase().trim();
// Debugging print statement to ensure values are captured correctly.
// Return true if the region name contains the search term.
@ -286,7 +292,7 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Email",
'Email',
style: Theme.of(context)
.textTheme
.bodySmall!
@ -303,10 +309,9 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
decoration: textBoxDecoration()!.copyWith(
errorStyle: const TextStyle(height: 0),
hintText: 'Enter your email address',
hintStyle: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(color: ColorsManager.grayColor, fontWeight: FontWeight.w400)),
hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith(
color: ColorsManager.grayColor,
fontWeight: FontWeight.w400)),
style: const TextStyle(color: Colors.black),
),
),
@ -320,7 +325,7 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Password",
'Password',
style: Theme.of(context)
.textTheme
.bodySmall!
@ -338,7 +343,7 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
controller: loginBloc.loginPasswordController,
onFieldSubmitted: (value) {
if (loginBloc.loginFormKey.currentState!.validate()) {
loginBloc.add(LoginButtonPressed(
loginBloc.add(LoginButtonPressed(
username: loginBloc.loginEmailController.text,
password: value,
));
@ -348,17 +353,18 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
},
decoration: textBoxDecoration()!.copyWith(
hintText: 'At least 8 characters',
hintStyle: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(color: ColorsManager.grayColor, fontWeight: FontWeight.w400),
hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith(
color: ColorsManager.grayColor, fontWeight: FontWeight.w400),
suffixIcon: IconButton(
onPressed: () {
loginBloc.add(PasswordVisibleEvent(newValue: loginBloc.obscureText));
loginBloc.add(
PasswordVisibleEvent(newValue: loginBloc.obscureText));
},
icon: SizedBox(
child: SvgPicture.asset(
loginBloc.obscureText ? Assets.visiblePassword : Assets.invisiblePassword,
loginBloc.obscureText
? Assets.visiblePassword
: Assets.invisiblePassword,
height: 15,
width: 15,
),
@ -385,11 +391,11 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
));
},
child: Text(
"Forgot Password?",
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(color: Colors.black, fontSize: 14, fontWeight: FontWeight.w400),
'Forgot Password?',
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.w400),
),
),
],
@ -453,7 +459,8 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
);
}
Widget _buildSignInButton(BuildContext context, AuthBloc loginBloc, Size size) {
Widget _buildSignInButton(
BuildContext context, AuthBloc loginBloc, Size size) {
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
@ -467,7 +474,7 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
fontSize: 14,
color: loginBloc.checkValidate
? ColorsManager.whiteColors
: ColorsManager.whiteColors.withOpacity(0.2),
: ColorsManager.whiteColors.withValues(alpha: 0.2),
)),
onPressed: () {
if (loginBloc.loginFormKey.currentState!.validate()) {
@ -494,7 +501,8 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
SizedBox(
child: Text(
loginBloc.validate,
style: const TextStyle(fontWeight: FontWeight.w700, color: ColorsManager.red),
style: const TextStyle(
fontWeight: FontWeight.w700, color: ColorsManager.red),
),
)
],

View File

@ -108,66 +108,64 @@ class _DynamicTableState extends State<AccessDeviceTable> {
child: Row(
children: [
if (widget.withCheckBox) _buildSelectAllCheckbox(),
...widget.headers
.map((header) => _buildTableHeaderCell(header)),
...widget.headers.map(_buildTableHeaderCell),
],
),
),
widget.isEmpty
? Expanded(
child: Column(
if (widget.isEmpty)
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
Column(
children: [
Column(
children: [
SvgPicture.asset(Assets.emptyTable),
const SizedBox(
height: 15,
),
Text(
// no password
widget.tableName == 'AccessManagement'
? 'No Password '
: 'No Devices',
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(
color: ColorsManager.grayColor),
)
],
SvgPicture.asset(Assets.emptyTable),
const SizedBox(
height: 15,
),
Text(
// no password
widget.tableName == 'AccessManagement'
? 'No Password '
: 'No Devices',
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(color: ColorsManager.grayColor),
)
],
),
],
),
)
: Expanded(
child: Container(
color: Colors.white,
child: ListView.builder(
shrinkWrap: true,
itemCount: widget.data.length,
itemBuilder: (context, index) {
final row = widget.data[index];
return Row(
children: [
if (widget.withCheckBox)
_buildRowCheckbox(
index, widget.size.height * 0.10),
...row.map((cell) => _buildTableCell(
cell.toString(),
widget.size.height * 0.10)),
],
);
},
),
),
],
),
)
else
Expanded(
child: ColoredBox(
color: Colors.white,
child: ListView.builder(
shrinkWrap: true,
itemCount: widget.data.length,
itemBuilder: (context, index) {
final row = widget.data[index];
return Row(
children: [
if (widget.withCheckBox)
_buildRowCheckbox(
index, widget.size.height * 0.10),
...row.map((cell) => _buildTableCell(
cell.toString(), widget.size.height * 0.10)),
],
);
},
),
),
),
],
),
),
@ -245,7 +243,7 @@ class _DynamicTableState extends State<AccessDeviceTable> {
}
Widget _buildTableCell(String content, double size) {
bool isBatteryLevel = content.endsWith('%');
final isBatteryLevel = content.endsWith('%');
double? batteryLevel;
if (isBatteryLevel) {

View File

@ -22,17 +22,21 @@ class CancelButton extends StatelessWidget {
return ElevatedButton(
onPressed: onPressed,
style: ButtonStyle(
backgroundColor: WidgetStateProperty.all(ColorsManager.boxColor), // White background
foregroundColor: WidgetStateProperty.all(Colors.black), // Black text color
backgroundColor:
WidgetStateProperty.all(ColorsManager.boxColor), // White background
foregroundColor:
WidgetStateProperty.all(Colors.black), // Black text color
shape: WidgetStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(borderRadius ?? 10),
side: const BorderSide(color: ColorsManager.boxColor), // Black border
side:
const BorderSide(color: ColorsManager.boxColor), // Black border
),
),
fixedSize: WidgetStateProperty.all(Size(width ?? 50, height ?? 40)), // Set button height
fixedSize: WidgetStateProperty.all(
Size(width ?? 50, height ?? 40)), // Set button height
),
child: Text(label), // Dynamic label
);
}
}
}

View File

@ -64,7 +64,7 @@ class DefaultButton extends StatelessWidget {
(Set<WidgetState> states) {
return enabled
? backgroundColor ?? ColorsManager.primaryColor
: Colors.black.withOpacity(0.2);
: Colors.black.withValues(alpha: 0.2);
}),
shape: WidgetStateProperty.all(
RoundedRectangleBorder(

View File

@ -34,7 +34,7 @@ class CurtainToggle extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipOval(
child: Container(
child: ColoredBox(
color: ColorsManager.whiteColors,
child: SvgPicture.asset(
Assets.curtainIcon,
@ -52,7 +52,7 @@ class CurtainToggle extends StatelessWidget {
width: 35,
child: CupertinoSwitch(
value: value,
activeColor: ColorsManager.dialogBlueTitle,
activeTrackColor: ColorsManager.dialogBlueTitle,
onChanged: onChanged,
),
),

View File

@ -12,7 +12,7 @@ Future<void> showCustomDialog({
double? iconWidth,
VoidCallback? onOkPressed,
bool barrierDismissible = false,
List<Widget>? actions,
List<Widget>? actions,
}) {
return showDialog(
context: context,
@ -40,14 +40,20 @@ Future<void> showCustomDialog({
style: Theme.of(context)
.textTheme
.headlineLarge!
.copyWith(fontSize: 20, fontWeight: FontWeight.w400, color: Colors.black),
.copyWith(
fontSize: 20,
fontWeight: FontWeight.w400,
color: Colors.black),
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(
message,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.black),
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(color: Colors.black),
textAlign: TextAlign.center,
),
),

View File

@ -20,8 +20,8 @@ class DynamicTable extends StatefulWidget {
final void Function(int, bool, dynamic)? onRowSelected;
final List<String>? initialSelectedIds;
final int uuidIndex;
final Function(dynamic selectedRows)? onSelectionChanged;
final Function(int rowIndex)? onSettingsPressed;
final void Function(dynamic selectedRows)? onSelectionChanged;
final void Function(int rowIndex)? onSettingsPressed;
const DynamicTable({
super.key,
required this.headers,
@ -79,10 +79,10 @@ class _DynamicTableState extends State<DynamicTable> {
// Check if the old and new lists are the same
if (oldList.length != newList.length) return false;
for (int i = 0; i < oldList.length; i++) {
for (var i = 0; i < oldList.length; i++) {
if (oldList[i].length != newList[i].length) return false;
for (int j = 0; j < oldList[i].length; j++) {
for (var j = 0; j < oldList[i].length; j++) {
if (oldList[i][j] != newList[i][j]) return false;
}
}
@ -162,7 +162,7 @@ class _DynamicTableState extends State<DynamicTable> {
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
controller: _horizontalBodyScrollController,
child: Container(
child: ColoredBox(
color: ColorsManager.whiteColors,
child: SizedBox(
width: widget.size.width,
@ -184,7 +184,7 @@ class _DynamicTableState extends State<DynamicTable> {
rowIndex: rowIndex,
columnIndex: entry.key,
);
}).toList(),
}),
],
);
}),
@ -304,13 +304,13 @@ class _DynamicTableState extends State<DynamicTable> {
required int rowIndex,
required int columnIndex,
}) {
bool isBatteryLevel = content.endsWith('%');
final isBatteryLevel = content.endsWith('%');
double? batteryLevel;
if (isBatteryLevel) {
batteryLevel = double.tryParse(content.replaceAll('%', '').trim());
}
bool isSettingsColumn = widget.headers[columnIndex] == 'Settings';
final isSettingsColumn = widget.headers[columnIndex] == 'Settings';
if (isSettingsColumn) {
return buildSettingsIcon(
@ -404,7 +404,7 @@ class _DynamicTableState extends State<DynamicTable> {
borderRadius: BorderRadius.circular(height / 2),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.17),
color: Colors.black.withValues(alpha: 0.17),
blurRadius: 14,
offset: const Offset(0, 4),
),
@ -416,11 +416,10 @@ class _DynamicTableState extends State<DynamicTable> {
padding: const EdgeInsets.all(8.0),
child: Center(
child: SvgPicture.asset(
Assets.settings, // ضع المسار الصحيح هنا
Assets.settings,
width: 40,
height: 22,
color: ColorsManager
.primaryColor, // نفس لون الأيقونة في الصورة
color: ColorsManager.primaryColor,
),
),
),

View File

@ -36,7 +36,7 @@ class FilterWidget extends StatelessWidget {
color: ColorsManager.boxColor,
border: Border.all(
color: isSelected
? ColorsManager.blueColor.withOpacity(0.8)
? ColorsManager.blueColor.withValues(alpha: 0.8)
: Colors.transparent,
width: 2.0,
),
@ -48,7 +48,7 @@ class FilterWidget extends StatelessWidget {
tabs[index],
style: TextStyle(
color: isSelected
? ColorsManager.blueColor.withOpacity(0.8)
? ColorsManager.blueColor.withValues(alpha: 0.8)
: Colors.black,
),
),

Some files were not shown because too many files have changed in this diff Show More