separated header

This commit is contained in:
hannathkadher
2024-11-23 18:55:32 +04:00
parent bca7aa059d
commit cb0abe751e
3 changed files with 196 additions and 173 deletions

View File

@ -0,0 +1,135 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
class CommunityStructureHeader extends StatelessWidget {
final String? communityName;
final bool isEditingName;
final TextEditingController nameController;
final VoidCallback onSave;
final VoidCallback onDelete;
final VoidCallback onEditName;
final ValueChanged<String> onNameSubmitted;
const CommunityStructureHeader({
Key? key,
required this.communityName,
required this.isEditingName,
required this.nameController,
required this.onSave,
required this.onDelete,
required this.onEditName,
required this.onNameSubmitted,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 27.0),
width: double.infinity,
decoration: BoxDecoration(
color: ColorsManager.whiteColors,
boxShadow: [
BoxShadow(
color: ColorsManager.shadowBlackColor,
spreadRadius: 0,
blurRadius: 8,
offset: const Offset(0, 4),
),
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Community Structure',
style: Theme.of(context)
.textTheme
.headlineLarge
?.copyWith(color: ColorsManager.blackColor),
),
if (communityName != null)
Row(
children: [
if (!isEditingName)
Text(
communityName!,
style: Theme.of(context)
.textTheme
.bodyLarge
?.copyWith(color: ColorsManager.blackColor),
),
if (isEditingName)
SizedBox(
width: 200,
child: TextField(
controller: nameController,
decoration: const InputDecoration(
border: InputBorder.none,
isDense: true,
),
style: const TextStyle(fontSize: 16, color: ColorsManager.blackColor),
onSubmitted: onNameSubmitted,
),
),
const SizedBox(width: 8),
GestureDetector(
onTap: onEditName,
child: SvgPicture.asset(
Assets.iconEdit,
width: 16,
height: 16,
),
),
],
),
],
),
Row(
children: [
ElevatedButton.icon(
onPressed: onSave,
icon: const Icon(Icons.save, size: 18, color: ColorsManager.spaceColor),
label: const Text("Save"),
style: ElevatedButton.styleFrom(
backgroundColor: ColorsManager.textFieldGreyColor,
foregroundColor: ColorsManager.blackColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
side: BorderSide(color: Colors.grey.shade300),
elevation: 0,
),
),
const SizedBox(width: 10),
ElevatedButton.icon(
onPressed: onDelete,
icon: SvgPicture.asset(
Assets.delete,
width: 18,
height: 18,
),
label: const Text("Delete"),
style: ElevatedButton.styleFrom(
backgroundColor: ColorsManager.textFieldGreyColor,
foregroundColor: Colors.black,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
side: BorderSide(color: ColorsManager.neutralGray),
elevation: 0,
),
),
],
),
],
),
);
}
}