Commit 405ae83f authored by 关振斌's avatar 关振斌

update uikit

parent adf14af8
...@@ -79,6 +79,8 @@ PODS: ...@@ -79,6 +79,8 @@ PODS:
- OrderedSet (~> 5.0) - OrderedSet (~> 5.0)
- flutter_keyboard_visibility (0.0.1): - flutter_keyboard_visibility (0.0.1):
- Flutter - Flutter
- flutter_tts (0.0.1):
- Flutter
- flutter_vibrate (0.0.1): - flutter_vibrate (0.0.1):
- Flutter - Flutter
- fluttercontactpicker (4.6.0): - fluttercontactpicker (4.6.0):
...@@ -156,6 +158,7 @@ DEPENDENCIES: ...@@ -156,6 +158,7 @@ DEPENDENCIES:
- flutter_inapp_purchase (from `.symlinks/plugins/flutter_inapp_purchase/ios`) - flutter_inapp_purchase (from `.symlinks/plugins/flutter_inapp_purchase/ios`)
- flutter_inappwebview (from `.symlinks/plugins/flutter_inappwebview/ios`) - flutter_inappwebview (from `.symlinks/plugins/flutter_inappwebview/ios`)
- flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`) - flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`)
- flutter_tts (from `.symlinks/plugins/flutter_tts/ios`)
- flutter_vibrate (from `.symlinks/plugins/flutter_vibrate/ios`) - flutter_vibrate (from `.symlinks/plugins/flutter_vibrate/ios`)
- fluttercontactpicker (from `.symlinks/plugins/fluttercontactpicker/ios`) - fluttercontactpicker (from `.symlinks/plugins/fluttercontactpicker/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
...@@ -216,6 +219,8 @@ EXTERNAL SOURCES: ...@@ -216,6 +219,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_inappwebview/ios" :path: ".symlinks/plugins/flutter_inappwebview/ios"
flutter_keyboard_visibility: flutter_keyboard_visibility:
:path: ".symlinks/plugins/flutter_keyboard_visibility/ios" :path: ".symlinks/plugins/flutter_keyboard_visibility/ios"
flutter_tts:
:path: ".symlinks/plugins/flutter_tts/ios"
flutter_vibrate: flutter_vibrate:
:path: ".symlinks/plugins/flutter_vibrate/ios" :path: ".symlinks/plugins/flutter_vibrate/ios"
fluttercontactpicker: fluttercontactpicker:
...@@ -268,6 +273,7 @@ SPEC CHECKSUMS: ...@@ -268,6 +273,7 @@ SPEC CHECKSUMS:
flutter_inapp_purchase: 5c6a1ac3f11b11d0c8c0321c0c41c1f05805e4c8 flutter_inapp_purchase: 5c6a1ac3f11b11d0c8c0321c0c41c1f05805e4c8
flutter_inappwebview: bfd58618f49dc62f2676de690fc6dcda1d6c3721 flutter_inappwebview: bfd58618f49dc62f2676de690fc6dcda1d6c3721
flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069 flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069
flutter_tts: 0f492aab6accf87059b72354fcb4ba934304771d
flutter_vibrate: 9f4c2ab57008965f78969472367c329dd77eb801 flutter_vibrate: 9f4c2ab57008965f78969472367c329dd77eb801
fluttercontactpicker: d582836dea6b5d489f3d259f35d7817ae82ee5e6 fluttercontactpicker: d582836dea6b5d489f3d259f35d7817ae82ee5e6
fluttertoast: eb263d302cc92e04176c053d2385237e9f43fad0 fluttertoast: eb263d302cc92e04176c053d2385237e9f43fad0
......
...@@ -361,16 +361,17 @@ ...@@ -361,16 +361,17 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = Z99J24WADU; DEVELOPMENT_TEAM = Z99J24WADU;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FLUTTER_BUILD_NAME = 1.0.1;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "AI写作大师"; INFOPLIST_KEY_CFBundleDisplayName = "AI写作大师";
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 4; MARKETING_VERSION = 5;
PRODUCT_BUNDLE_IDENTIFIER = com.wudi.app; PRODUCT_BUNDLE_IDENTIFIER = com.wudi.app;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
...@@ -493,16 +494,17 @@ ...@@ -493,16 +494,17 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/RunnerDebug.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/RunnerDebug.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = Z99J24WADU; DEVELOPMENT_TEAM = Z99J24WADU;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FLUTTER_BUILD_NAME = 1.0.1;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "AI写作大师"; INFOPLIST_KEY_CFBundleDisplayName = "AI写作大师";
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 4; MARKETING_VERSION = 5;
PRODUCT_BUNDLE_IDENTIFIER = com.wudi.app; PRODUCT_BUNDLE_IDENTIFIER = com.wudi.app;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
...@@ -519,16 +521,17 @@ ...@@ -519,16 +521,17 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = Z99J24WADU; DEVELOPMENT_TEAM = Z99J24WADU;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FLUTTER_BUILD_NAME = 1.0.1;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "AI写作大师"; INFOPLIST_KEY_CFBundleDisplayName = "AI写作大师";
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 4; MARKETING_VERSION = 5;
PRODUCT_BUNDLE_IDENTIFIER = com.wudi.app; PRODUCT_BUNDLE_IDENTIFIER = com.wudi.app;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
......
import 'package:chart/common/entities/detail.dart'; import 'package:chart/common/entities/detail.dart';
import 'package:chart/common/entities/entities.dart'; import 'package:chart/common/entities/entities.dart';
import 'package:chart/common/entities/scene.dart';
import 'package:chart/common/entities/selectAllEntity.dart'; import 'package:chart/common/entities/selectAllEntity.dart';
import 'package:chart/common/utils/utils.dart'; import 'package:chart/common/utils/utils.dart';
...@@ -70,6 +71,17 @@ class UserAPI { ...@@ -70,6 +71,17 @@ class UserAPI {
} }
} }
static Future<int> sceneConversion(Map<String, dynamic> parameters) async {
var response = await HttpUtil().post(
'/openAi/sceneConversion',
data: parameters,
);
return response['status'];
// return ApplePayEntity.fromMap(response['data']);
}
// /scene/sceneConversion
static Future<int> endConversion(Map<String, dynamic> parameters) async { static Future<int> endConversion(Map<String, dynamic> parameters) async {
var response = await HttpUtil().get( var response = await HttpUtil().get(
'/openAi/endConversion?conversionId=${parameters['conversionId']}', '/openAi/endConversion?conversionId=${parameters['conversionId']}',
...@@ -100,6 +112,19 @@ class UserAPI { ...@@ -100,6 +112,19 @@ class UserAPI {
// return ApplePayEntity.fromMap(response['data']); // return ApplePayEntity.fromMap(response['data']);
} }
//无上下文对话
static Future<int> aiAnswerWithoutSave(
Map<String, dynamic> parameters) async {
var response = await HttpUtil().post(
'/openAi/aiAnswerWithoutSave',
data: parameters,
);
return response['status'];
// return ApplePayEntity.fromMap(response['data']);
}
// /openAi/aiAnswerWithoutSave
//获取所有列表 //获取所有列表
static Future<SelectAllEntity> selectAll() async { static Future<SelectAllEntity> selectAll() async {
var response = await HttpUtil().get( var response = await HttpUtil().get(
...@@ -125,6 +150,28 @@ class UserAPI { ...@@ -125,6 +150,28 @@ class UserAPI {
// //
//home 重制回话
static Future<int> resetConversion() async {
var response = await HttpUtil().post(
'/openAi/resetConversion',
data: {},
);
return response['status'];
// return ApplePayEntity.fromMap(response['data']);
}
//home 保存问题
static Future<int> saveRespTemp(Map<String, dynamic> parameters) async {
var response = await HttpUtil().post(
'/openAi/saveRespTemp',
data: parameters,
);
return response['status'];
// return ApplePayEntity.fromMap(response['data']);
}
///api/ 保存问题 ///api/ 保存问题
static Future<int> saveResp(Map<String, dynamic> parameters) async { static Future<int> saveResp(Map<String, dynamic> parameters) async {
var response = await HttpUtil().post( var response = await HttpUtil().post(
...@@ -145,6 +192,16 @@ class UserAPI { ...@@ -145,6 +192,16 @@ class UserAPI {
return response['status']; return response['status'];
// return ApplePayEntity.fromMap(response['data']); // return ApplePayEntity.fromMap(response['data']);
} }
static Future<SceneEntity> getSceneList() async {
var response = await HttpUtil().get(
'/scene/getSceneList',
);
return SceneEntity.fromJson(response);
// UserInfoEntity.fromMap(response['data']);
// UserLoginResponseEntity.fromJson(response);
}
// /
// /api/ // /api/
// openAi/createConversion // openAi/createConversion
......
class SceneEntity {
int? _status;
String? _message;
List<SceneItem>? _data;
int? _timestamp;
SceneEntity(
{int? status, String? message, List<SceneItem>? data, int? timestamp}) {
if (status != null) {
this._status = status;
}
if (message != null) {
this._message = message;
}
if (data != null) {
this._data = data;
}
if (timestamp != null) {
this._timestamp = timestamp;
}
}
int? get status => _status;
set status(int? status) => _status = status;
String? get message => _message;
set message(String? message) => _message = message;
List<SceneItem>? get data => _data;
set data(List<SceneItem>? data) => _data = data;
int? get timestamp => _timestamp;
set timestamp(int? timestamp) => _timestamp = timestamp;
SceneEntity.fromJson(Map<String, dynamic> json) {
_status = json['status'];
_message = json['message'];
if (json['data'] != null) {
_data = <SceneItem>[];
json['data'].forEach((v) {
_data!.add(new SceneItem.fromJson(v));
});
}
_timestamp = json['timestamp'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['status'] = this._status;
data['message'] = this._message;
if (this._data != null) {
data['data'] = this._data!.map((v) => v.toJson()).toList();
}
data['timestamp'] = this._timestamp;
return data;
}
}
class SceneItem {
int? _id;
String? _sceneName;
String? _sceneDesc;
String? _scenePre;
int? _isShow;
String? _icon;
SceneItem(
{int? id,
String? sceneName,
String? sceneDesc,
String? scenePre,
int? isShow,
String? icon}) {
if (id != null) {
this._id = id;
}
if (sceneName != null) {
this._sceneName = sceneName;
}
if (sceneDesc != null) {
this._sceneDesc = sceneDesc;
}
if (scenePre != null) {
this._scenePre = scenePre;
}
if (isShow != null) {
this._isShow = isShow;
}
if (icon != null) {
this._icon = icon;
}
}
int? get id => _id;
set id(int? id) => _id = id;
String? get sceneName => _sceneName;
set sceneName(String? sceneName) => _sceneName = sceneName;
String? get sceneDesc => _sceneDesc;
set sceneDesc(String? sceneDesc) => _sceneDesc = sceneDesc;
String? get scenePre => _scenePre;
set scenePre(String? scenePre) => _scenePre = scenePre;
int? get isShow => _isShow;
set isShow(int? isShow) => _isShow = isShow;
String? get icon => _icon;
set icon(String? icon) => _icon = icon;
SceneItem.fromJson(Map<String, dynamic> json) {
_id = json['id'];
_sceneName = json['sceneName'];
_sceneDesc = json['sceneDesc'];
_scenePre = json['scenePre'];
_isShow = json['isShow'];
_icon = json['icon'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this._id;
data['sceneName'] = this._sceneName;
data['sceneDesc'] = this._sceneDesc;
data['scenePre'] = this._scenePre;
data['isShow'] = this._isShow;
data['icon'] = this._icon;
return data;
}
}
...@@ -21,5 +21,7 @@ class AppRoutes { ...@@ -21,5 +21,7 @@ class AppRoutes {
static const CREATION_PAGE_DETAIL = '/creation-detail'; static const CREATION_PAGE_DETAIL = '/creation-detail';
static const ASSISTANT_PAGE = '/assistant'; static const ASSISTANT_PAGE = '/assistant';
static const MY_PAGE = '/my'; static const MY_PAGE = '/my';
static const ASSISTANT_ITEM = '/creation-item';
// AssistantItemBinding
// UserPrivacyPage // UserPrivacyPage
} }
import 'package:chart/pages/assistant-item/index.dart';
import 'package:chart/pages/assistant/index.dart'; import 'package:chart/pages/assistant/index.dart';
import 'package:chart/pages/chat/view.dart'; import 'package:chart/pages/chat/view.dart';
import 'package:chart/pages/creation-detail/index.dart'; import 'package:chart/pages/creation-detail/index.dart';
...@@ -189,6 +190,11 @@ class AppPages { ...@@ -189,6 +190,11 @@ class AppPages {
name: AppRoutes.CREATION_PAGE_DETAIL, name: AppRoutes.CREATION_PAGE_DETAIL,
page: () => const CreationDetailPage(), page: () => const CreationDetailPage(),
binding: CreationDetailBinding(), binding: CreationDetailBinding(),
),
GetPage(
name: AppRoutes.ASSISTANT_ITEM,
page: () => AssistantItemPage(),
binding: AssistantItemBinding(),
) )
]; ];
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
// const SERVER_API_URL = 'https://yapi.baidu.com/mock/41008'; // const SERVER_API_URL = 'https://yapi.baidu.com/mock/41008';
// const SERVER_API_URL = 'http://192.168.120.175:8083/api'; // const SERVER_API_URL = 'http://192.168.120.175:8083/api';
const SERVER_API_URL = 'http://101.34.153.228:8083/api';//线上 const SERVER_API_URL = 'http://101.34.153.228:8083/api';//线上
// const SERVER_API_URL = 'http://192.168.2.178:8083/api';//线上
// const SERVER_API_URL = 'http://192.168.121.180:8083/api';//线上
//http://192.168.2.178:8083/api/doc.html //http://192.168.2.178:8083/api/doc.html
// const SERVER_API_URL = "http://192.168.120.108:8083/api"; // const SERVER_API_URL = "http://192.168.120.108:8083/api";
// http://192.168.110.127:8083/api/doc.html // http://192.168.110.127:8083/api/doc.html
......
...@@ -13,9 +13,10 @@ AppBar transparentAppBar({ ...@@ -13,9 +13,10 @@ AppBar transparentAppBar({
// elevation: 2, // elevation: 2,
title: title, title: title,
elevation: 0, elevation: 0,
leadingWidth: 115, leadingWidth: 90,
leading: leading ?? null, leading: leading ?? null,
actions: actions, actions: actions,
centerTitle: true,
); );
} }
......
...@@ -6,13 +6,19 @@ class ChartTTS { ...@@ -6,13 +6,19 @@ class ChartTTS {
String voiceName; String voiceName;
double volume; double volume;
double speechRate; double speechRate;
double pitch;
String language = "zh-CN"; String language = "zh-CN";
static ChartTTS tts = ChartTTS(); static ChartTTS tts = ChartTTS();
ChartTTS({this.voiceName = "zh", this.volume = 1.0, this.speechRate = 1.0}) { ChartTTS(
{this.voiceName = "zh",
this.volume = 1.0,
this.speechRate = 0.5,
this.pitch = 1.0}) {
flutterTts.setLanguage(language); flutterTts.setLanguage(language);
flutterTts.setVolume(volume); flutterTts.setVolume(volume);
flutterTts.setSpeechRate(speechRate); flutterTts.setPitch(1.0);
flutterTts.setSpeechRate(0.5);
} }
final FlutterTts _flutterTts = FlutterTts(); final FlutterTts _flutterTts = FlutterTts();
......
...@@ -229,8 +229,9 @@ class _DefaultMessageTextState extends State<DefaultMessageText> { ...@@ -229,8 +229,9 @@ class _DefaultMessageTextState extends State<DefaultMessageText> {
borderRadius: BorderRadius.circular(5), borderRadius: BorderRadius.circular(5),
child: Container( child: Container(
width: 100, width: 100,
padding: EdgeInsets.only(left: 5,top:5,right: 5,bottom: 5), padding: EdgeInsets.only(left: 5, top: 5, right: 5, bottom: 5),
decoration: BoxDecoration(gradient: LinearGradient( decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Color(0xFF3d3f54), Color(0xFF333450), Color(0xFF2b2b4d)], colors: [Color(0xFF3d3f54), Color(0xFF333450), Color(0xFF2b2b4d)],
begin: Alignment.topCenter, begin: Alignment.topCenter,
end: Alignment.bottomCenter, end: Alignment.bottomCenter,
......
...@@ -154,13 +154,13 @@ class ApplicationController extends GetxController { ...@@ -154,13 +154,13 @@ class ApplicationController extends GetxController {
label: '私人助理', label: '私人助理',
backgroundColor: AppColors.primaryBackground, backgroundColor: AppColors.primaryBackground,
), ),
const BottomNavigationBarItem( // const BottomNavigationBarItem(
icon: Image(image: AssetImage("assets/images/my.png"), width: 30.0), // icon: Image(image: AssetImage("assets/images/my.png"), width: 30.0),
activeIcon: Image( // activeIcon: Image(
image: AssetImage("assets/images/my-selected.png"), width: 30.0), // image: AssetImage("assets/images/my-selected.png"), width: 30.0),
label: '我的', // label: '我的',
backgroundColor: AppColors.primaryBackground, // backgroundColor: AppColors.primaryBackground,
), // ),
]; ];
pageController = PageController(initialPage: state.page); pageController = PageController(initialPage: state.page);
} }
......
...@@ -49,7 +49,7 @@ class ApplicationPage extends GetView<ApplicationController> { ...@@ -49,7 +49,7 @@ class ApplicationPage extends GetView<ApplicationController> {
HomePage(), HomePage(),
CreationPage(), CreationPage(),
AssistantPage(), AssistantPage(),
MyPage() // MyPage()
]); ]);
} }
......
import 'package:get/get.dart';
import 'controller.dart';
class AssistantItemBinding implements Bindings {
@override
void dependencies() {
Get.lazyPut<AssistantItemController>(() => AssistantItemController());
}
}
import 'dart:convert';
import 'package:chart/common/apis/user.dart';
import 'package:chart/common/store/store.dart';
import 'package:chart/package/chat_dash/dash_chat_2.dart';
import 'package:flutter_client_sse/flutter_client_sse.dart';
import 'package:flutter_vibrate/flutter_vibrate.dart';
import 'package:get/get.dart';
import 'package:chart/package/chat_dash/dash_chat_2.dart' as Chat;
import '../../common/values/values.dart';
import 'index.dart';
Chat.ChatUser _user = Chat.ChatUser(
id: '1',
// firstName: 'Charles',
// lastName: 'Leclerc',
);
final receiveUser = Chat.ChatUser(
id: '82091008-a484-4a89-ae75-a22bf8d6f3aa',
// firstName: "A",
// lastName: 'I',
// imageUrl:
// "https://imgb15.photophoto.cn/20201124/jiqirentupian-39852917_3.jpg"
// // imageUrl: "assets/images/300.jpg",
);
class AssistantItemController extends GetxController {
AssistantItemController();
static AssistantItemController get to => Get.put(AssistantItemController());
final state = AssistantItemState();
// tap
void handleTap(int index) {
Get.snackbar(
"标题",
"消息",
);
}
tabMessage(ChatMessage message) {
if (message.user.id == '0' && !state.isLoading) {
sendMessage(Chat.ChatMessage(
text: "${message.text}",
user: _user,
createdAt: DateTime.now(),
));
}
// Clipboard.setData(ClipboardData(text: message?.text));
// EasyLoading.showSuccess("复制成功");
// Get.snackbar("复制成功", "", colorText: Colors.white);
}
void sendMessage(Chat.ChatMessage message) async {
Vibrate.feedback(FeedbackType.impact);
final textMessage = Chat.ChatMessage(
user: _user,
createdAt: DateTime.now(),
// id: const Uuid().v4(),
text: "${message.text}",
);
_addMessage(textMessage);
final receiveMessage = Chat.ChatMessage(
user: receiveUser,
createdAt: DateTime.now(),
status: MessageStatus.pending,
// id: const Uuid().v4(),
text: "LOADING",
);
_addMessage(receiveMessage);
try {
await initEventSource();
state.isLoading = true;
await UserAPI.sceneConversion({
"conversionId": state.actId,
"question": message.text,
"sceneId": state.selectItem['sceneId'],
});
} catch (e) {}
// final loadingMessage = types.TextMessage(
// author: receiveUser,
// createdAt: DateTime.now().millisecondsSinceEpoch,
// id: const Uuid().v4(),
// text: "loading",
// status: types.Status.sending,
// // "sending",
// );
}
initEventSource() async {
SSEClient.subscribeToSSE(
url: "$SERVER_API_URL/openAi/connect/${UserStore.to.profile.id}",
header: {}).listen((event) async {
print(event);
if (event.data!.trim().isEmpty) {
return;
} else if (event.id == "[DONE]") {
await UserAPI.saveResp({
"conversionId": state.actId,
"content": state.messageList[0].text,
});
state.isLoading = false;
return;
}
Map<String, dynamic> jsonMap = jsonDecode("${event.data}");
_updateMessage("${jsonMap['content']}" as String);
});
// print(sse);
}
void _addMessage(Chat.ChatMessage message) {
state.messageList.insert(0, message);
}
_updateMessage(String text) {
if (state.messageList.isEmpty) {
return;
}
state.messageList.setRange(0, 1, [
ChatMessage(
user: receiveUser,
createdAt: DateTime.now(),
text: state.messageList.value[0].text == "LOADING"
? text
: state.messageList.value[0].text + text
// user: receiveUser,
// createdAt: DateTime.now(),
// // id: const Uuid().v4(),
// text: "",
)
]);
// state.messageList.value = [...state.messageList.value];list.setRange(1, 4, [9, 9, 9]);
// state.messageList.value[0].text = state.messageList.value[0].text + text;
}
/// 在 widget 内存中分配后立即调用。
@override
void onInit() {
super.onInit();
}
/// 在 onInit() 之后调用 1 帧。这是进入的理想场所
@override
void onReady() {
super.onReady();
}
/// 在 [onDelete] 方法之前调用。
@override
void onClose() {
super.onClose();
}
/// dispose 释放内存
@override
void dispose() {
super.dispose();
}
}
library assistant_item;
export './state.dart';
export './controller.dart';
export './bindings.dart';
export './view.dart';
import 'package:chart/package/chat_dash/dash_chat_2.dart' as Chat;
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
class AssistantItemState {
// title
final _title = "".obs;
set title(value) => _title.value = value;
get title => _title.value;
final _actId = 0.obs;
set actId(value) => _actId.value = value;
get actId => _actId.value;
final _selectItem = {}.obs;
set selectItem(value) => _selectItem.value = value;
get selectItem => _selectItem.value;
final _isLoading = false.obs;
set isLoading(value) => _isLoading.value = value;
get isLoading => _isLoading.value;
RxList<Chat.ChatMessage> messageList = <Chat.ChatMessage>[].obs;
final color = Colors.white.obs;
}
import 'package:chart/common/values/values.dart';
import 'package:chart/common/widgets/widgets.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
import 'package:chart/package/chat_dash/dash_chat_2.dart' as Chat;
import 'package:gradient_widgets/gradient_widgets.dart';
import 'index.dart';
import 'widgets/widgets.dart';
class AssistantItemPage extends GetView<AssistantItemController> {
const AssistantItemPage({Key? key}) : super(key: key);
// 主视图
Widget _buildView() {
return const HelloWidget();
}
@override
Widget build(BuildContext context) {
final cc = Get.put(AssistantItemController());
return Container(
decoration: BoxDecoration(
image: DecorationImage(
image: Image.asset("assets/images/background.png").image,
fit: BoxFit.cover),
),
child: Obx(
() => Scaffold(
backgroundColor: Color.fromARGB(0, 0, 0, 0),
appBar: AppBar(
elevation: 0,
backgroundColor: Color.fromARGB(0, 0, 0, 0),
actions: [],
title: RichText(
textAlign: TextAlign.center,
text: TextSpan(children: [
TextSpan(
text: "${controller.state.selectItem['title']}",
style: TextStyle(
color: AppColors.primaryElementText,
fontFamily: 'Montserrat',
fontSize: 18,
fontWeight: FontWeight.w600,
)),
TextSpan(
text: "${controller.state.messageList.length}",
style: TextStyle(fontSize: 0)),
])),
),
body: KeyboardVisibilityBuilder(builder: (context, visible) {
return Chat.DashChat(
inputOptions: Chat.InputOptions(
textInputAction: TextInputAction.send,
sendOnEnter: true,
// showTraillingBeforeSend: true,
// inputDisabled: cc.state.isLoading,
inputTextStyle: TextStyle(color: Colors.white),
inputToolbarStyle: BoxDecoration(
color: Color.fromARGB(120, 0, 0, 0),
// Color.fromARGB(0, 54, 59, 72),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16)),
),
inputToolbarMargin: EdgeInsets.all(0),
sendButtonBuilder: null,
inputToolbarPadding: EdgeInsets.only(
top: 15,
right: 15,
left: 15,
bottom: visible ? 15 : 50),
),
currentUser: _user,
onSend: cc.sendMessage,
messages: cc.state.messageList,
messageOptions: Chat.MessageOptions(
onPressMessage: cc.tabMessage,
// containerColor: Colors.black,
),
);
})),
));
}
// Widget build(BuildContext context) {
// final cc = Get.put(AssistantItemController());
// return GetBuilder<AssistantItemController>(
// builder: (_) {
// return Container(
// decoration: BoxDecoration(
// image: DecorationImage(
// image: Image.asset("assets/images/background.png").image,
// fit: BoxFit.cover),
// ),
// child: Obx(
// () => Scaffold(
// backgroundColor: Color.fromARGB(0, 29, 33, 60),
// appBar: AppBar(
// backgroundColor: Color.fromARGB(0, 29, 33, 60),
// title: Text('${cc.state.selectItem['title']}'),
// elevation: 0),
// body: Container(child:
// KeyboardVisibilityBuilder(builder: (context, visible) {
// return Obx(() => Chat.DashChat(
// inputOptions: Chat.InputOptions(
// textInputAction: TextInputAction.send,
// sendOnEnter: true,
// // showTraillingBeforeSend: true,
// inputDisabled: cc.state.isLoading,
// inputTextStyle: const TextStyle(color: Colors.white),
// inputToolbarStyle: const BoxDecoration(
// color: Color.fromARGB(120, 0, 0, 0),
// // Color.fromARGB(0, 54, 59, 72),
// borderRadius: BorderRadius.only(
// topLeft: Radius.circular(16),
// topRight: Radius.circular(16)),
// ),
// inputToolbarMargin: EdgeInsets.all(0),
// sendButtonBuilder: null,
// inputToolbarPadding: EdgeInsets.only(
// top: 15,
// right: 15,
// left: 15,
// bottom: visible ? 15 : 40),
// ),
// currentUser: _user,
// onSend: cc.sendMessage,
// messages: cc.state.messageList,
// // messageOptions: const Chat.MessageOptions(
// // // onPressMessage: cc.tabMessage/,
// // // containerColor: Colors.black,
// // ),
// ));
// })),
// ),
// ));
// },
// );
// }
// Widget build(BuildContext context) {
// return GetBuilder<AssistantItemController>(
// builder: (_) {
// return Scaffold(
// appBar: AppBar(title: const Text(c)),
// body: SafeArea(
// child: _buildView(),
// ),
// );
// },
// );
// }
}
Chat.ChatUser _user = Chat.ChatUser(
id: '1',
// firstName: 'Charles',
// lastName: 'Leclerc',
);
import 'package:flutter/material.dart';
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
import 'package:get/get.dart';
import 'package:chart/package/chat_dash/dash_chat_2.dart' as Chat;
import '../index.dart';
/// hello
class HelloWidget extends GetView<AssistantItemController> {
const HelloWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Center(child: KeyboardVisibilityBuilder(builder: (context, visible) {
return Obx(() => Chat.DashChat(
inputOptions: Chat.InputOptions(
textInputAction: TextInputAction.send,
sendOnEnter: true,
// showTraillingBeforeSend: true,
inputDisabled: controller.state.isLoading,
inputTextStyle: const TextStyle(color: Colors.white),
inputToolbarStyle: const BoxDecoration(
color: Color.fromARGB(120, 0, 0, 0),
// Color.fromARGB(0, 54, 59, 72),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16)),
),
inputToolbarMargin: EdgeInsets.all(0),
sendButtonBuilder: null,
inputToolbarPadding: EdgeInsets.only(
top: 15, right: 15, left: 15, bottom: visible ? 15 : 40),
),
currentUser: _user,
onSend: controller.sendMessage,
messages: controller.state.messageList,
messageOptions: const Chat.MessageOptions(
// onPressMessage: cc.tabMessage,
// containerColor: Colors.black,
),
));
}));
}
}
Chat.ChatUser _user = Chat.ChatUser(
id: '1',
// firstName: 'Charles',
// lastName: 'Leclerc',
);
library widgets;
export './hello.dart';
import 'package:chart/common/apis/apis.dart';
import 'package:chart/common/entities/scene.dart';
import 'package:chart/common/routers/names.dart';
import 'package:chart/pages/assistant-item/controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_vibrate/flutter_vibrate.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:loading_animation_widget/loading_animation_widget.dart';
class AssistantController extends GetxController { class AssistantController extends GetxController {
AssistantController(); AssistantController();
_initData() { final sceneList = [].obs;
update(["assistant"]);
_initData() async {
SceneEntity res = await UserAPI.getSceneList();
sceneList.addAll(res.data!);
} }
void onTap() {} void onTap(item) async {
EasyLoading.show(
status: "加载中",
dismissOnTap: false,
maskType: EasyLoadingMaskType.none,
indicator: LoadingAnimationWidget.staggeredDotsWave(
color: Colors.white,
size: 30,
));
Vibrate.feedback(FeedbackType.impact);
final res = await UserAPI.createConversion();
EasyLoading.dismiss();
AssistantItemController.to.state.actId = res;
AssistantItemController.to.state.selectItem = {
'title': item.sceneName,
'sceneId': item.id
};
AssistantItemController.to.state.messageList.clear();
// CreationDetailController.to
// .updateState('${item.id}', item.detailName, res.data!);
Get.toNamed(AppRoutes.ASSISTANT_ITEM);
// ASSISTANT_ITEM
}
// @override // @override
// void onInit() { // void onInit() {
......
This diff is collapsed.
...@@ -23,15 +23,29 @@ class GridWidget extends GetView<CreationController> { ...@@ -23,15 +23,29 @@ class GridWidget extends GetView<CreationController> {
maxHeight: Get.height * .156, maxHeight: Get.height * .156,
child: Opacity( child: Opacity(
opacity: .668, opacity: .668,
child: Image.network( child: ClipRRect(
width: double.infinity, borderRadius: BorderRadius.circular(10),
'https://www.hahagpt.com/images/assets/banner1.png', child: FadeInImage(
height: Get.height * .16, fadeInDuration: Duration(milliseconds: 500),
fit: BoxFit.cover placeholder: const AssetImage(
// ignore: prefer_const_constructors 'assets/images/loading.gif'), // 加载指示器
// placeholder: CircularProgressIndicator(), image: NetworkImage(
// errorWidget: Icon(Icons.error), 'https://www.hahagpt.com/images/assets/banner1.png'),
// image: NetworkImage(
// 'https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.pinterest.com%2Fpin%2Fai-visualization-design-fui-artificial-intelligence-siri-filter-ai-loading-logo-flow-light--400538960609301125%2F&psig=AOvVaw0X4iFGabqA_JwUiW9zEG4u&ust=1680859399497000&source=images&cd=vfe&ved=0CA8QjRxqFwoTCLiAnK33lP4CFQAAAAAdAAAAABAb'), // 图像URL
fit: BoxFit.cover, // 图像适应方式
placeholderFit: BoxFit.cover, // 图像适应
), ),
)
// Image.network(
// width: double.infinity,
// 'https://www.hahagpt.com/images/assets/banner1.png',
// height: Get.height * .16,
// fit: BoxFit.cover
// // ignore: prefer_const_constructors
// // placeholder: CircularProgressIndicator(),
// // errorWidget: Icon(Icons.error),
// ),
// //
// child: // child:
// Container( // Container(
...@@ -90,22 +104,42 @@ class GridWidget extends GetView<CreationController> { ...@@ -90,22 +104,42 @@ class GridWidget extends GetView<CreationController> {
child: Container( child: Container(
height: Get.height * 0.16, height: Get.height * 0.16,
decoration: BoxDecoration( decoration: BoxDecoration(
// color: Colors.red,
borderRadius: borderRadius:
BorderRadius.circular(10), BorderRadius.circular(10),
image: DecorationImage(
image: Image.network(
'${controller.list[index].icon}')
.image,
fit: BoxFit.fitHeight,
// colorFilter: ColorFilter.mode(Colors.red, BlendMode.colorBurn),
), ),
child: Stack(children: [
Positioned(
left: 0,
top: 0,
bottom: 0,
right: 0,
child: ClipRRect(
borderRadius:
BorderRadius.circular(10),
child: FadeInImage(
fadeInDuration: Duration(
milliseconds: 500),
placeholder: const AssetImage(
'assets/images/loading.gif'), // 加载指示器
image: NetworkImage(
'${controller.list[index].icon}'),
// image: NetworkImage(
// 'https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.pinterest.com%2Fpin%2Fai-visualization-design-fui-artificial-intelligence-siri-filter-ai-loading-logo-flow-light--400538960609301125%2F&psig=AOvVaw0X4iFGabqA_JwUiW9zEG4u&ust=1680859399497000&source=images&cd=vfe&ved=0CA8QjRxqFwoTCLiAnK33lP4CFQAAAAAdAAAAABAb'), // 图像URL
fit: BoxFit.cover, // 图像适应方式
placeholderFit:
BoxFit.cover, // 图像适应
), ),
child: Column( )),
Column(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.end, MainAxisAlignment.end,
children: [ children: [
// Stack()
GradientButton( GradientButton(
child: const Text('2.8万人使用', child: Text(
'${controller.list[index].count}人使用',
style: TextStyle( style: TextStyle(
fontSize: 10)), fontSize: 10)),
increaseHeightBy: -10.00, increaseHeightBy: -10.00,
...@@ -117,12 +151,6 @@ class GridWidget extends GetView<CreationController> { ...@@ -117,12 +151,6 @@ class GridWidget extends GetView<CreationController> {
// controller.requestPurchase, // controller.requestPurchase,
gradient: const LinearGradient( gradient: const LinearGradient(
colors: [ colors: [
// 61, 63, 84
// 180deg,
// #be6afb,
// #9c67f6,
// #7965f8
Color(0xFFbe6afb), Color(0xFFbe6afb),
Color(0xFF9c67f6), Color(0xFF9c67f6),
Color(0xFF7965f8) Color(0xFF7965f8)
...@@ -133,9 +161,7 @@ class GridWidget extends GetView<CreationController> { ...@@ -133,9 +161,7 @@ class GridWidget extends GetView<CreationController> {
) )
], ],
) )
]),
// Positioned(
// child: ),
)), )),
Text('${controller.list[index].detailName}', Text('${controller.list[index].detailName}',
style: TextStyle( style: TextStyle(
......
...@@ -48,7 +48,7 @@ class UserEulaPage extends GetView<UserEulaController> { ...@@ -48,7 +48,7 @@ class UserEulaPage extends GetView<UserEulaController> {
return GetBuilder<UserEulaController>( return GetBuilder<UserEulaController>(
builder: (_) { builder: (_) {
return Scaffold( return Scaffold(
appBar: transparentAppBar( appBar: AppBar(
leading: IconButton( leading: IconButton(
tooltip: '返回上一页', tooltip: '返回上一页',
icon: const Icon( icon: const Icon(
......
...@@ -67,21 +67,6 @@ class ChatNewController extends GetxController { ...@@ -67,21 +67,6 @@ class ChatNewController extends GetxController {
void sendMessage(Chat.ChatMessage message) async { void sendMessage(Chat.ChatMessage message) async {
print("${message.text}"); print("${message.text}");
Vibrate.feedback(FeedbackType.impact); Vibrate.feedback(FeedbackType.impact);
// if (state.messageList.isNotEmpty) {
// // data = !_messages.every((element) => element.status != Status.sending);
// }
// if (data) {
// Fluttertoast.showToast(
// msg: "操作太快了 你上个问题还没问完呢",
// toastLength: Toast.LENGTH_SHORT,
// gravity: ToastGravity.CENTER,
// timeInSecForIosWeb: 1,
// backgroundColor: Colors.red,
// textColor: Colors.white,
// fontSize: 16.0);
// return;
// }
final textMessage = Chat.ChatMessage( final textMessage = Chat.ChatMessage(
user: _user, user: _user,
...@@ -176,19 +161,6 @@ class ChatNewController extends GetxController { ...@@ -176,19 +161,6 @@ class ChatNewController extends GetxController {
void _addMessage(Chat.ChatMessage message) { void _addMessage(Chat.ChatMessage message) {
state.messageList.insert(0, message); state.messageList.insert(0, message);
// state.messageList = [message]
// state.messageList.add(message);
// state.messageList.add(message);
// updateState(state);
// update()
// update((state.messageList), {
// // state.messageList.value = [message]
// });
// user.update((value) {
// value?.name = "123";
// });
// state.messageList.value = [message];
} }
void addCount() { void addCount() {
......
...@@ -20,8 +20,11 @@ class PayListController extends GetxController { ...@@ -20,8 +20,11 @@ class PayListController extends GetxController {
final state = PayListState(); final state = PayListState();
final List<String> _productLists = [ final List<String> _productLists = [
"com.wudi.monthly_pass_chat", "com.wudi.chat.week_pass",
"com.wudi.yearly_pass_chat", "com.wudi.monthly_pass_chat_subscription",
"com.wudi.quarterly_pass_chat_subscription",
// "com.wudi.chat.halfyear_pass",
"com.wudi.yearly_pass_chat"
]; ];
final List<dynamic> _mapData = [ final List<dynamic> _mapData = [
...@@ -88,6 +91,7 @@ class PayListController extends GetxController { ...@@ -88,6 +91,7 @@ class PayListController extends GetxController {
}); });
if (res?.status == 200) { if (res?.status == 200) {
state.loading = false;
EasyLoading.showSuccess('${res?.message}'); EasyLoading.showSuccess('${res?.message}');
Vibrate.feedback(FeedbackType.success); Vibrate.feedback(FeedbackType.success);
EasyLoading.dismiss(); EasyLoading.dismiss();
...@@ -122,6 +126,7 @@ class PayListController extends GetxController { ...@@ -122,6 +126,7 @@ class PayListController extends GetxController {
} else { } else {
await FlutterInappPurchase.instance.clearTransactionIOS(); await FlutterInappPurchase.instance.clearTransactionIOS();
EasyLoading.showError("${res?.message}}"); EasyLoading.showError("${res?.message}}");
state.loading = false;
EasyLoading.dismiss(); EasyLoading.dismiss();
Vibrate.feedback(FeedbackType.error); Vibrate.feedback(FeedbackType.error);
} }
...@@ -133,6 +138,7 @@ class PayListController extends GetxController { ...@@ -133,6 +138,7 @@ class PayListController extends GetxController {
Vibrate.feedback(FeedbackType.error); Vibrate.feedback(FeedbackType.error);
EasyLoading.showError('支付订单失败'); EasyLoading.showError('支付订单失败');
EasyLoading.dismiss(); EasyLoading.dismiss();
state.loading = false;
}); });
} }
...@@ -145,12 +151,13 @@ class PayListController extends GetxController { ...@@ -145,12 +151,13 @@ class PayListController extends GetxController {
for (var purchase in purchases!) { for (var purchase in purchases!) {
// com.wudi.yearly_pass_chat // com.wudi.yearly_pass_chat
if (purchase.productId == 'com.wudi.yearly_pass_chat' || if (_productLists.contains(purchase.productId)) {
purchase.productId == "com.wudi.monthly_pass_chat") { print(purchase.productId);
// // IAPItem item // // IAPItem item
FlutterInappPurchase.instance.requestPurchase(purchase.productId!); FlutterInappPurchase.instance.requestPurchase(purchase.productId!);
EasyLoading.showSuccess("恢复购买成功"); EasyLoading.showSuccess("恢复购买成功");
} else { } else {
EasyLoading.showInfo("没有查询到购买订单");
EasyLoading.dismiss(); EasyLoading.dismiss();
} }
...@@ -177,6 +184,7 @@ class PayListController extends GetxController { ...@@ -177,6 +184,7 @@ class PayListController extends GetxController {
} }
void requestPurchase() { void requestPurchase() {
state.loading = true;
Vibrate.feedback(FeedbackType.selection); Vibrate.feedback(FeedbackType.selection);
// print("${item.productId}"); // print("${item.productId}");
EasyLoading.show(status: '支付中...'); EasyLoading.show(status: '支付中...');
......
...@@ -7,9 +7,13 @@ class PayListState { ...@@ -7,9 +7,13 @@ class PayListState {
set title(value) => this._title.value = value; set title(value) => this._title.value = value;
get title => this._title.value; get title => this._title.value;
final _selected = "com.wudi.monthly_pass_chat".obs; final _selected = "com.wudi.yearly_pass_chat".obs;
set selected(value) => _selected.value = value; set selected(value) => _selected.value = value;
get selected => _selected.value; get selected => _selected.value;
final _loading = false.obs;
set loading(value) => _loading.value = value;
get loading => _loading.value;
RxList<IAPItem> items = <IAPItem>[].obs; RxList<IAPItem> items = <IAPItem>[].obs;
} }
...@@ -33,6 +33,18 @@ class PayListPage extends GetView<PayListController> { ...@@ -33,6 +33,18 @@ class PayListPage extends GetView<PayListController> {
elevation: 0, elevation: 0,
backgroundColor: const Color.fromARGB(0, 0, 0, 0), backgroundColor: const Color.fromARGB(0, 0, 0, 0),
title: Text("订阅中心"), title: Text("订阅中心"),
actions: <Widget>[
GestureDetector(
onTap: () {
controller.restorePurchases();
},
child: Container(
padding: EdgeInsets.only(right: 10),
child: Center(
child: Text("恢复购买"),
)),
)
],
), ),
backgroundColor: const Color.fromARGB(0, 0, 0, 0), backgroundColor: const Color.fromARGB(0, 0, 0, 0),
body: _buildView() body: _buildView()
......
import 'package:flutter/material.dart';
class MarqueeView extends StatefulWidget {
final Duration pauseDuration, forwardDuration;
final double scrollSpeed; //滚动速度(时间单位是秒)。
final Widget child; //子视图。
/// 注: 构造函数入参的默认值必须是常量。
const MarqueeView(
{Key? key,
this.pauseDuration = const Duration(milliseconds: 100),
this.forwardDuration = const Duration(milliseconds: 2000),
this.scrollSpeed = 50.0,
required this.child})
: super(key: key);
@override
_MarqueeViewState createState() => _MarqueeViewState();
}
class _MarqueeViewState extends State<MarqueeView>
with SingleTickerProviderStateMixin {
bool _validFlag = true;
double _boxWidth = 0;
final ScrollController _controller = ScrollController();
@override
void dispose() {
_validFlag = false;
_controller.dispose();
super.dispose();
}
@override
void initState() {
super.initState();
scroll();
}
@override
Widget build(BuildContext context) {
/// 使用LayoutBuilder获取组件的大小。
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
_boxWidth = constraints.maxWidth;
return SingleChildScrollView(
// 禁止手动滑动。
physics: const NeverScrollableScrollPhysics(),
controller: _controller,
scrollDirection: Axis.horizontal,
child: Container(
margin: EdgeInsets.symmetric(vertical: 10),
padding: EdgeInsets.symmetric(horizontal: _boxWidth),
child: widget.child,
),
);
},
);
}
void scroll() async {
while (_validFlag) {
debugPrint('Track_MarqueeView_scroll');
await Future.delayed(widget.pauseDuration);
if (_boxWidth <= 0) {
continue;
}
_controller.jumpTo(0);
// 两个方向: Curves.easeIn 和 Curves.easeOut 。
await _controller.animateTo(_controller.position.maxScrollExtent,
duration: Duration(
seconds:
(_controller.position.maxScrollExtent / widget.scrollSpeed)
.floor()),
curve: Curves.easeIn);
}
}
}
library widgets; library widgets;
export 'helloword.dart'; export 'helloword.dart';
export 'marquee.dart';
...@@ -26,7 +26,7 @@ import 'package:flutter_client_sse/flutter_client_sse.dart'; ...@@ -26,7 +26,7 @@ import 'package:flutter_client_sse/flutter_client_sse.dart';
// EventSource eventSource = EventSource(Uri.parse('http://example.com/events')); // EventSource eventSource = EventSource(Uri.parse('http://example.com/events'));
// //
class HomeController extends GetxController { class HomeController extends GetxController with SingleGetTickerProviderMixin {
HomeController(); HomeController();
static HomeController get to => Get.put(HomeController()); static HomeController get to => Get.put(HomeController());
...@@ -36,6 +36,9 @@ class HomeController extends GetxController { ...@@ -36,6 +36,9 @@ class HomeController extends GetxController {
late StreamSubscription<Event> eventSource; late StreamSubscription<Event> eventSource;
late AnimationController _controller;
late Animation<double> _animation;
bool _isRotated = false;
// ignore: prefer_typing_uninitialized_variables // ignore: prefer_typing_uninitialized_variables
late var sse; late var sse;
...@@ -96,7 +99,7 @@ class HomeController extends GetxController { ...@@ -96,7 +99,7 @@ class HomeController extends GetxController {
if (UserStore.to.profile.id != '') { if (UserStore.to.profile.id != '') {
await initEventSource(); await initEventSource();
state.isLoading = true; state.isLoading = true;
int? result = await UserAPI.sceneAsk({ int? result = await UserAPI.aiAnswerWithoutSave({
"question": message.text, "question": message.text,
"conversionId": 0, "conversionId": 0,
"sceneId": 0, "sceneId": 0,
...@@ -120,7 +123,6 @@ class HomeController extends GetxController { ...@@ -120,7 +123,6 @@ class HomeController extends GetxController {
integral: value.integral)); integral: value.integral));
}); });
// index.value = state.messageList.length; // index.value = state.messageList.length;
} else { } else {
// EasyLoading.showError("网络异常"); // EasyLoading.showError("网络异常");
...@@ -143,15 +145,17 @@ class HomeController extends GetxController { ...@@ -143,15 +145,17 @@ class HomeController extends GetxController {
} catch (e) { } catch (e) {
print("eeeeeeee$e"); print("eeeeeeee$e");
state.isLoading = false; state.isLoading = false;
// _cancelLoading(); // // _cancelLoading();
final receiveErrorMessage = Chat.ChatMessage( // final receiveErrorMessage = Chat.ChatMessage(
user: receiveUser, // user: receiveUser,
createdAt: DateTime.now(), // createdAt: DateTime.now(),
// id: const Uuid().v4(), // // id: const Uuid().v4(),
text: "当前用户太多了,请稍等再试", // text: "当前用户太多了,请稍等再试",
); // );
_addMessage(receiveErrorMessage); // _addMessage(receiveErrorMessage);
_updateMessage("网络错误,请重试!");
EasyLoading.dismiss(); EasyLoading.dismiss();
Vibrate.feedback(FeedbackType.error); Vibrate.feedback(FeedbackType.error);
} }
...@@ -281,10 +285,9 @@ class HomeController extends GetxController { ...@@ -281,10 +285,9 @@ class HomeController extends GetxController {
if (event.data!.trim().isEmpty) { if (event.data!.trim().isEmpty) {
return; return;
} else if (event.id == "[DONE]") { } else if (event.id == "[DONE]") {
// await UserAPI.saveResp({ await UserAPI.saveRespTemp({
// "conversionId": state.conversionId, "content": state.messageList[0].text,
// "content": state.messageList[0].text, });
// });
state.isLoading = false; state.isLoading = false;
return; return;
} }
...@@ -331,17 +334,26 @@ class HomeController extends GetxController { ...@@ -331,17 +334,26 @@ class HomeController extends GetxController {
// state.messageList.value[0].text = state.messageList.value[0].text + text; // state.messageList.value[0].text = state.messageList.value[0].text + text;
} }
share() async { reset() async {
final text = rotateIcon();
state.messageList.reversed.map((element) => element.text).join('\n\n'); try {
print(text); await UserAPI.resetConversion();
// state.messageQueenItemQueen.map((element) => element.text).join(""); EasyLoading.showToast('重置成功');
if (text.isNotEmpty) { } catch (e) {}
await Share.share(
text,
// sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
);
} }
share() async {
Get.toNamed(AppRoutes.MY_PAGE);
// final text =
// state.messageList.reversed.map((element) => element.text).join('\n\n');
// print(text);
// // state.messageQueenItemQueen.map((element) => element.text).join("");
// if (text.isNotEmpty) {
// await Share.share(
// text,
// // sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
// );
// }
} }
tabMessage(ChatMessage message) { tabMessage(ChatMessage message) {
...@@ -376,15 +388,30 @@ class HomeController extends GetxController { ...@@ -376,15 +388,30 @@ class HomeController extends GetxController {
// http://192.168.110.127:8083/api/openAi/connect // http://192.168.110.127:8083/api/openAi/connect
// await initEventSource(); // await initEventSource();
super.onInit(); super.onInit();
_controller =
AnimationController(vsync: this, duration: Duration(seconds: 1));
_animation = Tween<double>(begin: 0, end: 1).animate(_controller);
// ever(Get.parameters['question'].obs, (value) { // ever(Get.parameters['question'].obs, (value) {
// print("messageListmessageListmessageListmessageList$value"); // print("messageListmessageListmessageListmessageList$value");
// }); // });
} }
Animation<double> get animation => _animation;
void rotateIcon() {
if (_isRotated) {
_controller.reverse();
} else {
_controller.forward();
}
_isRotated = !_isRotated;
update();
}
///dispose 释放内存 ///dispose 释放内存
@override @override
void dispose() { void dispose() {
_controller.dispose();
super.dispose(); super.dispose();
// dispose 释放对象 // dispose 释放对象
// refreshController.dispose(); // refreshController.dispose();
......
...@@ -29,10 +29,23 @@ class HomePage extends GetView<HomeController> { ...@@ -29,10 +29,23 @@ class HomePage extends GetView<HomeController> {
backgroundColor: Color.fromARGB(0, 0, 0, 0), backgroundColor: Color.fromARGB(0, 0, 0, 0),
appBar: transparentAppBar( appBar: transparentAppBar(
actions: [ actions: [
RotationTransition(
turns: controller.animation,
child: IconButton(
tooltip: '重置',
icon: const Icon(
Icons.settings_backup_restore_sharp,
color: AppColors.primaryElementText,
),
onPressed: () {
controller.reset();
},
),
),
IconButton( IconButton(
tooltip: '分享', tooltip: '设置',
icon: const Icon( icon: const Icon(
Icons.share, Icons.settings,
color: AppColors.primaryElementText, color: AppColors.primaryElementText,
), ),
onPressed: () { onPressed: () {
...@@ -41,6 +54,7 @@ class HomePage extends GetView<HomeController> { ...@@ -41,6 +54,7 @@ class HomePage extends GetView<HomeController> {
) )
], ],
title: RichText( title: RichText(
textAlign: TextAlign.center,
text: TextSpan(children: [ text: TextSpan(children: [
TextSpan( TextSpan(
text: "${controller.state.page}", text: "${controller.state.page}",
...@@ -55,8 +69,8 @@ class HomePage extends GetView<HomeController> { ...@@ -55,8 +69,8 @@ class HomePage extends GetView<HomeController> {
style: TextStyle(fontSize: 0)), style: TextStyle(fontSize: 0)),
])), ])),
leading: GradientButton( leading: GradientButton(
// increaseHeightBy: -5, increaseHeightBy: -5,
// increaseWidthBy: -5, increaseWidthBy: 105,
elevation: 0, elevation: 0,
shadowColor: Colors.black, shadowColor: Colors.black,
gradient: const LinearGradient( gradient: const LinearGradient(
...@@ -72,7 +86,7 @@ class HomePage extends GetView<HomeController> { ...@@ -72,7 +86,7 @@ class HomePage extends GetView<HomeController> {
Icon( Icon(
Icons.add_circle, Icons.add_circle,
color: Colors.black, color: Colors.black,
size: 35, size: 30,
), ),
SizedBox( SizedBox(
width: 10, width: 10,
...@@ -84,19 +98,7 @@ class HomePage extends GetView<HomeController> { ...@@ -84,19 +98,7 @@ class HomePage extends GetView<HomeController> {
]), ]),
callback: () { callback: () {
Get.toNamed(AppRoutes.PAY_LIST); Get.toNamed(AppRoutes.PAY_LIST);
}) }),
// IconButton(
// tooltip: '返回上一页',
// icon: const Icon(
// Icons.arrow_back,
// color: AppColors.primaryElementText,
// ),
// onPressed: () {
// // Get.back();
// controller.closeChat();
// },
// ),
), ),
body: SizedBox( body: SizedBox(
width: double.infinity, width: double.infinity,
...@@ -107,13 +109,13 @@ class HomePage extends GetView<HomeController> { ...@@ -107,13 +109,13 @@ class HomePage extends GetView<HomeController> {
// color: Color.fromARGB(0, 29, 33, 60), // color: Color.fromARGB(0, 29, 33, 60),
// color: Color.fromARGB(255, 26, 27, 46), // color: Color.fromARGB(255, 26, 27, 46),
child: Chat.DashChat( child: Chat.DashChat(
inputOptions: Chat.InputOptions( inputOptions: const Chat.InputOptions(
textInputAction: TextInputAction.send, textInputAction: TextInputAction.send,
sendOnEnter: true, sendOnEnter: true,
// showTraillingBeforeSend: true, // showTraillingBeforeSend: true,
// inputDisabled: cc.state.isLoading, // inputDisabled: cc.state.isLoading,
inputTextStyle: const TextStyle(color: Colors.white), inputTextStyle: TextStyle(color: Colors.white),
inputToolbarStyle: const BoxDecoration( inputToolbarStyle: BoxDecoration(
color: Color.fromARGB(120, 0, 0, 0), color: Color.fromARGB(120, 0, 0, 0),
// Color.fromARGB(0, 54, 59, 72), // Color.fromARGB(0, 54, 59, 72),
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
...@@ -122,8 +124,8 @@ class HomePage extends GetView<HomeController> { ...@@ -122,8 +124,8 @@ class HomePage extends GetView<HomeController> {
), ),
inputToolbarMargin: EdgeInsets.all(0), inputToolbarMargin: EdgeInsets.all(0),
sendButtonBuilder: null, sendButtonBuilder: null,
inputToolbarPadding: const EdgeInsets.only( inputToolbarPadding:
top: 15, right: 15, left: 15, bottom: 10), EdgeInsets.only(top: 15, right: 15, left: 15, bottom: 10),
), ),
currentUser: _user, currentUser: _user,
onSend: cc.sendMessage, onSend: cc.sendMessage,
......
import 'package:chart/common/routers/routes.dart';
import 'package:chart/common/store/store.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:gradient_widgets/gradient_widgets.dart';
import 'index.dart'; import 'index.dart';
...@@ -8,8 +11,172 @@ class MyPage extends GetView<MyController> { ...@@ -8,8 +11,172 @@ class MyPage extends GetView<MyController> {
// 主视图 // 主视图
Widget _buildView() { Widget _buildView() {
return const Center( final c = Get.put(UserStore());
child: Text("MyPage"), return ListView(
padding: EdgeInsets.symmetric(horizontal: 10),
children: [
Obx(() => c.profile.expireTime == null
? const Text(
"您还不是 VIP 会员",
style: TextStyle(
color: Color.fromARGB(255, 160, 165, 184),
fontSize: 14,
),
)
: Align(
alignment: Alignment.center,
child: Container(
// color: Colors.amber,
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 0),
child: RichText(
textAlign: TextAlign.center,
text: TextSpan(children: [
const TextSpan(
text: '您的VIP会员资格将于',
style: TextStyle(
color: Color.fromARGB(255, 160, 165, 184),
fontSize: 14,
),
),
TextSpan(
text:
" ${c.profile.expireTime.year}-${c.profile.expireTime.month}-${c.profile.expireTime.day} "),
const TextSpan(
text: '过期,如果您是自动续费会员将会在过期日前一天自动续费。',
style: TextStyle(
color: Color.fromARGB(255, 160, 165, 184),
fontSize: 14,
),
),
// Text(
// "您的VIP会员资格将于" +
// "${c.profile.expireTime.year}-${c.profile.expireTime.month}-${c.profile.expireTime.day}" +
// "过期,如果您是自动续费会员将会在过期日前一天自动续费。",
// textAlign: TextAlign.center,
// style: TextStyle(
// color: color,
// fontSize: 14,
// ),
// )
])),
),
)),
Container(
margin: EdgeInsets.only(top: 20),
child: InkWell(
onTap: () {
Get.toNamed(AppRoutes.PAY_LIST);
},
child: Ink(
width: Get.width,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10)),
gradient: const LinearGradient(
colors: [
Color(0xFF3d3f54),
Color(0xFF333450),
Color(0xFF2b2b4d)
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Icon(Icons.monetization_on_outlined),
SizedBox(
width: 10,
),
Text('购买订阅')
],
),
Icon(Icons.arrow_forward_ios_outlined),
]),
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 15),
),
),
),
Container(
margin: EdgeInsets.only(top: 20),
child: InkWell(
onTap: () {
Get.toNamed(AppRoutes.USER_EULA);
},
child: Ink(
width: Get.width,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10)),
gradient: const LinearGradient(
colors: [
Color(0xFF3d3f54),
Color(0xFF333450),
Color(0xFF2b2b4d)
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Icon(Icons.list),
SizedBox(
width: 10,
),
Text('服务协议')
],
),
Icon(Icons.arrow_forward_ios_outlined),
]),
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 15),
),
),
),
Container(
margin: EdgeInsets.only(top: 20),
child: InkWell(
onTap: () {
Get.toNamed(AppRoutes.PRIVACT);
},
child: Ink(
width: Get.width,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10)),
gradient: const LinearGradient(
colors: [
Color(0xFF3d3f54),
Color(0xFF333450),
Color(0xFF2b2b4d)
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Icon(Icons.list),
SizedBox(
width: 10,
),
Text('隐私政策')
],
),
Icon(Icons.arrow_forward_ios_outlined),
]),
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 15),
),
),
)
// GradientButton(child: Text("321"), callback: () {})
],
); );
} }
...@@ -19,17 +186,27 @@ class MyPage extends GetView<MyController> { ...@@ -19,17 +186,27 @@ class MyPage extends GetView<MyController> {
init: MyController(), init: MyController(),
id: "my", id: "my",
builder: (_) { builder: (_) {
return Scaffold( return Container(
// color: Colors.amber,
height: double.infinity,
// width: Get.width,
decoration: BoxDecoration(
image: DecorationImage(
image: Image.asset("assets/images/background.png").image,
fit: BoxFit.cover),
),
child: Scaffold(
backgroundColor: Color.fromARGB(0, 29, 33, 60), backgroundColor: Color.fromARGB(0, 29, 33, 60),
appBar: AppBar( appBar: AppBar(
elevation: 0, elevation: 0,
title: const Text("我的"), title: const Text("设置"),
bottomOpacity: 0.1, bottomOpacity: 0.1,
backgroundColor: Color.fromARGB(0, 29, 33, 60), backgroundColor: Color.fromARGB(0, 29, 33, 60),
), ),
body: SafeArea( body: SafeArea(
child: _buildView(), child: _buildView(),
), ),
),
); );
}, },
); );
......
...@@ -49,7 +49,7 @@ class PrivacyPage extends GetView<PrivacyController> { ...@@ -49,7 +49,7 @@ class PrivacyPage extends GetView<PrivacyController> {
return GetBuilder<PrivacyController>( return GetBuilder<PrivacyController>(
builder: (_) { builder: (_) {
return Scaffold( return Scaffold(
appBar: transparentAppBar( appBar: AppBar(
leading: IconButton( leading: IconButton(
tooltip: '返回上一页', tooltip: '返回上一页',
icon: const Icon( icon: const Icon(
......
...@@ -9,6 +9,7 @@ import connectivity_plus ...@@ -9,6 +9,7 @@ import connectivity_plus
import device_info_plus import device_info_plus
import firebase_auth import firebase_auth
import firebase_core import firebase_core
import flutter_tts
import package_info import package_info
import path_provider_foundation import path_provider_foundation
import share_plus import share_plus
...@@ -23,6 +24,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { ...@@ -23,6 +24,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
FlutterTtsPlugin.register(with: registry.registrar(forPlugin: "FlutterTtsPlugin"))
FLTPackageInfoPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlugin")) FLTPackageInfoPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
......
...@@ -120,6 +120,13 @@ packages: ...@@ -120,6 +120,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.1" version: "1.2.1"
clipboard:
dependency: "direct main"
description:
name: clipboard
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
clock: clock:
dependency: transitive dependency: transitive
description: description:
...@@ -218,6 +225,13 @@ packages: ...@@ -218,6 +225,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.3" version: "1.0.3"
custom_pop_up_menu:
dependency: "direct main"
description:
name: custom_pop_up_menu
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.4"
dash_chat_2: dash_chat_2:
dependency: "direct main" dependency: "direct main"
description: description:
...@@ -618,6 +632,13 @@ packages: ...@@ -618,6 +632,13 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_tts:
dependency: "direct main"
description:
name: flutter_tts
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.3"
flutter_vibrate: flutter_vibrate:
dependency: "direct main" dependency: "direct main"
description: description:
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <connectivity_plus/connectivity_plus_windows_plugin.h> #include <connectivity_plus/connectivity_plus_windows_plugin.h>
#include <flutter_tts/flutter_tts_plugin.h>
#include <share_plus/share_plus_windows_plugin_c_api.h> #include <share_plus/share_plus_windows_plugin_c_api.h>
#include <smart_auth/smart_auth_plugin.h> #include <smart_auth/smart_auth_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h> #include <url_launcher_windows/url_launcher_windows.h>
...@@ -14,6 +15,8 @@ ...@@ -14,6 +15,8 @@
void RegisterPlugins(flutter::PluginRegistry* registry) { void RegisterPlugins(flutter::PluginRegistry* registry) {
ConnectivityPlusWindowsPluginRegisterWithRegistrar( ConnectivityPlusWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
FlutterTtsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterTtsPlugin"));
SharePlusWindowsPluginCApiRegisterWithRegistrar( SharePlusWindowsPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi")); registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi"));
SmartAuthPluginRegisterWithRegistrar( SmartAuthPluginRegisterWithRegistrar(
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
connectivity_plus connectivity_plus
flutter_tts
share_plus share_plus
smart_auth smart_auth
url_launcher_windows url_launcher_windows
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment