Skip to content

Commit

Permalink
feat:聊天页增加(录音/图片/视频/文件)消息发送流程。
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeeYudE committed Aug 19, 2022
1 parent 52ecd9b commit 0160139
Show file tree
Hide file tree
Showing 39 changed files with 539 additions and 70 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.2
tag_name : v1.0.3

jobs:

Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ A new Wechat project.
wechat_flutter是flutter版微信,目前功能还在持续迭代,尽量还原原版微信功能。
Flutter版本:3.0.0


#测试账号 18202003769 密码 Bb123456

下载体验(Android)
Expand All @@ -15,19 +16,19 @@ 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/screenshot2.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) |
| ![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) |
| ![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) |
| ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| ![10.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/screenshot/screenshot9.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.19 聊天页增加(录音/图片/视频/文件)消息发送流程。
* 2022.08.18 首页增加Uniapp小程序跳转,设置页增加小程序wgt文件上传。
* 2022.08.15 增加视频号流程,支持上传视频。
* 2022.08.02 创建朋友圈增加定位选择流程。
Expand All @@ -49,9 +50,9 @@ Flutter版本:3.0.0

# todo
* 视频播放器增加缓存
* IMSDK有BUG,图片/录音/文件类型的发送流程暂未完成,等待官方修复
* 寻找好心人适配iOS平台

#git type用于说明 commit 的类别,只允许使用下面7个标识
# git type用于说明 commit 的类别,只允许使用下面7个标识
* feat:新功能(feature)
* fix:修补bug
* docs:文档(documentation)
Expand Down
Binary file added assets/images/chat/message_voice_receive_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/chat/message_voice_receive_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/chat/message_voice_receive_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/chat/message_voice_send_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/chat/message_voice_send_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/chat/message_voice_send_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/chat/sound_left_0.webp
Binary file not shown.
Binary file removed assets/images/chat/sound_left_1.webp
Binary file not shown.
Binary file removed assets/images/chat/sound_left_2.webp
Binary file not shown.
Binary file removed assets/images/chat/sound_left_3.webp
Binary file not shown.
Binary file removed assets/images/chat/sound_right_0.png
Binary file not shown.
Binary file removed assets/images/chat/sound_right_1.webp
Binary file not shown.
Binary file removed assets/images/chat/sound_right_2.webp
Binary file not shown.
Binary file removed assets/images/chat/sound_right_3.png
Binary file not shown.
2 changes: 1 addition & 1 deletion build_Release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# 打包显示的日志

_tag=v1.0.2
_tag=v1.0.3

git tag ${_tag}
git push --tags
Expand Down
2 changes: 1 addition & 1 deletion lib/app_pages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class AppPages {
),
_getPage(
name: VideoPerviewPage.routeName,
page: () => const VideoPerviewPage(),
page: () => VideoPerviewPage(),
),
_getPage(
name: ShakePage.routeName,
Expand Down
6 changes: 3 additions & 3 deletions lib/base/constant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class Constant{
static const String OBJECT_NAME_CHANNLES_COMMENTS = 'channlesComments';
static const String OBJECT_NAME_UNIAPP = 'uniapp';

static final double MAX_PHOTO_WIDTH = 600.w;
static final double MAX_PHOTO_WIDTH = 400.w;
static final double MAX_PHOTO_HEIGHT = 600.w;
static final double MIN_PHOTO_WIDTH = 300.w;
static final double MIN_PHOTO_HEIGHT = 300.w;
static final double MIN_PHOTO_WIDTH = 200.w;
static final double MIN_PHOTO_HEIGHT = 200.w;

}
51 changes: 43 additions & 8 deletions lib/controller/auido_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,29 @@ import 'dart:io';

import 'package:audioplayers/audioplayers.dart';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:leancloud_official_plugin/leancloud_plugin.dart';
import 'package:wechat/core.dart';
import 'package:wechat/utils/file_utils.dart';
import 'package:wechat/utils/range_download_manage.dart';

class AudioManager {
class AudioManager {

static AudioManager? _instance;

static final AudioPlayer _audioPlayer = AudioPlayer();
static final AudioCache _audioCache = AudioCache(prefix: 'assets/audio/');

static final AudioMessage _initAudioMessage = AudioMessage();

// 单例公开访问点
factory AudioManager() => _getInstance()!;

static Rx<AudioMessage> playAudioMessage = _initAudioMessage.obs;

// 私有构造函数
AudioManager._() {
// 具体初始化代码
_initAudio();
}

// 静态、同步、私有访问点
Expand All @@ -26,25 +34,47 @@ class AudioManager {
}


static _initAudio() {
static _initAudio() {
_audioPlayer.onPlayerStateChanged.listen((event) {
debugPrint('onPlayerStateChanged = ' + event.toString());
});
_audioPlayer.onPlayerCompletion.listen((event) {
debugPrint('onPlayerCompletion ');
debugPrint('onPlayerCompletion');
playAudioMessage.value = _initAudioMessage;
_clearAudio();
});
_audioPlayer.onPlayerError.listen((event) {
debugPrint('onPlayerError $event');
playAudioMessage.value = _initAudioMessage;
});

//获取音频的真实时长
_audioPlayer.onDurationChanged.listen((Duration event) {

});
}

AudioPlayer? getAudioPlayer() {
return _audioPlayer;
playMessage(AudioMessage message) async {
if(_audioPlayer.state == PlayerState.PLAYING && playAudioMessage.value == message){
_audioPlayer.stop();
_clearAudio();
return;
}
var audioTemporaryDirectory = await FileUtils.getAudioTemporaryDirectory();
var filename = message.filename;
if(filename == null){
return;
}
DownLoadManage().download(message.url, audioTemporaryDirectory.path + '/'+filename,done: (path){
var file = File(path);
if(Platform.isAndroid){
_audioPlayer.playBytes(file.readAsBytesSync());
}else{
_audioPlayer.play(path,isLocal:true);
}
playAudioMessage.value = message;
});
}


shake(){
_audioCache.play('shake.mp3');
}
Expand All @@ -57,9 +87,14 @@ class AudioManager {
_audioCache.play('receive_message.mp3');
}

static _clearAudio(){
playAudioMessage.value = _initAudioMessage;
}

dispose() {
if(_audioPlayer.state == PlayerState.PLAYING){
_audioPlayer.stop();
_clearAudio();
}
}

Expand Down
68 changes: 68 additions & 0 deletions lib/ext/leancloud_ext.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ extension LCMessageExt on Message{

bool get isSend => fromClientID == UserController.instance.username;


int get messageType {
if(this is TextMessage){
return TYPE_TEXT;
Expand Down Expand Up @@ -137,6 +138,42 @@ extension LCMessageExt on Message{
return '';
}


}

extension TypeMessageExt on TypedMessage{

Map get metaData{
var _lcfile = rawData['_lcfile'];
if(_lcfile == null){
rawData['_lcfile'] = {};
}
var metaData = rawData['_lcfile']['metaData'];
if(metaData == null){
metaData = {};
rawData['_lcfile']['metaData'] = metaData;
}
return metaData;
}

String get filename {
String? _filename;
final Map? metaDataMap = metaData;
if (metaDataMap != null) {
_filename = metaDataMap['filename']?.toString();
}
return _filename??'';
}

String get fileSize {
String? _filename;
final Map? metaDataMap = metaData;
if (metaDataMap != null) {
_filename = metaDataMap['size']?.toString();
}
return _filename??'';
}

}

extension LocationMessageExt on LocationMessage{
Expand All @@ -145,4 +182,35 @@ extension LocationMessageExt on LocationMessage{
return 'http://api.map.baidu.com/staticimage?center=$longitude,$latitude&maker=$longitude,$latitude&width=${400.w}&height=${150.w}&zoom=14';
}

}

extension VideoMessageExt on VideoMessage{

double get thumbnailWidth {
double? _thumbnailWidth;
final Map? metaDataMap = metaData;
if (metaDataMap != null) {
_thumbnailWidth = metaDataMap['_thumbnailWidth'];
}
return _thumbnailWidth??0.0;
}

double get thumbnailHeight {
double? _thumbnailHeight;
final Map? metaDataMap = metaData;
if (metaDataMap != null) {
_thumbnailHeight = metaDataMap['thumbnailHeight']?.toDouble();
}
return _thumbnailHeight??0.0;
}

String? get thumbnailUrl {
String? _thumbnailHeight;
final Map? metaDataMap = metaData;
if (metaDataMap != null) {
_thumbnailHeight = metaDataMap['thumbnailUrl'];
}
return _thumbnailHeight;
}

}
Loading

0 comments on commit 0160139

Please sign in to comment.