mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-08-26 07:19:39 +00:00
Merge pull request #76 from SyncrowIOT/bugifx/empty-subspace-routine-creation
fixed issue on empty subspace
This commit is contained in:
@ -29,25 +29,38 @@ class _SceneRoomsTabBarDevicesViewState
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
selectedSpace = HomeCubit.getInstance().selectedSpace!;
|
super.initState();
|
||||||
rooms = List.from(HomeCubit.getInstance().selectedSpace?.subspaces ?? []);
|
|
||||||
if (rooms != null) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (rooms![0].id != '-1') {
|
selectedSpace = HomeCubit.getInstance().selectedSpace!;
|
||||||
rooms?.insert(
|
|
||||||
0,
|
rooms = List.from(selectedSpace.subspaces ?? []);
|
||||||
|
|
||||||
|
if (rooms != null && rooms!.isNotEmpty) {
|
||||||
|
if (rooms![0].id != '-1') {
|
||||||
|
rooms?.insert(
|
||||||
|
0,
|
||||||
|
SubSpaceModel(
|
||||||
|
name: 'All Devices',
|
||||||
|
devices: context.read<DevicesCubit>().allDevices,
|
||||||
|
id: '-1',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rooms = [
|
||||||
SubSpaceModel(
|
SubSpaceModel(
|
||||||
name: 'All Devices',
|
name: 'All Devices',
|
||||||
devices: context.read<DevicesCubit>().allDevices,
|
devices: context.read<DevicesCubit>().allDevices,
|
||||||
id: '-1',
|
id: '-1',
|
||||||
),
|
)
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_tabController =
|
_tabController = TabController(length: rooms!.length, vsync: this);
|
||||||
TabController(length: rooms!.length, vsync: this, initialIndex: 0);
|
_tabController.addListener(_handleTabSwitched);
|
||||||
_tabController.addListener(_handleTabSwitched);
|
setState(() {});
|
||||||
super.initState();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleTabSwitched() {
|
void _handleTabSwitched() {
|
||||||
|
Reference in New Issue
Block a user