1
0
Fork 0

Add mailbox Select

This commit is contained in:
Florian RICHER (MrDev023) 2022-04-26 21:28:49 +02:00
parent ef3379f1d9
commit 8372769fbb
3 changed files with 76 additions and 6 deletions

View file

@ -22,6 +22,8 @@ class _HomePageState extends State<HomePage> {
final StreamController<StreamElement> controller =
StreamController<StreamElement>();
final ScrollController _scrollController = ScrollController();
Widget buildContent(BuildContext context, SharedPreferences prefs) {
return Column(children: [
if (!connected)
@ -30,6 +32,7 @@ class _HomePageState extends State<HomePage> {
prefs: prefs,
onValid: (String email, String password) async {
var value = await Mailer.connect(
context: context,
email: email,
password: password,
streamController: controller);
@ -75,7 +78,10 @@ class _HomePageState extends State<HomePage> {
}
return ListView.builder(
itemCount: streamElements.length,
controller: _scrollController,
itemBuilder: (BuildContext context, int index) {
_scrollController
.jumpTo(_scrollController.position.maxScrollExtent);
return StreamElementCard(
streamElement: streamElements[index]);
},

View file

@ -0,0 +1,59 @@
import 'package:flutter/material.dart';
import 'package:enough_mail/enough_mail.dart';
class MailBoxSelect extends StatefulWidget {
static Future<Mailbox?> show(BuildContext context,
{required List<Mailbox> mailboxes}) async {
return await showDialog<Mailbox>(
context: context,
builder: (context) => MailBoxSelect(mailBoxes: mailboxes),
);
}
const MailBoxSelect({Key? key, required this.mailBoxes}) : super(key: key);
final List<Mailbox> mailBoxes;
@override
_MailBoxSelectState createState() => _MailBoxSelectState();
}
class _MailBoxSelectState extends State<MailBoxSelect> {
Mailbox? _selectedMailbox;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Boîte de réception'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
DropdownButton<Mailbox>(
value: _selectedMailbox,
items: widget.mailBoxes.map((Mailbox mailBox) {
return DropdownMenuItem<Mailbox>(
value: mailBox,
child: Text(mailBox.name),
);
}).toList(),
onChanged: (Mailbox? value) {
if (value != null) {
setState(() => _selectedMailbox = value);
}
}),
TextButton(
onPressed: _selectedMailbox == null
? null
: () {
Navigator.pop(context, _selectedMailbox!);
},
child: const Text('Valider'))
],
),
),
);
}
}