58 lines
1.7 KiB
Dart
58 lines
1.7 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
||
|
|
import 'package:playwith_core/playwith_core.dart'; // Core 패키지 import
|
||
|
|
import 'lobby_screen.dart';
|
||
|
|
|
||
|
|
class IntroScreen extends StatefulWidget {
|
||
|
|
const IntroScreen({super.key});
|
||
|
|
|
||
|
|
@override
|
||
|
|
State<IntroScreen> createState() => _IntroScreenState();
|
||
|
|
}
|
||
|
|
|
||
|
|
class _IntroScreenState extends State<IntroScreen> {
|
||
|
|
final _nicknameController = TextEditingController();
|
||
|
|
|
||
|
|
void _enterLobby() {
|
||
|
|
if (_nicknameController.text.trim().isEmpty) return;
|
||
|
|
|
||
|
|
// 1. Core 패키지의 NetworkManager 초기화
|
||
|
|
NetworkManager().initialize(nickname: _nicknameController.text.trim());
|
||
|
|
|
||
|
|
// 2. 로비 화면으로 이동
|
||
|
|
Navigator.push(
|
||
|
|
context,
|
||
|
|
MaterialPageRoute(builder: (_) => const LobbyScreen()),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
return Scaffold(
|
||
|
|
body: Center(
|
||
|
|
child: Padding(
|
||
|
|
padding: const EdgeInsets.all(32.0),
|
||
|
|
child: Column(
|
||
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
|
children: [
|
||
|
|
const Text('PlayWith', style: TextStyle(fontSize: 40, fontWeight: FontWeight.bold)),
|
||
|
|
const SizedBox(height: 40),
|
||
|
|
TextField(
|
||
|
|
controller: _nicknameController,
|
||
|
|
decoration: const InputDecoration(
|
||
|
|
labelText: '닉네임을 입력하세요',
|
||
|
|
border: OutlineInputBorder(),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
const SizedBox(height: 20),
|
||
|
|
ElevatedButton(
|
||
|
|
onPressed: _enterLobby,
|
||
|
|
style: ElevatedButton.styleFrom(minimumSize: const Size(double.infinity, 50)),
|
||
|
|
child: const Text('입장하기'),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|