playWith/apps/app/lib/main.dart

82 lines
2.8 KiB
Dart
Raw Normal View History

2025-11-21 17:58:56 +09:00
import 'package:flutter/material.dart';
2025-11-24 17:53:00 +09:00
import 'package:playwith_core/playwith_core.dart';
2025-11-25 16:34:13 +09:00
import 'package:playwith_game_quiz/quiz_game.dart';
import 'login_screen.dart'; // [수정] 인트로 스크린 import (경로가 다르면 수정 필요)
import 'intro/intro_screen.dart'; // 만약 intro 폴더에 넣으셨다면 이 경로 사용
import 'lobby_screen.dart';
2025-11-21 17:58:56 +09:00
2025-11-25 16:34:13 +09:00
Future<void> main() async {
2025-11-24 17:53:00 +09:00
WidgetsFlutterBinding.ensureInitialized();
2025-11-25 16:34:13 +09:00
2025-11-24 17:53:00 +09:00
SoundManager().initialize(soundPaths: {
SoundKey.bgm: 'audio/bgm.mp3',
SoundKey.correct: 'audio/correct.mp3',
SoundKey.wrong: 'audio/wrong.mp3',
SoundKey.win: 'audio/win.mp3',
2025-11-25 16:34:13 +09:00
SoundKey.click: 'audio/correct.mp3',
2025-11-24 17:53:00 +09:00
});
2025-11-25 16:34:13 +09:00
await NotificationManager().initialize();
2025-11-21 18:04:15 +09:00
runApp(const PlayWithApp());
2025-11-21 17:58:56 +09:00
}
2025-11-24 17:53:00 +09:00
class PlayWithApp extends StatefulWidget {
2025-11-21 18:04:15 +09:00
const PlayWithApp({super.key});
2025-11-21 17:58:56 +09:00
2025-11-24 17:53:00 +09:00
@override
State<PlayWithApp> createState() => _PlayWithAppState();
}
class _PlayWithAppState extends State<PlayWithApp> {
final _net = NetworkManager();
2025-11-25 16:34:13 +09:00
final _settings = SettingsNotifier();
2025-11-24 17:53:00 +09:00
final List<BaseGame> _games = [
2025-11-25 16:34:13 +09:00
QuizGame(),
2025-11-24 17:53:00 +09:00
];
@override
void initState() {
super.initState();
_net.messageStream.listen((data) {
2025-11-25 16:34:13 +09:00
// 라우팅 로직...
2025-11-24 17:53:00 +09:00
});
}
2025-11-21 17:58:56 +09:00
@override
Widget build(BuildContext context) {
2025-11-25 16:34:13 +09:00
return ListenableBuilder(
listenable: _settings,
builder: (context, child) {
return MaterialApp(
title: 'PlayWith',
theme: _settings.currentTheme,
themeMode: _settings.currentThemeMode,
builder: (context, child) {
return MediaQuery(
data: MediaQuery.of(context).copyWith(
textScaler: TextScaler.linear(_settings.fontScale),
),
child: child!,
);
},
// [핵심 수정] 앱 시작 시 IntroScreen을 먼저 보여줌
// nextScreenBuilder를 통해 애니메이션 종료 후 갈 곳(Lobby) 지정
home: IntroScreen(
nextScreenBuilder: (context) => const LoginScreen(),
),
);
},
2025-11-21 17:58:56 +09:00
);
}
2025-11-25 16:34:13 +09:00
}
// [팁] 인트로와 닉네임 입력(IntroScreen.dart의 기존 로직)을 연결하기 위한 래퍼
// 기존에 있던 닉네임 입력 화면(IntroScreen)과 이름이 겹치므로,
// 기존의 닉네임 입력 화면은 'LoginScreen'이나 'NameInputScreen'으로 이름을 바꾸는 게 좋습니다.
// 만약 'IntroScreen' 파일이 닉네임 입력 화면이었다면,
// 이번에 만든 애니메이션 화면을 'SplashAnimationScreen' 등으로 이름을 지어서 구분해주세요.
// 여기서는 이번에 만든 애니메이션 화면을 'IntroAnimationScreen'이라고 가정하고,
// 애니메이션이 끝나면 -> 닉네임 입력 화면(기존 IntroScreen) -> 로비 순서로 가는 게 자연스럽습니다.