Skip to content

Commit

Permalink
feat:增加聊天通知栏弹出,增加修改昵称。
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeeYudE committed Aug 22, 2022
1 parent 6da9dc1 commit bd21d07
Show file tree
Hide file tree
Showing 24 changed files with 359 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- '[Build]'

env:
tag_name : v1.0.3
tag_name : v1.0.4

jobs:

Expand Down
44 changes: 38 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
A new Wechat project.

# 介绍
wechat_flutter是flutter版微信,目前功能还在持续迭代,尽量还原原版微信功能。
Flutter版本:3.0.0
wechat_flutter是flutter版微信,目前只支持Android端,功能还在持续迭代,尽量还原原版微信功能。
Flutter版本:3.0.0


#测试账号 18202003769 密码 Bb123456

下载体验(Android)
[https://github.com/LeeeYudE/flutter_wechat/releases/download/v1.0.2/app-release.apk](https://github.com/LeeeYudE/flutter_wechat/releases/download/v1.0.2/app-release.apk)
[https://github.com/LeeeYudE/flutter_wechat/releases/download/v1.0.4/app-release.apk](https://github.com/LeeeYudE/flutter_wechat/releases/download/v1.0.4/app-release.apk)

<img src="screenshot/qrcode.png" style="zoom:30%;" />

Expand All @@ -19,15 +19,16 @@ Flutter版本:3.0.0
| ![1.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/screenshot/screenshot0.gif) | ![2.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/screenshot/screenshot1.gif) | ![3.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/screenshot/screenshot9.gif) |
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|
| ![4.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/screenshot/screenshot3.gif) | ![5.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/screenshot/screenshot4.gif) | ![6.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/screenshot/screenshot5.gif) |
| ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|
| ![7.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/screenshot/screenshot6.gif) | ![8.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master//screenshot/screenshot7.gif) | ![9.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/screenshot/screenshot8.gif) |
| ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |


#Api方案采用Leancloud
* 数据存储文档:https://zh-docs.leancloud.app/leanstorage_guide-flutter.html
* IM聊天文档:https://zh-docs.leancloud.app/realtime-guide-beginner.html

# log
* 2022.08.22 增加聊天通知栏弹出,增加修改昵称。
* 2022.08.19 聊天页增加(录音/图片/视频/文件)消息发送流程。
* 2022.08.18 首页增加Uniapp小程序跳转,设置页增加小程序wgt文件上传。
* 2022.08.15 增加视频号流程,支持上传视频。
Expand Down Expand Up @@ -59,4 +60,35 @@ Flutter版本:3.0.0
* style: 格式(不影响代码运行的变动)
* refactor:重构(即不是新增功能,也不是修改bug的代码变动)
* test:增加测试
* chore:构建过程或辅助工具的变动
* chore:构建过程或辅助工具的变动

# 第三方框架

|| 功能 |
|------------------------------|-----------|
| leancloud | 即时通讯和数据储存 |
| getx | 状态管理 |
| cached_network_image | 图片缓存 |
| wechat_assets_picker | 微信选图 |
| wechat_camera_picker | 微信拍照 |
| flutter_baidu_mapapi_map | 百度地图 |
| flustars | 常用工具类 |
| permission_handler | 权限申请 |
| extended_image_library | 图片预览 |
| webview_flutter | web页面 |
| image_gallery_saver | 保存图片 |
| flutter_audio_recorder2 | 录音 |
| extended_text_field | 富文本输入 |
| flutter_luban | 图片压缩 |
| qr_code_scanner | 扫一扫 |
| flutter_local_auth_invisible | 生物验证 |
| chewie | 视频播放 |
| video_compress | 视频压缩 |
| video_editor | 视频编辑 |
| audioplayers | 音频播放 |
| flutter_local_notifications | 本地通知 |
| lottie | lottie动画 |

项目部分参考: https://github.com/fluttercandies/wechat_flutter
如有什么微信的功能需要开发,欢迎提到Issues。

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions lib/app_pages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import 'package:wechat/page/main/discover/shake_page.dart';
import 'package:wechat/page/main/map/nearby_location_page.dart';
import 'package:wechat/page/main/map/preview_loctaion_page.dart';
import 'package:wechat/page/main/map/select_location_page.dart';
import 'package:wechat/page/main/mine/edit_nickname_page.dart';
import 'package:wechat/page/main/mine/language_setting_page.dart';
import 'package:wechat/page/main/mine/setting_page.dart';
import 'package:wechat/page/main/discover/scan_qrcode_page.dart';
Expand Down Expand Up @@ -237,6 +238,10 @@ class AppPages {
name: TestAccountsPage.routeName,
page: () => const TestAccountsPage(),
),
_getPage(
name: EditNicknamePage.routeName,
page: () => EditNicknamePage(),
),
];

static GetPage _getPage({
Expand Down
7 changes: 6 additions & 1 deletion lib/base/base_getx.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'package:get/get.dart';
import 'package:leancloud_storage/leancloud.dart';
import 'package:wechat/utils/dialog_util.dart';

import '../utils/navigator_utils.dart';

enum ViewState { Init, Idle, Busy, Error, Empty }

///Controller
Expand Down Expand Up @@ -50,7 +52,7 @@ abstract class BaseXController extends GetxController {
DialogUtil.disimssLoading();
}

Future<bool> lcPost(Function function,{ValueChanged<Exception>? onError,bool? showloading = true,bool? showToast = true,String? loadingMsg,bool changeState = false , bool updated = true,}) async {
Future<bool> lcPost(Function function,{ValueChanged<Exception>? onError,bool? showloading = true,bool? showToast = true,String? loadingMsg,bool changeState = false , bool updated = true,bool pop = false}) async {
if(showloading??false) {
showLoading(msg: loadingMsg);
}
Expand All @@ -67,6 +69,9 @@ abstract class BaseXController extends GetxController {
if(showloading??false) {
disimssLoading();
}
if(pop){
NavigatorUtils.pop(true);
}
return true;
}on Exception catch (e){
if(e is LCException){
Expand Down
4 changes: 4 additions & 0 deletions lib/base/constant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ class Constant{

Constant._();


///隐私条例
static const String SOFTWARE_LICENSING = 'https://weixin.qq.com/cgi-bin/readtemplate?lang=en&t=weixin_agreement&s=default&cc=CN';

static const String JMESSAGE_APP_KEY = '2bb8339fd8bddd6634505ab6';///极光appkey
static const String JMESSAGE_MASTER_SECRET = '6f1be8e4bd1cfa39ea3d8bcd';///极光appkey
Expand Down
4 changes: 3 additions & 1 deletion lib/controller/chat_manager_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:wechat/page/main/main_page.dart';

import '../language/strings.dart';
import '../utils/navigator_utils.dart';
import '../utils/notification_util.dart';

class ChatManagerController extends BaseXController {

Expand Down Expand Up @@ -88,8 +89,9 @@ class ChatManagerController extends BaseXController {
}
if(_currentConversation != null && _currentConversation?.id == conversation.id){
conversation.read();
}else{
}else if(!conversation.isMuted) {
AudioManager().receiveMessage();
NotificationUtil.showNotificationWithNoSound(conversation.title(), message.contentText,payload: "chatId:${conversation.id}");
}
_updateConversation(conversation);
}
Expand Down
32 changes: 16 additions & 16 deletions lib/controller/jmessage_manager.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import 'package:jmessage_flutter/jmessage_flutter.dart';

class JMessageManager{

JMessageManager._();

static final JmessageFlutter jMessage = JmessageFlutter();

static JMessageManager? _instance;

static JMessageManager get instance {
_instance ??= JMessageManager._();
return _instance!;
}

}
// import 'package:jmessage_flutter/jmessage_flutter.dart';
//
// class JMessageManager{
//
// JMessageManager._();
//
// static final JmessageFlutter jMessage = JmessageFlutter();
//
// static JMessageManager? _instance;
//
// static JMessageManager get instance {
// _instance ??= JMessageManager._();
// return _instance!;
// }
//
// }
10 changes: 9 additions & 1 deletion lib/controller/user_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,19 @@ class UserController extends BaseXController {
var lcfile = await LCFile.fromPath(file.filename, file.path);
await lcfile.save();
user!['friendCircilBg'] = lcfile.url;
user!.save();
await user!.save();
});

}

Future<bool> editNickname(String nickname) async {
return await lcPost(() async {
user!['nickname'] = nickname;
await user!.save();
},pop: true);

}

Future<void> logout() async {
await LCUser.logout();
user = null;
Expand Down
1 change: 1 addition & 0 deletions lib/language/string_cn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const Map<String, String> languageChinese = {

Ids.phone_register: '手机号注册',
Ids.nickname: '昵称',
Ids.edit_nickname: '编辑昵称',
Ids.nickname_example: '例如:李晨',
Ids.phone: '手机号',
Ids.phone_input_hint: '请填写手机号',
Expand Down
1 change: 1 addition & 0 deletions lib/language/strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Ids {

static const String phone_register = 'phone_register';
static const String nickname = 'nickname';
static const String edit_nickname = 'edit_nickname';
static const String nickname_example = 'nickname_example';
static const String country_and_area = 'con_and_area';
static const String phone = 'phone';
Expand Down
3 changes: 1 addition & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import 'controller/chat_manager_controller.dart';
import 'controller/user_controller.dart';
import 'language/translation_service.dart';
import 'package:leancloud_storage/leancloud.dart';
import 'package:jmessage_flutter/jmessage_flutter.dart';

final RouteObserver<PageRoute> routeObserver = RouteObserver();

Expand All @@ -34,7 +33,7 @@ void main() async {
// LeanCloud.initialize('ugJfJQ7FWkwaPfex5af1R5Pb-gzGzoHsz', 'qHQJqjsXzj5XK9gwGLB59OYI',server: 'https://www.douyin.com', queryCache: LCQueryCache());
// LeanCloud.initialize('JN2Q4XReVkr7sQYEmma3bT6R-MdYXbMMI', 'pgktbsL98hKS2hzdi3OeJ8Pe', queryCache: LCQueryCache());
LeanCloud.initialize('jjdYaY3R8guscltQUDvkKnrt-gzGzoHsz', 'Sh3f3Pw9E7wDdRnEW7ik3dIU',server: 'https://jjdyay3r.lc-cn-n1-shared.com', queryCache: LCQueryCache());
JmessageFlutter().init(isOpenMessageRoaming: true, appkey: Constant.JMESSAGE_APP_KEY);
// JmessageFlutter().init(isOpenMessageRoaming: true, appkey: Constant.JMESSAGE_APP_KEY);
await SpUtil.getInstance();
SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
Expand Down
63 changes: 30 additions & 33 deletions lib/page/login/controller/register_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:jmessage_flutter/jmessage_flutter.dart';
import 'package:leancloud_storage/leancloud.dart';
import 'package:uuid/uuid.dart';
import 'package:wechat/base/base_getx.dart';
import 'package:wechat/core.dart';
import 'package:wechat/utils/navigator_utils.dart';

import '../../../controller/jmessage_manager.dart';
import '../../../language/strings.dart';
import '../../../utils/md5_utils.dart';
import '../model/zone_code.dart';
Expand Down Expand Up @@ -87,38 +84,38 @@ class RegisterController extends BaseXController{
void register(String phone , String password,String nickname , File? avatar) async {

lcPost(() async {
JmessageFlutter _jMessage = JMessageManager.jMessage;

await _jMessage.userRegister(
username: (currZone.tel! + phone).replaceAll('+', ''),
password: password,
nickname: nickname
);
phone = currZone.tel! + phone;
if(avatar != null){
await _jMessage.updateMyAvatar(imgPath: avatar.path);
}
await _jMessage.updateMyInfo(
extras: {
'wxid':Md5Util.createWxId,
'phone':phone,
}
);
await _jMessage.logout();
// LCUser user = LCUser();
// JmessageFlutter _jMessage = JMessageManager.jMessage;

// await _jMessage.userRegister(
// username: (currZone.tel! + phone).replaceAll('+', ''),
// password: password,
// nickname: nickname
// );
// phone = currZone.tel! + phone;
// if(avatar != null){
// LCFile _file = await LCFile.fromPath(avatar.filename, avatar.path);
// await _file.save();
// user['avatar'] = _file.url;
// await _jMessage.updateMyAvatar(imgPath: avatar.path);
// }
// phone = "+" + currZone.tel! + phone;
// user.username = phone;
// user.password = password;
// user.mobile = phone;
// user['nickname'] = nickname;

// await user.signUp();
// LCUser.logout();
// await _jMessage.updateMyInfo(
// extras: {
// 'wxid':Md5Util.createWxId,
// 'phone':phone,
// }
// );
// await _jMessage.logout();
LCUser user = LCUser();
if(avatar != null){
LCFile _file = await LCFile.fromPath(avatar.filename, avatar.path);
await _file.save();
user['avatar'] = _file.url;
}
phone = "+" + currZone.tel! + phone;
user.username = phone;
user.password = password;
user.mobile = phone;
user['nickname'] = nickname;

await user.signUp();
LCUser.logout();
NavigatorUtils.offNamed(RegisterSuccessPage.routeName);

},loadingMsg:Ids.registering.str());
Expand Down
3 changes: 2 additions & 1 deletion lib/page/login/register_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:wechat/widget/base_scaffold.dart';
import 'package:wechat/widget/common_btn.dart';
import 'package:wechat/widget/tap_widget.dart';

import '../../base/constant.dart';
import '../../language/strings.dart';

import '../../utils/utils.dart';
Expand Down Expand Up @@ -136,7 +137,7 @@ class RegisterPage extends BaseGetBuilder<RegisterController> {
children: <TextSpan>[
TextSpan(text:Ids.software_licensing_and_services_ordinance_1.str(),style: TextStyle(color: Colours.c_666666,fontSize: 28.sp)),
TextSpan(text:Ids.software_licensing_and_services_ordinance_2.str(),style: TextStyle(color: Colours.c_0066FF,fontSize: 28.sp),recognizer: TapGestureRecognizer()..onTap = (){
NavigatorUtils.toNamed(WebViewPage.routeName,arguments: WebviewArguments(title:Ids.software_licensing_and_services_ordinance_2.str(),url:'https://game.qq.com/contract_software.shtml'));
NavigatorUtils.toNamed(WebViewPage.routeName,arguments: WebviewArguments(title:Ids.software_licensing_and_services_ordinance_2.str(),url:Constant.SOFTWARE_LICENSING));
}),
TextSpan(text:Ids.software_licensing_and_services_ordinance_3.str(),style: TextStyle(color: Colours.c_666666,fontSize: 28.sp)),
],
Expand Down
1 change: 1 addition & 0 deletions lib/page/main/chat/controller/chat_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ChatController extends BaseXController {
Conversation? conversation;
RxBool startAudioRecord = false.obs;
RxInt recordStatus = PressRecordWidgetState.VOICE_STATUS_START.obs;
RxInt peakPower = 1.obs;
RxList<Message> messages = <Message>[].obs;
final TextEditingController textController = TextEditingController();
final AutoScrollController listScrollerController = AutoScrollController(keepScrollOffset: false);
Expand Down
7 changes: 6 additions & 1 deletion lib/page/main/chat/widget/press_record_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,15 @@ class PressRecordWidgetState extends State<PressRecordWidget> with SubscriptionM
mFlutterAudioRecorder2 = FlutterAudioRecorder2(path, audioFormat: AudioFormat.AAC); // or AudioFormat.WAV
await mFlutterAudioRecorder2!.initialized;
mFlutterAudioRecorder2?.start();
periodic(200,(time){
periodic(50,(time){
_powerTimer = time;
mFlutterAudioRecorder2?.current().then((value){
debugPrint('metering ${value?.metering?.peakPower} ${value?.metering?.averagePower}');
var peakPower = (value?.metering?.peakPower?.toInt().abs()??10)~/10;
if(peakPower > 6){
peakPower = 6;
}
_controller.peakPower.value = peakPower;
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/page/main/chat/widget/record_preview_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class RecordPreviewWidget extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(Utils.getImgPath(value == PressRecordWidgetState.VOICE_STATUS_END?"record_power_6":"record_cancel",dir: Utils.DIR_CHAT),width: 150.w,height: 150.w,),
Image.asset(Utils.getImgPath(value == PressRecordWidgetState.VOICE_STATUS_END?"record_power_${_controller.peakPower.value}":"record_cancel",dir: Utils.DIR_CHAT),width: 150.w,height: 150.w,),
Text(value == PressRecordWidgetState.VOICE_STATUS_END?Ids.up_for_cancel.str():Ids.loosen_to_cancle.str(),style: TextStyle(color: Colours.white,fontSize: 32.sp),)
],
),
Expand Down
Loading

0 comments on commit bd21d07

Please sign in to comment.