Files
submanager/lib/providers/navigation_provider.dart
JiWoong Sul 4731288622 Major UI/UX and architecture improvements
- Implemented new navigation system with NavigationProvider and route management
- Added adaptive theme system with ThemeProvider for better theme handling
- Introduced glassmorphism design elements (app bars, scaffolds, cards)
- Added advanced animations (spring animations, page transitions, staggered lists)
- Implemented performance optimizations (memory manager, lazy loading)
- Refactored Analysis screen into modular components
- Added floating navigation bar with haptic feedback
- Improved subscription cards with swipe actions
- Enhanced skeleton loading with better animations
- Added cached network image support
- Improved overall app architecture and code organization

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-10 18:36:57 +09:00

106 lines
2.5 KiB
Dart

import 'package:flutter/material.dart';
class NavigationProvider extends ChangeNotifier {
int _currentIndex = 0;
final List<int> _navigationHistory = [0];
String _currentRoute = '/';
String _currentTitle = '';
int get currentIndex => _currentIndex;
List<int> get navigationHistory => List.unmodifiable(_navigationHistory);
String get currentRoute => _currentRoute;
String get currentTitle => _currentTitle;
static const Map<String, int> routeToIndex = {
'/': 0,
'/add-subscription': -1,
'/sms-scanner': 3,
'/analysis': 1,
'/settings': 4,
'/subscription-detail': -1,
};
static const Map<int, String> indexToRoute = {
0: '/',
1: '/analysis',
3: '/sms-scanner',
4: '/settings',
};
static const Map<int, String> indexToTitle = {
0: '',
1: '분석',
3: 'SMS 스캔',
4: '설정',
};
void updateCurrentIndex(int index, {bool addToHistory = true}) {
if (_currentIndex == index) return;
_currentIndex = index;
_currentRoute = indexToRoute[index] ?? '/';
_currentTitle = indexToTitle[index] ?? '';
if (addToHistory && index >= 0) {
_navigationHistory.add(index);
if (_navigationHistory.length > 10) {
_navigationHistory.removeAt(0);
}
}
notifyListeners();
}
void updateByRoute(String route) {
final index = routeToIndex[route] ?? 0;
_currentRoute = route;
if (index >= 0) {
_currentIndex = index;
_currentTitle = indexToTitle[index] ?? '';
} else {
switch (route) {
case '/add-subscription':
_currentTitle = '구독 추가';
break;
case '/subscription-detail':
_currentTitle = '구독 상세';
break;
default:
_currentTitle = '';
}
}
notifyListeners();
}
bool canPop() {
return _navigationHistory.length > 1;
}
void pop() {
if (_navigationHistory.length > 1) {
_navigationHistory.removeLast();
final previousIndex = _navigationHistory.last;
updateCurrentIndex(previousIndex, addToHistory: false);
}
}
void reset() {
_currentIndex = 0;
_currentRoute = '/';
_currentTitle = '';
_navigationHistory.clear();
_navigationHistory.add(0);
notifyListeners();
}
void clearHistoryAndGoHome() {
_currentIndex = 0;
_currentRoute = '/';
_currentTitle = '';
_navigationHistory.clear();
_navigationHistory.add(0);
notifyListeners();
}
}