익명 커뮤니티 게시판(백판) 기능 추가
디시인사이드식 고정 카테고리 게시판 + 에타 스타일 익명(글 안에서만 유효한 익명 번호) 댓글. 신고는 자동 삭제 없이 운영자(교사/관리자) 검토 후 처리하도록 별도 신고 검토 화면을 대시보드에 추가. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
// ✍️ 커뮤니티 게시판 - 글쓰기 화면 (UI 전용).
|
||||
// 서버 통신/상태는 lib/function/board_write_controller.dart가 담당한다.
|
||||
import 'package:flutter/material.dart';
|
||||
import '../function/board_write_controller.dart';
|
||||
import '../theme/app_palette.dart';
|
||||
import 'app_notice.dart';
|
||||
import 'title_pill.dart';
|
||||
|
||||
class BoardWriteScreen extends StatefulWidget {
|
||||
final String studentId;
|
||||
final String category;
|
||||
final String categoryName;
|
||||
|
||||
const BoardWriteScreen({
|
||||
super.key,
|
||||
required this.studentId,
|
||||
required this.category,
|
||||
required this.categoryName,
|
||||
});
|
||||
|
||||
@override
|
||||
State<BoardWriteScreen> createState() => _BoardWriteScreenState();
|
||||
}
|
||||
|
||||
class _BoardWriteScreenState extends State<BoardWriteScreen> {
|
||||
late final BoardWriteController _controller;
|
||||
final _titleController = TextEditingController();
|
||||
final _contentController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = BoardWriteController(studentId: widget.studentId);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
_titleController.dispose();
|
||||
_contentController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _submit() async {
|
||||
final (success, message) = await _controller.submit(
|
||||
category: widget.category,
|
||||
title: _titleController.text,
|
||||
content: _contentController.text,
|
||||
);
|
||||
if (!mounted) return;
|
||||
AppNotice.show(
|
||||
context,
|
||||
message,
|
||||
icon: success ? Icons.check_circle_rounded : Icons.error_outline_rounded,
|
||||
);
|
||||
if (success) Navigator.of(context).pop(true);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListenableBuilder(
|
||||
listenable: _controller,
|
||||
builder: (context, _) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppPalette.mist,
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
foregroundColor: AppPalette.ink,
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
title: TitlePill('${widget.categoryName} 글쓰기'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: _controller.isSubmitting ? null : _submit,
|
||||
child: _controller.isSubmitting
|
||||
? const SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: const Text(
|
||||
'등록',
|
||||
style: TextStyle(
|
||||
color: AppPalette.ink,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(bottom: 4, left: 4),
|
||||
child: Text(
|
||||
'글쓴이는 익명으로 표시됩니다.',
|
||||
style: TextStyle(color: Colors.grey, fontSize: 12.5),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
TextField(
|
||||
controller: _titleController,
|
||||
maxLength: 100,
|
||||
decoration: InputDecoration(
|
||||
hintText: '제목',
|
||||
filled: true,
|
||||
fillColor: AppPalette.paper,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: BorderSide(color: AppPalette.sage),
|
||||
),
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
controller: _contentController,
|
||||
maxLines: 12,
|
||||
minLines: 8,
|
||||
decoration: InputDecoration(
|
||||
hintText: '내용을 입력하세요',
|
||||
filled: true,
|
||||
fillColor: AppPalette.paper,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: BorderSide(color: AppPalette.sage),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user