그룹 스터디 공개/비공개 기능 추가
그룹을 공개로 만들면 "공개 그룹" 목록에 뜨고, 학생이 참여 신청을 보내면 그룹장이 허용/거절할 수 있다. 그룹 상세 화면에 그룹장 전용 공개/비공개 전환 버튼과 대기 중인 참여 신청 목록을 추가. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+168
-28
@@ -43,37 +43,58 @@ class _GroupListScreenState extends State<GroupListScreen> {
|
||||
|
||||
Future<void> _showCreateGroupDialog() async {
|
||||
final nameController = TextEditingController();
|
||||
bool isPublic = false;
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: const Text('그룹 만들기'),
|
||||
content: TextField(
|
||||
controller: nameController,
|
||||
maxLength: 20,
|
||||
decoration: const InputDecoration(
|
||||
labelText: '그룹 이름',
|
||||
border: OutlineInputBorder(),
|
||||
builder: (dialogContext) => StatefulBuilder(
|
||||
builder: (dialogContext, setDialogState) => AlertDialog(
|
||||
title: const Text('그룹 만들기'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TextField(
|
||||
controller: nameController,
|
||||
maxLength: 20,
|
||||
decoration: const InputDecoration(
|
||||
labelText: '그룹 이름',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
SwitchListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: const Text('공개 그룹으로 만들기'),
|
||||
subtitle: const Text(
|
||||
'누구나 목록에서 보고 참여 신청할 수 있어요\n(그룹장이 허용해야 들어옵니다)',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
value: isPublic,
|
||||
activeThumbColor: AppPalette.ink,
|
||||
onChanged: (v) => setDialogState(() => isPublic = v),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext, false),
|
||||
child: const Text('취소', style: TextStyle(color: Colors.grey)),
|
||||
),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppPalette.ink,
|
||||
foregroundColor: AppPalette.paper,
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext, false),
|
||||
child: const Text('취소', style: TextStyle(color: Colors.grey)),
|
||||
),
|
||||
onPressed: () => Navigator.pop(dialogContext, true),
|
||||
child: const Text('만들기'),
|
||||
),
|
||||
],
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppPalette.ink,
|
||||
foregroundColor: AppPalette.paper,
|
||||
),
|
||||
onPressed: () => Navigator.pop(dialogContext, true),
|
||||
child: const Text('만들기'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
if (result != true || nameController.text.trim().isEmpty) return;
|
||||
final (success, message) = await _controller.createGroup(
|
||||
nameController.text.trim(),
|
||||
isPublic: isPublic,
|
||||
);
|
||||
if (!mounted) return;
|
||||
AppNotice.show(
|
||||
@@ -89,6 +110,16 @@ class _GroupListScreenState extends State<GroupListScreen> {
|
||||
AppNotice.show(context, message);
|
||||
}
|
||||
|
||||
Future<void> _requestJoin(int groupId) async {
|
||||
final (success, message) = await _controller.requestJoin(groupId);
|
||||
if (!mounted) return;
|
||||
AppNotice.show(
|
||||
context,
|
||||
message,
|
||||
icon: success ? Icons.check_circle_rounded : Icons.error_outline_rounded,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _openGroup(dynamic group) async {
|
||||
await pushLaunchpad(
|
||||
context,
|
||||
@@ -268,12 +299,54 @@ class _GroupListScreenState extends State<GroupListScreen> {
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'${g['name']}',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
'${g['name']}',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (g['isPublic'] == true) ...[
|
||||
const SizedBox(width: 6),
|
||||
const Icon(
|
||||
Icons.public_rounded,
|
||||
size: 14,
|
||||
color: Colors.grey,
|
||||
),
|
||||
],
|
||||
if ((g['pendingRequestCount'] ??
|
||||
0) >
|
||||
0) ...[
|
||||
const SizedBox(width: 6),
|
||||
Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(
|
||||
horizontal: 6,
|
||||
vertical: 1,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red[50],
|
||||
borderRadius:
|
||||
BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
'대기 ${g['pendingRequestCount']}',
|
||||
style: const TextStyle(
|
||||
fontSize: 10,
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
Text(
|
||||
'멤버 ${g['memberCount']}명'
|
||||
@@ -294,6 +367,73 @@ class _GroupListScreenState extends State<GroupListScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_controller.publicGroups.isNotEmpty) ...[
|
||||
const SizedBox(height: 20),
|
||||
_sectionHeader(
|
||||
'공개 그룹',
|
||||
count: _controller.publicGroups.length,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
for (final g in _controller.publicGroups)
|
||||
Container(
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 12,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppPalette.paper,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: AppPalette.sage),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.public_rounded,
|
||||
color: AppPalette.ink,
|
||||
size: 18,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'${g['name']}',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${g['ownerName']} · 멤버 ${g['memberCount']}명',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey[500],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (g['requested'] == true)
|
||||
Text(
|
||||
'신청됨',
|
||||
style: TextStyle(color: Colors.grey[500]),
|
||||
)
|
||||
else
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppPalette.ink,
|
||||
foregroundColor: AppPalette.paper,
|
||||
),
|
||||
onPressed: () =>
|
||||
_requestJoin(g['groupId'] as int),
|
||||
child: const Text('참여 신청'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user