백품타에 친구/그룹 스터디/출석 달력 기능 추가

친구 신청·수락, 그룹 생성·초대(친구 목록에서 선택)·오늘 출석 현황
공유, 개인 연속 출석(스트릭) 달력, 관리자가 날짜별로 선물/이벤트를
등록하는 달력 관리 화면을 추가. 대시보드에 학생용 3개(친구/그룹
스터디/출석 달력) + 교사·관리자용 1개(출석 달력 관리) 타일을 배치.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-21 04:09:35 +00:00
co-authored by Claude Sonnet 5
parent bdc79b94c3
commit 8a9b414535
9 changed files with 1904 additions and 0 deletions
+103
View File
@@ -0,0 +1,103 @@
// 👥 백품타 그룹 상세(멤버/오늘 출석/초대/나가기) 화면의 기능 담당 컨트롤러.
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:http/http.dart' as http;
import '../config.dart';
class GroupDetailController extends ChangeNotifier {
final int groupId;
final String studentId;
GroupDetailController({required this.groupId, required this.studentId});
bool _isLoading = true;
bool _isBusy = false;
List<dynamic> _members = [];
bool _disposed = false;
bool get isLoading => _isLoading;
bool get isBusy => _isBusy;
List<dynamic> get members => _members;
void _safeNotify() {
if (!_disposed) notifyListeners();
}
@override
void dispose() {
_disposed = true;
super.dispose();
}
Future<void> init() => refresh();
Future<void> refresh() async {
_isLoading = true;
_safeNotify();
try {
final response = await http.get(
Uri.parse('$baseUrl/api/groups/$groupId/members'),
);
if (response.statusCode == 200) {
final data = jsonDecode(utf8.decode(response.bodyBytes));
_members = data['members'] ?? [];
}
} catch (_) {
// 조용히 무시
} finally {
_isLoading = false;
_safeNotify();
}
}
Future<(bool success, String message)> invite(
String inviteeId,
String inviteeName,
) async {
_isBusy = true;
_safeNotify();
try {
final response = await http.post(
Uri.parse('$baseUrl/api/groups/$groupId/invite'),
headers: {"Content-Type": "application/json"},
body: jsonEncode({
"inviterId": studentId,
"inviteeId": inviteeId,
"inviteeName": inviteeName,
}),
);
final result = jsonDecode(utf8.decode(response.bodyBytes));
if (response.statusCode == 200 && result['status'] == 'success') {
return (true, '${result['message'] ?? '초대를 보냈습니다.'}');
}
return (false, '${result['message'] ?? '초대 실패'}');
} catch (e) {
return (false, '네트워크 에러: $e');
} finally {
_isBusy = false;
_safeNotify();
}
}
Future<(bool success, String message)> leave() async {
_isBusy = true;
_safeNotify();
try {
final response = await http.post(
Uri.parse('$baseUrl/api/groups/$groupId/leave'),
headers: {"Content-Type": "application/json"},
body: jsonEncode({"studentId": studentId}),
);
final result = jsonDecode(utf8.decode(response.bodyBytes));
if (response.statusCode == 200 && result['status'] == 'success') {
return (true, '${result['message'] ?? '그룹에서 나갔습니다.'}');
}
return (false, '${result['message'] ?? '처리 실패'}');
} catch (e) {
return (false, '네트워크 에러: $e');
} finally {
_isBusy = false;
_safeNotify();
}
}
}