2024-12-14 16:44:36 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2025-01-07 13:38:36 +00:00
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
// Firebase Core
|
|
|
|
import 'package:firebase_core/firebase_core.dart';
|
|
|
|
// Firebase Database (필요하다면)
|
|
|
|
import 'package:firebase_database/firebase_database.dart';
|
|
|
|
|
|
|
|
// firebase_options.dart 파일을 import
|
|
|
|
import 'firebase_options.dart';
|
|
|
|
|
|
|
|
import 'views/login/login_page.dart';
|
|
|
|
import 'views/room/main_page.dart';
|
|
|
|
|
2025-01-13 06:04:33 +00:00
|
|
|
// 모바일 광고
|
|
|
|
import 'package:google_mobile_ads/google_mobile_ads.dart';
|
|
|
|
|
2025-01-07 13:38:36 +00:00
|
|
|
void main() async {
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
2025-01-13 06:04:33 +00:00
|
|
|
// 파이어베이스 초기화
|
|
|
|
await Firebase.initializeApp();
|
|
|
|
|
|
|
|
// 모바일 광고 초기화
|
|
|
|
MobileAds.instance.initialize();
|
2024-12-14 16:44:36 +00:00
|
|
|
|
|
|
|
runApp(const MyApp());
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
const MyApp({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return MaterialApp(
|
2025-01-07 13:38:36 +00:00
|
|
|
title: 'ALLSCORE',
|
2024-12-14 16:44:36 +00:00
|
|
|
theme: ThemeData(
|
2025-01-07 13:38:36 +00:00
|
|
|
primarySwatch: Colors.blue,
|
|
|
|
),
|
|
|
|
home: FutureBuilder<bool>(
|
|
|
|
future: _checkLoginStatus(),
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
|
|
return const Scaffold(
|
|
|
|
body: Center(child: CircularProgressIndicator()),
|
|
|
|
);
|
|
|
|
} else if (snapshot.hasData && snapshot.data == true) {
|
|
|
|
return const MainPage();
|
|
|
|
} else {
|
|
|
|
return const LoginPage();
|
|
|
|
}
|
|
|
|
},
|
2024-12-14 16:44:36 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2025-01-07 13:38:36 +00:00
|
|
|
|
|
|
|
Future<bool> _checkLoginStatus() async {
|
|
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
bool autoLogin = prefs.getBool('auto_login') ?? false;
|
|
|
|
String authToken = prefs.getString('auth_token') ?? '';
|
|
|
|
return autoLogin && authToken.isNotEmpty;
|
|
|
|
}
|
2024-12-14 16:44:36 +00:00
|
|
|
}
|