first commit
This commit is contained in:
253
lib/widgets/chatbot_detail_page.dart
Normal file
253
lib/widgets/chatbot_detail_page.dart
Normal file
@@ -0,0 +1,253 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:video_player/video_player.dart'; // 비디오 패키지 임포트
|
||||
|
||||
class ChatbotDetailPage extends StatefulWidget {
|
||||
final VoidCallback onBack;
|
||||
|
||||
const ChatbotDetailPage({super.key, required this.onBack});
|
||||
|
||||
@override
|
||||
State<ChatbotDetailPage> createState() => _ChatbotDetailPageState();
|
||||
}
|
||||
|
||||
class _ChatbotDetailPageState extends State<ChatbotDetailPage> {
|
||||
late VideoPlayerController _knowVideoController;
|
||||
bool _isVideoInitialized = false;
|
||||
bool _hasVideoError = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_initializeKnowVideo();
|
||||
}
|
||||
|
||||
void _initializeKnowVideo() {
|
||||
const String videoAssetPath = 'assets/assets/videos/know.mp4';
|
||||
_knowVideoController = VideoPlayerController.asset(videoAssetPath);
|
||||
|
||||
_knowVideoController.initialize().then((_) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_isVideoInitialized = true;
|
||||
});
|
||||
_knowVideoController.setLooping(true);
|
||||
_knowVideoController.setVolume(0.0);
|
||||
_knowVideoController.play();
|
||||
}).catchError((error) {
|
||||
debugPrint("1차 지식 영상 로딩 실패, 백업 경로 시도 중...: $error");
|
||||
|
||||
_knowVideoController = VideoPlayerController.asset('assets/videos/know.mp4');
|
||||
_knowVideoController.initialize().then((_) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_isVideoInitialized = true;
|
||||
});
|
||||
_knowVideoController.setLooping(true);
|
||||
_knowVideoController.setVolume(0.0);
|
||||
_knowVideoController.play();
|
||||
}).catchError((retryError) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_hasVideoError = true;
|
||||
});
|
||||
debugPrint("최종 지식 비디오 초기화 에러: $retryError");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_knowVideoController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
// 상단 미니 센서 바
|
||||
SizedBox(
|
||||
height: 100,
|
||||
child: Row(
|
||||
children: [
|
||||
_buildMiniSensor('온도', '24.5°C', Colors.orangeAccent),
|
||||
const SizedBox(width: 10),
|
||||
_buildMiniSensor('습도', '65%', Colors.blueAccent),
|
||||
const SizedBox(width: 10),
|
||||
_buildMiniSensor('CO2', '420 ppm', Colors.greenAccent),
|
||||
const SizedBox(width: 10),
|
||||
_buildMiniSensor('TVOC', '0.15 mg/m³', Colors.tealAccent),
|
||||
const SizedBox(width: 10),
|
||||
_buildMiniSensor('미세먼지', '15', Colors.white70),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// 메인 콘텐츠 영역
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
// 🤖 [좌측] 푸미 캐릭터 전용 패널 (✨ flex: 60 으로 수정)
|
||||
Expanded(
|
||||
flex: 60,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF1A1D23),
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
border: Border.all(color: Colors.white.withOpacity(0.05)),
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
// 🔙 "목록으로 돌아가기" 버튼
|
||||
Positioned(
|
||||
top: 20,
|
||||
left: 20,
|
||||
child: MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: GestureDetector(
|
||||
onTap: widget.onBack,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.05),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: const Color(0xFFB4E49C).withOpacity(0.4)),
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.arrow_back_ios_new, color: Color(0xFFB4E49C), size: 14),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
'목록으로 돌아가기',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: -0.5,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// 정중앙 know.mp4 대형 배치
|
||||
Center(
|
||||
child: _hasVideoError
|
||||
? Icon(Icons.smart_toy, size: 160, color: const Color(0xFFB4E49C).withOpacity(0.3))
|
||||
: _isVideoInitialized
|
||||
? SizedBox(
|
||||
width: 600, // ✨ 메인 화면과 짝을 맞춰 550 스케일로 정돈 극대화!
|
||||
child: AspectRatio(
|
||||
aspectRatio: _knowVideoController.value.aspectRatio,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: VideoPlayer(_knowVideoController),
|
||||
),
|
||||
),
|
||||
)
|
||||
: const SizedBox(
|
||||
width: 100,
|
||||
height: 100,
|
||||
child: Center(child: CircularProgressIndicator(color: Color(0xFFB4E49C))),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
|
||||
// 💬 [우측] 채팅창 (✨ flex: 40 으로 수정)
|
||||
Expanded(
|
||||
flex: 40,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF1A1D23),
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: Row(
|
||||
children: [
|
||||
CircleAvatar(backgroundColor: Color(0xFFB4E49C), radius: 4),
|
||||
SizedBox(width: 10),
|
||||
Text('푸미 일지', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
children: [
|
||||
_buildChatBubble("상태 분석이 완료되었습니다. 무엇을 도와드릴까요?", true),
|
||||
_buildChatBubble("현재 습도가 적당하니?", false),
|
||||
_buildChatBubble("네, 습도 65%로 최적의 상태입니다.", true),
|
||||
],
|
||||
),
|
||||
),
|
||||
// 하단 입력창
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: TextField(
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Ask AI...',
|
||||
hintStyle: const TextStyle(color: Colors.white24, fontSize: 14),
|
||||
filled: true,
|
||||
fillColor: Colors.white.withOpacity(0.05),
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(15), borderSide: BorderSide.none),
|
||||
suffixIcon: const Icon(Icons.send, color: Color(0xFFB4E49C), size: 20),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 채팅 말풍선 헬퍼
|
||||
Widget _buildChatBubble(String msg, bool isBot) {
|
||||
return Align(
|
||||
alignment: isBot ? Alignment.centerLeft : Alignment.centerRight,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(vertical: 5),
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: isBot ? Colors.white.withOpacity(0.08) : const Color(0xFFB4E49C).withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: Text(msg, style: const TextStyle(color: Colors.white, fontSize: 13)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 미니 센서 카드 헬퍼
|
||||
Widget _buildMiniSensor(String t, String v, Color c) {
|
||||
return Expanded(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(color: const Color(0xFF1A1D23), borderRadius: BorderRadius.circular(15)),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(t, style: const TextStyle(color: Colors.white54, fontSize: 11)),
|
||||
Text(v, style: TextStyle(color: c, fontSize: 16, fontWeight: FontWeight.bold)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user