-
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.
- Loading branch information
1 parent
8643c5e
commit 60926a6
Showing
14 changed files
with
905 additions
and
186 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,59 @@ | ||
|
||
import 'package:adaptive_theme/adaptive_theme.dart'; | ||
import 'package:chat_all/config/prompts.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class RoleHome extends StatelessWidget { | ||
final Function(String prompt) setPrompt; | ||
const RoleHome({super.key,required this.setPrompt}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
|
||
return ListView.builder( | ||
itemBuilder: (context, index) => GestureDetector( | ||
onTap: (){ | ||
setPrompt(promptsCN[index]['prompt']!); | ||
}, | ||
child: Container( | ||
decoration: BoxDecoration( | ||
borderRadius: BorderRadius.circular(15), | ||
border: Border.all(color: Colors.grey), | ||
), | ||
padding: const EdgeInsets.all(5), | ||
margin: const EdgeInsets.only(left: 10, right: 10, top: 5, bottom: 5), | ||
child: Row( | ||
children: [ | ||
emojis[index], | ||
const SizedBox(width: 10,), | ||
Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
SizedBox( | ||
width: 260, | ||
child: Text( | ||
promptsCN[index]["act"]!, | ||
style: AdaptiveTheme.of(context).theme.textTheme.titleLarge, | ||
overflow: TextOverflow.ellipsis, | ||
), | ||
), | ||
// Text("你好") | ||
SizedBox( | ||
width: 260, | ||
child: Text( | ||
promptsCN[index]['prompt']!, | ||
style: | ||
AdaptiveTheme.of(context).theme.textTheme.titleMedium, | ||
overflow: TextOverflow.ellipsis, | ||
)) | ||
], | ||
) | ||
], | ||
), | ||
), | ||
), | ||
itemCount: promptsCN.length, | ||
); | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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,49 @@ | ||
import 'dart:developer'; | ||
|
||
import 'package:adaptive_theme/adaptive_theme.dart'; | ||
import 'package:chat_all/component/role_home.dart'; | ||
import 'package:chat_all/model/message.dart'; | ||
import 'package:dart_openai/dart_openai.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:get/get.dart'; | ||
|
||
import '../controller/chat.dart'; | ||
import '../controller/sidebar.dart'; | ||
|
||
class RolesPage extends StatefulWidget { | ||
const RolesPage({super.key}); | ||
|
||
@override | ||
State<StatefulWidget> createState() => _RolesPageState(); | ||
|
||
} | ||
|
||
class _RolesPageState extends State<RolesPage>{ | ||
final _sidebarController = Get.find<SidebarPageController>(); | ||
final _chatController = Get.find<ChatPageController>(); | ||
|
||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
|
||
appBar: AppBar( | ||
title: const Text("角色列表"), | ||
centerTitle: true, | ||
backgroundColor: AdaptiveTheme.of(context).theme.primaryColor, | ||
), | ||
body: RoleHome(setPrompt: setPrompt,), | ||
); | ||
} | ||
|
||
void setPrompt(String prompt){ | ||
|
||
_sidebarController.newHistory(); | ||
_chatController.reloadHistory(); | ||
_chatController.currHistoryMessage.messages.add( | ||
Message(content: prompt, role: OpenAIChatMessageRole.system, historyId: _chatController.currHistoryMessage.id) | ||
); | ||
Get.toNamed("/chat"); | ||
} | ||
|
||
} |
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
Oops, something went wrong.