UI调整,签名
This commit is contained in:
parent
ee6b25f9b6
commit
d3113a5e64
BIN
android/app/ChatApp.jks
Normal file
BIN
android/app/ChatApp.jks
Normal file
Binary file not shown.
|
|
@ -28,6 +28,16 @@ android {
|
|||
compileSdk = flutter.compileSdkVersion
|
||||
ndkVersion = flutter.ndkVersion
|
||||
|
||||
signingConfigs {
|
||||
//签名的配置
|
||||
signConfig {
|
||||
storeFile file("ChatApp.jks")
|
||||
storePassword '123456'
|
||||
keyAlias 'ChatApp'
|
||||
keyPassword '123456'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
|
@ -47,8 +57,14 @@ android {
|
|||
buildTypes {
|
||||
release {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
signingConfig = signingConfigs.debug
|
||||
signingConfig signingConfigs.signConfig //打包命令行:gradlew assembleRelease
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
//关闭混淆
|
||||
minifyEnabled false //删除无用代码
|
||||
shrinkResources false //删除无用资源
|
||||
}
|
||||
debug {
|
||||
signingConfig signingConfigs.signConfig
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:label="Chat"
|
||||
android:name="${applicationName}"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
android:icon="@mipmap/ic_logo">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
|
|
|
|||
BIN
android/app/src/main/res/mipmap-xxhdpi/ic_logo.png
Normal file
BIN
android/app/src/main/res/mipmap-xxhdpi/ic_logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 86 KiB |
BIN
assets/images/avatar1.png
Normal file
BIN
assets/images/avatar1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 278 KiB |
BIN
assets/images/avatar2.png
Normal file
BIN
assets/images/avatar2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 286 KiB |
|
|
@ -25,9 +25,7 @@ class HomeModel {
|
|||
var nowTime = DateTime.now(); //获取当前时间
|
||||
var nTime = nowTime.millisecondsSinceEpoch; //单位是毫秒(千分之一秒),13位时间戳
|
||||
RequestCenter.instance.request(NetworkConfig.chat, {
|
||||
"messages": [
|
||||
{"role": "user", "content": message}
|
||||
],
|
||||
"messages": [{"role": "user", "content": message}],
|
||||
"mode": "chat",
|
||||
"character": character
|
||||
}, (BaseEntity dataEntity) {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
|
||||
import 'HomeModel.dart';
|
||||
|
||||
import 'Message.dart';
|
||||
|
||||
class Homepage extends StatefulWidget {
|
||||
|
|
@ -18,21 +16,28 @@ class Homepage extends StatefulWidget {
|
|||
class _HomepageState extends State<Homepage> {
|
||||
late StreamSubscription subscription;
|
||||
final HomeModel viewModel = HomeModel();
|
||||
final TextEditingController _controller1 = TextEditingController();
|
||||
final TextEditingController _chatController = TextEditingController();
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
String text = "";
|
||||
String data = '';
|
||||
List<Message> list = [];
|
||||
|
||||
Future<void> chat() async {
|
||||
viewModel.chat(text,'Assistant');
|
||||
EasyLoading.show(status: 'loading...');
|
||||
viewModel.chat(text, 'Assistant');
|
||||
}
|
||||
|
||||
void _textFieldChanged(String str) {
|
||||
text = str;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
// 监听输入变化
|
||||
_controller1.addListener(() {
|
||||
print(_controller1.text);
|
||||
_chatController.addListener(() {
|
||||
print(_chatController.text);
|
||||
});
|
||||
|
||||
subscription = viewModel.streamController.stream.listen((newData) {
|
||||
|
|
@ -41,30 +46,29 @@ class _HomepageState extends State<Homepage> {
|
|||
if (code == "chat") {
|
||||
//有数据
|
||||
data = newData['data'];
|
||||
|
||||
setState(() {
|
||||
|
||||
list.add(Message(data, false));
|
||||
setState(() {});
|
||||
Future.delayed(Duration(milliseconds: 500), () {
|
||||
_scrollController.jumpTo(_scrollController.position.maxScrollExtent);
|
||||
});
|
||||
//EasyLoading.showToast(data);
|
||||
print("data" + data.toString());
|
||||
}
|
||||
EasyLoading.dismiss();
|
||||
} else {
|
||||
EasyLoading.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
void _textFieldChanged1(String str) {
|
||||
text = str;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
_chatController.dispose();
|
||||
subscription.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
|
@ -90,6 +94,7 @@ class _HomepageState extends State<Homepage> {
|
|||
alignment: Alignment.topCenter,
|
||||
child: ListView.builder(
|
||||
// reverse: true,
|
||||
controller: _scrollController,
|
||||
itemCount: list.length,
|
||||
itemBuilder: (Context, index) {
|
||||
return _item(index);
|
||||
|
|
@ -107,6 +112,7 @@ class _HomepageState extends State<Homepage> {
|
|||
margin: EdgeInsets.only(left: 16),
|
||||
child: TextField(
|
||||
controller: _chatController,
|
||||
onChanged: _textFieldChanged,
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none, // 移除非聚焦状态下的边框
|
||||
enabledBorder: InputBorder.none, // 移除获得焦点但未输入内容时的边框
|
||||
|
|
@ -117,16 +123,20 @@ class _HomepageState extends State<Homepage> {
|
|||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
list.add(Message(chatText, true));
|
||||
chat();
|
||||
list.add(Message(text, true));
|
||||
_chatController.clear();
|
||||
Future.delayed(Duration(milliseconds: 200), () {
|
||||
_scrollController.jumpTo(_scrollController.position.maxScrollExtent);
|
||||
});
|
||||
setState(() {});
|
||||
},
|
||||
child: Container(
|
||||
width: 70,
|
||||
height: 50,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFF006CFF), borderRadius: BorderRadius.all(Radius.circular(8.0))),
|
||||
decoration:
|
||||
BoxDecoration(color: Color(0xFF006CFF), borderRadius: BorderRadius.all(Radius.circular(8.0))),
|
||||
child: Text(
|
||||
"发送",
|
||||
style: TextStyle(color: Colors.white),
|
||||
|
|
@ -148,14 +158,25 @@ class _HomepageState extends State<Homepage> {
|
|||
child: !list[index].isMe
|
||||
? Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: 45,
|
||||
height: 45,
|
||||
color: Color(0xFFD8D8D8),
|
||||
margin: EdgeInsets.only(left: 16),
|
||||
margin: EdgeInsets.only(left: 16, top: 4),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Image(
|
||||
fit: BoxFit.cover,
|
||||
image: AssetImage('assets/images/avatar2.png'),
|
||||
),
|
||||
Container(
|
||||
),
|
||||
),
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: MediaQuery.of(context).size.width - 150, // 确保不超过屏幕宽度
|
||||
),
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 4.0),
|
||||
padding: EdgeInsets.all(12.0),
|
||||
decoration: BoxDecoration(
|
||||
|
|
@ -170,12 +191,18 @@ class _HomepageState extends State<Homepage> {
|
|||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: MediaQuery.of(context).size.width - 150, // 确保不超过屏幕宽度
|
||||
),
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 4.0),
|
||||
padding: EdgeInsets.all(12.0),
|
||||
decoration: BoxDecoration(
|
||||
|
|
@ -190,11 +217,18 @@ class _HomepageState extends State<Homepage> {
|
|||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 45,
|
||||
height: 45,
|
||||
color: Color(0xFFD8D8D8),
|
||||
margin: EdgeInsets.only(right: 16),
|
||||
margin: EdgeInsets.only(right: 16, top: 4),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Image(
|
||||
fit: BoxFit.cover,
|
||||
image: AssetImage('assets/images/avatar1.png'),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
44
pubspec.yaml
44
pubspec.yaml
|
|
@ -42,53 +42,15 @@ dev_dependencies:
|
|||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
# The "flutter_lints" package below contains a set of recommended lints to
|
||||
# encourage good coding practices. The lint set provided by the package is
|
||||
# activated in the `analysis_options.yaml` file located at the root of your
|
||||
# package. See that file for information about deactivating specific lint
|
||||
# rules and activating additional ones.
|
||||
flutter_lints: ^3.0.0
|
||||
build_runner: ^2.4.11
|
||||
json_serializable: ^6.8.0
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
||||
# The following section is specific to Flutter packages.
|
||||
flutter:
|
||||
|
||||
# The following line ensures that the Material Icons font is
|
||||
# included with your application, so that you can use the icons in
|
||||
# the material Icons class.
|
||||
uses-material-design: true
|
||||
assets:
|
||||
- assets/
|
||||
- assets/images/
|
||||
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
# assets:
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.dev/assets-and-images/#resolution-aware
|
||||
|
||||
# For details regarding adding assets from package dependencies, see
|
||||
# https://flutter.dev/assets-and-images/#from-packages
|
||||
|
||||
# To add custom fonts to your application, add a fonts section here,
|
||||
# in this "flutter" section. Each entry in this list should have a
|
||||
# "family" key with the font family name, and a "fonts" key with a
|
||||
# list giving the asset and other descriptors for the font. For
|
||||
# example:
|
||||
# fonts:
|
||||
# - family: Schyler
|
||||
# fonts:
|
||||
# - asset: fonts/Schyler-Regular.ttf
|
||||
# - asset: fonts/Schyler-Italic.ttf
|
||||
# style: italic
|
||||
# - family: Trajan Pro
|
||||
# fonts:
|
||||
# - asset: fonts/TrajanPro.ttf
|
||||
# - asset: fonts/TrajanPro_Bold.ttf
|
||||
# weight: 700
|
||||
#
|
||||
# For details regarding fonts from package dependencies,
|
||||
# see https://flutter.dev/custom-fonts/#from-packages
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user