66 lines
2.1 KiB
Dart
66 lines
2.1 KiB
Dart
import 'package:desktopapp/utils/mailer.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
class WhitelistSettings extends StatefulWidget {
|
|
const WhitelistSettings(
|
|
{Key? key, required this.settings, required this.prefs})
|
|
: super(key: key);
|
|
|
|
final MailerSettings settings;
|
|
final SharedPreferences prefs;
|
|
|
|
@override
|
|
_WhitelistSettingsState createState() => _WhitelistSettingsState();
|
|
}
|
|
|
|
class _WhitelistSettingsState extends State<WhitelistSettings> {
|
|
final TextEditingController controller = TextEditingController();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Card(
|
|
child: Column(
|
|
children: [
|
|
const Text('Whitelist :', style: TextStyle(fontSize: 24)),
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Row(
|
|
children: [
|
|
Expanded(child: TextField(controller: controller)),
|
|
TextButton(
|
|
child: const Text('Ajouter'),
|
|
onPressed: () {
|
|
setState(() {
|
|
widget.settings.whitelist.add(controller.text);
|
|
controller.clear();
|
|
widget.settings.saveSettings(widget.prefs);
|
|
});
|
|
},
|
|
)
|
|
],
|
|
),
|
|
),
|
|
Expanded(
|
|
child: ListView.builder(
|
|
itemCount: widget.settings.whitelist.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return ListTile(
|
|
title: Text(widget.settings.whitelist[index]),
|
|
leading: IconButton(
|
|
icon: const Icon(Icons.delete_rounded),
|
|
onPressed: () {
|
|
setState(() {
|
|
widget.settings.whitelist.removeAt(index);
|
|
widget.settings.saveSettings(widget.prefs);
|
|
});
|
|
},
|
|
),
|
|
);
|
|
}),
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|