156 lines
5.3 KiB
Dart
156 lines
5.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class CreateGroupPage extends StatefulWidget {
|
|
const CreateGroupPage({super.key});
|
|
|
|
@override
|
|
State<CreateGroupPage> createState() => _CreateGroupPageState();
|
|
}
|
|
|
|
class _CreateGroupPageState extends State<CreateGroupPage> {
|
|
final _controller = TextEditingController();
|
|
|
|
@override
|
|
void dispose() {
|
|
_controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
void _confirm() {
|
|
final name = _controller.text.trim();
|
|
if (name.isNotEmpty) {
|
|
Navigator.of(context).pop(name);
|
|
} else {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(
|
|
content: Text('نام گروه نمیتواند خالی باشد'),
|
|
duration: Duration(seconds: 1),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
void _cancel() {
|
|
Navigator.of(context).pop(null);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.black,
|
|
body: SafeArea(
|
|
// استفاده از SingleChildScrollView برای حل مشکل اسکرول و دیده نشدن دکمهها
|
|
child: SingleChildScrollView(
|
|
physics: const BouncingScrollPhysics(),
|
|
padding: const EdgeInsets.all(12.0), // کاهش پدینگ برای فضای بیشتر
|
|
child: Column(
|
|
// حذف MainAxisAlignment.center برای جلوگیری از بیرون زدن محتوا
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const SizedBox(height: 20), // فاصله از بالا
|
|
// آیکون گروه (کمی کوچکتر شده)
|
|
Container(
|
|
width: 60,
|
|
height: 60,
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFF00C853).withOpacity(0.15),
|
|
shape: BoxShape.circle,
|
|
border: Border.all(
|
|
color: const Color(0xFF00C853).withOpacity(0.5),
|
|
width: 2,
|
|
),
|
|
),
|
|
child: const Icon(
|
|
Icons.group_add,
|
|
color: Color(0xFF00C853),
|
|
size: 30, // کاهش سایز آیکون
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
|
|
// عنوان
|
|
const Text(
|
|
'گروه جدید',
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 16, // کاهش سایز فونت
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
const SizedBox(height: 20),
|
|
|
|
// ورودی متن
|
|
TextField(
|
|
controller: _controller,
|
|
autofocus: true,
|
|
textAlign: TextAlign.center,
|
|
textCapitalization: TextCapitalization.sentences,
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 14, // کاهش سایز فونت متن
|
|
letterSpacing: 0.5,
|
|
),
|
|
decoration: InputDecoration(
|
|
hintText: 'نام گروه را وارد کنید',
|
|
hintStyle: const TextStyle(
|
|
color: Colors.white38,
|
|
fontSize: 12,
|
|
),
|
|
filled: true,
|
|
fillColor: Colors.white.withOpacity(0.08),
|
|
border: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
borderSide: BorderSide.none,
|
|
),
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
horizontal: 12,
|
|
vertical: 12, // کاهش ارتفاع فیلد
|
|
),
|
|
),
|
|
onSubmitted: (_) => _confirm(),
|
|
),
|
|
const SizedBox(height: 24),
|
|
|
|
// دکمه تایید
|
|
SizedBox(
|
|
width: double.infinity,
|
|
height: 40, // ارتفاع ثابت برای دکمه
|
|
child: ElevatedButton(
|
|
onPressed: _confirm,
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: const Color(0xFF00C853),
|
|
foregroundColor: Colors.black,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(20),
|
|
),
|
|
elevation: 0,
|
|
),
|
|
child: const Text(
|
|
'ساخت گروه',
|
|
style: TextStyle(fontSize: 13, fontWeight: FontWeight.bold),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
|
|
// دکمه لغو
|
|
SizedBox(
|
|
width: double.infinity,
|
|
height: 40, // ارتفاع ثابت برای دکمه
|
|
child: TextButton(
|
|
onPressed: _cancel,
|
|
style: TextButton.styleFrom(foregroundColor: Colors.white54),
|
|
child: const Text('لغو', style: TextStyle(fontSize: 13)),
|
|
),
|
|
),
|
|
|
|
// فضای خالی در پایین برای اسکرول راحتتر
|
|
const SizedBox(height: 20),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|