Bläddra i källkod

翻译管家聊天界面

master
jiahao 5 år sedan
förälder
incheckning
9a35946a09
7 ändrade filer med 288 tillägg och 158 borttagningar
  1. +2
    -2
      ios/Flutter/flutter_export_environment.sh
  2. +12
    -12
      ios/Runner.xcodeproj/project.pbxproj
  3. +219
    -100
      lib/chat/ChatPage.dart
  4. +26
    -26
      lib/chat/full_img_view.dart
  5. +15
    -4
      lib/home/audio_chat_view.dart
  6. +12
    -12
      lib/home/realtimehelper/translation_butler_page.dart
  7. +2
    -2
      lib/utils/HttpUtil.dart

+ 2
- 2
ios/Flutter/flutter_export_environment.sh Visa fil

@@ -6,6 +6,6 @@ export "FLUTTER_TARGET=/Users/random/code/flutter/project/hibok/lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "FLUTTER_FRAMEWORK_DIR=/Users/random/sdk/flutter_sdk/bin/cache/artifacts/engine/ios"
export "FLUTTER_BUILD_NAME=1.0.5"
export "FLUTTER_BUILD_NUMBER=6"
export "FLUTTER_BUILD_NAME=1.0.9"
export "FLUTTER_BUILD_NUMBER=13"
export "TRACK_WIDGET_CREATION=true"

+ 12
- 12
ios/Runner.xcodeproj/project.pbxproj Visa fil

@@ -542,7 +542,7 @@
CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 12;
CURRENT_PROJECT_VERSION = 13;
DEVELOPMENT_TEAM = QJ9M3998Q6;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
@@ -556,7 +556,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 1.0.8;
MARKETING_VERSION = 1.0.9;
PRODUCT_BUNDLE_IDENTIFIER = com.chengyouhudong.hibok;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -578,14 +578,14 @@
CODE_SIGN_ENTITLEMENTS = "Share Extension/Share Extension.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 12;
CURRENT_PROJECT_VERSION = 13;
DEVELOPMENT_TEAM = QJ9M3998Q6;
ENABLE_BITCODE = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = "Share Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 1.0.8;
MARKETING_VERSION = 1.0.9;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
OTHER_LDFLAGS = "";
@@ -610,14 +610,14 @@
CODE_SIGN_ENTITLEMENTS = "Share Extension/Share Extension.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 12;
CURRENT_PROJECT_VERSION = 13;
DEVELOPMENT_TEAM = QJ9M3998Q6;
ENABLE_BITCODE = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = "Share Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 1.0.8;
MARKETING_VERSION = 1.0.9;
MTL_FAST_MATH = YES;
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = com.chengyouhudong.hibok.share;
@@ -640,14 +640,14 @@
CODE_SIGN_ENTITLEMENTS = "Share Extension/Share ExtensionProfile.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 12;
CURRENT_PROJECT_VERSION = 13;
DEVELOPMENT_TEAM = QJ9M3998Q6;
ENABLE_BITCODE = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = "Share Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 1.0.8;
MARKETING_VERSION = 1.0.9;
MTL_FAST_MATH = YES;
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = com.chengyouhudong.hibok.share;
@@ -777,7 +777,7 @@
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 12;
CURRENT_PROJECT_VERSION = 13;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
@@ -791,7 +791,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 1.0.8;
MARKETING_VERSION = 1.0.9;
PRODUCT_BUNDLE_IDENTIFIER = com.chengyouhudong.hibok;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -811,7 +811,7 @@
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 12;
CURRENT_PROJECT_VERSION = 13;
DEVELOPMENT_TEAM = QJ9M3998Q6;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
@@ -825,7 +825,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 1.0.8;
MARKETING_VERSION = 1.0.9;
PRODUCT_BUNDLE_IDENTIFIER = com.chengyouhudong.hibok;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";


+ 219
- 100
lib/chat/ChatPage.dart Visa fil

@@ -1,5 +1,7 @@
import 'dart:convert';
import 'dart:io';
import 'package:chat/home/audio_chat_view.dart';
import 'package:chat/utils/screen.dart';
import 'package:chat/utils/upload_util.dart';
import 'package:fixnum/fixnum.dart';
import 'package:cached_network_image/cached_network_image.dart';
@@ -216,10 +218,12 @@ class _ChatPageState extends State<ChatPage> {
MsgModel msg = MsgHandler.createSendMsg(
ChatType.valueOf(originMsg.msgType), originMsg.msgContent);
msg.extraInfo = originMsg.extraInfo;
if(originMsg.extraFile==null ||originMsg.extraFile.contains('http')){
if (originMsg.extraFile == null ||
originMsg.extraFile.contains('http')) {
msg.extraFile = originMsg.extraFile;
}else{
msg.extraFile = UploadUtil().getFullUrl(originMsg.extraFile, originMsg.sessionId, originMsg.channelType);
} else {
msg.extraFile = UploadUtil().getFullUrl(
originMsg.extraFile, originMsg.sessionId, originMsg.channelType);
}
msg.localFile = originMsg.localFile;
@@ -281,7 +285,8 @@ class _ChatPageState extends State<ChatPage> {
userId: friendInfo.userId,
pageType: SendMessagePageType.Remark,
originalName: Provider.of<RefNameProvider>(context)
.getRefName(friendInfo.userId, friendInfo.nickName));
.getRefName(
friendInfo.userId, friendInfo.nickName));
},
),
);
@@ -322,73 +327,187 @@ class _ChatPageState extends State<ChatPage> {
];
})));
return MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => _keyboardIndexProvider),
Provider<bool>.value(value: false),
Provider<int>.value(value: widget.friendId),
],
child: GestureDetector(
onTap: hideKeyBoard,
child: ExtendedTextSelectionPointerHandler(
///选择文字,消除弹窗
builder: (states) {
return Listener(
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: const Color(0xFFE2E9F1),
appBar: AppBar(
title: Text(
'${Provider.of<RefNameProvider>(context).getRefName(friendInfo.userId, friendInfo.nickName)}',
textScaleFactor: 1.0,
style: TextStyle(
color: Constants.BlackTextColor,
fontSize: 16.47),
),
leading: CustomUI.buildCustomLeading(context),
titleSpacing: -10,
centerTitle: false,
elevation: 1,
actions: actions),
body: SafeArea(
child: Column(
children: <Widget>[
NetStateWidget(),
widget.isTranslateButler
? _buildTranslationButler()
: Container(),
widget.isTranslateButler
? _buildServiceCard(true, () {})
: Container(),
widget.isTranslateButler
? _buildServiceCard(false, () {})
: Container(),
Expanded(child: _buildMessageList()),
InputBar(sendMsg: sendMsg),
],
))),
behavior: HitTestBehavior.translucent,
onPointerDown: (value) {
for (var state in states) {
if (!state.containsPosition(value.position)) {
//clear other selection
state.clearSelection();
}
}
},
onPointerMove: (value) {
//clear other selection
for (var state in states) {
if (!state.containsPosition(value.position)) {
return Stack(
children: <Widget>[
MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => _keyboardIndexProvider),
Provider<bool>.value(value: false),
Provider<int>.value(value: widget.friendId),
],
child: GestureDetector(
onTap: hideKeyBoard,
child: ExtendedTextSelectionPointerHandler(
///选择文字,消除弹窗
builder: (states) {
return Listener(
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: const Color(0xFFE2E9F1),
appBar: AppBar(
title: Text(
'${Provider.of<RefNameProvider>(context).getRefName(friendInfo.userId, friendInfo.nickName)}',
textScaleFactor: 1.0,
style: TextStyle(
color: Constants.BlackTextColor,
fontSize: 16.47),
),
leading: CustomUI.buildCustomLeading(context),
titleSpacing: -10,
centerTitle: false,
elevation: 1,
actions: actions),
body: SafeArea(
child: Column(
children: <Widget>[
NetStateWidget(),
widget.isTranslateButler
? _buildTranslationButler()
: Container(),
widget.isTranslateButler
? _buildServiceCard(true, () {})
: Container(),
widget.isTranslateButler
? _buildServiceCard(false, () {})
: Container(),
Expanded(child: _buildMessageList()),
InputBar(sendMsg: sendMsg),
],
))),
behavior: HitTestBehavior.translucent,
onPointerDown: (value) {
for (var state in states) {
if (!state.containsPosition(value.position)) {
//clear other selection
state.clearSelection();
}
}
},
onPointerMove: (value) {
//clear other selection
state.clearSelection();
}
}
for (var state in states) {
if (!state.containsPosition(value.position)) {
//clear other selection
state.clearSelection();
}
}
},
);
},
);
},
)));
))),
widget.isTranslateButler ? getAudioChatView() : Container(),
widget.isTranslateButler ? zoomAudioButton() : Container()
],
);
}
Widget getAudioChatView() {
if (friendInfo == null) {
return Container();
}
return isActive == null
? Container()
: Offstage(
offstage: !isShowAudio,
child: AudioChatPage(
userInfo: friendInfo,
isTranslateButler: true,
translateButlerCloseCallBack: audioChatPageCallBack,
),
);
}
audioChatPageCallBack(int args) {
switch (args) {
case 1:
setState(() {
isShowAudio = !isShowAudio;
isShowZoomButton = true;
});
break;
case 2:
setState(() {
isActive = false;
});
break;
}
}
bool isShowAudio = false;
///控住连麦窗口是否显示
bool isActive = true;
///控制连麦是否关闭
bool isShowZoomButton = true;
GlobalKey mykey = GlobalKey();
double dx = 0, dy = 0;
double zoomButtonSize = 60;
void dragEvent(DragUpdateDetails details) {
final RenderObject box = context.findRenderObject();
// 获得自定义Widget的大小,用来计算Widget的中心锚点
dx = details.globalPosition.dx - mykey.currentContext.size.width / 2;
dy = details.globalPosition.dy - mykey.currentContext.size.height / 2;
print('dx $dx dy $dy screen width:${Screen.width}');
if (dx > Screen.width - zoomButtonSize) {
dx = Screen.width - zoomButtonSize;
} else if (dx < 0) {
dx = 0;
}
if (dy > Screen.height - zoomButtonSize) {
dy = Screen.height - zoomButtonSize;
} else if (dy < 0) {
dy = 0;
}
setState(() {});
}
Widget zoomAudioButton() {
friendInfo == null
? Container()
: AudioChatPage(
userInfo: friendInfo,
);
if (friendInfo == null || !isShowZoomButton) {
return Container();
}
Widget button = Container(
key: mykey,
color: Colors.blue,
width: 60,
height: 60,
);
return GestureDetector(
onHorizontalDragUpdate: dragEvent,
onVerticalDragUpdate: dragEvent,
onTap: (){
setState(() {
isShowAudio = !isShowAudio;
isShowZoomButton = !isShowZoomButton;
});
},
child: Container(
child: Transform.translate(
offset: Offset(dx, dy),
child: Align(
alignment: Alignment.topLeft,
child: button,
),
),
),
);
}
Widget _buildTranslationButler() {
@@ -426,31 +545,35 @@ class _ChatPageState extends State<ChatPage> {
child: Image.asset(R.assetsImagesDefaultNorAvatar))),
Padding(
padding: EdgeInsets.only(left: 10),
child: Container(child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
I18n.of(context).translation_butler ,
textScaleFactor: 1.0,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
color: AppColors.NewAppbarTextColor, fontSize: 15),
),
SizedBox(height: 5,),
Text(
coinTIme,
textScaleFactor: 1.0,
maxLines: 1,
style: TextStyle(
color: Color(0xFF797979), fontSize: 13),
)
],
),constraints:BoxConstraints(maxWidth: 135),),
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
I18n.of(context).translation_butler,
textScaleFactor: 1.0,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
color: AppColors.NewAppbarTextColor, fontSize: 15),
),
SizedBox(
height: 5,
),
Text(
coinTIme,
textScaleFactor: 1.0,
maxLines: 1,
style: TextStyle(color: Color(0xFF797979), fontSize: 13),
)
],
),
constraints: BoxConstraints(maxWidth: 135),
),
),
Expanded(
child: Container(
constraints:BoxConstraints(maxWidth: 130),
constraints: BoxConstraints(maxWidth: 130),
width: double.maxFinite,
child: CountDownButton(
I18n.of(context).translation_butler_end_service,
@@ -596,27 +719,23 @@ class _ChatPageState extends State<ChatPage> {
}
MsgModel msg;
int count=0;
testBig(MsgModel msg)async{
int count = 0;
for(int k=0;k<100;k++){
testBig(MsgModel msg) async {
for (int k = 0; k < 100; k++) {
msg.msgContent = utf8.encode('测试$count');
Int64 time = Int64((DateTime.now()).millisecondsSinceEpoch);
msg.time = time.toInt();
MsgHandler.insertMsgToDB(msg);
MsgHandler.sendChatMsg(msg);
await Future.delayed(Duration(milliseconds: 500),(){});
await Future.delayed(Duration(milliseconds: 500), () {});
count++;
}
count=0;
count = 0;
print('发送完毕');
showToast('发送完毕');
}
void receiveMsg(args) {
if (mounted) {
setState(() {});


+ 26
- 26
lib/chat/full_img_view.dart Visa fil

@@ -62,7 +62,7 @@ class _PhotoPageState extends State<PhotoPage>
} else {
fileData = Uint8List.fromList(widget.msg.msgContent);
}
return GestureDetector(
return Material(color: Colors.black,child: GestureDetector(
onTap: () {
Navigator.pop(context);
},
@@ -74,30 +74,30 @@ class _PhotoPageState extends State<PhotoPage>
children: <Widget>[
SingleChildScrollView(
child: Column(
children: <Widget>[
Container(
width: Screen.width,
constraints: BoxConstraints(minHeight: Screen.height),
child: ExtendedImage.memory(
fileData,
fit: BoxFit.fitWidth,
mode: ExtendedImageMode.gesture,
initGestureConfigHandler: (state) {
return GestureConfig(
minScale: 0.9,
animationMinScale: 0.7,
maxScale: 3.0,
animationMaxScale: 3.5,
speed: 1.0,
inertialSpeed: 100.0,
initialScale: 1.0,
inPageView: true,
initialAlignment: InitialAlignment.center,
);
},
))
],
)),
children: <Widget>[
Container(
width: Screen.width,
constraints: BoxConstraints(minHeight: Screen.height),
child: ExtendedImage.memory(
fileData,
fit: BoxFit.fitWidth,
mode: ExtendedImageMode.gesture,
initGestureConfigHandler: (state) {
return GestureConfig(
minScale: 0.9,
animationMinScale: 0.7,
maxScale: 3.0,
animationMaxScale: 3.5,
speed: 1.0,
inertialSpeed: 100.0,
initialScale: 1.0,
inPageView: true,
initialAlignment: InitialAlignment.center,
);
},
))
],
)),
Positioned(
right: 10,
bottom: 10,
@@ -113,7 +113,7 @@ class _PhotoPageState extends State<PhotoPage>
child: Icon(Icons.save_alt, color: Colors.white70),
)),))
],
)));
))),);
}
saveToGallery() async {


+ 15
- 4
lib/home/audio_chat_view.dart Visa fil

@@ -33,8 +33,9 @@ import 'package:provider/provider.dart';
class AudioChatPage extends StatefulWidget {
final UserInfo userInfo;
final bool isReplay;
AudioChatPage({this.userInfo, this.isReplay = false});
final bool isTranslateButler;
final Function translateButlerCloseCallBack;
AudioChatPage({@required this.userInfo, this.isReplay = false, this.isTranslateButler,this.translateButlerCloseCallBack});
@override
_AudioChatPageState createState() => _AudioChatPageState();
}
@@ -215,7 +216,11 @@ class _AudioChatPageState extends State<AudioChatPage> {
_viewAudio(),
isReply ? _replayToolBar() : _bottomToolBar(),
],
)))
))),
widget.isTranslateButler?Material(child: InkWell(child: Container(color: Colors.yellow,width: 60,height: 60,),onTap: (){
widget.translateButlerCloseCallBack(1);
print('内页内页');
},),):Container()
],
)));
}
@@ -774,7 +779,13 @@ class _AudioChatPageState extends State<AudioChatPage> {
if (!isQuit) {
if (Navigator.canPop(context)) {
isQuit = true;
Navigator.of(context).pop();
if(widget.translateButlerCloseCallBack!=null){
widget.translateButlerCloseCallBack(2);
}else{
Navigator.of(context).pop();
}
SoundUtils().stop();
callingTimer?.cancel();
}


+ 12
- 12
lib/home/realtimehelper/translation_butler_page.dart Visa fil

@@ -75,18 +75,18 @@ class TranslationButlerPageState extends State<TranslationButlerPage> {


Future.delayed(Duration(seconds: 1), () {
CustomUI.buildTranslationHelperOrderDialog(context,true);
// Navigator.of(context).push(
// new MaterialPageRoute(
// builder: (context) {
// return ChatPage(
// key: Key('Chat'),
// friendId: 100006,
// isTranslateButler: true,
// );
// },
// ),
// );
// CustomUI.buildTranslationHelperOrderDialog(context,true);
Navigator.of(context).push(
new MaterialPageRoute(
builder: (context) {
return ChatPage(
key: Key('Chat'),
friendId: 100029,
isTranslateButler: true,
);
},
),
);
});




+ 2
- 2
lib/utils/HttpUtil.dart Visa fil

@@ -44,9 +44,9 @@ class HttpUtil {
//static const String BaseUrl = 'http://192.168.0.223:7001/';
//static const String BaseUrl = 'http://192.168.0.207:9080/';
// static const String BaseUrl = 'http://120.79.107.63:9080/';
static const String BaseUrl = 'http://120.79.107.63:9080/';
//static const String BaseUrl = 'http://192.168.0.177:9016/';
static const String BaseUrl = 'https://datasm.chengyouhd.com/';
// static const String BaseUrl = 'https://datasm.chengyouhd.com/';
static HttpUtil _getInstance() {
if (_instance == null) {


Laddar…
Avbryt
Spara