그룹 스터디 공개/비공개 기능 추가
그룹을 공개로 만들면 "공개 그룹" 목록에 뜨고, 학생이 참여 신청을 보내면 그룹장이 허용/거절할 수 있다. 그룹 상세 화면에 그룹장 전용 공개/비공개 전환 버튼과 대기 중인 참여 신청 목록을 추가. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -135,6 +135,48 @@ class _GroupDetailScreenState extends State<GroupDetailScreen> {
|
||||
friendController.dispose();
|
||||
}
|
||||
|
||||
Future<void> _toggleVisibility() async {
|
||||
final makePublic = !_controller.isPublic;
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: Text(makePublic ? '공개 그룹으로 전환' : '비공개 그룹으로 전환'),
|
||||
content: Text(
|
||||
makePublic
|
||||
? '이제 누구나 이 그룹을 찾아서 참여 신청을 보낼 수 있어요. 참여는 그룹장이 허용해야 완료됩니다.'
|
||||
: '더 이상 공개 목록에 뜨지 않고, 대기 중인 참여 신청은 모두 거절 처리됩니다.',
|
||||
),
|
||||
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,
|
||||
),
|
||||
onPressed: () => Navigator.pop(dialogContext, true),
|
||||
child: const Text('전환'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (confirmed != true) return;
|
||||
final (_, message) = await _controller.setVisibility(makePublic);
|
||||
if (!mounted) return;
|
||||
AppNotice.show(context, message);
|
||||
}
|
||||
|
||||
Future<void> _respondJoinRequest(int requestId, bool accept) async {
|
||||
final (_, message) = await _controller.respondJoinRequest(
|
||||
requestId,
|
||||
accept,
|
||||
);
|
||||
if (!mounted) return;
|
||||
AppNotice.show(context, message);
|
||||
}
|
||||
|
||||
Future<void> _leave() async {
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
@@ -183,6 +225,16 @@ class _GroupDetailScreenState extends State<GroupDetailScreen> {
|
||||
foregroundColor: AppPalette.ink,
|
||||
elevation: 0,
|
||||
actions: [
|
||||
if (_controller.isOwner)
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
_controller.isPublic
|
||||
? Icons.public_rounded
|
||||
: Icons.lock_rounded,
|
||||
),
|
||||
tooltip: _controller.isPublic ? '공개 그룹' : '비공개 그룹',
|
||||
onPressed: _toggleVisibility,
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.exit_to_app_rounded),
|
||||
tooltip: '그룹 나가기',
|
||||
@@ -213,6 +265,86 @@ class _GroupDetailScreenState extends State<GroupDetailScreen> {
|
||||
Expanded(child: _statPill('오늘 공부함', attendedCount)),
|
||||
],
|
||||
),
|
||||
if (_controller.isOwner &&
|
||||
_controller.joinRequests.isNotEmpty) ...[
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 4,
|
||||
height: 16,
|
||||
decoration: BoxDecoration(
|
||||
color: AppPalette.ink,
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text(
|
||||
'대기 중인 참여 신청',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppPalette.ink,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
'${_controller.joinRequests.length}명',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.grey[500],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
for (final r in _controller.joinRequests)
|
||||
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: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
'${r['name']} (${r['studentId']})',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => _respondJoinRequest(
|
||||
r['requestId'] as int,
|
||||
false,
|
||||
),
|
||||
child: const Text(
|
||||
'거절',
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppPalette.ink,
|
||||
foregroundColor: AppPalette.paper,
|
||||
),
|
||||
onPressed: () => _respondJoinRequest(
|
||||
r['requestId'] as int,
|
||||
true,
|
||||
),
|
||||
child: const Text('허용'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user