mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 14:47:23 +00:00
formatted all files.
This commit is contained in:
@ -25,3 +25,8 @@ linter:
|
|||||||
prefer_int_literals: false
|
prefer_int_literals: false
|
||||||
sort_constructors_first: false
|
sort_constructors_first: false
|
||||||
avoid_redundant_argument_values: 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
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
class DialogDropdown extends StatefulWidget {
|
class DialogDropdown extends StatefulWidget {
|
||||||
final List<String> items;
|
final List<String> items;
|
||||||
@ -7,14 +8,14 @@ class DialogDropdown extends StatefulWidget {
|
|||||||
final String? selectedValue;
|
final String? selectedValue;
|
||||||
|
|
||||||
const DialogDropdown({
|
const DialogDropdown({
|
||||||
Key? key,
|
super.key,
|
||||||
required this.items,
|
required this.items,
|
||||||
required this.onSelected,
|
required this.onSelected,
|
||||||
this.selectedValue,
|
this.selectedValue,
|
||||||
}) : super(key: key);
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_DialogDropdownState createState() => _DialogDropdownState();
|
State<DialogDropdown> createState() => _DialogDropdownState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DialogDropdownState extends State<DialogDropdown> {
|
class _DialogDropdownState extends State<DialogDropdown> {
|
||||||
@ -46,16 +47,14 @@ class _DialogDropdownState extends State<DialogDropdown> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OverlayEntry _createOverlayEntry() {
|
OverlayEntry _createOverlayEntry() {
|
||||||
final renderBox = context.findRenderObject() as RenderBox;
|
final renderBox = context.findRenderObject()! as RenderBox;
|
||||||
final size = renderBox.size;
|
final size = renderBox.size;
|
||||||
final offset = renderBox.localToGlobal(Offset.zero);
|
final offset = renderBox.localToGlobal(Offset.zero);
|
||||||
|
|
||||||
return OverlayEntry(
|
return OverlayEntry(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: _closeDropdown,
|
||||||
_closeDropdown();
|
|
||||||
},
|
|
||||||
behavior: HitTestBehavior.translucent,
|
behavior: HitTestBehavior.translucent,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
@ -87,12 +86,9 @@ class _DialogDropdownState extends State<DialogDropdown> {
|
|||||||
child: ListTile(
|
child: ListTile(
|
||||||
title: Text(
|
title: Text(
|
||||||
item,
|
item,
|
||||||
style: Theme.of(context)
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
.textTheme
|
color: ColorsManager.textPrimaryColor,
|
||||||
.bodyMedium
|
),
|
||||||
?.copyWith(
|
|
||||||
color: ColorsManager.textPrimaryColor,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
widget.onSelected(item);
|
widget.onSelected(item);
|
||||||
|
@ -10,24 +10,25 @@ class EditChip extends StatelessWidget {
|
|||||||
final double borderRadius;
|
final double borderRadius;
|
||||||
|
|
||||||
const EditChip({
|
const EditChip({
|
||||||
Key? key,
|
super.key,
|
||||||
this.label = 'Edit',
|
this.label = 'Edit',
|
||||||
required this.onTap,
|
required this.onTap,
|
||||||
this.labelColor = ColorsManager.spaceColor,
|
this.labelColor = ColorsManager.spaceColor,
|
||||||
this.backgroundColor = ColorsManager.whiteColors,
|
this.backgroundColor = ColorsManager.whiteColors,
|
||||||
this.borderColor = ColorsManager.spaceColor,
|
this.borderColor = ColorsManager.spaceColor,
|
||||||
this.borderRadius = 16.0,
|
this.borderRadius = 16.0,
|
||||||
}) : super(key: key);
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
child: Chip(
|
child: Chip(
|
||||||
label: Text(
|
label: Text(label,
|
||||||
label,
|
style: Theme.of(context)
|
||||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(color: labelColor)
|
.textTheme
|
||||||
),
|
.bodySmall!
|
||||||
|
.copyWith(color: labelColor)),
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(borderRadius),
|
borderRadius: BorderRadius.circular(borderRadius),
|
||||||
|
@ -9,12 +9,12 @@ class TagDialogTextfieldDropdown extends StatefulWidget {
|
|||||||
final String product;
|
final String product;
|
||||||
|
|
||||||
const TagDialogTextfieldDropdown({
|
const TagDialogTextfieldDropdown({
|
||||||
Key? key,
|
super.key,
|
||||||
required this.items,
|
required this.items,
|
||||||
required this.onSelected,
|
required this.onSelected,
|
||||||
this.initialValue,
|
this.initialValue,
|
||||||
required this.product,
|
required this.product,
|
||||||
}) : super(key: key);
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_DialogTextfieldDropdownState createState() =>
|
_DialogTextfieldDropdownState createState() =>
|
||||||
@ -79,7 +79,7 @@ class _DialogTextfieldDropdownState extends State<TagDialogTextfieldDropdown> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OverlayEntry _createOverlayEntry() {
|
OverlayEntry _createOverlayEntry() {
|
||||||
final renderBox = context.findRenderObject() as RenderBox;
|
final renderBox = context.findRenderObject()! as RenderBox;
|
||||||
final size = renderBox.size;
|
final size = renderBox.size;
|
||||||
final offset = renderBox.localToGlobal(Offset.zero);
|
final offset = renderBox.localToGlobal(Offset.zero);
|
||||||
|
|
||||||
|
@ -10,7 +10,8 @@ class CustomExpansionTile extends StatefulWidget {
|
|||||||
final ValueChanged<bool>? onExpansionChanged; // Notify when expansion changes
|
final ValueChanged<bool>? onExpansionChanged; // Notify when expansion changes
|
||||||
final VoidCallback? onItemSelected; // Callback for selecting the item
|
final VoidCallback? onItemSelected; // Callback for selecting the item
|
||||||
|
|
||||||
CustomExpansionTile({
|
const CustomExpansionTile({
|
||||||
|
super.key,
|
||||||
required this.title,
|
required this.title,
|
||||||
this.children,
|
this.children,
|
||||||
this.initiallyExpanded = false,
|
this.initiallyExpanded = false,
|
||||||
|
@ -7,7 +7,7 @@ class CustomSearchBar extends StatefulWidget {
|
|||||||
final TextEditingController? controller;
|
final TextEditingController? controller;
|
||||||
final String hintText;
|
final String hintText;
|
||||||
final String? searchQuery;
|
final String? searchQuery;
|
||||||
final Function(String)? onSearchChanged; // Callback for search input changes
|
final void Function(String)? onSearchChanged;
|
||||||
|
|
||||||
const CustomSearchBar({
|
const CustomSearchBar({
|
||||||
super.key,
|
super.key,
|
||||||
@ -37,7 +37,7 @@ class _CustomSearchBarState extends State<CustomSearchBar> {
|
|||||||
color: ColorsManager.whiteColors,
|
color: ColorsManager.whiteColors,
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: Colors.black.withOpacity(0.2),
|
color: Colors.black.withValues(alpha: 0.2),
|
||||||
spreadRadius: 0,
|
spreadRadius: 0,
|
||||||
blurRadius: 8,
|
blurRadius: 8,
|
||||||
offset: const Offset(0, 4),
|
offset: const Offset(0, 4),
|
||||||
@ -57,7 +57,7 @@ class _CustomSearchBarState extends State<CustomSearchBar> {
|
|||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
),
|
),
|
||||||
onChanged: widget.onSearchChanged, // Call the callback on text change
|
onChanged: widget.onSearchChanged,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: ColorsManager.textFieldGreyColor,
|
fillColor: ColorsManager.textFieldGreyColor,
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
// File generated by FlutterFire CLI.
|
// File generated by FlutterFire CLI.
|
||||||
// ignore_for_file: type=lint
|
// ignore_for_file: type=lint
|
||||||
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
|
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.
|
/// Default [FirebaseOptions] for use with your Firebase apps.
|
||||||
///
|
///
|
||||||
|
@ -40,7 +40,7 @@ class MyApp extends StatelessWidget {
|
|||||||
initialLocation: RoutesConst.auth,
|
initialLocation: RoutesConst.auth,
|
||||||
routes: AppRoutes.getRoutes(),
|
routes: AppRoutes.getRoutes(),
|
||||||
redirect: (context, state) async {
|
redirect: (context, state) async {
|
||||||
String checkToken = await AuthBloc.getTokenAndValidate();
|
final checkToken = await AuthBloc.getTokenAndValidate();
|
||||||
final loggedIn = checkToken == 'Success';
|
final loggedIn = checkToken == 'Success';
|
||||||
final goingToLogin = state.uri.toString() == RoutesConst.auth;
|
final goingToLogin = state.uri.toString() == RoutesConst.auth;
|
||||||
|
|
||||||
|
@ -21,7 +21,8 @@ import 'package:syncrow_web/utils/theme/theme.dart';
|
|||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
try {
|
try {
|
||||||
const environment = String.fromEnvironment('FLAVOR', defaultValue: 'development');
|
const environment =
|
||||||
|
String.fromEnvironment('FLAVOR', defaultValue: 'development');
|
||||||
await dotenv.load(fileName: '.env.$environment');
|
await dotenv.load(fileName: '.env.$environment');
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await Firebase.initializeApp(
|
await Firebase.initializeApp(
|
||||||
@ -39,7 +40,7 @@ class MyApp extends StatelessWidget {
|
|||||||
initialLocation: RoutesConst.auth,
|
initialLocation: RoutesConst.auth,
|
||||||
routes: AppRoutes.getRoutes(),
|
routes: AppRoutes.getRoutes(),
|
||||||
redirect: (context, state) async {
|
redirect: (context, state) async {
|
||||||
String checkToken = await AuthBloc.getTokenAndValidate();
|
final checkToken = await AuthBloc.getTokenAndValidate();
|
||||||
final loggedIn = checkToken == 'Success';
|
final loggedIn = checkToken == 'Success';
|
||||||
final goingToLogin = state.uri.toString() == RoutesConst.auth;
|
final goingToLogin = state.uri.toString() == RoutesConst.auth;
|
||||||
|
|
||||||
@ -57,7 +58,8 @@ class MyApp extends StatelessWidget {
|
|||||||
BlocProvider<CreateRoutineBloc>(
|
BlocProvider<CreateRoutineBloc>(
|
||||||
create: (context) => CreateRoutineBloc(),
|
create: (context) => CreateRoutineBloc(),
|
||||||
),
|
),
|
||||||
BlocProvider(create: (context) => HomeBloc()..add(const FetchUserInfo())),
|
BlocProvider(
|
||||||
|
create: (context) => HomeBloc()..add(const FetchUserInfo())),
|
||||||
BlocProvider<VisitorPasswordBloc>(
|
BlocProvider<VisitorPasswordBloc>(
|
||||||
create: (context) => VisitorPasswordBloc(),
|
create: (context) => VisitorPasswordBloc(),
|
||||||
),
|
),
|
||||||
|
@ -21,7 +21,8 @@ import 'package:syncrow_web/utils/theme/theme.dart';
|
|||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
try {
|
try {
|
||||||
const environment = String.fromEnvironment('FLAVOR', defaultValue: 'staging');
|
const environment =
|
||||||
|
String.fromEnvironment('FLAVOR', defaultValue: 'staging');
|
||||||
await dotenv.load(fileName: '.env.$environment');
|
await dotenv.load(fileName: '.env.$environment');
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await Firebase.initializeApp(
|
await Firebase.initializeApp(
|
||||||
@ -39,7 +40,7 @@ class MyApp extends StatelessWidget {
|
|||||||
initialLocation: RoutesConst.auth,
|
initialLocation: RoutesConst.auth,
|
||||||
routes: AppRoutes.getRoutes(),
|
routes: AppRoutes.getRoutes(),
|
||||||
redirect: (context, state) async {
|
redirect: (context, state) async {
|
||||||
String checkToken = await AuthBloc.getTokenAndValidate();
|
final checkToken = await AuthBloc.getTokenAndValidate();
|
||||||
final loggedIn = checkToken == 'Success';
|
final loggedIn = checkToken == 'Success';
|
||||||
final goingToLogin = state.uri.toString() == RoutesConst.auth;
|
final goingToLogin = state.uri.toString() == RoutesConst.auth;
|
||||||
|
|
||||||
@ -57,7 +58,8 @@ class MyApp extends StatelessWidget {
|
|||||||
BlocProvider<CreateRoutineBloc>(
|
BlocProvider<CreateRoutineBloc>(
|
||||||
create: (context) => CreateRoutineBloc(),
|
create: (context) => CreateRoutineBloc(),
|
||||||
),
|
),
|
||||||
BlocProvider(create: (context) => HomeBloc()..add(const FetchUserInfo())),
|
BlocProvider(
|
||||||
|
create: (context) => HomeBloc()..add(const FetchUserInfo())),
|
||||||
BlocProvider<VisitorPasswordBloc>(
|
BlocProvider<VisitorPasswordBloc>(
|
||||||
create: (context) => VisitorPasswordBloc(),
|
create: (context) => VisitorPasswordBloc(),
|
||||||
),
|
),
|
||||||
|
@ -11,7 +11,7 @@ import 'package:syncrow_web/utils/constants/app_enum.dart';
|
|||||||
import 'package:syncrow_web/utils/snack_bar.dart';
|
import 'package:syncrow_web/utils/snack_bar.dart';
|
||||||
|
|
||||||
class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||||
AccessBloc() : super((AccessInitial())) {
|
AccessBloc() : super(AccessInitial()) {
|
||||||
on<FetchTableData>(_onFetchTableData);
|
on<FetchTableData>(_onFetchTableData);
|
||||||
on<SelectTime>(selectTime);
|
on<SelectTime>(selectTime);
|
||||||
on<FilterDataEvent>(_filterData);
|
on<FilterDataEvent>(_filterData);
|
||||||
@ -43,12 +43,12 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateTabsCount() {
|
void updateTabsCount() {
|
||||||
int toBeEffectiveCount = data
|
final toBeEffectiveCount = data
|
||||||
.where((item) => item.passwordStatus.value == 'To be effective')
|
.where((item) => item.passwordStatus.value == 'To be effective')
|
||||||
.length;
|
.length;
|
||||||
int effectiveCount =
|
final effectiveCount =
|
||||||
data.where((item) => item.passwordStatus.value == 'Effective').length;
|
data.where((item) => item.passwordStatus.value == 'Effective').length;
|
||||||
int expiredCount =
|
final expiredCount =
|
||||||
data.where((item) => item.passwordStatus.value == 'Expired').length;
|
data.where((item) => item.passwordStatus.value == 'Expired').length;
|
||||||
tabs[1] = 'To Be Effective ($toBeEffectiveCount)';
|
tabs[1] = 'To Be Effective ($toBeEffectiveCount)';
|
||||||
tabs[2] = 'Effective ($effectiveCount)';
|
tabs[2] = 'Effective ($effectiveCount)';
|
||||||
@ -81,7 +81,7 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
|||||||
Emitter<AccessState> emit,
|
Emitter<AccessState> emit,
|
||||||
) async {
|
) async {
|
||||||
emit(AccessLoaded());
|
emit(AccessLoaded());
|
||||||
final DateTime? picked = await showDatePicker(
|
final picked = await showDatePicker(
|
||||||
context: event.context,
|
context: event.context,
|
||||||
initialDate: DateTime.now(),
|
initialDate: DateTime.now(),
|
||||||
firstDate: DateTime.now().add(const Duration(days: -5095)),
|
firstDate: DateTime.now().add(const Duration(days: -5095)),
|
||||||
@ -89,7 +89,7 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
|||||||
builder: (BuildContext context, Widget? child) {
|
builder: (BuildContext context, Widget? child) {
|
||||||
return Theme(
|
return Theme(
|
||||||
data: ThemeData.light().copyWith(
|
data: ThemeData.light().copyWith(
|
||||||
colorScheme: ColorScheme.light(
|
colorScheme: const ColorScheme.light(
|
||||||
primary: ColorsManager.blackColor,
|
primary: ColorsManager.blackColor,
|
||||||
onPrimary: Colors.white,
|
onPrimary: Colors.white,
|
||||||
onSurface: ColorsManager.grayColor,
|
onSurface: ColorsManager.grayColor,
|
||||||
@ -105,20 +105,20 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (picked != null) {
|
if (picked != null) {
|
||||||
final TimeOfDay? timePicked = await showHourPicker(
|
final timePicked = await showHourPicker(
|
||||||
context: event.context,
|
context: event.context,
|
||||||
initialTime: TimeOfDay.now(),
|
initialTime: TimeOfDay.now(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (timePicked != null) {
|
if (timePicked != null) {
|
||||||
final DateTime selectedDateTime = DateTime(
|
final selectedDateTime = DateTime(
|
||||||
picked.year,
|
picked.year,
|
||||||
picked.month,
|
picked.month,
|
||||||
picked.day,
|
picked.day,
|
||||||
timePicked.hour,
|
timePicked.hour,
|
||||||
timePicked.minute,
|
timePicked.minute,
|
||||||
);
|
);
|
||||||
final int selectedTimestamp =
|
final selectedTimestamp =
|
||||||
selectedDateTime.millisecondsSinceEpoch ~/ 1000;
|
selectedDateTime.millisecondsSinceEpoch ~/ 1000;
|
||||||
if (event.isStart) {
|
if (event.isStart) {
|
||||||
if (expirationTimeTimeStamp != null &&
|
if (expirationTimeTimeStamp != null &&
|
||||||
@ -152,39 +152,35 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
|||||||
final searchText = event.passwordName?.toLowerCase() ?? '';
|
final searchText = event.passwordName?.toLowerCase() ?? '';
|
||||||
final searchEmailText = event.emailAuthorizer?.toLowerCase() ?? '';
|
final searchEmailText = event.emailAuthorizer?.toLowerCase() ?? '';
|
||||||
filteredData = data.where((item) {
|
filteredData = data.where((item) {
|
||||||
bool matchesCriteria = true;
|
var matchesCriteria = true;
|
||||||
// Convert timestamp to DateTime and extract date component
|
// Convert timestamp to DateTime and extract date component
|
||||||
DateTime effectiveDate = DateTime.fromMillisecondsSinceEpoch(
|
final effectiveDate = DateTime.fromMillisecondsSinceEpoch(
|
||||||
int.parse(item.effectiveTime.toString()) * 1000)
|
int.parse(item.effectiveTime.toString()) * 1000)
|
||||||
.toUtc()
|
.toUtc()
|
||||||
.toLocal();
|
.toLocal();
|
||||||
DateTime invalidDate = DateTime.fromMillisecondsSinceEpoch(
|
final invalidDate = DateTime.fromMillisecondsSinceEpoch(
|
||||||
int.parse(item.invalidTime.toString()) * 1000)
|
int.parse(item.invalidTime.toString()) * 1000)
|
||||||
.toUtc()
|
.toUtc()
|
||||||
.toLocal();
|
.toLocal();
|
||||||
DateTime effectiveDateAndTime = DateTime(
|
final effectiveDateAndTime = DateTime(
|
||||||
effectiveDate.year,
|
effectiveDate.year,
|
||||||
effectiveDate.month,
|
effectiveDate.month,
|
||||||
effectiveDate.day,
|
effectiveDate.day,
|
||||||
effectiveDate.hour,
|
effectiveDate.hour,
|
||||||
effectiveDate.minute);
|
effectiveDate.minute);
|
||||||
DateTime invalidDateAndTime = DateTime(
|
final invalidDateAndTime = DateTime(invalidDate.year, invalidDate.month,
|
||||||
invalidDate.year,
|
invalidDate.day, invalidDate.hour, invalidDate.minute);
|
||||||
invalidDate.month,
|
|
||||||
invalidDate.day,
|
|
||||||
invalidDate.hour,
|
|
||||||
invalidDate.minute);
|
|
||||||
|
|
||||||
// Filter by password name, making the search case-insensitive
|
// Filter by password name, making the search case-insensitive
|
||||||
if (searchText.isNotEmpty) {
|
if (searchText.isNotEmpty) {
|
||||||
final bool matchesName =
|
final matchesName =
|
||||||
item.passwordName.toString().toLowerCase().contains(searchText);
|
item.passwordName.toString().toLowerCase().contains(searchText);
|
||||||
if (!matchesName) {
|
if (!matchesName) {
|
||||||
matchesCriteria = false;
|
matchesCriteria = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (searchEmailText.isNotEmpty) {
|
if (searchEmailText.isNotEmpty) {
|
||||||
final bool matchesName = item.authorizerEmail
|
final matchesName = item.authorizerEmail
|
||||||
.toString()
|
.toString()
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.contains(searchEmailText);
|
.contains(searchEmailText);
|
||||||
@ -194,7 +190,7 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
|||||||
}
|
}
|
||||||
// Filter by start date only
|
// Filter by start date only
|
||||||
if (event.startTime != null && event.endTime == null) {
|
if (event.startTime != null && event.endTime == null) {
|
||||||
DateTime startDateTime =
|
var startDateTime =
|
||||||
DateTime.fromMillisecondsSinceEpoch(event.startTime! * 1000)
|
DateTime.fromMillisecondsSinceEpoch(event.startTime! * 1000)
|
||||||
.toUtc()
|
.toUtc()
|
||||||
.toLocal();
|
.toLocal();
|
||||||
@ -206,7 +202,7 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
|||||||
}
|
}
|
||||||
// Filter by end date only
|
// Filter by end date only
|
||||||
if (event.endTime != null && event.startTime == null) {
|
if (event.endTime != null && event.startTime == null) {
|
||||||
DateTime startDateTime =
|
var startDateTime =
|
||||||
DateTime.fromMillisecondsSinceEpoch(event.endTime! * 1000)
|
DateTime.fromMillisecondsSinceEpoch(event.endTime! * 1000)
|
||||||
.toUtc()
|
.toUtc()
|
||||||
.toLocal();
|
.toLocal();
|
||||||
@ -219,11 +215,11 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
|||||||
|
|
||||||
// Filter by both start date and end date
|
// Filter by both start date and end date
|
||||||
if (event.startTime != null && event.endTime != null) {
|
if (event.startTime != null && event.endTime != null) {
|
||||||
DateTime startDateTime =
|
var startDateTime =
|
||||||
DateTime.fromMillisecondsSinceEpoch(event.startTime! * 1000)
|
DateTime.fromMillisecondsSinceEpoch(event.startTime! * 1000)
|
||||||
.toUtc()
|
.toUtc()
|
||||||
.toLocal();
|
.toLocal();
|
||||||
DateTime endDateTime =
|
var endDateTime =
|
||||||
DateTime.fromMillisecondsSinceEpoch(event.endTime! * 1000)
|
DateTime.fromMillisecondsSinceEpoch(event.endTime! * 1000)
|
||||||
.toUtc()
|
.toUtc()
|
||||||
.toLocal();
|
.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());
|
emit(AccessLoaded());
|
||||||
startTime = 'Start Time';
|
startTime = 'Start Time';
|
||||||
endTime = 'End Time';
|
endTime = 'End Time';
|
||||||
@ -272,7 +268,7 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String timestampToDate(dynamic timestamp) {
|
String timestampToDate(dynamic timestamp) {
|
||||||
DateTime dateTime =
|
final dateTime =
|
||||||
DateTime.fromMillisecondsSinceEpoch(int.parse(timestamp) * 1000);
|
DateTime.fromMillisecondsSinceEpoch(int.parse(timestamp) * 1000);
|
||||||
return "${dateTime.year}/${dateTime.month.toString().padLeft(2, '0')}/${dateTime.day.toString().padLeft(2, '0')} "
|
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')}";
|
" ${dateTime.hour.toString().padLeft(2, '0')}:${dateTime.minute.toString().padLeft(2, '0')}";
|
||||||
@ -289,17 +285,17 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
|||||||
break;
|
break;
|
||||||
case 1: // To Be Effective
|
case 1: // To Be Effective
|
||||||
filteredData = data
|
filteredData = data
|
||||||
.where((item) => item.passwordStatus.value == "To Be Effective")
|
.where((item) => item.passwordStatus.value == 'To Be Effective')
|
||||||
.toList();
|
.toList();
|
||||||
break;
|
break;
|
||||||
case 2: // Effective
|
case 2: // Effective
|
||||||
filteredData = data
|
filteredData = data
|
||||||
.where((item) => item.passwordStatus.value == "Effective")
|
.where((item) => item.passwordStatus.value == 'Effective')
|
||||||
.toList();
|
.toList();
|
||||||
break;
|
break;
|
||||||
case 3: // Expired
|
case 3: // Expired
|
||||||
filteredData = data
|
filteredData = data
|
||||||
.where((item) => item.passwordStatus.value == "Expired")
|
.where((item) => item.passwordStatus.value == 'Expired')
|
||||||
.toList();
|
.toList();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -15,7 +15,7 @@ class AccessLoaded extends AccessState {}
|
|||||||
class FailedState extends AccessState {
|
class FailedState extends AccessState {
|
||||||
final String message;
|
final String message;
|
||||||
|
|
||||||
FailedState(this.message);
|
const FailedState(this.message);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [message];
|
List<Object> get props => [message];
|
||||||
|
@ -36,7 +36,7 @@ class PasswordModel {
|
|||||||
effectiveTime: json['effectiveTime'],
|
effectiveTime: json['effectiveTime'],
|
||||||
passwordCreated: json['passwordCreated'],
|
passwordCreated: json['passwordCreated'],
|
||||||
createdTime: json['createdTime'],
|
createdTime: json['createdTime'],
|
||||||
passwordName: json['passwordName']??'No Name',
|
passwordName: json['passwordName'] ?? 'No Name',
|
||||||
passwordStatus: AccessStatusExtension.fromString(json['passwordStatus']),
|
passwordStatus: AccessStatusExtension.fromString(json['passwordStatus']),
|
||||||
passwordType: AccessTypeExtension.fromString(json['passwordType']),
|
passwordType: AccessTypeExtension.fromString(json['passwordType']),
|
||||||
deviceUuid: json['deviceUuid'],
|
deviceUuid: json['deviceUuid'],
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import 'dart:ui';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class DashedBorderPainter extends CustomPainter {
|
class DashedBorderPainter extends CustomPainter {
|
||||||
@ -20,27 +18,28 @@ class DashedBorderPainter extends CustomPainter {
|
|||||||
..strokeWidth = 0.5
|
..strokeWidth = 0.5
|
||||||
..style = PaintingStyle.stroke;
|
..style = PaintingStyle.stroke;
|
||||||
|
|
||||||
final Path topPath = Path()
|
final topPath = Path()
|
||||||
..moveTo(0, 0)
|
..moveTo(0, 0)
|
||||||
..lineTo(size.width, 0);
|
..lineTo(size.width, 0);
|
||||||
|
|
||||||
final Path bottomPath = Path()
|
final bottomPath = Path()
|
||||||
..moveTo(0, size.height)
|
..moveTo(0, size.height)
|
||||||
..lineTo(size.width, size.height);
|
..lineTo(size.width, size.height);
|
||||||
|
|
||||||
final dashedTopPath = _createDashedPath(topPath, dashWidth, dashSpace);
|
final dashedTopPath = _createDashedPath(topPath, dashWidth, dashSpace);
|
||||||
final dashedBottomPath = _createDashedPath(bottomPath, dashWidth, dashSpace);
|
final dashedBottomPath =
|
||||||
|
_createDashedPath(bottomPath, dashWidth, dashSpace);
|
||||||
|
|
||||||
canvas.drawPath(dashedTopPath, paint);
|
canvas.drawPath(dashedTopPath, paint);
|
||||||
canvas.drawPath(dashedBottomPath, paint);
|
canvas.drawPath(dashedBottomPath, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
Path _createDashedPath(Path source, double dashWidth, double dashSpace) {
|
Path _createDashedPath(Path source, double dashWidth, double dashSpace) {
|
||||||
final Path dashedPath = Path();
|
final dashedPath = Path();
|
||||||
for (PathMetric pathMetric in source.computeMetrics()) {
|
for (final pathMetric in source.computeMetrics()) {
|
||||||
double distance = 0.0;
|
var distance = 0.0;
|
||||||
while (distance < pathMetric.length) {
|
while (distance < pathMetric.length) {
|
||||||
final double nextDistance = distance + dashWidth;
|
final nextDistance = distance + dashWidth;
|
||||||
dashedPath.addPath(
|
dashedPath.addPath(
|
||||||
pathMetric.extractPath(distance, nextDistance),
|
pathMetric.extractPath(distance, nextDistance),
|
||||||
Offset.zero,
|
Offset.zero,
|
||||||
|
@ -16,4 +16,4 @@ extension GetMonthNameFromNumber on num {
|
|||||||
_ => 'N/A'
|
_ => 'N/A'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,8 @@ class AirQualityDataModel extends Equatable {
|
|||||||
return AirQualityDataModel(
|
return AirQualityDataModel(
|
||||||
date: DateTime.parse(json['date'] as String),
|
date: DateTime.parse(json['date'] as String),
|
||||||
data: (json['data'] as List<dynamic>)
|
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(),
|
.toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -46,7 +47,7 @@ class AirQualityPercentageData extends Equatable {
|
|||||||
|
|
||||||
factory AirQualityPercentageData.fromJson(Map<String, dynamic> json) {
|
factory AirQualityPercentageData.fromJson(Map<String, dynamic> json) {
|
||||||
return AirQualityPercentageData(
|
return AirQualityPercentageData(
|
||||||
type: json['type'] as String? ?? '',
|
type: json['type'] as String? ?? '',
|
||||||
name: json['name'] as String? ?? '',
|
name: json['name'] as String? ?? '',
|
||||||
percentage: (json['percentage'] as num?)?.toDouble() ?? 0,
|
percentage: (json['percentage'] as num?)?.toDouble() ?? 0,
|
||||||
);
|
);
|
||||||
|
@ -36,11 +36,14 @@ class AnalyticsDevice {
|
|||||||
deviceTuyaUuid: json['deviceTuyaUuid'] as String?,
|
deviceTuyaUuid: json['deviceTuyaUuid'] as String?,
|
||||||
isActive: json['isActive'] as bool?,
|
isActive: json['isActive'] as bool?,
|
||||||
productDevice: json['productDevice'] != null
|
productDevice: json['productDevice'] != null
|
||||||
? ProductDevice.fromJson(json['productDevice'] as Map<String, dynamic>)
|
? ProductDevice.fromJson(
|
||||||
|
json['productDevice'] as Map<String, dynamic>)
|
||||||
: null,
|
: null,
|
||||||
spaceUuid: json['spaceUuid'] as String?,
|
spaceUuid: json['spaceUuid'] as String?,
|
||||||
latitude: json['lat'] != null ? double.parse(json['lat'] as String) : null,
|
latitude:
|
||||||
longitude: json['lon'] != null ? double.parse(json['lon'] as String) : null,
|
json['lat'] != null ? double.parse(json['lat'] as String) : null,
|
||||||
|
longitude:
|
||||||
|
json['lon'] != null ? double.parse(json['lon'] as String) : null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,8 @@ class Occupacy extends Equatable {
|
|||||||
|
|
||||||
factory Occupacy.fromJson(Map<String, dynamic> json) {
|
factory Occupacy.fromJson(Map<String, dynamic> json) {
|
||||||
return Occupacy(
|
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(),
|
occupancy: (json['occupancy_percentage'] ?? 0).toString(),
|
||||||
spaceUuid: json['space_uuid'] as String? ?? '',
|
spaceUuid: json['space_uuid'] as String? ?? '',
|
||||||
occupiedSeconds: json['occupied_seconds'] as int? ?? 0,
|
occupiedSeconds: json['occupied_seconds'] as int? ?? 0,
|
||||||
|
@ -19,7 +19,8 @@ class OccupancyHeatMapModel extends Equatable {
|
|||||||
eventDate: DateTime.parse(
|
eventDate: DateTime.parse(
|
||||||
json['event_date'] as String? ?? '${DateTime.now()}',
|
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,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,8 @@ class AirQualityDistributionBloc
|
|||||||
state.copyWith(
|
state.copyWith(
|
||||||
status: AirQualityDistributionStatus.success,
|
status: AirQualityDistributionStatus.success,
|
||||||
chartData: result,
|
chartData: result,
|
||||||
filteredChartData: _arrangeChartDataByType(result, state.selectedAqiType),
|
filteredChartData:
|
||||||
|
_arrangeChartDataByType(result, state.selectedAqiType),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -61,7 +62,8 @@ class AirQualityDistributionBloc
|
|||||||
emit(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
selectedAqiType: event.aqiType,
|
selectedAqiType: event.aqiType,
|
||||||
filteredChartData: _arrangeChartDataByType(state.chartData, event.aqiType),
|
filteredChartData:
|
||||||
|
_arrangeChartDataByType(state.chartData, event.aqiType),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,8 @@ import 'package:syncrow_web/pages/analytics/services/device_location/device_loca
|
|||||||
part 'device_location_event.dart';
|
part 'device_location_event.dart';
|
||||||
part 'device_location_state.dart';
|
part 'device_location_state.dart';
|
||||||
|
|
||||||
class DeviceLocationBloc extends Bloc<DeviceLocationEvent, DeviceLocationState> {
|
class DeviceLocationBloc
|
||||||
|
extends Bloc<DeviceLocationEvent, DeviceLocationState> {
|
||||||
DeviceLocationBloc(
|
DeviceLocationBloc(
|
||||||
this._deviceLocationService,
|
this._deviceLocationService,
|
||||||
) : super(const DeviceLocationState()) {
|
) : super(const DeviceLocationState()) {
|
||||||
|
@ -53,7 +53,8 @@ class RangeOfAqiBloc extends Bloc<RangeOfAqiEvent, RangeOfAqiState> {
|
|||||||
emit(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
selectedAqiType: event.aqiType,
|
selectedAqiType: event.aqiType,
|
||||||
filteredRangeOfAqi: _arrangeChartDataByType(state.rangeOfAqi, event.aqiType),
|
filteredRangeOfAqi:
|
||||||
|
_arrangeChartDataByType(state.rangeOfAqi, event.aqiType),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,8 @@ abstract final class RangeOfAqiChartsHelper {
|
|||||||
tooltipRoundedRadius: 16,
|
tooltipRoundedRadius: 16,
|
||||||
showOnTopOfTheChartBoxArea: false,
|
showOnTopOfTheChartBoxArea: false,
|
||||||
tooltipPadding: const EdgeInsets.all(8),
|
tooltipPadding: const EdgeInsets.all(8),
|
||||||
getTooltipItems: (touchedSpots) => RangeOfAqiChartsHelper.getTooltipItems(
|
getTooltipItems: (touchedSpots) =>
|
||||||
|
RangeOfAqiChartsHelper.getTooltipItems(
|
||||||
touchedSpots,
|
touchedSpots,
|
||||||
chartData,
|
chartData,
|
||||||
),
|
),
|
||||||
|
@ -81,7 +81,8 @@ class AqiDeviceInfo extends StatelessWidget {
|
|||||||
aqiLevel: status
|
aqiLevel: status
|
||||||
.firstWhere(
|
.firstWhere(
|
||||||
(e) => e.code == 'air_quality_index',
|
(e) => e.code == 'air_quality_index',
|
||||||
orElse: () => Status(code: 'air_quality_index', value: ''),
|
orElse: () =>
|
||||||
|
Status(code: 'air_quality_index', value: ''),
|
||||||
)
|
)
|
||||||
.value
|
.value
|
||||||
.toString(),
|
.toString(),
|
||||||
|
@ -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) {
|
return List.generate(sortedData.length, (index) {
|
||||||
final data = sortedData[index];
|
final data = sortedData[index];
|
||||||
final stackItems = <BarChartRodData>[];
|
final stackItems = <BarChartRodData>[];
|
||||||
double currentY = 0;
|
double currentY = 0;
|
||||||
bool isFirstElement = true;
|
var isFirstElement = true;
|
||||||
|
|
||||||
// Sort data by type to ensure consistent order
|
// Sort data by type to ensure consistent order
|
||||||
final sortedPercentageData = List<AirQualityPercentageData>.from(data.data)
|
final sortedPercentageData =
|
||||||
..sort((a, b) => a.type.compareTo(b.type));
|
List<AirQualityPercentageData>.from(data.data)
|
||||||
|
..sort((a, b) => a.type.compareTo(b.type));
|
||||||
|
|
||||||
for (final percentageData in sortedPercentageData) {
|
for (final percentageData in sortedPercentageData) {
|
||||||
stackItems.add(
|
stackItems.add(
|
||||||
BarChartRodData(
|
BarChartRodData(
|
||||||
fromY: currentY,
|
fromY: currentY,
|
||||||
toY: currentY + percentageData.percentage ,
|
toY: currentY + percentageData.percentage,
|
||||||
color: AirQualityDataModel.metricColors[percentageData.name]!,
|
color: AirQualityDataModel.metricColors[percentageData.name],
|
||||||
borderRadius: isFirstElement
|
borderRadius: isFirstElement
|
||||||
? const BorderRadius.only(
|
? const BorderRadius.only(
|
||||||
topLeft: Radius.circular(22),
|
topLeft: Radius.circular(22),
|
||||||
@ -84,9 +86,9 @@ class AqiDistributionChart extends StatelessWidget {
|
|||||||
tooltipRoundedRadius: 16,
|
tooltipRoundedRadius: 16,
|
||||||
tooltipPadding: const EdgeInsets.all(8),
|
tooltipPadding: const EdgeInsets.all(8),
|
||||||
getTooltipItem: (group, groupIndex, rod, rodIndex) {
|
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(
|
final textStyle = context.textTheme.bodySmall?.copyWith(
|
||||||
color: ColorsManager.blackColor,
|
color: ColorsManager.blackColor,
|
||||||
@ -94,8 +96,9 @@ class AqiDistributionChart extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Sort data by type to ensure consistent order
|
// Sort data by type to ensure consistent order
|
||||||
final sortedPercentageData = List<AirQualityPercentageData>.from(data.data)
|
final sortedPercentageData =
|
||||||
..sort((a, b) => a.type.compareTo(b.type));
|
List<AirQualityPercentageData>.from(data.data)
|
||||||
|
..sort((a, b) => a.type.compareTo(b.type));
|
||||||
|
|
||||||
for (final percentageData in sortedPercentageData) {
|
for (final percentageData in sortedPercentageData) {
|
||||||
children.add(TextSpan(
|
children.add(TextSpan(
|
||||||
|
@ -49,7 +49,7 @@ class AqiSubValueWidget extends StatelessWidget {
|
|||||||
|
|
||||||
int _getActiveSegmentByRange(double value, (double min, double max) range) {
|
int _getActiveSegmentByRange(double value, (double min, double max) range) {
|
||||||
final ranges = _getRangesForValue(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;
|
if (value <= ranges[i].max) return i;
|
||||||
}
|
}
|
||||||
return ranges.length - 1;
|
return ranges.length - 1;
|
||||||
|
@ -29,7 +29,8 @@ class AqiTypeDropdown extends StatefulWidget {
|
|||||||
class _AqiTypeDropdownState extends State<AqiTypeDropdown> {
|
class _AqiTypeDropdownState extends State<AqiTypeDropdown> {
|
||||||
AqiType? _selectedItem = AqiType.aqi;
|
AqiType? _selectedItem = AqiType.aqi;
|
||||||
|
|
||||||
void _updateSelectedItem(AqiType? item) => setState(() => _selectedItem = item);
|
void _updateSelectedItem(AqiType? item) =>
|
||||||
|
setState(() => _selectedItem = item);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -63,7 +63,7 @@ class RangeOfAqiChart extends StatelessWidget {
|
|||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
begin: Alignment.bottomCenter,
|
begin: Alignment.bottomCenter,
|
||||||
end: Alignment.topCenter,
|
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) {
|
colors: RangeOfAqiChartsHelper.gradientData.map((e) {
|
||||||
final (color, _) = e;
|
final (color, _) = e;
|
||||||
return color.withValues(alpha: 0.6);
|
return color.withValues(alpha: 0.6);
|
||||||
@ -99,7 +99,8 @@ class RangeOfAqiChart extends StatelessWidget {
|
|||||||
}) {
|
}) {
|
||||||
const invisibleDot = FlDotData(show: false);
|
const invisibleDot = FlDotData(show: false);
|
||||||
return LineChartBarData(
|
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,
|
isCurved: true,
|
||||||
color: color,
|
color: color,
|
||||||
barWidth: 4,
|
barWidth: 4,
|
||||||
|
@ -32,7 +32,8 @@ class RangeOfAqiChartBox extends StatelessWidget {
|
|||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Expanded(child: RangeOfAqiChart(chartData: state.filteredRangeOfAqi)),
|
Expanded(
|
||||||
|
child: RangeOfAqiChart(chartData: state.filteredRangeOfAqi)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -8,7 +8,8 @@ sealed class AnalyticsDevicesEvent extends Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final class LoadAnalyticsDevicesEvent extends AnalyticsDevicesEvent {
|
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 GetAnalyticsDevicesParam param;
|
||||||
final void Function(AnalyticsDevice device) onSuccess;
|
final void Function(AnalyticsDevice device) onSuccess;
|
||||||
|
@ -7,7 +7,7 @@ sealed class AnalyticsTabEvent extends Equatable {
|
|||||||
List<Object> get props => [];
|
List<Object> get props => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
class UpdateAnalyticsTabEvent extends AnalyticsTabEvent {
|
class UpdateAnalyticsTabEvent extends AnalyticsTabEvent {
|
||||||
const UpdateAnalyticsTabEvent(this.analyticsTab);
|
const UpdateAnalyticsTabEvent(this.analyticsTab);
|
||||||
|
|
||||||
final AnalyticsPageTab analyticsTab;
|
final AnalyticsPageTab analyticsTab;
|
||||||
|
@ -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/community_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_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
|
@override
|
||||||
void onCommunitySelected(
|
void onCommunitySelected(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
@ -25,7 +26,8 @@ final class AirQualityDataLoadingStrategy implements AnalyticsDataLoadingStrateg
|
|||||||
SpaceModel space,
|
SpaceModel space,
|
||||||
) {
|
) {
|
||||||
final spaceTreeBloc = context.read<SpaceTreeBloc>();
|
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;
|
final hasSelectedSpaces = spaceTreeBloc.state.selectedSpaces.isNotEmpty;
|
||||||
if (hasSelectedSpaces) clearData(context);
|
if (hasSelectedSpaces) clearData(context);
|
||||||
@ -34,7 +36,7 @@ final class AirQualityDataLoadingStrategy implements AnalyticsDataLoadingStrateg
|
|||||||
|
|
||||||
spaceTreeBloc
|
spaceTreeBloc
|
||||||
..add(const SpaceTreeClearSelectionEvent())
|
..add(const SpaceTreeClearSelectionEvent())
|
||||||
..add(OnSpaceSelected(community, space.uuid ?? '', []));
|
..add(OnSpaceSelected(community, space.uuid ?? '', const []));
|
||||||
|
|
||||||
FetchAirQualityDataHelper.loadAirQualityData(
|
FetchAirQualityDataHelper.loadAirQualityData(
|
||||||
context,
|
context,
|
||||||
|
@ -8,7 +8,8 @@ abstract final class AnalyticsDataLoadingStrategyFactory {
|
|||||||
const AnalyticsDataLoadingStrategyFactory._();
|
const AnalyticsDataLoadingStrategyFactory._();
|
||||||
static AnalyticsDataLoadingStrategy getStrategy(AnalyticsPageTab tab) {
|
static AnalyticsDataLoadingStrategy getStrategy(AnalyticsPageTab tab) {
|
||||||
return switch (tab) {
|
return switch (tab) {
|
||||||
AnalyticsPageTab.energyManagement => EnergyManagementDataLoadingStrategy(),
|
AnalyticsPageTab.energyManagement =>
|
||||||
|
EnergyManagementDataLoadingStrategy(),
|
||||||
AnalyticsPageTab.occupancy => OccupancyDataLoadingStrategy(),
|
AnalyticsPageTab.occupancy => OccupancyDataLoadingStrategy(),
|
||||||
AnalyticsPageTab.airQuality => AirQualityDataLoadingStrategy(),
|
AnalyticsPageTab.airQuality => AirQualityDataLoadingStrategy(),
|
||||||
};
|
};
|
||||||
|
@ -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/community_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||||
|
|
||||||
class EnergyManagementDataLoadingStrategy implements AnalyticsDataLoadingStrategy {
|
class EnergyManagementDataLoadingStrategy
|
||||||
|
implements AnalyticsDataLoadingStrategy {
|
||||||
@override
|
@override
|
||||||
void onCommunitySelected(
|
void onCommunitySelected(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
@ -31,7 +32,8 @@ class EnergyManagementDataLoadingStrategy implements AnalyticsDataLoadingStrateg
|
|||||||
SpaceModel space,
|
SpaceModel space,
|
||||||
) {
|
) {
|
||||||
final spaceTreeBloc = context.read<SpaceTreeBloc>();
|
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;
|
final hasSelectedSpaces = spaceTreeBloc.state.selectedSpaces.isNotEmpty;
|
||||||
|
|
||||||
if (isSpaceSelected) {
|
if (isSpaceSelected) {
|
||||||
|
@ -24,7 +24,8 @@ class OccupancyDataLoadingStrategy implements AnalyticsDataLoadingStrategy {
|
|||||||
SpaceModel space,
|
SpaceModel space,
|
||||||
) {
|
) {
|
||||||
final spaceTreeBloc = context.read<SpaceTreeBloc>();
|
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;
|
final hasSelectedSpaces = spaceTreeBloc.state.selectedSpaces.isNotEmpty;
|
||||||
if (hasSelectedSpaces) clearData(context);
|
if (hasSelectedSpaces) clearData(context);
|
||||||
@ -33,7 +34,7 @@ class OccupancyDataLoadingStrategy implements AnalyticsDataLoadingStrategy {
|
|||||||
|
|
||||||
spaceTreeBloc
|
spaceTreeBloc
|
||||||
..add(const SpaceTreeClearSelectionEvent())
|
..add(const SpaceTreeClearSelectionEvent())
|
||||||
..add(OnSpaceSelected(community, space.uuid ?? '', []));
|
..add(OnSpaceSelected(community, space.uuid ?? '', const []));
|
||||||
|
|
||||||
FetchOccupancyDataHelper.loadOccupancyData(
|
FetchOccupancyDataHelper.loadOccupancyData(
|
||||||
context,
|
context,
|
||||||
|
@ -10,7 +10,8 @@ class AnalyticsCommunitiesSidebar extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final selectedTab = context.watch<AnalyticsTabBloc>().state;
|
final selectedTab = context.watch<AnalyticsTabBloc>().state;
|
||||||
final strategy = AnalyticsDataLoadingStrategyFactory.getStrategy(selectedTab);
|
final strategy =
|
||||||
|
AnalyticsDataLoadingStrategyFactory.getStrategy(selectedTab);
|
||||||
|
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: AnalyticsSpaceTreeView(
|
child: AnalyticsSpaceTreeView(
|
||||||
|
@ -20,7 +20,7 @@ class AnalyticsDateFilterButton extends StatefulWidget {
|
|||||||
final void Function(DateTime)? onDateSelected;
|
final void Function(DateTime)? onDateSelected;
|
||||||
final DatePickerType datePickerType;
|
final DatePickerType datePickerType;
|
||||||
|
|
||||||
static final _color = ColorsManager.blackColor.withValues(alpha: 0.8);
|
static final Color _color = ColorsManager.blackColor.withValues(alpha: 0.8);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AnalyticsDateFilterButton> createState() =>
|
State<AnalyticsDateFilterButton> createState() =>
|
||||||
|
@ -21,8 +21,8 @@ class AnalyticsPageTabButton extends StatelessWidget {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
AnalyticsDataLoadingStrategyFactory.getStrategy(tab).clearData(context);
|
AnalyticsDataLoadingStrategyFactory.getStrategy(tab).clearData(context);
|
||||||
context.read<AnalyticsTabBloc>().add(
|
context.read<AnalyticsTabBloc>().add(
|
||||||
UpdateAnalyticsTabEvent(tab),
|
UpdateAnalyticsTabEvent(tab),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
tab.title,
|
tab.title,
|
||||||
@ -33,8 +33,9 @@ class AnalyticsPageTabButton extends StatelessWidget {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: isSelected ? FontWeight.w700 : FontWeight.w400,
|
fontWeight: isSelected ? FontWeight.w700 : FontWeight.w400,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
color:
|
color: isSelected
|
||||||
isSelected ? ColorsManager.slidingBlueColor : ColorsManager.textGray,
|
? ColorsManager.slidingBlueColor
|
||||||
|
: ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -21,18 +21,18 @@ class _MonthPickerWidgetState extends State<MonthPickerWidget> {
|
|||||||
int? _selectedMonth;
|
int? _selectedMonth;
|
||||||
|
|
||||||
static const _monthNames = [
|
static const _monthNames = [
|
||||||
"January",
|
'January',
|
||||||
"February",
|
'February',
|
||||||
"March",
|
'March',
|
||||||
"April",
|
'April',
|
||||||
"May",
|
'May',
|
||||||
"June",
|
'June',
|
||||||
"July",
|
'July',
|
||||||
"August",
|
'August',
|
||||||
"September",
|
'September',
|
||||||
"October",
|
'October',
|
||||||
"November",
|
'November',
|
||||||
"December",
|
'December',
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -189,14 +189,19 @@ class _MonthPickerWidgetState extends State<MonthPickerWidget> {
|
|||||||
final isFutureMonth = isCurrentYear && index > currentDate.month - 1;
|
final isFutureMonth = isCurrentYear && index > currentDate.month - 1;
|
||||||
|
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: isFutureMonth ? null : () => setState(() => _selectedMonth = index),
|
onTap: isFutureMonth
|
||||||
|
? null
|
||||||
|
: () => setState(() => _selectedMonth = index),
|
||||||
child: DecoratedBox(
|
child: DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFFEDF2F7),
|
color: const Color(0xFFEDF2F7),
|
||||||
borderRadius: BorderRadius.only(
|
borderRadius: BorderRadius.only(
|
||||||
topLeft: index % 3 == 0 ? const Radius.circular(16) : Radius.zero,
|
topLeft:
|
||||||
bottomLeft: index % 3 == 0 ? const Radius.circular(16) : Radius.zero,
|
index % 3 == 0 ? const Radius.circular(16) : Radius.zero,
|
||||||
topRight: index % 3 == 2 ? 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:
|
bottomRight:
|
||||||
index % 3 == 2 ? const Radius.circular(16) : Radius.zero,
|
index % 3 == 2 ? const Radius.circular(16) : Radius.zero,
|
||||||
),
|
),
|
||||||
|
@ -53,7 +53,8 @@ class _AnalyticsSpaceTreeViewState extends State<AnalyticsSpaceTreeView> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<SpaceTreeBloc, SpaceTreeState>(builder: (context, state) {
|
return BlocBuilder<SpaceTreeBloc, SpaceTreeState>(
|
||||||
|
builder: (context, state) {
|
||||||
final communities = state.searchQuery.isNotEmpty
|
final communities = state.searchQuery.isNotEmpty
|
||||||
? state.filteredCommunity
|
? state.filteredCommunity
|
||||||
: state.communityList;
|
: state.communityList;
|
||||||
@ -76,9 +77,10 @@ class _AnalyticsSpaceTreeViewState extends State<AnalyticsSpaceTreeView> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
CustomSearchBar(
|
CustomSearchBar(
|
||||||
onSearchChanged: (query) => context.read<SpaceTreeBloc>().add(
|
onSearchChanged: (query) =>
|
||||||
SearchQueryEvent(query),
|
context.read<SpaceTreeBloc>().add(
|
||||||
),
|
SearchQueryEvent(query),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -113,7 +115,8 @@ class _AnalyticsSpaceTreeViewState extends State<AnalyticsSpaceTreeView> {
|
|||||||
isExpanded: state.expandedCommunities.contains(
|
isExpanded: state.expandedCommunities.contains(
|
||||||
communities[index].uuid,
|
communities[index].uuid,
|
||||||
),
|
),
|
||||||
onItemSelected: () => widget.onSelectCommunity?.call(
|
onItemSelected: () =>
|
||||||
|
widget.onSelectCommunity?.call(
|
||||||
communities[index],
|
communities[index],
|
||||||
communities[index].spaces,
|
communities[index].spaces,
|
||||||
),
|
),
|
||||||
@ -121,8 +124,8 @@ class _AnalyticsSpaceTreeViewState extends State<AnalyticsSpaceTreeView> {
|
|||||||
(space) {
|
(space) {
|
||||||
return CustomExpansionTileSpaceTree(
|
return CustomExpansionTileSpaceTree(
|
||||||
title: space.name,
|
title: space.name,
|
||||||
isExpanded:
|
isExpanded: state.expandedSpaces
|
||||||
state.expandedSpaces.contains(space.uuid),
|
.contains(space.uuid),
|
||||||
onItemSelected: () =>
|
onItemSelected: () =>
|
||||||
widget.onSelectSpace?.call(
|
widget.onSelectSpace?.call(
|
||||||
communities[index],
|
communities[index],
|
||||||
@ -153,7 +156,8 @@ class _AnalyticsSpaceTreeViewState extends State<AnalyticsSpaceTreeView> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (state.paginationIsLoading) const CircularProgressIndicator(),
|
if (state.paginationIsLoading)
|
||||||
|
const CircularProgressIndicator(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -19,9 +19,9 @@ class YearPickerWidget extends StatefulWidget {
|
|||||||
class _YearPickerWidgetState extends State<YearPickerWidget> {
|
class _YearPickerWidgetState extends State<YearPickerWidget> {
|
||||||
late int _currentYear;
|
late int _currentYear;
|
||||||
|
|
||||||
static final years = List.generate(
|
static final List<int> years = List.generate(
|
||||||
DateTime.now().year - (DateTime.now().year - 5) + 1,
|
DateTime.now().year - (DateTime.now().year - 5) + 1,
|
||||||
(index) => (2020 + index),
|
(index) => 2020 + index,
|
||||||
).where((year) => year <= DateTime.now().year).toList();
|
).where((year) => year <= DateTime.now().year).toList();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -123,9 +123,12 @@ class _YearPickerWidgetState extends State<YearPickerWidget> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFFEDF2F7),
|
color: const Color(0xFFEDF2F7),
|
||||||
borderRadius: BorderRadius.only(
|
borderRadius: BorderRadius.only(
|
||||||
topLeft: index % 3 == 0 ? const Radius.circular(16) : Radius.zero,
|
topLeft:
|
||||||
bottomLeft: index % 3 == 0 ? const Radius.circular(16) : Radius.zero,
|
index % 3 == 0 ? const Radius.circular(16) : Radius.zero,
|
||||||
topRight: index % 3 == 2 ? 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:
|
bottomRight:
|
||||||
index % 3 == 2 ? const Radius.circular(16) : Radius.zero,
|
index % 3 == 2 ? const Radius.circular(16) : Radius.zero,
|
||||||
),
|
),
|
||||||
|
@ -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_event.dart';
|
||||||
part 'energy_consumption_by_phases_state.dart';
|
part 'energy_consumption_by_phases_state.dart';
|
||||||
|
|
||||||
class EnergyConsumptionByPhasesBloc
|
class EnergyConsumptionByPhasesBloc extends Bloc<EnergyConsumptionByPhasesEvent,
|
||||||
extends Bloc<EnergyConsumptionByPhasesEvent, EnergyConsumptionByPhasesState> {
|
EnergyConsumptionByPhasesState> {
|
||||||
EnergyConsumptionByPhasesBloc(
|
EnergyConsumptionByPhasesBloc(
|
||||||
this._energyConsumptionByPhasesService,
|
this._energyConsumptionByPhasesService,
|
||||||
) : super(const EnergyConsumptionByPhasesState()) {
|
) : super(const EnergyConsumptionByPhasesState()) {
|
||||||
on<LoadEnergyConsumptionByPhasesEvent>(_onLoadEnergyConsumptionByPhasesEvent);
|
on<LoadEnergyConsumptionByPhasesEvent>(
|
||||||
on<ClearEnergyConsumptionByPhasesEvent>(_onClearEnergyConsumptionByPhasesEvent);
|
_onLoadEnergyConsumptionByPhasesEvent);
|
||||||
|
on<ClearEnergyConsumptionByPhasesEvent>(
|
||||||
|
_onClearEnergyConsumptionByPhasesEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
final EnergyConsumptionByPhasesService _energyConsumptionByPhasesService;
|
final EnergyConsumptionByPhasesService _energyConsumptionByPhasesService;
|
||||||
@ -25,7 +27,8 @@ class EnergyConsumptionByPhasesBloc
|
|||||||
) async {
|
) async {
|
||||||
emit(state.copyWith(status: EnergyConsumptionByPhasesStatus.loading));
|
emit(state.copyWith(status: EnergyConsumptionByPhasesStatus.loading));
|
||||||
try {
|
try {
|
||||||
final chartData = await _energyConsumptionByPhasesService.load(event.param);
|
final chartData =
|
||||||
|
await _energyConsumptionByPhasesService.load(event.param);
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
status: EnergyConsumptionByPhasesStatus.loaded,
|
status: EnergyConsumptionByPhasesStatus.loaded,
|
||||||
@ -49,7 +52,7 @@ class EnergyConsumptionByPhasesBloc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onClearEnergyConsumptionByPhasesEvent(
|
Future<void> _onClearEnergyConsumptionByPhasesEvent(
|
||||||
ClearEnergyConsumptionByPhasesEvent event,
|
ClearEnergyConsumptionByPhasesEvent event,
|
||||||
Emitter<EnergyConsumptionByPhasesState> emit,
|
Emitter<EnergyConsumptionByPhasesState> emit,
|
||||||
) async {
|
) async {
|
||||||
|
@ -7,7 +7,8 @@ sealed class EnergyConsumptionByPhasesEvent extends Equatable {
|
|||||||
List<Object> get props => [];
|
List<Object> get props => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadEnergyConsumptionByPhasesEvent extends EnergyConsumptionByPhasesEvent {
|
class LoadEnergyConsumptionByPhasesEvent
|
||||||
|
extends EnergyConsumptionByPhasesEvent {
|
||||||
const LoadEnergyConsumptionByPhasesEvent({
|
const LoadEnergyConsumptionByPhasesEvent({
|
||||||
required this.param,
|
required this.param,
|
||||||
});
|
});
|
||||||
@ -18,6 +19,7 @@ class LoadEnergyConsumptionByPhasesEvent extends EnergyConsumptionByPhasesEvent
|
|||||||
List<Object> get props => [param];
|
List<Object> get props => [param];
|
||||||
}
|
}
|
||||||
|
|
||||||
final class ClearEnergyConsumptionByPhasesEvent extends EnergyConsumptionByPhasesEvent {
|
final class ClearEnergyConsumptionByPhasesEvent
|
||||||
|
extends EnergyConsumptionByPhasesEvent {
|
||||||
const ClearEnergyConsumptionByPhasesEvent();
|
const ClearEnergyConsumptionByPhasesEvent();
|
||||||
}
|
}
|
||||||
|
@ -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_event.dart';
|
||||||
part 'energy_consumption_per_device_state.dart';
|
part 'energy_consumption_per_device_state.dart';
|
||||||
|
|
||||||
class EnergyConsumptionPerDeviceBloc
|
class EnergyConsumptionPerDeviceBloc extends Bloc<
|
||||||
extends Bloc<EnergyConsumptionPerDeviceEvent, EnergyConsumptionPerDeviceState> {
|
EnergyConsumptionPerDeviceEvent, EnergyConsumptionPerDeviceState> {
|
||||||
EnergyConsumptionPerDeviceBloc(
|
EnergyConsumptionPerDeviceBloc(
|
||||||
this._energyConsumptionPerDeviceService,
|
this._energyConsumptionPerDeviceService,
|
||||||
) : super(const EnergyConsumptionPerDeviceState()) {
|
) : super(const EnergyConsumptionPerDeviceState()) {
|
||||||
on<LoadEnergyConsumptionPerDeviceEvent>(_onLoadEnergyConsumptionPerDeviceEvent);
|
on<LoadEnergyConsumptionPerDeviceEvent>(
|
||||||
|
_onLoadEnergyConsumptionPerDeviceEvent);
|
||||||
on<ClearEnergyConsumptionPerDeviceEvent>(
|
on<ClearEnergyConsumptionPerDeviceEvent>(
|
||||||
_onClearEnergyConsumptionPerDeviceEvent);
|
_onClearEnergyConsumptionPerDeviceEvent);
|
||||||
}
|
}
|
||||||
@ -26,7 +27,8 @@ class EnergyConsumptionPerDeviceBloc
|
|||||||
) async {
|
) async {
|
||||||
emit(state.copyWith(status: EnergyConsumptionPerDeviceStatus.loading));
|
emit(state.copyWith(status: EnergyConsumptionPerDeviceStatus.loading));
|
||||||
try {
|
try {
|
||||||
final chartData = await _energyConsumptionPerDeviceService.load(event.param);
|
final chartData =
|
||||||
|
await _energyConsumptionPerDeviceService.load(event.param);
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
status: EnergyConsumptionPerDeviceStatus.loaded,
|
status: EnergyConsumptionPerDeviceStatus.loaded,
|
||||||
@ -50,7 +52,7 @@ class EnergyConsumptionPerDeviceBloc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onClearEnergyConsumptionPerDeviceEvent(
|
Future<void> _onClearEnergyConsumptionPerDeviceEvent(
|
||||||
ClearEnergyConsumptionPerDeviceEvent event,
|
ClearEnergyConsumptionPerDeviceEvent event,
|
||||||
Emitter<EnergyConsumptionPerDeviceState> emit,
|
Emitter<EnergyConsumptionPerDeviceState> emit,
|
||||||
) async {
|
) async {
|
||||||
|
@ -8,7 +8,8 @@ import 'package:syncrow_web/services/api/api_exception.dart';
|
|||||||
part 'power_clamp_info_event.dart';
|
part 'power_clamp_info_event.dart';
|
||||||
part 'power_clamp_info_state.dart';
|
part 'power_clamp_info_state.dart';
|
||||||
|
|
||||||
class PowerClampInfoBloc extends Bloc<PowerClampInfoEvent, PowerClampInfoState> {
|
class PowerClampInfoBloc
|
||||||
|
extends Bloc<PowerClampInfoEvent, PowerClampInfoState> {
|
||||||
PowerClampInfoBloc(
|
PowerClampInfoBloc(
|
||||||
this._powerClampInfoService,
|
this._powerClampInfoService,
|
||||||
) : super(const PowerClampInfoState()) {
|
) : super(const PowerClampInfoState()) {
|
||||||
@ -25,7 +26,8 @@ class PowerClampInfoBloc extends Bloc<PowerClampInfoEvent, PowerClampInfoState>
|
|||||||
) async {
|
) async {
|
||||||
emit(state.copyWith(status: PowerClampInfoStatus.loading));
|
emit(state.copyWith(status: PowerClampInfoStatus.loading));
|
||||||
try {
|
try {
|
||||||
final powerClampModel = await _powerClampInfoService.getInfo(event.deviceId);
|
final powerClampModel =
|
||||||
|
await _powerClampInfoService.getInfo(event.deviceId);
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
status: PowerClampInfoStatus.loaded,
|
status: PowerClampInfoStatus.loaded,
|
||||||
@ -49,7 +51,7 @@ class PowerClampInfoBloc extends Bloc<PowerClampInfoEvent, PowerClampInfoState>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onUpdatePowerClampStatusEvent(
|
Future<void> _onUpdatePowerClampStatusEvent(
|
||||||
UpdatePowerClampStatusEvent event,
|
UpdatePowerClampStatusEvent event,
|
||||||
Emitter<PowerClampInfoState> emit,
|
Emitter<PowerClampInfoState> emit,
|
||||||
) async {
|
) async {
|
||||||
|
@ -16,7 +16,6 @@ final class LoadPowerClampInfoEvent extends PowerClampInfoEvent {
|
|||||||
List<Object> get props => [deviceId];
|
List<Object> get props => [deviceId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final class UpdatePowerClampStatusEvent extends PowerClampInfoEvent {
|
final class UpdatePowerClampStatusEvent extends PowerClampInfoEvent {
|
||||||
const UpdatePowerClampStatusEvent(this.statusList);
|
const UpdatePowerClampStatusEvent(this.statusList);
|
||||||
|
|
||||||
@ -28,4 +27,4 @@ final class UpdatePowerClampStatusEvent extends PowerClampInfoEvent {
|
|||||||
|
|
||||||
final class ClearPowerClampInfoEvent extends PowerClampInfoEvent {
|
final class ClearPowerClampInfoEvent extends PowerClampInfoEvent {
|
||||||
const ClearPowerClampInfoEvent();
|
const ClearPowerClampInfoEvent();
|
||||||
}
|
}
|
||||||
|
@ -24,4 +24,4 @@ class _RealtimeDeviceChangesUpdated extends RealtimeDeviceChangesEvent {
|
|||||||
final List<Status> deviceStatusList;
|
final List<Status> deviceStatusList;
|
||||||
|
|
||||||
const _RealtimeDeviceChangesUpdated(this.deviceStatusList);
|
const _RealtimeDeviceChangesUpdated(this.deviceStatusList);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ class TotalEnergyConsumptionBloc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onClearTotalEnergyConsumptionEvent(
|
Future<void> _onClearTotalEnergyConsumptionEvent(
|
||||||
ClearTotalEnergyConsumptionEvent event,
|
ClearTotalEnergyConsumptionEvent event,
|
||||||
Emitter<TotalEnergyConsumptionState> emit,
|
Emitter<TotalEnergyConsumptionState> emit,
|
||||||
) async {
|
) async {
|
||||||
|
@ -7,7 +7,8 @@ sealed class TotalEnergyConsumptionEvent extends Equatable {
|
|||||||
List<Object?> get props => [];
|
List<Object?> get props => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
final class TotalEnergyConsumptionLoadEvent extends TotalEnergyConsumptionEvent {
|
final class TotalEnergyConsumptionLoadEvent
|
||||||
|
extends TotalEnergyConsumptionEvent {
|
||||||
const TotalEnergyConsumptionLoadEvent({required this.param});
|
const TotalEnergyConsumptionLoadEvent({required this.param});
|
||||||
|
|
||||||
final GetTotalEnergyConsumptionParam param;
|
final GetTotalEnergyConsumptionParam param;
|
||||||
@ -16,6 +17,7 @@ final class TotalEnergyConsumptionLoadEvent extends TotalEnergyConsumptionEvent
|
|||||||
List<Object?> get props => [param];
|
List<Object?> get props => [param];
|
||||||
}
|
}
|
||||||
|
|
||||||
final class ClearTotalEnergyConsumptionEvent extends TotalEnergyConsumptionEvent {
|
final class ClearTotalEnergyConsumptionEvent
|
||||||
|
extends TotalEnergyConsumptionEvent {
|
||||||
const ClearTotalEnergyConsumptionEvent();
|
const ClearTotalEnergyConsumptionEvent();
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,8 @@ abstract final class EnergyManagementChartsHelper {
|
|||||||
return labels.where((element) => element.isNotEmpty).join(', ');
|
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 touchedSpots.map((spot) {
|
||||||
return LineTooltipItem(
|
return LineTooltipItem(
|
||||||
getToolTipLabel(spot.x, spot.y),
|
getToolTipLabel(spot.x, spot.y),
|
||||||
@ -85,7 +86,8 @@ abstract final class EnergyManagementChartsHelper {
|
|||||||
static LineTouchTooltipData lineTouchTooltipData() {
|
static LineTouchTooltipData lineTouchTooltipData() {
|
||||||
return LineTouchTooltipData(
|
return LineTouchTooltipData(
|
||||||
getTooltipColor: (touchTooltipItem) => ColorsManager.whiteColors,
|
getTooltipColor: (touchTooltipItem) => ColorsManager.whiteColors,
|
||||||
tooltipBorder: const BorderSide(color: ColorsManager.semiTransparentBlack),
|
tooltipBorder:
|
||||||
|
const BorderSide(color: ColorsManager.semiTransparentBlack),
|
||||||
tooltipRoundedRadius: 16,
|
tooltipRoundedRadius: 16,
|
||||||
showOnTopOfTheChartBoxArea: false,
|
showOnTopOfTheChartBoxArea: false,
|
||||||
tooltipPadding: const EdgeInsets.all(8),
|
tooltipPadding: const EdgeInsets.all(8),
|
||||||
|
@ -122,7 +122,8 @@ abstract final class FetchEnergyManagementDataHelper {
|
|||||||
final selectedDevice = getSelectedDevice(context);
|
final selectedDevice = getSelectedDevice(context);
|
||||||
|
|
||||||
context.read<RealtimeDeviceChangesBloc>().add(
|
context.read<RealtimeDeviceChangesBloc>().add(
|
||||||
RealtimeDeviceChangesStarted(deviceUuid ?? selectedDevice?.uuid ?? ''),
|
RealtimeDeviceChangesStarted(
|
||||||
|
deviceUuid ?? selectedDevice?.uuid ?? ''),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,8 @@ class AnalyticsEnergyManagementView extends StatelessWidget {
|
|||||||
spacing: 20,
|
spacing: 20,
|
||||||
children: [
|
children: [
|
||||||
Expanded(child: TotalEnergyConsumptionChartBox()),
|
Expanded(child: TotalEnergyConsumptionChartBox()),
|
||||||
Expanded(child: EnergyConsumptionPerDeviceChartBox()),
|
Expanded(
|
||||||
|
child: EnergyConsumptionPerDeviceChartBox()),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -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;
|
final spaceUuid = state.selectedDevice?.spaceUuid;
|
||||||
return DropdownButton<AnalyticsDevice?>(
|
return DropdownButton<AnalyticsDevice?>(
|
||||||
value: state.selectedDevice,
|
value: state.selectedDevice,
|
||||||
|
@ -18,7 +18,6 @@ class EnergyConsumptionByPhasesChart extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BarChart(
|
return BarChart(
|
||||||
BarChartData(
|
BarChartData(
|
||||||
|
|
||||||
gridData: EnergyManagementChartsHelper.gridData().copyWith(
|
gridData: EnergyManagementChartsHelper.gridData().copyWith(
|
||||||
checkToShowHorizontalLine: (value) => true,
|
checkToShowHorizontalLine: (value) => true,
|
||||||
horizontalInterval: 250,
|
horizontalInterval: 250,
|
||||||
@ -100,11 +99,11 @@ class EnergyConsumptionByPhasesChart extends StatelessWidget {
|
|||||||
}) {
|
}) {
|
||||||
final data = energyData;
|
final data = energyData;
|
||||||
|
|
||||||
final date = DateFormat('dd/MM/yyyy').format(data[group.x.toInt()].date);
|
final date = DateFormat('dd/MM/yyyy').format(data[group.x].date);
|
||||||
final phaseA = data[group.x.toInt()].energyConsumedA;
|
final phaseA = data[group.x].energyConsumedA;
|
||||||
final phaseB = data[group.x.toInt()].energyConsumedB;
|
final phaseB = data[group.x].energyConsumedB;
|
||||||
final phaseC = data[group.x.toInt()].energyConsumedC;
|
final phaseC = data[group.x].energyConsumedC;
|
||||||
final total = data[group.x.toInt()].energyConsumedKw;
|
final total = data[group.x].energyConsumedKw;
|
||||||
|
|
||||||
return BarTooltipItem(
|
return BarTooltipItem(
|
||||||
'$date\n',
|
'$date\n',
|
||||||
|
@ -22,7 +22,8 @@ class EnergyConsumptionByPhasesChartBox extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
AnalyticsErrorWidget(state.errorMessage),
|
AnalyticsErrorWidget(state.errorMessage),
|
||||||
EnergyConsumptionByPhasesTitle(
|
EnergyConsumptionByPhasesTitle(
|
||||||
isLoading: state.status == EnergyConsumptionByPhasesStatus.loading,
|
isLoading:
|
||||||
|
state.status == EnergyConsumptionByPhasesStatus.loading,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Expanded(
|
Expanded(
|
||||||
|
@ -17,7 +17,6 @@ class EnergyConsumptionPerDeviceChart extends StatelessWidget {
|
|||||||
context,
|
context,
|
||||||
leftTitlesInterval: 250,
|
leftTitlesInterval: 250,
|
||||||
),
|
),
|
||||||
|
|
||||||
gridData: EnergyManagementChartsHelper.gridData().copyWith(
|
gridData: EnergyManagementChartsHelper.gridData().copyWith(
|
||||||
checkToShowHorizontalLine: (value) => true,
|
checkToShowHorizontalLine: (value) => true,
|
||||||
horizontalInterval: 250,
|
horizontalInterval: 250,
|
||||||
|
@ -46,7 +46,8 @@ class EnergyConsumptionPerDeviceChartBox extends StatelessWidget {
|
|||||||
flex: 2,
|
flex: 2,
|
||||||
child: EnergyConsumptionPerDeviceDevicesList(
|
child: EnergyConsumptionPerDeviceDevicesList(
|
||||||
chartData: state.chartData,
|
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 Divider(height: 0),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: EnergyConsumptionPerDeviceChart(chartData: state.chartData),
|
child:
|
||||||
|
EnergyConsumptionPerDeviceChart(chartData: state.chartData),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -43,11 +43,14 @@ class PowerClampEnergyDataWidget extends StatelessWidget {
|
|||||||
title: 'Smart Power Clamp',
|
title: 'Smart Power Clamp',
|
||||||
showSpaceUuidInDevicesDropdown: true,
|
showSpaceUuidInDevicesDropdown: true,
|
||||||
onChanged: (device) {
|
onChanged: (device) {
|
||||||
FetchEnergyManagementDataHelper.loadEnergyConsumptionByPhases(
|
FetchEnergyManagementDataHelper
|
||||||
|
.loadEnergyConsumptionByPhases(
|
||||||
context,
|
context,
|
||||||
powerClampUuid: device.uuid,
|
powerClampUuid: device.uuid,
|
||||||
selectedDate:
|
selectedDate: context
|
||||||
context.read<AnalyticsDatePickerBloc>().state.monthlyDate,
|
.read<AnalyticsDatePickerBloc>()
|
||||||
|
.state
|
||||||
|
.monthlyDate,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -91,7 +94,8 @@ class PowerClampEnergyDataWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 14),
|
const SizedBox(height: 14),
|
||||||
const Expanded(flex: 3, child: EnergyConsumptionByPhasesChartBox()),
|
const Expanded(
|
||||||
|
flex: 3, child: EnergyConsumptionByPhasesChartBox()),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -140,9 +140,9 @@ class PowerClampPhasesDataWidget extends StatelessWidget {
|
|||||||
|
|
||||||
String _formatCurrentValue(String? value) {
|
String _formatCurrentValue(String? value) {
|
||||||
if (value == null) return '--';
|
if (value == null) return '--';
|
||||||
String str = value;
|
var str = value;
|
||||||
if (str.isEmpty || str == '--') return '--';
|
if (str.isEmpty || str == '--') return '--';
|
||||||
str = str.replaceAll(RegExp(r'[^0-9]'), '');
|
str = str.replaceAll(RegExp('[^0-9]'), '');
|
||||||
if (str.isEmpty) return '--';
|
if (str.isEmpty) return '--';
|
||||||
if (str.length == 1) return '${str[0]}.0';
|
if (str.length == 1) return '${str[0]}.0';
|
||||||
return '${str[0]}.${str.substring(1)}';
|
return '${str[0]}.${str.substring(1)}';
|
||||||
@ -150,9 +150,9 @@ class PowerClampPhasesDataWidget extends StatelessWidget {
|
|||||||
|
|
||||||
String _formatPowerFactor(String? value) {
|
String _formatPowerFactor(String? value) {
|
||||||
if (value == null) return '--';
|
if (value == null) return '--';
|
||||||
String str = value;
|
var str = value;
|
||||||
if (str.isEmpty || str == '--') return '--';
|
if (str.isEmpty || str == '--') return '--';
|
||||||
str = str.replaceAll(RegExp(r'[^0-9]'), '');
|
str = str.replaceAll(RegExp('[^0-9]'), '');
|
||||||
if (str.isEmpty) return '--';
|
if (str.isEmpty) return '--';
|
||||||
final intValue = int.tryParse(str);
|
final intValue = int.tryParse(str);
|
||||||
if (intValue == null) return '--';
|
if (intValue == null) return '--';
|
||||||
@ -162,9 +162,9 @@ class PowerClampPhasesDataWidget extends StatelessWidget {
|
|||||||
|
|
||||||
String _formatVoltage(String? value) {
|
String _formatVoltage(String? value) {
|
||||||
if (value == null) return '--';
|
if (value == null) return '--';
|
||||||
String str = value;
|
var str = value;
|
||||||
if (str.isEmpty || str == '--') return '--';
|
if (str.isEmpty || str == '--') return '--';
|
||||||
str = str.replaceAll(RegExp(r'[^0-9]'), '');
|
str = str.replaceAll(RegExp('[^0-9]'), '');
|
||||||
if (str.isEmpty) return '--';
|
if (str.isEmpty) return '--';
|
||||||
if (str.length == 1) return '0.${str[0]}';
|
if (str.length == 1) return '0.${str[0]}';
|
||||||
return '${str.substring(0, str.length - 1)}.${str.substring(str.length - 1)}';
|
return '${str.substring(0, str.length - 1)}.${str.substring(str.length - 1)}';
|
||||||
|
@ -29,7 +29,6 @@ class TotalEnergyConsumptionChart extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
duration: Duration.zero,
|
duration: Duration.zero,
|
||||||
curve: Curves.easeIn,
|
curve: Curves.easeIn,
|
||||||
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,8 @@ class TotalEnergyConsumptionChartBox extends StatelessWidget {
|
|||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
ChartsLoadingWidget(
|
ChartsLoadingWidget(
|
||||||
isLoading: state.status == TotalEnergyConsumptionStatus.loading,
|
isLoading:
|
||||||
|
state.status == TotalEnergyConsumptionStatus.loading,
|
||||||
),
|
),
|
||||||
const Expanded(
|
const Expanded(
|
||||||
flex: 3,
|
flex: 3,
|
||||||
|
@ -23,9 +23,11 @@ class OccupancyBloc extends Bloc<OccupancyEvent, OccupancyState> {
|
|||||||
emit(state.copyWith(status: OccupancyStatus.loading));
|
emit(state.copyWith(status: OccupancyStatus.loading));
|
||||||
try {
|
try {
|
||||||
final chartData = await _occupacyService.load(event.param);
|
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) {
|
} on APIException catch (e) {
|
||||||
emit(state.copyWith(status: OccupancyStatus.failure, errorMessage: e.message));
|
emit(state.copyWith(
|
||||||
|
status: OccupancyStatus.failure, errorMessage: e.message));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(state.copyWith(status: OccupancyStatus.failure, errorMessage: '$e'));
|
emit(state.copyWith(status: OccupancyStatus.failure, errorMessage: '$e'));
|
||||||
}
|
}
|
||||||
|
@ -25,15 +25,18 @@ abstract final class FetchOccupancyDataHelper {
|
|||||||
|
|
||||||
final datePickerState = context.read<AnalyticsDatePickerBloc>().state;
|
final datePickerState = context.read<AnalyticsDatePickerBloc>().state;
|
||||||
|
|
||||||
loadAnalyticsDevices(context, communityUuid: communityId, spaceUuid: spaceId);
|
loadAnalyticsDevices(context,
|
||||||
final selectedDevice = context.read<AnalyticsDevicesBloc>().state.selectedDevice;
|
communityUuid: communityId, spaceUuid: spaceId);
|
||||||
|
final selectedDevice =
|
||||||
|
context.read<AnalyticsDevicesBloc>().state.selectedDevice;
|
||||||
|
|
||||||
loadOccupancyChartData(
|
loadOccupancyChartData(
|
||||||
context,
|
context,
|
||||||
spaceUuid: spaceId,
|
spaceUuid: spaceId,
|
||||||
date: datePickerState.monthlyDate,
|
date: datePickerState.monthlyDate,
|
||||||
);
|
);
|
||||||
loadHeatMapData(context, spaceUuid: spaceId, year: datePickerState.yearlyDate);
|
loadHeatMapData(context,
|
||||||
|
spaceUuid: spaceId, year: datePickerState.yearlyDate);
|
||||||
|
|
||||||
if (selectedDevice case final AnalyticsDevice device) {
|
if (selectedDevice case final AnalyticsDevice device) {
|
||||||
context.read<RealtimeDeviceChangesBloc>()
|
context.read<RealtimeDeviceChangesBloc>()
|
||||||
@ -64,7 +67,8 @@ abstract final class FetchOccupancyDataHelper {
|
|||||||
context.read<OccupancyBloc>().add(
|
context.read<OccupancyBloc>().add(
|
||||||
LoadOccupancyEvent(
|
LoadOccupancyEvent(
|
||||||
GetOccupancyParam(
|
GetOccupancyParam(
|
||||||
monthDate: '${date.year}-${date.month.toString().padLeft(2, '0')}',
|
monthDate:
|
||||||
|
'${date.year}-${date.month.toString().padLeft(2, '0')}',
|
||||||
spaceUuid: spaceUuid,
|
spaceUuid: spaceUuid,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -20,9 +20,12 @@ class AnalyticsOccupancyView extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
spacing: 32,
|
spacing: 32,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(height: height * 0.46, child: const OccupancyEndSideBar()),
|
SizedBox(
|
||||||
SizedBox(height: height * 0.5, child: const OccupancyChartBox()),
|
height: height * 0.46, child: const OccupancyEndSideBar()),
|
||||||
SizedBox(height: height * 0.5, child: const OccupancyHeatMapBox()),
|
SizedBox(
|
||||||
|
height: height * 0.5, child: const OccupancyChartBox()),
|
||||||
|
SizedBox(
|
||||||
|
height: height * 0.5, child: const OccupancyHeatMapBox()),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -41,7 +41,8 @@ class OccupancyChart extends StatelessWidget {
|
|||||||
barRods: [
|
barRods: [
|
||||||
BarChartRodData(
|
BarChartRodData(
|
||||||
toY: 100.0,
|
toY: 100.0,
|
||||||
fromY: occupancyValue == 0 ? occupancyValue : occupancyValue + 2.5,
|
fromY:
|
||||||
|
occupancyValue == 0 ? occupancyValue : occupancyValue + 2.5,
|
||||||
color: ColorsManager.graysColor,
|
color: ColorsManager.graysColor,
|
||||||
width: _chartWidth,
|
width: _chartWidth,
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
@ -88,8 +89,8 @@ class OccupancyChart extends StatelessWidget {
|
|||||||
}) {
|
}) {
|
||||||
final data = chartData;
|
final data = chartData;
|
||||||
|
|
||||||
final occupancyValue = double.parse(data[group.x.toInt()].occupancy);
|
final occupancyValue = double.parse(data[group.x].occupancy);
|
||||||
final percentage = '${(occupancyValue).toStringAsFixed(0)}%';
|
final percentage = '${occupancyValue.toStringAsFixed(0)}%';
|
||||||
|
|
||||||
return BarTooltipItem(
|
return BarTooltipItem(
|
||||||
percentage,
|
percentage,
|
||||||
@ -116,7 +117,7 @@ class OccupancyChart extends StatelessWidget {
|
|||||||
alignment: AlignmentDirectional.centerStart,
|
alignment: AlignmentDirectional.centerStart,
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
child: Text(
|
child: Text(
|
||||||
'${(value).toStringAsFixed(0)}%',
|
'${value.toStringAsFixed(0)}%',
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: ColorsManager.greyColor,
|
color: ColorsManager.greyColor,
|
||||||
|
@ -44,13 +44,15 @@ class OccupancyChartBox extends StatelessWidget {
|
|||||||
child: AnalyticsDateFilterButton(
|
child: AnalyticsDateFilterButton(
|
||||||
onDateSelected: (DateTime value) {
|
onDateSelected: (DateTime value) {
|
||||||
context.read<AnalyticsDatePickerBloc>().add(
|
context.read<AnalyticsDatePickerBloc>().add(
|
||||||
UpdateAnalyticsDatePickerEvent(montlyDate: value),
|
UpdateAnalyticsDatePickerEvent(
|
||||||
|
montlyDate: value),
|
||||||
);
|
);
|
||||||
if (spaceTreeState.selectedSpaces.isNotEmpty) {
|
if (spaceTreeState.selectedSpaces.isNotEmpty) {
|
||||||
FetchOccupancyDataHelper.loadOccupancyChartData(
|
FetchOccupancyDataHelper.loadOccupancyChartData(
|
||||||
context,
|
context,
|
||||||
spaceUuid:
|
spaceUuid:
|
||||||
spaceTreeState.selectedSpaces.firstOrNull ?? '',
|
spaceTreeState.selectedSpaces.firstOrNull ??
|
||||||
|
'',
|
||||||
date: value,
|
date: value,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -44,13 +44,15 @@ class OccupancyHeatMapBox extends StatelessWidget {
|
|||||||
child: AnalyticsDateFilterButton(
|
child: AnalyticsDateFilterButton(
|
||||||
onDateSelected: (DateTime value) {
|
onDateSelected: (DateTime value) {
|
||||||
context.read<AnalyticsDatePickerBloc>().add(
|
context.read<AnalyticsDatePickerBloc>().add(
|
||||||
UpdateAnalyticsDatePickerEvent(yearlyDate: value),
|
UpdateAnalyticsDatePickerEvent(
|
||||||
|
yearlyDate: value),
|
||||||
);
|
);
|
||||||
if (spaceTreeState.selectedSpaces.isNotEmpty) {
|
if (spaceTreeState.selectedSpaces.isNotEmpty) {
|
||||||
FetchOccupancyDataHelper.loadHeatMapData(
|
FetchOccupancyDataHelper.loadHeatMapData(
|
||||||
context,
|
context,
|
||||||
spaceUuid:
|
spaceUuid:
|
||||||
spaceTreeState.selectedSpaces.firstOrNull ?? '',
|
spaceTreeState.selectedSpaces.firstOrNull ??
|
||||||
|
'',
|
||||||
year: value,
|
year: value,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,11 @@ class OccupancyPainter extends CustomPainter {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
final Paint fillPaint = Paint();
|
final fillPaint = Paint();
|
||||||
final Paint borderPaint = Paint()
|
final borderPaint = Paint()
|
||||||
..color = ColorsManager.grayBorder.withValues(alpha: 0.4)
|
..color = ColorsManager.grayBorder.withValues(alpha: 0.4)
|
||||||
..style = PaintingStyle.stroke;
|
..style = PaintingStyle.stroke;
|
||||||
final Paint hoveredBorderPaint = Paint()
|
final hoveredBorderPaint = Paint()
|
||||||
..color = Colors.black
|
..color = Colors.black
|
||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = 1.5;
|
..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, y), Offset(x, y + cellSize), borderPaint);
|
||||||
canvas.drawLine(Offset(x + cellSize, y), Offset(x + cellSize, y + cellSize),
|
canvas.drawLine(Offset(x + cellSize, y),
|
||||||
borderPaint);
|
Offset(x + cellSize, y + cellSize), borderPaint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _drawDashedLine(Canvas canvas, Offset start, Offset end, Paint paint) {
|
void _drawDashedLine(Canvas canvas, Offset start, Offset end, Paint paint) {
|
||||||
const double dashWidth = 2.0;
|
const dashWidth = 2.0;
|
||||||
const double dashSpace = 4.0;
|
const dashSpace = 4.0;
|
||||||
final double totalLength = (end - start).distance;
|
final totalLength = (end - start).distance;
|
||||||
final Offset direction = (end - start) / (end - start).distance;
|
final direction = (end - start) / (end - start).distance;
|
||||||
|
|
||||||
double currentLength = 0.0;
|
var currentLength = 0.0;
|
||||||
while (currentLength < totalLength) {
|
while (currentLength < totalLength) {
|
||||||
final Offset dashStart = start + direction * currentLength;
|
final dashStart = start + direction * currentLength;
|
||||||
final double nextLength = currentLength + dashWidth;
|
final nextLength = currentLength + dashWidth;
|
||||||
final Offset dashEnd =
|
final dashEnd = start +
|
||||||
start + direction * (nextLength < totalLength ? nextLength : totalLength);
|
direction * (nextLength < totalLength ? nextLength : totalLength);
|
||||||
canvas.drawLine(dashStart, dashEnd, paint);
|
canvas.drawLine(dashStart, dashEnd, paint);
|
||||||
currentLength = nextLength + dashSpace;
|
currentLength = nextLength + dashSpace;
|
||||||
}
|
}
|
||||||
|
@ -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/params/get_air_quality_distribution_param.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/services/air_quality_distribution/air_quality_distribution_service.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();
|
final _random = Random();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -43,7 +44,6 @@ class FakeAirQualityDistributionService implements AirQualityDistributionService
|
|||||||
name: 'poor',
|
name: 'poor',
|
||||||
percentage: nonNullValues[2],
|
percentage: nonNullValues[2],
|
||||||
type: AqiType.hcho.code,
|
type: AqiType.hcho.code,
|
||||||
|
|
||||||
),
|
),
|
||||||
AirQualityPercentageData(
|
AirQualityPercentageData(
|
||||||
name: 'unhealthy',
|
name: 'unhealthy',
|
||||||
@ -71,7 +71,7 @@ class FakeAirQualityDistributionService implements AirQualityDistributionService
|
|||||||
List<bool> nullMask,
|
List<bool> nullMask,
|
||||||
) {
|
) {
|
||||||
double nonNullSum = 0;
|
double nonNullSum = 0;
|
||||||
for (int i = 0; i < originalValues.length; i++) {
|
for (var i = 0; i < originalValues.length; i++) {
|
||||||
if (!nullMask[i]) {
|
if (!nullMask[i]) {
|
||||||
nonNullSum += originalValues[i];
|
nonNullSum += originalValues[i];
|
||||||
}
|
}
|
||||||
|
@ -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/pages/analytics/services/air_quality_distribution/air_quality_distribution_service.dart';
|
||||||
import 'package:syncrow_web/services/api/http_service.dart';
|
import 'package:syncrow_web/services/api/http_service.dart';
|
||||||
|
|
||||||
class RemoteAirQualityDistributionService implements AirQualityDistributionService {
|
class RemoteAirQualityDistributionService
|
||||||
|
implements AirQualityDistributionService {
|
||||||
RemoteAirQualityDistributionService(this._httpService);
|
RemoteAirQualityDistributionService(this._httpService);
|
||||||
|
|
||||||
final HTTPService _httpService;
|
final HTTPService _httpService;
|
||||||
|
@ -16,7 +16,8 @@ class AnalyticsDevicesServiceDelegate implements AnalyticsDevicesService {
|
|||||||
GetAnalyticsDevicesParam param,
|
GetAnalyticsDevicesParam param,
|
||||||
) {
|
) {
|
||||||
return switch (param.requestType) {
|
return switch (param.requestType) {
|
||||||
AnalyticsDeviceRequestType.occupancy => _occupancyService.getDevices(param),
|
AnalyticsDeviceRequestType.occupancy =>
|
||||||
|
_occupancyService.getDevices(param),
|
||||||
AnalyticsDeviceRequestType.energyManagement =>
|
AnalyticsDeviceRequestType.energyManagement =>
|
||||||
_energyManagementService.getDevices(param),
|
_energyManagementService.getDevices(param),
|
||||||
};
|
};
|
||||||
|
@ -14,7 +14,8 @@ final class RemoteEnergyManagementAnalyticsDevicesService
|
|||||||
static const _defaultErrorMessage = 'Failed to load analytics devices';
|
static const _defaultErrorMessage = 'Failed to load analytics devices';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<AnalyticsDevice>> getDevices(GetAnalyticsDevicesParam param) async {
|
Future<List<AnalyticsDevice>> getDevices(
|
||||||
|
GetAnalyticsDevicesParam param) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: '/devices-space-community/recursive-child',
|
path: '/devices-space-community/recursive-child',
|
||||||
@ -37,7 +38,8 @@ final class RemoteEnergyManagementAnalyticsDevicesService
|
|||||||
final message = e.response?.data as Map<String, dynamic>?;
|
final message = e.response?.data as Map<String, dynamic>?;
|
||||||
final error = message?['error'] as Map<String, dynamic>?;
|
final error = message?['error'] as Map<String, dynamic>?;
|
||||||
final errorMessage = error?['error'] as String? ?? '';
|
final errorMessage = error?['error'] as String? ?? '';
|
||||||
final formattedErrorMessage = [_defaultErrorMessage, errorMessage].join(': ');
|
final formattedErrorMessage =
|
||||||
|
[_defaultErrorMessage, errorMessage].join(': ');
|
||||||
throw APIException(formattedErrorMessage);
|
throw APIException(formattedErrorMessage);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw APIException('$_defaultErrorMessage: $e');
|
throw APIException('$_defaultErrorMessage: $e');
|
||||||
|
@ -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/api_exception.dart';
|
||||||
import 'package:syncrow_web/services/api/http_service.dart';
|
import 'package:syncrow_web/services/api/http_service.dart';
|
||||||
|
|
||||||
class RemoteOccupancyAnalyticsDevicesService implements AnalyticsDevicesService {
|
class RemoteOccupancyAnalyticsDevicesService
|
||||||
|
implements AnalyticsDevicesService {
|
||||||
const RemoteOccupancyAnalyticsDevicesService(this._httpService);
|
const RemoteOccupancyAnalyticsDevicesService(this._httpService);
|
||||||
|
|
||||||
final HTTPService _httpService;
|
final HTTPService _httpService;
|
||||||
@ -14,7 +15,8 @@ class RemoteOccupancyAnalyticsDevicesService implements AnalyticsDevicesService
|
|||||||
static const _defaultErrorMessage = 'Failed to load analytics devices';
|
static const _defaultErrorMessage = 'Failed to load analytics devices';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<AnalyticsDevice>> getDevices(GetAnalyticsDevicesParam param) async {
|
Future<List<AnalyticsDevice>> getDevices(
|
||||||
|
GetAnalyticsDevicesParam param) async {
|
||||||
try {
|
try {
|
||||||
final requests = await Future.wait<List<AnalyticsDevice>>(
|
final requests = await Future.wait<List<AnalyticsDevice>>(
|
||||||
param.deviceTypes.map((e) {
|
param.deviceTypes.map((e) {
|
||||||
@ -34,15 +36,18 @@ class RemoteOccupancyAnalyticsDevicesService implements AnalyticsDevicesService
|
|||||||
final message = e.response?.data as Map<String, dynamic>?;
|
final message = e.response?.data as Map<String, dynamic>?;
|
||||||
final error = message?['error'] as Map<String, dynamic>?;
|
final error = message?['error'] as Map<String, dynamic>?;
|
||||||
final errorMessage = error?['error'] as String? ?? '';
|
final errorMessage = error?['error'] as String? ?? '';
|
||||||
final formattedErrorMessage = [_defaultErrorMessage, errorMessage].join(': ');
|
final formattedErrorMessage =
|
||||||
|
[_defaultErrorMessage, errorMessage].join(': ');
|
||||||
throw APIException(formattedErrorMessage);
|
throw APIException(formattedErrorMessage);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
final formattedErrorMessage = [_defaultErrorMessage, e.toString()].join(': ');
|
final formattedErrorMessage =
|
||||||
|
[_defaultErrorMessage, e.toString()].join(': ');
|
||||||
throw APIException(formattedErrorMessage);
|
throw APIException(formattedErrorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<AnalyticsDevice>> _makeRequest(GetAnalyticsDevicesParam param) async {
|
Future<List<AnalyticsDevice>> _makeRequest(
|
||||||
|
GetAnalyticsDevicesParam param) async {
|
||||||
try {
|
try {
|
||||||
final projectUuid = await ProjectManager.getProjectUUID();
|
final projectUuid = await ProjectManager.getProjectUUID();
|
||||||
|
|
||||||
@ -69,7 +74,8 @@ class RemoteOccupancyAnalyticsDevicesService implements AnalyticsDevicesService
|
|||||||
final message = e.response?.data as Map<String, dynamic>?;
|
final message = e.response?.data as Map<String, dynamic>?;
|
||||||
final error = message?['error'] as Map<String, dynamic>?;
|
final error = message?['error'] as Map<String, dynamic>?;
|
||||||
final errorMessage = error?['error'] as String? ?? '';
|
final errorMessage = error?['error'] as String? ?? '';
|
||||||
final formattedErrorMessage = [_defaultErrorMessage, errorMessage].join(': ');
|
final formattedErrorMessage =
|
||||||
|
[_defaultErrorMessage, errorMessage].join(': ');
|
||||||
throw APIException(formattedErrorMessage);
|
throw APIException(formattedErrorMessage);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw APIException('$_defaultErrorMessage: $e');
|
throw APIException('$_defaultErrorMessage: $e');
|
||||||
|
@ -34,7 +34,7 @@ class DeviceLocationDetailsServiceDecorator implements DeviceLocationService {
|
|||||||
|
|
||||||
return deviceLocationInfo;
|
return deviceLocationInfo;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw Exception('Failed to load device location info: ${e.toString()}');
|
throw Exception('Failed to load device location info: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,8 @@ final class RemoteEnergyConsumptionByPhasesService
|
|||||||
|
|
||||||
final HTTPService _httpService;
|
final HTTPService _httpService;
|
||||||
|
|
||||||
static const _defaultErrorMessage = 'Failed to load energy consumption per phase';
|
static const _defaultErrorMessage =
|
||||||
|
'Failed to load energy consumption per phase';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<PhasesEnergyConsumption>> load(
|
Future<List<PhasesEnergyConsumption>> load(
|
||||||
@ -36,7 +37,8 @@ final class RemoteEnergyConsumptionByPhasesService
|
|||||||
final message = e.response?.data as Map<String, dynamic>?;
|
final message = e.response?.data as Map<String, dynamic>?;
|
||||||
final error = message?['error'] as Map<String, dynamic>?;
|
final error = message?['error'] as Map<String, dynamic>?;
|
||||||
final errorMessage = error?['error'] as String? ?? '';
|
final errorMessage = error?['error'] as String? ?? '';
|
||||||
final formattedErrorMessage = [_defaultErrorMessage, errorMessage].join(': ');
|
final formattedErrorMessage =
|
||||||
|
[_defaultErrorMessage, errorMessage].join(': ');
|
||||||
throw APIException(formattedErrorMessage);
|
throw APIException(formattedErrorMessage);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');
|
final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');
|
||||||
|
@ -13,7 +13,8 @@ class RemoteEnergyConsumptionPerDeviceService
|
|||||||
|
|
||||||
final HTTPService _httpService;
|
final HTTPService _httpService;
|
||||||
|
|
||||||
static const _defaultErrorMessage = 'Failed to load energy consumption per device';
|
static const _defaultErrorMessage =
|
||||||
|
'Failed to load energy consumption per device';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<DeviceEnergyDataModel>> load(
|
Future<List<DeviceEnergyDataModel>> load(
|
||||||
@ -31,7 +32,8 @@ class RemoteEnergyConsumptionPerDeviceService
|
|||||||
final message = e.response?.data as Map<String, dynamic>?;
|
final message = e.response?.data as Map<String, dynamic>?;
|
||||||
final error = message?['error'] as Map<String, dynamic>?;
|
final error = message?['error'] as Map<String, dynamic>?;
|
||||||
final errorMessage = error?['error'] as String? ?? '';
|
final errorMessage = error?['error'] as String? ?? '';
|
||||||
final formattedErrorMessage = [_defaultErrorMessage, errorMessage].join(': ');
|
final formattedErrorMessage =
|
||||||
|
[_defaultErrorMessage, errorMessage].join(': ');
|
||||||
throw APIException(formattedErrorMessage);
|
throw APIException(formattedErrorMessage);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');
|
final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');
|
||||||
@ -59,7 +61,8 @@ abstract final class _EnergyConsumptionPerDeviceMapper {
|
|||||||
final energyJson = data as Map<String, dynamic>;
|
final energyJson = data as Map<String, dynamic>;
|
||||||
return EnergyDataModel(
|
return EnergyDataModel(
|
||||||
date: DateTime.parse(energyJson['date'] as String),
|
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(),
|
}).toList(),
|
||||||
);
|
);
|
||||||
|
@ -33,7 +33,8 @@ final class RemoteOccupancyService implements OccupacyService {
|
|||||||
final message = e.response?.data as Map<String, dynamic>?;
|
final message = e.response?.data as Map<String, dynamic>?;
|
||||||
final error = message?['error'] as Map<String, dynamic>?;
|
final error = message?['error'] as Map<String, dynamic>?;
|
||||||
final errorMessage = error?['error'] as String? ?? '';
|
final errorMessage = error?['error'] as String? ?? '';
|
||||||
final formattedErrorMessage = [_defaultErrorMessage, errorMessage].join(': ');
|
final formattedErrorMessage =
|
||||||
|
[_defaultErrorMessage, errorMessage].join(': ');
|
||||||
throw APIException(formattedErrorMessage);
|
throw APIException(formattedErrorMessage);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');
|
final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');
|
||||||
|
@ -13,7 +13,8 @@ final class RemoteOccupancyHeatMapService implements OccupancyHeatMapService {
|
|||||||
static const _defaultErrorMessage = 'Failed to load occupancy heat map';
|
static const _defaultErrorMessage = 'Failed to load occupancy heat map';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<OccupancyHeatMapModel>> load(GetOccupancyHeatMapParam param) async {
|
Future<List<OccupancyHeatMapModel>> load(
|
||||||
|
GetOccupancyHeatMapParam param) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: '/occupancy/heat-map/space/${param.spaceUuid}',
|
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 dailyData = json['data'] as List<dynamic>? ?? <dynamic>[];
|
||||||
|
|
||||||
final result = dailyData.map(
|
final result = dailyData.map(
|
||||||
(json) => OccupancyHeatMapModel.fromJson(json as Map<String, dynamic>),
|
(json) =>
|
||||||
|
OccupancyHeatMapModel.fromJson(json as Map<String, dynamic>),
|
||||||
);
|
);
|
||||||
|
|
||||||
return result.toList();
|
return result.toList();
|
||||||
@ -36,7 +38,8 @@ final class RemoteOccupancyHeatMapService implements OccupancyHeatMapService {
|
|||||||
final message = e.response?.data as Map<String, dynamic>?;
|
final message = e.response?.data as Map<String, dynamic>?;
|
||||||
final error = message?['error'] as Map<String, dynamic>?;
|
final error = message?['error'] as Map<String, dynamic>?;
|
||||||
final errorMessage = error?['error'] as String? ?? '';
|
final errorMessage = error?['error'] as String? ?? '';
|
||||||
final formattedErrorMessage = [_defaultErrorMessage, errorMessage].join(': ');
|
final formattedErrorMessage =
|
||||||
|
[_defaultErrorMessage, errorMessage].join(': ');
|
||||||
throw APIException(formattedErrorMessage);
|
throw APIException(formattedErrorMessage);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');
|
final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');
|
||||||
|
@ -28,7 +28,8 @@ final class RemotePowerClampInfoService implements PowerClampInfoService {
|
|||||||
final message = e.response?.data as Map<String, dynamic>?;
|
final message = e.response?.data as Map<String, dynamic>?;
|
||||||
final error = message?['error'] as Map<String, dynamic>?;
|
final error = message?['error'] as Map<String, dynamic>?;
|
||||||
final errorMessage = error?['error'] as String? ?? '';
|
final errorMessage = error?['error'] as String? ?? '';
|
||||||
final formattedErrorMessage = [_defaultErrorMessage, errorMessage].join(': ');
|
final formattedErrorMessage =
|
||||||
|
[_defaultErrorMessage, errorMessage].join(': ');
|
||||||
throw APIException(formattedErrorMessage);
|
throw APIException(formattedErrorMessage);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');
|
final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');
|
||||||
|
@ -6,7 +6,7 @@ import 'package:syncrow_web/pages/analytics/services/range_of_aqi/range_of_aqi_s
|
|||||||
class FakeRangeOfAqiService implements RangeOfAqiService {
|
class FakeRangeOfAqiService implements RangeOfAqiService {
|
||||||
@override
|
@override
|
||||||
Future<List<RangeOfAqi>> load(GetRangeOfAqiParam param) async {
|
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;
|
final random = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
|
||||||
return List.generate(30, (index) {
|
return List.generate(30, (index) {
|
||||||
@ -19,14 +19,20 @@ class FakeRangeOfAqiService implements RangeOfAqiService {
|
|||||||
final avg = (min + avgDelta).clamp(0.0, 301.0);
|
final avg = (min + avgDelta).clamp(0.0, 301.0);
|
||||||
final max = (avg + maxDelta).clamp(0.0, 301.0);
|
final max = (avg + maxDelta).clamp(0.0, 301.0);
|
||||||
|
|
||||||
return RangeOfAqi(
|
return RangeOfAqi(
|
||||||
data: [
|
data: [
|
||||||
RangeOfAqiValue(type: AqiType.aqi.code, min: min, average: avg, max: max),
|
RangeOfAqiValue(
|
||||||
RangeOfAqiValue(type: AqiType.pm25.code, min: min, average: avg, max: max),
|
type: AqiType.aqi.code, min: min, average: avg, max: max),
|
||||||
RangeOfAqiValue(type: AqiType.pm10.code, min: min, average: avg, max: max),
|
RangeOfAqiValue(
|
||||||
RangeOfAqiValue(type: AqiType.hcho.code, min: min, average: avg, max: max),
|
type: AqiType.pm25.code, min: min, average: avg, max: max),
|
||||||
RangeOfAqiValue(type: AqiType.tvoc.code, min: min, average: avg, max: max),
|
RangeOfAqiValue(
|
||||||
RangeOfAqiValue(type: AqiType.co2.code, min: min, average: avg, max: max),
|
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,
|
date: date,
|
||||||
);
|
);
|
||||||
|
@ -3,4 +3,4 @@ import 'package:syncrow_web/pages/analytics/params/get_range_of_aqi_param.dart';
|
|||||||
|
|
||||||
abstract interface class RangeOfAqiService {
|
abstract interface class RangeOfAqiService {
|
||||||
Future<List<RangeOfAqi>> load(GetRangeOfAqiParam param);
|
Future<List<RangeOfAqi>> load(GetRangeOfAqiParam param);
|
||||||
}
|
}
|
||||||
|
@ -2,4 +2,4 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/device_sta
|
|||||||
|
|
||||||
abstract interface class RealtimeDeviceService {
|
abstract interface class RealtimeDeviceService {
|
||||||
Stream<List<Status>> subscribe(String deviceId);
|
Stream<List<Status>> subscribe(String deviceId);
|
||||||
}
|
}
|
||||||
|
@ -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/api_exception.dart';
|
||||||
import 'package:syncrow_web/services/api/http_service.dart';
|
import 'package:syncrow_web/services/api/http_service.dart';
|
||||||
|
|
||||||
class RemoteTotalEnergyConsumptionService implements TotalEnergyConsumptionService {
|
class RemoteTotalEnergyConsumptionService
|
||||||
|
implements TotalEnergyConsumptionService {
|
||||||
const RemoteTotalEnergyConsumptionService(this._httpService);
|
const RemoteTotalEnergyConsumptionService(this._httpService);
|
||||||
|
|
||||||
final HTTPService _httpService;
|
final HTTPService _httpService;
|
||||||
@ -29,7 +30,8 @@ class RemoteTotalEnergyConsumptionService implements TotalEnergyConsumptionServi
|
|||||||
final message = e.response?.data as Map<String, dynamic>?;
|
final message = e.response?.data as Map<String, dynamic>?;
|
||||||
final error = message?['error'] as Map<String, dynamic>?;
|
final error = message?['error'] as Map<String, dynamic>?;
|
||||||
final errorMessage = error?['error'] as String? ?? '';
|
final errorMessage = error?['error'] as String? ?? '';
|
||||||
final formattedErrorMessage = [_defaultErrorMessage, errorMessage].join(': ');
|
final formattedErrorMessage =
|
||||||
|
[_defaultErrorMessage, errorMessage].join(': ');
|
||||||
throw APIException(formattedErrorMessage);
|
throw APIException(formattedErrorMessage);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');
|
final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');
|
||||||
|
@ -75,7 +75,8 @@ class AnalyticsSidebarHeader extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
SelectableText(
|
SelectableText(
|
||||||
context.watch<AnalyticsDevicesBloc>().state.selectedDevice?.uuid ?? 'N/A',
|
context.watch<AnalyticsDevicesBloc>().state.selectedDevice?.uuid ??
|
||||||
|
'N/A',
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
color: ColorsManager.blackColor,
|
color: ColorsManager.blackColor,
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
|
@ -36,7 +36,8 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
|
|
||||||
////////////////////////////// forget password //////////////////////////////////
|
////////////////////////////// forget password //////////////////////////////////
|
||||||
final TextEditingController forgetEmailController = TextEditingController();
|
final TextEditingController forgetEmailController = TextEditingController();
|
||||||
final TextEditingController forgetPasswordController = TextEditingController();
|
final TextEditingController forgetPasswordController =
|
||||||
|
TextEditingController();
|
||||||
final TextEditingController forgetOtp = TextEditingController();
|
final TextEditingController forgetOtp = TextEditingController();
|
||||||
final forgetFormKey = GlobalKey<FormState>();
|
final forgetFormKey = GlobalKey<FormState>();
|
||||||
final forgetEmailKey = GlobalKey<FormState>();
|
final forgetEmailKey = GlobalKey<FormState>();
|
||||||
@ -53,7 +54,8 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_remainingTime = 1;
|
_remainingTime = 1;
|
||||||
add(UpdateTimerEvent(remainingTime: _remainingTime, isButtonEnabled: false));
|
add(UpdateTimerEvent(
|
||||||
|
remainingTime: _remainingTime, isButtonEnabled: false));
|
||||||
try {
|
try {
|
||||||
forgetEmailValidate = '';
|
forgetEmailValidate = '';
|
||||||
_remainingTime = (await AuthenticationAPI.sendOtp(
|
_remainingTime = (await AuthenticationAPI.sendOtp(
|
||||||
@ -62,7 +64,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
if (e.response!.statusCode == 400) {
|
if (e.response!.statusCode == 400) {
|
||||||
final errorData = e.response!.data;
|
final errorData = e.response!.data;
|
||||||
String errorMessage = errorData['message'];
|
final String errorMessage = errorData['message'];
|
||||||
if (errorMessage == 'User not found') {
|
if (errorMessage == 'User not found') {
|
||||||
validate = 'Invalid Credential';
|
validate = 'Invalid Credential';
|
||||||
emit(AuthInitialState());
|
emit(AuthInitialState());
|
||||||
@ -90,7 +92,8 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
add(const UpdateTimerEvent(remainingTime: 0, isButtonEnabled: true));
|
add(const UpdateTimerEvent(remainingTime: 0, isButtonEnabled: true));
|
||||||
} else {
|
} 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));
|
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> changePassword(
|
Future<void> changePassword(
|
||||||
ChangePasswordEvent event, Emitter<AuthState> emit) async {
|
ChangePasswordEvent event, Emitter<AuthState> emit) async {
|
||||||
emit(LoadingForgetState());
|
emit(LoadingForgetState());
|
||||||
try {
|
try {
|
||||||
var response = await AuthenticationAPI.verifyOtp(
|
final response = await AuthenticationAPI.verifyOtp(
|
||||||
email: forgetEmailController.text, otpCode: forgetOtp.text);
|
email: forgetEmailController.text, otpCode: forgetOtp.text);
|
||||||
if (response == true) {
|
if (response == true) {
|
||||||
await AuthenticationAPI.forgetPassword(
|
await AuthenticationAPI.forgetPassword(
|
||||||
@ -122,7 +125,6 @@ Future<void> changePassword(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String? validateCode(String? value) {
|
String? validateCode(String? value) {
|
||||||
if (value == null || value.isEmpty) {
|
if (value == null || value.isEmpty) {
|
||||||
return 'Code is required';
|
return 'Code is required';
|
||||||
@ -131,7 +133,9 @@ Future<void> changePassword(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onUpdateTimer(UpdateTimerEvent event, Emitter<AuthState> emit) {
|
void _onUpdateTimer(UpdateTimerEvent event, Emitter<AuthState> emit) {
|
||||||
emit(TimerState(isButtonEnabled: event.isButtonEnabled, remainingTime: event.remainingTime));
|
emit(TimerState(
|
||||||
|
isButtonEnabled: event.isButtonEnabled,
|
||||||
|
remainingTime: event.remainingTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////// login /////////////////////////////////////
|
///////////////////////////////////// login /////////////////////////////////////
|
||||||
@ -151,8 +155,7 @@ Future<void> changePassword(
|
|||||||
static UserModel? user;
|
static UserModel? user;
|
||||||
bool showValidationMessage = false;
|
bool showValidationMessage = false;
|
||||||
|
|
||||||
|
Future<void> _login(LoginButtonPressed event, Emitter<AuthState> emit) async {
|
||||||
void _login(LoginButtonPressed event, Emitter<AuthState> emit) async {
|
|
||||||
emit(AuthLoading());
|
emit(AuthLoading());
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
try {
|
try {
|
||||||
@ -179,7 +182,7 @@ Future<void> changePassword(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (token.accessTokenIsNotEmpty) {
|
if (token.accessTokenIsNotEmpty) {
|
||||||
FlutterSecureStorage storage = const FlutterSecureStorage();
|
const storage = FlutterSecureStorage();
|
||||||
await storage.write(
|
await storage.write(
|
||||||
key: Token.loginAccessTokenKey, value: token.accessToken);
|
key: Token.loginAccessTokenKey, value: token.accessToken);
|
||||||
const FlutterSecureStorage().write(
|
const FlutterSecureStorage().write(
|
||||||
@ -197,8 +200,7 @@ Future<void> changePassword(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void checkBoxToggle(
|
||||||
checkBoxToggle(
|
|
||||||
CheckBoxEvent event,
|
CheckBoxEvent event,
|
||||||
Emitter<AuthState> emit,
|
Emitter<AuthState> emit,
|
||||||
) {
|
) {
|
||||||
@ -277,12 +279,12 @@ Future<void> changePassword(
|
|||||||
if (value == null || value.isEmpty) {
|
if (value == null || value.isEmpty) {
|
||||||
return 'Please enter your password';
|
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');
|
validationErrors.add(' - one lowercase letter');
|
||||||
}
|
}
|
||||||
if (!RegExp(r'^(?=.*[A-Z])').hasMatch(value)) {
|
if (!RegExp('^(?=.*[A-Z])').hasMatch(value)) {
|
||||||
validationErrors.add(' - one uppercase letter');
|
validationErrors.add(' - one uppercase letter');
|
||||||
}
|
}
|
||||||
if (!RegExp(r'^(?=.*\d)').hasMatch(value)) {
|
if (!RegExp(r'^(?=.*\d)').hasMatch(value)) {
|
||||||
@ -304,7 +306,7 @@ Future<void> changePassword(
|
|||||||
|
|
||||||
String? fullNameValidator(String? value) {
|
String? fullNameValidator(String? value) {
|
||||||
if (value == null) return 'Full name is required';
|
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) {
|
if (withoutExtraSpaces.length < 2 || withoutExtraSpaces.length > 30) {
|
||||||
return 'Full name must be between 2 and 30 characters long';
|
return 'Full name must be between 2 and 30 characters long';
|
||||||
}
|
}
|
||||||
@ -339,12 +341,14 @@ Future<void> changePassword(
|
|||||||
static Future<String> getTokenAndValidate() async {
|
static Future<String> getTokenAndValidate() async {
|
||||||
try {
|
try {
|
||||||
const storage = FlutterSecureStorage();
|
const storage = FlutterSecureStorage();
|
||||||
final firstLaunch =
|
final firstLaunch = await SharedPreferencesHelper.readBoolFromSP(
|
||||||
await SharedPreferencesHelper.readBoolFromSP(StringsManager.firstLaunch) ?? true;
|
StringsManager.firstLaunch) ??
|
||||||
|
true;
|
||||||
if (firstLaunch) {
|
if (firstLaunch) {
|
||||||
storage.deleteAll();
|
storage.deleteAll();
|
||||||
}
|
}
|
||||||
await SharedPreferencesHelper.saveBoolToSP(StringsManager.firstLaunch, false);
|
await SharedPreferencesHelper.saveBoolToSP(
|
||||||
|
StringsManager.firstLaunch, false);
|
||||||
final value = await storage.read(key: Token.loginAccessTokenKey) ?? '';
|
final value = await storage.read(key: Token.loginAccessTokenKey) ?? '';
|
||||||
if (value.isEmpty) {
|
if (value.isEmpty) {
|
||||||
return 'Token not found';
|
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 {
|
try {
|
||||||
emit(AuthLoading());
|
emit(AuthLoading());
|
||||||
regionList = await AuthenticationAPI.fetchRegion();
|
regionList = await AuthenticationAPI.fetchRegion();
|
||||||
@ -389,15 +394,17 @@ Future<void> changePassword(
|
|||||||
}
|
}
|
||||||
|
|
||||||
String formattedTime(int time) {
|
String formattedTime(int time) {
|
||||||
final int days = (time / 86400).floor(); // 86400 seconds in a day
|
final days = (time / 86400).floor(); // 86400 seconds in a day
|
||||||
final int hours = ((time % 86400) / 3600).floor();
|
final hours = ((time % 86400) / 3600).floor();
|
||||||
final int minutes = (((time % 86400) % 3600) / 60).floor();
|
final minutes = (((time % 86400) % 3600) / 60).floor();
|
||||||
final int seconds = (((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) '${days}d', // Append 'd' for days
|
||||||
if (days > 0 || hours > 0)
|
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'),
|
minutes.toString().padLeft(2, '0'),
|
||||||
seconds.toString().padLeft(2, '0'),
|
seconds.toString().padLeft(2, '0'),
|
||||||
].join(':');
|
].join(':');
|
||||||
@ -417,7 +424,7 @@ Future<void> changePassword(
|
|||||||
return checkValidate;
|
return checkValidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
changeValidate(
|
void changeValidate(
|
||||||
ChangeValidateEvent event,
|
ChangeValidateEvent event,
|
||||||
Emitter<AuthState> emit,
|
Emitter<AuthState> emit,
|
||||||
) {
|
) {
|
||||||
@ -426,7 +433,7 @@ Future<void> changePassword(
|
|||||||
emit(LoginInitial());
|
emit(LoginInitial());
|
||||||
}
|
}
|
||||||
|
|
||||||
changeForgetValidate(
|
void changeForgetValidate(
|
||||||
ChangeValidateEvent event,
|
ChangeValidateEvent event,
|
||||||
Emitter<AuthState> emit,
|
Emitter<AuthState> emit,
|
||||||
) {
|
) {
|
||||||
|
@ -46,7 +46,8 @@ class StopTimerEvent extends AuthEvent {}
|
|||||||
class UpdateTimerEvent extends AuthEvent {
|
class UpdateTimerEvent extends AuthEvent {
|
||||||
final int remainingTime;
|
final int remainingTime;
|
||||||
final bool isButtonEnabled;
|
final bool isButtonEnabled;
|
||||||
const UpdateTimerEvent({required this.remainingTime, required this.isButtonEnabled});
|
const UpdateTimerEvent(
|
||||||
|
{required this.remainingTime, required this.isButtonEnabled});
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChangePasswordEvent extends AuthEvent {}
|
class ChangePasswordEvent extends AuthEvent {}
|
||||||
|
@ -56,7 +56,8 @@ class TimerState extends AuthState {
|
|||||||
final bool isButtonEnabled;
|
final bool isButtonEnabled;
|
||||||
final int remainingTime;
|
final int remainingTime;
|
||||||
|
|
||||||
const TimerState({required this.isButtonEnabled, required this.remainingTime});
|
const TimerState(
|
||||||
|
{required this.isButtonEnabled, required this.remainingTime});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [isButtonEnabled, remainingTime];
|
List<Object> get props => [isButtonEnabled, remainingTime];
|
||||||
@ -80,7 +81,7 @@ class TimerUpdated extends AuthState {
|
|||||||
final String formattedTime;
|
final String formattedTime;
|
||||||
final bool isButtonEnabled;
|
final bool isButtonEnabled;
|
||||||
|
|
||||||
TimerUpdated({
|
const TimerUpdated({
|
||||||
required this.formattedTime,
|
required this.formattedTime,
|
||||||
required this.isButtonEnabled,
|
required this.isButtonEnabled,
|
||||||
});
|
});
|
||||||
|
@ -21,9 +21,9 @@ class LoginWithEmailModel {
|
|||||||
return {
|
return {
|
||||||
'email': email,
|
'email': email,
|
||||||
'password': password,
|
'password': password,
|
||||||
"platform": "web"
|
'platform': 'web'
|
||||||
// 'regionUuid': regionUuid,
|
// 'regionUuid': regionUuid,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//tst@tst.com
|
//tst@tst.com
|
||||||
|
@ -11,6 +11,14 @@ class Token {
|
|||||||
final int iat;
|
final int iat;
|
||||||
final int exp;
|
final int exp;
|
||||||
|
|
||||||
|
Token(
|
||||||
|
this.accessToken,
|
||||||
|
this.refreshToken,
|
||||||
|
this.sessionId,
|
||||||
|
this.iat,
|
||||||
|
this.exp,
|
||||||
|
);
|
||||||
|
|
||||||
Token.emptyConstructor()
|
Token.emptyConstructor()
|
||||||
: accessToken = '',
|
: accessToken = '',
|
||||||
refreshToken = '',
|
refreshToken = '',
|
||||||
@ -24,14 +32,6 @@ class Token {
|
|||||||
|
|
||||||
bool get isNotEmpty => accessToken.isNotEmpty && refreshToken.isNotEmpty;
|
bool get isNotEmpty => accessToken.isNotEmpty && refreshToken.isNotEmpty;
|
||||||
|
|
||||||
Token(
|
|
||||||
this.accessToken,
|
|
||||||
this.refreshToken,
|
|
||||||
this.sessionId,
|
|
||||||
this.iat,
|
|
||||||
this.exp,
|
|
||||||
);
|
|
||||||
|
|
||||||
Token.refreshToken(this.refreshToken)
|
Token.refreshToken(this.refreshToken)
|
||||||
: accessToken = '',
|
: accessToken = '',
|
||||||
sessionId = '',
|
sessionId = '',
|
||||||
@ -40,7 +40,7 @@ class Token {
|
|||||||
|
|
||||||
factory Token.fromJson(Map<String, dynamic> json) {
|
factory Token.fromJson(Map<String, dynamic> json) {
|
||||||
//save token to secure storage
|
//save token to secure storage
|
||||||
var storage = const FlutterSecureStorage();
|
const storage = FlutterSecureStorage();
|
||||||
storage.write(
|
storage.write(
|
||||||
key: loginAccessTokenKey, value: json[loginAccessTokenKey] ?? '');
|
key: loginAccessTokenKey, value: json[loginAccessTokenKey] ?? '');
|
||||||
storage.write(
|
storage.write(
|
||||||
|
@ -55,22 +55,21 @@ class UserModel {
|
|||||||
|
|
||||||
//from token
|
//from token
|
||||||
factory UserModel.fromToken(Token token) {
|
factory UserModel.fromToken(Token token) {
|
||||||
Map<String, dynamic> tempJson = Token.decodeToken(token.accessToken);
|
final tempJson = Token.decodeToken(token.accessToken);
|
||||||
|
|
||||||
return UserModel(
|
return UserModel(
|
||||||
hasAcceptedWebAgreement: null,
|
hasAcceptedWebAgreement: null,
|
||||||
role: null,
|
role: null,
|
||||||
webAgreementAcceptedAt: null,
|
webAgreementAcceptedAt: null,
|
||||||
uuid: tempJson['uuid'].toString(),
|
uuid: tempJson['uuid'].toString(),
|
||||||
email: tempJson['email'],
|
email: tempJson['email'],
|
||||||
firstName: null,
|
firstName: null,
|
||||||
lastName: null,
|
lastName: null,
|
||||||
photoUrl: null,
|
photoUrl: null,
|
||||||
phoneNumber: null,
|
phoneNumber: null,
|
||||||
isEmailVerified: null,
|
isEmailVerified: null,
|
||||||
isAgreementAccepted: null,
|
isAgreementAccepted: null,
|
||||||
project: null
|
project: null);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
|
@ -36,20 +36,18 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: _buildForm,
|
||||||
return _buildForm(context, state);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildForm(BuildContext context, AuthState state) {
|
Widget _buildForm(BuildContext context, AuthState state) {
|
||||||
late ScrollController _scrollController;
|
late ScrollController scrollController;
|
||||||
_scrollController = ScrollController();
|
scrollController = ScrollController();
|
||||||
void _scrollToCenter() {
|
void scrollToCenter() {
|
||||||
final double middlePosition = _scrollController.position.maxScrollExtent / 2;
|
final middlePosition = scrollController.position.maxScrollExtent / 2;
|
||||||
_scrollController.animateTo(
|
scrollController.animateTo(
|
||||||
middlePosition,
|
middlePosition,
|
||||||
duration: const Duration(seconds: 1),
|
duration: const Duration(seconds: 1),
|
||||||
curve: Curves.easeInOut,
|
curve: Curves.easeInOut,
|
||||||
@ -57,24 +55,25 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
_scrollToCenter();
|
scrollToCenter();
|
||||||
});
|
});
|
||||||
final forgetBloc = BlocProvider.of<AuthBloc>(context);
|
final forgetBloc = BlocProvider.of<AuthBloc>(context);
|
||||||
Size size = MediaQuery.of(context).size;
|
final size = MediaQuery.of(context).size;
|
||||||
return FirstLayer(
|
return FirstLayer(
|
||||||
second: Center(
|
second: Center(
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
if (state is AuthLoading) const Center(child: CircularProgressIndicator()),
|
if (state is AuthLoading)
|
||||||
|
const Center(child: CircularProgressIndicator()),
|
||||||
ListView(
|
ListView(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
controller: _scrollController,
|
controller: scrollController,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.all(size.width * 0.02),
|
padding: EdgeInsets.all(size.width * 0.02),
|
||||||
margin: EdgeInsets.all(size.width * 0.09),
|
margin: EdgeInsets.all(size.width * 0.09),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.black.withOpacity(0.3),
|
color: Colors.black.withValues(alpha: 0.3),
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
@ -94,17 +93,22 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
flex: 3,
|
flex: 3,
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white.withOpacity(0.1),
|
color: Colors.white.withValues(alpha: 0.1),
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(30)),
|
borderRadius:
|
||||||
border: Border.all(color: ColorsManager.graysColor.withOpacity(0.2)),
|
const BorderRadius.all(Radius.circular(30)),
|
||||||
|
border: Border.all(
|
||||||
|
color: ColorsManager.graysColor
|
||||||
|
.withValues(alpha: 0.2)),
|
||||||
),
|
),
|
||||||
child: Form(
|
child: Form(
|
||||||
key: forgetBloc.forgetFormKey,
|
key: forgetBloc.forgetFormKey,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.symmetric(
|
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(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceEvenly,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
@ -121,7 +125,9 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.bodySmall!
|
.bodySmall!
|
||||||
.copyWith(fontSize: 14, fontWeight: FontWeight.w400),
|
.copyWith(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w400),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
// Column(
|
// Column(
|
||||||
@ -140,69 +146,90 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
Form(
|
Form(
|
||||||
key: forgetBloc.forgetEmailKey,
|
key: forgetBloc.forgetEmailKey,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment:
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Account",
|
'Account',
|
||||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
style: Theme.of(context)
|
||||||
fontSize: 14, fontWeight: FontWeight.w400),
|
.textTheme
|
||||||
|
.bodySmall!
|
||||||
|
.copyWith(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight:
|
||||||
|
FontWeight.w400),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
controller: forgetBloc.forgetEmailController,
|
controller: forgetBloc
|
||||||
validator: forgetBloc.validateEmail,
|
.forgetEmailController,
|
||||||
decoration: textBoxDecoration()!.copyWith(
|
validator:
|
||||||
|
forgetBloc.validateEmail,
|
||||||
|
decoration:
|
||||||
|
textBoxDecoration()!.copyWith(
|
||||||
hintText: 'Enter your email',
|
hintText: 'Enter your email',
|
||||||
hintStyle: Theme.of(context)
|
hintStyle: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.bodySmall!
|
.bodySmall!
|
||||||
.copyWith(
|
.copyWith(
|
||||||
color: ColorsManager.grayColor,
|
color: ColorsManager
|
||||||
fontWeight: FontWeight.w400),
|
.grayColor,
|
||||||
|
fontWeight:
|
||||||
|
FontWeight.w400),
|
||||||
),
|
),
|
||||||
style: const TextStyle(color: Colors.black),
|
style: const TextStyle(
|
||||||
|
color: Colors.black),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
const SizedBox(height: 20.0),
|
const SizedBox(height: 20.0),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"One Time Password",
|
'One Time Password',
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.bodySmall!
|
.bodySmall!
|
||||||
.copyWith(fontSize: 14, fontWeight: FontWeight.w400),
|
.copyWith(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w400),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
validator: forgetBloc.validateCode,
|
validator: forgetBloc.validateCode,
|
||||||
keyboardType: TextInputType.visiblePassword,
|
keyboardType:
|
||||||
|
TextInputType.visiblePassword,
|
||||||
controller: forgetBloc.forgetOtp,
|
controller: forgetBloc.forgetOtp,
|
||||||
decoration: textBoxDecoration()!.copyWith(
|
decoration:
|
||||||
|
textBoxDecoration()!.copyWith(
|
||||||
hintText: 'Enter Code',
|
hintText: 'Enter Code',
|
||||||
hintStyle: Theme.of(context)
|
hintStyle: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.bodySmall!
|
.bodySmall!
|
||||||
.copyWith(
|
.copyWith(
|
||||||
color: ColorsManager.grayColor,
|
color:
|
||||||
fontWeight: FontWeight.w400),
|
ColorsManager.grayColor,
|
||||||
|
fontWeight:
|
||||||
|
FontWeight.w400),
|
||||||
suffixIcon: SizedBox(
|
suffixIcon: SizedBox(
|
||||||
width: 100,
|
width: 100,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: state is TimerState &&
|
onTap: state is TimerState &&
|
||||||
!state.isButtonEnabled &&
|
!state
|
||||||
state.remainingTime != 1
|
.isButtonEnabled &&
|
||||||
|
state.remainingTime !=
|
||||||
|
1
|
||||||
? null
|
? null
|
||||||
:
|
: () {
|
||||||
() {
|
|
||||||
if (forgetBloc
|
if (forgetBloc
|
||||||
.forgetEmailKey
|
.forgetEmailKey
|
||||||
.currentState!
|
.currentState!
|
||||||
@ -211,27 +238,31 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
StartTimerEvent());
|
StartTimerEvent());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
child: Text(
|
child: Text(
|
||||||
'Get Code ${state is TimerState && !state.isButtonEnabled && state.remainingTime != 1 ? "(${forgetBloc.formattedTime(state.remainingTime)}) " : ""}',
|
'Get Code ${state is TimerState && !state.isButtonEnabled && state.remainingTime != 1 ? "(${forgetBloc.formattedTime(state.remainingTime)}) " : ""}',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: state is TimerState &&
|
color: state
|
||||||
!state.isButtonEnabled
|
is TimerState &&
|
||||||
|
!state
|
||||||
|
.isButtonEnabled
|
||||||
? Colors.grey
|
? Colors.grey
|
||||||
: ColorsManager.btnColor,
|
: ColorsManager
|
||||||
|
.btnColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
style: const TextStyle(color: Colors.black),
|
style: const TextStyle(
|
||||||
|
color: Colors.black),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (forgetBloc.forgetValidate !=
|
if (forgetBloc.forgetValidate !=
|
||||||
'') // Check if there is a validation message
|
'') // Check if there is a validation message
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 8.0),
|
padding:
|
||||||
|
const EdgeInsets.only(top: 8.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
forgetBloc.forgetValidate,
|
forgetBloc.forgetValidate,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
@ -244,34 +275,44 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 20.0),
|
const SizedBox(height: 20.0),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Password",
|
'Password',
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.bodySmall!
|
.bodySmall!
|
||||||
.copyWith(fontSize: 14, fontWeight: FontWeight.w400),
|
.copyWith(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w400),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
obscureText: forgetBloc.obscureText,
|
obscureText: forgetBloc.obscureText,
|
||||||
keyboardType: TextInputType.visiblePassword,
|
keyboardType:
|
||||||
validator: forgetBloc.passwordValidator,
|
TextInputType.visiblePassword,
|
||||||
controller: forgetBloc.forgetPasswordController,
|
validator:
|
||||||
decoration: textBoxDecoration()!.copyWith(
|
forgetBloc.passwordValidator,
|
||||||
|
controller: forgetBloc
|
||||||
|
.forgetPasswordController,
|
||||||
|
decoration:
|
||||||
|
textBoxDecoration()!.copyWith(
|
||||||
suffixIcon: IconButton(
|
suffixIcon: IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
forgetBloc.add(PasswordVisibleEvent(
|
forgetBloc.add(
|
||||||
newValue: forgetBloc.obscureText));
|
PasswordVisibleEvent(
|
||||||
|
newValue: forgetBloc
|
||||||
|
.obscureText));
|
||||||
},
|
},
|
||||||
icon: SizedBox(
|
icon: SizedBox(
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
forgetBloc.obscureText
|
forgetBloc.obscureText
|
||||||
? Assets.visiblePassword
|
? Assets.visiblePassword
|
||||||
: Assets.invisiblePassword,
|
: Assets
|
||||||
|
.invisiblePassword,
|
||||||
height: 15,
|
height: 15,
|
||||||
width: 15,
|
width: 15,
|
||||||
),
|
),
|
||||||
@ -282,10 +323,13 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
.textTheme
|
.textTheme
|
||||||
.bodySmall!
|
.bodySmall!
|
||||||
.copyWith(
|
.copyWith(
|
||||||
color: ColorsManager.grayColor,
|
color:
|
||||||
fontWeight: FontWeight.w400),
|
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),
|
const SizedBox(height: 20.0),
|
||||||
Row(
|
Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: size.width * 0.2,
|
width: size.width * 0.2,
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
backgroundColor: ColorsManager.btnColor,
|
backgroundColor:
|
||||||
|
ColorsManager.btnColor,
|
||||||
child: const Text('Submit'),
|
child: const Text('Submit'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (forgetBloc.forgetFormKey.currentState!.validate() ||
|
if (forgetBloc
|
||||||
forgetBloc.forgetEmailKey.currentState!
|
.forgetFormKey.currentState!
|
||||||
|
.validate() ||
|
||||||
|
forgetBloc.forgetEmailKey
|
||||||
|
.currentState!
|
||||||
.validate()) {
|
.validate()) {
|
||||||
if (forgetBloc.forgetEmailKey.currentState!
|
if (forgetBloc.forgetEmailKey
|
||||||
|
.currentState!
|
||||||
.validate() &&
|
.validate() &&
|
||||||
forgetBloc.forgetFormKey.currentState!
|
forgetBloc.forgetFormKey
|
||||||
|
.currentState!
|
||||||
.validate()) {
|
.validate()) {
|
||||||
forgetBloc.add(ChangePasswordEvent());
|
forgetBloc
|
||||||
|
.add(ChangePasswordEvent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -325,7 +377,8 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
child: Text(
|
child: Text(
|
||||||
forgetBloc.validate,
|
forgetBloc.validate,
|
||||||
style: const TextStyle(
|
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(
|
child: Wrap(
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
const Text(
|
||||||
"Do you have an account? ",
|
'Do you have an account? ',
|
||||||
style: TextStyle(color: Colors.white),
|
style:
|
||||||
|
TextStyle(color: Colors.white),
|
||||||
),
|
),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@ -346,7 +400,7 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
child: const Text(
|
child: const Text(
|
||||||
"Sign in",
|
'Sign in',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -372,14 +426,15 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildDropdownField(BuildContext context, AuthBloc loginBloc, Size size) {
|
Widget _buildDropdownField(
|
||||||
final TextEditingController textEditingController = TextEditingController();
|
BuildContext context, AuthBloc loginBloc, Size size) {
|
||||||
|
final textEditingController = TextEditingController();
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Country/Region",
|
'Country/Region',
|
||||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
@ -398,10 +453,13 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
builder: (FormFieldState<String> field) {
|
builder: (FormFieldState<String> field) {
|
||||||
return InputDecorator(
|
return InputDecorator(
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 2, vertical: 10),
|
contentPadding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 2, vertical: 10),
|
||||||
errorText: field.errorText,
|
errorText: field.errorText,
|
||||||
filled: true, // Ensure the dropdown is filled with the background color
|
filled:
|
||||||
fillColor: ColorsManager.boxColor, // Match the dropdown container color
|
true, // Ensure the dropdown is filled with the background color
|
||||||
|
fillColor: ColorsManager
|
||||||
|
.boxColor, // Match the dropdown container color
|
||||||
border: OutlineInputBorder(
|
border: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(8.0),
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(
|
||||||
@ -412,14 +470,16 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(8.0),
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(
|
||||||
color: field.hasError ? Colors.red : ColorsManager.grayColor,
|
color:
|
||||||
|
field.hasError ? Colors.red : ColorsManager.grayColor,
|
||||||
width: 1.5,
|
width: 1.5,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(8.0),
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(
|
||||||
color: field.hasError ? Colors.red : ColorsManager.grayColor,
|
color:
|
||||||
|
field.hasError ? Colors.red : ColorsManager.grayColor,
|
||||||
width: 1.5,
|
width: 1.5,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -446,10 +506,11 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
return DropdownMenuItem<String>(
|
return DropdownMenuItem<String>(
|
||||||
value: region.id,
|
value: region.id,
|
||||||
child: Text(
|
child: Text(
|
||||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
style:
|
||||||
fontSize: 14,
|
Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||||
fontWeight: FontWeight.w400,
|
fontSize: 14,
|
||||||
),
|
fontWeight: FontWeight.w400,
|
||||||
|
),
|
||||||
region.name,
|
region.name,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
@ -462,7 +523,8 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
onChanged: (String? value) {
|
onChanged: (String? value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
loginBloc.add(SelectRegionEvent(val: value));
|
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(
|
buttonStyleData: const ButtonStyleData(
|
||||||
@ -486,7 +548,8 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
searchInnerWidgetHeight: 50,
|
searchInnerWidgetHeight: 50,
|
||||||
searchInnerWidget: Container(
|
searchInnerWidget: Container(
|
||||||
height: 50,
|
height: 50,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 8, vertical: 4),
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
style: const TextStyle(color: Colors.black),
|
style: const TextStyle(color: Colors.black),
|
||||||
controller: textEditingController,
|
controller: textEditingController,
|
||||||
@ -500,7 +563,8 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
searchMatchFn: (item, searchValue) {
|
searchMatchFn: (item, searchValue) {
|
||||||
final regionName = (item.child as Text).data?.toLowerCase() ?? '';
|
final regionName =
|
||||||
|
(item.child as Text).data?.toLowerCase() ?? '';
|
||||||
final search = searchValue.toLowerCase().trim();
|
final search = searchValue.toLowerCase().trim();
|
||||||
return regionName.contains(search);
|
return regionName.contains(search);
|
||||||
},
|
},
|
||||||
|
@ -79,7 +79,7 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
child: Container(
|
child: Container(
|
||||||
margin: const EdgeInsets.all(50),
|
margin: const EdgeInsets.all(50),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.black.withOpacity(0.3),
|
color: Colors.black.withValues(alpha: 0.3),
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(20))),
|
borderRadius: const BorderRadius.all(Radius.circular(20))),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@ -93,12 +93,15 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
margin: EdgeInsets.all(30),
|
margin: const EdgeInsets.all(30),
|
||||||
padding: EdgeInsets.all(20),
|
padding: const EdgeInsets.all(20),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white.withOpacity(0.1),
|
color: Colors.white.withValues(alpha: 0.1),
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(30)),
|
borderRadius:
|
||||||
border: Border.all(color: ColorsManager.graysColor.withOpacity(0.2))),
|
const BorderRadius.all(Radius.circular(30)),
|
||||||
|
border: Border.all(
|
||||||
|
color: ColorsManager.graysColor
|
||||||
|
.withValues(alpha: 0.2))),
|
||||||
child: Form(
|
child: Form(
|
||||||
key: loginBloc.loginFormKey,
|
key: loginBloc.loginFormKey,
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -109,7 +112,9 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
const Text(
|
const Text(
|
||||||
'Login',
|
'Login',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold),
|
color: Colors.white,
|
||||||
|
fontSize: 24,
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
// Column(
|
// Column(
|
||||||
@ -155,15 +160,15 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Email",
|
'Email',
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
validator: loginBloc.validateEmail,
|
validator: loginBloc.validateEmail,
|
||||||
controller: loginBloc.loginEmailController,
|
controller: loginBloc.loginEmailController,
|
||||||
decoration:
|
decoration: textBoxDecoration()!
|
||||||
textBoxDecoration()!.copyWith(hintText: 'Enter your email'),
|
.copyWith(hintText: 'Enter your email'),
|
||||||
style: const TextStyle(color: Colors.black),
|
style: const TextStyle(color: Colors.black),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -175,7 +180,7 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Password",
|
'Password',
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@ -183,7 +188,8 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
validator: loginBloc.validatePassword,
|
validator: loginBloc.validatePassword,
|
||||||
obscureText: loginBloc.obscureText,
|
obscureText: loginBloc.obscureText,
|
||||||
keyboardType: TextInputType.visiblePassword,
|
keyboardType: TextInputType.visiblePassword,
|
||||||
controller: loginBloc.loginPasswordController,
|
controller:
|
||||||
|
loginBloc.loginPasswordController,
|
||||||
decoration: textBoxDecoration()!.copyWith(
|
decoration: textBoxDecoration()!.copyWith(
|
||||||
hintText: 'At least 8 characters',
|
hintText: 'At least 8 characters',
|
||||||
),
|
),
|
||||||
@ -201,16 +207,19 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
Navigator.of(context)
|
||||||
builder: (context) => const ForgetPasswordPage(),
|
.push(MaterialPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
const ForgetPasswordPage(),
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
"Forgot Password?",
|
'Forgot Password?',
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.bodySmall!
|
.bodySmall!
|
||||||
.copyWith(color: ColorsManager.blackColor),
|
.copyWith(
|
||||||
|
color: ColorsManager.blackColor),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -221,13 +230,15 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
Transform.scale(
|
Transform.scale(
|
||||||
scale: 1.2, // Adjust the scale as needed
|
scale: 1.2, // Adjust the scale as needed
|
||||||
child: Checkbox(
|
child: Checkbox(
|
||||||
fillColor: MaterialStateProperty.all<Color>(Colors.white),
|
fillColor: WidgetStateProperty.all<Color>(
|
||||||
|
Colors.white),
|
||||||
activeColor: Colors.white,
|
activeColor: Colors.white,
|
||||||
value: loginBloc.isChecked,
|
value: loginBloc.isChecked,
|
||||||
checkColor: Colors.black,
|
checkColor: Colors.black,
|
||||||
shape: const CircleBorder(),
|
shape: const CircleBorder(),
|
||||||
onChanged: (bool? newValue) {
|
onChanged: (bool? newValue) {
|
||||||
loginBloc.add(CheckBoxEvent(newValue: newValue));
|
loginBloc.add(
|
||||||
|
CheckBoxEvent(newValue: newValue));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -236,30 +247,37 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
child: RichText(
|
child: RichText(
|
||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
text: 'Agree to ',
|
text: 'Agree to ',
|
||||||
style: const TextStyle(color: Colors.white),
|
style:
|
||||||
|
const TextStyle(color: Colors.white),
|
||||||
children: [
|
children: [
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: '(Terms of Service)',
|
text: '(Terms of Service)',
|
||||||
style: const TextStyle(color: Colors.black),
|
style: const TextStyle(
|
||||||
|
color: Colors.black),
|
||||||
recognizer: TapGestureRecognizer()
|
recognizer: TapGestureRecognizer()
|
||||||
..onTap = () {
|
..onTap = () {
|
||||||
loginBloc.launchURL('https://example.com/terms');
|
loginBloc.launchURL(
|
||||||
|
'https://example.com/terms');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: ' (Legal Statement)',
|
text: ' (Legal Statement)',
|
||||||
style: const TextStyle(color: Colors.black),
|
style: const TextStyle(
|
||||||
|
color: Colors.black),
|
||||||
recognizer: TapGestureRecognizer()
|
recognizer: TapGestureRecognizer()
|
||||||
..onTap = () {
|
..onTap = () {
|
||||||
loginBloc.launchURL('https://example.com/legal');
|
loginBloc.launchURL(
|
||||||
|
'https://example.com/legal');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: ' (Privacy Statement)',
|
text: ' (Privacy Statement)',
|
||||||
style: const TextStyle(color: Colors.black),
|
style: const TextStyle(
|
||||||
|
color: Colors.black),
|
||||||
recognizer: TapGestureRecognizer()
|
recognizer: TapGestureRecognizer()
|
||||||
..onTap = () {
|
..onTap = () {
|
||||||
loginBloc.launchURL('https://example.com/privacy');
|
loginBloc.launchURL(
|
||||||
|
'https://example.com/privacy');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -276,11 +294,14 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
: ColorsManager.grayColor,
|
: ColorsManager.grayColor,
|
||||||
child: const Text('Sign in'),
|
child: const Text('Sign in'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (loginBloc.loginFormKey.currentState!.validate()) {
|
if (loginBloc.loginFormKey.currentState!
|
||||||
|
.validate()) {
|
||||||
loginBloc.add(
|
loginBloc.add(
|
||||||
LoginButtonPressed(
|
LoginButtonPressed(
|
||||||
username: loginBloc.loginEmailController.text,
|
username:
|
||||||
password: loginBloc.loginPasswordController.text,
|
loginBloc.loginEmailController.text,
|
||||||
|
password: loginBloc
|
||||||
|
.loginPasswordController.text,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -295,10 +316,11 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
Flexible(
|
Flexible(
|
||||||
child: Text(
|
child: Text(
|
||||||
"Don't you have an account? ",
|
"Don't you have an account? ",
|
||||||
style: TextStyle(color: Colors.white, fontSize: 13),
|
style: TextStyle(
|
||||||
|
color: Colors.white, fontSize: 13),
|
||||||
)),
|
)),
|
||||||
Text(
|
Text(
|
||||||
"Sign up",
|
'Sign up',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -24,7 +24,8 @@ class LoginWebPage extends StatefulWidget {
|
|||||||
State<LoginWebPage> createState() => _LoginWebPageState();
|
State<LoginWebPage> createState() => _LoginWebPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout {
|
class _LoginWebPageState extends State<LoginWebPage>
|
||||||
|
with HelperResponsiveLayout {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@ -42,9 +43,7 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: _buildLoginForm,
|
||||||
return _buildLoginForm(context, state);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -54,12 +53,12 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
|||||||
final loginBloc = BlocProvider.of<AuthBloc>(context);
|
final loginBloc = BlocProvider.of<AuthBloc>(context);
|
||||||
final isSmallScreen = isSmallScreenSize(context);
|
final isSmallScreen = isSmallScreenSize(context);
|
||||||
final isMediumScreen = isMediumScreenSize(context);
|
final isMediumScreen = isMediumScreenSize(context);
|
||||||
Size size = MediaQuery.of(context).size;
|
final size = MediaQuery.of(context).size;
|
||||||
late ScrollController scrollController;
|
late ScrollController scrollController;
|
||||||
scrollController = ScrollController();
|
scrollController = ScrollController();
|
||||||
|
|
||||||
void scrollToCenter() {
|
void scrollToCenter() {
|
||||||
final double middlePosition = scrollController.position.maxScrollExtent / 2;
|
final middlePosition = scrollController.position.maxScrollExtent / 2;
|
||||||
scrollController.animateTo(
|
scrollController.animateTo(
|
||||||
middlePosition,
|
middlePosition,
|
||||||
duration: const Duration(seconds: 1),
|
duration: const Duration(seconds: 1),
|
||||||
@ -84,7 +83,7 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
|||||||
padding: EdgeInsets.all(size.width * 0.02),
|
padding: EdgeInsets.all(size.width * 0.02),
|
||||||
margin: EdgeInsets.all(size.width * 0.05),
|
margin: EdgeInsets.all(size.width * 0.05),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.black.withOpacity(0.3),
|
color: Colors.black.withValues(alpha: 0.3),
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
@ -121,7 +120,8 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
|||||||
const Spacer(),
|
const Spacer(),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: _buildLoginFormFields(context, loginBloc, size),
|
child: _buildLoginFormFields(
|
||||||
|
context, loginBloc, size),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
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(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white.withOpacity(0.1),
|
color: Colors.white.withValues(alpha: 0.1),
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(30)),
|
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(
|
child: Form(
|
||||||
key: loginBloc.loginFormKey,
|
key: loginBloc.loginFormKey,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding:
|
padding: EdgeInsets.symmetric(
|
||||||
EdgeInsets.symmetric(horizontal: size.width * 0.02, vertical: size.width * 0.003),
|
horizontal: size.width * 0.02, vertical: size.width * 0.003),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@ -176,14 +179,15 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildDropdownField(BuildContext context, AuthBloc loginBloc, Size size) {
|
Widget _buildDropdownField(
|
||||||
final TextEditingController textEditingController = TextEditingController();
|
BuildContext context, AuthBloc loginBloc, Size size) {
|
||||||
|
final textEditingController = TextEditingController();
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Country/Region",
|
'Country/Region',
|
||||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
@ -246,7 +250,8 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
|||||||
searchInnerWidgetHeight: 50,
|
searchInnerWidgetHeight: 50,
|
||||||
searchInnerWidget: Container(
|
searchInnerWidget: Container(
|
||||||
height: 50,
|
height: 50,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
style: const TextStyle(color: Colors.black),
|
style: const TextStyle(color: Colors.black),
|
||||||
controller: textEditingController,
|
controller: textEditingController,
|
||||||
@ -261,7 +266,8 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
|||||||
),
|
),
|
||||||
searchMatchFn: (item, searchValue) {
|
searchMatchFn: (item, searchValue) {
|
||||||
// Use the item's child text (region name) for searching.
|
// 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();
|
final search = searchValue.toLowerCase().trim();
|
||||||
// Debugging print statement to ensure values are captured correctly.
|
// Debugging print statement to ensure values are captured correctly.
|
||||||
// Return true if the region name contains the search term.
|
// Return true if the region name contains the search term.
|
||||||
@ -286,7 +292,7 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
|||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Email",
|
'Email',
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.bodySmall!
|
.bodySmall!
|
||||||
@ -303,10 +309,9 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
|||||||
decoration: textBoxDecoration()!.copyWith(
|
decoration: textBoxDecoration()!.copyWith(
|
||||||
errorStyle: const TextStyle(height: 0),
|
errorStyle: const TextStyle(height: 0),
|
||||||
hintText: 'Enter your email address',
|
hintText: 'Enter your email address',
|
||||||
hintStyle: Theme.of(context)
|
hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
.textTheme
|
color: ColorsManager.grayColor,
|
||||||
.bodySmall!
|
fontWeight: FontWeight.w400)),
|
||||||
.copyWith(color: ColorsManager.grayColor, fontWeight: FontWeight.w400)),
|
|
||||||
style: const TextStyle(color: Colors.black),
|
style: const TextStyle(color: Colors.black),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -320,7 +325,7 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
|||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Password",
|
'Password',
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.bodySmall!
|
.bodySmall!
|
||||||
@ -338,7 +343,7 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
|||||||
controller: loginBloc.loginPasswordController,
|
controller: loginBloc.loginPasswordController,
|
||||||
onFieldSubmitted: (value) {
|
onFieldSubmitted: (value) {
|
||||||
if (loginBloc.loginFormKey.currentState!.validate()) {
|
if (loginBloc.loginFormKey.currentState!.validate()) {
|
||||||
loginBloc.add(LoginButtonPressed(
|
loginBloc.add(LoginButtonPressed(
|
||||||
username: loginBloc.loginEmailController.text,
|
username: loginBloc.loginEmailController.text,
|
||||||
password: value,
|
password: value,
|
||||||
));
|
));
|
||||||
@ -348,17 +353,18 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
|||||||
},
|
},
|
||||||
decoration: textBoxDecoration()!.copyWith(
|
decoration: textBoxDecoration()!.copyWith(
|
||||||
hintText: 'At least 8 characters',
|
hintText: 'At least 8 characters',
|
||||||
hintStyle: Theme.of(context)
|
hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
.textTheme
|
color: ColorsManager.grayColor, fontWeight: FontWeight.w400),
|
||||||
.bodySmall!
|
|
||||||
.copyWith(color: ColorsManager.grayColor, fontWeight: FontWeight.w400),
|
|
||||||
suffixIcon: IconButton(
|
suffixIcon: IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
loginBloc.add(PasswordVisibleEvent(newValue: loginBloc.obscureText));
|
loginBloc.add(
|
||||||
|
PasswordVisibleEvent(newValue: loginBloc.obscureText));
|
||||||
},
|
},
|
||||||
icon: SizedBox(
|
icon: SizedBox(
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
loginBloc.obscureText ? Assets.visiblePassword : Assets.invisiblePassword,
|
loginBloc.obscureText
|
||||||
|
? Assets.visiblePassword
|
||||||
|
: Assets.invisiblePassword,
|
||||||
height: 15,
|
height: 15,
|
||||||
width: 15,
|
width: 15,
|
||||||
),
|
),
|
||||||
@ -385,11 +391,11 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
|||||||
));
|
));
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
"Forgot Password?",
|
'Forgot Password?',
|
||||||
style: Theme.of(context)
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
.textTheme
|
color: Colors.black,
|
||||||
.bodySmall!
|
fontSize: 14,
|
||||||
.copyWith(color: Colors.black, fontSize: 14, fontWeight: FontWeight.w400),
|
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(
|
return Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
@ -467,7 +474,7 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
|||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color: loginBloc.checkValidate
|
color: loginBloc.checkValidate
|
||||||
? ColorsManager.whiteColors
|
? ColorsManager.whiteColors
|
||||||
: ColorsManager.whiteColors.withOpacity(0.2),
|
: ColorsManager.whiteColors.withValues(alpha: 0.2),
|
||||||
)),
|
)),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (loginBloc.loginFormKey.currentState!.validate()) {
|
if (loginBloc.loginFormKey.currentState!.validate()) {
|
||||||
@ -494,7 +501,8 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
child: Text(
|
child: Text(
|
||||||
loginBloc.validate,
|
loginBloc.validate,
|
||||||
style: const TextStyle(fontWeight: FontWeight.w700, color: ColorsManager.red),
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.w700, color: ColorsManager.red),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
@ -108,66 +108,64 @@ class _DynamicTableState extends State<AccessDeviceTable> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
if (widget.withCheckBox) _buildSelectAllCheckbox(),
|
if (widget.withCheckBox) _buildSelectAllCheckbox(),
|
||||||
...widget.headers
|
...widget.headers.map(_buildTableHeaderCell),
|
||||||
.map((header) => _buildTableHeaderCell(header)),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
widget.isEmpty
|
if (widget.isEmpty)
|
||||||
? Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
Column(
|
SvgPicture.asset(Assets.emptyTable),
|
||||||
children: [
|
const SizedBox(
|
||||||
SvgPicture.asset(Assets.emptyTable),
|
height: 15,
|
||||||
const SizedBox(
|
|
||||||
height: 15,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
// no password
|
|
||||||
widget.tableName == 'AccessManagement'
|
|
||||||
? 'No Password '
|
|
||||||
: 'No Devices',
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodySmall!
|
|
||||||
.copyWith(
|
|
||||||
color: ColorsManager.grayColor),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
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,
|
else
|
||||||
child: ListView.builder(
|
Expanded(
|
||||||
shrinkWrap: true,
|
child: ColoredBox(
|
||||||
itemCount: widget.data.length,
|
color: Colors.white,
|
||||||
itemBuilder: (context, index) {
|
child: ListView.builder(
|
||||||
final row = widget.data[index];
|
shrinkWrap: true,
|
||||||
return Row(
|
itemCount: widget.data.length,
|
||||||
children: [
|
itemBuilder: (context, index) {
|
||||||
if (widget.withCheckBox)
|
final row = widget.data[index];
|
||||||
_buildRowCheckbox(
|
return Row(
|
||||||
index, widget.size.height * 0.10),
|
children: [
|
||||||
...row.map((cell) => _buildTableCell(
|
if (widget.withCheckBox)
|
||||||
cell.toString(),
|
_buildRowCheckbox(
|
||||||
widget.size.height * 0.10)),
|
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) {
|
Widget _buildTableCell(String content, double size) {
|
||||||
bool isBatteryLevel = content.endsWith('%');
|
final isBatteryLevel = content.endsWith('%');
|
||||||
double? batteryLevel;
|
double? batteryLevel;
|
||||||
|
|
||||||
if (isBatteryLevel) {
|
if (isBatteryLevel) {
|
||||||
|
@ -22,17 +22,21 @@ class CancelButton extends StatelessWidget {
|
|||||||
return ElevatedButton(
|
return ElevatedButton(
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
backgroundColor: WidgetStateProperty.all(ColorsManager.boxColor), // White background
|
backgroundColor:
|
||||||
foregroundColor: WidgetStateProperty.all(Colors.black), // Black text color
|
WidgetStateProperty.all(ColorsManager.boxColor), // White background
|
||||||
|
foregroundColor:
|
||||||
|
WidgetStateProperty.all(Colors.black), // Black text color
|
||||||
shape: WidgetStateProperty.all<RoundedRectangleBorder>(
|
shape: WidgetStateProperty.all<RoundedRectangleBorder>(
|
||||||
RoundedRectangleBorder(
|
RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(borderRadius ?? 10),
|
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
|
child: Text(label), // Dynamic label
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ class DefaultButton extends StatelessWidget {
|
|||||||
(Set<WidgetState> states) {
|
(Set<WidgetState> states) {
|
||||||
return enabled
|
return enabled
|
||||||
? backgroundColor ?? ColorsManager.primaryColor
|
? backgroundColor ?? ColorsManager.primaryColor
|
||||||
: Colors.black.withOpacity(0.2);
|
: Colors.black.withValues(alpha: 0.2);
|
||||||
}),
|
}),
|
||||||
shape: WidgetStateProperty.all(
|
shape: WidgetStateProperty.all(
|
||||||
RoundedRectangleBorder(
|
RoundedRectangleBorder(
|
||||||
|
@ -34,7 +34,7 @@ class CurtainToggle extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
ClipOval(
|
ClipOval(
|
||||||
child: Container(
|
child: ColoredBox(
|
||||||
color: ColorsManager.whiteColors,
|
color: ColorsManager.whiteColors,
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
Assets.curtainIcon,
|
Assets.curtainIcon,
|
||||||
@ -52,7 +52,7 @@ class CurtainToggle extends StatelessWidget {
|
|||||||
width: 35,
|
width: 35,
|
||||||
child: CupertinoSwitch(
|
child: CupertinoSwitch(
|
||||||
value: value,
|
value: value,
|
||||||
activeColor: ColorsManager.dialogBlueTitle,
|
activeTrackColor: ColorsManager.dialogBlueTitle,
|
||||||
onChanged: onChanged,
|
onChanged: onChanged,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -12,7 +12,7 @@ Future<void> showCustomDialog({
|
|||||||
double? iconWidth,
|
double? iconWidth,
|
||||||
VoidCallback? onOkPressed,
|
VoidCallback? onOkPressed,
|
||||||
bool barrierDismissible = false,
|
bool barrierDismissible = false,
|
||||||
List<Widget>? actions,
|
List<Widget>? actions,
|
||||||
}) {
|
}) {
|
||||||
return showDialog(
|
return showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@ -40,14 +40,20 @@ Future<void> showCustomDialog({
|
|||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.headlineLarge!
|
.headlineLarge!
|
||||||
.copyWith(fontSize: 20, fontWeight: FontWeight.w400, color: Colors.black),
|
.copyWith(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: Colors.black),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 8.0),
|
padding: const EdgeInsets.only(top: 8.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
message,
|
message,
|
||||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.black),
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodyMedium!
|
||||||
|
.copyWith(color: Colors.black),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -20,8 +20,8 @@ class DynamicTable extends StatefulWidget {
|
|||||||
final void Function(int, bool, dynamic)? onRowSelected;
|
final void Function(int, bool, dynamic)? onRowSelected;
|
||||||
final List<String>? initialSelectedIds;
|
final List<String>? initialSelectedIds;
|
||||||
final int uuidIndex;
|
final int uuidIndex;
|
||||||
final Function(dynamic selectedRows)? onSelectionChanged;
|
final void Function(dynamic selectedRows)? onSelectionChanged;
|
||||||
final Function(int rowIndex)? onSettingsPressed;
|
final void Function(int rowIndex)? onSettingsPressed;
|
||||||
const DynamicTable({
|
const DynamicTable({
|
||||||
super.key,
|
super.key,
|
||||||
required this.headers,
|
required this.headers,
|
||||||
@ -79,10 +79,10 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
// Check if the old and new lists are the same
|
// Check if the old and new lists are the same
|
||||||
if (oldList.length != newList.length) return false;
|
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;
|
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;
|
if (oldList[i][j] != newList[i][j]) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
controller: _horizontalBodyScrollController,
|
controller: _horizontalBodyScrollController,
|
||||||
child: Container(
|
child: ColoredBox(
|
||||||
color: ColorsManager.whiteColors,
|
color: ColorsManager.whiteColors,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: widget.size.width,
|
width: widget.size.width,
|
||||||
@ -184,7 +184,7 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
rowIndex: rowIndex,
|
rowIndex: rowIndex,
|
||||||
columnIndex: entry.key,
|
columnIndex: entry.key,
|
||||||
);
|
);
|
||||||
}).toList(),
|
}),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
@ -304,13 +304,13 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
required int rowIndex,
|
required int rowIndex,
|
||||||
required int columnIndex,
|
required int columnIndex,
|
||||||
}) {
|
}) {
|
||||||
bool isBatteryLevel = content.endsWith('%');
|
final isBatteryLevel = content.endsWith('%');
|
||||||
double? batteryLevel;
|
double? batteryLevel;
|
||||||
|
|
||||||
if (isBatteryLevel) {
|
if (isBatteryLevel) {
|
||||||
batteryLevel = double.tryParse(content.replaceAll('%', '').trim());
|
batteryLevel = double.tryParse(content.replaceAll('%', '').trim());
|
||||||
}
|
}
|
||||||
bool isSettingsColumn = widget.headers[columnIndex] == 'Settings';
|
final isSettingsColumn = widget.headers[columnIndex] == 'Settings';
|
||||||
|
|
||||||
if (isSettingsColumn) {
|
if (isSettingsColumn) {
|
||||||
return buildSettingsIcon(
|
return buildSettingsIcon(
|
||||||
@ -404,7 +404,7 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
borderRadius: BorderRadius.circular(height / 2),
|
borderRadius: BorderRadius.circular(height / 2),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: Colors.black.withOpacity(0.17),
|
color: Colors.black.withValues(alpha: 0.17),
|
||||||
blurRadius: 14,
|
blurRadius: 14,
|
||||||
offset: const Offset(0, 4),
|
offset: const Offset(0, 4),
|
||||||
),
|
),
|
||||||
@ -416,11 +416,10 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
Assets.settings, // ضع المسار الصحيح هنا
|
Assets.settings,
|
||||||
width: 40,
|
width: 40,
|
||||||
height: 22,
|
height: 22,
|
||||||
color: ColorsManager
|
color: ColorsManager.primaryColor,
|
||||||
.primaryColor, // نفس لون الأيقونة في الصورة
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -36,7 +36,7 @@ class FilterWidget extends StatelessWidget {
|
|||||||
color: ColorsManager.boxColor,
|
color: ColorsManager.boxColor,
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: isSelected
|
color: isSelected
|
||||||
? ColorsManager.blueColor.withOpacity(0.8)
|
? ColorsManager.blueColor.withValues(alpha: 0.8)
|
||||||
: Colors.transparent,
|
: Colors.transparent,
|
||||||
width: 2.0,
|
width: 2.0,
|
||||||
),
|
),
|
||||||
@ -48,7 +48,7 @@ class FilterWidget extends StatelessWidget {
|
|||||||
tabs[index],
|
tabs[index],
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: isSelected
|
color: isSelected
|
||||||
? ColorsManager.blueColor.withOpacity(0.8)
|
? ColorsManager.blueColor.withValues(alpha: 0.8)
|
||||||
: Colors.black,
|
: Colors.black,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user