UI调整,签名

This commit is contained in:
18631081161 2024-06-18 00:05:22 +08:00
parent ee6b25f9b6
commit d3113a5e64
9 changed files with 107 additions and 94 deletions

BIN
android/app/ChatApp.jks Normal file

Binary file not shown.

View File

@ -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
}
}
}

View File

@ -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"

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

BIN
assets/images/avatar1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 KiB

BIN
assets/images/avatar2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 KiB

View File

@ -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) {

View File

@ -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'),
),
),
),
],
),

View File

@ -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