Files
school-attendance/lib/ui/device_checkout_request_screen.dart
T
sihooandClaude Sonnet 5 527661b6e5 나머지 기능 화면들도 검정 AppBar를 둥근 제목 알약으로 통일
실시간 출석 현황과 같은 톤으로, 설정/교사 회원가입/관리자 시스템/
NFC 태그 쓰기·체크인/학생 통합 관리 센터/스마트기기 반출 신청·대장
화면의 검정 배경 AppBar를 투명 배경 + 가운데 둥근 제목 알약으로 교체.

출석 현황 화면과 달리 폰트 크기는 줄이지 않고 각 화면이 원래 쓰던
스타일(굵기 등)을 그대로 유지 - 공용 TitlePill 위젯이 스타일링된
Text를 그대로 감싸주기만 함.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-08 15:17:05 +09:00

199 lines
7.2 KiB
Dart

// 📱 스마트기기(패드) 반출 신청 화면 (UI 전용). 시작~종료 시각과 사용 목적을 입력받는다.
// 서버 통신/상태는 lib/function/device_checkout_controller.dart가 담당한다.
import 'package:flutter/material.dart';
import '../function/device_checkout_controller.dart';
import '../theme/app_palette.dart';
import 'app_notice.dart';
import 'title_pill.dart';
class DeviceCheckoutRequestScreen extends StatefulWidget {
final String studentId;
final String studentName;
const DeviceCheckoutRequestScreen({
super.key,
required this.studentId,
required this.studentName,
});
@override
State<DeviceCheckoutRequestScreen> createState() =>
_DeviceCheckoutRequestScreenState();
}
class _DeviceCheckoutRequestScreenState
extends State<DeviceCheckoutRequestScreen> {
final DeviceCheckoutController _controller = DeviceCheckoutController();
final TextEditingController _purposeController = TextEditingController();
TimeOfDay? _startTime;
TimeOfDay? _endTime;
@override
void dispose() {
_controller.dispose();
_purposeController.dispose();
super.dispose();
}
String _formatTime(TimeOfDay time) =>
'${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}';
Future<void> _pickStartTime() async {
final picked = await showTimePicker(
context: context,
initialTime: _startTime ?? TimeOfDay.now(),
helpText: '사용 시작 시각',
);
if (picked != null) setState(() => _startTime = picked);
}
Future<void> _pickEndTime() async {
final picked = await showTimePicker(
context: context,
initialTime: _endTime ?? TimeOfDay.now(),
helpText: '사용 종료 시각',
);
if (picked != null) setState(() => _endTime = picked);
}
Future<void> _submit() async {
final purpose = _purposeController.text.trim();
if (_startTime == null || _endTime == null || purpose.isEmpty) {
AppNotice.show(context, '시작/종료 시각과 사용 목적을 모두 입력해주세요.');
return;
}
final (success, message) = await _controller.submitRequest(
studentId: widget.studentId,
studentName: widget.studentName,
purpose: purpose,
startTime: _formatTime(_startTime!),
endTime: _formatTime(_endTime!),
);
if (!mounted) return;
AppNotice.show(context, message);
if (success) Navigator.pop(context);
}
@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: const TitlePill(
child: Text(
'스마트기기 반출 신청',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
),
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(24.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'패드는 NFC 태그가 안 되니, 사용 시간과 목적을 적어 신청하면\n'
'선생님이 확인하고 승인해줍니다. 승인되면 반납 바구니에서 꺼내 쓰세요.',
style: TextStyle(
color: Colors.black54,
fontSize: 13,
height: 1.4,
),
),
const SizedBox(height: 24),
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: AppPalette.paper,
borderRadius: BorderRadius.circular(24),
border: Border.all(color: AppPalette.sage),
),
child: Column(
children: [
Row(
children: [
Expanded(
child: OutlinedButton.icon(
onPressed: _pickStartTime,
icon: const Icon(Icons.play_arrow_rounded),
label: Text(
_startTime == null
? '시작 시각'
: _formatTime(_startTime!),
),
),
),
const SizedBox(width: 12),
Expanded(
child: OutlinedButton.icon(
onPressed: _pickEndTime,
icon: const Icon(Icons.stop_rounded),
label: Text(
_endTime == null
? '종료 시각'
: _formatTime(_endTime!),
),
),
),
],
),
const SizedBox(height: 16),
TextField(
controller: _purposeController,
maxLines: 3,
decoration: const InputDecoration(
labelText: '사용 목적',
hintText: '예: 수행평가 자료조사',
alignLabelWithHint: true,
border: OutlineInputBorder(),
),
),
const SizedBox(height: 20),
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
onPressed: _controller.isSubmitting ? null : _submit,
style: ElevatedButton.styleFrom(
backgroundColor: AppPalette.ink,
foregroundColor: AppPalette.paper,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: _controller.isSubmitting
? const CircularProgressIndicator(
color: Colors.white,
)
: const Text(
'반출 신청하기',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15,
),
),
),
),
],
),
),
],
),
),
);
},
);
}
}