Просмотр исходного кода

修改图片全屏显示,修改context获取方式

master
kaciya 5 лет назад
Родитель
Сommit
ee3422a1fc
26 измененных файлов: 136 добавлений и 197 удалений
  1. +2
    -0
      android/.settings/org.eclipse.buildship.core.prefs
  2. +2
    -2
      lib/chat/emoji_gif_text.dart
  3. +42
    -76
      lib/chat/full_img_view.dart
  4. +26
    -21
      lib/chat/util_keyboard.dart
  5. +10
    -0
      lib/data/constants.dart
  6. +1
    -2
      lib/home/IndexPage.dart
  7. +3
    -3
      lib/home/InformUser.dart
  8. +0
    -10
      lib/home/alter_select_view.dart
  9. +9
    -10
      lib/home/friend_page.dart
  10. +1
    -3
      lib/home/homeMain.dart
  11. +1
    -2
      lib/home/qr_scanner_view.dart
  12. +2
    -2
      lib/home/service_view.dart
  13. +3
    -4
      lib/home/splash_page.dart
  14. +3
    -7
      lib/main.dart
  15. +1
    -1
      lib/map/google_map_location_picker.dart
  16. +1
    -1
      lib/map/search_input.dart
  17. +11
    -12
      lib/models/last_msg_description.dart
  18. +0
    -13
      lib/photo/ui/page/photo_folder_select_menu.dart
  19. +2
    -2
      lib/utils/HttpUtil.dart
  20. +3
    -3
      lib/utils/LoadingDialog.dart
  21. +1
    -2
      lib/utils/NetUtil.dart
  22. +1
    -1
      lib/utils/app_navigator.dart
  23. +2
    -2
      lib/utils/conversation_table.dart
  24. +2
    -2
      lib/utils/keyboard/bottom_area_avoider.dart
  25. +4
    -13
      lib/utils/receive_share_file.dart
  26. +3
    -3
      lib/utils/upload_util.dart

+ 2
- 0
android/.settings/org.eclipse.buildship.core.prefs Просмотреть файл

@@ -0,0 +1,2 @@
connection.project.dir=
eclipse.preferences.version=1

+ 2
- 2
lib/chat/emoji_gif_text.dart Просмотреть файл

@@ -1,5 +1,5 @@
import 'package:chat/generated/i18n.dart';
import 'package:chat/utils/LoadingDialog.dart';
import 'package:chat/data/constants.dart';
import 'package:extended_text_library/extended_text_library.dart';
import 'package:flutter/material.dart';
@@ -28,7 +28,7 @@ class EmojiGifText extends SpecialText {
imageHeight: size,
start: start,
fit: BoxFit.fill,
margin: EdgeInsets.only(left: 2.0, top: 2.0, right: 2.0)):SpecialTextSpan(text:'[${I18n.of(LoadingManage.context).emoji}]', actualText: '' );
margin: EdgeInsets.only(left: 2.0, top: 2.0, right: 2.0)):SpecialTextSpan(text:'[${I18n.of(Constants.getCurrentContext()).emoji}]', actualText: '' );
// return Image.asset(EmojiGifUitl.instance.emojiMap[key]);


+ 42
- 76
lib/chat/full_img_view.dart Просмотреть файл

@@ -1,14 +1,14 @@
import 'dart:io';
import 'dart:typed_data';
import 'package:chat/chat/download_item.dart';
import 'package:chat/generated/i18n.dart';
import 'package:chat/models/ChatMsg.dart';
import 'package:chat/utils/screen.dart';
import 'package:extended_image/extended_image.dart';
import 'package:flutter/material.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:oktoast/oktoast.dart';
import '../r.dart';
class PhotoPage extends StatefulWidget {
final MsgModel msg;
@@ -20,12 +20,6 @@ class PhotoPage extends StatefulWidget {
class _PhotoPageState extends State<PhotoPage>
with SingleTickerProviderStateMixin {
AnimationController _controller;
Animation<Offset> _animation;
Offset _offset = Offset.zero;
double _scale = 1.0;
Offset _normalizedOffset;
double _previousScale;
double _kMinFlingVelocity = 600.0;
ImageProvider provider;
@@ -37,7 +31,6 @@ class _PhotoPageState extends State<PhotoPage>
_controller = AnimationController(vsync: this);
_controller.addListener(() {
setState(() {
_offset = _animation.value;
});
});
}
@@ -59,75 +52,50 @@ class _PhotoPageState extends State<PhotoPage>
super.dispose();
}
Offset _clampOffset(Offset offset) {
final Size size = context.size;
// widget的屏幕宽度
final Offset minOffset = Offset(size.width, size.height) * (1.0 - _scale);
// 限制他的最小尺寸
return Offset(
offset.dx.clamp(minOffset.dx, 0.0), offset.dy.clamp(minOffset.dy, 0.0));
}
void _handleOnScaleStart(ScaleStartDetails details) {
setState(() {
_previousScale = _scale;
_normalizedOffset = (details.focalPoint - _offset) / _scale;
// 计算图片放大后的位置
_controller.stop();
});
}
void _handleOnScaleUpdate(ScaleUpdateDetails details) {
setState(() {
_scale = (_previousScale * details.scale).clamp(1.0, 3.0);
// 限制放大倍数 1~3倍
_offset = _clampOffset(details.focalPoint - _normalizedOffset * _scale);
// 更新当前位置
});
}
void _handleOnScaleEnd(ScaleEndDetails details) {
final double magnitude = details.velocity.pixelsPerSecond.distance;
if (magnitude < _kMinFlingVelocity) return;
final Offset direction = details.velocity.pixelsPerSecond / magnitude;
// 计算当前的方向
final double distance = (Offset.zero & context.size).shortestSide;
// 计算放大倍速,并相应的放大宽和高,比如原来是600*480的图片,放大后倍数为1.25倍时,宽和高是同时变化的
_animation = _controller.drive(Tween<Offset>(
begin: _offset, end: _clampOffset(_offset + direction * distance)));
_controller
..value = 0.0
..fling(velocity: magnitude / 1000.0);
}
@override
Widget build(BuildContext context) {
Uint8List fileData;
if (widget.msg.localFile != null) {
fileData = File(widget.msg.localFile).readAsBytesSync();
} else {
fileData = Uint8List.fromList(widget.msg.msgContent);
}
return GestureDetector(
onTap: () {
Navigator.pop(context);
},
onScaleStart: _handleOnScaleStart,
onScaleUpdate: _handleOnScaleUpdate,
onScaleEnd: _handleOnScaleEnd,
child: Material(
child: DownloadItem(
msg: widget.msg,
isAutoDown: false,
onComplete: () {
getImgData();
setState(() {});
onTap: () {
Navigator.pop(context);
},
child: Transform(
transform: Matrix4.identity()
..translate(_offset.dx, _offset.dy)
..scale(_scale),
child: Container(
width: Screen.width,
height: Screen.height,
alignment: Alignment.center,
child: Stack(
children: <Widget>[
Image(
fit: BoxFit.fitWidth,
image: provider ?? AssetImage(R.assetsImagesIcAlbum),
),
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,
);
},
))
],
)),
Positioned(
right: 10,
bottom: 10,
@@ -141,14 +109,12 @@ class _PhotoPageState extends State<PhotoPage>
child: Icon(Icons.save_alt, color: Colors.white70),
)))
],
)),
)),
);
)));
}
saveToGallery() async {
if (widget.msg.localFile != null) {
var data= File(widget.msg.localFile).readAsBytesSync();
var data = File(widget.msg.localFile).readAsBytesSync();
ImageGallerySaver.saveImage(data).then((res) {
print(res);
if (res != null) {


+ 26
- 21
lib/chat/util_keyboard.dart Просмотреть файл

@@ -13,7 +13,7 @@ import 'package:chat/proto/all.pbserver.dart';
import 'package:chat/utils/ChargeMoney.dart';
import 'package:chat/utils/CustomUI.dart';
import 'package:chat/utils/HttpUtil.dart';
import 'package:chat/utils/LoadingDialog.dart';
import 'package:chat/data/constants.dart';
import 'package:chat/utils/app_navigator.dart';
import 'package:chat/utils/blacklist_mgr.dart';
import 'package:chat/utils/image_util.dart';
@@ -33,13 +33,18 @@ import 'package:file_picker/file_picker.dart';
import '../r.dart';
class UtilKeyboard extends StatelessWidget {
class UtilKeyboard extends StatefulWidget {
final double keyboardHeight;
final Function sendMsg;
final bool isGroup;
UtilKeyboard({this.keyboardHeight, this.sendMsg, this.isGroup});
bool isAuthority = false;
@override
_UtilKeyboardState createState() => _UtilKeyboardState();
}
class _UtilKeyboardState extends State<UtilKeyboard> {
bool isAuthority = false;
@override
Widget build(BuildContext context) {
@@ -58,7 +63,7 @@ class UtilKeyboard extends StatelessWidget {
_sendVideo(context);
}));
if (!isGroup) {
if (!widget.isGroup) {
iconList.add(
_buildOtherSelect(R.assetsImagesChatItem3, I18n.of(context).chat, () {
_audioChat(context);
@@ -70,7 +75,7 @@ class UtilKeyboard extends StatelessWidget {
_openMap(context);
}));
if (!isGroup) {
if (!widget.isGroup) {
iconList.add(Offstage(
offstage: !isShowRedPacket,
child: _buildOtherSelect(
@@ -91,7 +96,7 @@ class UtilKeyboard extends StatelessWidget {
return Container(
width: Screen.width,
color: Colors.white,
height: keyboardHeight,
height: widget.keyboardHeight,
padding: EdgeInsets.only(top: 20, bottom: 10, left: 20),
alignment: Alignment.topLeft,
child: Wrap(spacing: 10.0, runSpacing: 20.0, children: iconList));
@@ -99,7 +104,7 @@ class UtilKeyboard extends StatelessWidget {
_showGiftSheet(BuildContext context) {
int friendId = 0;
if (!isGroup) {
if (!widget.isGroup) {
friendId = Provider.of<int>(context);
}
@@ -113,7 +118,7 @@ class UtilKeyboard extends StatelessWidget {
builder: (BuildContext context) {
return StatefulBuilder(
builder: (BuildContext context, setBottomSheetState) {
return GiftSelectWidget(friendId, sendMsg);
return GiftSelectWidget(friendId, widget.sendMsg);
},
);
});
@@ -135,16 +140,16 @@ class UtilKeyboard extends StatelessWidget {
var reslutStr = jsonEncode(result);
int friendId = 0;
if (!isGroup) {
if (!widget.isGroup) {
friendId = Provider.of<int>(context);
}
var msg = MsgHandler.createSendMsg(
ChatType.PlaceChatType, utf8.encode(reslutStr),
friendId: friendId,
channelType:
isGroup ? ChatChannelType.Group : ChatChannelType.Session);
widget.isGroup ? ChatChannelType.Group : ChatChannelType.Session);
sendMsg(msg);
widget.sendMsg(msg);
}
}
@@ -284,7 +289,7 @@ class UtilKeyboard extends StatelessWidget {
int aspectRatio = rect.width * 100 ~/ rect.height;
int friendId = 0;
if (!isGroup) {
if (!widget.isGroup) {
friendId = Provider.of<int>(context);
}
var msg = MsgHandler.createSendMsg(ChatType.ImageChatType, sendImg,
@@ -292,9 +297,9 @@ class UtilKeyboard extends StatelessWidget {
friendId: friendId,
localFile: isNeedUpload ? imgFile.absolute.path : null,
channelType:
isGroup ? ChatChannelType.Group : ChatChannelType.Session);
widget.isGroup ? ChatChannelType.Group : ChatChannelType.Session);
sendMsg(msg);
widget.sendMsg(msg);
}
}
@@ -309,7 +314,7 @@ class UtilKeyboard extends StatelessWidget {
}
int friendId = 0;
if (!isGroup) {
if (!widget.isGroup) {
friendId = Provider.of<int>(context);
}
@@ -332,9 +337,9 @@ class UtilKeyboard extends StatelessWidget {
friendId: friendId,
localFile: file.path,
channelType:
isGroup ? ChatChannelType.Group : ChatChannelType.Session);
widget.isGroup ? ChatChannelType.Group : ChatChannelType.Session);
sendMsg(msg);
widget.sendMsg(msg);
}
@@ -349,7 +354,7 @@ class UtilKeyboard extends StatelessWidget {
print('视频大小:$videoSize');
if (videoSize > 33 * 1024 * 1024) {
showToast(I18n.of(LoadingManage.context).video_more_big);
showToast(I18n.of(Constants.getCurrentContext()).video_more_big);
return;
}
@@ -361,7 +366,7 @@ class UtilKeyboard extends StatelessWidget {
int aspectRatio = rect.width * 100 ~/ rect.height;
int friendId = 0;
if (!isGroup) {
if (!widget.isGroup) {
friendId = Provider.of<int>(context);
}
var msg = MsgHandler.createSendMsg(ChatType.ShortVideoChatType, thumbnail,
@@ -369,9 +374,9 @@ class UtilKeyboard extends StatelessWidget {
friendId: friendId,
localFile: video.path,
channelType:
isGroup ? ChatChannelType.Group : ChatChannelType.Session);
widget.isGroup ? ChatChannelType.Group : ChatChannelType.Session);
sendMsg(msg);
widget.sendMsg(msg);
}
}


+ 10
- 0
lib/data/constants.dart Просмотреть файл

@@ -109,6 +109,16 @@ class Constants {
///ture 应用商店版本 false线下渠道
static const bool isStoreVersion = false;
//app全局key,处理content
static final GlobalKey<NavigatorState> navigatorKey = GlobalKey();
/// 获取当前的state
static NavigatorState getCurrentState() => navigatorKey.currentState;
/// 获取当前的context
static BuildContext getCurrentContext() => navigatorKey.currentContext;
///在pubspec.yaml中修改版本号
static String versionName = '1.0.0';


+ 1
- 2
lib/home/IndexPage.dart Просмотреть файл

@@ -1,6 +1,5 @@
import 'package:chat/data/UserData.dart';
import 'package:chat/generated/i18n.dart';
import 'package:chat/utils/LoadingDialog.dart';
import 'package:chat/utils/screen.dart';
import 'package:connectivity/connectivity.dart';
import 'package:flutter/cupertino.dart';
@@ -153,7 +152,7 @@ class _IndexPageState extends State<IndexPage> {
return;
}
if (resData['data'] != null) {
HttpUtil().changePage(LoadingManage.context, resData);
HttpUtil().changePage(Constants.getCurrentContext(), resData);
}
}


+ 3
- 3
lib/home/InformUser.dart Просмотреть файл

@@ -27,7 +27,7 @@ enum reason {
liar,
}
int Max_Img_Num = 4;
const int MaxImgNum = 4;
class InformUserPage extends StatefulWidget {
@required
@@ -182,7 +182,7 @@ class _InformUserPageState extends State<InformUserPage> {
var photos = await PhotoPicker.pickAsset(
context: context,
themeColor: Color(0xFFF0F0F0),
maxSelected: Max_Img_Num - imgUrlList.length,
maxSelected: MaxImgNum - imgUrlList.length,
textColor: Color(0xFF3F3F3F),
pickType: PickType.onlyImage);
@@ -346,7 +346,7 @@ class _InformUserPageState extends State<InformUserPage> {
List<Widget> list = imgUrlList.map((f) {
return _buildImg(f);
}).toList();
if (list.length < Max_Img_Num) {
if (list.length < MaxImgNum) {
list.add(upButton);
}
var socialCard = new Container(


+ 0
- 10
lib/home/alter_select_view.dart Просмотреть файл

@@ -187,16 +187,6 @@ class _AlterSelectPageState extends State<AlterSelectPage> {
}
}
Widget _buildAvatar(url) {
return ClipRRect(
borderRadius: BorderRadius.circular(6),
child: CachedNetworkImage(
imageUrl: url,
width: Constants.ContactAvatarSize,
height: Constants.ContactAvatarSize,
));
}
String getLetter(BuildContext context, double tileHeight, Offset globalPos) {
RenderBox _box = context.findRenderObject();
var local = _box.globalToLocal(globalPos);


+ 9
- 10
lib/home/friend_page.dart Просмотреть файл

@@ -12,7 +12,6 @@ import 'package:chat/generated/i18n.dart';
import 'package:chat/models/ref_name_provider.dart';
import 'package:chat/utils/CustomUI.dart';
import 'package:chat/utils/HttpUtil.dart';
import 'package:chat/utils/LoadingDialog.dart';
import 'package:chat/utils/MessageMgr.dart';
import 'package:chat/utils/TokenMgr.dart';
import 'package:chat/utils/conversation_table.dart';
@@ -93,7 +92,7 @@ class _FriendPageState extends State<FriendPage> {
avatar: '',
userId: 0,
iconCode: 0xe66c,
title: I18n.of(LoadingManage.context).new_friends,
title: I18n.of(Constants.getCurrentContext()).new_friends,
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
@@ -187,11 +186,11 @@ class _FriendPageState extends State<FriendPage> {
showPermission() async {
if (await CustomUI.showPermissionSetting(
LoadingManage.context,
Constants.getCurrentContext(),
PermissionGroup.contacts,
I18n.of(LoadingManage.context).contact_permission)) {
I18n.of(Constants.getCurrentContext()).contact_permission)) {
MessageMgr().emit('PostContact');
Navigator.push(LoadingManage.context,
Navigator.push(Constants.getCurrentContext(),
MaterialPageRoute<void>(builder: (BuildContext context) {
return ContactsPage();
}));
@@ -259,7 +258,7 @@ class _FriendPageState extends State<FriendPage> {
avatar: '',
userId: 0,
iconCode: 0xe659,
title: I18n.of(LoadingManage.context).scan,
title: I18n.of(Constants.getCurrentContext()).scan,
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
@@ -268,14 +267,14 @@ class _FriendPageState extends State<FriendPage> {
const Color(0xFF3441C1),
]),
onPressed: () {
CustomUI().goScanPage(LoadingManage.context);
CustomUI().goScanPage(Constants.getCurrentContext());
}),
FriendsInfo(
avatar: '',
userId: 0,
iconCode: 0xe67a,
isShowDivder: true,
title: I18n.of(LoadingManage.context).contact_add,
title: I18n.of(Constants.getCurrentContext()).contact_add,
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
@@ -303,7 +302,7 @@ class _FriendPageState extends State<FriendPage> {
userId: 0,
iconCode: 0xe662,
isShowDivder: true,
title: I18n.of(LoadingManage.context).add_friends,
title: I18n.of(Constants.getCurrentContext()).add_friends,
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
@@ -312,7 +311,7 @@ class _FriendPageState extends State<FriendPage> {
const Color(0xFF6118A6),
]),
onPressed: () async {
Navigator.push(LoadingManage.context,
Navigator.push(Constants.getCurrentContext(),
MaterialPageRoute<void>(builder: (BuildContext context) {
return SearchNewFriendsPage();
}));


+ 1
- 3
lib/home/homeMain.dart Просмотреть файл

@@ -8,7 +8,6 @@ import 'package:chat/home/unread_dot_widget.dart';
import 'package:chat/models/UserInfo.dart';
import 'package:chat/models/ref_name_provider.dart';
import 'package:chat/utils/HttpUtil.dart';
import 'package:chat/utils/LoadingDialog.dart';
import 'package:chat/utils/MessageMgr.dart';
import 'package:chat/utils/TokenMgr.dart';
import 'package:chat/utils/app_navigator.dart';
@@ -142,7 +141,6 @@ class _HomeMainState extends State<HomeMain> {
@override
void initState() {
MsgHandler.context = context;
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light);
super.initState();
@@ -253,7 +251,7 @@ class _HomeMainState extends State<HomeMain> {
goShareInfo(data) async {
Future.delayed(Duration(milliseconds: 1000), () {
Navigator.of(LoadingManage.context).push(
Navigator.of(Constants.getCurrentContext()).push(
new MaterialPageRoute(
builder: (context) {
return FilePreview(data);


+ 1
- 2
lib/home/qr_scanner_view.dart Просмотреть файл

@@ -7,7 +7,6 @@ import 'package:chat/data/group_data_mgr.dart';
import 'package:chat/generated/i18n.dart';
import 'package:chat/home/qr_scanner_overlay.dart';
import 'package:chat/utils/CustomUI.dart';
import 'package:chat/utils/LoadingDialog.dart';
import 'package:chat/utils/MessageMgr.dart';
import 'package:chat/utils/app_navigator.dart';
import 'package:flutter/material.dart';
@@ -208,7 +207,7 @@ class _QrScannerPageState extends State<QrScannerPage>
showToast(I18n.of(context).no_goupr_info);
return;
}
Navigator.push(LoadingManage.context,
Navigator.push(Constants.getCurrentContext(),
MaterialPageRoute<void>(builder: (BuildContext context) {
return JoinGroupConfirmPage(
groupInfoModel: groupInfo,


+ 2
- 2
lib/home/service_view.dart Просмотреть файл

@@ -32,8 +32,8 @@ class ServiceMsgModel {
}
class ServiceCenterPage extends StatefulWidget {
int questionIndex = -1;
ServiceCenterPage(this.questionIndex);
final int questionIndex;
ServiceCenterPage({this.questionIndex = -1});
@override
_ServiceCenterPageState createState() => _ServiceCenterPageState();


+ 3
- 4
lib/home/splash_page.dart Просмотреть файл

@@ -1,5 +1,4 @@
import 'package:chat/generated/i18n.dart';
import 'package:chat/utils/LoadingDialog.dart';
import 'package:chat/utils/screen.dart';
import 'package:chat/utils/sp_utils.dart';
import 'package:flutter/cupertino.dart';
@@ -34,11 +33,11 @@ class SplashPageState extends State<SplashPage> {
void initState() {
super.initState();

list.add(SplashBean('assets/images/img_splash_1.png',I18n.of( LoadingManage.context).splash_tips1 , I18n.of( LoadingManage.context).splash_tips_content1,
list.add(SplashBean('assets/images/img_splash_1.png',I18n.of( Constants.getCurrentContext()).splash_tips1 , I18n.of( Constants.getCurrentContext()).splash_tips_content1,
Color(0xffEC527D)));
list.add(SplashBean('assets/images/img_splash_2.png', I18n.of( LoadingManage.context).splash_tips2, I18n.of( LoadingManage.context).splash_tips_content2,
list.add(SplashBean('assets/images/img_splash_2.png', I18n.of( Constants.getCurrentContext()).splash_tips2, I18n.of( Constants.getCurrentContext()).splash_tips_content2,
Color(0xffB439EB)));
list.add(SplashBean('assets/images/img_splash_3.png', I18n.of( LoadingManage.context).splash_tips3, I18n.of( LoadingManage.context).splash_tips_content3,
list.add(SplashBean('assets/images/img_splash_3.png', I18n.of( Constants.getCurrentContext()).splash_tips3, I18n.of( Constants.getCurrentContext()).splash_tips_content3,
Color(0xff2B79F7)));

pageController = PageController(


+ 3
- 7
lib/main.dart Просмотреть файл

@@ -12,7 +12,6 @@ import 'package:chat/home/splash_page.dart';
import 'package:chat/models/gift_select_provider.dart';
import 'package:chat/models/money_change.dart';
import 'package:chat/models/ref_name_provider.dart';
import 'package:chat/utils/LoadingDialog.dart';
import 'package:chat/utils/MessageMgr.dart';
import 'package:chat/utils/NetUtil.dart';
import 'package:chat/utils/OtherLogin.dart';
@@ -115,7 +114,7 @@ void setCustomErrorPage(BuildContext context) {
Container(
margin: EdgeInsets.only(top: ScreenUtil().setHeight(50)),
child: Text(
I18n.of(LoadingManage.context).server_error_tips,
I18n.of(Constants.getCurrentContext()).server_error_tips,
style: TextStyle(color: Color(0xFF8F8E8E), fontSize: 18),
),
),
@@ -214,7 +213,6 @@ class MyApp extends StatefulWidget {
_MyAppState createState() => _MyAppState();
}
final GlobalKey<NavigatorState> navigatorKey = new GlobalKey<NavigatorState>();
class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
final i18n = I18n.delegate;
@@ -232,7 +230,6 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
initVersionName();
askLocationPermission();
MsgHandler.context = context;
I18n.onLocaleChanged = onLocaleChange;
WidgetsBinding.instance.addObserver(this);
ReceiveShareFile.init();
@@ -385,7 +382,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
// 此处
return 'Hibok';
},
navigatorKey: navigatorKey,
navigatorKey: Constants.navigatorKey,
routes: <String, WidgetBuilder>{
'/main': (BuildContext context) => HomeMain(),
},
@@ -410,8 +407,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
}
goIndex() {
LoadingManage.context = navigatorKey.currentState.overlay.context;
if (!isOpen) {
return SplashPage();
} else {


+ 1
- 1
lib/map/google_map_location_picker.dart Просмотреть файл

@@ -137,7 +137,7 @@ class LocationPickerState extends State<LocationPicker> {
),
Expanded(
child: Text(
"Finding place...",
"搜索中...",
style: TextStyle(
fontSize: 16,
),


+ 1
- 1
lib/map/search_input.dart Просмотреть файл

@@ -80,7 +80,7 @@ class SearchInputState extends State {
keyboardAppearance: Brightness.light,
style: TextStyle(textBaseline: TextBaseline.alphabetic),
decoration: InputDecoration(
hintText: 'Search place',
hintText: '搜索位置',
border: InputBorder.none,
),
controller: editController,


+ 11
- 12
lib/models/last_msg_description.dart Просмотреть файл

@@ -8,7 +8,6 @@ import 'package:chat/models/last_message_model.dart';
import 'package:chat/models/ref_name_provider.dart';
import 'package:chat/proto/chat.pb.dart';
import 'package:chat/utils/HttpUtil.dart';
import 'package:chat/utils/LoadingDialog.dart';
import 'package:chat/utils/MessageMgr.dart';
import 'package:chat/utils/msgHandler.dart';
import 'package:chat/utils/screen.dart';
@@ -82,19 +81,19 @@ class _LastMsgDescriptionState extends State<LastMsgDescription> {
}
break;
case ChatType.EmoticonType:
desc = '[${I18n.of(LoadingManage.context).emoji}]';
desc = '[${I18n.of(Constants.getCurrentContext()).emoji}]';
break;
case ChatType.ImageChatType:
desc = '[${I18n.of(LoadingManage.context).picture}]';
desc = '[${I18n.of(Constants.getCurrentContext()).picture}]';
break;
case ChatType.ShortVideoChatType:
desc = '[${I18n.of(LoadingManage.context).video}]';
desc = '[${I18n.of(Constants.getCurrentContext()).video}]';
break;
case ChatType.PlaceChatType:
desc = '[${I18n.of(LoadingManage.context).locate}]';
desc = '[${I18n.of(Constants.getCurrentContext()).locate}]';
break;
case ChatType.ShortVoiceChatType:
desc = '[${I18n.of(LoadingManage.context).voice}]';
desc = '[${I18n.of(Constants.getCurrentContext()).voice}]';
break;
case ChatType.GiftChatType:
@@ -102,9 +101,9 @@ class _LastMsgDescriptionState extends State<LastMsgDescription> {
GiftChat.fromBuffer(widget.lastMessageModel.msgContent);
if (giftChat.tuId == UserData().basicInfo.userId) {
desc = I18n.of(LoadingManage.context).you_get;
desc = I18n.of(Constants.getCurrentContext()).you_get;
} else {
desc = I18n.of(LoadingManage.context).you_give;
desc = I18n.of(Constants.getCurrentContext()).you_give;
}
break;
@@ -118,21 +117,21 @@ class _LastMsgDescriptionState extends State<LastMsgDescription> {
if (wallet.state == RedWalletState.Received) {
var myId = UserData().basicInfo.userId;
if (wallet.suId == myId) {
desc = I18n.of(LoadingManage.context)
desc = I18n.of(Constants.getCurrentContext())
.get_money
.replaceFirst('/s1', fdName);
} else {
desc = I18n.of(LoadingManage.context)
desc = I18n.of(Constants.getCurrentContext())
.you_get_money
.replaceFirst('/s1', fdName);
}
} else if (wallet.state == RedWalletState.Expire) {
desc = I18n.of(LoadingManage.context).money_over;
desc = I18n.of(Constants.getCurrentContext()).money_over;
} else {
print('WWWWW${wallet.state}');
}
} else {
desc = '[${I18n.of(LoadingManage.context).red_money}]';
desc = '[${I18n.of(Constants.getCurrentContext()).red_money}]';
}
break;


+ 0
- 13
lib/photo/ui/page/photo_folder_select_menu.dart Просмотреть файл

@@ -88,19 +88,6 @@ class _PhotoSelectMenuState extends State<PhotoSelectMenu> {
setState(() {});
}
Widget _mask() {
return GestureDetector(
onTap: () {
print('到mask了');
clearOverlay();
},
child: Expanded(
child: Container(
width: MediaQuery.of(context).size.width,
color: Color.fromRGBO(0, 0, 0, 0.1),
)));
}
void clearOverlay() {
if (overlayEntry != null) {
overlayEntry.remove();


+ 2
- 2
lib/utils/HttpUtil.dart Просмотреть файл

@@ -87,7 +87,7 @@ class HttpUtil {
return response; // continue
}, onError: (DioError e) async {
// Do something with response error
showToast(I18n.of(LoadingManage.context).net_error);
showToast(I18n.of(Constants.getCurrentContext()).net_error);
return e; //continue
}));
}
@@ -172,7 +172,7 @@ class HttpUtil {
}
print('post请求发生错误:$e');
if (isShowLoading) LoadingManage().closeLoading();
showToast(I18n.of(LoadingManage.context).server_error_tips);
showToast(I18n.of(Constants.getCurrentContext()).server_error_tips);
if (failback != null) failback();
}
return response;


+ 3
- 3
lib/utils/LoadingDialog.dart Просмотреть файл

@@ -5,6 +5,7 @@
import 'package:flutter/material.dart';
import 'package:chat/utils/my_dialog.dart' as myDialog;
import 'package:chat/data/constants.dart';
class LoadingManage {
//私有构造函数
@@ -16,10 +17,9 @@ class LoadingManage {
//工厂构造函数
factory LoadingManage() => _singleton;
static BuildContext context;
showLoading() {
myDialog.showDialog(
context: context,
context: Constants.getCurrentContext(),
barrierDismissible: true,
builder: (BuildContext context) {
return LoadingDialog();
@@ -27,7 +27,7 @@ class LoadingManage {
}
closeLoading() {
Navigator.of(context).pop();
Constants.getCurrentState().pop();
}
}


+ 1
- 2
lib/utils/NetUtil.dart Просмотреть файл

@@ -9,7 +9,6 @@ import 'package:chat/data/constants.dart';
import 'package:chat/data/group_data_mgr.dart';
import 'package:chat/generated/i18n.dart';
import 'package:chat/proto/all.pbserver.dart';
import 'package:chat/utils/LoadingDialog.dart';
import 'package:chat/utils/net_state_util.dart';
import 'package:chat/utils/screen.dart';
import 'package:chat/utils/upload_util.dart';
@@ -164,7 +163,7 @@ class NetWork {
} else {
_stateBloc.addState(ChatState.loginFailed);
print('登录失败${msgContent.errorCode}');
showToast(I18n.of(LoadingManage.context).fail);
showToast(I18n.of(Constants.getCurrentContext()).fail);
}
} else if (msgId == 3) {
//用户登出,其他设备替换


+ 1
- 1
lib/utils/app_navigator.dart Просмотреть файл

@@ -134,7 +134,7 @@ class AppNavigator {
//客服
static pushServicePage(BuildContext context, {questionIndex = -1}) async {
AppNavigator.push(context, ServiceCenterPage(questionIndex));
AppNavigator.push(context, ServiceCenterPage(questionIndex : questionIndex));
}
//群成员列表


+ 2
- 2
lib/utils/conversation_table.dart Просмотреть файл

@@ -1,7 +1,7 @@
import 'package:chat/data/UserData.dart';
import 'package:chat/models/UserInfo.dart';
import 'package:chat/models/ref_name_provider.dart';
import 'package:chat/utils/LoadingDialog.dart';
import 'package:chat/data/constants.dart';
import 'package:chat/utils/sql_model.dart';
import 'package:flutter/material.dart';
import 'package:lpinyin/lpinyin.dart';
@@ -39,7 +39,7 @@ class FriendModel {
}
updataRefName() {
refName = Provider.of<RefNameProvider>(LoadingManage.context, listen: false)
refName = Provider.of<RefNameProvider>(Constants.getCurrentContext(), listen: false)
.getRefName(friendId, name);
nameTag = getNameTag();
}


+ 2
- 2
lib/utils/keyboard/bottom_area_avoider.dart Просмотреть файл

@@ -38,7 +38,7 @@ class BottomAreaAvoider extends StatefulWidget {
/// Animation curve. Defaults to [defaultCurve]
final Curve curve;

ScrollController scrollTo;
final ScrollController scrollTo;

BottomAreaAvoider({
Key key,
@@ -181,7 +181,7 @@ RenderObject findFocusedObject(RenderObject root) {
final q = Queue<RenderObject>();
q.add(root);
while (q.isNotEmpty) {
final node = q.removeFirst();
final RenderObject node = q.removeFirst();
final config = SemanticsConfiguration();
node.describeSemanticsConfiguration(config);
if (config.isFocused) {


+ 4
- 13
lib/utils/receive_share_file.dart Просмотреть файл

@@ -1,31 +1,23 @@
import 'dart:async';

import 'package:receive_sharing_intent/receive_sharing_intent.dart';

import 'MessageMgr.dart';

class ReceiveShareFile {
static StreamSubscription _intentDataStreamSubscription;
static List<SharedMediaFile> _sharedFiles;
static String tempFilePath;

static int mLastClickTime = 0;
static final int TIME_INTERVAL = 3000;
static int timeInterval = 3000;

static void init() {
// For sharing images coming from outside the app while the app is in the memory
_intentDataStreamSubscription = ReceiveSharingIntent.getMediaStream()
ReceiveSharingIntent.getMediaStream()
.listen((List<SharedMediaFile> value) {
// setState(() {
// _sharedFiles = value;
// print("Shared:" + (_sharedFiles?.map((f) => f.path)?.join(",") ?? ""));
// });
// print('#### getfilePath ${value[0].path}');

if (currentIndex == 1) {
int nowTime = DateTime.now().millisecondsSinceEpoch;

if (nowTime - mLastClickTime > TIME_INTERVAL) {
if (nowTime - mLastClickTime > timeInterval) {
if (value != null && value.length > 0) {
MessageMgr().emit(MessageMgr.RECEIVE_THIRD_SHARE, value[0].path);
}
@@ -51,7 +43,7 @@ class ReceiveShareFile {

if (currentIndex == 1) {
int nowTime = DateTime.now().millisecondsSinceEpoch;
if (nowTime - mLastClickTime > TIME_INTERVAL) {
if (nowTime - mLastClickTime > timeInterval) {
// do something
if (value != null && value.length > 0) {
MessageMgr().emit(MessageMgr.RECEIVE_THIRD_SHARE, value[0].path);
@@ -67,7 +59,6 @@ class ReceiveShareFile {
});

// For sharing or opening urls/text coming from outside the app while the app is in the memory
_intentDataStreamSubscription =
ReceiveSharingIntent.getTextStream().listen((String value) {
print('#### getfilePath $value ');
// setState(() {


+ 3
- 3
lib/utils/upload_util.dart Просмотреть файл

@@ -5,7 +5,7 @@ import 'package:chat/models/ChatMsg.dart';
import 'package:chat/models/group_info_model.dart';
import 'package:chat/models/group_info_server_model.dart';
import 'package:chat/proto/all.pbserver.dart';
import 'package:chat/utils/LoadingDialog.dart';
import 'package:chat/data/constants.dart';
import 'package:chat/utils/file_cache_mgr.dart';
import 'package:convert/convert.dart';
import 'package:dio/dio.dart';
@@ -224,12 +224,12 @@ class UploadUtil {
return path;
} else {
msg.state = MsgState.DownloadFailed;
showToast(I18n.of(LoadingManage.context).server_error_tips);
showToast(I18n.of(Constants.getCurrentContext()).server_error_tips);
return null;
}
} catch (e) {
msg.state = MsgState.DownloadFailed;
showToast(I18n.of(LoadingManage.context).server_error_tips);
showToast(I18n.of(Constants.getCurrentContext()).server_error_tips);
print(response.toString());
}
}


Загрузка…
Отмена
Сохранить