mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
add table view
This commit is contained in:
@ -34,7 +34,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
TextEditingController();
|
TextEditingController();
|
||||||
final TextEditingController forgetOtp = TextEditingController();
|
final TextEditingController forgetOtp = TextEditingController();
|
||||||
final forgetFormKey = GlobalKey<FormState>();
|
final forgetFormKey = GlobalKey<FormState>();
|
||||||
late bool checkValidate = false;
|
late bool checkValidate = false;
|
||||||
|
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
int _remainingTime = 0;
|
int _remainingTime = 0;
|
||||||
@ -58,8 +58,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
add(const UpdateTimerEvent(remainingTime: 0, isButtonEnabled: true));
|
add(const UpdateTimerEvent(remainingTime: 0, isButtonEnabled: true));
|
||||||
} else {
|
} else {
|
||||||
add(UpdateTimerEvent(
|
add(UpdateTimerEvent(
|
||||||
remainingTime: _remainingTime,
|
remainingTime: _remainingTime, isButtonEnabled: false));
|
||||||
isButtonEnabled: false));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -152,29 +151,35 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
key: UserModel.userUuidKey,
|
key: UserModel.userUuidKey,
|
||||||
value: Token.decodeToken(token.accessToken)['uuid'].toString());
|
value: Token.decodeToken(token.accessToken)['uuid'].toString());
|
||||||
user = UserModel.fromToken(token);
|
user = UserModel.fromToken(token);
|
||||||
|
debugPrint(token.accessToken);
|
||||||
loginEmailController.clear();
|
loginEmailController.clear();
|
||||||
loginPasswordController.clear();
|
loginPasswordController.clear();
|
||||||
emit(LoginSuccess());
|
emit(LoginSuccess());
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
emit(const LoginFailure(error: 'Something went wrong'));
|
emit(const LoginFailure(error: 'Something went wrong'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
emit(const LoginFailure(error: 'Accept terms and condition'));
|
emit(const LoginFailure(error: 'Accept terms and condition'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkBoxToggle(CheckBoxEvent event, Emitter<AuthState> emit,) {
|
checkBoxToggle(
|
||||||
|
CheckBoxEvent event,
|
||||||
|
Emitter<AuthState> emit,
|
||||||
|
) {
|
||||||
emit(AuthLoading());
|
emit(AuthLoading());
|
||||||
isChecked = event.newValue!;
|
isChecked = event.newValue!;
|
||||||
add(CheckEnableEvent());
|
add(CheckEnableEvent());
|
||||||
emit(LoginInitial());
|
emit(LoginInitial());
|
||||||
}
|
}
|
||||||
|
|
||||||
checkOtpCode(ChangePasswordEvent event, Emitter<AuthState> emit,) async {
|
checkOtpCode(
|
||||||
|
ChangePasswordEvent event,
|
||||||
|
Emitter<AuthState> emit,
|
||||||
|
) async {
|
||||||
emit(LoadingForgetState());
|
emit(LoadingForgetState());
|
||||||
await AuthenticationAPI.verifyOtp(email: forgetEmailController.text, otpCode: forgetOtp.text);
|
await AuthenticationAPI.verifyOtp(
|
||||||
|
email: forgetEmailController.text, otpCode: forgetOtp.text);
|
||||||
emit(SuccessForgetState());
|
emit(SuccessForgetState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,19 +207,17 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
} else if (regionUuid == '') {
|
} else if (regionUuid == '') {
|
||||||
return 'Please select your region';
|
return 'Please select your region';
|
||||||
}
|
}
|
||||||
validate='';
|
validate = '';
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String? loginValidateEmail(String? value) {
|
String? loginValidateEmail(String? value) {
|
||||||
if (!RegExp(r'^[^@]+@[^@]+\.[^@]+').hasMatch(value!)) {
|
if (!RegExp(r'^[^@]+@[^@]+\.[^@]+').hasMatch(value!)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool _validateInputs(Emitter<AuthState> emit) {
|
bool _validateInputs(Emitter<AuthState> emit) {
|
||||||
emit(LoadingForgetState());
|
emit(LoadingForgetState());
|
||||||
final nameError = validateEmail(forgetEmailController.text);
|
final nameError = validateEmail(forgetEmailController.text);
|
||||||
@ -357,7 +360,9 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
final String formattedTime = [
|
final String 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(':');
|
||||||
@ -365,9 +370,12 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
return formattedTime;
|
return formattedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkEnable( CheckEnableEvent event, Emitter<AuthState> emit,) {
|
bool checkEnable(
|
||||||
|
CheckEnableEvent event,
|
||||||
|
Emitter<AuthState> emit,
|
||||||
|
) {
|
||||||
emit(AuthLoading());
|
emit(AuthLoading());
|
||||||
checkValidate = isChecked==true &&
|
checkValidate = isChecked == true &&
|
||||||
loginPasswordController.text.isNotEmpty &&
|
loginPasswordController.text.isNotEmpty &&
|
||||||
loginEmailController.text.isNotEmpty &&
|
loginEmailController.text.isNotEmpty &&
|
||||||
regionUuid != '';
|
regionUuid != '';
|
||||||
@ -375,14 +383,21 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
return checkValidate;
|
return checkValidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
changeValidate(ChangeValidateEvent event, Emitter<AuthState> emit,){
|
changeValidate(
|
||||||
|
ChangeValidateEvent event,
|
||||||
|
Emitter<AuthState> emit,
|
||||||
|
) {
|
||||||
emit(AuthLoading());
|
emit(AuthLoading());
|
||||||
validate='';
|
validate = '';
|
||||||
emit(LoginInitial());
|
emit(LoginInitial());
|
||||||
}
|
}
|
||||||
changeForgetValidate(ChangeValidateEvent event, Emitter<AuthState> emit,){
|
|
||||||
|
changeForgetValidate(
|
||||||
|
ChangeValidateEvent event,
|
||||||
|
Emitter<AuthState> emit,
|
||||||
|
) {
|
||||||
emit(AuthLoading());
|
emit(AuthLoading());
|
||||||
forgetValidate='';
|
forgetValidate = '';
|
||||||
emit(LoginInitial());
|
emit(LoginInitial());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,8 +75,7 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
BoxDecoration(color: Colors.grey[200]),
|
BoxDecoration(color: Colors.grey[200]),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
if (widget.withCheckBox)
|
if (widget.withCheckBox) _buildSelectAllCheckbox(),
|
||||||
_buildSelectAllCheckbox(),
|
|
||||||
...widget.headers
|
...widget.headers
|
||||||
.map((header) => _buildTableHeaderCell(header))
|
.map((header) => _buildTableHeaderCell(header))
|
||||||
.toList(),
|
.toList(),
|
||||||
@ -93,10 +92,11 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
final row = widget.data[index];
|
final row = widget.data[index];
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
if (widget.withCheckBox)
|
if (widget.withCheckBox) _buildRowCheckbox(index),
|
||||||
_buildRowCheckbox(index),
|
...row
|
||||||
...row.map((cell) =>
|
.map((cell) =>
|
||||||
_buildTableCell(cell.toString())).toList(),
|
_buildTableCell(cell.toString()))
|
||||||
|
.toList(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -143,7 +143,10 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Text(title, style: const TextStyle(fontWeight: FontWeight.bold)),
|
child: Text(title,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: ColorsManager.lightGreyColor)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -156,11 +159,11 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
padding: const EdgeInsets.all(15.0),
|
padding: const EdgeInsets.all(15.0),
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
border: Border(
|
border: Border(
|
||||||
bottom: BorderSide(
|
bottom: BorderSide(
|
||||||
color: ColorsManager.boxDivider,
|
color: ColorsManager.boxDivider,
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: Text(
|
child: Text(
|
||||||
content,
|
content,
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_web/core/extension/build_context_x.dart';
|
import 'package:syncrow_web/core/extension/build_context_x.dart';
|
||||||
import 'package:syncrow_web/pages/common/buttons/search_reset_buttons.dart';
|
import 'package:syncrow_web/pages/common/buttons/search_reset_buttons.dart';
|
||||||
|
import 'package:syncrow_web/pages/common/custom_table.dart';
|
||||||
import 'package:syncrow_web/pages/common/filter/filter_widget.dart';
|
import 'package:syncrow_web/pages/common/filter/filter_widget.dart';
|
||||||
import 'package:syncrow_web/pages/common/text_field/custom_text_field.dart';
|
import 'package:syncrow_web/pages/common/text_field/custom_text_field.dart';
|
||||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||||
|
import 'package:syncrow_web/utils/style.dart';
|
||||||
|
|
||||||
class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
||||||
const DeviceManagementBody({super.key});
|
const DeviceManagementBody({super.key});
|
||||||
@ -80,6 +82,46 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
const SizedBox(
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: DynamicTable(
|
||||||
|
cellDecoration: containerDecoration,
|
||||||
|
selectAll: (p0) {
|
||||||
|
// visitorBloc.selectedDeviceIds.clear();
|
||||||
|
// for (var item in state.data) {
|
||||||
|
// visitorBloc.add(SelectDeviceEvent(item.uuid));
|
||||||
|
// }
|
||||||
|
},
|
||||||
|
onRowCheckboxChanged: (index, isSelected) {
|
||||||
|
// final deviceId = state.data[index].uuid;
|
||||||
|
// visitorBloc.add(SelectDeviceEvent(deviceId));
|
||||||
|
},
|
||||||
|
withCheckBox: true,
|
||||||
|
size: context.screenSize,
|
||||||
|
headers: const [
|
||||||
|
'Device Name',
|
||||||
|
'Product Name',
|
||||||
|
'Device ID',
|
||||||
|
'Unit Name',
|
||||||
|
'Room',
|
||||||
|
'Battery Level',
|
||||||
|
'Installation Date and Time',
|
||||||
|
'Status',
|
||||||
|
'Last Offline Date and Time',
|
||||||
|
],
|
||||||
|
data: []
|
||||||
|
// state.data.map((item) {
|
||||||
|
// return [
|
||||||
|
// item.name.toString(),
|
||||||
|
// item.uuid.toString(),
|
||||||
|
// item.productType.toString(),
|
||||||
|
// '',
|
||||||
|
// item.online.value.toString(),
|
||||||
|
// ];
|
||||||
|
// }).toList(),
|
||||||
|
)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -3,9 +3,10 @@ import 'package:flutter/material.dart';
|
|||||||
abstract class ColorsManager {
|
abstract class ColorsManager {
|
||||||
static const Color textPrimaryColor = Color(0xFF5D5D5D);
|
static const Color textPrimaryColor = Color(0xFF5D5D5D);
|
||||||
static const Color switchOffColor = Color(0x7F8D99AE);
|
static const Color switchOffColor = Color(0x7F8D99AE);
|
||||||
static const Color primaryColor = Color(0xFF0030CB);//023DFE
|
static const Color primaryColor = Color(0xFF0030CB); //023DFE
|
||||||
static const Color secondaryTextColor = Color(0xFF848484);
|
static const Color secondaryTextColor = Color(0xFF848484);
|
||||||
static Color primaryColorWithOpacity = const Color(0xFF023DFE).withOpacity(0.6);
|
static Color primaryColorWithOpacity =
|
||||||
|
const Color(0xFF023DFE).withOpacity(0.6);
|
||||||
static const Color whiteColors = Colors.white;
|
static const Color whiteColors = Colors.white;
|
||||||
static const Color secondaryColor = Color(0xFF023DFE);
|
static const Color secondaryColor = Color(0xFF023DFE);
|
||||||
static const Color onSecondaryColor = Color(0xFF023DFE);
|
static const Color onSecondaryColor = Color(0xFF023DFE);
|
||||||
@ -13,7 +14,7 @@ abstract class ColorsManager {
|
|||||||
static const Color primaryTextColor = Colors.black;
|
static const Color primaryTextColor = Colors.black;
|
||||||
|
|
||||||
static const Color greyColor = Color(0xFFd5d5d5);
|
static const Color greyColor = Color(0xFFd5d5d5);
|
||||||
|
static const Color lightGreyColor = Color(0xFF999999);
|
||||||
static const Color backgroundColor = Color(0xFFececec);
|
static const Color backgroundColor = Color(0xFFececec);
|
||||||
static const Color dozeColor = Color(0xFFFEC258);
|
static const Color dozeColor = Color(0xFFFEC258);
|
||||||
static const Color relaxColor = Color(0xFFFBD288);
|
static const Color relaxColor = Color(0xFFFBD288);
|
||||||
|
Reference in New Issue
Block a user