import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/roles_and_permission/users_page/add_user_dialog/bloc/users_bloc.dart';
import 'package:syncrow_web/pages/roles_and_permission/users_page/add_user_dialog/bloc/users_status.dart';
import 'package:syncrow_web/pages/space_tree/view/space_tree_view.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';

class SpacesAccessView extends StatelessWidget {
  final String? userId;
  const SpacesAccessView({super.key, this.userId = ''});
  @override
  Widget build(BuildContext context) {
    return BlocBuilder<UsersBloc, UsersState>(builder: (context, state) {
      final _blocRole = BlocProvider.of<UsersBloc>(context);
      return Container(
        color: Colors.white,
        child: Form(
          key: _blocRole.formKey,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              Text(
                'Spaces access',
                style: context.textTheme.bodyLarge
                    ?.copyWith(fontWeight: FontWeight.w700, fontSize: 20, color: Colors.black),
              ),
              const SizedBox(
                height: 35,
              ),
              const SizedBox(
                child: Text(
                    'Select the spaces you would like to grant access to for the user you are adding'),
              ),
              const SizedBox(
                height: 25,
              ),
              Expanded(child: SpaceTreeView(onSelect: () {}))
              // Expanded(
              //   child: SizedBox(
              //     child: Column(
              //       children: [
              //         Expanded(
              //           flex: 2,
              //           child: Container(
              //             decoration: const BoxDecoration(
              //               color: ColorsManager.circleRolesBackground,
              //               borderRadius: BorderRadius.only(
              //                   topRight: Radius.circular(20),
              //                   topLeft: Radius.circular(20)),
              //             ),
              //             child: Padding(
              //               padding: const EdgeInsets.all(8.0),
              //               child: Row(
              //                 children: [
              //                   Expanded(
              //                     child: Container(
              //                       decoration: BoxDecoration(
              //                           borderRadius: const BorderRadius.all(
              //                               Radius.circular(20)),
              //                           border: Border.all(
              //                               color: ColorsManager.grayBorder)),
              //                       child: TextFormField(
              //                         style:
              //                             const TextStyle(color: Colors.black),
              //                         // controller: _blocRole.firstNameController,
              //                         onChanged: (value) {
              //                           _blocRole.add(SearchAnode(
              //                               nodes: _blocRole.updatedCommunities,
              //                               searchTerm: value));
              //                         },
              //                         decoration: textBoxDecoration(radios: 20)!
              //                             .copyWith(
              //                           fillColor: Colors.white,
              //                           suffixIcon: Padding(
              //                             padding:
              //                                 const EdgeInsets.only(right: 16),
              //                             child: SvgPicture.asset(
              //                               Assets.textFieldSearch,
              //                               width: 24,
              //                               height: 24,
              //                             ),
              //                           ),
              //                           hintStyle: context.textTheme.bodyMedium
              //                               ?.copyWith(
              //                                   fontWeight: FontWeight.w400,
              //                                   fontSize: 12,
              //                                   color: ColorsManager.textGray),
              //                         ),
              //                       ),
              //                     ),
              //                   ),
              //                 ],
              //               ),
              //             ),
              //           ),
              //         ),
              //         Expanded(
              //             flex: 7,
              //             child: Container(
              //                 color: ColorsManager.circleRolesBackground,
              //                 padding: const EdgeInsets.all(8.0),
              //                 child: Container(
              //                     color: ColorsManager.whiteColors,
              //                     child: TreeView(userId: userId))))
              //       ],
              //     ),
              //   ),
              // ),
            ],
          ),
        ),
      );
    });
  }
}
