47 lines
1.6 KiB
Dart
47 lines
1.6 KiB
Dart
import 'package:desktopapp/utils/mailer.dart';
|
|
import 'package:desktopapp/widgets/pages/settings/messages_settings.dart';
|
|
import 'package:desktopapp/widgets/pages/settings/whitelist_settings.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
class Settings extends StatefulWidget {
|
|
const Settings({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
_SettingsState createState() => _SettingsState();
|
|
}
|
|
|
|
class _SettingsState extends State<Settings> {
|
|
MailerSettings? mailerSettings;
|
|
Widget buildContent(BuildContext context, SharedPreferences prefs) {
|
|
return Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: GridView(
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 2, mainAxisSpacing: 8.0, crossAxisSpacing: 8.0),
|
|
children: [
|
|
MessagesSettings(settings: mailerSettings!, prefs: prefs),
|
|
WhitelistSettings(settings: mailerSettings!, prefs: prefs)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('Settings')),
|
|
body: FutureBuilder(
|
|
future: SharedPreferences.getInstance(),
|
|
builder: (BuildContext context,
|
|
AsyncSnapshot<SharedPreferences> snapshot) {
|
|
if (snapshot.hasData) {
|
|
final prefs = snapshot.data!;
|
|
mailerSettings = MailerSettings.loadSettings(prefs);
|
|
return buildContent(context, prefs);
|
|
} else {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
}));
|
|
}
|
|
}
|