Bug fixes

This commit is contained in:
Abdullah Alassaf
2024-11-12 00:15:26 +03:00
parent faf294bb10
commit b547a126ed
23 changed files with 342 additions and 510 deletions

View File

@ -1,7 +1,7 @@
import UIKit import UIKit
import Flutter import Flutter
@main @UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate { @objc class AppDelegate: FlutterAppDelegate {
override func application( override func application(
_ application: UIApplication, _ application: UIApplication,

View File

@ -55,8 +55,7 @@ class HomeCubit extends Cubit<HomeState> {
Future fetchUserInfo() async { Future fetchUserInfo() async {
try { try {
var uuid = var uuid = await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
user = await ProfileApi().fetchUserInfo(uuid); user = await ProfileApi().fetchUserInfo(uuid);
emit(HomeUserInfoLoaded(user!)); // Emit state after fetching user info emit(HomeUserInfoLoaded(user!)); // Emit state after fetching user info
} catch (e) { } catch (e) {
@ -77,12 +76,9 @@ class HomeCubit extends Cubit<HomeState> {
selectedSpace = null; selectedSpace = null;
selectedRoom = null; selectedRoom = null;
pageIndex = 0; pageIndex = 0;
OneSignal.User.pushSubscription OneSignal.User.pushSubscription.removeObserver((stateChanges) => oneSignalSubscriptionObserver);
.removeObserver((stateChanges) => oneSignalSubscriptionObserver); OneSignal.Notifications.removePermissionObserver((permission) => oneSignalPermissionObserver);
OneSignal.Notifications.removePermissionObserver( OneSignal.Notifications.removeClickListener((event) => oneSignalClickListenerObserver);
(permission) => oneSignalPermissionObserver);
OneSignal.Notifications.removeClickListener(
(event) => oneSignalClickListenerObserver);
return super.close(); return super.close();
} }
@ -124,9 +120,7 @@ class HomeCubit extends Cubit<HomeState> {
return; return;
} }
var userUuid = var userUuid = await const FlutterSecureStorage().read(key: UserModel.userUuidKey) ?? '';
await const FlutterSecureStorage().read(key: UserModel.userUuidKey) ??
'';
if (userUuid.isNotEmpty) { if (userUuid.isNotEmpty) {
await OneSignal.login(userUuid); await OneSignal.login(userUuid);
} }
@ -134,24 +128,21 @@ class HomeCubit extends Cubit<HomeState> {
await OneSignal.User.pushSubscription.optIn(); await OneSignal.User.pushSubscription.optIn();
//this function will be called once a user is subscribed //this function will be called once a user is subscribed
oneSignalSubscriptionObserver = oneSignalSubscriptionObserver = OneSignal.User.pushSubscription.addObserver((state) async {
OneSignal.User.pushSubscription.addObserver((state) async {
if (state.current.optedIn) { if (state.current.optedIn) {
await _sendSubscriptionId(); await _sendSubscriptionId();
} }
}); });
// Send the player id when a user allows notifications // Send the player id when a user allows notifications
oneSignalPermissionObserver = oneSignalPermissionObserver = OneSignal.Notifications.addPermissionObserver((state) async {
OneSignal.Notifications.addPermissionObserver((state) async {
await _sendSubscriptionId(); await _sendSubscriptionId();
}); });
//check if the player id is sent, if not send it again //check if the player id is sent, if not send it again
await _sendSubscriptionId(); await _sendSubscriptionId();
oneSignalClickListenerObserver = oneSignalClickListenerObserver = OneSignal.Notifications.addClickListener((event) async {
OneSignal.Notifications.addClickListener((event) async {
//Once the user clicks on the notification //Once the user clicks on the notification
}); });
} catch (err) { } catch (err) {
@ -222,8 +213,7 @@ class HomeCubit extends Cubit<HomeState> {
//////////////////////////////////////// API //////////////////////////////////////// //////////////////////////////////////// API ////////////////////////////////////////
generateInvitation(SpaceModel unit) async { generateInvitation(SpaceModel unit) async {
try { try {
final invitationCode = final invitationCode = await SpacesAPI.generateInvitationCode(unit.id, unit.community.uuid);
await SpacesAPI.generateInvitationCode(unit.id, unit.community.uuid);
if (invitationCode.isNotEmpty) { if (invitationCode.isNotEmpty) {
Share.share('The invitation code is $invitationCode'); Share.share('The invitation code is $invitationCode');
CustomSnackBar.displaySnackBar( CustomSnackBar.displaySnackBar(
@ -239,9 +229,7 @@ class HomeCubit extends Cubit<HomeState> {
Future<bool> joinAUnit(String code) async { Future<bool> joinAUnit(String code) async {
try { try {
var userUuid = var userUuid = await const FlutterSecureStorage().read(key: UserModel.userUuidKey) ?? '';
await const FlutterSecureStorage().read(key: UserModel.userUuidKey) ??
'';
Map<String, String> body = {'inviteCode': code}; Map<String, String> body = {'inviteCode': code};
final success = await SpacesAPI.joinUnit(userUuid, body); final success = await SpacesAPI.joinUnit(userUuid, body);
@ -277,14 +265,13 @@ class HomeCubit extends Cubit<HomeState> {
fetchRoomsByUnitId(SpaceModel space) async { fetchRoomsByUnitId(SpaceModel space) async {
emitSafe(GetSpaceRoomsLoading()); emitSafe(GetSpaceRoomsLoading());
try { try {
space.subspaces = space.subspaces = await SpacesAPI.getSubSpaceBySpaceId(space.community.uuid, space.id);
await SpacesAPI.getSubSpaceBySpaceId(space.community.uuid, space.id);
} catch (failure) { } catch (failure) {
emitSafe(GetSpaceRoomsError(failure.toString())); emitSafe(GetSpaceRoomsError(failure.toString()));
return; return;
} }
if (space.subspaces != null && space.subspaces!.isNotEmpty) { if (space.subspaces.isNotEmpty) {
emitSafe(GetSpaceRoomsSuccess(space.subspaces!)); emitSafe(GetSpaceRoomsSuccess(space.subspaces));
} else { } else {
emitSafe(GetSpaceRoomsError("No rooms found")); emitSafe(GetSpaceRoomsError("No rooms found"));
} }
@ -360,8 +347,7 @@ class HomeCubit extends Cubit<HomeState> {
size: 32, size: 32,
), ),
style: ButtonStyle( style: ButtonStyle(
foregroundColor: foregroundColor: WidgetStateProperty.all(ColorsManager.textPrimaryColor),
WidgetStateProperty.all(ColorsManager.textPrimaryColor),
), ),
onPressed: () { onPressed: () {
Navigator.pushNamed( Navigator.pushNamed(
@ -382,8 +368,7 @@ class HomeCubit extends Cubit<HomeState> {
NavigationService.navigatorKey.currentContext! NavigationService.navigatorKey.currentContext!
.read<SmartSceneSelectBloc>() .read<SmartSceneSelectBloc>()
.add(const SmartSceneClearEvent()); .add(const SmartSceneClearEvent());
BlocProvider.of<EffectPeriodBloc>( BlocProvider.of<EffectPeriodBloc>(NavigationService.navigatorKey.currentState!.context)
NavigationService.navigatorKey.currentState!.context)
.add(ResetEffectivePeriod()); .add(ResetEffectivePeriod());
NavigationService.navigatorKey.currentContext! NavigationService.navigatorKey.currentContext!
.read<CreateSceneBloc>() .read<CreateSceneBloc>()
@ -396,8 +381,7 @@ class HomeCubit extends Cubit<HomeState> {
size: 28, size: 28,
), ),
style: ButtonStyle( style: ButtonStyle(
foregroundColor: foregroundColor: WidgetStateProperty.all(ColorsManager.textPrimaryColor),
WidgetStateProperty.all(ColorsManager.textPrimaryColor),
), ),
onPressed: () {}, onPressed: () {},
), ),
@ -430,8 +414,7 @@ class HomeCubit extends Cubit<HomeState> {
}; };
static var bottomNavItems = [ static var bottomNavItems = [
defaultBottomNavBarItem( defaultBottomNavBarItem(icon: Assets.assetsIconsDashboard, label: 'Dashboard'),
icon: Assets.assetsIconsDashboard, label: 'Dashboard'),
// defaultBottomNavBarItem(icon: Assets.assetsIconslayout, label: 'Layout'), // defaultBottomNavBarItem(icon: Assets.assetsIconslayout, label: 'Layout'),
defaultBottomNavBarItem(icon: Assets.assetsIconsDevices, label: 'Devices'), defaultBottomNavBarItem(icon: Assets.assetsIconsDevices, label: 'Devices'),
defaultBottomNavBarItem(icon: Assets.assetsIconsRoutines, label: 'Routine'), defaultBottomNavBarItem(icon: Assets.assetsIconsRoutines, label: 'Routine'),
@ -457,8 +440,7 @@ class HomeCubit extends Cubit<HomeState> {
void updateDevice(String deviceId) async { void updateDevice(String deviceId) async {
try { try {
final response = await DevicesAPI.firmwareDevice( final response = await DevicesAPI.firmwareDevice(deviceId: deviceId, firmwareVersion: '0');
deviceId: deviceId, firmwareVersion: '0');
if (response['success'] ?? false) { if (response['success'] ?? false) {
CustomSnackBar.displaySnackBar('No updates available'); CustomSnackBar.displaySnackBar('No updates available');
} }
@ -466,8 +448,7 @@ class HomeCubit extends Cubit<HomeState> {
} }
} }
BottomNavigationBarItem defaultBottomNavBarItem( BottomNavigationBarItem defaultBottomNavBarItem({required String icon, required String label}) {
{required String icon, required String label}) {
return BottomNavigationBarItem( return BottomNavigationBarItem(
icon: SvgPicture.asset(icon), icon: SvgPicture.asset(icon),
activeIcon: SvgPicture.asset( activeIcon: SvgPicture.asset(

View File

@ -46,7 +46,7 @@ class AppBarHomeDropdown extends StatelessWidget {
const SizedBox(width: 5), const SizedBox(width: 5),
Flexible( Flexible(
child: BodyMedium( child: BodyMedium(
text: space.name ?? "??", text: space.name,
style: context.bodyMedium.copyWith( style: context.bodyMedium.copyWith(
fontSize: 15, fontSize: 15,
color: ColorsManager.textPrimaryColor, color: ColorsManager.textPrimaryColor,

View File

@ -14,16 +14,15 @@ import 'package:syncrow_app/utils/resource_manager/constants.dart';
import 'package:syncrow_app/utils/resource_manager/font_manager.dart'; import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
import 'package:syncrow_app/utils/resource_manager/styles_manager.dart'; import 'package:syncrow_app/utils/resource_manager/styles_manager.dart';
class checkEmailPage extends StatelessWidget { class CheckEmailPage extends StatelessWidget {
bool? forget; final bool? forget;
checkEmailPage({super.key, this.forget}); const CheckEmailPage({super.key, this.forget});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final formKey = AuthCubit.get(context).checkEmailFormKey; final formKey = AuthCubit.get(context).checkEmailFormKey;
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle( SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
statusBarBrightness: Brightness.light, statusBarBrightness: Brightness.light, statusBarIconBrightness: Brightness.light));
statusBarIconBrightness: Brightness.light));
return BlocConsumer<AuthCubit, AuthState>( return BlocConsumer<AuthCubit, AuthState>(
listener: (context, state) { listener: (context, state) {
if (state is AuthError) { if (state is AuthError) {
@ -93,9 +92,7 @@ class checkEmailPage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
SizedBox( SizedBox(
height: height: MediaQuery.sizeOf(context).height / 5.5,
MediaQuery.sizeOf(context).height /
5.5,
), ),
TitleMedium( TitleMedium(
text: 'Forgot password?', text: 'Forgot password?',
@ -117,39 +114,32 @@ class checkEmailPage extends StatelessWidget {
scrollPadding: EdgeInsets.zero, scrollPadding: EdgeInsets.zero,
autocorrect: false, autocorrect: false,
enableSuggestions: false, enableSuggestions: false,
autofillHints: const [ autofillHints: const [AutofillHints.email],
AutofillHints.email validator: AuthCubit.get(context).emailAddressValidator,
],
validator: AuthCubit.get(context)
.emailAddressValidator,
onTapOutside: (event) { onTapOutside: (event) {
FocusScope.of(context).unfocus(); FocusScope.of(context).unfocus();
}, },
onChanged: (value) { onChanged: (value) {
AuthCubit.get(context).email = value; AuthCubit.get(context).email = value;
}, },
decoration: defaultInputDecoration( decoration: defaultInputDecoration(context,
context,
hint: "Example@email.com"), hint: "Example@email.com"),
), ),
const SizedBox( const SizedBox(
height: 20, height: 20,
), ),
Row( Row(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.center,
MainAxisAlignment.center,
children: [ children: [
Expanded( Expanded(
child: DefaultButton( child: DefaultButton(
isDone: state is AuthLoginSuccess, isDone: state is AuthLoginSuccess,
isLoading: state is AuthLoading, isLoading: state is AuthLoading,
customButtonStyle: ButtonStyle( customButtonStyle: ButtonStyle(
backgroundColor: backgroundColor: MaterialStateProperty.all(
MaterialStateProperty.all(
Colors.black.withOpacity(.25), Colors.black.withOpacity(.25),
), ),
foregroundColor: foregroundColor: MaterialStateProperty.all(
MaterialStateProperty.all(
Colors.white, Colors.white,
), ),
), ),
@ -157,16 +147,11 @@ class checkEmailPage extends StatelessWidget {
'Send Code', 'Send Code',
), ),
onPressed: () { onPressed: () {
AuthCubit.get(context) AuthCubit.get(context).showValidationMessage = true;
.showValidationMessage = true; if (formKey.currentState!.validate()) {
if (formKey.currentState!
.validate()) {
if ((state is! AuthLoading)) { if ((state is! AuthLoading)) {
AuthCubit.get(context) AuthCubit.get(context).sendOtp(isforget: forget);
.sendOtp( FocusScope.of(context).unfocus();
isforget: forget);
FocusScope.of(context)
.unfocus();
} }
} }
}, },
@ -176,17 +161,14 @@ class checkEmailPage extends StatelessWidget {
), ),
Padding( Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: MediaQuery.sizeOf(context) top: MediaQuery.sizeOf(context).height / 5.5),
.height /
5.5),
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.center,
MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
BodyLarge( BodyLarge(
text: "Do you have an account? ", text: "Do you have an account? ",
style: context.displaySmall style:
.copyWith(color: Colors.white), context.displaySmall.copyWith(color: Colors.white),
), ),
TextButton( TextButton(
onPressed: () { onPressed: () {
@ -194,8 +176,7 @@ class checkEmailPage extends StatelessWidget {
}, },
child: BodyLarge( child: BodyLarge(
text: "Sign in", text: "Sign in",
style: style: context.displaySmall.copyWith(
context.displaySmall.copyWith(
color: Colors.black, color: Colors.black,
fontWeight: FontsManager.bold, fontWeight: FontsManager.bold,
), ),

View File

@ -19,7 +19,7 @@ class ForgetPassword extends StatelessWidget {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => checkEmailPage(forget: isforget), builder: (context) => CheckEmailPage(forget: isforget),
)); ));
}, },
child: BodyMedium( child: BodyMedium(

View File

@ -25,12 +25,12 @@ part 'devices_state.dart';
class DevicesCubit extends Cubit<DevicesState> { class DevicesCubit extends Cubit<DevicesState> {
Future<void> _initializeDevices(SpaceModel selectedSpace) async { Future<void> _initializeDevices(SpaceModel selectedSpace) async {
// Fetch devices for each room in the selected space // Fetch devices for each room in the selected space
for (var room in selectedSpace.subspaces ?? []) { for (var room in selectedSpace.subspaces) {
await fetchDevicesByRoomId(selectedSpace, room.id!); await fetchDevicesByRoomId(selectedSpace, room.id!);
} }
// Fetch groups based on the selected space ID // Fetch groups based on the selected space ID
await fetchGroups(selectedSpace.id ?? ''); await fetchGroups(selectedSpace.id);
} }
DevicesCubit._() : super(DevicesInitial()) { DevicesCubit._() : super(DevicesInitial()) {
@ -111,9 +111,8 @@ class DevicesCubit extends Cubit<DevicesState> {
// Getter to retrieve all devices from HomeCubit // Getter to retrieve all devices from HomeCubit
List<DeviceModel> get allDevices { List<DeviceModel> get allDevices {
List<DeviceModel> devices = []; List<DeviceModel> devices = [];
if (HomeCubit.getInstance().selectedSpace != null && if (HomeCubit.getInstance().selectedSpace != null) {
HomeCubit.getInstance().selectedSpace!.subspaces != null) { for (var room in HomeCubit.getInstance().selectedSpace!.subspaces) {
for (var room in HomeCubit.getInstance().selectedSpace!.subspaces!) {
if (room.devices != null) { if (room.devices != null) {
devices.addAll(room.devices!); devices.addAll(room.devices!);
} }
@ -278,15 +277,15 @@ class DevicesCubit extends Cubit<DevicesState> {
if (response['success'] ?? false) { if (response['success'] ?? false) {
emitSafe(DeviceControlSuccess(code: control.code)); emitSafe(DeviceControlSuccess(code: control.code));
//this delay is to give tuya server time to update the status //this delay is to give tuya server time to update the status
Future.delayed(const Duration(milliseconds: 400), () { // Future.delayed(const Duration(milliseconds: 400), () {
fetchDevicesStatues( fetchDevicesStatues(
deviceId, deviceId,
HomeCubit.getInstance() HomeCubit.getInstance()
.selectedSpace! .selectedSpace!
.subspaces! .subspaces
.indexOf(HomeCubit.getInstance().selectedRoom!), .indexOf(HomeCubit.getInstance().selectedRoom!),
code: control.code); code: control.code);
}); // });
} else { } else {
emitSafe(DeviceControlError('Failed to control the device')); emitSafe(DeviceControlError('Failed to control the device'));
} }
@ -317,20 +316,17 @@ class DevicesCubit extends Cubit<DevicesState> {
emitSafe(GetDevicesLoading()); emitSafe(GetDevicesLoading());
int roomIndex = HomeCubit.getInstance() int roomIndex = HomeCubit.getInstance()
.selectedSpace! .selectedSpace!
.subspaces! .subspaces
.indexWhere((element) => element.id == roomId); .indexWhere((element) => element.id == roomId);
try { try {
HomeCubit.getInstance().selectedSpace!.subspaces![roomIndex].devices = HomeCubit.getInstance().selectedSpace!.subspaces[roomIndex].devices =
await DevicesAPI.getDevicesByRoomId( await DevicesAPI.getDevicesByRoomId(
communityUuid: unit!.community.uuid, communityUuid: unit!.community.uuid, spaceUuid: unit.id, roomId: roomId);
spaceUuid: unit.id,
roomId: roomId);
} catch (e) { } catch (e) {
emitSafe(GetDevicesError(e.toString())); emitSafe(GetDevicesError(e.toString()));
return; return;
} }
final devices = final devices = HomeCubit.getInstance().selectedSpace!.subspaces[roomIndex].devices;
HomeCubit.getInstance().selectedSpace!.subspaces![roomIndex].devices;
emitSafe(GetDevicesSuccess(devices)); emitSafe(GetDevicesSuccess(devices));
//get status for each device //get status for each device
@ -347,7 +343,7 @@ class DevicesCubit extends Cubit<DevicesState> {
emitSafe(GetDeviceStatusLoading(code: code)); emitSafe(GetDeviceStatusLoading(code: code));
int deviceIndex = HomeCubit.getInstance() int deviceIndex = HomeCubit.getInstance()
.selectedSpace! .selectedSpace!
.subspaces![roomIndex] .subspaces[roomIndex]
.devices! .devices!
.indexWhere((element) => element.uuid == deviceUuid); .indexWhere((element) => element.uuid == deviceUuid);
List<StatusModel> statuses = []; List<StatusModel> statuses = [];
@ -360,11 +356,8 @@ class DevicesCubit extends Cubit<DevicesState> {
emitSafe(GetDeviceStatusError(e.toString())); emitSafe(GetDeviceStatusError(e.toString()));
return; return;
} }
HomeCubit.getInstance() HomeCubit.getInstance().selectedSpace!.subspaces[roomIndex].devices![deviceIndex].status =
.selectedSpace! statuses;
.subspaces![roomIndex]
.devices![deviceIndex]
.status = statuses;
emitSafe(GetDeviceStatusSuccess(code: code)); emitSafe(GetDeviceStatusSuccess(code: code));
} }

View File

@ -14,8 +14,7 @@ class PowerClampSwitch extends PowerClampEvent {
final bool switchD; final bool switchD;
final String deviceId; final String deviceId;
final String productId; final String productId;
const PowerClampSwitch( const PowerClampSwitch({required this.switchD, this.deviceId = '', this.productId = ''});
{required this.switchD, this.deviceId = '', this.productId = ''});
@override @override
List<Object> get props => [switchD, deviceId, productId]; List<Object> get props => [switchD, deviceId, productId];
@ -26,8 +25,8 @@ class PowerClampUpdated extends PowerClampEvent {}
class FetchEnergyData extends PowerClampEvent {} class FetchEnergyData extends PowerClampEvent {}
class SelectDateEvent extends PowerClampEvent { class SelectDateEvent extends PowerClampEvent {
BuildContext context; final BuildContext context;
SelectDateEvent({required this.context}); const SelectDateEvent({required this.context});
} }
class PowerClampInitial extends PowerClampEvent { class PowerClampInitial extends PowerClampEvent {
@ -108,12 +107,9 @@ class StopTimer extends PowerClampEvent {}
class OnClose extends PowerClampEvent {} class OnClose extends PowerClampEvent {}
class FilterRecordsByDateEvent extends PowerClampEvent { class FilterRecordsByDateEvent extends PowerClampEvent {
final DateTime selectedDate; final DateTime selectedDate;
final String viewType; // 'Day', 'Month', 'Year' final String viewType; // 'Day', 'Month', 'Year'
const FilterRecordsByDateEvent( const FilterRecordsByDateEvent({required this.selectedDate, required this.viewType});
{required this.selectedDate, required this.viewType});
} }

View File

@ -13,13 +13,14 @@ import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart'; import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
import 'package:syncrow_app/utils/context_extension.dart'; import 'package:syncrow_app/utils/context_extension.dart';
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart'; import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
class DevicesViewPage extends StatelessWidget { class DevicesViewPage extends StatelessWidget {
const DevicesViewPage({super.key}); const DevicesViewPage({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocProvider( return BlocProvider(
create: (context) => SceneBloc(), // Initialize your SceneBloc here create: (context) => SceneBloc(), // Initialize your SceneBloc here
child: DevicesViewBody(), child: DevicesViewBody(),
); );
} }
@ -42,75 +43,74 @@ class DevicesViewBody extends StatelessWidget {
return HomeCubit.getInstance().spaces?.isEmpty ?? true return HomeCubit.getInstance().spaces?.isEmpty ?? true
? const CreateUnitWidget() ? const CreateUnitWidget()
: Column( : Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
children: [
TitleMedium(
text: StringsManager.devices,
style: context.titleMedium.copyWith(
fontSize: 25,
),
),
],
),
SizedBox(
height: MediaQuery.of(context).size.height*0.1,
child: const SceneView(pageType: true,)
),
const SizedBox(
height: 20,
),
const RoomsSlider(),
const SizedBox(
height: 10,
),
Expanded(
child: PageView(
controller: HomeCubit.getInstance().devicesPageController,
onPageChanged: (index) {
HomeCubit.getInstance().devicesPageChanged(index);
},
children: [ children: [
WizardPage( Row(
groupsList: DevicesCubit.getInstance().allCategories ?? [], children: [
TitleMedium(
text: StringsManager.devices,
style: context.titleMedium.copyWith(
fontSize: 25,
),
),
],
), ),
if (HomeCubit.getInstance().selectedSpace != null) SizedBox(
if (HomeCubit.getInstance().selectedSpace!.subspaces != null) height: MediaQuery.of(context).size.height * 0.1,
...HomeCubit.getInstance().selectedSpace!.subspaces!.map((room) { child: const SceneView(
return RoomPage( pageType: true,
room: room, )),
); const SizedBox(
}, height: 20,
) ),
const RoomsSlider(),
const SizedBox(
height: 10,
),
Expanded(
child: PageView(
controller: HomeCubit.getInstance().devicesPageController,
onPageChanged: (index) {
HomeCubit.getInstance().devicesPageChanged(index);
},
children: [
WizardPage(
groupsList: DevicesCubit.getInstance().allCategories ?? [],
),
if (HomeCubit.getInstance().selectedSpace != null)
...HomeCubit.getInstance().selectedSpace!.subspaces.map(
(room) {
return RoomPage(
room: room,
);
},
)
],
),
),
HomeCubit.getInstance().selectedSpace != null
? Padding(
padding: const EdgeInsets.symmetric(
vertical: 7,
),
child: SmoothPageIndicator(
controller: HomeCubit.getInstance().devicesPageController,
count: HomeCubit.getInstance().selectedSpace!.subspaces.length + 1,
effect: const WormEffect(
paintStyle: PaintingStyle.stroke,
dotHeight: 8,
dotWidth: 8,
),
),
)
: const Center(
child: BodyLarge(text: 'No Home Found'),
),
], ],
), );
),
HomeCubit.getInstance().selectedSpace != null
? Padding(
padding: const EdgeInsets.symmetric(
vertical: 7,
),
child: SmoothPageIndicator(
controller: HomeCubit.getInstance().devicesPageController,
count: HomeCubit.getInstance().selectedSpace!.subspaces!.length + 1,
effect: const WormEffect(
paintStyle: PaintingStyle.stroke,
dotHeight: 8,
dotWidth: 8,
),
),
)
: const Center(
child: BodyLarge(text: 'No Home Found'),
),
],
);
} }
}, },
); );
} }
} }

View File

@ -1,7 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:syncrow_app/features/devices/model/subspace_model.dart'; import 'package:syncrow_app/features/devices/model/subspace_model.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/devices/model/room_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/room_page_switch.dart'; import 'package:syncrow_app/features/devices/view/widgets/room_page_switch.dart';
import 'package:syncrow_app/generated/assets.dart'; import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
@ -52,9 +51,7 @@ class _RoomPageState extends State<RoomPage> {
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'Search', hintText: 'Search',
hintStyle: const TextStyle( hintStyle: const TextStyle(
color: ColorsManager.textGray, color: ColorsManager.textGray, fontSize: 16, fontWeight: FontWeight.w400),
fontSize: 16,
fontWeight: FontWeight.w400),
prefixIcon: Container( prefixIcon: Container(
padding: const EdgeInsets.all(5.0), padding: const EdgeInsets.all(5.0),
margin: const EdgeInsets.all(10.0), margin: const EdgeInsets.all(10.0),

View File

@ -39,29 +39,23 @@ class RoomsSlider extends StatelessWidget {
), ),
), ),
if (HomeCubit.getInstance().selectedSpace != null) if (HomeCubit.getInstance().selectedSpace != null)
if (HomeCubit.getInstance().selectedSpace!.subspaces != null) ...HomeCubit.getInstance().selectedSpace!.subspaces.map(
...HomeCubit.getInstance().selectedSpace!.subspaces!.map( (room) => InkWell(
(room) => InkWell( onTap: () {
onTap: () { HomeCubit.getInstance().roomSliderPageChanged(
HomeCubit.getInstance().roomSliderPageChanged( HomeCubit.getInstance().selectedSpace!.subspaces.indexOf(room));
HomeCubit.getInstance() },
.selectedSpace! child: TitleMedium(
.subspaces! text: room.name!,
.indexOf(room)); style: context.titleMedium.copyWith(
}, fontSize: 25,
child: TitleMedium( color: HomeCubit.getInstance().selectedRoom == room
text: room.name!, ? ColorsManager.textPrimaryColor
style: context.titleMedium.copyWith( : ColorsManager.textPrimaryColor.withOpacity(.2),
fontSize: 25,
color:
HomeCubit.getInstance().selectedRoom == room
? ColorsManager.textPrimaryColor
: ColorsManager.textPrimaryColor
.withOpacity(.2),
),
), ),
), ),
) ),
)
], ],
), ),
); );

View File

@ -40,13 +40,10 @@ class SceneListview extends StatelessWidget {
sceneName: scene.name, sceneName: scene.name,
), ),
); );
context context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
.read<SmartSceneSelectBloc>()
.add(const SmartSceneClearEvent());
BlocProvider.of<CreateSceneBloc>(context).add( BlocProvider.of<CreateSceneBloc>(context)
FetchSceneTasksEvent( .add(FetchSceneTasksEvent(sceneId: scene.id, isAutomation: false));
sceneId: scene.id, isAutomation: false));
/// the state to set the scene type must be after the fetch /// the state to set the scene type must be after the fetch
BlocProvider.of<CreateSceneBloc>(context) BlocProvider.of<CreateSceneBloc>(context)
@ -59,15 +56,13 @@ class SceneListview extends StatelessWidget {
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: scene.iconInBytes != null && child: scene.iconInBytes.isNotEmpty
scene.iconInBytes.isNotEmpty
? Image.memory( ? Image.memory(
scene.iconInBytes, scene.iconInBytes,
height: 32, height: 32,
width: 32, width: 32,
fit: BoxFit.fill, fit: BoxFit.fill,
errorBuilder: (context, error, stackTrace) => errorBuilder: (context, error, stackTrace) => Image.asset(
Image.asset(
Assets.assetsIconsLogo, Assets.assetsIconsLogo,
height: 32, height: 32,
width: 32, width: 32,

View File

@ -1,6 +1,5 @@
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.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/room_model.dart';
import 'package:syncrow_app/features/devices/model/subspace_model.dart'; import 'package:syncrow_app/features/devices/model/subspace_model.dart';
abstract class ManageUnitState extends Equatable { abstract class ManageUnitState extends Equatable {

View File

@ -44,8 +44,7 @@ class ManageHomeView extends StatelessWidget {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
BodyMedium( BodyMedium(text: StringHelpers.toTitleCase(spaces[index].name)),
text: StringHelpers.toTitleCase(spaces[index].name ?? "")),
const Icon( const Icon(
Icons.arrow_forward_ios, Icons.arrow_forward_ios,
color: ColorsManager.greyColor, color: ColorsManager.greyColor,
@ -75,8 +74,7 @@ class ManageHomeView extends StatelessWidget {
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
BodyMedium( BodyMedium(text: HomeCubit.getInstance().spaces![index].name),
text: HomeCubit.getInstance().spaces![index].name ?? ""),
const Icon( const Icon(
Icons.arrow_forward_ios, Icons.arrow_forward_ios,
color: ColorsManager.greyColor, color: ColorsManager.greyColor,

View File

@ -60,7 +60,7 @@ mixin SceneLogicHelper {
if (isAutomation) { if (isAutomation) {
final createAutomationModel = CreateAutomationModel( final createAutomationModel = CreateAutomationModel(
unitUuid: HomeCubit.getInstance().selectedSpace!.id ?? '', unitUuid: HomeCubit.getInstance().selectedSpace?.id ?? '',
automationName: sceneName.text, automationName: sceneName.text,
decisionExpr: sceneBloc.conditionRule, decisionExpr: sceneBloc.conditionRule,
effectiveTime: sceneBloc.effectiveTime ?? effectiveTime: sceneBloc.effectiveTime ??
@ -124,7 +124,7 @@ mixin SceneLogicHelper {
)); ));
} else { } else {
final createSceneModel = CreateSceneModel( final createSceneModel = CreateSceneModel(
spaceUuid: HomeCubit.getInstance().selectedSpace!.id ?? '', spaceUuid: HomeCubit.getInstance().selectedSpace?.id ?? '',
iconId: sceneBloc.selectedIcon, iconId: sceneBloc.selectedIcon,
showInDevice: sceneBloc.showInDeviceScreen, showInDevice: sceneBloc.showInDeviceScreen,
sceneName: sceneName.text, sceneName: sceneName.text,

View File

@ -7,24 +7,19 @@ import 'package:syncrow_app/features/devices/model/subspace_model.dart';
import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_bloc.dart'; import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_bloc.dart';
import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_event.dart'; import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_event.dart';
import 'package:syncrow_app/features/scene/widgets/scene_devices/scene_devices_body.dart'; import 'package:syncrow_app/features/scene/widgets/scene_devices/scene_devices_body.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/navigation/navigate_to_route.dart'; import 'package:syncrow_app/navigation/navigate_to_route.dart';
import 'package:syncrow_app/navigation/routing_constants.dart'; import 'package:syncrow_app/navigation/routing_constants.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart';
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart'; import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
class SceneRoomsTabBarDevicesView extends StatefulWidget { class SceneRoomsTabBarDevicesView extends StatefulWidget {
const SceneRoomsTabBarDevicesView({super.key}); const SceneRoomsTabBarDevicesView({super.key});
@override @override
State<SceneRoomsTabBarDevicesView> createState() => State<SceneRoomsTabBarDevicesView> createState() => _SceneRoomsTabBarDevicesViewState();
_SceneRoomsTabBarDevicesViewState();
} }
class _SceneRoomsTabBarDevicesViewState class _SceneRoomsTabBarDevicesViewState extends State<SceneRoomsTabBarDevicesView>
extends State<SceneRoomsTabBarDevicesView>
with SingleTickerProviderStateMixin { with SingleTickerProviderStateMixin {
late final TabController _tabController; late final TabController _tabController;
List<SubSpaceModel>? rooms = []; List<SubSpaceModel>? rooms = [];
@ -47,8 +42,7 @@ class _SceneRoomsTabBarDevicesViewState
} }
} }
_tabController = _tabController = TabController(length: rooms!.length, vsync: this, initialIndex: 0);
TabController(length: rooms!.length, vsync: this, initialIndex: 0);
_tabController.addListener(_handleTabSwitched); _tabController.addListener(_handleTabSwitched);
super.initState(); super.initState();
} }
@ -58,10 +52,8 @@ class _SceneRoomsTabBarDevicesViewState
final value = _tabController.index; final value = _tabController.index;
/// select tab /// select tab
context.read<TabBarBloc>().add(TabChanged( context.read<TabBarBloc>().add(
selectedIndex: value, TabChanged(selectedIndex: value, roomId: rooms?[value].id ?? '', unit: selectedSpace));
roomId: rooms?[value].id ?? '',
unit: selectedSpace));
return; return;
} }
} }

View File

@ -1,13 +1,9 @@
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:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart'; import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_bloc.dart';
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.dart';
import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart'; import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart';
import 'package:syncrow_app/features/scene/model/scene_settings_route_arguments.dart'; import 'package:syncrow_app/features/scene/model/scene_settings_route_arguments.dart';
import 'package:syncrow_app/features/scene/widgets/alert_dialogs/delete_routine_dialog.dart';
import 'package:syncrow_app/features/scene/widgets/create_scene_save_button.dart'; import 'package:syncrow_app/features/scene/widgets/create_scene_save_button.dart';
import 'package:syncrow_app/features/scene/widgets/if_then_containers/if_container.dart'; import 'package:syncrow_app/features/scene/widgets/if_then_containers/if_container.dart';
import 'package:syncrow_app/features/scene/widgets/if_then_containers/then_container.dart'; import 'package:syncrow_app/features/scene/widgets/if_then_containers/then_container.dart';
@ -24,19 +20,16 @@ class SceneTasksView extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final sceneSettings = ModalRoute.of(context)!.settings.arguments final sceneSettings = ModalRoute.of(context)!.settings.arguments as SceneSettingsRouteArguments;
as SceneSettingsRouteArguments;
final isAutomation = final isAutomation = sceneSettings.sceneType == CreateSceneEnum.deviceStatusChanges.name;
sceneSettings.sceneType == CreateSceneEnum.deviceStatusChanges.name;
// context.read<CreateSceneBloc>().add(SceneTypeEvent(isAutomation // context.read<CreateSceneBloc>().add(SceneTypeEvent(isAutomation
// ? CreateSceneEnum.deviceStatusChanges // ? CreateSceneEnum.deviceStatusChanges
// : CreateSceneEnum.tabToRun)); // : CreateSceneEnum.tabToRun));
return DefaultScaffold( return DefaultScaffold(
title: sceneSettings.sceneName.isNotEmpty title:
? sceneSettings.sceneName sceneSettings.sceneName.isNotEmpty ? sceneSettings.sceneName : StringsManager.createScene,
: StringsManager.createScene,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
leading: IconButton( leading: IconButton(
onPressed: () { onPressed: () {

View File

@ -22,48 +22,62 @@ class SceneView extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocProvider( return BlocProvider(
create: (BuildContext context) => SceneBloc() create: (BuildContext context) {
..add(LoadScenes( if (pageType) {
HomeCubit.getInstance().selectedSpace?.id ?? '', return SceneBloc()
HomeCubit.getInstance().selectedSpace ?? ..add(LoadScenes(
SpaceModel( HomeCubit.getInstance().selectedSpace?.id ?? '',
id: '-1', HomeCubit.getInstance().selectedSpace ??
name: '', SpaceModel(
community: Community( id: '-1',
uuid: '-1', name: '',
name: '', community: Community(
)), uuid: '-1',
showInDevice: pageType)) name: '',
..add(LoadAutomation(HomeCubit.getInstance().selectedSpace?.id ?? '')), )),
showInDevice: pageType));
} else {
return SceneBloc()
..add(LoadScenes(
HomeCubit.getInstance().selectedSpace?.id ?? '',
HomeCubit.getInstance().selectedSpace ??
SpaceModel(
id: '-1',
name: '',
community: Community(
uuid: '-1',
name: '',
)),
showInDevice: pageType))
..add(LoadAutomation(HomeCubit.getInstance().selectedSpace?.id ?? ''));
}
},
child: BlocBuilder<CreateSceneBloc, CreateSceneState>( child: BlocBuilder<CreateSceneBloc, CreateSceneState>(
builder: (context, state) { builder: (context, state) {
if (state is DeleteSceneSuccess) { if (state is DeleteSceneSuccess) {
if (state.success) { if (state.success) {
BlocProvider.of<SceneBloc>(context).add(LoadScenes( BlocProvider.of<SceneBloc>(context).add(LoadScenes(
HomeCubit.getInstance().selectedSpace!.id!,HomeCubit.getInstance().selectedSpace!, HomeCubit.getInstance().selectedSpace!.id, HomeCubit.getInstance().selectedSpace!,
showInDevice: pageType)); showInDevice: pageType));
BlocProvider.of<SceneBloc>(context).add( BlocProvider.of<SceneBloc>(context)
LoadAutomation(HomeCubit.getInstance().selectedSpace!.id!)); .add(LoadAutomation(HomeCubit.getInstance().selectedSpace!.id));
} }
} }
if (state is CreateSceneWithTasks) { if (state is CreateSceneWithTasks) {
if (state.success == true) { if (state.success == true) {
BlocProvider.of<SceneBloc>(context).add(LoadScenes( BlocProvider.of<SceneBloc>(context).add(LoadScenes(
HomeCubit.getInstance().selectedSpace!.id!,HomeCubit.getInstance().selectedSpace!, HomeCubit.getInstance().selectedSpace!.id, HomeCubit.getInstance().selectedSpace!,
showInDevice: pageType)); showInDevice: pageType));
BlocProvider.of<SceneBloc>(context).add( BlocProvider.of<SceneBloc>(context)
LoadAutomation(HomeCubit.getInstance().selectedSpace!.id!)); .add(LoadAutomation(HomeCubit.getInstance().selectedSpace!.id));
context context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
.read<SmartSceneSelectBloc>()
.add(const SmartSceneClearEvent());
} }
} }
return BlocListener<SceneBloc, SceneState>( return BlocListener<SceneBloc, SceneState>(
listener: (context, state) { listener: (context, state) {
if (state is SceneTriggerSuccess) { if (state is SceneTriggerSuccess) {
context.showCustomSnackbar( context.showCustomSnackbar(
message: message: 'Scene ${state.sceneName} triggered successfully!');
'Scene ${state.sceneName} triggered successfully!');
} }
}, },
child: HomeCubit.getInstance().spaces?.isEmpty ?? true child: HomeCubit.getInstance().spaces?.isEmpty ?? true
@ -100,30 +114,25 @@ class SceneView extends StatelessWidget {
child: ListView( child: ListView(
children: [ children: [
Theme( Theme(
data: ThemeData().copyWith( data: ThemeData()
dividerColor: Colors.transparent), .copyWith(dividerColor: Colors.transparent),
child: ExpansionTile( child: ExpansionTile(
tilePadding: tilePadding: const EdgeInsets.symmetric(horizontal: 6),
const EdgeInsets.symmetric(
horizontal: 6),
initiallyExpanded: true, initiallyExpanded: true,
iconColor: ColorsManager.grayColor, iconColor: ColorsManager.grayColor,
title: const BodyMedium( title: const BodyMedium(text: 'Tap to run routines'),
text: 'Tap to run routines'),
children: [ children: [
scenes.isNotEmpty scenes.isNotEmpty
? SceneGrid( ? SceneGrid(
scenes: scenes, scenes: scenes,
loadingSceneId: loadingSceneId: state.loadingSceneId,
state.loadingSceneId,
disablePlayButton: false, disablePlayButton: false,
loadingStates: state loadingStates:
.loadingStates, // Add this line state.loadingStates, // Add this line
) )
: const Center( : const Center(
child: BodyMedium( child: BodyMedium(
text: text: 'No scenes have been added yet',
'No scenes have been added yet',
), ),
), ),
const SizedBox( const SizedBox(
@ -133,30 +142,25 @@ class SceneView extends StatelessWidget {
), ),
), ),
Theme( Theme(
data: ThemeData().copyWith( data: ThemeData()
dividerColor: Colors.transparent), .copyWith(dividerColor: Colors.transparent),
child: ExpansionTile( child: ExpansionTile(
initiallyExpanded: true, initiallyExpanded: true,
iconColor: ColorsManager.grayColor, iconColor: ColorsManager.grayColor,
tilePadding: tilePadding: const EdgeInsets.symmetric(horizontal: 6),
const EdgeInsets.symmetric( title: const BodyMedium(text: 'Automation'),
horizontal: 6),
title: const BodyMedium(
text: 'Automation'),
children: [ children: [
automationList.isNotEmpty automationList.isNotEmpty
? SceneGrid( ? SceneGrid(
scenes: automationList, scenes: automationList,
loadingSceneId: loadingSceneId: state.loadingSceneId,
state.loadingSceneId,
disablePlayButton: true, disablePlayButton: true,
loadingStates: state loadingStates:
.loadingStates, // Add this line state.loadingStates, // Add this line
) )
: const Center( : const Center(
child: BodyMedium( child: BodyMedium(
text: text: 'No automations have been added yet',
'No automations have been added yet',
), ),
), ),
const SizedBox( const SizedBox(

View File

@ -10,8 +10,7 @@ import 'package:syncrow_app/navigation/routing_constants.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class DeleteRoutineButton extends StatelessWidget { class DeleteRoutineButton extends StatelessWidget {
const DeleteRoutineButton( const DeleteRoutineButton({super.key, required this.sceneId, required this.isAutomation});
{super.key, required this.sceneId, required this.isAutomation});
final String sceneId; final String sceneId;
final bool isAutomation; final bool isAutomation;
@ -23,10 +22,10 @@ class DeleteRoutineButton extends StatelessWidget {
if (state is DeleteSceneSuccess) { if (state is DeleteSceneSuccess) {
if (state.success) { if (state.success) {
navigateToRoute(context, Routes.homeRoute); navigateToRoute(context, Routes.homeRoute);
BlocProvider.of<SceneBloc>(context).add(LoadScenes(
HomeCubit.getInstance().selectedSpace!.id, HomeCubit.getInstance().selectedSpace!));
BlocProvider.of<SceneBloc>(context) BlocProvider.of<SceneBloc>(context)
.add(LoadScenes(HomeCubit.getInstance().selectedSpace!.id!,HomeCubit.getInstance().selectedSpace!)); .add(LoadAutomation(HomeCubit.getInstance().selectedSpace!.id));
BlocProvider.of<SceneBloc>(context).add(
LoadAutomation(HomeCubit.getInstance().selectedSpace!.id!));
} }
} }
}, },
@ -43,8 +42,7 @@ class DeleteRoutineButton extends StatelessWidget {
confirmTab: () { confirmTab: () {
context.read<CreateSceneBloc>().add(DeleteSceneEvent( context.read<CreateSceneBloc>().add(DeleteSceneEvent(
sceneId: sceneId, sceneId: sceneId,
unitUuid: unitUuid: HomeCubit.getInstance().selectedSpace!.id,
HomeCubit.getInstance().selectedSpace!.id!,
)); ));
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },

View File

@ -3,7 +3,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_bloc.dart'; import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_state.dart'; import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_state.dart';
import 'package:syncrow_app/features/devices/model/room_model.dart';
import 'package:syncrow_app/features/devices/model/subspace_model.dart'; import 'package:syncrow_app/features/devices/model/subspace_model.dart';
import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_bloc.dart'; import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_bloc.dart';
import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_state.dart'; import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_state.dart';
@ -29,11 +28,9 @@ class SceneDevicesBody extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isAutomationDeviceStatus = ((ModalRoute.of(context) final isAutomationDeviceStatus =
?.settings ((ModalRoute.of(context)?.settings.arguments as SceneSettingsRouteArguments?)?.sceneType ==
.arguments as SceneSettingsRouteArguments?) CreateSceneEnum.deviceStatusChanges.name);
?.sceneType ==
CreateSceneEnum.deviceStatusChanges.name);
return BlocBuilder<TabBarBloc, TabBarState>( return BlocBuilder<TabBarBloc, TabBarState>(
builder: (context, tabState) { builder: (context, tabState) {
return Column( return Column(
@ -49,8 +46,7 @@ class SceneDevicesBody extends StatelessWidget {
text: e.name ?? '', text: e.name ?? '',
textAlign: TextAlign.start, textAlign: TextAlign.start,
style: context.bodyLarge.copyWith( style: context.bodyLarge.copyWith(
color: (tabState is TabSelected) && color: (tabState is TabSelected) && tabState.roomId == e.id
tabState.roomId == e.id
? ColorsManager.textPrimaryColor ? ColorsManager.textPrimaryColor
: ColorsManager.textPrimaryColor.withOpacity(0.2), : ColorsManager.textPrimaryColor.withOpacity(0.2),
), ),
@ -64,10 +60,8 @@ class SceneDevicesBody extends StatelessWidget {
child: TabBarView( child: TabBarView(
controller: _tabController, controller: _tabController,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
children: rooms! children:
.map((e) => rooms!.map((e) => _buildRoomTab(e, context, isAutomationDeviceStatus)).toList(),
_buildRoomTab(e, context, isAutomationDeviceStatus))
.toList(),
), ),
), ),
], ],
@ -76,8 +70,7 @@ class SceneDevicesBody extends StatelessWidget {
); );
} }
Widget _buildRoomTab( Widget _buildRoomTab(SubSpaceModel room, BuildContext context, bool isAutomationDeviceStatus) {
SubSpaceModel room, BuildContext context, bool isAutomationDeviceStatus) {
return BlocBuilder<DeviceManagerBloc, DeviceManagerState>( return BlocBuilder<DeviceManagerBloc, DeviceManagerState>(
builder: (context, state) { builder: (context, state) {
if (state.loading && state.devices == null) { if (state.loading && state.devices == null) {

View File

@ -38,8 +38,8 @@ class SceneItem extends StatelessWidget {
onTap: () { onTap: () {
context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent()); context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
if (disablePlayButton == false) { if (disablePlayButton == false) {
BlocProvider.of<CreateSceneBloc>(context).add( BlocProvider.of<CreateSceneBloc>(context)
FetchSceneTasksEvent(sceneId: scene.id, isAutomation: false)); .add(FetchSceneTasksEvent(sceneId: scene.id, isAutomation: false));
/// the state to set the scene type must be after the fetch /// the state to set the scene type must be after the fetch
BlocProvider.of<CreateSceneBloc>(context) BlocProvider.of<CreateSceneBloc>(context)
@ -73,19 +73,16 @@ class SceneItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
if (!disablePlayButton && scene.iconInBytes != null && scene.iconInBytes.isNotEmpty) if (!disablePlayButton && scene.iconInBytes.isNotEmpty)
Image.memory( Image.memory(
scene.iconInBytes, scene.iconInBytes,
height: 32, height: 32,
width: 32, width: 32,
fit: BoxFit.fill, fit: BoxFit.fill,
errorBuilder: (context, error, stackTrace) => Image.asset( errorBuilder: (context, error, stackTrace) =>
Assets.assetsIconsLogo, Image.asset(Assets.assetsIconsLogo, height: 32, width: 32, fit: BoxFit.fill),
height: 32,
width: 32,
fit: BoxFit.fill),
), ),
if (disablePlayButton || scene.iconInBytes == null || scene.iconInBytes.isEmpty) if (disablePlayButton || scene.iconInBytes.isEmpty)
SvgPicture.asset( SvgPicture.asset(
Assets.automationIcon, Assets.automationIcon,
height: 32, height: 32,
@ -96,9 +93,7 @@ class SceneItem extends StatelessWidget {
? IconButton( ? IconButton(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
onPressed: () { onPressed: () {
context context.read<SceneBloc>().add(SceneTrigger(scene.id, scene.name));
.read<SceneBloc>()
.add(SceneTrigger(scene.id, scene.name));
}, },
icon: isLoading icon: isLoading
? const Center( ? const Center(
@ -120,15 +115,11 @@ class SceneItem extends StatelessWidget {
activeColor: ColorsManager.primaryColor, activeColor: ColorsManager.primaryColor,
value: scene.status == 'enable' ? true : false, value: scene.status == 'enable' ? true : false,
onChanged: (value) { onChanged: (value) {
context.read<SceneBloc>().add( context.read<SceneBloc>().add(UpdateAutomationStatus(
UpdateAutomationStatus( automationStatusUpdate: AutomationStatusUpdate(
automationStatusUpdate: isEnable: value,
AutomationStatusUpdate( spaceUuid: HomeCubit.getInstance().selectedSpace!.id),
isEnable: value, automationId: scene.id));
spaceUuid: HomeCubit.getInstance()
.selectedSpace!
.id!),
automationId: scene.id));
}, },
), ),
], ],

View File

@ -1,50 +1,51 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart'; // import 'package:flutter_svg/svg.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart'; // import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
import 'package:syncrow_app/generated/assets.dart'; // import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/navigation/routing_constants.dart'; // import 'package:syncrow_app/navigation/routing_constants.dart';
class CreateUnitWidget extends StatelessWidget { class CreateUnitWidget extends StatelessWidget {
const CreateUnitWidget({super.key}); const CreateUnitWidget({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SizedBox( return Container();
width: MediaQuery.sizeOf(context).width, // return SizedBox(
height: MediaQuery.sizeOf(context).height, // width: MediaQuery.sizeOf(context).width,
child: Column( // height: MediaQuery.sizeOf(context).height,
mainAxisAlignment: MainAxisAlignment.center, // child: Column(
children: [ // mainAxisAlignment: MainAxisAlignment.center,
SvgPicture.asset( // children: [
Assets.noUnitsIconDashboard, // SvgPicture.asset(
width: 100, // Assets.noUnitsIconDashboard,
height: 100, // width: 100,
), // height: 100,
const SizedBox( // ),
height: 50, // const SizedBox(
), // height: 50,
Flexible( // ),
child: GestureDetector( // Flexible(
onTap: () { // child: GestureDetector(
Navigator.pushNamed(context, Routes.createUnit); // onTap: () {
}, // Navigator.pushNamed(context, Routes.createUnit);
child: Container( // },
padding: const EdgeInsets.symmetric(horizontal: 34, vertical: 14), // child: Container(
decoration: ShapeDecoration( // padding: const EdgeInsets.symmetric(horizontal: 34, vertical: 14),
color: const Color(0x99023DFE), // decoration: ShapeDecoration(
shape: RoundedRectangleBorder( // color: const Color(0x99023DFE),
borderRadius: BorderRadius.circular(20), // shape: RoundedRectangleBorder(
), // borderRadius: BorderRadius.circular(20),
), // ),
child: const TitleMedium( // ),
text: 'Create a unit', // child: const TitleMedium(
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w400, color: Colors.white), // text: 'Create a unit',
), // style: TextStyle(fontSize: 16, fontWeight: FontWeight.w400, color: Colors.white),
), // ),
), // ),
), // ),
], // ),
), // ],
); // ),
// );
} }
} }

View File

@ -1,7 +1,7 @@
//ignore_for_file: constant_identifier_names //ignore_for_file: constant_identifier_names
import 'dart:ui'; import 'dart:ui';
import 'package:syncrow_app/features/devices/model/function_model.dart'; import 'package:syncrow_app/features/devices/model/function_model.dart';
import 'package:syncrow_app/features/menu/view/widgets/create_home/create_home_view.dart'; // import 'package:syncrow_app/features/menu/view/widgets/create_home/create_home_view.dart';
import 'package:syncrow_app/features/menu/view/widgets/join_home/join_home_view.dart'; import 'package:syncrow_app/features/menu/view/widgets/join_home/join_home_view.dart';
import 'package:syncrow_app/features/menu/view/widgets/manage_home/manage_home_view.dart'; import 'package:syncrow_app/features/menu/view/widgets/manage_home/manage_home_view.dart';
import 'package:syncrow_app/features/menu/view/widgets/privacy/privacy_view.dart'; import 'package:syncrow_app/features/menu/view/widgets/privacy/privacy_view.dart';
@ -92,9 +92,7 @@ Map<String, DeviceType> devicesTypesMap = {
Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = { Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
DeviceType.AC: [ DeviceType.AC: [
FunctionModel( FunctionModel(
code: 'switch', code: 'switch', type: functionTypesMap['Boolean'], values: ValueModel.fromJson({})),
type: functionTypesMap['Boolean'],
values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'mode', code: 'mode',
type: functionTypesMap['Enum'], type: functionTypesMap['Enum'],
@ -117,9 +115,7 @@ Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
// "range": ["low", "middle", "high", "auto"] // "range": ["low", "middle", "high", "auto"]
})), })),
FunctionModel( FunctionModel(
code: 'child_lock', code: 'child_lock', type: functionTypesMap['Boolean'], values: ValueModel.fromJson({})),
type: functionTypesMap['Boolean'],
values: ValueModel.fromJson({})),
], ],
DeviceType.Gateway: [ DeviceType.Gateway: [
FunctionModel( FunctionModel(
@ -133,9 +129,7 @@ Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
"range": ["normal", "alarm"] "range": ["normal", "alarm"]
})), })),
FunctionModel( FunctionModel(
code: 'factory_reset', code: 'factory_reset', type: functionTypesMap['Boolean'], values: ValueModel.fromJson({})),
type: functionTypesMap['Boolean'],
values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'alarm_active', code: 'alarm_active',
type: functionTypesMap['String'], type: functionTypesMap['String'],
@ -145,8 +139,7 @@ Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
FunctionModel( FunctionModel(
code: 'sensitivity', code: 'sensitivity',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "", "min": 1, "max": 10, "scale": 0, "step": 1})),
{"unit": "", "min": 1, "max": 10, "scale": 0, "step": 1})),
], ],
DeviceType.DoorLock: [ DeviceType.DoorLock: [
FunctionModel( FunctionModel(
@ -154,9 +147,7 @@ Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
type: functionTypesMap['Raw'], type: functionTypesMap['Raw'],
values: ValueModel.fromJson({})), values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'remote_no_dp_key', code: 'remote_no_dp_key', type: functionTypesMap['Raw'], values: ValueModel.fromJson({})),
type: functionTypesMap['Raw'],
values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'normal_open_switch', code: 'normal_open_switch',
type: functionTypesMap['Boolean'], type: functionTypesMap['Boolean'],
@ -166,87 +157,64 @@ Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
FunctionModel( FunctionModel(
code: 'far_detection', code: 'far_detection',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "cm", "min": 75, "max": 600, "scale": 0, "step": 75})),
{"unit": "cm", "min": 75, "max": 600, "scale": 0, "step": 75})),
FunctionModel( FunctionModel(
code: 'presence_time', code: 'presence_time',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values:
{"unit": "Min", "min": 0, "max": 65535, "scale": 0, "step": 1})), ValueModel.fromJson({"unit": "Min", "min": 0, "max": 65535, "scale": 0, "step": 1})),
FunctionModel( FunctionModel(
code: 'motion_sensitivity_value', code: 'motion_sensitivity_value',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "", "min": 1, "max": 5, "scale": 0, "step": 1})),
{"unit": "", "min": 1, "max": 5, "scale": 0, "step": 1})),
FunctionModel( FunctionModel(
code: 'motionless_sensitivity', code: 'motionless_sensitivity',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "", "min": 1, "max": 5, "scale": 0, "step": 1})),
{"unit": "", "min": 1, "max": 5, "scale": 0, "step": 1})),
FunctionModel( FunctionModel(
code: 'indicator', code: 'indicator', type: functionTypesMap['Boolean'], values: ValueModel.fromJson({})),
type: functionTypesMap['Boolean'],
values: ValueModel.fromJson({})),
], ],
DeviceType.OneGang: [ DeviceType.OneGang: [
FunctionModel( FunctionModel(
code: 'switch_1', code: 'switch_1', type: functionTypesMap['Boolean'], values: ValueModel.fromJson({})),
type: functionTypesMap['Boolean'],
values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'countdown_1', code: 'countdown_1',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
{"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
], ],
DeviceType.TwoGang: [ DeviceType.TwoGang: [
FunctionModel( FunctionModel(
code: 'switch_1', code: 'switch_1', type: functionTypesMap['Boolean'], values: ValueModel.fromJson({})),
type: functionTypesMap['Boolean'],
values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'switch_2', code: 'switch_2', type: functionTypesMap['Boolean'], values: ValueModel.fromJson({})),
type: functionTypesMap['Boolean'],
values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'countdown_1', code: 'countdown_1',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
{"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
FunctionModel( FunctionModel(
code: 'countdown_2', code: 'countdown_2',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
{"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
], ],
DeviceType.ThreeGang: [ DeviceType.ThreeGang: [
FunctionModel( FunctionModel(
code: 'switch_1', code: 'switch_1', type: functionTypesMap['Boolean'], values: ValueModel.fromJson({})),
type: functionTypesMap['Boolean'],
values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'switch_2', code: 'switch_2', type: functionTypesMap['Boolean'], values: ValueModel.fromJson({})),
type: functionTypesMap['Boolean'],
values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'switch_3', code: 'switch_3', type: functionTypesMap['Boolean'], values: ValueModel.fromJson({})),
type: functionTypesMap['Boolean'],
values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'countdown_1', code: 'countdown_1',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
{"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
FunctionModel( FunctionModel(
code: 'countdown_2', code: 'countdown_2',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
{"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
FunctionModel( FunctionModel(
code: 'countdown_3', code: 'countdown_3',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
{"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
], ],
DeviceType.Curtain: [ DeviceType.Curtain: [
FunctionModel( FunctionModel(
@ -258,19 +226,15 @@ Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
FunctionModel( FunctionModel(
code: 'percent_control', code: 'percent_control',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "%", "min": 0, "max": 100, "scale": 0, "step": 1})),
{"unit": "%", "min": 0, "max": 100, "scale": 0, "step": 1})),
], ],
DeviceType.WH: [ DeviceType.WH: [
FunctionModel( FunctionModel(
code: 'switch_1', code: 'switch_1', type: functionTypesMap['Boolean'], values: ValueModel.fromJson({})),
type: functionTypesMap['Boolean'],
values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'countdown_1', code: 'countdown_1',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
{"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
FunctionModel( FunctionModel(
code: 'relay_status', code: 'relay_status',
type: functionTypesMap['Enum'], type: functionTypesMap['Enum'],
@ -294,9 +258,7 @@ Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
], ],
DeviceType.DS: [ DeviceType.DS: [
FunctionModel( FunctionModel(
code: 'doorcontact_state', code: 'doorcontact_state', type: functionTypesMap['Raw'], values: ValueModel.fromJson({})),
type: functionTypesMap['Raw'],
values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'battery_percentage', code: 'battery_percentage',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
@ -304,14 +266,11 @@ Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
], ],
DeviceType.OneTouch: [ DeviceType.OneTouch: [
FunctionModel( FunctionModel(
code: 'switch_1', code: 'switch_1', type: functionTypesMap['Boolean'], values: ValueModel.fromJson({})),
type: functionTypesMap['Boolean'],
values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'countdown_1', code: 'countdown_1',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
{"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
FunctionModel( FunctionModel(
code: 'relay_status', code: 'relay_status',
type: functionTypesMap['Enum'], type: functionTypesMap['Enum'],
@ -333,23 +292,17 @@ Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
], ],
DeviceType.TowTouch: [ DeviceType.TowTouch: [
FunctionModel( FunctionModel(
code: 'switch_1', code: 'switch_1', type: functionTypesMap['Boolean'], values: ValueModel.fromJson({})),
type: functionTypesMap['Boolean'],
values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'switch_2', code: 'switch_2', type: functionTypesMap['Boolean'], values: ValueModel.fromJson({})),
type: functionTypesMap['Boolean'],
values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'countdown_1', code: 'countdown_1',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
{"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
FunctionModel( FunctionModel(
code: 'countdown_2', code: 'countdown_2',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
{"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
FunctionModel( FunctionModel(
code: 'relay_status', code: 'relay_status',
type: functionTypesMap['Enum'], type: functionTypesMap['Enum'],
@ -377,32 +330,23 @@ Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
], ],
DeviceType.ThreeTouch: [ DeviceType.ThreeTouch: [
FunctionModel( FunctionModel(
code: 'switch_1', code: 'switch_1', type: functionTypesMap['Boolean'], values: ValueModel.fromJson({})),
type: functionTypesMap['Boolean'],
values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'switch_2', code: 'switch_2', type: functionTypesMap['Boolean'], values: ValueModel.fromJson({})),
type: functionTypesMap['Boolean'],
values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'switch_3', code: 'switch_3', type: functionTypesMap['Boolean'], values: ValueModel.fromJson({})),
type: functionTypesMap['Boolean'],
values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'countdown_1', code: 'countdown_1',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
{"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
FunctionModel( FunctionModel(
code: 'countdown_2', code: 'countdown_2',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
{"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
FunctionModel( FunctionModel(
code: 'countdown_3', code: 'countdown_3',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
{"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
FunctionModel( FunctionModel(
code: 'relay_status', code: 'relay_status',
type: functionTypesMap['Enum'], type: functionTypesMap['Enum'],
@ -436,24 +380,19 @@ Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
], ],
DeviceType.GarageDoor: [ DeviceType.GarageDoor: [
FunctionModel( FunctionModel(
code: 'switch_1', code: 'switch_1', type: functionTypesMap['Boolean'], values: ValueModel.fromJson({})),
type: functionTypesMap['Boolean'],
values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'countdown_1', code: 'countdown_1',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "s", "min": 0, "max": 86400, "scale": 0, "step": 1})),
{"unit": "s", "min": 0, "max": 86400, "scale": 0, "step": 1})),
FunctionModel( FunctionModel(
code: 'tr_timecon', code: 'tr_timecon',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "s", "min": 0, "max": 120, "scale": 0, "step": 1})),
{"unit": "s", "min": 0, "max": 120, "scale": 0, "step": 1})),
FunctionModel( FunctionModel(
code: 'countdown_alarm', code: 'countdown_alarm',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "s", "min": 0, "max": 86400, "scale": 0, "step": 1})),
{"unit": "s", "min": 0, "max": 86400, "scale": 0, "step": 1})),
FunctionModel( FunctionModel(
code: 'door_control_1', code: 'door_control_1',
type: functionTypesMap['Enum'], type: functionTypesMap['Enum'],
@ -474,24 +413,19 @@ Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
DeviceType.WaterLeak: [], DeviceType.WaterLeak: [],
DeviceType.PC: [ DeviceType.PC: [
FunctionModel( FunctionModel(
code: 'switch_1', code: 'switch_1', type: functionTypesMap['Boolean'], values: ValueModel.fromJson({})),
type: functionTypesMap['Boolean'],
values: ValueModel.fromJson({})),
FunctionModel( FunctionModel(
code: 'countdown_1', code: 'countdown_1',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "s", "min": 0, "max": 86400, "scale": 0, "step": 1})),
{"unit": "s", "min": 0, "max": 86400, "scale": 0, "step": 1})),
FunctionModel( FunctionModel(
code: 'tr_timecon', code: 'tr_timecon',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "s", "min": 0, "max": 120, "scale": 0, "step": 1})),
{"unit": "s", "min": 0, "max": 120, "scale": 0, "step": 1})),
FunctionModel( FunctionModel(
code: 'countdown_alarm', code: 'countdown_alarm',
type: functionTypesMap['Integer'], type: functionTypesMap['Integer'],
values: ValueModel.fromJson( values: ValueModel.fromJson({"unit": "s", "min": 0, "max": 86400, "scale": 0, "step": 1})),
{"unit": "s", "min": 0, "max": 86400, "scale": 0, "step": 1})),
FunctionModel( FunctionModel(
code: 'door_control_1', code: 'door_control_1',
type: functionTypesMap['Enum'], type: functionTypesMap['Enum'],
@ -585,11 +519,11 @@ List<Map<String, Object>> menuSections = [
'title': 'Home Management', 'title': 'Home Management',
'color': ColorsManager.primaryColor, 'color': ColorsManager.primaryColor,
'buttons': [ 'buttons': [
{ // {
'title': 'Create a Unit', // 'title': 'Create a Unit',
'Icon': Assets.assetsIconsMenuIconsHomeManagementIconsCreateHome, // 'Icon': Assets.assetsIconsMenuIconsHomeManagementIconsCreateHome,
'page': const CreateUnitView() // 'page': const CreateUnitView()
}, // },
{ {
'title': 'Join a Unit', 'title': 'Join a Unit',
'Icon': Assets.assetsIconsMenuIconsHomeManagementIconsJoinAHome, 'Icon': Assets.assetsIconsMenuIconsHomeManagementIconsJoinAHome,
@ -654,11 +588,7 @@ List<Map<String, Object>> menuSections = [
'Icon': Assets.assetsIconsMenuIconsMessagesCenterIconsMessages, 'Icon': Assets.assetsIconsMenuIconsMessagesCenterIconsMessages,
'page': null 'page': null
}, },
{ {'title': 'FAQs', 'Icon': Assets.assetsIconsMenuIconsMessagesCenterIconsFAQs, 'page': null},
'title': 'FAQs',
'Icon': Assets.assetsIconsMenuIconsMessagesCenterIconsFAQs,
'page': null
},
{ {
'title': 'Help & Feedback', 'title': 'Help & Feedback',
'Icon': Assets.assetsIconsMenuIconsMessagesCenterIconsHelpAndFeedback, 'Icon': Assets.assetsIconsMenuIconsMessagesCenterIconsHelpAndFeedback,
@ -688,11 +618,7 @@ List<Map<String, Object>> menuSections = [
'title': 'Legal Information', 'title': 'Legal Information',
'color': const Color(0xFF001B72), 'color': const Color(0xFF001B72),
'buttons': [ 'buttons': [
{ {'title': 'About', 'Icon': Assets.assetsIconsMenuIconsLeagalInfoIconsAbout, 'page': null},
'title': 'About',
'Icon': Assets.assetsIconsMenuIconsLeagalInfoIconsAbout,
'page': null
},
{ {
'title': 'Privacy Policy', 'title': 'Privacy Policy',
'Icon': Assets.assetsIconsMenuIconsLeagalInfoIconsPrivacyPolicy, 'Icon': Assets.assetsIconsMenuIconsLeagalInfoIconsPrivacyPolicy,

View File

@ -5,7 +5,7 @@ description: This is the mobile application project, developed with Flutter for
# pub.dev using `flutter pub publish`. This is preferred for private packages. # pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: "none" # Remove this line if you wish to publish to pub.dev publish_to: "none" # Remove this line if you wish to publish to pub.dev
version: 1.0.5+35 version: 1.0.7+40
environment: environment:
sdk: ">=3.0.6 <4.0.0" sdk: ">=3.0.6 <4.0.0"