mirror of
https://gitlab.com/foxixus/neomovies_mobile.git
synced 2025-10-28 01:18:50 +05:00
1. Add Downloads screen to main navigation:
- Import DownloadsScreen in main_screen.dart
- Replace placeholder 'Downloads Page' with actual DownloadsScreen component
- Downloads tab now fully functional with torrent management
2. Fix authentication models for API compatibility:
- AuthResponse: Handle wrapped API response with 'data' field
- User model: Add 'verified' field, support both '_id' and 'id' fields
- Add toJson() method to User for serialization
- Fix parsing to match backend response format
3. Fix movie details screen (gray screen issue):
- Implement getExternalIds() in NeoMoviesApiClient
- Add IMDb ID fetching via /movies/{id}/external-ids endpoint
- Update api_client.dart to use new getExternalIds method
- Fix movie detail provider to properly load IMDb IDs
Changes:
- lib/presentation/screens/main_screen.dart: Add DownloadsScreen import and replace placeholder
- lib/data/models/auth_response.dart: Handle wrapped 'data' response
- lib/data/models/user.dart: Add verified field and toJson method
- lib/data/api/neomovies_api_client.dart: Add getExternalIds endpoint
- lib/data/api/api_client.dart: Implement getImdbId using external IDs
Result:
✅ Downloads tab works and shows torrent list
✅ Authentication properly parses API responses
✅ Movie detail screen loads IMDb IDs correctly
✅ All API models match backend format
110 lines
3.6 KiB
Dart
110 lines
3.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:neomovies_mobile/presentation/providers/auth_provider.dart';
|
|
import 'package:neomovies_mobile/presentation/screens/auth/profile_screen.dart';
|
|
import 'package:neomovies_mobile/presentation/screens/favorites/favorites_screen.dart';
|
|
import 'package:neomovies_mobile/presentation/screens/search/search_screen.dart';
|
|
import 'package:neomovies_mobile/presentation/screens/home/home_screen.dart';
|
|
import 'package:neomovies_mobile/presentation/screens/downloads/downloads_screen.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class MainScreen extends StatefulWidget {
|
|
const MainScreen({super.key});
|
|
|
|
@override
|
|
State<MainScreen> createState() => _MainScreenState();
|
|
}
|
|
|
|
class _MainScreenState extends State<MainScreen> {
|
|
int _selectedIndex = 0;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
// Check auth status when the main screen is initialized
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
Provider.of<AuthProvider>(context, listen: false).checkAuthStatus();
|
|
});
|
|
}
|
|
|
|
// Pages for each tab
|
|
static const List<Widget> _widgetOptions = <Widget>[
|
|
HomeScreen(),
|
|
SearchScreen(),
|
|
FavoritesScreen(),
|
|
DownloadsScreen(),
|
|
ProfileScreen(),
|
|
];
|
|
|
|
void _onItemTapped(int index) {
|
|
setState(() {
|
|
_selectedIndex = index;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
|
|
return Scaffold(
|
|
body: IndexedStack(
|
|
index: _selectedIndex,
|
|
children: _widgetOptions,
|
|
),
|
|
bottomNavigationBar: NavigationBarTheme(
|
|
data: NavigationBarThemeData(
|
|
backgroundColor: colorScheme.surfaceContainerHighest,
|
|
indicatorColor: colorScheme.surfaceContainerHighest.withOpacity(0.6),
|
|
iconTheme: MaterialStateProperty.resolveWith<IconThemeData>((states) {
|
|
if (states.contains(MaterialState.selected)) {
|
|
return IconThemeData(color: colorScheme.onSurface);
|
|
}
|
|
return IconThemeData(color: colorScheme.onSurfaceVariant);
|
|
}),
|
|
labelTextStyle: MaterialStateProperty.resolveWith<TextStyle>((states) {
|
|
if (states.contains(MaterialState.selected)) {
|
|
return TextStyle(
|
|
color: colorScheme.onSurface,
|
|
fontWeight: FontWeight.w600,
|
|
);
|
|
}
|
|
return TextStyle(
|
|
color: colorScheme.onSurfaceVariant,
|
|
);
|
|
}),
|
|
),
|
|
child: NavigationBar(
|
|
onDestinationSelected: _onItemTapped,
|
|
selectedIndex: _selectedIndex,
|
|
destinations: const <NavigationDestination>[
|
|
NavigationDestination(
|
|
icon: Icon(Icons.home_outlined),
|
|
selectedIcon: Icon(Icons.home),
|
|
label: 'Home',
|
|
),
|
|
NavigationDestination(
|
|
icon: Icon(Icons.search),
|
|
selectedIcon: Icon(Icons.search),
|
|
label: 'Search',
|
|
),
|
|
NavigationDestination(
|
|
icon: Icon(Icons.favorite_border),
|
|
selectedIcon: Icon(Icons.favorite),
|
|
label: 'Favorites',
|
|
),
|
|
NavigationDestination(
|
|
icon: Icon(Icons.download_outlined),
|
|
selectedIcon: Icon(Icons.download),
|
|
label: 'Downloads',
|
|
),
|
|
NavigationDestination(
|
|
icon: Icon(Icons.person_2_outlined),
|
|
selectedIcon: Icon(Icons.person_2),
|
|
label: 'Profile',
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|