import 'package:flutter/material.dart'; import 'package:syncrow_web/utils/color_manager.dart'; class CreateCommunityDialog extends StatefulWidget { final Function(String name, String description, String regionId) onCreateCommunity; const CreateCommunityDialog({super.key, required this.onCreateCommunity}); @override CreateCommunityDialogState createState() => CreateCommunityDialogState(); } class CreateCommunityDialogState extends State { String enteredName = ''; // Store the entered community name @override Widget build(BuildContext context) { return Dialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), ), backgroundColor: Colors.transparent, // Transparent for shadow effect child: Stack( children: [ // Background container with shadow and rounded corners Container( width: 490, padding: const EdgeInsets.all(20), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(20), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.25), blurRadius: 20, spreadRadius: 5, offset: const Offset(0, 5), ), ], ), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'Community Name', style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, ), ), const SizedBox(height: 16), // Input field for the community name TextField( onChanged: (value) { enteredName = value; // Capture entered name }, style: const TextStyle( color: Colors.black, ), decoration: InputDecoration( hintText: 'Please enter the community name', filled: true, fillColor: const Color(0xFFF5F6F7), hintStyle: const TextStyle( fontSize: 14, color: Color(0xFF999999), fontWeight: FontWeight.w400, ), border: OutlineInputBorder( borderSide: const BorderSide(color: Color(0xFFF5F6F7), width: 1), borderRadius: BorderRadius.circular(10), ), enabledBorder: OutlineInputBorder( borderSide: const BorderSide(color: Color(0xFFF5F6F7), width: 1), borderRadius: BorderRadius.circular(10), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: const BorderSide(color: Color(0xFFF5F6F7), width: 1), ), ), ), const SizedBox(height: 24), // Action buttons Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: TextButton( onPressed: () => Navigator.of(context).pop(), style: TextButton.styleFrom( padding: const EdgeInsets.symmetric(vertical: 16), backgroundColor: const Color(0xFFF5F6F7), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), ), child: const Text( 'Cancel', style: TextStyle(color: Colors.black), ), ), ), const SizedBox(width: 16), Expanded( child: ElevatedButton( onPressed: () { if (enteredName.isNotEmpty) { widget.onCreateCommunity( enteredName, "", "42dc377a-1a39-4df9-b85a-b3817af88525", ); Navigator.of(context).pop(); } }, style: ElevatedButton.styleFrom( padding: const EdgeInsets.symmetric(vertical: 16), backgroundColor: ColorsManager.secondaryColor, foregroundColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), ), child: const Text('OK'), ), ), ], ), ], ), ), ], ), ); } }