mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-26 10:24:53 +00:00
4&6scene
This commit is contained in:
@ -41,10 +41,10 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
|||||||
on<GetSceneBySwitchName>(getSceneByName);
|
on<GetSceneBySwitchName>(getSceneByName);
|
||||||
on<SelectSceneEvent>(_selectScene);
|
on<SelectSceneEvent>(_selectScene);
|
||||||
on<SixSceneInitialInfo>(fetchDeviceInfo);
|
on<SixSceneInitialInfo>(fetchDeviceInfo);
|
||||||
on<ControlDeviceScene>(_controlDevice);
|
|
||||||
on<SaveNameEvent>(saveName);
|
on<SaveNameEvent>(saveName);
|
||||||
on<AssignRoomEvent>(_assignDevice);
|
on<AssignRoomEvent>(_assignDevice);
|
||||||
on<FetchRoomsEvent>(_fetchRoomsAndDevices);
|
on<FetchRoomsEvent>(_fetchRoomsAndDevices);
|
||||||
|
on<SixSceneInitialQuestion>(_onSixSceneInitial);
|
||||||
}
|
}
|
||||||
|
|
||||||
final TextEditingController nameController =
|
final TextEditingController nameController =
|
||||||
@ -358,12 +358,14 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
|||||||
value: switchStatus),
|
value: switchStatus),
|
||||||
sixSceneId);
|
sixSceneId);
|
||||||
deviceStatus.switch_backlight = switchStatus;
|
deviceStatus.switch_backlight = switchStatus;
|
||||||
if (!response['success']) {
|
|
||||||
add(const SixSceneInitial());
|
|
||||||
}
|
|
||||||
emit(ChangeSwitchState(isEnable: switchStatus));
|
|
||||||
} catch (_) {
|
|
||||||
add(const SixSceneInitial());
|
add(const SixSceneInitial());
|
||||||
|
add(const SexSceneSwitchInitial());
|
||||||
|
|
||||||
|
emit(ChangeSwitchState(isEnable: switchStatus));
|
||||||
|
emit(UpdateState(device: deviceStatus));
|
||||||
|
} catch (_) {
|
||||||
|
emit(const SixSceneFailedState(errorMessage: 'Something went wrong'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,27 +457,6 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
|||||||
emit(UpdateStateList(groupDevices: groupDevices, devices: devices));
|
emit(UpdateStateList(groupDevices: groupDevices, devices: devices));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _controlDevice(
|
|
||||||
ControlDeviceScene event, Emitter<SixSceneState> emit) async {
|
|
||||||
emit(SixSceneLoadingState());
|
|
||||||
try {
|
|
||||||
deviceStatus.switch_backlight = !event.backLight!;
|
|
||||||
emit(UpdateState(device: deviceStatus));
|
|
||||||
final response = await DevicesAPI.controlDevice(
|
|
||||||
DeviceControlModel(
|
|
||||||
deviceId: sixSceneId,
|
|
||||||
code: 'switch_backlight',
|
|
||||||
value: !event.backLight!),
|
|
||||||
sixSceneId);
|
|
||||||
|
|
||||||
if (!response['success']) {
|
|
||||||
// add(InitialEvent(groupScreen: oneTouchGroup));
|
|
||||||
}
|
|
||||||
} catch (_) {
|
|
||||||
// add(InitialEvent(groupScreen: oneTouchGroup));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool _validateInputs() {
|
bool _validateInputs() {
|
||||||
final nameError = fullNameValidator(nameController.text);
|
final nameError = fullNameValidator(nameController.text);
|
||||||
if (nameError != null) {
|
if (nameError != null) {
|
||||||
|
|||||||
@ -202,10 +202,6 @@ class AssignDeviceScene extends SixSceneEvent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class ControlDeviceScene extends SixSceneEvent {
|
|
||||||
final bool? backLight;
|
|
||||||
const ControlDeviceScene({this.backLight});
|
|
||||||
}
|
|
||||||
|
|
||||||
class AssignRoomEvent extends SixSceneEvent {
|
class AssignRoomEvent extends SixSceneEvent {
|
||||||
final String roomId;
|
final String roomId;
|
||||||
|
|||||||
@ -394,9 +394,8 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
|||||||
value: switchStatus),
|
value: switchStatus),
|
||||||
fourSceneId);
|
fourSceneId);
|
||||||
deviceStatus.switch_backlight = switchStatus;
|
deviceStatus.switch_backlight = switchStatus;
|
||||||
if (!response['success']) {
|
add(const FourSceneInitial());
|
||||||
add(const FourSceneInitial());
|
|
||||||
}
|
|
||||||
emit(ChangeSwitchState(isEnable: switchStatus));
|
emit(ChangeSwitchState(isEnable: switchStatus));
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
add(const FourSceneInitial());
|
add(const FourSceneInitial());
|
||||||
|
|||||||
@ -1,16 +1,19 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_bloc.dart';
|
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_bloc.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_event.dart';
|
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_event.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart';
|
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart';
|
||||||
|
|
||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/six_scene_model.dart';
|
import 'package:syncrow_app/features/devices/model/six_scene_model.dart';
|
||||||
|
import 'package:syncrow_app/features/menu/view/widgets/manage_home/home_settings.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
|
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||||
|
import 'package:syncrow_app/utils/helpers/custom_page_route.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
class ShareSixScenePage extends StatelessWidget {
|
class ShareSixScenePage extends StatelessWidget {
|
||||||
@ -20,6 +23,8 @@ class ShareSixScenePage extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
var spaces = HomeCubit.getInstance().spaces;
|
||||||
|
|
||||||
return DefaultScaffold(
|
return DefaultScaffold(
|
||||||
title: 'Share Device',
|
title: 'Share Device',
|
||||||
child: BlocProvider(
|
child: BlocProvider(
|
||||||
@ -94,7 +99,12 @@ class ShareSixScenePage extends StatelessWidget {
|
|||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
backgroundColor: ColorsManager.blueColor1,
|
backgroundColor: ColorsManager.blueColor1,
|
||||||
borderRadius: 50,
|
borderRadius: 50,
|
||||||
onPressed: () {},
|
onPressed: () {
|
||||||
|
Navigator.of(context).push(CustomPageRoute(
|
||||||
|
builder: (context) => HomeSettingsView(
|
||||||
|
space: spaces!.first,
|
||||||
|
)));
|
||||||
|
},
|
||||||
child: Text('Add Home Member')),
|
child: Text('Add Home Member')),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -35,7 +35,7 @@ class SixSceneSettings extends StatelessWidget {
|
|||||||
create: (context) => SixSceneBloc(sixSceneId: device?.uuid ?? '')
|
create: (context) => SixSceneBloc(sixSceneId: device?.uuid ?? '')
|
||||||
..add(const SixSceneInitial())
|
..add(const SixSceneInitial())
|
||||||
..add(const SixSceneInitial())
|
..add(const SixSceneInitial())
|
||||||
..add(SixSceneInitialInfo()),
|
..add(const SixSceneInitialInfo()),
|
||||||
child: BlocBuilder<SixSceneBloc, SixSceneState>(
|
child: BlocBuilder<SixSceneBloc, SixSceneState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final _bloc = BlocProvider.of<SixSceneBloc>(context);
|
final _bloc = BlocProvider.of<SixSceneBloc>(context);
|
||||||
@ -84,14 +84,15 @@ class SixSceneSettings extends StatelessWidget {
|
|||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
DefaultContainer(
|
DefaultContainer(
|
||||||
borderRadius:
|
borderRadius: const BorderRadius.all(
|
||||||
BorderRadius.all(Radius.circular(30)),
|
Radius.circular(30)),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.only(left: 90),
|
padding:
|
||||||
|
const EdgeInsets.only(left: 90),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment:
|
mainAxisAlignment:
|
||||||
MainAxisAlignment.spaceBetween,
|
MainAxisAlignment.spaceBetween,
|
||||||
@ -104,7 +105,7 @@ class SixSceneSettings extends StatelessWidget {
|
|||||||
text: _bloc.deviceInfo.name,
|
text: _bloc.deviceInfo.name,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
SizedBox(
|
const SizedBox(
|
||||||
height: 5,
|
height: 5,
|
||||||
),
|
),
|
||||||
BodySmall(
|
BodySmall(
|
||||||
@ -112,7 +113,7 @@ class SixSceneSettings extends StatelessWidget {
|
|||||||
.subspace.subspaceName),
|
.subspace.subspaceName),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Icon(Icons.edit_sharp)
|
const Icon(Icons.edit_sharp)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -166,20 +167,20 @@ class SixSceneSettings extends StatelessWidget {
|
|||||||
text: 'Device Information',
|
text: 'Device Information',
|
||||||
icon: Assets.infoIcon,
|
icon: Assets.infoIcon,
|
||||||
),
|
),
|
||||||
const Divider(
|
// const Divider(
|
||||||
color: ColorsManager.dividerColor,
|
// color: ColorsManager.dividerColor,
|
||||||
),
|
// ),
|
||||||
SettingWidget(
|
// SettingWidget(
|
||||||
onTap: () {
|
// onTap: () {
|
||||||
Navigator.of(context).push(
|
// Navigator.of(context).push(
|
||||||
MaterialPageRoute(
|
// MaterialPageRoute(
|
||||||
builder: (context) =>
|
// builder: (context) =>
|
||||||
ShareSixScenePage(device: device!)),
|
// ShareSixScenePage(device: device!)),
|
||||||
);
|
// );
|
||||||
},
|
// },
|
||||||
text: 'Tap-to Run and Automation',
|
// text: 'Tap-to Run and Automation',
|
||||||
icon: Assets.tapRunIcon,
|
// icon: Assets.tapRunIcon,
|
||||||
),
|
// ),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -225,20 +226,20 @@ class SixSceneSettings extends StatelessWidget {
|
|||||||
text: 'Share Device',
|
text: 'Share Device',
|
||||||
icon: Assets.shareIcon,
|
icon: Assets.shareIcon,
|
||||||
),
|
),
|
||||||
const Divider(
|
// const Divider(
|
||||||
color: ColorsManager.dividerColor,
|
// color: ColorsManager.dividerColor,
|
||||||
),
|
// ),
|
||||||
SettingWidget(
|
// SettingWidget(
|
||||||
onTap: () {
|
// onTap: () {
|
||||||
Navigator.of(context).push(
|
// Navigator.of(context).push(
|
||||||
MaterialPageRoute(
|
// MaterialPageRoute(
|
||||||
builder: (context) =>
|
// builder: (context) =>
|
||||||
SixSceneCreateGroup(device: device!)),
|
// SixSceneCreateGroup(device: device!)),
|
||||||
);
|
// );
|
||||||
},
|
// },
|
||||||
text: 'Create Group',
|
// text: 'Create Group',
|
||||||
icon: Assets.createGroupIcon,
|
// icon: Assets.createGroupIcon,
|
||||||
),
|
// ),
|
||||||
const Divider(
|
const Divider(
|
||||||
color: ColorsManager.dividerColor,
|
color: ColorsManager.dividerColor,
|
||||||
),
|
),
|
||||||
|
|||||||
@ -136,6 +136,7 @@ class SixSceneScreen extends StatelessWidget {
|
|||||||
child: DefaultContainer(
|
child: DefaultContainer(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_bloc.add(ChangeSwitchStatusEvent());
|
_bloc.add(ChangeSwitchStatusEvent());
|
||||||
|
|
||||||
},
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment:
|
crossAxisAlignment:
|
||||||
|
|||||||
@ -1,15 +1,18 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_bloc.dart';
|
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_bloc.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_event.dart';
|
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_event.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_state.dart';
|
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_state.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/four_scene_model.dart';
|
import 'package:syncrow_app/features/devices/model/four_scene_model.dart';
|
||||||
|
import 'package:syncrow_app/features/menu/view/widgets/manage_home/home_settings.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
|
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||||
|
import 'package:syncrow_app/utils/helpers/custom_page_route.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
class ShareFourScenePage extends StatelessWidget {
|
class ShareFourScenePage extends StatelessWidget {
|
||||||
@ -17,6 +20,8 @@ class ShareFourScenePage extends StatelessWidget {
|
|||||||
const ShareFourScenePage({super.key, this.device});
|
const ShareFourScenePage({super.key, this.device});
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
var spaces = HomeCubit.getInstance().spaces;
|
||||||
|
|
||||||
return DefaultScaffold(
|
return DefaultScaffold(
|
||||||
title: 'Share Device',
|
title: 'Share Device',
|
||||||
child: BlocProvider(
|
child: BlocProvider(
|
||||||
@ -89,7 +94,12 @@ class ShareFourScenePage extends StatelessWidget {
|
|||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
backgroundColor: ColorsManager.blueColor1,
|
backgroundColor: ColorsManager.blueColor1,
|
||||||
borderRadius: 50,
|
borderRadius: 50,
|
||||||
onPressed: () {},
|
onPressed: () {
|
||||||
|
Navigator.of(context).push(CustomPageRoute(
|
||||||
|
builder: (context) => HomeSettingsView(
|
||||||
|
space: spaces!.first,
|
||||||
|
)));
|
||||||
|
},
|
||||||
child: Text('Add Home Member')),
|
child: Text('Add Home Member')),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user