add the compose widget to sidebar
This commit is contained in:
parent
214a60ce1b
commit
c025fbe07a
@ -5,6 +5,7 @@ import 'structs.dart';
|
||||
import 'api_service.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'email.dart';
|
||||
import 'Compose.dart';
|
||||
|
||||
class HomeScreen extends StatefulWidget {
|
||||
@override
|
||||
@ -44,49 +45,50 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
||||
});
|
||||
}
|
||||
|
||||
void _showOptionsSearchDialog () async {
|
||||
void _showOptionsSearchDialog() async {
|
||||
List<String> folders = await apiService.fetchFolders();
|
||||
|
||||
if (mounted) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('Choose an Option'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: folders.map((option) {
|
||||
return ListTile(
|
||||
title: Text(option),
|
||||
leading: Radio<String>(
|
||||
value: option,
|
||||
groupValue: _selectedOption, // Bind with _selectedOption
|
||||
onChanged: (String? value) {
|
||||
setState(() {
|
||||
_selectedOption = value;
|
||||
});
|
||||
Navigator.of(context).pop(); // Close the dialog on selection
|
||||
},
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
actions: <Widget>[
|
||||
ElevatedButton(
|
||||
child: Text('Submit'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(); // Close the dialog
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text('You selected: $_selectedOption'),
|
||||
));
|
||||
},
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('Choose an Option'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: folders.map((option) {
|
||||
return ListTile(
|
||||
title: Text(option),
|
||||
leading: Radio<String>(
|
||||
value: option,
|
||||
groupValue: _selectedOption, // Bind with _selectedOption
|
||||
onChanged: (String? value) {
|
||||
setState(() {
|
||||
_selectedOption = value;
|
||||
});
|
||||
Navigator.of(context)
|
||||
.pop(); // Close the dialog on selection
|
||||
},
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);}
|
||||
actions: <Widget>[
|
||||
ElevatedButton(
|
||||
child: Text('Submit'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(); // Close the dialog
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text('You selected: $_selectedOption'),
|
||||
));
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Remove a tab
|
||||
void _removeTab(int index) {
|
||||
@ -119,7 +121,7 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
||||
body: ListView.separated(
|
||||
itemCount: result.length,
|
||||
itemBuilder: (context, index) {
|
||||
final SerializableMessage email = result[index];
|
||||
final SerializableMessage email = result[index];
|
||||
return ListTile(
|
||||
title: Text(email.from,
|
||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
@ -132,27 +134,24 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
||||
// print('tapped');
|
||||
// List<String> emailContent =
|
||||
// await apiService.fetchEmailContent([email.id], email.list);
|
||||
//call the foldable
|
||||
|
||||
//call the foldable
|
||||
|
||||
List<String> emailContent = // list of the html
|
||||
await apiService.fetchEmailContent([email.id], email.list);
|
||||
await apiService
|
||||
.fetchEmailContent([email.id], email.list);
|
||||
// List<String> emailIds = email.messages;
|
||||
|
||||
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>SonicEmailView(
|
||||
email: email,
|
||||
emailHTML: emailContent[0])
|
||||
),
|
||||
builder: (context) => SonicEmailView(
|
||||
email: email, emailHTML: emailContent[0])),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) => Divider(),
|
||||
),
|
||||
|
||||
);
|
||||
}
|
||||
},
|
||||
@ -170,7 +169,7 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
||||
return Scaffold(
|
||||
backgroundColor: Theme.of(context).colorScheme.onPrimary,
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 20, 0 , 20),
|
||||
padding: const EdgeInsets.fromLTRB(0, 20, 0, 20),
|
||||
child: Scaffold(
|
||||
key: _scaffoldKey,
|
||||
drawer: FolderDrawer(
|
||||
@ -195,6 +194,12 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ListTile(
|
||||
leading: Icon(Icons.edit_note_sharp),
|
||||
onTap: () {
|
||||
OverlayService()
|
||||
.showPersistentWidget(context);
|
||||
}),
|
||||
ListTile(
|
||||
leading: Icon(Icons.home),
|
||||
onTap: () {
|
||||
@ -219,7 +224,8 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
||||
child: Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: IconButton(
|
||||
icon: Icon(Icons.close, color: Colors.white),
|
||||
icon:
|
||||
Icon(Icons.close, color: Colors.white),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isSidebarOpen = false;
|
||||
@ -256,7 +262,8 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
||||
),
|
||||
onSubmitted: (value) {
|
||||
if (value.isNotEmpty) {
|
||||
_performSearch(value, _selectedOption);
|
||||
_performSearch(
|
||||
value, _selectedOption);
|
||||
}
|
||||
//this is the input box i mentioned
|
||||
// if (value == '') {
|
||||
@ -314,8 +321,10 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
||||
Text(entry.value),
|
||||
if (entry.value != 'Emails')
|
||||
GestureDetector(
|
||||
onTap: () => _removeTab(entry.key),
|
||||
child: Icon(Icons.close, size: 16),
|
||||
onTap: () =>
|
||||
_removeTab(entry.key),
|
||||
child: Icon(Icons.close,
|
||||
size: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -333,23 +342,28 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
_emailPageKey.currentState!.isBackDisabled ? null: _emailPageKey.currentState
|
||||
?.updatePagenation('back');
|
||||
_emailPageKey.currentState!.isBackDisabled
|
||||
? null
|
||||
: _emailPageKey.currentState
|
||||
?.updatePagenation('back');
|
||||
},
|
||||
child: Icon(Icons.navigate_before),
|
||||
),
|
||||
Builder(
|
||||
builder: (context) {
|
||||
final emailState = _emailPageKey.currentState;
|
||||
final emailState =
|
||||
_emailPageKey.currentState;
|
||||
if (emailState == null) {
|
||||
// Schedule a rebuild once the state is available
|
||||
Future.microtask(() => setState(() {}));
|
||||
return Text('Loading...');
|
||||
}
|
||||
|
||||
|
||||
return ValueListenableBuilder<int>(
|
||||
valueListenable: emailState.currentPageNotifier,
|
||||
builder: (context, value, _) => Text('$value'),
|
||||
valueListenable:
|
||||
emailState.currentPageNotifier,
|
||||
builder: (context, value, _) =>
|
||||
Text('$value'),
|
||||
);
|
||||
},
|
||||
),
|
||||
@ -376,7 +390,7 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
// if (_tabs.isEmpty)
|
||||
// Expanded(
|
||||
// child: EmailPage(key: _emailPageKey),
|
||||
|
Loading…
Reference in New Issue
Block a user