build dialog with steps view

This commit is contained in:
Rafeek-Khoudare
2025-07-07 15:37:38 +03:00
parent e2d4e48875
commit 201348a9bf
7 changed files with 796 additions and 0 deletions

View File

@ -0,0 +1,191 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/svg.dart';
import 'package:go_router/go_router.dart';
import 'package:syncrow_web/pages/access_management/booking_system/view/widgets/icon_text_button.dart';
import 'package:syncrow_web/pages/access_management/manage_bookable_spaces/data/dummy_bookable_spaces_service.dart';
import 'package:syncrow_web/pages/access_management/manage_bookable_spaces/domain/models/bookable_space_model.dart';
import 'package:syncrow_web/pages/access_management/manage_bookable_spaces/domain/params/bookable_spaces_params.dart';
import 'package:syncrow_web/pages/access_management/manage_bookable_spaces/presentation/blocs/bookable_spaces_bloc/bookable_spaces_bloc.dart';
import 'package:syncrow_web/pages/access_management/manage_bookable_spaces/presentation/screens/setup_bookable_spaces_dialog.dart';
import 'package:syncrow_web/pages/access_management/manage_bookable_spaces/presentation/widgets/custom_data_table.dart';
import 'package:syncrow_web/pages/device_managment/shared/navigate_home_grid_view.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
import 'package:syncrow_web/utils/theme/responsive_text_theme.dart';
import 'package:syncrow_web/web_layout/web_scaffold.dart';
class ManageBookableSpacesPage extends StatefulWidget {
const ManageBookableSpacesPage({super.key});
@override
State<ManageBookableSpacesPage> createState() =>
_ManageBookableSpacesPageState();
}
class _ManageBookableSpacesPageState extends State<ManageBookableSpacesPage> {
final PageController _pageController = PageController(initialPage: 1);
int _currentPageIndex = 1;
@override
Widget build(BuildContext context) {
return WebScaffold(
enableMenuSidebar: false,
appBarTitle: Text(
'Access Management',
style: ResponsiveTextTheme.of(context).deviceManagementTitle,
),
centerBody: Row(
mainAxisSize: MainAxisSize.min,
children: [
TextButton(
onPressed: () => _switchPage(0),
child: Text(
'Access Overview',
style: context.textTheme.titleMedium?.copyWith(
color: _currentPageIndex == 0 ? Colors.white : Colors.grey,
fontWeight:
_currentPageIndex == 0 ? FontWeight.w700 : FontWeight.w400,
),
),
),
TextButton(
onPressed: () => _switchPage(1),
child: Text(
'Booking System',
style: context.textTheme.titleMedium?.copyWith(
color: _currentPageIndex == 1 ? Colors.white : Colors.grey,
fontWeight:
_currentPageIndex == 1 ? FontWeight.w700 : FontWeight.w400,
),
),
),
],
),
rightBody: const NavigateHomeGridView(),
scaffoldBody: BlocProvider(
create: (context) => BookableSpacesBloc(
DummyBookableSpacesService(),
// RemoteBookableSpacesService(HTTPService()),
)..add(LoadBookableSpacesEvent(
BookableSpacesParams(currentPage: 1),
)),
child: const ManageBookableSpacesWidget(),
),
);
}
void _switchPage(int index) {
setState(() => _currentPageIndex = index);
_pageController.jumpToPage(index);
}
}
class ManageBookableSpacesWidget extends StatelessWidget {
const ManageBookableSpacesWidget({super.key});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(20),
child: Column(
children: [
Expanded(
flex: 1,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SvgTextButton(
svgAsset: Assets.backButtonIcon,
label: 'Booking Home',
onPressed: () {
context.pop();
}),
SvgTextButton(
svgAsset: Assets.backButtonIcon,
label: 'Set Up a Bookable Spaces',
onPressed: () async => showDialog(
context: context,
builder: (context) => SetupBookableSpacesDialog(),
),
)
],
)),
Expanded(
flex: 9,
child: BlocBuilder<BookableSpacesBloc, BookableSpacesState>(
builder: (context, state) {
if (state is BookableSpacesLoading) {
return const CircularProgressIndicator();
} else if (state is BookableSpacesError) {
return Text(state.error);
} else if (state is BookableSpacesLoaded) {
return CustomDataTable<BookableSpacemodel>(
items: state.bookableSpacesList.data,
cellsWidgets: (space) => [
DataCell(
Padding(
padding: const EdgeInsetsGeometry.only(left: 10),
child: Text(space.spaceName)),
),
DataCell(Padding(
padding: const EdgeInsetsGeometry.only(left: 10),
child: Text(space.spaceVirtualAddress))),
DataCell(SizedBox(
width: 200,
child: Wrap(
spacing: 4,
children: space.spaceConfig.bookableDays
.map((day) => Text(
day,
style: const TextStyle(fontSize: 12),
))
.toList(),
),
)),
DataCell(Padding(
padding: const EdgeInsetsGeometry.only(left: 10),
child: Text(space.spaceConfig.bookingStartTime))),
DataCell(Padding(
padding: const EdgeInsetsGeometry.only(left: 10),
child: Text(space.spaceConfig.bookingEndTime))),
DataCell(Padding(
padding: const EdgeInsetsGeometry.only(left: 10),
child: Text('${space.spaceConfig.cost} Points'))),
DataCell(Center(
child: Transform.scale(
scale: 0.7,
child: Switch(
value: space.spaceConfig.availability,
onChanged: (value) {},
),
),
)),
DataCell(Center(
child: ElevatedButton(
onPressed: () {},
child: SvgPicture.asset(Assets.settings),
),
)),
],
columnsTitles: const [
'space',
'space Virtual Address',
'Bookable Days',
'Booking Start Time',
'Booking End Time',
'Cost',
'Availability',
'Settings',
],
);
} else {
return const SizedBox();
}
},
),
)
],
),
);
}
}