voicemail settings
This commit is contained in:
parent
50235b13c5
commit
b9ea62f8c1
@ -4,6 +4,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:dialer/features/settings/call/settingsCall.dart';
|
import 'package:dialer/features/settings/call/settingsCall.dart';
|
||||||
import 'package:dialer/features/settings/sim/settings_accounts.dart';
|
import 'package:dialer/features/settings/sim/settings_accounts.dart';
|
||||||
import 'package:dialer/features/settings/key/manage_keys_page.dart';
|
import 'package:dialer/features/settings/key/manage_keys_page.dart';
|
||||||
|
import 'package:dialer/features/settings/sorting/sorting.dart';
|
||||||
|
import 'package:dialer/features/settings/voicemail/voicemail.dart';
|
||||||
|
|
||||||
class SettingsPage extends StatelessWidget {
|
class SettingsPage extends StatelessWidget {
|
||||||
const SettingsPage({super.key});
|
const SettingsPage({super.key});
|
||||||
@ -28,6 +30,18 @@ class SettingsPage extends StatelessWidget {
|
|||||||
MaterialPageRoute(builder: (context) => const GestionDeClesPage()),
|
MaterialPageRoute(builder: (context) => const GestionDeClesPage()),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
case 'Sorting settings':
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => const SortingSettingsPage()),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 'Messagerie vocale':
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => Voicemail()),
|
||||||
|
);
|
||||||
|
break;
|
||||||
// Add more cases for other settings pages
|
// Add more cases for other settings pages
|
||||||
default:
|
default:
|
||||||
// Handle default or unknown settings
|
// Handle default or unknown settings
|
||||||
@ -41,6 +55,8 @@ class SettingsPage extends StatelessWidget {
|
|||||||
'Calling settings',
|
'Calling settings',
|
||||||
'Page des comptes téléphoniques',
|
'Page des comptes téléphoniques',
|
||||||
'Gestion de clés', // Add the new option here
|
'Gestion de clés', // Add the new option here
|
||||||
|
'Sorting settings',
|
||||||
|
'Messagerie vocale',
|
||||||
];
|
];
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
132
dialer/lib/features/settings/voicemail/voicemail.dart
Normal file
132
dialer/lib/features/settings/voicemail/voicemail.dart
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
class Voicemail extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_VoicemailState createState() => _VoicemailState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _VoicemailState extends State<Voicemail> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
final TextEditingController _customController = TextEditingController();
|
||||||
|
|
||||||
|
String _selectedProvider = 'SFR';
|
||||||
|
String _voicemailNumber = '';
|
||||||
|
bool _isCustomNumber = false;
|
||||||
|
|
||||||
|
// List of French internet providers and their voicemail numbers
|
||||||
|
final Map<String, String> _providers = {
|
||||||
|
'SFR': '123',
|
||||||
|
'Orange': '888',
|
||||||
|
'Bouygues': '660',
|
||||||
|
'Free': '666',
|
||||||
|
'Custom': '',
|
||||||
|
};
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_loadVoicemailNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _loadVoicemailNumber() async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
setState(() {
|
||||||
|
_voicemailNumber = prefs.getString('voicemailNumber') ?? '';
|
||||||
|
_isCustomNumber = !_providers.containsValue(_voicemailNumber);
|
||||||
|
_selectedProvider = _isCustomNumber ? 'Custom' : _providers.keys.firstWhere((key) => _providers[key] == _voicemailNumber, orElse: () => 'SFR');
|
||||||
|
_customController.text = _isCustomNumber ? _voicemailNumber : '';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _saveVoicemailNumber() async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
prefs.setString('voicemailNumber', _voicemailNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.black,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text('Messagerie vocale'),
|
||||||
|
),
|
||||||
|
body: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
DropdownButtonFormField<String>(
|
||||||
|
value: _selectedProvider,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'Selectionnez un fournisseur',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
items: _providers.keys.map((String provider) {
|
||||||
|
return DropdownMenuItem<String>(
|
||||||
|
value: provider,
|
||||||
|
child: Text(provider),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
onChanged: (String? newValue) {
|
||||||
|
setState(() {
|
||||||
|
_selectedProvider = newValue!;
|
||||||
|
_isCustomNumber = _selectedProvider == 'Custom';
|
||||||
|
_voicemailNumber = _isCustomNumber ? _customController.text : _providers[_selectedProvider]!;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(height: 20),
|
||||||
|
if (_isCustomNumber)
|
||||||
|
TextFormField(
|
||||||
|
controller: _customController,
|
||||||
|
keyboardType: TextInputType.phone,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'Entrez un numéro de messagerie vocale',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
validator: (value) {
|
||||||
|
if (_isCustomNumber && value!.isEmpty) {
|
||||||
|
return 'Veuillez entrer un numéro de messagerie vocale';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
onChanged: (value) {
|
||||||
|
_voicemailNumber = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(height: 20),
|
||||||
|
const Spacer(),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
if (_formKey.currentState!.validate()) {
|
||||||
|
_voicemailNumber = _isCustomNumber ? _customController.text : _providers[_selectedProvider]!;
|
||||||
|
_saveVoicemailNumber();
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text('Enregistrer'),
|
||||||
|
),
|
||||||
|
// Padding(
|
||||||
|
// // center the button
|
||||||
|
// padding: const Edge
|
||||||
|
// child: ElevatedButton(
|
||||||
|
// onPressed: () {
|
||||||
|
// if (_formKey.currentState!.validate()) {
|
||||||
|
// _voicemailNumber = _isCustomNumber ? _customController.text : _providers[_selectedProvider]!;
|
||||||
|
// _saveVoicemailNumber();
|
||||||
|
// Navigator.pop(context);
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// child: Text('Save'),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user