mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
water heater and timer and schedule ui and api ,
Circulate ui and Inching ui
This commit is contained in:
@ -38,10 +38,8 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
WaterHeaterBloc({required this.whId,required this.switchCode}) : super(WHInitialState()) {
|
||||
on<WaterHeaterInitial>(_fetchWaterHeaterStatus);
|
||||
on<WaterHeaterSwitch>(_changeFirstSwitch);
|
||||
|
||||
on<SetCounterValue>(_setCounterValue);
|
||||
on<GetCounterEvent>(_getCounterValue);
|
||||
|
||||
on<ToggleDaySelectionEvent>(toggleDaySelection);
|
||||
on<ScheduleSave>(saveSchedule);
|
||||
on<GetScheduleEvent>(getSchedule);
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
|
||||
abstract class WaterHeaterEvent extends Equatable {
|
||||
const WaterHeaterEvent();
|
||||
|
@ -1,6 +1,5 @@
|
||||
|
||||
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
|
@ -12,7 +12,6 @@ import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
import '../../../../../generated/assets.dart';
|
||||
|
||||
class WaterHeaterPage extends StatelessWidget {
|
||||
@ -21,19 +20,15 @@ class WaterHeaterPage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool value = false;
|
||||
return DefaultScaffold(
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
WaterHeaterBloc(switchCode: 'switch_1', whId: device?.uuid ?? '')
|
||||
..add(const WaterHeaterInitial()),
|
||||
WaterHeaterBloc(switchCode: 'switch_1', whId: device?.uuid ?? '')
|
||||
..add(const WaterHeaterInitial()),
|
||||
child: BlocBuilder<WaterHeaterBloc, WaterHeaterState>(
|
||||
builder: (context, state) {
|
||||
final waterHeaterBloc = BlocProvider.of<WaterHeaterBloc>(context);
|
||||
|
||||
WHModel whModel = WHModel(firstCountDown: 0, firstSwitch: false);
|
||||
|
||||
|
||||
if (state is LoadingNewSate) {
|
||||
whModel = state.whModel;
|
||||
} else if (state is UpdateState) {
|
||||
|
@ -18,7 +18,7 @@ import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
|
||||
import '../../../bloc/water_heater_bloc/water_heater_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/water_heater_bloc/water_heater_event.dart';
|
||||
|
||||
class WHTimerScheduleScreen extends StatelessWidget {
|
||||
final DeviceModel device;
|
||||
@ -76,36 +76,33 @@ class WHTimerScheduleScreen extends StatelessWidget {
|
||||
fontWeight: FontsManager.bold,
|
||||
),
|
||||
actions: [
|
||||
waterHeaterBloc.createSchedule == true
|
||||
&& waterHeaterBloc.selectedTabIndex == 1 ? TextButton(
|
||||
onPressed: () {
|
||||
waterHeaterBloc.add(ScheduleSave());
|
||||
},
|
||||
child: const Text('Save'))
|
||||
: waterHeaterBloc.selectedTabIndex == 1
|
||||
? IconButton(
|
||||
onPressed: () {
|
||||
waterHeaterBloc.toggleCreateSchedule();
|
||||
},
|
||||
icon: const Icon(Icons.add),
|
||||
)
|
||||
: const SizedBox(),
|
||||
|
||||
|
||||
waterHeaterBloc.createCirculate == true
|
||||
&&waterHeaterBloc.selectedTabIndex==2 ? TextButton(
|
||||
onPressed: () {
|
||||
waterHeaterBloc.add(ScheduleSave());
|
||||
},
|
||||
child: const Text('Save'))
|
||||
waterHeaterBloc.createSchedule == true && waterHeaterBloc.selectedTabIndex == 1 ?
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
waterHeaterBloc.add(ScheduleSave());
|
||||
},
|
||||
child: const Text('Save')) : waterHeaterBloc.selectedTabIndex == 1
|
||||
? IconButton(
|
||||
onPressed: () {
|
||||
waterHeaterBloc.toggleCreateSchedule();
|
||||
},
|
||||
icon: const Icon(Icons.add),
|
||||
)
|
||||
: const SizedBox(),
|
||||
waterHeaterBloc.createCirculate == true &&waterHeaterBloc.selectedTabIndex==2 ?
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
waterHeaterBloc.add(ScheduleSave());
|
||||
},
|
||||
child: const Text('Save'))
|
||||
: waterHeaterBloc.selectedTabIndex == 2
|
||||
? IconButton(
|
||||
onPressed: () {
|
||||
waterHeaterBloc.toggleCreateCirculate();
|
||||
},
|
||||
icon: const Icon(Icons.add),
|
||||
)
|
||||
: const SizedBox(),
|
||||
? IconButton(
|
||||
onPressed: () {
|
||||
waterHeaterBloc.toggleCreateCirculate();
|
||||
},
|
||||
icon: const Icon(Icons.add),
|
||||
)
|
||||
: const SizedBox(),
|
||||
],
|
||||
),
|
||||
child: state is WHLoadingState
|
||||
@ -137,6 +134,9 @@ class WHTimerScheduleScreen extends StatelessWidget {
|
||||
}
|
||||
waterHeaterBloc.toggleSelectedIndex(value);
|
||||
} else {
|
||||
if (waterHeaterBloc.createSchedule == true) {
|
||||
waterHeaterBloc.toggleCreateSchedule();
|
||||
}
|
||||
waterHeaterBloc.toggleSelectedIndex(value);
|
||||
}
|
||||
},
|
||||
@ -213,8 +213,7 @@ class WHTimerScheduleScreen extends StatelessWidget {
|
||||
'Circulate',
|
||||
style: context.bodySmall.copyWith(
|
||||
color: waterHeaterBloc
|
||||
.selectedTabIndex ==
|
||||
2
|
||||
.selectedTabIndex == 2
|
||||
? Colors.white
|
||||
: ColorsManager.blackColor,
|
||||
fontSize: 8,
|
||||
@ -227,8 +226,7 @@ class WHTimerScheduleScreen extends StatelessWidget {
|
||||
icon: SvgPicture.asset(
|
||||
Assets.scheduleInchingIcon,
|
||||
color: waterHeaterBloc
|
||||
.selectedTabIndex ==
|
||||
3
|
||||
.selectedTabIndex == 3
|
||||
? Colors.white
|
||||
: ColorsManager.blackColor,
|
||||
),
|
||||
@ -239,8 +237,7 @@ class WHTimerScheduleScreen extends StatelessWidget {
|
||||
'Inching',
|
||||
style: context.bodySmall.copyWith(
|
||||
color: waterHeaterBloc
|
||||
.selectedTabIndex ==
|
||||
3
|
||||
.selectedTabIndex == 3
|
||||
? Colors.white
|
||||
: ColorsManager.blackColor,
|
||||
fontSize: 8,
|
||||
|
Reference in New Issue
Block a user