Commit 7779fc2d authored by 关振斌's avatar 关振斌

update style

parent 2ffc9c3c
PODS:
- alipay_kit_ios (5.0.0):
- alipay_kit_ios/utdid (= 5.0.0)
- alipay_kit_ios/vendor (= 5.0.0)
- Flutter
- alipay_kit_ios/utdid (5.0.0):
- Flutter
- alipay_kit_ios/vendor (5.0.0):
- Flutter
- "app_settings (3.0.0+1)":
- Flutter
- babstrap_settings_screen (0.0.1):
......@@ -150,7 +142,6 @@ PODS:
- Flutter
DEPENDENCIES:
- alipay_kit_ios (from `.symlinks/plugins/alipay_kit_ios/ios`)
- app_settings (from `.symlinks/plugins/app_settings/ios`)
- babstrap_settings_screen (from `.symlinks/plugins/babstrap_settings_screen/ios`)
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
......@@ -198,8 +189,6 @@ SPEC REPOS:
- Toast
EXTERNAL SOURCES:
alipay_kit_ios:
:path: ".symlinks/plugins/alipay_kit_ios/ios"
app_settings:
:path: ".symlinks/plugins/app_settings/ios"
babstrap_settings_screen:
......@@ -256,7 +245,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/webview_flutter_wkwebview/ios"
SPEC CHECKSUMS:
alipay_kit_ios: bfa484b12d4690cc48a803f39ed5fb58fa774d2e
app_settings: d103828c9f5d515c4df9ee754dabd443f7cedcf3
babstrap_settings_screen: 535097da0fa521a47fef6f6678ff2b464ee15937
connectivity_plus: 413a8857dd5d9f1c399a39130850d02fe0feaf7e
......
import 'package:chart/common/entities/detail.dart';
import 'package:chart/common/entities/entities.dart';
import 'package:chart/common/entities/selectAllEntity.dart';
import 'package:chart/common/utils/utils.dart';
import '../../entity/login_entity.dart';
......@@ -87,6 +89,42 @@ class UserAPI {
// return ApplePayEntity.fromMap(response['data']);
}
//无上下文对话
static Future<int> sceneAsk(Map<String, dynamic> parameters) async {
var response = await HttpUtil().post(
'/openAi/aiAnswerWithStream',
data: parameters,
);
return response['status'];
// return ApplePayEntity.fromMap(response['data']);
}
//获取所有列表
static Future<SelectAllEntity> selectAll() async {
var response = await HttpUtil().get(
'/classifyDetail/selectAll',
);
// goodEntityFromList(response['data']);
return SelectAllEntity.fromJson(response);
// return ApplePayEntity.fromMap(response['data']);
}
static Future<DetailEntity> getDetailParamsByDetailId(detailId) async {
var response = await HttpUtil().post(
'/detailParams/getDetailParamsByDetailId/$detailId',
);
// goodEntityFromList(response['data']);
return DetailEntity.fromJson(response);
// return ApplePayEntity.fromMap(response['data']);
}
// detailParams/getDetailParamsByDetailId/12
//
///api/ 保存问题
static Future<int> saveResp(Map<String, dynamic> parameters) async {
var response = await HttpUtil().post(
......
class DetailEntity {
int? _status;
String? _message;
List<DetailData>? _data;
int? _timestamp;
DetailEntity(
{int? status, String? message, List<DetailData>? 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<DetailData>? get data => _data;
set data(List<DetailData>? data) => _data = data;
int? get timestamp => _timestamp;
set timestamp(int? timestamp) => _timestamp = timestamp;
DetailEntity.fromJson(Map<String, dynamic> json) {
_status = json['status'];
_message = json['message'];
if (json['data'] != null) {
_data = <DetailData>[];
json['data'].forEach((v) {
_data!.add(new DetailData.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 DetailData {
int? _id;
String? _label;
String? _placeHolder;
int? _detailId;
String? _createTime;
String? _updateTime;
int? _isDelete;
int? _isShow;
Null? _value;
int? _sort;
DetailData(
{int? id,
String? label,
String? placeHolder,
int? detailId,
String? createTime,
String? updateTime,
int? isDelete,
int? isShow,
Null? value,
int? sort}) {
if (id != null) {
this._id = id;
}
if (label != null) {
this._label = label;
}
if (placeHolder != null) {
this._placeHolder = placeHolder;
}
if (detailId != null) {
this._detailId = detailId;
}
if (createTime != null) {
this._createTime = createTime;
}
if (updateTime != null) {
this._updateTime = updateTime;
}
if (isDelete != null) {
this._isDelete = isDelete;
}
if (isShow != null) {
this._isShow = isShow;
}
if (value != null) {
this._value = value;
}
if (sort != null) {
this._sort = sort;
}
}
int? get id => _id;
set id(int? id) => _id = id;
String? get label => _label;
set label(String? label) => _label = label;
String? get placeHolder => _placeHolder;
set placeHolder(String? placeHolder) => _placeHolder = placeHolder;
int? get detailId => _detailId;
set detailId(int? detailId) => _detailId = detailId;
String? get createTime => _createTime;
set createTime(String? createTime) => _createTime = createTime;
String? get updateTime => _updateTime;
set updateTime(String? updateTime) => _updateTime = updateTime;
int? get isDelete => _isDelete;
set isDelete(int? isDelete) => _isDelete = isDelete;
int? get isShow => _isShow;
set isShow(int? isShow) => _isShow = isShow;
Null? get value => _value;
set value(Null? value) => _value = value;
int? get sort => _sort;
set sort(int? sort) => _sort = sort;
DetailData.fromJson(Map<String, dynamic> json) {
_id = json['id'];
_label = json['label'];
_placeHolder = json['placeHolder'];
_detailId = json['detailId'];
_createTime = json['createTime'];
_updateTime = json['updateTime'];
_isDelete = json['isDelete'];
_isShow = json['isShow'];
_value = json['value'];
_sort = json['sort'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this._id;
data['label'] = this._label;
data['placeHolder'] = this._placeHolder;
data['detailId'] = this._detailId;
data['createTime'] = this._createTime;
data['updateTime'] = this._updateTime;
data['isDelete'] = this._isDelete;
data['isShow'] = this._isShow;
data['value'] = this._value;
data['sort'] = this._sort;
return data;
}
}
class SelectAllEntity {
int? _status;
String? _message;
List<SelectEntity>? _data;
int? _timestamp;
SelectAllEntity(
{int? status,
String? message,
List<SelectEntity>? 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<SelectEntity>? get data => _data;
set data(List<SelectEntity>? data) => _data = data;
int? get timestamp => _timestamp;
set timestamp(int? timestamp) => _timestamp = timestamp;
SelectAllEntity.fromJson(Map<String, dynamic> json) {
_status = json['status'];
_message = json['message'];
if (json['data'] != null) {
_data = <SelectEntity>[];
json['data'].forEach((v) {
_data!.add(new SelectEntity.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 SelectEntity {
int? _id;
String? _detailName;
int? _classifyId;
String? _detailDesc;
String? _createTime;
String? _updateTime;
int? _isDelete;
int? _isShow;
String? _template;
String? _icon;
int? _count;
SelectEntity(
{int? id,
String? detailName,
int? classifyId,
String? detailDesc,
String? createTime,
String? updateTime,
int? isDelete,
int? isShow,
String? template,
String? icon,
int? count}) {
if (id != null) {
this._id = id;
}
if (detailName != null) {
this._detailName = detailName;
}
if (classifyId != null) {
this._classifyId = classifyId;
}
if (detailDesc != null) {
this._detailDesc = detailDesc;
}
if (createTime != null) {
this._createTime = createTime;
}
if (updateTime != null) {
this._updateTime = updateTime;
}
if (isDelete != null) {
this._isDelete = isDelete;
}
if (isShow != null) {
this._isShow = isShow;
}
if (template != null) {
this._template = template;
}
if (icon != null) {
this._icon = icon;
}
if (count != null) {
this._count = count;
}
}
int? get id => _id;
set id(int? id) => _id = id;
String? get detailName => _detailName;
set detailName(String? detailName) => _detailName = detailName;
int? get classifyId => _classifyId;
set classifyId(int? classifyId) => _classifyId = classifyId;
String? get detailDesc => _detailDesc;
set detailDesc(String? detailDesc) => _detailDesc = detailDesc;
String? get createTime => _createTime;
set createTime(String? createTime) => _createTime = createTime;
String? get updateTime => _updateTime;
set updateTime(String? updateTime) => _updateTime = updateTime;
int? get isDelete => _isDelete;
set isDelete(int? isDelete) => _isDelete = isDelete;
int? get isShow => _isShow;
set isShow(int? isShow) => _isShow = isShow;
String? get template => _template;
set template(String? template) => _template = template;
String? get icon => _icon;
set icon(String? icon) => _icon = icon;
int? get count => _count;
set count(int? count) => _count = count;
SelectEntity.fromJson(Map<String, dynamic> json) {
_id = json['id'];
_detailName = json['detailName'];
_classifyId = json['classifyId'];
_detailDesc = json['detailDesc'];
_createTime = json['createTime'];
_updateTime = json['updateTime'];
_isDelete = json['isDelete'];
_isShow = json['isShow'];
_template = json['template'];
_icon = json['icon'];
_count = json['count'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this._id;
data['detailName'] = this._detailName;
data['classifyId'] = this._classifyId;
data['detailDesc'] = this._detailDesc;
data['createTime'] = this._createTime;
data['updateTime'] = this._updateTime;
data['isDelete'] = this._isDelete;
data['isShow'] = this._isShow;
data['template'] = this._template;
data['icon'] = this._icon;
data['count'] = this._count;
return data;
}
}
......@@ -15,5 +15,11 @@ class AppRoutes {
static const USER_PRIVACT = '/user_privacy';
static const WILL_COME = '/will_come';
static const USER_EULA = '/eula';
static const HOME_PAGE = '/home';
static const CREATION_PAGE = '/creation';
static const CREATION_PAGE_DETAIL = '/creation-detail';
static const ASSISTANT_PAGE = '/assistant';
static const MY_PAGE = '/my';
// UserPrivacyPage
}
import 'package:chart/pages/assistant/index.dart';
import 'package:chart/pages/chat/view.dart';
import 'package:chart/pages/creation-detail/index.dart';
import 'package:chart/pages/creation/index.dart';
import 'package:chart/pages/eula/bindings.dart';
import 'package:chart/pages/eula/view.dart';
import 'package:chart/pages/frame/android_pay_list/view.dart';
import 'package:chart/pages/frame/notfound/index.dart';
import 'package:chart/pages/frame/pay_list/view.dart';
import 'package:chart/pages/home/index.dart';
import 'package:chart/pages/my/index.dart';
import 'package:chart/pages/privacy/index.dart';
import 'package:chart/pages/template/index.dart';
import 'package:chart/pages/user_privacy/index.dart';
......@@ -158,6 +163,33 @@ class AppPages {
page: () => CategoryPage(),
binding: CategoryBinding(),
),
//重构UI
GetPage(
name: AppRoutes.HOME_PAGE,
page: () => HomePage(),
binding: HomeBinding(),
),
GetPage(
name: AppRoutes.CREATION_PAGE,
page: () => CreationPage(),
binding: CreationBinding(),
),
GetPage(
name: AppRoutes.ASSISTANT_PAGE,
page: () => AssistantPage(),
binding: AssistantBinding(),
),
GetPage(
name: AppRoutes.MY_PAGE,
page: () => MyPage(),
binding: MyBinding(),
),
GetPage(
name: AppRoutes.CREATION_PAGE_DETAIL,
page: () => const CreationDetailPage(),
binding: CreationDetailBinding(),
)
];
// static final unknownRoute = GetPage(
......
......@@ -95,6 +95,7 @@ class UserStore extends GetxController {
}
Future refreshInfo() async {
if (GetPlatform.isIOS) {
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
final res = await UserAPI.appleLogin({
......@@ -117,6 +118,7 @@ class UserStore extends GetxController {
await MainController.to.asyncLoadBannerData();
}
}
handleLogin(IntegralEntity res) async {
await setToken(res.token);
......
......@@ -9,9 +9,11 @@ AppBar transparentAppBar({
List<Widget>? actions,
}) {
return AppBar(
backgroundColor: Color.fromRGBO(41, 45, 62, 1.00),
backgroundColor: Color.fromARGB(0, 0, 0, 0),
// elevation: 2,
title: title,
elevation: 0,
leadingWidth: 115,
leading: leading ?? null,
actions: actions,
);
......
import 'package:chart/pages/frame/product/bindings.dart';
import 'package:chart/pages/home/index.dart';
import 'package:flutter/material.dart';
import 'package:chart/common/langs/translation_service.dart';
import 'package:chart/common/routers/pages.dart';
......@@ -33,11 +34,12 @@ class ChatApp extends StatelessWidget {
designSize: Size(375, 812),
builder: (context, child) => GetMaterialApp(
title: 'AI写作大师',
theme: AppTheme.light,
theme: ThemeData.dark(),
debugShowCheckedModeBanner: false,
initialRoute: AppPages.INITIAL,
// initialBinding: AllControllerBinding(),
darkTheme: ThemeData.dark(),
themeMode: ThemeMode.dark,
initialBinding: AllControllerBinding(),
getPages: AppPages.routes,
builder: EasyLoading.init(),
translations: TranslationService(),
......@@ -60,6 +62,7 @@ class AllControllerBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut(() => ProductBinding());
Get.lazyPut(() => HomeBinding());
///Get.lazyPut(() => OneController());
///Get.lazyPut(() => TwoController());
......
......@@ -13,6 +13,7 @@ import 'package:get/get_connect/http/src/utils/utils.dart';
import 'package:gradient_borders/input_borders/gradient_outline_input_border.dart';
import 'package:highlight/highlight.dart';
import 'package:intl/intl.dart' as intl;
import 'package:loading_animation_widget/loading_animation_widget.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:video_player/video_player.dart' as vp;
......
......@@ -48,7 +48,17 @@ InputDecoration defaultInputDecoration(
Color.fromRGBO(116, 112, 249, 1.00),
Color.fromRGBO(149, 197, 208, 1.00)
]),
width: 5,
width: 2,
),
disabledBorder: GradientOutlineInputBorder(
// rgba(140, 197, 208, 1.00)
borderRadius: BorderRadius.circular(10),
// ignore: prefer_const_literals_to_create_immutables
gradient: LinearGradient(colors: [
Color.fromRGBO(116, 112, 249, 1.00),
Color.fromRGBO(149, 197, 208, 1.00),
]),
width: 2,
),
// OutlineInputBorder(
// borderRadius:
......@@ -66,7 +76,7 @@ InputDecoration defaultInputDecoration(
Color.fromRGBO(116, 112, 249, 1.00),
Color.fromRGBO(149, 197, 208, 1.00)
]),
width: 5,
width: 2,
),
// focusedBorder: OutlineInputBorder(
// borderRadius: BorderRadius.circular(10),
......
......@@ -93,24 +93,11 @@ class _InputToolbarState extends State<InputToolbar>
Expanded(
child: Directionality(
textDirection: widget.inputOptions.inputTextDirection,
child: widget.inputOptions.inputDisabled
? Center(
child: AnimatedTextKit(
animatedTexts: [
TypewriterAnimatedText('AI正在生成中......',
textStyle: TextStyle(color: Colors.white)),
],
)
// Text("请稍等", style: TextStyle(color: Colors.white)
,
)
: TextField(
child: TextField(
focusNode: focusNode,
controller: textController,
enabled: !widget.inputOptions.inputDisabled,
textCapitalization:
widget.inputOptions.textCapitalization,
textCapitalization: widget.inputOptions.textCapitalization,
textInputAction: widget.inputOptions.textInputAction,
decoration: widget.inputOptions.inputDecoration ??
defaultInputDecoration(_sendMessage),
......
......@@ -74,6 +74,73 @@ class _MessageListState extends State<MessageList> {
final ChatMessage? nextMessage =
i > 0 ? widget.messages[i - 1] : null;
final ChatMessage message = widget.messages[i];
final bool isPlaceHolder = message.user.id == '0';
if (isPlaceHolder) {
//
return InkWell(
onTap: () {
scrollController.animateTo(
0.0,
duration: const Duration(milliseconds: 300),
curve: Curves.easeInOut,
);
widget.messageOptions.onPressMessage!(message);
},
child: Container(
margin: const EdgeInsets.only(
left: 10, right: 10, bottom: 20),
child: Column(
children: [
Row(
children: [
Icon(
Icons.timelapse_sharp,
color: Color.fromARGB(255, 117, 194, 245),
),
SizedBox(width: 10),
Text(message.customProperties!['title']),
],
),
Container(
padding: const EdgeInsets.symmetric(
vertical: 15, horizontal: 20),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
gradient: const LinearGradient(
colors: [
Color(0xFF3d3f54),
Color(0xFF333450),
Color(0xFF2b2b4d)
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
)),
margin: const EdgeInsets.only(top: 20),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
message.text,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: const TextStyle(
color: Color.fromARGB(
255, 170, 170, 194)),
)),
const Icon(
Icons.arrow_forward,
color: Color(0xFF9c67f6),
),
]),
)
],
),
),
);
}
final bool isAfterDateSeparator = _shouldShowDateSeparator(
previousMessage, message, widget.messageListOptions);
bool isBeforeDateSeparator = false;
......@@ -101,7 +168,6 @@ class _MessageListState extends State<MessageList> {
isBeforeDateSeparator,
),
] else
// Text('121')
MessageRow(
message: widget.messages[i],
nextMessage: nextMessage,
......@@ -160,7 +226,7 @@ class _MessageListState extends State<MessageList> {
: DefaultScrollToBottom(
scrollController: scrollController,
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
textColor: Theme.of(context).primaryColor,
textColor: Colors.white,
),
],
),
......
......@@ -49,18 +49,18 @@ class DefaultAvatar extends StatelessWidget {
child: Stack(
alignment: Alignment.center,
children: <Widget>[
ClipOval(
child: Container(
color: Colors.grey[200],
child: Image(
image: fallbackImage ??
const AssetImage(
'assets/images/logo.png',
// package: 'dash_chat_2',
),
),
),
),
// ClipOval(
// child: Container(
// color: Colors.grey[200],
// child: Image(
// image: fallbackImage ??
// const AssetImage(
// 'assets/images/logo.png',
// // package: 'dash_chat_2',
// ),
// ),
// ),
// ),
if (user.profileImage != null && user.profileImage!.isNotEmpty)
Center(
child: ClipOval(
......
......@@ -92,12 +92,13 @@ class DefaultMessageText extends StatelessWidget {
}
}
return <Widget>[
getParsePattern(message.text, isOwnMessage, messageLength, index)
getParsePattern(message.text, isOwnMessage, messageLength, index),
];
}
Widget getPostMessageBuild(String text, List<ChatMessage> messageLength,
bool isOwnMessage, int index) {
// text
// var lastMessage = messageLength.first;
// if(lastMessage.) {
......@@ -114,14 +115,24 @@ class DefaultMessageText extends StatelessWidget {
// child: Markdown(data: text, selectable: true),
// );
return MyMarkdown(
return text == 'LOADING'
? Row(
children: [
const Text("AI正在思考中"),
LoadingAnimationWidget.staggeredDotsWave(
color: Colors.white,
size: 20,
),
],
)
: MyMarkdown(
// syntaxHighlighter: SyntaxHighlighter(),
// styleConfig: StyleConfig(),
data: text,
// styleSheet: MarkdownStyleSheet(
// // code: TextStyle(color: Colors.red),
// ),
styleSheet: MarkdownStyleSheet(
p: TextStyle(color: Colors.white),
code: TextStyle(color: Colors.white),
),
);
// Column(
// children: [
......@@ -153,6 +164,7 @@ class DefaultMessageText extends StatelessWidget {
: defaultPersePatterns,
text: text,
style: TextStyle(
fontSize: 16,
color: isOwnMessage
? (messageOptions.currentUserTextColor ?? Colors.white)
: (messageOptions.textColor ?? Colors.black),
......
......@@ -42,17 +42,23 @@ class MessageRow extends StatelessWidget {
/// Get the avatar widget
Widget getAvatar() {
return messageOptions.avatarBuilder != null
? messageOptions.avatarBuilder!(
message.user,
messageOptions.onPressAvatar,
messageOptions.onLongPressAvatar,
)
: DefaultAvatar(
return DefaultAvatar(
user: message.user,
onLongPressAvatar: messageOptions.onLongPressAvatar,
onPressAvatar: messageOptions.onPressAvatar,
);
// messageOptions.avatarBuilder != null
// ? messageOptions.avatarBuilder!(
// message.user,
// messageOptions.onPressAvatar,
// messageOptions.onLongPressAvatar,
// )
// :
// DefaultAvatar(
// user: message.user,
// onLongPressAvatar: messageOptions.onLongPressAvatar,
// onPressAvatar: messageOptions.onPressAvatar,
// );
}
@override
......@@ -75,15 +81,15 @@ class MessageRow extends StatelessWidget {
mainAxisAlignment:
isOwnMessage ? MainAxisAlignment.end : MainAxisAlignment.start,
children: <Widget>[
// if (messageOptions.showOtherUsersAvatar)
// Opacity(
// opacity:
// !isOwnMessage && (!isNextSameAuthor || isBeforeDateSeparator)
// ? 1
// : 0,
// child: getAvatar(),
// ),
if (messageOptions.showOtherUsersAvatar)
Opacity(
opacity:
!isOwnMessage && (!isNextSameAuthor || isBeforeDateSeparator)
? 1
: 0,
child: getAvatar(),
),
if (!messageOptions.showOtherUsersAvatar)
const Padding(padding: EdgeInsets.only(left: 10)),
GestureDetector(
onLongPress: messageOptions.onLongPressMessage != null
......@@ -95,7 +101,7 @@ class MessageRow extends StatelessWidget {
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: messageOptions.maxWidth ??
MediaQuery.of(context).size.width * 0.7,
MediaQuery.of(context).size.width * 0.8,
),
child: Column(
crossAxisAlignment: isOwnMessage
......
......@@ -57,32 +57,52 @@ class TextContainer extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
decoration: messageOptions.messageDecorationBuilder != null
? messageOptions.messageDecorationBuilder!(
message, previousMessage, nextMessage)
: defaultMessageDecoration(
color: isOwnMessage
? (messageOptions.currentUserContainerColor ??
Theme.of(context).primaryColor)
: (messageOptions.containerColor ?? Colors.grey[100])!,
borderTopLeft:
isPreviousSameAuthor && !isOwnMessage && !isAfterDateSeparator
? 0.0
: 18.0,
borderTopRight:
isPreviousSameAuthor && isOwnMessage && !isAfterDateSeparator
? 0.0
: 18.0,
borderBottomLeft:
!isOwnMessage && !isBeforeDateSeparator && isNextSameAuthor
? 0.0
: 18.0,
borderBottomRight:
isOwnMessage && !isBeforeDateSeparator && isNextSameAuthor
? 0.0
: 18.0,
margin: EdgeInsets.only(bottom: index == 0 ? 20 : 0),
// background-image: linear-gradient(180deg, #be6afb, #9c67f6, #7965f8);
// background-image: linear-gradient(180deg, #3d3f54, #333450, #2b2b4d);
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: !isOwnMessage ? Radius.circular(0) : Radius.circular(20),
topRight: Radius.circular(20),
bottomLeft: Radius.circular(20),
bottomRight:
isOwnMessage ? Radius.circular(0) : Radius.circular(20)
// bottomRight:
// isOwnMessage ? Radius.circular(20) : Radius.circular(0),
),
padding: messageOptions.messagePadding ?? const EdgeInsets.all(11),
gradient: LinearGradient(
colors: isOwnMessage
? [Color(0xFFbe6afb), Color(0xFF9c67f6), Color(0xFF7965f8)]
: [Color(0xFF3d3f54), Color(0xFF333450), Color(0xFF2b2b4d)],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
)),
// decoration: messageOptions.messageDecorationBuilder != null
// ? messageOptions.messageDecorationBuilder!(
// message, previousMessage, nextMessage)
// : defaultMessageDecoration(
// color: isOwnMessage
// ? (messageOptions.currentUserContainerColor ??
// Theme.of(context).primaryColor)
// : (messageOptions.containerColor ?? Colors.grey[100])!,
// borderTopLeft:
// isPreviousSameAuthor && !isOwnMessage && !isAfterDateSeparator
// ? 0.0
// : 18.0,
// borderTopRight:
// isPreviousSameAuthor && isOwnMessage && !isAfterDateSeparator
// ? 0.0
// : 18.0,
// borderBottomLeft:
// !isOwnMessage && !isBeforeDateSeparator && isNextSameAuthor
// ? 0.0
// : 18.0,
// borderBottomRight:
// isOwnMessage && !isBeforeDateSeparator && isNextSameAuthor
// ? 0.0
// : 18.0,
// ),
padding: messageOptions.messagePadding ?? const EdgeInsets.all(16),
child: DefaultMessageText(
index: index,
messageLength: messageLength,
......
......@@ -126,58 +126,43 @@ class ApplicationController extends GetxController {
// handleIncomingLinks();
// 准备一些静态数据
tabTitles = ['首页', '我的聊天', '个人中心'];
tabTitles = ['AI对话', '创作', '私人助理', '我的'];
bottomTabs = <BottomNavigationBarItem>[
new BottomNavigationBarItem(
icon: Icon(
Iconfont.fav,
color: AppColors.tabBarElement,
),
activeIcon: Icon(
Iconfont.home,
color: AppColors.secondaryElementText,
),
label: '首页',
// ignore: unnecessary_new
const BottomNavigationBarItem(
icon: Image(image: AssetImage("assets/images/home.png"), width: 24.0),
activeIcon: Image(
image: AssetImage("assets/images/home-selected.png"), width: 24.0),
label: '百晓通',
backgroundColor: AppColors.primaryBackground,
),
new BottomNavigationBarItem(
icon: Icon(
Iconfont.grid,
color: AppColors.tabBarElement,
),
activeIcon: Icon(
Iconfont.grid,
color: AppColors.secondaryElementText,
),
label: '我的聊天',
const BottomNavigationBarItem(
icon:
Image(image: AssetImage("assets/images/product.png"), width: 24.0),
activeIcon: Image(
image: AssetImage("assets/images/product-selected.png"),
width: 24.0),
label: '创作',
backgroundColor: AppColors.primaryBackground,
),
// new BottomNavigationBarItem(
// icon: Icon(
// Iconfont.tag,
// color: AppColors.tabBarElement,
// ),
// activeIcon: Icon(
// Iconfont.tag,
// color: AppColors.secondaryElementText,
// ),
// label: 'tag',
// backgroundColor: AppColors.primaryBackground,
// ),
new BottomNavigationBarItem(
icon: Icon(
Iconfont.me,
color: AppColors.tabBarElement,
),
activeIcon: Icon(
Iconfont.me,
color: AppColors.secondaryElementText,
const BottomNavigationBarItem(
icon: Image(
image: AssetImage("assets/images/assistant.png"), width: 24.0),
activeIcon: Image(
image: AssetImage("assets/images/assistant-selected.png"),
width: 24.0),
label: '私人助理',
backgroundColor: AppColors.primaryBackground,
),
label: '个人中心',
const BottomNavigationBarItem(
icon: Image(image: AssetImage("assets/images/my.png"), width: 24.0),
activeIcon: Image(
image: AssetImage("assets/images/my-selected.png"), width: 24.0),
label: '我的',
backgroundColor: AppColors.primaryBackground,
),
];
pageController = new PageController(initialPage: state.page);
pageController = PageController(initialPage: state.page);
}
@override
......
import 'package:chart/pages/assistant/index.dart';
import 'package:chart/pages/creation/index.dart';
import 'package:chart/pages/home/index.dart';
import 'package:chart/pages/my/index.dart';
import 'package:flutter/material.dart';
import 'package:chart/common/values/values.dart';
import 'package:chart/common/widgets/widgets.dart';
......@@ -37,21 +41,16 @@ class ApplicationPage extends GetView<ApplicationController> {
// 内容页
Widget _buildPageView() {
return PageView(
physics: NeverScrollableScrollPhysics(),
children: <Widget>[
MainPage(),
// DashBoardPage(),
// Text("data"),
// Text("da"),
// MainPage(),
CategoryPage(),
UserDetailPage()
// Text('BookmarksPage'),
// Text('AccountPage'),
],
physics: const NeverScrollableScrollPhysics(),
controller: controller.pageController,
onPageChanged: controller.handlePageChanged,
);
// children: <Widget>[MainPage(), CategoryPage(), UserDetailPage()],
children: <Widget>[
HomePage(),
CreationPage(),
AssistantPage(),
MyPage()
]);
}
// 底部导航
......@@ -104,29 +103,45 @@ class ApplicationPage extends GetView<ApplicationController> {
// letIndexChange: (index) => true,
// ),
return Obx(() => BottomNavigationBar(
// #363b48
backgroundColor: Color.fromARGB(0, 54, 59, 72),
//
// Color.fromARGB(255, 54, 59, 72),
// Color.argb(255, 82, 88, 103)
fixedColor: Colors.white,
elevation: 0,
// Color(0x363b48FF),
items: controller.bottomTabs,
currentIndex: controller.state.page,
// fixedColor: AppColors.primaryElement,
type: BottomNavigationBarType.fixed,
onTap: controller.handleNavBarTap,
showSelectedLabels: false,
showUnselectedLabels: false,
));
showSelectedLabels: true,
showUnselectedLabels: true,
selectedLabelStyle: TextStyle(
fontSize: 12,
)));
}
@override
Widget build(BuildContext context) {
return Obx(() => Scaffold(
appBar: controller.state.page == 0 ? null : _buildAppBar(),
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: _buildAppBar(),
body: _buildPageView(),
bottomNavigationBar: _buildBottomNavigationBar(),
floatingActionButton: FloatingActionButton(
// elevation: 6.0,
// highlightElevation: 12.0,
child: Icon(Icons.chat),
onPressed: controller.handleChat,
),
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
));
// floatingActionButton: FloatingActionButton(
// child: Icon(Icons.chat),
// onPressed: controller.handleChat,
// ),
// floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
)),
);
}
}
import 'package:get/get.dart';
import 'controller.dart';
class AssistantBinding implements Bindings {
@override
void dependencies() {
Get.lazyPut<AssistantController>(() => AssistantController());
}
}
import 'package:get/get.dart';
class AssistantController extends GetxController {
AssistantController();
_initData() {
update(["assistant"]);
}
void onTap() {}
// @override
// void onInit() {
// super.onInit();
// }
@override
void onReady() {
super.onReady();
_initData();
}
// @override
// void onClose() {
// super.onClose();
// }
}
library assistant;
export './controller.dart';
export './view.dart';
export './bindings.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'index.dart';
import 'widgets/widgets.dart';
class AssistantPage extends GetView<AssistantController> {
const AssistantPage({Key? key}) : super(key: key);
// 主视图
Widget _buildView() {
return GridWidget();
}
@override
Widget build(BuildContext context) {
return GetBuilder<AssistantController>(
init: AssistantController(),
id: "assistant",
builder: (_) {
return Scaffold(
backgroundColor: Color.fromARGB(0, 29, 33, 60),
// appBar: AppBar(title: const Text("assistant"), elevation: 0),
body: SafeArea(
child: _buildView(),
),
);
},
);
}
}
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:chart/common/values/values.dart';
import 'package:flutter_vibrate/flutter_vibrate.dart';
import 'package:get/get.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gradient_widgets/gradient_widgets.dart';
import '../index.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
class GridWidget extends GetView<AssistantController> {
@override
Widget build(BuildContext context) {
return CustomScrollView(
slivers: [
SliverPersistentHeader(
pinned: true, //是否固定在顶部
floating: true,
delegate: _SliverAppBarDelegate(
minHeight: Get.height * .16,
maxHeight: Get.height * .156,
child: Opacity(
opacity: .8,
child: Image.network(
width: double.infinity,
'https://www.hahagpt.com/images/assets/banner2.png',
height: Get.height * .16,
fit: BoxFit.cover
// ignore: prefer_const_constructors
// placeholder: CircularProgressIndicator(),
// errorWidget: Icon(Icons.error),
),
//
// child:
// Container(
// padding: EdgeInsets.only(left: 16),
// color: Colors.pink,
// alignment: Alignment.centerLeft,
// child: Text("浮动", style: TextStyle(fontSize: 18)),
// ),
)),
),
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return Container(
padding: const EdgeInsets.only(
left: 10,
right: 10,
),
margin: const EdgeInsets.only(
top: 10,
bottom: 20,
),
child: StaggeredGrid.count(
crossAxisCount: 1,
mainAxisSpacing: 20,
crossAxisSpacing: 10,
children: List.generate(100, (index) {
return StaggeredGridTile.count(
crossAxisCellCount: 1,
mainAxisCellCount: 0.31,
child: Container(
// margin: EdgeInsets.only(bottom: 20),
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
// ignore: prefer_const_constructors
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
// background-image: linear-gradient(180deg, #3d3f54, #333450, #2b2b4d);
colors: const [
Color(0xFF3d3f54),
Color(0xFF333450),
Color(0xFF2b2b4d)
]),
),
child: Row(
children: [
Image.network(
'https://www.hahagpt.com/images/yiliao.jpg'),
Expanded(
child: Container(
// color: Colors.red,
margin: const EdgeInsets.only(
left: 10,
),
child: Column(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text('语言翻译'),
GradientButton(
child: Text('咨询',
style: TextStyle(
fontSize: 10)),
increaseHeightBy: -5.00,
increaseWidthBy: -10.00,
callback: () {},
// controller.requestPurchase,
gradient:
Gradients.cosmicFusion,
// shadowColor: Gradients
// .backToFuture.colors.last
// .withOpacity(0.25),
)
]),
Text(
"下面我让你来充当翻译家,你的目标是把任何语言翻译成英文,请翻译时不要带翻译腔,而是要翻译得自然、流畅和地道,使用优美和高雅的表达方式。",
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 10))
]),
),
)
],
)),
// child: Ink(
// // decoration: BoxDecoration(
// // // color: Colors.amber.withOpacity(.5),
// // borderRadius: BorderRadius.circular(10),
// // ),
// child: GestureDetector(
// // radius: 20.0,
// // highlightColor: Colors.amber,
// // focusColor: Colors.black,
// // hoverColor: Colors.white,
// onTap: () {
// Vibrate.feedback(FeedbackType.impact);
// // print(12);
// // 点击事件
// },
// child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Padding(
// padding: EdgeInsets.only(left: 10, right: 10),
// child: Container(
// height: Get.height * 0.16,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(10),
// image: DecorationImage(
// image: Image.network(
// 'https://www.hahagpt.com/images/tousu.jpg')
// .image,
// fit: BoxFit.fitWidth,
// // colorFilter: ColorFilter.mode(Colors.red, BlendMode.colorBurn),
// ),
// ),
// child: Column(
// mainAxisAlignment:
// MainAxisAlignment.end,
// children: [
// GradientButton(
// child: Text('2.8万人使用',
// style: TextStyle(fontSize: 10)),
// increaseHeightBy: -10.00,
// increaseWidthBy: -10.00,
// callback: () {},
// // controller.requestPurchase,
// gradient: Gradients.cosmicFusion,
// shadowColor: Gradients
// .backToFuture.colors.last
// .withOpacity(0.25),
// )
// ],
// )
// // Positioned(
// // child: ),
// )),
// Text("心情日志",
// style: TextStyle(
// fontFamily: 'Montserrat',
// fontWeight: FontWeight.w500,
// fontSize: 14)),
// Text("为您打开思绪",
// style: TextStyle(
// color: Color(0x908f8fc9), fontSize: 12))
// ],
// ),
// // child: Container(color: Colors.red),
// // child: const Overlay(
// // initialEntries: [],
// // )
// ),
// ),
// child: Ink(
// color: Colors.black.withOpacity(0.1),
// child: Container(
// // color: Colors.black,
// // color: Colors.black.withOpacity(0.5),
// child: Column(
// children: [
// Image.network(
// 'https://www.hahagpt.com/images/tousu.jpg')
// ],
// )),
// ),
);
}).toList()
// Range(1,100).to
// .map((e) => StaggeredGridTile.count(
// crossAxisCellCount: 1,
// mainAxisCellCount: 1.7,
// child: Container(color: Colors.black),
// ))
),
);
},
childCount: 1,
))
// Positioned(
// left: 50,
// top: 50,
// child: Opacity(
// opacity: 0.1,
// child: Container(
// width: double.infinity,
// height: 100,
// color: Colors.red,
// ),
// )),
// Expanded(
// child:
// )
],
);
// return Container(
// alignment: Alignment.center,
// height: 100.w,
// padding: EdgeInsets.all(20.w),
// child: Container(
// padding: EdgeInsets.symmetric(horizontal: 20.w),
// decoration: BoxDecoration(
// border: Border.fromBorderSide(Borders.primaryBorder),
// borderRadius: Radii.k6pxRadius,
// ),
// child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Text(
// "Tired of Ads? Get Premium - \$9.99",
// textAlign: TextAlign.center,
// style: TextStyle(
// color: AppColors.primaryText,
// fontFamily: "Avenir",
// fontWeight: FontWeight.w400,
// fontSize: 18,
// height: 18 / 18,
// ),
// ),
// ],
// ),
// ),
// );
}
}
class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
_SliverAppBarDelegate({
required this.minHeight,
required this.maxHeight,
required this.child,
});
final double minHeight;
final double maxHeight;
final Widget child;
@override
double get minExtent => minHeight;
@override
double get maxExtent => max(maxHeight, minHeight);
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return new SizedBox.expand(child: child);
}
@override
bool shouldRebuild(_SliverAppBarDelegate oldDelegate) {
return maxHeight != oldDelegate.maxHeight ||
minHeight != oldDelegate.minHeight ||
child != oldDelegate.child;
}
}
library widgets;
// export 'news_page_list.dart';
export 'grid.dart';
......@@ -36,22 +36,6 @@ class ChatPageController extends GetxController {
/// 事件
void sendMessage(types.PartialText message) async {
// 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 = types.TextMessage(
author: _user,
createdAt: DateTime.now().millisecondsSinceEpoch,
......@@ -59,17 +43,7 @@ class ChatPageController extends GetxController {
text: "${message.text}",
);
// final loadingMessage = types.TextMessage(
// author: receiveUser,
// createdAt: DateTime.now().millisecondsSinceEpoch,
// id: const Uuid().v4(),
// text: "loading",
// status: types.Status.sending,
// // "sending",
// );
_addMessage(textMessage);
// _addMessage(loadingMessage);
try {
String? result = await NewsAPI.sendMessage(
......
......@@ -55,39 +55,3 @@ class ChatPage extends GetView<ChatPageController> {
final _user = const types.User(
id: '82091008-a4aa-4a89-ae75-a22bf8d6f3aa',
);
// Container(
// height: double.infinity,
// width: double.infinity,
// decoration: BoxDecoration(
// image: DecorationImage(
// image: Image.asset("assets/images/bg.png").image,
// fit: BoxFit.cover),
// ),
// child: Chat(
// // onAttachmentPressed: _handleAttachmentPressed,
// // bubbleBuilder: _bubbleBuilder,
// theme: const DefaultChatTheme(
// // #1e1c39//#1e1c39#1e1c39#1e1c39
// // rgba(30, 28, 57, 1.00)
// backgroundColor: Color.fromRGBO(30, 28, 57, 0),
// // inputBackgroundColor: Colors.red,
// ),
// messages: controller.messageList,
// // messages: controller.state.messageList,
// // onAttachmentPressed: _handleAttachmentPressed,
// // onMessageTap: _handleMessageTap,
// // onPreviewDataFetched: _handlePreviewDataFetched,
// // onSendPressed: _handleSendPressed,
// showUserAvatars: true,
// showUserNames: true,
// // UserStore.to.isLogin
// // user: _user,
// l10n: const ChatL10nEn(
// inputPlaceholder: '请输入你的问题,并寻求解答...',
// attachmentButtonAccessibilityLabel: '继续',
// emptyChatPlaceholder: '暂无聊天信息',
// sendButtonAccessibilityLabel: '发送'),
// onSendPressed: controller.sendMessage, user: _user,
// )
\ No newline at end of file
......@@ -20,60 +20,19 @@ class ChartComponent extends StatelessWidget {
Widget build(BuildContext context) {
// controller.
return Obx(() => Chat(
// onAttachmentPressed: _handleAttachmentPressed,
// bubbleBuilder: _bubbleBuilder,
theme: const DefaultChatTheme(
// #1e1c39//#1e1c39#1e1c39#1e1c39
// rgba(30, 28, 57, 1.00)
backgroundColor: Color.fromRGBO(30, 28, 57, 0),
// inputBackgroundColor: Colors.red,
),
messages: controller.messageList,
// messages: controller.state.messageList,
// onAttachmentPressed: _handleAttachmentPressed,
// onMessageTap: _handleMessageTap,
// onPreviewDataFetched: _handlePreviewDataFetched,
// onSendPressed: _handleSendPressed,
showUserAvatars: true,
showUserNames: true,
// UserStore.to.isLogin
// user: _user,
l10n: const ChatL10nEn(
inputPlaceholder: '请输入你的问题,并寻求解答...',
attachmentButtonAccessibilityLabel: '继续',
emptyChatPlaceholder: '暂无聊天信息',
sendButtonAccessibilityLabel: '发送'),
onSendPressed: controller.sendMessage, user: _user,
onSendPressed: controller.sendMessage,
user: _user,
));
// Obx(
// () => true
// ? Text("1321")
// : Chat(
// // onAttachmentPressed: _handleAttachmentPressed,
// // bubbleBuilder: _bubbleBuilder,
// theme: const DefaultChatTheme(
// // #1e1c39//#1e1c39#1e1c39#1e1c39
// // rgba(30, 28, 57, 1.00)
// backgroundColor: Color.fromRGBO(30, 28, 57, 0),
// // inputBackgroundColor: Colors.red,
// ),
// messages: controller.messageList,
// // messages: controller.state.messageList,
// // onAttachmentPressed: _handleAttachmentPressed,
// // onMessageTap: _handleMessageTap,
// // onPreviewDataFetched: _handlePreviewDataFetched,
// // onSendPressed: _handleSendPressed,
// showUserAvatars: true,
// showUserNames: true,
// // UserStore.to.isLogin
// // user: _user,
// l10n: const ChatL10nEn(
// inputPlaceholder: '请输入你的问题,并寻求解答...',
// attachmentButtonAccessibilityLabel: '继续',
// emptyChatPlaceholder: '暂无聊天信息',
// sendButtonAccessibilityLabel: '发送'),
// onSendPressed: controller.sendMessage, user: _user,
// ),
// );
}
}
import 'package:get/get.dart';
import 'controller.dart';
class CreationDetailBinding implements Bindings {
@override
void dependencies() {
Get.lazyPut<CreationDetailController>(() => CreationDetailController());
}
}
import 'package:chart/common/entities/detail.dart';
import 'package:get/get.dart';
import 'index.dart';
class CreationDetailController extends GetxController {
static CreationDetailController get to => Get.put(CreationDetailController());
CreationDetailController();
final state = CreationDetailState();
// final
// tap
void handleTap(int index) {
Get.snackbar(
"标题",
"消息",
);
}
void updateState(String title, List<DetailData> items) {
state.title = title;
state.detailList.value = [];
state.detailList.addAll(items);
}
/// 在 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 creation_detail;
export './state.dart';
export './controller.dart';
export './bindings.dart';
export './view.dart';
import 'package:chart/common/entities/detail.dart';
import 'package:get/get.dart';
class CreationDetailState {
// title
final _title = "".obs;
set title(value) => _title.value = value;
get title => _title.value;
RxList detailList = [].obs;
}
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'index.dart';
import 'widgets/widgets.dart';
class CreationDetailPage extends GetView<CreationDetailController> {
const CreationDetailPage({Key? key}) : super(key: key);
// 主视图
Widget _buildView() {
return const HelloWidget();
}
@override
Widget build(BuildContext context) {
return GetBuilder<CreationDetailController>(
builder: (_) {
return Container(
decoration: BoxDecoration(
image: DecorationImage(
image: Image.asset("assets/images/background.png").image,
fit: BoxFit.cover),
// gradient: LinearGradient(
// begin: Alignment.topCenter,
// end: Alignment.bottomCenter,
// // background: linear-gradient(180deg, #0F172A 0%, #0F1B38 100%);
// colors: [
// Color(0xFF0F172A),
// Color(0xFF0F1B38),
// ],
// ),
),
child: Obx(() => Scaffold(
backgroundColor: Color.fromARGB(0, 29, 33, 60),
appBar: AppBar(
backgroundColor: Color.fromARGB(0, 29, 33, 60),
title: Text('${controller.state.title}'),
elevation: 0),
body: Container(
child: SafeArea(
child: _buildView(),
)),
)),
);
},
);
}
}
import 'package:chart/common/entities/detail.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:gradient_borders/gradient_borders.dart';
import '../index.dart';
/// hello
class HelloWidget extends GetView<CreationDetailController> {
const HelloWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Obx(() => Container(
padding: EdgeInsets.symmetric(
horizontal: 10,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: controller.state.detailList.map((element) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('${element.label}'),
TextField(
decoration: InputDecoration(
isDense: true,
hintText: '${element.placeHolder}',
filled: true,
// fillColor: fillColor ?? Colors.grey[100],
contentPadding: const EdgeInsets.only(
left: 18,
top: 15,
bottom: 15,
),
// suffixIcon: IconButton(
// onPressed: sendMessage,
// icon: Icon(
// Icons.send,
// size: 30,
// ),
// // rgba(123, 238, 251, 1.00)
// // rgba(122, 239, 251, 1.00)
// color: Color.fromRGBO(123, 238, 251, 1),
// ),
// Icon(Icons.abc_rounded),
// border: const InputBorder()
// border: OutlineInputBorder(
// borderRadius: BorderRadius.circular(10),
// borderSide: const BorderSide(
// width: 10,
// style: BorderStyle.solid,
// ),
// ),
// rgba(116, 112, 249, 1.00)
enabledBorder: const GradientOutlineInputBorder(
// rgba(140, 197, 208, 1.00)
// borderRadius: BorderRadius.circular(10),
gradient: LinearGradient(colors: [
Color(0xFFb05ddd),
Color(0xFFb05ddd),
]),
width: 1,
),
disabledBorder: const GradientOutlineInputBorder(
// rgba(140, 197, 208, 1.00)
// borderRadius: BorderRadius.circular(10),
// ignore: prefer_const_literals_to_create_immutables
gradient: LinearGradient(colors: [
Color(0xFFb05ddd),
Color(0xFFb05ddd),
]),
width: 1,
),
// OutlineInputBorder(
// borderRadius:
// BorderRadius.circular(10),
// borderSide: const BorderSide(
// width: 5,
// style: BorderStyle.solid,
// ),
// ),
focusedBorder: const GradientOutlineInputBorder(
// rgba(140, 197, 208, 1.00)
// borderRadius: BorderRadius.circular(10),
gradient: LinearGradient(colors: [
Color(0xFFb05ddd),
Color(0xFFb05ddd),
]),
width: 1,
),
// focusedBorder: OutlineInputBorder(
// borderRadius: BorderRadius.circular(10),
// borderSide: const BorderSide(
// width: 5,
// style: BorderStyle.solid,
// ),
// ),
),
style: TextStyle(
// color: AppColors.primaryText,
fontWeight: FontWeight.w400,
fontSize: 14,
),
maxLines: 1,
// autocorrect: false, // 自动纠正
// obscureText: isPassword, // 隐藏输入内容, 密码框
),
],
);
}).toList(),
// children: controller.state.detailList
// .map((element) => element.label)
// .toList()
// children: [
// Text('${controller.state.detailList.length}'),
// ],
)));
}
}
library widgets;
export './hello.dart';
import 'package:get/get.dart';
import 'controller.dart';
class CreationBinding implements Bindings {
@override
void dependencies() {
Get.lazyPut<CreationController>(() => CreationController());
}
}
import 'package:chart/common/apis/apis.dart';
import 'package:chart/common/entities/selectAllEntity.dart';
import 'package:chart/common/routers/names.dart';
import 'package:chart/pages/creation-detail/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:loading_animation_widget/loading_animation_widget.dart';
class CreationController extends GetxController {
CreationController();
final count = 0.obs;
final list = [].obs;
// RxList<Chat.ChatMessage>
_initData() async {
// ignore: invalid_use_of_protected_member
if (list.value.isEmpty) {
SelectAllEntity entity = await UserAPI.selectAll();
if (entity.status == 200) {
// list.addAll();
list.addAll(entity.data!);
}
}
// update(["creation"]);
}
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.getDetailParamsByDetailId(item.classifyId);
EasyLoading.dismiss();
CreationDetailController.to.updateState(item.detailName, res.data!);
Get.toNamed(AppRoutes.CREATION_PAGE_DETAIL);
//
}
void increment() {
count.value = count.value + 1;
// count.update((val) {
// print(val);
// val! + 1;
// });
}
// @override
// void onInit() {
// super.onInit();
// }
@override
void onReady() {
super.onReady();
_initData();
}
// @override
// void onClose() {
// super.onClose();
// }
}
library creation;
export './controller.dart';
export './view.dart';
export './bindings.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'index.dart';
import 'widgets/grid.dart';
class CreationPage extends GetView<CreationController> {
const CreationPage({Key? key}) : super(key: key);
// 主视图
Widget _buildView() {
return GridWidget();
// return Obx(() => Center(
// child: InkWell(
// onTap: () => controller.increment(),
// child: Text('${controller.count}', style: TextStyle(fontSize: 40)),
// ),
// ));
}
@override
Widget build(BuildContext context) {
return GetBuilder<CreationController>(
init: CreationController(),
id: "creation",
builder: (_) {
return Scaffold(
backgroundColor: Color.fromARGB(0, 29, 33, 60),
// appBar: AppBar(
// backgroundColor: Color.fromARGB(255, 29, 33, 60),
// // title: const Text(
// // "创作",
// // ),
// elevation: 0),
body: SafeArea(
child: _buildView(),
),
);
},
);
}
}
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:chart/common/values/values.dart';
import 'package:flutter_vibrate/flutter_vibrate.dart';
import 'package:get/get.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gradient_widgets/gradient_widgets.dart';
import '../index.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
class GridWidget extends GetView<CreationController> {
@override
Widget build(BuildContext context) {
return CustomScrollView(
slivers: [
SliverPersistentHeader(
pinned: true, //是否固定在顶部
floating: true,
delegate: _SliverAppBarDelegate(
minHeight: Get.height * .16,
maxHeight: Get.height * .156,
child: Opacity(
opacity: .668,
child: 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:
// Container(
// padding: EdgeInsets.only(left: 16),
// color: Colors.pink,
// alignment: Alignment.centerLeft,
// child: Text("浮动", style: TextStyle(fontSize: 18)),
// ),
)),
),
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return Obx(() => Container(
padding: const EdgeInsets.only(
left: 10,
right: 10,
),
margin: const EdgeInsets.only(
top: 10,
bottom: 20,
),
child: StaggeredGrid.count(
crossAxisCount: 3,
mainAxisSpacing: 30,
crossAxisSpacing: 10,
children: List.generate(controller.list.length, (index) {
return StaggeredGridTile.count(
crossAxisCellCount: 1,
mainAxisCellCount: 1.7,
child: Ink(
// decoration: BoxDecoration(
// // color: Colors.amber.withOpacity(.5),
// borderRadius: BorderRadius.circular(10),
// ),
child: GestureDetector(
// radius: 20.0,
// highlightColor: Colors.amber,
// focusColor: Colors.black,
// hoverColor: Colors.white,
onTap: () {
controller.onTap(controller.list[index]);
//
// print(12);
// 点击事件
},
child: Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Padding(
padding:
EdgeInsets.only(left: 10, right: 10),
child: Container(
height: Get.height * 0.16,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(10),
image: DecorationImage(
image: Image.network(
'${controller.list[index].icon}')
.image,
fit: BoxFit.fitWidth,
// colorFilter: ColorFilter.mode(Colors.red, BlendMode.colorBurn),
),
),
child: Column(
mainAxisAlignment:
MainAxisAlignment.end,
children: [
GradientButton(
child: Text('2.8万人使用',
style: TextStyle(
fontSize: 10)),
increaseHeightBy: -10.00,
increaseWidthBy: -10.00,
callback: () {},
// controller.requestPurchase,
gradient:
Gradients.cosmicFusion,
shadowColor: Gradients
.backToFuture.colors.last
.withOpacity(0.25),
)
],
)
// Positioned(
// child: ),
)),
Text('${controller.list[index].detailName}',
style: TextStyle(
fontFamily: 'Montserrat',
fontWeight: FontWeight.w500,
fontSize: 14)),
Text('${controller.list[index].detailDesc}',
style: TextStyle(
color: Color(0x908f8fc9),
fontSize: 12))
],
),
// child: Container(color: Colors.red),
// child: const Overlay(
// initialEntries: [],
// )
),
),
// child: Ink(
// color: Colors.black.withOpacity(0.1),
// child: Container(
// // color: Colors.black,
// // color: Colors.black.withOpacity(0.5),
// child: Column(
// children: [
// Image.network(
// 'https://www.hahagpt.com/images/tousu.jpg')
// ],
// )),
// ),
);
}).toList()
// Range(1,100).to
// .map((e) => StaggeredGridTile.count(
// crossAxisCellCount: 1,
// mainAxisCellCount: 1.7,
// child: Container(color: Colors.black),
// ))
),
));
},
childCount: 1,
)),
// Positioned(
// left: 50,
// top: 50,
// child: Opacity(
// opacity: 0.1,
// child: Container(
// width: double.infinity,
// height: 100,
// color: Colors.red,
// ),
// )),
// Expanded(
// child:
// )
],
);
// return Container(
// alignment: Alignment.center,
// height: 100.w,
// padding: EdgeInsets.all(20.w),
// child: Container(
// padding: EdgeInsets.symmetric(horizontal: 20.w),
// decoration: BoxDecoration(
// border: Border.fromBorderSide(Borders.primaryBorder),
// borderRadius: Radii.k6pxRadius,
// ),
// child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Text(
// "Tired of Ads? Get Premium - \$9.99",
// textAlign: TextAlign.center,
// style: TextStyle(
// color: AppColors.primaryText,
// fontFamily: "Avenir",
// fontWeight: FontWeight.w400,
// fontSize: 18,
// height: 18 / 18,
// ),
// ),
// ],
// ),
// ),
// );
}
}
class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
_SliverAppBarDelegate({
required this.minHeight,
required this.maxHeight,
required this.child,
});
final double minHeight;
final double maxHeight;
final Widget child;
@override
double get minExtent => minHeight;
@override
double get maxExtent => max(maxHeight, minHeight);
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return new SizedBox.expand(child: child);
}
@override
bool shouldRebuild(_SliverAppBarDelegate oldDelegate) {
return maxHeight != oldDelegate.maxHeight ||
minHeight != oldDelegate.minHeight ||
child != oldDelegate.child;
}
}
library widgets;
// export 'news_page_list.dart';
export 'grid.dart';
......@@ -20,23 +20,6 @@ class ChatNewPage extends GetView<ChatNewController> {
@override
Widget build(BuildContext context) {
// final c = Get.put(ChatPageController());
// Text(
// "${controller.state.page}",
// style: TextStyle(
// color: AppColors.primaryElementText,
// fontFamily: 'Montserrat',
// fontSize: 18,
// fontWeight: FontWeight.w600,
// ),
// )
// final c = Get.put(ChatNewController());
// return WillPopScope(
// onWillPop: () async {
// 禁止返回
// return false;
// },
return WillPopScope(
onWillPop: () async {
return false;
......@@ -52,11 +35,6 @@ class ChatNewPage extends GetView<ChatNewController> {
),
onPressed: () {
controller.share();
// Get.offAll(ApplicationPage());
// await Get.off(ApplicationPage());
// Get.toNamed(AppRoutes.Application);
// Navigator.of(context).pop();
//_nextPage(-1);
},
)
],
......@@ -83,11 +61,6 @@ class ChatNewPage extends GetView<ChatNewController> {
onPressed: () {
// Get.back();
controller.closeChat();
// Get.offAll(ApplicationPage());
// await Get.off(ApplicationPage());
// Get.toNamed(AppRoutes.Application);
// Navigator.of(context).pop();
//_nextPage(-1);
},
)),
body: Container(
......@@ -104,33 +77,9 @@ class ChatNewPage extends GetView<ChatNewController> {
child: Chat.DashChat(
inputOptions: Chat.InputOptions(
inputDisabled: controller.state.isLoading,
// controller.state.isLoading,
// alwaysShowSend: true,
// sendButtonBuilder: (send) => const Text("data"),
// showTraillingBeforeSend: true,
inputTextStyle: TextStyle(color: Colors.white),
inputToolbarStyle: BoxDecoration(
color: Color.fromRGBO(36, 40, 64, 1.00),
//
// color: LinearGradient(
// width: 5,
// colors: [Colors.red, Colors.yellow],
// begin: Alignment.topLeft,
// end: Alignment.bottomRight,
// ),
// Color.fromRGBO(36, 40, 64, 1.00),
// border: Border.all(
// width: 5,
// color: LinearGradient(
// colors: [Colors.red, Colors.yellow],
// begin: Alignment.topLeft,
// end: Alignment.bottomRight,
// ),
// ),
// c
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16)),
......@@ -138,88 +87,17 @@ class ChatNewPage extends GetView<ChatNewController> {
inputToolbarMargin: EdgeInsets.all(0),
sendButtonBuilder: null,
inputToolbarPadding:
// symmetric(horizontal: 10, vertical: 20)
EdgeInsets.only(top: 15, right: 15, left: 15, bottom: 35),
// inputToolbarPadding : const EdgeInsets.all(8.0),
// this.inputToolbarMargin = const EdgeInsets.only(top: 8.0),
// textController:
// sendButtonBuilder:
// () => TextButton(
// child: const Text("13213"),
// onPressed: (send) => {send()},
// )
// inputTextStyle: TextStyle(color: Colors.red),
// inputDecoration: InputDecoration(
// isDense: true,
// filled: true,
// fillColor: Colors.red,
// // contentPadding: const EdgeInsets.only(
// // left: 18,
// // top: 10,
// // bottom: 10,
// // ),
// // border: OutlineInputBorder(
// // borderRadius: BorderRadius.circular(25),
// // borderSide: const BorderSide(
// // width: 0,
// // style: BorderStyle.none,
// // ),
// // ),
// ),
),
// ${controller.state.messageList.length}条消息
currentUser: _user,
onSend: controller.sendMessage,
// messageListOptions:
// const MessageListOptions(loadEarlierBuilder: Text("2131")),
messages: controller.state.messageList,
// messageListOptions: MessageListOptions(
// chatFooterBuilder: Container(
// color: Colors.red,
// width: double.infinity,
// height: 100.00,
// child: Text("footer")),
// ),
messageOptions: Chat.MessageOptions(
onPressMessage: controller.tabMessage,
// containerColor: Colors.black,
),
),
// Column(children: [
// ]),
// Chat(
// // onAttachmentPressed: _handleAttachmentPressed,
// // bubbleBuilder: _bubbleBuilder,
// theme: const DefaultChatTheme(
// // #1e1c39//#1e1c39#1e1c39#1e1c39
// // rgba(30, 28, 57, 1.00)
// backgroundColor: Color.fromRGBO(30, 28, 57, 0),
// // inputBackgroundColor: Colors.red,
// ),
// messages: controller.state.messageList.value,
// // messages: controller.state.messageList,
// // onAttachmentPressed: _handleAttachmentPressed,
// // onMessageTap: _handleMessageTap,
// // onPreviewDataFetched: _handlePreviewDataFetched,
// // onSendPressed: _handleSendPressed,
// showUserAvatars: true,
// showUserNames: true,
// // UserStore.to.isLogin
// // user: _user,
// l10n: const ChatL10nEn(
// inputPlaceholder: '请输入你的问题,并寻求解答...',
// attachmentButtonAccessibilityLabel: '继续',
// emptyChatPlaceholder: '暂无聊天信息',
// sendButtonAccessibilityLabel: '发送'),
// onSendPressed: controller.sendMessage, user: _user,
// ),
)
// Obx(() => )),
)));
))));
}
}
......
import 'package:get/get.dart';
import 'controller.dart';
class HomeBinding implements Bindings {
@override
void dependencies() {
Get.lazyPut<HomeController>(() => HomeController());
}
}
import 'dart:async';
import 'package:chart/common/apis/apis.dart';
import 'package:chart/common/routers/routes.dart';
import 'package:chart/common/store/store.dart';
import 'package:chart/common/values/server.dart';
import 'package:chart/entity/user_entity.dart';
import 'package:chart/package/chat_dash/dash_chat_2.dart' as Chat;
import 'package:chart/package/chat_dash/dash_chat_2.dart';
import 'package:chart/pages/category/controller.dart';
import 'package:chart/pages/frame/product/controller.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_vibrate/flutter_vibrate.dart';
import 'package:get/get.dart';
import 'package:share_plus/share_plus.dart';
import 'package:uuid/uuid.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
import 'index.dart';
import 'package:eventsource/eventsource.dart';
import 'dart:convert';
import 'package:flutter/services.dart';
import 'package:flutter_client_sse/flutter_client_sse.dart';
// EventSource eventSource = EventSource(Uri.parse('http://example.com/events'));
//
class HomeController extends GetxController {
HomeController();
static HomeController get to => Get.put(HomeController());
/// 响应式成员变量
final state = ChatPageState();
late StreamSubscription<Event> eventSource;
// ignore: prefer_typing_uninitialized_variables
late var sse;
/// 成员变量
/// 事件
// final _user = const types.User(
// id: '82091008-a4aa-4a89-ae75-a22bf8d6f3aa',
// );
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",
);
/// 事件
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);
// return;
// _addMessage(loadingMessage);
// ("正在思考中...");
try {
// print("1321312321${UserStore.to.profile.id}");
if (UserStore.to.profile.id != '') {
await initEventSource();
state.isLoading = true;
int? result = await UserAPI.sceneAsk({
"question": message.text,
"conversionId": 0,
"sceneId": 0,
});
// question: this.messageText,
// conversionId: 0,
// sceneId: 0,
// _cancelLoading();
// print(
// "eventSource.isPausedeventSource.isPausedeventSource.isPaused---------------${eventSource.isPaused}");
if (result == 200) {
EasyLoading.dismiss();
Vibrate.feedback(FeedbackType.success);
UserAPI.getUserInfo().then((value) async {
await UserStore.to.saveProfile(IntegralEntity(
id: UserStore.to.profile.id,
username: UserStore.to.profile.username,
token: UserStore.to.profile.token,
expireTime: value.expireTime,
integral: value.integral));
});
final receiveMessage = Chat.ChatMessage(
user: receiveUser,
createdAt: DateTime.now(),
status: MessageStatus.pending,
// id: const Uuid().v4(),
text: "LOADING",
);
_addMessage(receiveMessage);
// index.value = state.messageList.length;
} else {
// EasyLoading.showError("网络异常");
EasyLoading.dismiss();
state.isLoading = false;
}
} else {
final receiveErrorMessage = Chat.ChatMessage(
user: receiveUser,
createdAt: DateTime.now(),
// id: const Uuid().v4(),
text: "你还未登录,请登录后再体验更多功能。",
);
state.isLoading = false;
_addMessage(receiveErrorMessage);
EasyLoading.dismiss();
Vibrate.feedback(FeedbackType.error);
Get.toNamed(AppRoutes.SIGN_IN);
}
} catch (e) {
print("eeeeeeee$e");
state.isLoading = false;
// _cancelLoading();
final receiveErrorMessage = Chat.ChatMessage(
user: receiveUser,
createdAt: DateTime.now(),
// id: const Uuid().v4(),
text: "当前用户太多了,请稍等再试",
);
_addMessage(receiveErrorMessage);
EasyLoading.dismiss();
Vibrate.feedback(FeedbackType.error);
}
}
void _addMessage(Chat.ChatMessage message) {
// state.messageList.value = [message];
state.messageList.insert(0, message);
// update(['messageList']);
// 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";
// });
//
}
void addCount() {
// count.value = count.value + 1;
}
// 方法
closeChat() async {
// // final c = Get.put(ChatPageController());
final c = Get.put(CategoryController());
state.isNext = 1;
try {
await UserAPI.endConversion({
"conversionId": state.conversionId,
});
Vibrate.feedback(FeedbackType.impact);
state.messageList.value = [];
Get.back();
c.refresh();
} catch (e) {}
// Get.back();
// Get.defaultDialog(
// title: "提示",
// textConfirm:"",
// content: Container(
// child: Column(children: [Text("返回后查看当前回话记录请去我的信息页面!")
// ]),
// ));
}
// 拉取数据
Future<void> fetchNewsList({bool isRefresh = false}) async {
// var result =
// await NewsAPI.newsPageList({'page': curPage, "size": pageSize});
// if (isRefresh == true) {
// curPage = 1;
// total = result.total!;
// state.newsList.clear();
// } else {
// curPage++;
// }
// state.newsList.addAll(result.records!);
// print("${state.newsList.length}");
}
getMessageList(messageList, id) {
final messages = List<ChatMessage>.generate(messageList.length, (index) {
final i = messageList[index];
var message;
if (i?.role == "user") {
message = Chat.ChatMessage(
text: i?.content,
user: _user,
createdAt: DateTime.parse(i.sendTime).toLocal(),
);
} else {
message = ChatMessage(
user: receiveUser,
createdAt: DateTime.parse(i.sendTime).toLocal(),
text: i?.content,
);
}
return message;
});
state.isNext = 2;
state.messageList.value = messages.reversed.toList();
state.conversionId = id;
Get.toNamed("${AppRoutes.CHAT_PAGE}");
}
sendMessageByBanner(String message) async {
await createConversionId();
// Vibrate.feedback(FeedbackType.impact);
// // message.question
Chat.ChatUser _user = Chat.ChatUser(
id: '1',
// firstName: 'Charles',
// lastName: 'Leclerc',
);
// // ?question=${message.question}
// Get.toNamed("${AppRoutes.CHAT_PAGE}");
sendMessage(Chat.ChatMessage(
text: "${message}",
user: _user,
createdAt: DateTime.now(),
));
}
initEventSource() async {
// if (UserStore.to.isLogin) {
sse = 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.conversionId,
// "content": state.messageList[0].text,
// });
state.isLoading = false;
return;
}
Map<String, dynamic> jsonMap = jsonDecode("${event.data}");
if (jsonMap['askType'] == 1) {
_updateMessage("${jsonMap['content']}" as String);
}
});
// print(sse);
}
Future createConversionId() async {
Vibrate.feedback(FeedbackType.impact);
Get.toNamed(AppRoutes.CHAT_PAGE);
int id = await UserAPI.createConversion();
state.conversionId = id;
}
_updateMessage(String text) {
print(state.messageList.length);
// state.messageList[0].text = state.messageList[0].text + text;
// state.messageList.forEach((element) {
// print(element.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;
}
share() async {
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) {
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);
}
@override
void onReady() async {
super.onReady();
}
@override
void onClose() {
print("222____________________onCloseonCloseonCloseonCloseonCloseonClose");
super.onClose();
}
/// 生命周期
@override
void onInit() async {
// await initEventSource();
// connect("http://example.org/events");
// http://192.168.110.127:8083/api/openAi/connect
// await initEventSource();
super.onInit();
// ever(Get.parameters['question'].obs, (value) {
// print("messageListmessageListmessageListmessageList$value");
// });
}
///dispose 释放内存
@override
void dispose() {
super.dispose();
// dispose 释放对象
// refreshController.dispose();
}
// obx(Map map) {}
}
library home;
export './controller.dart';
export './view.dart';
export './bindings.dart';
export './state.dart';
// import 'dart:ffi';
import 'package:chart/common/entities/entities.dart';
import 'package:chart/package/chat_dash/dash_chat_2.dart' as Chat;
import 'package:get/get.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
Chat.ChatUser _userPlaceHolder = Chat.ChatUser(
id: '0',
// firstName: 'Charles',
// lastName: 'Leclerc',
);
class ChatPageState {
// 新闻翻页 // List<types.Message>
RxList<Chat.ChatMessage> messageList = <Chat.ChatMessage>[
Chat.ChatMessage(
user: _userPlaceHolder,
createdAt: DateTime.now(),
// id: const Uuid().v4(),
text: "【有志者,事竟成】用英文怎么说",
customProperties: {"title": '语言翻译', 'icon': 'a'}),
Chat.ChatMessage(
user: _userPlaceHolder,
createdAt: DateTime.now(),
// id: const Uuid().v4(),
text: "请帮我列出双色球的预测方法?",
customProperties: {"title": '难题破解', 'icon': 'a'}),
Chat.ChatMessage(
user: _userPlaceHolder,
createdAt: DateTime.now(),
// id: const Uuid().v4(),
text: "外星人真实存在吗?",
customProperties: {"title": '宇宙奥义', 'icon': 'a'}),
Chat.ChatMessage(
user: _userPlaceHolder,
createdAt: DateTime.now(),
// id: const Uuid().v4(),
text: "三星堆文化来自何方?",
customProperties: {"title": '历史谜题', 'icon': 'a'}),
Chat.ChatMessage(
user: _userPlaceHolder,
createdAt: DateTime.now(),
// id: const Uuid().v4(),
text: "若xy-x+y=0,且xy>0,则1/x-1/y的值为多少?",
customProperties: {"title": '学习工作', 'icon': 'a'}),
Chat.ChatMessage(
user: _userPlaceHolder,
createdAt: DateTime.now(),
// id: const Uuid().v4(),
text: "怎么做辣椒炒肉?",
customProperties: {"title": '美食烹饪', 'icon': 'a'}),
Chat.ChatMessage(
user: _userPlaceHolder,
createdAt: DateTime.now(),
// id: const Uuid().v4(),
text: "身高180cm,体重180斤,那么BMI值是多少?",
customProperties: {"title": '健康养身', 'icon': 'a'})
].obs;
// get _messageList =>
final _page = "AI聊天".obs;
set page(value) => _page.value = value;
get page => _page.value;
final RxBool _isLoading = false.obs;
set isLoading(value) => _isLoading.value = value;
get isLoading => _isLoading.value;
final _conversionId = 0.obs;
set conversionId(value) => _conversionId.value = value;
get conversionId => _conversionId.value;
final _isNext = 1.obs;
set isNext(value) => _isNext.value = value;
get isNext => _isNext.value;
// RxList<NewsItem> newsList = <NewsItem>[].obs;
}
import 'package:chart/common/routers/routes.dart';
import 'package:chart/common/values/values.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
import 'package:gradient_widgets/gradient_widgets.dart';
import '../../../common/widgets/app.dart';
import 'index.dart';
import 'package:chart/package/chat_dash/dash_chat_2.dart' as Chat;
import 'widgets/widgets.dart';
class HomePage extends GetView<HomeController> {
// 内容页
// Widget _buildView() {
// return HellowordWidget();
// }
@override
Widget build(BuildContext context) {
final cc = Get.put(HomeController());
return WillPopScope(
onWillPop: () async {
return false;
},
child: Obx(() => Scaffold(
backgroundColor: Color.fromARGB(0, 0, 0, 0),
appBar: transparentAppBar(
actions: [
IconButton(
tooltip: '分享',
icon: const Icon(
Icons.share,
color: AppColors.primaryElementText,
),
onPressed: () {
controller.share();
},
)
],
title: RichText(
text: TextSpan(children: [
TextSpan(
text: "${controller.state.page}",
style: TextStyle(
color: AppColors.primaryElementText,
fontFamily: 'Montserrat',
fontSize: 18,
fontWeight: FontWeight.w600,
)),
TextSpan(
text: "${controller.state.messageList.length}",
style: TextStyle(fontSize: 0)),
])),
leading: GradientButton(
// increaseHeightBy: -5,
// increaseWidthBy: -5,
elevation: 0,
shadowColor: Colors.black,
gradient: const LinearGradient(
colors: [
Color.fromARGB(255, 223, 188, 134),
Color.fromARGB(255, 244, 218, 129),
Color.fromARGB(255, 248, 228, 127)
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
child: Row(children: const [
Icon(
Icons.add_circle,
color: Colors.black,
size: 35,
),
SizedBox(
width: 10,
),
Text("订阅",
style: TextStyle(
color: Color.fromARGB(255, 95, 54, 0),
fontSize: 16))
]),
callback: () {})
// IconButton(
// tooltip: '返回上一页',
// icon: const Icon(
// Icons.arrow_back,
// color: AppColors.primaryElementText,
// ),
// onPressed: () {
// // Get.back();
// controller.closeChat();
// },
// ),
),
body: Container(
width: double.infinity,
height: double.infinity,
// color: Color.fromARGB(0, 255, 255, 0),
// color: Colors.red,
// Color.argb(255, 29, 33, 60)
// color: Color.fromARGB(0, 29, 33, 60),
// color: Color.fromARGB(255, 26, 27, 46),
child: 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(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: 10),
),
currentUser: _user,
onSend: cc.sendMessage,
messages: cc.state.messageList,
messageOptions: Chat.MessageOptions(
onPressMessage: cc.tabMessage,
// containerColor: Colors.black,
),
),
))));
}
}
Chat.ChatUser _user = Chat.ChatUser(
id: '1',
// firstName: 'Charles',
// lastName: 'Leclerc',
);
import 'package:flutter/material.dart';
import 'package:chart/common/values/values.dart';
import 'package:get/get.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../index.dart';
class GridWidget extends GetView<HomeController> {
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
height: 100.w,
padding: EdgeInsets.all(20.w),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 20.w),
decoration: BoxDecoration(
border: Border.fromBorderSide(Borders.primaryBorder),
borderRadius: Radii.k6pxRadius,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Tired of Ads? Get Premium - \$9.99",
textAlign: TextAlign.center,
style: TextStyle(
color: AppColors.primaryText,
fontFamily: "Avenir",
fontWeight: FontWeight.w400,
fontSize: 18,
height: 18 / 18,
),
),
],
),
),
);
}
}
library widgets;
// export 'news_page_list.dart';
export 'chat.dart';
import 'package:get/get.dart';
import 'controller.dart';
class MyBinding implements Bindings {
@override
void dependencies() {
Get.lazyPut<MyController>(() => MyController());
}
}
import 'package:get/get.dart';
class MyController extends GetxController {
MyController();
_initData() {
update(["my"]);
}
void onTap() {}
// @override
// void onInit() {
// super.onInit();
// }
@override
void onReady() {
super.onReady();
_initData();
}
// @override
// void onClose() {
// super.onClose();
// }
}
library my;
export './controller.dart';
export './view.dart';
export './bindings.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'index.dart';
class MyPage extends GetView<MyController> {
const MyPage({Key? key}) : super(key: key);
// 主视图
Widget _buildView() {
return const Center(
child: Text("MyPage"),
);
}
@override
Widget build(BuildContext context) {
return GetBuilder<MyController>(
init: MyController(),
id: "my",
builder: (_) {
return Scaffold(
backgroundColor: Color.fromARGB(255, 29, 33, 60),
appBar: AppBar(
elevation: 0,
title: const Text("我的"),
bottomOpacity: 0.1,
backgroundColor: Color.fromARGB(255, 29, 33, 60),
),
body: SafeArea(
child: _buildView(),
),
);
},
);
}
}
......@@ -22,13 +22,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "5.0.0"
alipay_kit_ios:
dependency: "direct main"
description:
name: alipay_kit_ios
url: "https://pub.dartlang.org"
source: hosted
version: "5.0.0"
animated_text_kit:
dependency: "direct main"
description:
......@@ -763,6 +756,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
loading_animation_widget:
dependency: "direct main"
description:
name: loading_animation_widget
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0+4"
logging:
dependency: transitive
description:
......
......@@ -112,13 +112,14 @@ dependencies:
social_login_buttons: ^1.0.7
flutter_markdown: ^0.6.14
alipay_kit: 5.0.0
alipay_kit_ios: 5.0.0
# alipay_kit_ios: 5.0.0
pointycastle: ^3.1.1
eventsource: ^0.4.0
flutter_client_sse: ^1.0.0
highlight: ^0.7.0
device_info_plus: ^8.1.0
app_settings: ^4.2.0
loading_animation_widget: ^1.2.0+4
# package:bubble/bubble.dart
......
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