mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-24 19:37:56 +00:00
90 lines
3.5 KiB
Dart
90 lines
3.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
|
|
import 'package:syncrow_app/features/app_layout/bloc/spaces_cubit.dart';
|
|
import 'package:syncrow_app/features/devices/view/widgets/devices_view_header.dart';
|
|
import 'package:syncrow_app/features/devices/view/widgets/room_page.dart';
|
|
import 'package:syncrow_app/features/devices/view/widgets/rooms_slider.dart';
|
|
import 'package:syncrow_app/features/devices/view/widgets/wizard_page.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
|
|
|
import '../../bloc/devices_cubit.dart';
|
|
|
|
class DevicesViewBody extends StatelessWidget {
|
|
const DevicesViewBody({
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocProvider(
|
|
create: (context) => DevicesCubit(),
|
|
child: BlocBuilder<SpacesCubit, SpacesState>(
|
|
builder: (context, state) {
|
|
return BlocBuilder<DevicesCubit, DevicesState>(
|
|
builder: (context, state) {
|
|
//TODO : move to NavigationCubit
|
|
if (state is DevicesLoading) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
} else {
|
|
return Padding(
|
|
padding: EdgeInsets.only(
|
|
top: Constants.appBarHeight,
|
|
bottom: Constants.bottomNavBarHeight,
|
|
),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
const DevicesViewHeader(),
|
|
const RoomsSlider(),
|
|
const SizedBox(
|
|
height: 10,
|
|
),
|
|
Expanded(
|
|
child: PageView(
|
|
controller:
|
|
SpacesCubit.get(context).devicesPageController,
|
|
onPageChanged: (index) {
|
|
SpacesCubit.get(context).devicesPageChanged(index);
|
|
},
|
|
children: [
|
|
const WizardPage(),
|
|
if (SpacesCubit.selectedSpace != null)
|
|
if (SpacesCubit.selectedSpace!.rooms != null)
|
|
...SpacesCubit.selectedSpace!.rooms!.map(
|
|
(room) {
|
|
return RoomPage(
|
|
room: room,
|
|
);
|
|
},
|
|
)
|
|
],
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
vertical: 7,
|
|
),
|
|
child: SmoothPageIndicator(
|
|
controller:
|
|
SpacesCubit.get(context).devicesPageController,
|
|
count: SpacesCubit.selectedSpace!.rooms!.length + 1,
|
|
effect: const WormEffect(
|
|
paintStyle: PaintingStyle.stroke,
|
|
dotHeight: 8,
|
|
dotWidth: 8,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
},
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|