|
@@ -9,16 +9,43 @@ class HomeScreen extends StatefulWidget {
|
|
_HomeScreenState createState() => _HomeScreenState();
|
|
_HomeScreenState createState() => _HomeScreenState();
|
|
}
|
|
}
|
|
|
|
|
|
-class _HomeScreenState extends State<HomeScreen> {
|
|
|
|
|
|
+class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin{
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
final GlobalKey<EmailPageState> _emailPageKey = GlobalKey<EmailPageState>();
|
|
final GlobalKey<EmailPageState> _emailPageKey = GlobalKey<EmailPageState>();
|
|
ApiService apiService = ApiService();
|
|
ApiService apiService = ApiService();
|
|
bool _isSidebarOpen = true;
|
|
bool _isSidebarOpen = true;
|
|
|
|
+ bool querySearches = false;
|
|
|
|
+
|
|
|
|
+ List<String> _tabs = ['INBOX', 'Search'];
|
|
|
|
+ TabController? _tabController;
|
|
|
|
|
|
@override
|
|
@override
|
|
void initState() {
|
|
void initState() {
|
|
super.initState();
|
|
super.initState();
|
|
|
|
+ _tabController = TabController(length: _tabs.length, vsync: this);
|
|
}
|
|
}
|
|
|
|
+ // Add a new tab based on the search
|
|
|
|
+ void _performSearch(String query) {
|
|
|
|
+ setState(() {
|
|
|
|
+ _tabs.add(query);
|
|
|
|
+ _tabController = TabController(length: _tabs.length, vsync: this);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Remove a tab
|
|
|
|
+ void _removeTab(int index) {
|
|
|
|
+ setState(() {
|
|
|
|
+ _tabs.removeAt(index);
|
|
|
|
+ _tabController = TabController(length: _tabs.length, vsync: this);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @override
|
|
|
|
+ void dispose() {
|
|
|
|
+ _tabController?.dispose();
|
|
|
|
+ super.dispose();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
@override
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
@@ -30,6 +57,31 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
_emailPageKey.currentState?.updateSelectedFolder(folder);
|
|
_emailPageKey.currentState?.updateSelectedFolder(folder);
|
|
},
|
|
},
|
|
),
|
|
),
|
|
|
|
+ // appBar: AppBar(
|
|
|
|
+ // title: Text('Search with Tabs'),
|
|
|
|
+ // bottom: _tabs.isNotEmpty
|
|
|
|
+ // ? TabBar(
|
|
|
|
+ // controller: _tabController,
|
|
|
|
+ // isScrollable: true,
|
|
|
|
+ // tabs: _tabs
|
|
|
|
+ // .asMap()
|
|
|
|
+ // .entries
|
|
|
|
+ // .map((entry) => Tab(
|
|
|
|
+ // child: Row(
|
|
|
|
+ // children: [
|
|
|
|
+ // Text(entry.value),
|
|
|
|
+ // SizedBox(width: 8),
|
|
|
|
+ // GestureDetector(
|
|
|
|
+ // onTap: () => _removeTab(entry.key),
|
|
|
|
+ // child: Icon(Icons.close, size: 16),
|
|
|
|
+ // ),
|
|
|
|
+ // ],
|
|
|
|
+ // ),
|
|
|
|
+ // ))
|
|
|
|
+ // .toList(),
|
|
|
|
+ // )
|
|
|
|
+ // : null,
|
|
|
|
+ // ),
|
|
body: Stack(
|
|
body: Stack(
|
|
children: [
|
|
children: [
|
|
Row(
|
|
Row(
|
|
@@ -97,6 +149,25 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
border: OutlineInputBorder(),
|
|
border: OutlineInputBorder(),
|
|
prefixIcon: Icon(Icons.search),
|
|
prefixIcon: Icon(Icons.search),
|
|
),
|
|
),
|
|
|
|
+ onSubmitted: (value) {
|
|
|
|
+ if (value.isNotEmpty) {
|
|
|
|
+ _performSearch(value);
|
|
|
|
+ }
|
|
|
|
+ //this is the input box i mentioned
|
|
|
|
+ // if (value == '') {
|
|
|
|
+ // setState(() {
|
|
|
|
+ // querySearches = false;
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
|
|
+ // Future<List<String>> results = apiService
|
|
|
|
+ // .sonicSearch('INBOX', 20, 0, value);
|
|
|
|
+ // // print(value);
|
|
|
|
+ // print(results);
|
|
|
|
+ // setState(() {
|
|
|
|
+ // querySearches = true;
|
|
|
|
+ // });
|
|
|
|
+
|
|
|
|
+ },
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
],
|
|
@@ -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(
|
|
Container(
|
|
// alignment: Alignment.topLeft,
|
|
// alignment: Alignment.topLeft,
|
|
padding: EdgeInsets.all(8.0),
|
|
padding: EdgeInsets.all(8.0),
|
|
@@ -134,12 +230,33 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
},
|
|
},
|
|
child: Icon(Icons.navigate_next),
|
|
child: Icon(Icons.navigate_next),
|
|
),
|
|
),
|
|
|
|
+
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
Expanded(
|
|
- child: EmailPage(key: _emailPageKey),
|
|
|
|
- )
|
|
|
|
|
|
+ child: TabBarView(
|
|
|
|
+ controller: _tabController,
|
|
|
|
+ children: _tabs.map((tab) {
|
|
|
|
+ return Center(child: EmailPage(key: _emailPageKey,));
|
|
|
|
+ }).toList(),
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ // if (_tabs.isEmpty)
|
|
|
|
+ // Expanded(
|
|
|
|
+ // child: EmailPage(key: _emailPageKey),
|
|
|
|
+ // ),
|
|
|
|
+ // if (_tabs.isNotEmpty)
|
|
|
|
+ // Expanded(
|
|
|
|
+ // // child: Text('supposed to be mails'),
|
|
|
|
+ // child: TabBarView(
|
|
|
|
+ // controller: _tabController,
|
|
|
|
+ // children: _tabs
|
|
|
|
+ // .map((tab) => Center(child: Text('Results for $tab')))
|
|
|
|
+ // .toList(),
|
|
|
|
+ // ),
|
|
|
|
+ // ),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
@@ -162,7 +279,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
),
|
|
),
|
|
);
|
|
);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+}
|
|
// void _showPopupMenu(BuildContext context, Offset position) async {
|
|
// void _showPopupMenu(BuildContext context, Offset position) async {
|
|
// final RenderBox overlay =
|
|
// final RenderBox overlay =
|
|
// Overlay.of(context).context.findRenderObject() as RenderBox;
|
|
// Overlay.of(context).context.findRenderObject() as RenderBox;
|