mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-26 10:54:55 +00:00
4&6scene
This commit is contained in:
@ -41,10 +41,10 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
on<GetSceneBySwitchName>(getSceneByName);
|
||||
on<SelectSceneEvent>(_selectScene);
|
||||
on<SixSceneInitialInfo>(fetchDeviceInfo);
|
||||
on<ControlDeviceScene>(_controlDevice);
|
||||
on<SaveNameEvent>(saveName);
|
||||
on<AssignRoomEvent>(_assignDevice);
|
||||
on<FetchRoomsEvent>(_fetchRoomsAndDevices);
|
||||
on<SixSceneInitialQuestion>(_onSixSceneInitial);
|
||||
}
|
||||
|
||||
final TextEditingController nameController =
|
||||
@ -358,12 +358,14 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
value: switchStatus),
|
||||
sixSceneId);
|
||||
deviceStatus.switch_backlight = switchStatus;
|
||||
if (!response['success']) {
|
||||
add(const SixSceneInitial());
|
||||
}
|
||||
emit(ChangeSwitchState(isEnable: switchStatus));
|
||||
} catch (_) {
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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() {
|
||||
final nameError = fullNameValidator(nameController.text);
|
||||
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 {
|
||||
final String roomId;
|
||||
|
||||
@ -394,9 +394,8 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
value: switchStatus),
|
||||
fourSceneId);
|
||||
deviceStatus.switch_backlight = switchStatus;
|
||||
if (!response['success']) {
|
||||
add(const FourSceneInitial());
|
||||
}
|
||||
add(const FourSceneInitial());
|
||||
|
||||
emit(ChangeSwitchState(isEnable: switchStatus));
|
||||
} catch (_) {
|
||||
add(const FourSceneInitial());
|
||||
|
||||
@ -1,16 +1,19 @@
|
||||
import 'package:flutter/material.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_event.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/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_container.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_medium.dart';
|
||||
import 'package:syncrow_app/utils/helpers/custom_page_route.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class ShareSixScenePage extends StatelessWidget {
|
||||
@ -20,6 +23,8 @@ class ShareSixScenePage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var spaces = HomeCubit.getInstance().spaces;
|
||||
|
||||
return DefaultScaffold(
|
||||
title: 'Share Device',
|
||||
child: BlocProvider(
|
||||
@ -94,7 +99,12 @@ class ShareSixScenePage extends StatelessWidget {
|
||||
child: DefaultButton(
|
||||
backgroundColor: ColorsManager.blueColor1,
|
||||
borderRadius: 50,
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(CustomPageRoute(
|
||||
builder: (context) => HomeSettingsView(
|
||||
space: spaces!.first,
|
||||
)));
|
||||
},
|
||||
child: Text('Add Home Member')),
|
||||
),
|
||||
)
|
||||
|
||||
@ -35,7 +35,7 @@ class SixSceneSettings extends StatelessWidget {
|
||||
create: (context) => SixSceneBloc(sixSceneId: device?.uuid ?? '')
|
||||
..add(const SixSceneInitial())
|
||||
..add(const SixSceneInitial())
|
||||
..add(SixSceneInitialInfo()),
|
||||
..add(const SixSceneInitialInfo()),
|
||||
child: BlocBuilder<SixSceneBloc, SixSceneState>(
|
||||
builder: (context, state) {
|
||||
final _bloc = BlocProvider.of<SixSceneBloc>(context);
|
||||
@ -84,14 +84,15 @@ class SixSceneSettings extends StatelessWidget {
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(height: 20),
|
||||
const SizedBox(height: 20),
|
||||
DefaultContainer(
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(30)),
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(30)),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10.0),
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 90),
|
||||
padding:
|
||||
const EdgeInsets.only(left: 90),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
@ -104,7 +105,7 @@ class SixSceneSettings extends StatelessWidget {
|
||||
text: _bloc.deviceInfo.name,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
BodySmall(
|
||||
@ -112,7 +113,7 @@ class SixSceneSettings extends StatelessWidget {
|
||||
.subspace.subspaceName),
|
||||
],
|
||||
),
|
||||
Icon(Icons.edit_sharp)
|
||||
const Icon(Icons.edit_sharp)
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -166,20 +167,20 @@ class SixSceneSettings extends StatelessWidget {
|
||||
text: 'Device Information',
|
||||
icon: Assets.infoIcon,
|
||||
),
|
||||
const Divider(
|
||||
color: ColorsManager.dividerColor,
|
||||
),
|
||||
SettingWidget(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
ShareSixScenePage(device: device!)),
|
||||
);
|
||||
},
|
||||
text: 'Tap-to Run and Automation',
|
||||
icon: Assets.tapRunIcon,
|
||||
),
|
||||
// const Divider(
|
||||
// color: ColorsManager.dividerColor,
|
||||
// ),
|
||||
// SettingWidget(
|
||||
// onTap: () {
|
||||
// Navigator.of(context).push(
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) =>
|
||||
// ShareSixScenePage(device: device!)),
|
||||
// );
|
||||
// },
|
||||
// text: 'Tap-to Run and Automation',
|
||||
// icon: Assets.tapRunIcon,
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -225,20 +226,20 @@ class SixSceneSettings extends StatelessWidget {
|
||||
text: 'Share Device',
|
||||
icon: Assets.shareIcon,
|
||||
),
|
||||
const Divider(
|
||||
color: ColorsManager.dividerColor,
|
||||
),
|
||||
SettingWidget(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
SixSceneCreateGroup(device: device!)),
|
||||
);
|
||||
},
|
||||
text: 'Create Group',
|
||||
icon: Assets.createGroupIcon,
|
||||
),
|
||||
// const Divider(
|
||||
// color: ColorsManager.dividerColor,
|
||||
// ),
|
||||
// SettingWidget(
|
||||
// onTap: () {
|
||||
// Navigator.of(context).push(
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) =>
|
||||
// SixSceneCreateGroup(device: device!)),
|
||||
// );
|
||||
// },
|
||||
// text: 'Create Group',
|
||||
// icon: Assets.createGroupIcon,
|
||||
// ),
|
||||
const Divider(
|
||||
color: ColorsManager.dividerColor,
|
||||
),
|
||||
|
||||
@ -136,6 +136,7 @@ class SixSceneScreen extends StatelessWidget {
|
||||
child: DefaultContainer(
|
||||
onTap: () {
|
||||
_bloc.add(ChangeSwitchStatusEvent());
|
||||
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
|
||||
@ -1,15 +1,18 @@
|
||||
import 'package:flutter/material.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_event.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/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_container.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_medium.dart';
|
||||
import 'package:syncrow_app/utils/helpers/custom_page_route.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class ShareFourScenePage extends StatelessWidget {
|
||||
@ -17,6 +20,8 @@ class ShareFourScenePage extends StatelessWidget {
|
||||
const ShareFourScenePage({super.key, this.device});
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var spaces = HomeCubit.getInstance().spaces;
|
||||
|
||||
return DefaultScaffold(
|
||||
title: 'Share Device',
|
||||
child: BlocProvider(
|
||||
@ -89,7 +94,12 @@ class ShareFourScenePage extends StatelessWidget {
|
||||
child: DefaultButton(
|
||||
backgroundColor: ColorsManager.blueColor1,
|
||||
borderRadius: 50,
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(CustomPageRoute(
|
||||
builder: (context) => HomeSettingsView(
|
||||
space: spaces!.first,
|
||||
)));
|
||||
},
|
||||
child: Text('Add Home Member')),
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user