diff --git a/assets/images/background.png b/assets/images/background.png index e8dc271..075a7e0 100644 Binary files a/assets/images/background.png and b/assets/images/background.png differ diff --git a/assets/images/background1.png b/assets/images/background1.png deleted file mode 100644 index 075a7e0..0000000 Binary files a/assets/images/background1.png and /dev/null differ diff --git a/assets/images/background2.png b/assets/images/background2.png deleted file mode 100644 index 3ffc458..0000000 Binary files a/assets/images/background2.png and /dev/null differ diff --git a/assets/images/background3.png b/assets/images/background3.png deleted file mode 100644 index 165f03f..0000000 Binary files a/assets/images/background3.png and /dev/null differ diff --git a/assets/images/layer_img.png b/assets/images/layer_img.png index f154a8d..8c2151c 100644 Binary files a/assets/images/layer_img.png and b/assets/images/layer_img.png differ diff --git a/assets/images/layer_img1.png b/assets/images/layer_img1.png deleted file mode 100644 index d0d708e..0000000 Binary files a/assets/images/layer_img1.png and /dev/null differ diff --git a/assets/images/layer_img2.png b/assets/images/layer_img2.png deleted file mode 100644 index 67b5f1b..0000000 Binary files a/assets/images/layer_img2.png and /dev/null differ diff --git a/assets/videos/angry.mp4 b/assets/videos/angry.mp4 index 0d5962c..63aa80c 100644 Binary files a/assets/videos/angry.mp4 and b/assets/videos/angry.mp4 differ diff --git a/lib/screens/chat_screen.dart b/lib/screens/chat_screen.dart index 3ec0646..8ade767 100644 --- a/lib/screens/chat_screen.dart +++ b/lib/screens/chat_screen.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:video_player/video_player.dart'; import '../models/chat_message.dart'; import '../services/chat_service.dart'; -import 'dart:math'; //26.06.24 추가 +import 'dart:math'; class ChatScreen extends StatefulWidget { @@ -32,39 +32,36 @@ class _ChatScreenState extends State { _addInitialMessage(); } - //26.06.24 추가 시작 - String _getVideoFileName(int emotionCategory) { + (String, int) _getVideoInfo(int emotionCategory) { switch(emotionCategory) { case 1: - return 'default.mp4'; // DEFAULT + return ('default.mp4', 10); // DEFAULT case 2: - return 'joy.mp4'; // JOY + return ('joy.mp4', 8); // JOY case 3: - return 'thinking.mp4'; // THINKING + return ('thinking.mp4', 10); // THINKING case 4: - return 'realization.mp4'; // REALIZATION + return ('realization.mp4', 10); // REALIZATION case 5: - return 'angry.mp4'; // ANGER + return ('angry.mp4', 10); // ANGER case 6: - return 'thirst.mp4'; // THIRST + return ('thirst.mp4', 10); // THIRST case 7: - return 'cold.mp4'; // COLD + return ('cold.mp4', 8); // COLD default: - return 'default.mp4'; // 기본값 + return ('default.mp4', 10); // 기본값 } } void _initializeVideo(int emotionCategory) { - final videoFileName = _getVideoFileName(emotionCategory); + final (videoFileName, duration) = _getVideoInfo(emotionCategory); - print('비디오 변경: emotion=$emotionCategory → $videoFileName'); + print('비디오 변경: emotion=$emotionCategory → $videoFileName (${duration}초)'); // 새 비디오 컨트롤러 생성 final newController = VideoPlayerController.asset('assets/videos/$videoFileName'); - // 새 비디오를 먼저 로드 newController.initialize().then((_) { - // 로드 완료 후에 기존 컨트롤러 교체 try { if (_videoController.hasListeners) { _videoController.dispose(); @@ -73,7 +70,6 @@ class _ChatScreenState extends State { print('기존 컨트롤러 dispose 스킵: $e'); } - // 새 컨트롤러로 교체 _videoController = newController; _videoController.setLooping(true); _videoController.setVolume(0.0); @@ -86,7 +82,6 @@ class _ChatScreenState extends State { print('비디오 로드 오류: $error'); }); } - //26.06.24 추가 끝 void _addInitialMessage() { setState(() { @@ -101,7 +96,6 @@ class _ChatScreenState extends State { }); } - //26.06.24 추가 시작 void _sendMessage(String text) async { if (text.isEmpty) return; @@ -148,15 +142,27 @@ class _ChatScreenState extends State { if (emotionCategory != _currentEmotion) { print('감정 변경! $emotionCategory로 비디오 교체'); _currentEmotion = emotionCategory; - // 백그라운드에서 비디오 로드 (화면 깜빡임 없음) + _isVideoInitialized = false; _initializeVideo(_currentEmotion); + + // 영상별 길이에 맞춰 DEFAULT로 복원 + final (_, duration) = _getVideoInfo(emotionCategory); + final delaySeconds = duration * 2; // 2번 재생 + + Future.delayed(Duration(seconds: delaySeconds), () { + if (mounted) { + print('DEFAULT로 복원'); + _currentEmotion = 1; // DEFAULT = 1 + _initializeVideo(1); + } + }); } _messages.add( ChatMessage( text: responseMessage, isUser: false, timestamp: DateTime.now(), - emotionCategory: emotionCategory, // ← 추가 + emotionCategory: emotionCategory, ), ); _isLoading = false; @@ -165,13 +171,13 @@ class _ChatScreenState extends State { } catch (e) { print('메시지 전송 오류: $e'); setState(() { - _messages.removeLast(); // ← 로딩 메시지 제거 + _messages.removeLast(); _messages.add( ChatMessage( text: '오류가 발생했습니다. 다시 시도해주세요.', isUser: false, timestamp: DateTime.now(), - emotionCategory: _currentEmotion, // ← 추가 + emotionCategory: _currentEmotion, ), ); _isLoading = false; @@ -179,7 +185,6 @@ class _ChatScreenState extends State { _scrollToBottom(); } } - //26.06.24 추가 끝 void _scrollToBottom() { Future.delayed(const Duration(milliseconds: 100), () { @@ -213,7 +218,7 @@ class _ChatScreenState extends State { Container( decoration: BoxDecoration( image: DecorationImage( - image: AssetImage('assets/images/background1.png'), + image: AssetImage('assets/images/background.png'), fit: BoxFit.cover, ), ), @@ -223,7 +228,6 @@ class _ChatScreenState extends State { decoration: BoxDecoration( color: Colors.white.withOpacity(0.8), // 투명도 넣기 borderRadius: BorderRadius.circular(36), // 모서리 둥글게 - // border: Border.all(color: Color(0xFFE0E0E0), width: 1), ), child: Row( children: [ @@ -232,14 +236,6 @@ class _ChatScreenState extends State { flex: 5, child: Container( margin: const EdgeInsets.fromLTRB(30, 0, 30, 50), - // decoration: BoxDecoration( - // color: Colors.white, - // borderRadius: BorderRadius.circular(30), - // border: Border.all( - // color: Color(0xFFE0E0E0), - // width: 1, - // ), - // ), child: Column( children: [ // 헤더 @@ -353,7 +349,7 @@ class _ChatScreenState extends State { ), ), ), - const SizedBox(height: 16), + const SizedBox(height: 55), // 캐릭터 정보 + 설명 문구 // 1. 가장 바깥쪽 박스 추가 Container( @@ -431,7 +427,12 @@ class _ChatScreenState extends State { Expanded( flex: 5, child: Container( - margin: const EdgeInsets.all(50), + margin: const EdgeInsets.only( + top: 50, + bottom: 50, + right: 50, + left: 10, + ), decoration: BoxDecoration( color: Color(0xFFfbfdf8), borderRadius: BorderRadius.circular(30), @@ -533,7 +534,6 @@ class _ChatScreenState extends State { controller: _scrollController, padding: const EdgeInsets.all(16), itemCount: _messages.length, - //26.06.24 추가 시작 itemBuilder: (context, index) { final message = _messages[index]; final isLoadingMessage = _isLoading && @@ -544,7 +544,6 @@ class _ChatScreenState extends State { isLoading: isLoadingMessage, ); }, - //26.06.24 추가 끝 ), ), ), @@ -822,7 +821,7 @@ class _ChatScreenState extends State { // Layer 이미지 (화면 전체) IgnorePointer( child: Image.asset( - 'assets/images/layer_img1.png', + 'assets/images/layer_img.png', fit: BoxFit.cover, width: double.infinity, height: double.infinity, @@ -836,11 +835,11 @@ class _ChatScreenState extends State { class _ChatBubble extends StatelessWidget { final ChatMessage message; - final bool isLoading; //26.06.24 추가 + final bool isLoading; const _ChatBubble({ required this.message, - this.isLoading = false //26.06.24 추가 + this.isLoading = false }); String _formatTime(DateTime dateTime) { @@ -911,7 +910,6 @@ class _ChatBubble extends StatelessWidget { ), ], ), - // 26.06.24 추가 시작 child: isLoading ? _LoadingAnimation() // 로딩 중 : SelectableText( @@ -924,7 +922,6 @@ class _ChatBubble extends StatelessWidget { height: 1.4, ), ), - // 26.06.24 추가 끝 ), ), if (!message.isUser) const SizedBox(width: 8), @@ -942,7 +939,6 @@ class _ChatBubble extends StatelessWidget { } } -//26.06.24 추가 시작 class _LoadingAnimation extends StatefulWidget { const _LoadingAnimation(); @@ -1060,8 +1056,4 @@ class _DotPainter extends CustomPainter { @override bool shouldRepaint(_DotPainter oldDelegate) => false; -} -//26.06.24 추가 끝 - -//26.06.24 추가 시작 -//26.06.24 추가 끝 \ No newline at end of file +} \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 18589ae..50ec724 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -72,17 +72,9 @@ flutter: - assets/images/profile.png - assets/images/background.png - - assets/images/background1.png - - assets/images/background2.png - - assets/images/background3.png - - assets/images/send.png - - - assets/images/layer_img.png - - assets/images/layer_img1.png - - assets/images/layer_img2.png - - assets/images/chat_img.png + - assets/images/send.png # To add assets to your application, add an assets section, like this: # assets: