import 'package:flutter/material.dart';
import '../contacts/contact_state.dart';
import '../contacts/widgets/alphabet_scroll_page.dart';

class FavoritesPage extends StatelessWidget {
  const FavoritesPage({super.key});

  @override
  Widget build(BuildContext context) {
    final contactState = ContactState.of(context);
    
    if (contactState.loading) {
      return const Scaffold(
        backgroundColor: Colors.black,
        body: Center(child: CircularProgressIndicator()),
      );
    }
    
    final favorites = contactState.favoriteContacts;
    
    return Scaffold(
      backgroundColor: Colors.black,
      body: favorites.isEmpty
          ? const Center(
              child: Text(
                'No favorites yet.\nStar your contacts to add them here.',
                style: TextStyle(color: Colors.white60),
                textAlign: TextAlign.center,
              ),
            )
          : AlphabetScrollPage(
              scrollOffset: contactState.scrollOffset,
              contacts: favorites,
            ),
    );
  }
}
