import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../core/app_colors.dart';
import '../../widgets/admin_drawer.dart';
import 'admin_doctors_page.dart';
import 'admin_patients_page.dart';

final adminPageProvider = NotifierProvider<AdminPageNotifier, String>(AdminPageNotifier.new);

class AdminPageNotifier extends Notifier<String> {
  @override String build() => 'doctors';
  void set(String page) => state = page;
}

class AdminHomePage extends ConsumerWidget {
  const AdminHomePage({super.key});

  @override Widget build(BuildContext context, WidgetRef ref) {
    final page = ref.watch(adminPageProvider);

    return Scaffold(
      backgroundColor: AppColors.pageGrey,
      appBar: AppBar(
        backgroundColor: Colors.white,
        elevation: 0,
        title: const Text('系统管理', style: TextStyle(color: AppColors.textPrimary)),
        iconTheme: const IconThemeData(color: AppColors.textPrimary),
      ),
      drawer: const AdminDrawer(),
      body: switch (page) {
        'doctors' => const AdminDoctorsPage(),
        'patients' => const AdminPatientsPage(),
        _ => const AdminDoctorsPage(),
      },
    );
  }
}
