perf(app): 초기화 병렬 처리 및 UI 개선

## 성능 최적화

### main.dart
- 앱 초기화 병렬 처리 (Future.wait 활용)
- 광고 SDK, Hive 초기화 동시 실행
- Hive Box 오픈 병렬 처리
- 코드 구조화 (_initializeHive, _initializeNotifications)

### visit_provider.dart
- allLastVisitDatesProvider 추가
- 리스트 화면에서 N+1 쿼리 방지
- 모든 맛집의 마지막 방문일 일괄 조회

## UI 개선

### 각 화면 리팩토링
- AppDimensions 상수 적용
- 스켈레톤 로더 적용
- 코드 정리 및 일관성 개선
This commit is contained in:
JiWoong Sul
2026-01-12 15:16:05 +09:00
parent 21941443ee
commit 6f45c7b456
8 changed files with 252 additions and 205 deletions

View File

@@ -22,14 +22,28 @@ import 'data/sample/sample_data_initializer.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
if (AdHelper.isMobilePlatform) {
await MobileAds.instance.initialize();
}
// Initialize timezone
// Initialize timezone (동기, 빠름)
tz.initializeTimeZones();
// Initialize Hive
// 광고 SDK와 Hive 초기화를 병렬 처리
await Future.wait([
if (AdHelper.isMobilePlatform) MobileAds.instance.initialize(),
_initializeHive(),
]);
// Hive 초기화 후 병렬 처리 가능한 작업들
await Future.wait([
SampleDataInitializer.seedInitialData(),
_initializeNotifications(),
AdaptiveTheme.getThemeMode(),
]).then((results) {
final savedThemeMode = results[2] as AdaptiveThemeMode?;
runApp(ProviderScope(child: LunchPickApp(savedThemeMode: savedThemeMode)));
});
}
/// Hive 초기화 및 Box 오픈
Future<void> _initializeHive() async {
await Hive.initFlutter();
// Register Hive Adapters
@@ -39,24 +53,21 @@ void main() async {
Hive.registerAdapter(RecommendationRecordAdapter());
Hive.registerAdapter(UserSettingsAdapter());
// Open Hive Boxes
await Hive.openBox<Restaurant>(AppConstants.restaurantBox);
await Hive.openBox<VisitRecord>(AppConstants.visitRecordBox);
await Hive.openBox<RecommendationRecord>(AppConstants.recommendationBox);
await Hive.openBox(AppConstants.settingsBox);
await Hive.openBox<UserSettings>('user_settings');
await SampleDataInitializer.seedInitialData();
// Open Hive Boxes (병렬 오픈)
await Future.wait([
Hive.openBox<Restaurant>(AppConstants.restaurantBox),
Hive.openBox<VisitRecord>(AppConstants.visitRecordBox),
Hive.openBox<RecommendationRecord>(AppConstants.recommendationBox),
Hive.openBox(AppConstants.settingsBox),
Hive.openBox<UserSettings>('user_settings'),
]);
}
// Initialize Notification Service (only for non-web platforms)
if (!kIsWeb) {
final notificationService = NotificationService();
await notificationService.ensureInitialized(requestPermission: true);
}
// Get saved theme mode
final savedThemeMode = await AdaptiveTheme.getThemeMode();
runApp(ProviderScope(child: LunchPickApp(savedThemeMode: savedThemeMode)));
/// 알림 서비스 초기화 (비-웹 플랫폼)
Future<void> _initializeNotifications() async {
if (kIsWeb) return;
final notificationService = NotificationService();
await notificationService.ensureInitialized(requestPermission: true);
}
class LunchPickApp extends StatelessWidget {