mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-24 22:27:55 +00:00
This commit adds the HomeCubit class along with its corresponding HomeState class. It also includes necessary imports and updates references to the previously used SpacesCubit to the new HomeCubit in various files. handled the multible onCreate -- HomeCubit
73 lines
2.8 KiB
Dart
73 lines
2.8 KiB
Dart
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/shared_widgets/text_widgets/title_medium.dart';
|
|
import 'package:syncrow_app/utils/context_extension.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
|
|
|
|
class RoomsSlider extends StatelessWidget {
|
|
const RoomsSlider({
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocBuilder<HomeCubit, SpacesState>(
|
|
builder: (context, state) {
|
|
return SizedBox(
|
|
height: 40,
|
|
child: PageView(
|
|
controller: HomeCubit.get(context).roomsPageController,
|
|
onPageChanged: (index) {
|
|
HomeCubit.get(context).roomSliderPageChanged(index);
|
|
},
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
|
child: InkWell(
|
|
onTap: () {
|
|
HomeCubit.get(context).unselectRoom();
|
|
},
|
|
child: TitleMedium(
|
|
text: StringsManager.wizard,
|
|
style: context.titleMedium.copyWith(
|
|
fontSize: 25,
|
|
color: HomeCubit.get(context).selectedRoom == null
|
|
? ColorsManager.textPrimaryColor
|
|
: ColorsManager.textPrimaryColor.withOpacity(.2),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
if (HomeCubit.selectedSpace != null)
|
|
if (HomeCubit.selectedSpace!.rooms != null)
|
|
...HomeCubit.selectedSpace!.rooms!.map(
|
|
(room) => Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
|
child: InkWell(
|
|
onTap: () {
|
|
HomeCubit.get(context).roomSliderPageChanged(
|
|
HomeCubit.selectedSpace!.rooms!.indexOf(room));
|
|
},
|
|
child: TitleMedium(
|
|
text: room.name!,
|
|
style: context.titleMedium.copyWith(
|
|
fontSize: 25,
|
|
color: HomeCubit.get(context).selectedRoom == room
|
|
? ColorsManager.textPrimaryColor
|
|
: ColorsManager.textPrimaryColor
|
|
.withOpacity(.2),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|