|
@@ -36,7 +36,8 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
|
setState(() {
|
|
setState(() {
|
|
if (!_tabs.contains(query)) {
|
|
if (!_tabs.contains(query)) {
|
|
_tabs.add(query);
|
|
_tabs.add(query);
|
|
- _tabWidgets[query] = _buildSearchResultsWidget(query); // Store a different widget for this tab
|
|
|
|
|
|
+ _tabWidgets[query] = _buildSearchResultsWidget(
|
|
|
|
+ query); // Store a different widget for this tab
|
|
_tabController = TabController(length: _tabs.length, vsync: this);
|
|
_tabController = TabController(length: _tabs.length, vsync: this);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -72,76 +73,80 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
|
// ),
|
|
// ),
|
|
// );
|
|
// );
|
|
return FutureBuilder<List<SerializableMessage>>(
|
|
return FutureBuilder<List<SerializableMessage>>(
|
|
- future: apiService.sonicSearch("INBOX", 10, 0, query),
|
|
|
|
- builder: (BuildContext context, AsyncSnapshot<List<SerializableMessage>> snapshot) {
|
|
|
|
- if (snapshot.connectionState == ConnectionState.waiting) {
|
|
|
|
- return Center(child: CircularProgressIndicator());
|
|
|
|
- } else if (snapshot.hasError) {
|
|
|
|
- return Center(child: Text('Error: ${snapshot.error}'));
|
|
|
|
- } else if (!snapshot.hasData || snapshot.data!.isEmpty) {
|
|
|
|
- return Center(child: Text('No results found for: $query'));
|
|
|
|
- } else {
|
|
|
|
- List<SerializableMessage> result = snapshot.data!;
|
|
|
|
- return Scaffold(
|
|
|
|
- body: ListView.separated(
|
|
|
|
- itemCount: result.length,
|
|
|
|
- itemBuilder: (context, index){
|
|
|
|
- final email = result[index];
|
|
|
|
- return ListTile(
|
|
|
|
- title: Text(email.from,
|
|
|
|
- style: TextStyle(fontWeight: FontWeight.bold)),
|
|
|
|
- subtitle: Column(
|
|
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
- children: [Text(email.subject)],
|
|
|
|
- ),
|
|
|
|
- trailing: Text(email.date.toString()),
|
|
|
|
- onTap: () async {
|
|
|
|
- String emailContent = await apiService.fetchEmailContent(email.id as List<String>);
|
|
|
|
- Navigator.push(
|
|
|
|
- context,
|
|
|
|
- MaterialPageRoute(
|
|
|
|
- builder: (context) => EmailView(
|
|
|
|
- emailContent: emailContent,
|
|
|
|
- from: email.from,
|
|
|
|
- name: email.name,
|
|
|
|
- to: email.to.toString(),
|
|
|
|
- subject: email.subject,
|
|
|
|
- date: email.date.toString(),
|
|
|
|
- id: email.id.toString(),
|
|
|
|
- ),
|
|
|
|
|
|
+ future: apiService.sonicSearch("INBOX", 10, 0, query),
|
|
|
|
+ builder: (BuildContext context,
|
|
|
|
+ AsyncSnapshot<List<SerializableMessage>> snapshot) {
|
|
|
|
+ if (snapshot.connectionState == ConnectionState.waiting) {
|
|
|
|
+ return Center(child: CircularProgressIndicator());
|
|
|
|
+ } else if (snapshot.hasError) {
|
|
|
|
+ return Center(child: Text('Error: ${snapshot.error}'));
|
|
|
|
+ } else if (!snapshot.hasData || snapshot.data!.isEmpty) {
|
|
|
|
+ return Center(child: Text('No results found for: $query'));
|
|
|
|
+ } else {
|
|
|
|
+ List<SerializableMessage> result = snapshot.data!;
|
|
|
|
+ return Scaffold(
|
|
|
|
+ body: ListView.separated(
|
|
|
|
+ itemCount: result.length,
|
|
|
|
+ itemBuilder: (context, index) {
|
|
|
|
+ final email = result[index];
|
|
|
|
+ return ListTile(
|
|
|
|
+ title: Text(email.from,
|
|
|
|
+ style: TextStyle(fontWeight: FontWeight.bold)),
|
|
|
|
+ subtitle: Column(
|
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
+ children: [Text(email.subject)],
|
|
),
|
|
),
|
|
|
|
+ trailing: Text(email.date.toString()),
|
|
|
|
+ onTap: () async {
|
|
|
|
+ print('tapped');
|
|
|
|
+ String emailContent = await apiService
|
|
|
|
+ .fetchEmailContent([email.id]);
|
|
|
|
+ print('content below');
|
|
|
|
+ print(emailContent);
|
|
|
|
+ Navigator.push(
|
|
|
|
+ context,
|
|
|
|
+ MaterialPageRoute(
|
|
|
|
+ builder: (context) => EmailView(
|
|
|
|
+ emailContent: emailContent,
|
|
|
|
+ from: email.from,
|
|
|
|
+ name: email.name,
|
|
|
|
+ to: email.to.toString(),
|
|
|
|
+ subject: email.subject,
|
|
|
|
+ date: email.date.toString(),
|
|
|
|
+ id: email.id.toString(),
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
|
|
+ );
|
|
|
|
+ },
|
|
);
|
|
);
|
|
},
|
|
},
|
|
- );
|
|
|
|
- },
|
|
|
|
separatorBuilder: (context, index) => Divider(),
|
|
separatorBuilder: (context, index) => Divider(),
|
|
),
|
|
),
|
|
- // child: Column(
|
|
|
|
- // mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
- // children: [
|
|
|
|
- // Text("Results for: $query", style: TextStyle(fontSize: 24)),
|
|
|
|
- // // Display the actual data
|
|
|
|
- // Text(result[0].name), // Accessing the first result safely
|
|
|
|
- // Text(result[0].from), // Displaying the 'from' field as an example
|
|
|
|
- // Text(result[0].hash),
|
|
|
|
- // Text(result[0].subject),
|
|
|
|
- // Text(result[0].uid.toString()),
|
|
|
|
- // Text(result[0].list),
|
|
|
|
- // Text(result[0].id),
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // // Add more fields or customize the display
|
|
|
|
- // // SerializableEmailListScreen(emails: result, getEmailContent: getEmailContent)
|
|
|
|
- // // Expanded(
|
|
|
|
|
|
+ // child: Column(
|
|
|
|
+ // mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
+ // children: [
|
|
|
|
+ // Text("Results for: $query", style: TextStyle(fontSize: 24)),
|
|
|
|
+ // // Display the actual data
|
|
|
|
+ // Text(result[0].name), // Accessing the first result safely
|
|
|
|
+ // Text(result[0].from), // Displaying the 'from' field as an example
|
|
|
|
+ // Text(result[0].hash),
|
|
|
|
+ // Text(result[0].subject),
|
|
|
|
+ // Text(result[0].uid.toString()),
|
|
|
|
+ // Text(result[0].list),
|
|
|
|
+ // Text(result[0].id),
|
|
|
|
|
|
- // // child:
|
|
|
|
- // // ),
|
|
|
|
|
|
+ // // Add more fields or customize the display
|
|
|
|
+ // // SerializableEmailListScreen(emails: result, getEmailContent: getEmailContent)
|
|
|
|
+ // // Expanded(
|
|
|
|
+
|
|
|
|
+ // // child:
|
|
|
|
+ // // ),
|
|
// ],
|
|
// ],
|
|
);
|
|
);
|
|
- // );
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- );
|
|
|
|
|
|
+ // );
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ );
|
|
}
|
|
}
|
|
|
|
|
|
@override
|
|
@override
|
|
@@ -160,7 +165,6 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
|
_emailPageKey.currentState?.updateSelectedFolder(folder);
|
|
_emailPageKey.currentState?.updateSelectedFolder(folder);
|
|
},
|
|
},
|
|
),
|
|
),
|
|
-
|
|
|
|
body: Stack(
|
|
body: Stack(
|
|
children: [
|
|
children: [
|
|
Row(
|
|
Row(
|
|
@@ -316,7 +320,7 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
|
controller: _tabController,
|
|
controller: _tabController,
|
|
children: _tabs.map((tab) {
|
|
children: _tabs.map((tab) {
|
|
return _tabWidgets[tab] ??
|
|
return _tabWidgets[tab] ??
|
|
- Center(child: Text("No content found"));
|
|
|
|
|
|
+ Center(child: Text("No content found"));
|
|
// return Center(
|
|
// return Center(
|
|
// child: EmailPage(
|
|
// child: EmailPage(
|
|
// key: _emailPageKey,
|
|
// key: _emailPageKey,
|