Files
syncrow-app/lib/features/devices/view/widgets/devices_view_body.dart
T
2024-03-07 12:57:35 +03:00

84 lines
3.2 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<DevicesCubit, DevicesState>(
builder: (context, state) {
//TODO : move to NavigationCubit
return state is DevicesLoading
? const Center(child: CircularProgressIndicator())
: 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(),
...SpacesCubit.get(context).selectedSpace.rooms.map(
(room) {
return RoomPage(
room: room,
);
},
)
],
),
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 7,
),
child: SmoothPageIndicator(
controller:
SpacesCubit.get(context).devicesPageController,
count: 3,
effect: const WormEffect(
dotHeight: 8,
dotWidth: 8,
),
onDotClicked: (index) {
SpacesCubit.get(context).unselectRoom();
},
),
),
],
),
);
},
),
);
}
}