|
@@ -9,16 +9,43 @@ class HomeScreen extends StatefulWidget {
|
|
|
_HomeScreenState createState() => _HomeScreenState();
|
|
|
}
|
|
|
|
|
|
-class _HomeScreenState extends State<HomeScreen> {
|
|
|
+class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin{
|
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
final GlobalKey<EmailPageState> _emailPageKey = GlobalKey<EmailPageState>();
|
|
|
ApiService apiService = ApiService();
|
|
|
bool _isSidebarOpen = true;
|
|
|
+ bool querySearches = false;
|
|
|
+
|
|
|
+ List<String> _tabs = ['INBOX', 'Search'];
|
|
|
+ TabController? _tabController;
|
|
|
|
|
|
@override
|
|
|
void initState() {
|
|
|
super.initState();
|
|
|
+ _tabController = TabController(length: _tabs.length, vsync: this);
|
|
|
}
|
|
|
+
|
|
|
+ void _performSearch(String query) {
|
|
|
+ setState(() {
|
|
|
+ _tabs.add(query);
|
|
|
+ _tabController = TabController(length: _tabs.length, vsync: this);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ void _removeTab(int index) {
|
|
|
+ setState(() {
|
|
|
+ _tabs.removeAt(index);
|
|
|
+ _tabController = TabController(length: _tabs.length, vsync: this);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ void dispose() {
|
|
|
+ _tabController?.dispose();
|
|
|
+ super.dispose();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
@@ -30,6 +57,31 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
|
_emailPageKey.currentState?.updateSelectedFolder(folder);
|
|
|
},
|
|
|
),
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
body: Stack(
|
|
|
children: [
|
|
|
Row(
|
|
@@ -97,6 +149,25 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
|
border: OutlineInputBorder(),
|
|
|
prefixIcon: Icon(Icons.search),
|
|
|
),
|
|
|
+ onSubmitted: (value) {
|
|
|
+ if (value.isNotEmpty) {
|
|
|
+ _performSearch(value);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
),
|
|
|
),
|
|
|
],
|
|
@@ -113,6 +184,31 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
|
],
|
|
|
),
|
|
|
),
|
|
|
+ Container(
|
|
|
+ color: Color.fromARGB(255, 131, 110, 143),
|
|
|
+ child: TabBar(
|
|
|
+ controller: _tabController,
|
|
|
+ isScrollable: true,
|
|
|
+ tabs: _tabs
|
|
|
+ .asMap()
|
|
|
+ .entries
|
|
|
+ .map((entry) => Tab(
|
|
|
+ child: Row(
|
|
|
+ children: [
|
|
|
+ Text(entry.value),
|
|
|
+ if (entry.value != 'INBOX')
|
|
|
+ GestureDetector(
|
|
|
+ onTap: () => _removeTab(entry.key),
|
|
|
+ child: Icon(Icons.close, size: 16),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ))
|
|
|
+ .toList(),
|
|
|
+ labelColor: Colors.white,
|
|
|
+ indicatorColor: Colors.white,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
Container(
|
|
|
|
|
|
padding: EdgeInsets.all(8.0),
|
|
@@ -134,12 +230,33 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
|
},
|
|
|
child: Icon(Icons.navigate_next),
|
|
|
),
|
|
|
+
|
|
|
],
|
|
|
),
|
|
|
),
|
|
|
Expanded(
|
|
|
- child: EmailPage(key: _emailPageKey),
|
|
|
- )
|
|
|
+ child: TabBarView(
|
|
|
+ controller: _tabController,
|
|
|
+ children: _tabs.map((tab) {
|
|
|
+ return Center(child: EmailPage(key: _emailPageKey,));
|
|
|
+ }).toList(),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
],
|
|
|
),
|
|
|
),
|
|
@@ -162,7 +279,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
|
),
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
+}
|
|
|
|
|
|
|
|
|
|