// ABOUTME: Shared app bar widget for consistent navigation bar across all screens
// ABOUTME: Includes theme toggle button and dynamic title based on current screen
import 'package:flutter/material.dart';

class SharedAppBar extends StatelessWidget implements PreferredSizeWidget {
  final String title;
  final VoidCallback? onThemeToggle;
  final bool isDarkMode;

  const SharedAppBar({
    super.key,
    required this.title,
    this.onThemeToggle,
    required this.isDarkMode,
  });

  @override
  Widget build(BuildContext context) {
    return AppBar(
      title: Text(
        title,
        style: Theme.of(context).textTheme.headlineSmall?.copyWith(
          fontWeight: FontWeight.w600,
        ),
      ),
      centerTitle: true,
      elevation: 0,
      scrolledUnderElevation: 4,
      actions: [
        if (onThemeToggle != null)
          IconButton(
            onPressed: onThemeToggle,
            icon: Icon(
              isDarkMode ? Icons.light_mode : Icons.dark_mode,
            ),
            tooltip: isDarkMode ? 'Switch to light mode' : 'Switch to dark mode',
          ),
      ],
    );
  }

  @override
  Size get preferredSize => const Size.fromHeight(kToolbarHeight);
}
