-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from yihong1120/feature/dashboard-display
Feature/dashboard display
- Loading branch information
Showing
6 changed files
with
146 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class NavigationDrawer extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Drawer( | ||
child: ListView( | ||
padding: EdgeInsets.zero, | ||
children: <Widget>[ | ||
DrawerHeader( | ||
decoration: BoxDecoration( | ||
color: Colors.blue, | ||
), | ||
child: Text( | ||
'Navigation Menu', | ||
style: TextStyle( | ||
color: Colors.white, | ||
fontSize: 24, | ||
), | ||
), | ||
), | ||
ListTile( | ||
leading: Icon(Icons.home), | ||
title: Text('Home'), | ||
onTap: () => _navigateTo(context, '/'), // 导航到主页,根据实际路由调整 | ||
), | ||
ListTile( | ||
leading: Icon(Icons.bar_chart), | ||
title: Text('Reports'), | ||
onTap: () => _navigateTo(context, '/reports'), // 调整为实际报告页面的路由 | ||
), | ||
ListTile( | ||
leading: Icon(Icons.chat), | ||
title: Text('Chatbot'), | ||
onTap: () => _navigateTo(context, '/chat'), // 调整为实际聊天页面的路由 | ||
), | ||
ListTile( | ||
leading: Icon(Icons.account_circle), | ||
title: Text('Accounts'), | ||
onTap: () => _navigateTo(context, '/accounts'), // 调整为实际账户页面的路由 | ||
), | ||
], | ||
), | ||
); | ||
} | ||
|
||
void _navigateTo(BuildContext context, String route) { | ||
Navigator.pop(context); // 关闭抽屉 | ||
if (ModalRoute.of(context)?.settings.name != route) { | ||
Navigator.pushNamed(context, route); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:http/http.dart' as http; | ||
|
||
class ChatPage extends StatefulWidget { | ||
@override | ||
_ChatScreenState createState() => _ChatScreenState(); | ||
} | ||
|
||
class _ChatScreenState extends State<ChatScreen> { | ||
final TextEditingController _controller = TextEditingController(); | ||
String _response = ''; | ||
|
||
void _sendMessage() async { | ||
var response = await http.post( | ||
Uri.parse('YOUR_DJANGO_SERVER_URL/chat-with-gemini/'), | ||
headers: <String, String>{ | ||
'Content-Type': 'application/json; charset=UTF-8', | ||
}, | ||
body: <String, String>{ | ||
'message': _controller.text, | ||
}, | ||
); | ||
setState(() { | ||
_response = response.body; | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text('Chat with Gemini'), | ||
), | ||
body: Column( | ||
children: <Widget>[ | ||
Expanded( | ||
child: Text(_response), | ||
), | ||
TextField( | ||
controller: _controller, | ||
decoration: InputDecoration( | ||
labelText: 'Enter your message', | ||
), | ||
), | ||
ElevatedButton( | ||
onPressed: _sendMessage, | ||
child: Text('Send'), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'chat_page.dart'; | ||
|
||
Map<String, WidgetBuilder> chatRoutes = { | ||
'/chat': (context) => const ChatPage(), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters