import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../../global/api.dart';
import '../../../global/store.dart';
import '../../../global/widgets/ui_button.dart';

class SettingsScreen extends ConsumerStatefulWidget {
  const SettingsScreen({super.key});

  @override
  ConsumerState<SettingsScreen> createState() => _SettingsScreenState();
}

class _SettingsScreenState extends ConsumerState<SettingsScreen> {
  @override
  Widget build(BuildContext context) {
    final user = ref.read(userProvider);
    final family = ref.read(familyProvider);
    return Column(
      children: [
        const Text('Settings'),
        const SizedBox(height: 20),
        Text(user?.name ?? 'N/A'),
        Text("Username: ${user?.username ?? 'N/A'}"),
        Text("Email: ${user?.email ?? 'N/A'}"),
        Text("Family Code: ${family?.code ?? 'N/A'}"),
        const Spacer(),
        UiButton(
          onPressed: () {
            ref.read(jwtProvider.notifier).revokeToken();
            // Navigator.pushAndRemoveUntil(
            //   context,
            //   MaterialPageRoute(builder: (ctx) => const AccountCreateScreen()),
            //   (_) => false,
            // );
          },
          text: 'Sign Out',
        ),
        const SizedBox(height: 20),
      ],
    );
  }
}
