提交 062e2032 authored 作者: JarvanMo's avatar JarvanMo

update doc

上级 2f31b94d
### Summary ## Summary
`Fluwx` doesn't support all kind of sharing.Only text, image, web page, `Fluwx` doesn't support all kind of sharing.Only text, image, web page,
music, video and mini program are supported.We'll consider the more. music, video and mini program are supported.We'll consider the more.
More support will be considered in the future. More support will be considered in the future.
. .
> NOTE:Images or thumbnails used for sharing only support `png`and`jpg`
### What kind of images are supported
- Network images
- Assets Images
- Local Images
However, developers must care about the following points:
> NOTE:Images or thumbnails used for sharing only support `png`and`jpg`.Network or assets images are OK.<br> - Provide schema `assets://` when using assets images.Query `?package=package_name` is neccessary when load images from particular package. Here's a full exmaple:`assets://path/to/your/image.png?package=fromPackage`
> However,using images from `assets`,you have to add a schema `assets://`。<br> - Provide schema `file://` or `content://` when using local images, but `content://` only works on Android due to `FileProvider`.For example, `content://media/external/file`
- Otherwise, network images by default.
- `Fluwx` will create thumbnail from main image if no thumbnail is provided.
- Due to the limits of WeChat,the thumbnail must be smaller than 32k(mini-program's is 120k), `Fluwx` will compress images before sharing if thumbnail is larger than that. But the result of compression is unpredictable.
.Network or assets images are OK.<br>
> However,using images from `assets`,you have to add a schema `assets://path/to/your/image.png?package=fromPackage`。<br>
> For assets image from a particular package,you have to add a query param:`?package=package_name`<br> > For assets image from a particular package,you have to add a query param:`?package=package_name`<br>
> If you want to use local image,`file://` must be provided.For example, a local image path should be "file://path/to/your/image.jpg". <br> > If you want to use local image,`file://` must be provided.For example, a local image path should be "file://path/to/your/image.jpg". <br>
> If no schema or wrong schema provided,`Fluwx` will load it as network image.Be careful<br> > If no schema or wrong schema provided,`Fluwx` will load it as network image.Be careful<br>
...@@ -14,7 +32,8 @@ More support will be considered in the future. ...@@ -14,7 +32,8 @@ More support will be considered in the future.
> a qualified thumbnail.Otherwise, `Fluwx` will compress it for you. The result of compression is unpredictable.<br> > a qualified thumbnail.Otherwise, `Fluwx` will compress it for you. The result of compression is unpredictable.<br>
> Considering that we may obtain a path such as *content://media/external/file* on Android, `fluwx` also support reading image or thumbnail from `content://`.<br> > Considering that we may obtain a path such as *content://media/external/file* on Android, `fluwx` also support reading image or thumbnail from `content://`.<br>
> `content://` only works on Android. > `content://` only works on Android.
### The Destination
## The Destination
The destination of sharing can be SESSION(default),TIMELINE or FAVORITE.However,mini-program only support SESSION. The destination of sharing can be SESSION(default),TIMELINE or FAVORITE.However,mini-program only support SESSION.
```dart ```dart
///[WeChatScene.SESSION]会话 ///[WeChatScene.SESSION]会话
...@@ -26,17 +45,10 @@ More support will be considered in the future. ...@@ -26,17 +45,10 @@ More support will be considered in the future.
FAVORITE FAVORITE
} }
``` ```
### Return
the return value of `fluwx.share(model)` is `Map`
```dart
{
"platform":"Android",//or iOS
result:true //or false,depends on WXApi.sendRequest()
}
```
### Share Text
## Share Text
```dart ```dart
fluwx.share(WeChatShareTextModel( fluwx.share(WeChatShareTextModel(
text: "text from fluwx", text: "text from fluwx",
...@@ -44,7 +56,7 @@ More support will be considered in the future. ...@@ -44,7 +56,7 @@ More support will be considered in the future.
scene: scene scene: scene
)); ));
``` ```
### Share Image ## Share Image
```dart ```dart
fluwx.share(WeChatShareImageModel( fluwx.share(WeChatShareImageModel(
image: _imagePath, image: _imagePath,
...@@ -55,7 +67,7 @@ More support will be considered in the future. ...@@ -55,7 +67,7 @@ More support will be considered in the future.
``` ```
> NOTE:`Fluwx` will create thumbnail from `image` if thumbnail isn't provided. > NOTE:`Fluwx` will create thumbnail from `image` if thumbnail isn't provided.
### Share Music ## Share Music
```dart ```dart
var model = WeChatShareMusicModel( var model = WeChatShareMusicModel(
title: _title, title: _title,
...@@ -69,7 +81,7 @@ More support will be considered in the future. ...@@ -69,7 +81,7 @@ More support will be considered in the future.
``` ```
Two kind of music:`musicUrl``musicLowBandUrl`.They are not coexisting,if both are assigned, only`musicUrl` will be used. Two kind of music:`musicUrl``musicLowBandUrl`.They are not coexisting,if both are assigned, only`musicUrl` will be used.
### Share Video ## Share Video
```dart ```dart
var model = new WeChatShareVideoModel( var model = new WeChatShareVideoModel(
videoUrl: _videoUrl, videoUrl: _videoUrl,
...@@ -83,7 +95,7 @@ Two kind of music:`musicUrl`和`musicLowBandUrl`.They are not coexisting,if ...@@ -83,7 +95,7 @@ Two kind of music:`musicUrl`和`musicLowBandUrl`.They are not coexisting,if
``` ```
Two kind of video:`videoUrl``videoLowBandUrl`.They are not coexisting,if both are assigned, only `videoUrl` will be used. Two kind of video:`videoUrl``videoLowBandUrl`.They are not coexisting,if both are assigned, only `videoUrl` will be used.
### Share Mini Program ## Share Mini Program
```dart ```dart
var model =new WeChatShareMiniProgramModel( var model =new WeChatShareMiniProgramModel(
webPageUrl: _webPageUrl, webPageUrl: _webPageUrl,
......
### 简述 ## 简述
目前`Fluwx`并不是支持所有的分享类型,目前仅支持文本分享、图片分享、网址分享 目前`Fluwx`并不是支持所有的分享类型,目前仅支持文本分享、图片分享、网址分享
音乐、视频以及小程序的分享。未来会考虑增加更多支持。 音乐、视频以及小程序的分享。未来会考虑增加更多支持。
### 都支持什么图片
- 网络图片
- Assets图片
- 本地图片
但是, 需要注意以下几点:
> 注意:目前分享中涉及到图片的地方仅支持`png`和`jpg`,支持网络图片及`assets`图片。<br> - 如果使用Assets图片,请务必提供前缀 `assets://` .如果想加载指定包的图片请加上查询参数 `?package=package_name` 。 例子:`assets://path/to/your/image.png?package=fromPackage`
> 使用`assets`图片需要添加`assets://`。<br> - 如果使用本地图片,请务必提供前缀`file://` 或者 `content://`,但 `content://` 只在Android上有效,因为有的图片可能是从`FileProvider`得到的,例如, `content://media/external/file`
> 也可以在`assets`图片添加`?package=package_name`以读取指定包的图片。<br> - 默认当作网络图片处理。
> 如果你想使用本地图片请勿必提供`file://`,比如`file://path/to/your/image.jpg`。<br> - 如果不提供缩略图,`Fluwx`将会尝试从主图片中创建缩略图。
> 如果不指定schema或者schema错误,将会被处理为网络图片,请谨慎。<br> - 由于微信的限制,一般的缩略图要小于32k(小程序的缩略图要小于120k),所以如果缩略图不符合规格,`Fluwx`将执行压缩。 其结果可能并不是你所预期的。
> 由于微信的限制,一般的缩略图要小于32k(小程序的缩略图要小于120k),所以在使用缩略的时候<br>
> 很有必要使用一张合格的缩略图,否则`Fluwx`进行压缩,其结果可能并不是你所预期的。 ## 分享去处
> 考虑到在`Android`上,我们可能得到像*content://media/external/file*这样的路径, `fluwx` 也支持从`content://`中读取图片或者缩略图.<br>
> `content://` 只在Android上有效。
### 分享去处
绝大部分分享可以分享到会话,朋友圈,收藏(小程序目前只能分享到会话)。默认分享到会话。 绝大部分分享可以分享到会话,朋友圈,收藏(小程序目前只能分享到会话)。默认分享到会话。
```dart ```dart
...@@ -26,16 +33,9 @@ ...@@ -26,16 +33,9 @@
FAVORITE FAVORITE
} }
``` ```
### 返回值处理
`fluwx.share(model)`返回的是一个`Map`
```dart
{
"platform":"Android",//或者iOS
result:true //或者false,取决于WXApi.sendRequest()的结果
}
```
### 分享文本 ## 分享文本
```dart ```dart
fluwx.share(WeChatShareTextModel( fluwx.share(WeChatShareTextModel(
text: "text from fluwx", text: "text from fluwx",
...@@ -43,7 +43,9 @@ ...@@ -43,7 +43,9 @@
scene: scene scene: scene
)); ));
``` ```
### 分享图片
## 分享图片
```dart ```dart
fluwx.share(WeChatShareImageModel( fluwx.share(WeChatShareImageModel(
image: _imagePath, image: _imagePath,
...@@ -52,9 +54,11 @@ ...@@ -52,9 +54,11 @@
scene: scene, scene: scene,
description: "image")); description: "image"));
``` ```
> 注意:如果不指定 `thumbnail`,那么`Fluwx`将尝试从`image`中获取缩略图。
### 分享音乐 > 注意:如果不指定 `thumbnail`,那么`Fluwx`将尝试从`image`中获取缩略图。
## 分享音乐
```dart ```dart
var model = WeChatShareMusicModel( var model = WeChatShareMusicModel(
title: _title, title: _title,
...@@ -66,9 +70,12 @@ ...@@ -66,9 +70,12 @@
fluwx.share(model); fluwx.share(model);
``` ```
音乐的分享有两种:`musicUrl``musicLowBandUrl`。这两种形式是不共存的,如果 音乐的分享有两种:`musicUrl``musicLowBandUrl`。这两种形式是不共存的,如果
都二者都进行了赋值,那么只会读取`musicUrl` 都二者都进行了赋值,那么只会读取`musicUrl`
### 分享视频
## 分享视频
```dart ```dart
var model = new WeChatShareVideoModel( var model = new WeChatShareVideoModel(
videoUrl: _videoUrl, videoUrl: _videoUrl,
...@@ -80,9 +87,12 @@ ...@@ -80,9 +87,12 @@
); );
fluwx.share(model); fluwx.share(model);
``` ```
视频的分享有两种:`videoUrl``videoLowBandUrl`。这两种形式是不共存的,如果 视频的分享有两种:`videoUrl``videoLowBandUrl`。这两种形式是不共存的,如果
都二者都进行了赋值,那么只会读取`videoUrl` 都二者都进行了赋值,那么只会读取`videoUrl`
### 分享小程序 ### 分享小程序
```dart ```dart
var model =new WeChatShareMiniProgramModel( var model =new WeChatShareMiniProgramModel(
webPageUrl: _webPageUrl, webPageUrl: _webPageUrl,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论