feat: API 통합 2차 작업 완료
- 자동 로그인 구현: 앱 시작 시 토큰 확인 후 적절한 화면으로 라우팅 - AuthInterceptor 개선: AuthService와 통합하여 토큰 관리 일원화 - 로그아웃 기능 개선: AuthService를 사용한 API 로그아웃 처리 - 대시보드 API 연동: MockDataService에서 실제 API로 완전 전환 - Dashboard DTO 모델 생성 (OverviewStats, RecentActivity 등) - DashboardRemoteDataSource 및 DashboardService 구현 - OverviewController를 ChangeNotifier 패턴으로 개선 - OverviewScreenRedesign에 Provider 패턴 적용 - API 통합 진행 상황 문서 업데이트
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:superport/models/equipment_unified_model.dart';
|
||||
import 'package:superport/screens/common/app_layout_redesign.dart';
|
||||
import 'package:superport/screens/common/theme_shadcn.dart';
|
||||
@@ -8,6 +9,7 @@ import 'package:superport/screens/equipment/equipment_out_form.dart';
|
||||
import 'package:superport/screens/license/license_form.dart'; // MaintenanceFormScreen으로 사용
|
||||
import 'package:superport/screens/user/user_form.dart';
|
||||
import 'package:superport/screens/warehouse_location/warehouse_location_form.dart';
|
||||
import 'package:superport/services/auth_service.dart';
|
||||
import 'package:superport/utils/constants.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:superport/screens/login/login_screen.dart';
|
||||
@@ -29,6 +31,8 @@ class SuperportApp extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final authService = GetIt.instance<AuthService>();
|
||||
|
||||
return MaterialApp(
|
||||
title: 'supERPort',
|
||||
theme: ShadcnTheme.lightTheme,
|
||||
@@ -39,7 +43,26 @@ class SuperportApp extends StatelessWidget {
|
||||
],
|
||||
supportedLocales: const [Locale('ko', 'KR'), Locale('en', 'US')],
|
||||
locale: const Locale('ko', 'KR'),
|
||||
initialRoute: '/login',
|
||||
home: FutureBuilder<bool>(
|
||||
future: authService.isLoggedIn(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (snapshot.hasData && snapshot.data!) {
|
||||
// 토큰이 유효하면 홈 화면으로
|
||||
return AppLayoutRedesign(initialRoute: Routes.home);
|
||||
} else {
|
||||
// 토큰이 없거나 유효하지 않으면 로그인 화면으로
|
||||
return const LoginScreen();
|
||||
}
|
||||
},
|
||||
),
|
||||
onGenerateRoute: (settings) {
|
||||
// 로그인 라우트 처리
|
||||
if (settings.name == '/login') {
|
||||
@@ -182,6 +205,7 @@ class SuperportApp extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
},
|
||||
navigatorKey: GlobalKey<NavigatorState>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user