mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
Merge pull request #45 from SyncrowIOT/web_issue
forget_password&power_clamp_issue
This commit is contained in:
@ -31,7 +31,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>();
|
||||||
@ -48,7 +49,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(
|
||||||
@ -84,7 +86,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));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -94,21 +97,25 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> changePassword(ChangePasswordEvent event, Emitter<AuthState> emit) async {
|
Future<void> changePassword(
|
||||||
|
ChangePasswordEvent event, Emitter<AuthState> emit) async {
|
||||||
emit(LoadingForgetState());
|
emit(LoadingForgetState());
|
||||||
try {
|
try {
|
||||||
var response = await AuthenticationAPI.verifyOtp(
|
var 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(
|
||||||
password: forgetPasswordController.text, email: forgetEmailController.text);
|
otpCode: forgetOtp.text,
|
||||||
|
password: forgetPasswordController.text,
|
||||||
|
email: forgetEmailController.text);
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
||||||
emit(SuccessForgetState());
|
emit(SuccessForgetState());
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorData = e.response!.data;
|
final errorData = e.response!.data;
|
||||||
String errorMessage = errorData['error']['message'] ?? 'something went wrong';
|
String errorMessage =
|
||||||
|
errorData['error']['message'] ?? 'something went wrong';
|
||||||
validate = errorMessage;
|
validate = errorMessage;
|
||||||
emit(AuthInitialState());
|
emit(AuthInitialState());
|
||||||
}
|
}
|
||||||
@ -122,7 +129,9 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 /////////////////////////////////////
|
||||||
@ -154,7 +163,9 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
|
|
||||||
token = await AuthenticationAPI.loginWithEmail(
|
token = await AuthenticationAPI.loginWithEmail(
|
||||||
model: LoginWithEmailModel(
|
model: LoginWithEmailModel(
|
||||||
email: event.username, password: event.password, regionUuid: event.regionUuid),
|
email: event.username,
|
||||||
|
password: event.password,
|
||||||
|
regionUuid: event.regionUuid),
|
||||||
);
|
);
|
||||||
} catch (failure) {
|
} catch (failure) {
|
||||||
validate = 'Invalid Credentials!';
|
validate = 'Invalid Credentials!';
|
||||||
@ -164,7 +175,8 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
|
|
||||||
if (token.accessTokenIsNotEmpty) {
|
if (token.accessTokenIsNotEmpty) {
|
||||||
FlutterSecureStorage storage = const FlutterSecureStorage();
|
FlutterSecureStorage storage = const FlutterSecureStorage();
|
||||||
await storage.write(key: Token.loginAccessTokenKey, value: token.accessToken);
|
await storage.write(
|
||||||
|
key: Token.loginAccessTokenKey, value: token.accessToken);
|
||||||
const FlutterSecureStorage().write(
|
const FlutterSecureStorage().write(
|
||||||
key: UserModel.userUuidKey,
|
key: UserModel.userUuidKey,
|
||||||
value: Token.decodeToken(token.accessToken)['uuid'].toString());
|
value: Token.decodeToken(token.accessToken)['uuid'].toString());
|
||||||
@ -322,12 +334,14 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
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';
|
||||||
@ -380,7 +394,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(':');
|
||||||
|
@ -33,56 +33,190 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
int currentPage = 0;
|
int currentPage = 0;
|
||||||
|
|
||||||
List<EventDevice> record = [
|
List<EventDevice> record = [
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2024-10-23 11:15:43'), value: '2286'),
|
EventDevice(
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2024-10-23 11:15:35'), value: '2285'),
|
code: 'VoltageA',
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2024-10-23 11:15:29'), value: '2284'),
|
eventTime: DateTime.parse('2024-10-23 11:15:43'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2024-10-23 11:15:25'), value: '2285'),
|
value: '2286'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2024-10-23 11:15:21'), value: '2284'),
|
EventDevice(
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2024-10-23 11:15:17'), value: '2285'),
|
code: 'VoltageA',
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2024-10-23 11:15:07'), value: '2286'),
|
eventTime: DateTime.parse('2024-10-23 11:15:35'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2024-10-23 11:14:47'), value: '2285'),
|
value: '2285'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2024-10-23 11:14:40'), value: '2284'),
|
EventDevice(
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2024-10-23 11:14:23'), value: '2285'),
|
code: 'VoltageA',
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2024-10-23 11:14:13'), value: '2284'),
|
eventTime: DateTime.parse('2024-10-23 11:15:29'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-10-23 11:15:43'), value: '2286'),
|
value: '2284'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-10-23 11:15:35'), value: '2285'),
|
EventDevice(
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-10-23 11:15:29'), value: '2284'),
|
code: 'VoltageA',
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-10-23 11:15:25'), value: '2285'),
|
eventTime: DateTime.parse('2024-10-23 11:15:25'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-10-23 11:15:21'), value: '2284'),
|
value: '2285'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-10-23 11:15:17'), value: '2285'),
|
EventDevice(
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-10-23 11:15:07'), value: '2286'),
|
code: 'VoltageA',
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-10-23 11:14:47'), value: '2285'),
|
eventTime: DateTime.parse('2024-10-23 11:15:21'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-10-23 11:14:40'), value: '2284'),
|
value: '2284'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-10-23 11:14:23'), value: '2285'),
|
EventDevice(
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-10-23 11:14:13'), value: '2284'),
|
code: 'VoltageA',
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-23 11:15:43'), value: '2286'),
|
eventTime: DateTime.parse('2024-10-23 11:15:17'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-23 11:15:35'), value: '2285'),
|
value: '2285'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-23 11:15:29'), value: '2284'),
|
EventDevice(
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-23 11:15:25'), value: '2285'),
|
code: 'VoltageA',
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-23 11:15:21'), value: '2284'),
|
eventTime: DateTime.parse('2024-10-23 11:15:07'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-23 11:15:17'), value: '2285'),
|
value: '2286'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-23 11:15:07'), value: '2286'),
|
EventDevice(
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-23 11:14:47'), value: '2285'),
|
code: 'VoltageA',
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-23 11:14:40'), value: '2284'),
|
eventTime: DateTime.parse('2024-10-23 11:14:47'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-23 11:14:23'), value: '2285'),
|
value: '2285'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-23 11:14:13'), value: '2284'),
|
EventDevice(
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-11 11:15:43'), value: '2286'),
|
code: 'VoltageA',
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-11 11:15:35'), value: '2285'),
|
eventTime: DateTime.parse('2024-10-23 11:14:40'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-12 11:15:29'), value: '2284'),
|
value: '2284'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-13 11:15:25'), value: '2285'),
|
EventDevice(
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-14 11:15:21'), value: '2284'),
|
code: 'VoltageA',
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-15 11:15:17'), value: '2285'),
|
eventTime: DateTime.parse('2024-10-23 11:14:23'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-16 11:15:07'), value: '2286'),
|
value: '2285'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-17 11:14:47'), value: '2285'),
|
EventDevice(
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-18 11:14:40'), value: '2284'),
|
code: 'VoltageA',
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-19 11:14:23'), value: '2285'),
|
eventTime: DateTime.parse('2024-10-23 11:14:13'),
|
||||||
EventDevice(code: 'VoltageA', eventTime: DateTime.parse('2023-02-20 11:14:13'), value: '2284'),
|
value: '2284'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-10-23 11:15:43'),
|
||||||
|
value: '2286'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-10-23 11:15:35'),
|
||||||
|
value: '2285'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-10-23 11:15:29'),
|
||||||
|
value: '2284'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-10-23 11:15:25'),
|
||||||
|
value: '2285'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-10-23 11:15:21'),
|
||||||
|
value: '2284'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-10-23 11:15:17'),
|
||||||
|
value: '2285'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-10-23 11:15:07'),
|
||||||
|
value: '2286'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-10-23 11:14:47'),
|
||||||
|
value: '2285'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-10-23 11:14:40'),
|
||||||
|
value: '2284'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-10-23 11:14:23'),
|
||||||
|
value: '2285'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-10-23 11:14:13'),
|
||||||
|
value: '2284'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-23 11:15:43'),
|
||||||
|
value: '2286'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-23 11:15:35'),
|
||||||
|
value: '2285'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-23 11:15:29'),
|
||||||
|
value: '2284'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-23 11:15:25'),
|
||||||
|
value: '2285'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-23 11:15:21'),
|
||||||
|
value: '2284'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-23 11:15:17'),
|
||||||
|
value: '2285'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-23 11:15:07'),
|
||||||
|
value: '2286'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-23 11:14:47'),
|
||||||
|
value: '2285'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-23 11:14:40'),
|
||||||
|
value: '2284'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-23 11:14:23'),
|
||||||
|
value: '2285'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-23 11:14:13'),
|
||||||
|
value: '2284'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-11 11:15:43'),
|
||||||
|
value: '2286'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-11 11:15:35'),
|
||||||
|
value: '2285'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-12 11:15:29'),
|
||||||
|
value: '2284'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-13 11:15:25'),
|
||||||
|
value: '2285'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-14 11:15:21'),
|
||||||
|
value: '2284'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-15 11:15:17'),
|
||||||
|
value: '2285'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-16 11:15:07'),
|
||||||
|
value: '2286'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-17 11:14:47'),
|
||||||
|
value: '2285'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-18 11:14:40'),
|
||||||
|
value: '2284'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-19 11:14:23'),
|
||||||
|
value: '2285'),
|
||||||
|
EventDevice(
|
||||||
|
code: 'VoltageA',
|
||||||
|
eventTime: DateTime.parse('2023-02-20 11:14:13'),
|
||||||
|
value: '2284'),
|
||||||
];
|
];
|
||||||
|
|
||||||
FutureOr<void> _onFetchDeviceStatus(SmartPowerFetchDeviceEvent event, Emitter<SmartPowerState> emit) async {
|
FutureOr<void> _onFetchDeviceStatus(
|
||||||
|
SmartPowerFetchDeviceEvent event, Emitter<SmartPowerState> emit) async {
|
||||||
emit(SmartPowerLoading());
|
emit(SmartPowerLoading());
|
||||||
try {
|
try {
|
||||||
var status = await DevicesManagementApi().getPowerClampInfo(event.deviceId);
|
var status =
|
||||||
|
await DevicesManagementApi().getPowerClampInfo(event.deviceId);
|
||||||
deviceStatus = PowerClampModel.fromJson(status);
|
deviceStatus = PowerClampModel.fromJson(status);
|
||||||
|
|
||||||
phaseData = [
|
phaseData = [
|
||||||
@ -114,19 +248,22 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _onArrowPressed(SmartPowerArrowPressedEvent event, Emitter<SmartPowerState> emit) {
|
FutureOr<void> _onArrowPressed(
|
||||||
|
SmartPowerArrowPressedEvent event, Emitter<SmartPowerState> emit) {
|
||||||
currentPage = (currentPage + event.direction + 4) % 4;
|
currentPage = (currentPage + event.direction + 4) % 4;
|
||||||
emit(SmartPowerStatusLoaded(deviceStatus, currentPage));
|
emit(SmartPowerStatusLoaded(deviceStatus, currentPage));
|
||||||
emit(GetDeviceStatus());
|
emit(GetDeviceStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _onPageChanged(SmartPowerPageChangedEvent event, Emitter<SmartPowerState> emit) {
|
FutureOr<void> _onPageChanged(
|
||||||
|
SmartPowerPageChangedEvent event, Emitter<SmartPowerState> emit) {
|
||||||
currentPage = event.page;
|
currentPage = event.page;
|
||||||
emit(SmartPowerStatusLoaded(deviceStatus, currentPage));
|
emit(SmartPowerStatusLoaded(deviceStatus, currentPage));
|
||||||
emit(GetDeviceStatus());
|
emit(GetDeviceStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onFactoryReset(SmartPowerFactoryReset event, Emitter<SmartPowerState> emit) async {
|
Future<void> _onFactoryReset(
|
||||||
|
SmartPowerFactoryReset event, Emitter<SmartPowerState> emit) async {
|
||||||
emit(SmartPowerLoading());
|
emit(SmartPowerLoading());
|
||||||
try {
|
try {
|
||||||
final response = await DevicesManagementApi().factoryReset(
|
final response = await DevicesManagementApi().factoryReset(
|
||||||
@ -143,7 +280,8 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onBatchControl(PowerBatchControlEvent event, Emitter<SmartPowerState> emit) async {
|
Future<void> _onBatchControl(
|
||||||
|
PowerBatchControlEvent event, Emitter<SmartPowerState> emit) async {
|
||||||
final oldValue = deviceStatus.status;
|
final oldValue = deviceStatus.status;
|
||||||
|
|
||||||
_updateLocalValue(event.code, event.value);
|
_updateLocalValue(event.code, event.value);
|
||||||
@ -159,11 +297,14 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onFetchBatchStatus(SmartPowerFetchBatchEvent event, Emitter<SmartPowerState> emit) async {
|
Future<void> _onFetchBatchStatus(
|
||||||
|
SmartPowerFetchBatchEvent event, Emitter<SmartPowerState> emit) async {
|
||||||
emit(SmartPowerLoading());
|
emit(SmartPowerLoading());
|
||||||
try {
|
try {
|
||||||
final response = await DevicesManagementApi().getPowerStatus(event.devicesIds);
|
final response =
|
||||||
PowerClampBatchModel deviceStatus = PowerClampBatchModel.fromJson(response);
|
await DevicesManagementApi().getPowerStatus(event.devicesIds);
|
||||||
|
PowerClampBatchModel deviceStatus =
|
||||||
|
PowerClampBatchModel.fromJson(response);
|
||||||
|
|
||||||
emit(SmartPowerLoadBatchControll(deviceStatus));
|
emit(SmartPowerLoadBatchControll(deviceStatus));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -195,9 +336,11 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
try {
|
try {
|
||||||
late bool response;
|
late bool response;
|
||||||
if (isBatch) {
|
if (isBatch) {
|
||||||
response = await DevicesManagementApi().deviceBatchControl(deviceId, code, value);
|
response = await DevicesManagementApi()
|
||||||
|
.deviceBatchControl(deviceId, code, value);
|
||||||
} else {
|
} else {
|
||||||
response = await DevicesManagementApi().deviceControl(deviceId, Status(code: code, value: value));
|
response = await DevicesManagementApi()
|
||||||
|
.deviceControl(deviceId, Status(code: code, value: value));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!response) {
|
if (!response) {
|
||||||
@ -217,7 +360,8 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _revertValueAndEmit(String deviceId, String code, dynamic oldValue, Emitter<SmartPowerState> emit) {
|
void _revertValueAndEmit(String deviceId, String code, dynamic oldValue,
|
||||||
|
Emitter<SmartPowerState> emit) {
|
||||||
_updateLocalValue(code, oldValue);
|
_updateLocalValue(code, oldValue);
|
||||||
emit(SmartPowerLoadBatchControll(deviceBatchStatus));
|
emit(SmartPowerLoadBatchControll(deviceBatchStatus));
|
||||||
}
|
}
|
||||||
@ -274,8 +418,10 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
int selectedYear = DateTime.now().year;
|
int selectedYear = DateTime.now().year;
|
||||||
int selectedMonth = DateTime.now().month;
|
int selectedMonth = DateTime.now().month;
|
||||||
|
|
||||||
FixedExtentScrollController yearController = FixedExtentScrollController(initialItem: selectedYear - 1905);
|
FixedExtentScrollController yearController =
|
||||||
FixedExtentScrollController monthController = FixedExtentScrollController(initialItem: selectedMonth - 1);
|
FixedExtentScrollController(initialItem: selectedYear - 1905);
|
||||||
|
FixedExtentScrollController monthController =
|
||||||
|
FixedExtentScrollController(initialItem: selectedMonth - 1);
|
||||||
|
|
||||||
return await showDialog<DateTime>(
|
return await showDialog<DateTime>(
|
||||||
context: context,
|
context: context,
|
||||||
@ -285,7 +431,10 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
height: 350,
|
height: 350,
|
||||||
width: 350,
|
width: 350,
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -294,7 +443,8 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
padding: EdgeInsets.all(16.0),
|
padding: EdgeInsets.all(16.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Select Month and Year',
|
'Select Month and Year',
|
||||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
style:
|
||||||
|
TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
@ -337,7 +487,8 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
builder: (context, index) {
|
builder: (context, index) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
DateFormat.MMMM().format(DateTime(0, index + 1)),
|
DateFormat.MMMM()
|
||||||
|
.format(DateTime(0, index + 1)),
|
||||||
style: const TextStyle(fontSize: 18),
|
style: const TextStyle(fontSize: 18),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -352,7 +503,8 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
),
|
),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16.0, vertical: 8.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@ -365,7 +517,8 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
TextButton(
|
TextButton(
|
||||||
child: const Text('OK'),
|
child: const Text('OK'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
final selectedDateTime = DateTime(selectedYear, selectedMonth);
|
final selectedDateTime =
|
||||||
|
DateTime(selectedYear, selectedMonth);
|
||||||
Navigator.of(context).pop(selectedDateTime);
|
Navigator.of(context).pop(selectedDateTime);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -383,7 +536,8 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
|
|
||||||
Future<DateTime?> selectYear(BuildContext context) async {
|
Future<DateTime?> selectYear(BuildContext context) async {
|
||||||
int selectedYear = DateTime.now().year;
|
int selectedYear = DateTime.now().year;
|
||||||
FixedExtentScrollController yearController = FixedExtentScrollController(initialItem: selectedYear - 1905);
|
FixedExtentScrollController yearController =
|
||||||
|
FixedExtentScrollController(initialItem: selectedYear - 1905);
|
||||||
|
|
||||||
return await showDialog<DateTime>(
|
return await showDialog<DateTime>(
|
||||||
context: context,
|
context: context,
|
||||||
@ -393,7 +547,10 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
height: 350,
|
height: 350,
|
||||||
width: 350,
|
width: 350,
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -402,7 +559,8 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
padding: EdgeInsets.all(16.0),
|
padding: EdgeInsets.all(16.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Select Year',
|
'Select Year',
|
||||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
style:
|
||||||
|
TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
@ -429,7 +587,8 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
),
|
),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16.0, vertical: 8.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@ -492,7 +651,8 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
),
|
),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16.0, vertical: 8.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@ -524,7 +684,8 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
|
|
||||||
String formattedDate = DateFormat('yyyy/MM/dd').format(DateTime.now());
|
String formattedDate = DateFormat('yyyy/MM/dd').format(DateTime.now());
|
||||||
|
|
||||||
void checkDayMonthYearSelected(SelectDateEvent event, Emitter<SmartPowerState> emit) async {
|
void checkDayMonthYearSelected(
|
||||||
|
SelectDateEvent event, Emitter<SmartPowerState> emit) async {
|
||||||
Future<DateTime?> Function(BuildContext context)? dateSelector;
|
Future<DateTime?> Function(BuildContext context)? dateSelector;
|
||||||
String dateFormat;
|
String dateFormat;
|
||||||
switch (currentIndex) {
|
switch (currentIndex) {
|
||||||
@ -569,18 +730,23 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<EnergyData> energyDataList = [];
|
List<EnergyData> energyDataList = [];
|
||||||
void _filterRecordsByDate(FilterRecordsByDateEvent event, Emitter<SmartPowerState> emit) {
|
void _filterRecordsByDate(
|
||||||
|
FilterRecordsByDateEvent event, Emitter<SmartPowerState> emit) {
|
||||||
// emit(SmartPowerLoading());
|
// emit(SmartPowerLoading());
|
||||||
|
|
||||||
if (event.viewType == 'Year') {
|
if (event.viewType == 'Year') {
|
||||||
formattedDate = event.selectedDate.year.toString();
|
formattedDate = event.selectedDate.year.toString();
|
||||||
filteredRecords = record.where((record) => record.eventTime!.year == event.selectedDate.year).toList();
|
filteredRecords = record
|
||||||
|
.where((record) => record.eventTime!.year == event.selectedDate.year)
|
||||||
|
.toList();
|
||||||
} else if (event.viewType == 'Month') {
|
} else if (event.viewType == 'Month') {
|
||||||
formattedDate = "${event.selectedDate.year.toString()}-${getMonthShortName(event.selectedDate.month)}";
|
formattedDate =
|
||||||
|
"${event.selectedDate.year.toString()}-${getMonthShortName(event.selectedDate.month)}";
|
||||||
|
|
||||||
filteredRecords = record
|
filteredRecords = record
|
||||||
.where((record) =>
|
.where((record) =>
|
||||||
record.eventTime!.year == event.selectedDate.year && record.eventTime!.month == event.selectedDate.month)
|
record.eventTime!.year == event.selectedDate.year &&
|
||||||
|
record.eventTime!.month == event.selectedDate.month)
|
||||||
.toList();
|
.toList();
|
||||||
} else if (event.viewType == 'Day') {
|
} else if (event.viewType == 'Day') {
|
||||||
formattedDate =
|
formattedDate =
|
||||||
@ -598,7 +764,8 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
energyDataList = filteredRecords.map((eventDevice) {
|
energyDataList = filteredRecords.map((eventDevice) {
|
||||||
return EnergyData(
|
return EnergyData(
|
||||||
event.viewType == 'Year'
|
event.viewType == 'Year'
|
||||||
? getMonthShortName(int.tryParse(DateFormat('MM').format(eventDevice.eventTime!))!)
|
? getMonthShortName(
|
||||||
|
int.tryParse(DateFormat('MM').format(eventDevice.eventTime!))!)
|
||||||
: event.viewType == 'Month'
|
: event.viewType == 'Month'
|
||||||
? DateFormat('yyyy/MM/dd').format(eventDevice.eventTime!)
|
? DateFormat('yyyy/MM/dd').format(eventDevice.eventTime!)
|
||||||
: DateFormat('HH:mm:ss').format(eventDevice.eventTime!),
|
: DateFormat('HH:mm:ss').format(eventDevice.eventTime!),
|
||||||
@ -617,7 +784,8 @@ class SmartPowerBloc extends Bloc<SmartPowerEvent, SmartPowerState> {
|
|||||||
|
|
||||||
void selectDateRange() async {
|
void selectDateRange() async {
|
||||||
DateTime startDate = dateTime!;
|
DateTime startDate = dateTime!;
|
||||||
DateTime endDate = DateTime(startDate.year, startDate.month + 1, 1).subtract(Duration(days: 1));
|
DateTime endDate = DateTime(startDate.year, startDate.month + 1, 1)
|
||||||
|
.subtract(Duration(days: 1));
|
||||||
String formattedEndDate = DateFormat('dd/MM/yyyy').format(endDate);
|
String formattedEndDate = DateFormat('dd/MM/yyyy').format(endDate);
|
||||||
endChartDate = ' - $formattedEndDate';
|
endChartDate = ' - $formattedEndDate';
|
||||||
}
|
}
|
||||||
|
@ -93,9 +93,9 @@ class _EnergyConsumptionPageState extends State<EnergyConsumptionPage> {
|
|||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 15),
|
padding: const EdgeInsets.only(top: 10),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: MediaQuery.of(context).size.height * 0.12,
|
height: MediaQuery.of(context).size.height * 0.11,
|
||||||
child: LineChart(
|
child: LineChart(
|
||||||
LineChartData(
|
LineChartData(
|
||||||
lineTouchData: LineTouchData(
|
lineTouchData: LineTouchData(
|
||||||
@ -227,7 +227,7 @@ class _EnergyConsumptionPageState extends State<EnergyConsumptionPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(5.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@ -240,7 +240,7 @@ class _EnergyConsumptionPageState extends State<EnergyConsumptionPage> {
|
|||||||
child: Container(child: widget.widget),
|
child: Container(child: widget.widget),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
const SizedBox(
|
||||||
width: 20,
|
width: 20,
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
|
@ -12,7 +12,8 @@ import 'package:syncrow_web/utils/constants/assets.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';
|
||||||
|
|
||||||
//Smart Power Clamp
|
//Smart Power Clamp
|
||||||
class SmartPowerDeviceControl extends StatelessWidget with HelperResponsiveLayout {
|
class SmartPowerDeviceControl extends StatelessWidget
|
||||||
|
with HelperResponsiveLayout {
|
||||||
final String deviceId;
|
final String deviceId;
|
||||||
|
|
||||||
const SmartPowerDeviceControl({super.key, required this.deviceId});
|
const SmartPowerDeviceControl({super.key, required this.deviceId});
|
||||||
@ -20,7 +21,8 @@ class SmartPowerDeviceControl extends StatelessWidget with HelperResponsiveLayou
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => SmartPowerBloc(deviceId: deviceId)..add(SmartPowerFetchDeviceEvent(deviceId)),
|
create: (context) => SmartPowerBloc(deviceId: deviceId)
|
||||||
|
..add(SmartPowerFetchDeviceEvent(deviceId)),
|
||||||
child: BlocBuilder<SmartPowerBloc, SmartPowerState>(
|
child: BlocBuilder<SmartPowerBloc, SmartPowerState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final _blocProvider = BlocProvider.of<SmartPowerBloc>(context);
|
final _blocProvider = BlocProvider.of<SmartPowerBloc>(context);
|
||||||
@ -68,7 +70,10 @@ class SmartPowerDeviceControl extends StatelessWidget with HelperResponsiveLayou
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Live',
|
'Live',
|
||||||
style: TextStyle(fontSize: 32, fontWeight: FontWeight.w700, color: ColorsManager.blackColor),
|
style: TextStyle(
|
||||||
|
fontSize: 32,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: ColorsManager.textPrimaryColor),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -80,19 +85,25 @@ class SmartPowerDeviceControl extends StatelessWidget with HelperResponsiveLayou
|
|||||||
PowerClampInfoCard(
|
PowerClampInfoCard(
|
||||||
iconPath: Assets.powerActiveIcon,
|
iconPath: Assets.powerActiveIcon,
|
||||||
title: 'Active',
|
title: 'Active',
|
||||||
value: blocProvider.deviceStatus.status.general.dataPoints[2].value.toString(),
|
value: blocProvider
|
||||||
|
.deviceStatus.status.general.dataPoints[2].value
|
||||||
|
.toString(),
|
||||||
unit: '',
|
unit: '',
|
||||||
),
|
),
|
||||||
PowerClampInfoCard(
|
PowerClampInfoCard(
|
||||||
iconPath: Assets.voltMeterIcon,
|
iconPath: Assets.voltMeterIcon,
|
||||||
title: 'Current',
|
title: 'Current',
|
||||||
value: blocProvider.deviceStatus.status.general.dataPoints[1].value.toString(),
|
value: blocProvider
|
||||||
|
.deviceStatus.status.general.dataPoints[1].value
|
||||||
|
.toString(),
|
||||||
unit: ' A',
|
unit: ' A',
|
||||||
),
|
),
|
||||||
PowerClampInfoCard(
|
PowerClampInfoCard(
|
||||||
iconPath: Assets.frequencyIcon,
|
iconPath: Assets.frequencyIcon,
|
||||||
title: 'Frequency',
|
title: 'Frequency',
|
||||||
value: blocProvider.deviceStatus.status.general.dataPoints[4].value.toString(),
|
value: blocProvider
|
||||||
|
.deviceStatus.status.general.dataPoints[4].value
|
||||||
|
.toString(),
|
||||||
unit: ' Hz',
|
unit: ' Hz',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -161,9 +172,10 @@ class SmartPowerDeviceControl extends StatelessWidget with HelperResponsiveLayou
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 10,
|
height: 5,
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
child: PageView(
|
child: PageView(
|
||||||
controller: _pageController,
|
controller: _pageController,
|
||||||
onPageChanged: (int page) {
|
onPageChanged: (int page) {
|
||||||
@ -172,12 +184,14 @@ class SmartPowerDeviceControl extends StatelessWidget with HelperResponsiveLayou
|
|||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
children: [
|
children: [
|
||||||
EnergyConsumptionPage(
|
EnergyConsumptionPage(
|
||||||
formattedDate: '${blocProvider.formattedDate}${blocProvider.endChartDate}',
|
formattedDate:
|
||||||
|
'${blocProvider.dateTime!.day}/${blocProvider.dateTime!.month}/${blocProvider.dateTime!.year} ${blocProvider.endChartDate}',
|
||||||
onTap: () {
|
onTap: () {
|
||||||
blocProvider.add(SelectDateEvent(context: context));
|
blocProvider.add(SelectDateEvent(context: context));
|
||||||
blocProvider.add(FilterRecordsByDateEvent(
|
blocProvider.add(FilterRecordsByDateEvent(
|
||||||
selectedDate: blocProvider.dateTime!,
|
selectedDate: blocProvider.dateTime!,
|
||||||
viewType: blocProvider.views[blocProvider.currentIndex]));
|
viewType: blocProvider
|
||||||
|
.views[blocProvider.currentIndex]));
|
||||||
},
|
},
|
||||||
widget: blocProvider.dateSwitcher(),
|
widget: blocProvider.dateSwitcher(),
|
||||||
chartData: blocProvider.energyDataList.isNotEmpty
|
chartData: blocProvider.energyDataList.isNotEmpty
|
||||||
@ -200,7 +214,8 @@ class SmartPowerDeviceControl extends StatelessWidget with HelperResponsiveLayou
|
|||||||
date: blocProvider.formattedDate,
|
date: blocProvider.formattedDate,
|
||||||
),
|
),
|
||||||
EnergyConsumptionPage(
|
EnergyConsumptionPage(
|
||||||
formattedDate: blocProvider.formattedDate,
|
formattedDate:
|
||||||
|
'${blocProvider.dateTime!.day}/${blocProvider.dateTime!.month}/${blocProvider.dateTime!.year} ${blocProvider.endChartDate}',
|
||||||
onTap: () {
|
onTap: () {
|
||||||
blocProvider.add(SelectDateEvent(context: context));
|
blocProvider.add(SelectDateEvent(context: context));
|
||||||
},
|
},
|
||||||
@ -225,7 +240,8 @@ class SmartPowerDeviceControl extends StatelessWidget with HelperResponsiveLayou
|
|||||||
date: blocProvider.formattedDate,
|
date: blocProvider.formattedDate,
|
||||||
),
|
),
|
||||||
EnergyConsumptionPage(
|
EnergyConsumptionPage(
|
||||||
formattedDate: blocProvider.formattedDate,
|
formattedDate:
|
||||||
|
'${blocProvider.dateTime!.day}/${blocProvider.dateTime!.month}/${blocProvider.dateTime!.year} ${blocProvider.endChartDate}',
|
||||||
onTap: () {
|
onTap: () {
|
||||||
blocProvider.add(SelectDateEvent(context: context));
|
blocProvider.add(SelectDateEvent(context: context));
|
||||||
},
|
},
|
||||||
|
@ -18,10 +18,11 @@ class AuthenticationAPI {
|
|||||||
static Future forgetPassword({
|
static Future forgetPassword({
|
||||||
required var email,
|
required var email,
|
||||||
required var password,
|
required var password,
|
||||||
|
required var otpCode,
|
||||||
}) async {
|
}) async {
|
||||||
final response = await HTTPService().post(
|
final response = await HTTPService().post(
|
||||||
path: ApiEndpoints.forgetPassword,
|
path: ApiEndpoints.forgetPassword,
|
||||||
body: {"email": email, "password": password},
|
body: {"email": email, "password": password,"otpCode": otpCode},
|
||||||
showServerMessage: true,
|
showServerMessage: true,
|
||||||
expectedResponseModel: (json) {});
|
expectedResponseModel: (json) {});
|
||||||
return response;
|
return response;
|
||||||
|
@ -42,4 +42,5 @@ abstract class ColorsManager {
|
|||||||
static const Color textGreen = Color(0xFF008905);
|
static const Color textGreen = Color(0xFF008905);
|
||||||
static const Color yaGreen = Color(0xFFFFBF44);
|
static const Color yaGreen = Color(0xFFFFBF44);
|
||||||
}
|
}
|
||||||
//background: #999999;
|
//background: #background: #5D5D5D;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user