import 'package:flutter/material.dart';

class SettingsCallPage extends StatefulWidget {
  const SettingsCallPage({super.key});

  @override
  _SettingsCallPageState createState() => _SettingsCallPageState();
}

class _SettingsCallPageState extends State<SettingsCallPage> {
  bool _enableVoicemail = true;
  bool _enableCallRecording = false;
  String _ringtone = 'Default';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.black,
      appBar: AppBar(
        title: const Text('Calling settings'),
      ),
      body: ListView(
        children: [
          SwitchListTile(
            title: const Text('Enable Voicemail', style: TextStyle(color: Colors.white)),
            value: _enableVoicemail,
            onChanged: (bool value) {
              setState(() {
                _enableVoicemail = value;
              });
            },
          ),
          SwitchListTile(
            title: const Text('Enable call Recording', style: TextStyle(color: Colors.white)),
            value: _enableCallRecording,
            onChanged: (bool value) {
              setState(() {
                _enableCallRecording = value;
              });
            },
          ),
          ListTile(
            title: const Text('Ringtone', style: TextStyle(color: Colors.white)),
            subtitle: Text(_ringtone, style: const TextStyle(color: Colors.grey)),
            trailing: const Icon(Icons.arrow_forward_ios, color: Colors.white),
            onTap: () {
              _selectRingtone(context);
            },
          ),
        ],
      ),
    );
  }

  void _selectRingtone(BuildContext context) {
    showDialog<String>(
      context: context,
      builder: (BuildContext context) {
        return SimpleDialog(
          title: const Text('Select Ringtone'),
          children: <Widget>[
            SimpleDialogOption(
              onPressed: () {
                Navigator.pop(context, 'Default');
              },
              child: const Text('Default'),
            ),
            SimpleDialogOption(
              onPressed: () {
                Navigator.pop(context, 'Classic');
              },
              child: const Text('Classic'),
            ),
            SimpleDialogOption(
              onPressed: () {
                Navigator.pop(context, 'Beep');
              },
              child: const Text('Beep'),
            ),
            // ...existing options...
          ],
        );
      },
    ).then((value) {
      if (value != null) {
        setState(() {
          _ringtone = value;
        });
      }
    });
  }
}
