parent
46a832fa42
commit
9514a79f6a
89
.drone.yml
Normal file → Executable file
89
.drone.yml
Normal file → Executable file
@ -3,7 +3,7 @@ name: default
|
||||
|
||||
steps:
|
||||
- name: prepare
|
||||
image: v7lin/flutter:1.9.1-hotfix.2-stable
|
||||
image: v7lin/flutter:1.17.3-stable
|
||||
volumes:
|
||||
- name: pub-cache
|
||||
path: /opt/flutter/.pub-cache
|
||||
@ -11,15 +11,33 @@ steps:
|
||||
- flutter packages get
|
||||
|
||||
#- name: build_runner
|
||||
# image: v7lin/flutter:1.9.1-hotfix.2-stable
|
||||
# image: v7lin/flutter:1.17.3-stable
|
||||
# volumes:
|
||||
# - name: pub-cache
|
||||
# path: /opt/flutter/.pub-cache
|
||||
# commands:
|
||||
# - flutter packages pub run build_runner build
|
||||
# - flutter pub run build_runner build --delete-conflicting-outputs
|
||||
|
||||
#- name: android-check
|
||||
# image: v7lin/flutter:1.17.3-stable
|
||||
# volumes:
|
||||
# - name: pub-cache
|
||||
# path: /opt/flutter/.pub-cache
|
||||
# - name: gradle
|
||||
# path: /root/.gradle
|
||||
# commands:
|
||||
# - cd example/android/
|
||||
# - ./gradlew :wechat_kit:check
|
||||
|
||||
# docker run --rm -it -v ${PWD}:/src v7lin/clang:5.0.2-r0 sh -c "clang-format -style=file -i src/Classes/*.h src/Classes/*.m"
|
||||
#- name: ios-format
|
||||
# image: v7lin/clang
|
||||
# commands:
|
||||
# - cd ios/
|
||||
# - clang-format -style=file -i src/Classes/*.h src/Classes/*.m
|
||||
|
||||
- name: format
|
||||
image: v7lin/flutter:1.9.1-hotfix.2-stable
|
||||
image: v7lin/flutter:1.17.3-stable
|
||||
volumes:
|
||||
- name: pub-cache
|
||||
path: /opt/flutter/.pub-cache
|
||||
@ -27,7 +45,7 @@ steps:
|
||||
- flutter format --dry-run --set-exit-if-changed .
|
||||
|
||||
- name: analyze
|
||||
image: v7lin/flutter:1.9.1-hotfix.2-stable
|
||||
image: v7lin/flutter:1.17.3-stable
|
||||
volumes:
|
||||
- name: pub-cache
|
||||
path: /opt/flutter/.pub-cache
|
||||
@ -35,17 +53,17 @@ steps:
|
||||
- flutter analyze
|
||||
|
||||
- name: test
|
||||
image: v7lin/flutter:1.9.1-hotfix.2-stable
|
||||
image: v7lin/flutter:1.17.3-stable
|
||||
volumes:
|
||||
- name: pub-cache
|
||||
path: /opt/flutter/.pub-cache
|
||||
commands:
|
||||
- flutter test --coverage
|
||||
- cd example/
|
||||
- flutter test
|
||||
# - cd example/
|
||||
# - flutter test
|
||||
|
||||
- name: proguard
|
||||
image: v7lin/flutter:1.9.1-hotfix.2-stable
|
||||
image: v7lin/flutter:1.17.3-stable
|
||||
volumes:
|
||||
- name: pub-cache
|
||||
path: /opt/flutter/.pub-cache
|
||||
@ -55,20 +73,20 @@ steps:
|
||||
- cd example/
|
||||
- flutter build apk
|
||||
|
||||
- name: coverage
|
||||
image: plugins/codecov:2.0.3
|
||||
settings:
|
||||
token:
|
||||
from_secret: CODECOV_TOKEN
|
||||
files:
|
||||
- ./coverage/lcov.info
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
#- name: coverage
|
||||
# image: plugins/codecov:2.0.3
|
||||
# settings:
|
||||
# token:
|
||||
# from_secret: CODECOV_TOKEN
|
||||
# files:
|
||||
# - ./coverage/lcov.info
|
||||
# when:
|
||||
# event:
|
||||
# exclude:
|
||||
# - pull_request
|
||||
|
||||
- name: publish-check
|
||||
image: v7lin/flutter:1.9.1-hotfix.2-stable
|
||||
image: v7lin/flutter:1.17.3-stable
|
||||
volumes:
|
||||
- name: pub-cache
|
||||
path: /opt/flutter/.pub-cache
|
||||
@ -91,10 +109,9 @@ steps:
|
||||
volumes:
|
||||
- name: pub-cache
|
||||
path: /opt/flutter/.pub-cache
|
||||
environment:
|
||||
PUB_CACHE: /opt/flutter/.pub-cache
|
||||
commands:
|
||||
- wget -P $PUB_CACHE https://raw.githubusercontent.com/v7lin/pub_credentials/master/credentials.json.enc
|
||||
- FLUTTER_HOME=/opt/flutter/.pub-cache
|
||||
- wget -P $FLUTTER_HOME https://raw.githubusercontent.com/v7lin/pub_credentials/master/credentials.json.enc
|
||||
|
||||
- name: restore-cache-openssl
|
||||
image: v7lin/openssl:1.1.1b
|
||||
@ -102,17 +119,17 @@ steps:
|
||||
- name: pub-cache
|
||||
path: /opt/flutter/.pub-cache
|
||||
environment:
|
||||
PUB_CACHE: /opt/flutter/.pub-cache
|
||||
ENC_METHOD:
|
||||
from_secret: ENC_METHOD
|
||||
ENC_PASSWORD:
|
||||
from_secret: ENC_PASSWORD
|
||||
commands:
|
||||
- openssl enc -d -$ENC_METHOD -k $ENC_PASSWORD -in $PUB_CACHE/credentials.json.enc -out $PUB_CACHE/credentials.json
|
||||
- rm $PUB_CACHE/credentials.json.enc
|
||||
- FLUTTER_HOME=/opt/flutter/.pub-cache
|
||||
- openssl enc -d -$ENC_METHOD -k $ENC_PASSWORD -in $FLUTTER_HOME/credentials.json.enc -out $FLUTTER_HOME/credentials.json
|
||||
- rm $FLUTTER_HOME/credentials.json.enc
|
||||
|
||||
- name: publish
|
||||
image: v7lin/flutter:1.9.1-hotfix.2-stable
|
||||
image: v7lin/flutter:1.17.3-stable
|
||||
volumes:
|
||||
- name: pub-cache
|
||||
path: /opt/flutter/.pub-cache
|
||||
@ -125,14 +142,14 @@ steps:
|
||||
- name: pub-cache
|
||||
path: /opt/flutter/.pub-cache
|
||||
environment:
|
||||
PUB_CACHE: /opt/flutter/.pub-cache
|
||||
ENC_METHOD:
|
||||
from_secret: ENC_METHOD
|
||||
ENC_PASSWORD:
|
||||
from_secret: ENC_PASSWORD
|
||||
commands:
|
||||
- openssl enc -e -$ENC_METHOD -k $ENC_PASSWORD -in $PUB_CACHE/credentials.json -out $PUB_CACHE/credentials.json.enc
|
||||
- rm $PUB_CACHE/credentials.json
|
||||
- FLUTTER_HOME=/opt/flutter/.pub-cache
|
||||
- openssl enc -e -$ENC_METHOD -k $ENC_PASSWORD -in $FLUTTER_HOME/credentials.json -out $FLUTTER_HOME/credentials.json.enc
|
||||
- rm /opt/flutter/.pub-cache/credentials.json
|
||||
|
||||
- name: save-cache
|
||||
image: docker:git
|
||||
@ -140,7 +157,6 @@ steps:
|
||||
- name: pub-cache
|
||||
path: /opt/flutter/.pub-cache
|
||||
environment:
|
||||
PUB_CACHE: /opt/flutter/.pub-cache
|
||||
GIT_USER_EMAIL:
|
||||
from_secret: GIT_USER_EMAIL
|
||||
GIT_USER_NAME:
|
||||
@ -148,13 +164,14 @@ steps:
|
||||
GIT_USER_PASSWORD:
|
||||
from_secret: GIT_USER_PASSWORD # 密码含'@',用'%40'替换 -> URLEncoder.encode("@","utf-8");
|
||||
commands:
|
||||
- FLUTTER_HOME=/opt/flutter/.pub-cache
|
||||
- git config --global user.email $GIT_USER_EMAIL
|
||||
- git config --global user.name $GIT_USER_NAME
|
||||
- git config --global credential.helper store
|
||||
- git clone -b master https://$GIT_USER_NAME:$GIT_USER_PASSWORD@github.com/v7lin/pub_credentials.git $PUB_CACHE/pub_credentials
|
||||
- rm $PUB_CACHE/pub_credentials/credentials.json.enc
|
||||
- mv $PUB_CACHE/credentials.json.enc $PUB_CACHE/pub_credentials/credentials.json.enc
|
||||
- cd $PUB_CACHE/pub_credentials
|
||||
- git clone -b master https://$GIT_USER_NAME:$GIT_USER_PASSWORD@github.com/v7lin/pub_credentials.git $FLUTTER_HOME/pub_credentials
|
||||
- rm $FLUTTER_HOME/pub_credentials/credentials.json.enc
|
||||
- mv $FLUTTER_HOME/credentials.json.enc $FLUTTER_HOME/pub_credentials/credentials.json.enc
|
||||
- cd $FLUTTER_HOME/pub_credentials
|
||||
- git commit -am "update credentials by ci/cd tools"
|
||||
- git push
|
||||
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,9 +3,9 @@
|
||||
|
||||
.packages
|
||||
.pub/
|
||||
pubspec.lock
|
||||
|
||||
build/
|
||||
|
||||
# custom
|
||||
.idea/
|
||||
*.iml
|
||||
|
@ -4,7 +4,7 @@
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: 5391447fae6209bb21a89e6a5a6583cac1af9b4b
|
||||
revision: b041144f833e05cf463b8887fa12efdec9493488
|
||||
channel: stable
|
||||
|
||||
project_type: plugin
|
||||
|
@ -1,3 +1,7 @@
|
||||
## 1.0.0 - 2020.6.18
|
||||
|
||||
* 升级 Android/iOS SDK
|
||||
|
||||
## 0.2.4 - 2019.9.26
|
||||
|
||||
* 降级Android SDK
|
||||
|
90
README.md
90
README.md
@ -1,9 +1,9 @@
|
||||
# fake_weibo
|
||||
# weibo_kit
|
||||
|
||||
[](https://cloud.drone.io/v7lin/fake_weibo)
|
||||
[](https://codecov.io/gh/v7lin/fake_weibo)
|
||||
[](https://github.com/v7lin/fake_weibo/releases)
|
||||
[](https://pub.dartlang.org/packages/fake_weibo)
|
||||
[](https://pub.dartlang.org/packages/weibo_kit)
|
||||
[](https://github.com/v7lin/fake_weibo/blob/master/LICENSE)
|
||||
|
||||
flutter版新浪微博SDK
|
||||
@ -14,6 +14,7 @@ flutter版新浪微博SDK
|
||||
* [flutter版腾讯(QQ)SDK](https://github.com/v7lin/fake_tencent)
|
||||
* [flutter版新浪微博SDK](https://github.com/v7lin/fake_weibo)
|
||||
* [flutter版支付宝SDK](https://github.com/v7lin/fake_alipay)
|
||||
* [flutter版walle渠道打包工具](https://github.com/v7lin/walle_kit)
|
||||
* [flutter版腾讯(信鸽)推送SDK](https://github.com/v7lin/fake_push)
|
||||
* [flutter版talkingdata移动统计SDK](https://github.com/v7lin/fake_analytics)
|
||||
|
||||
@ -35,6 +36,26 @@ flutter版新浪微博SDK
|
||||
# 混淆已打入 Library,随 Library 引用,自动添加到 apk 打包混淆
|
||||
```
|
||||
|
||||
#### 获取 android 微信签名信息
|
||||
|
||||
非官方方法 -> 反编译 app_signatures.apk 所得
|
||||
|
||||
命令:
|
||||
|
||||
```shell
|
||||
keytool -list -v -keystore ${your_keystore_path} -storepass ${your_keystore_password} 2>/dev/null | grep -p 'MD5:.*' -o | sed 's/MD5://' | sed 's/ //g' | sed 's/://g' | awk '{print tolower($0)}'
|
||||
```
|
||||
|
||||
示例:
|
||||
|
||||
```shell
|
||||
keytool -list -v -keystore example/android/app/infos/dev.jks -storepass 123456 2>/dev/null | grep -p 'MD5:.*' -o | sed 's/MD5://' | sed 's/ //g' | sed 's/://g' | awk '{print tolower($0)}'
|
||||
```
|
||||
|
||||
```shell
|
||||
28424130a4416d519e00946651d53a46
|
||||
```
|
||||
|
||||
## ios
|
||||
|
||||
```
|
||||
@ -45,7 +66,7 @@ iOS 9.0
|
||||
在Xcode中,选择你的工程设置项,选中“TARGETS”一栏,在“info”标签栏的“URL type“添加“URL scheme”为你所注册的应用程序id
|
||||
|
||||
URL Types
|
||||
weibosdk: identifier=com.weibo schemes=wb${appKey}
|
||||
weibosdk: identifier=weibo schemes=wb${appKey}
|
||||
```
|
||||
|
||||
```
|
||||
@ -63,6 +84,61 @@ iOS 9系统策略更新,限制了http协议的访问,此外应用需要在
|
||||
<true/>
|
||||
<key>NSExceptionDomains</key>
|
||||
<dict>
|
||||
<key>sina.cn</key>
|
||||
<dict>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSExceptionMinimumTLSVersion</key>
|
||||
<string>TLSv1.0</string>
|
||||
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>weibo.cn</key>
|
||||
<dict>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSExceptionMinimumTLSVersion</key>
|
||||
<string>TLSv1.0</string>
|
||||
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>weibo.com</key>
|
||||
<dict>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSExceptionMinimumTLSVersion</key>
|
||||
<string>TLSv1.0</string>
|
||||
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>sinaimg.cn</key>
|
||||
<dict>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
<key>NSExceptionMinimumTLSVersion</key>
|
||||
<string>TLSv1.0</string>
|
||||
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>sinajs.cn</key>
|
||||
<dict>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSExceptionMinimumTLSVersion</key>
|
||||
<string>TLSv1.0</string>
|
||||
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>sina.com.cn</key>
|
||||
<dict>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
@ -83,7 +159,7 @@ iOS 9系统策略更新,限制了http协议的访问,此外应用需要在
|
||||
|
||||
```
|
||||
dependencies:
|
||||
fake_weibo:
|
||||
weibo_kit:
|
||||
git:
|
||||
url: https://github.com/v7lin/fake_weibo.git
|
||||
```
|
||||
@ -92,7 +168,7 @@ dependencies:
|
||||
|
||||
```
|
||||
dependencies:
|
||||
fake_weibo: ^${latestTag}
|
||||
weibo_kit: ^${latestTag}
|
||||
```
|
||||
|
||||
* example
|
||||
@ -102,10 +178,10 @@ dependencies:
|
||||
## Getting Started
|
||||
|
||||
This project is a starting point for a Flutter
|
||||
[plug-in package](https://flutter.io/developing-packages/),
|
||||
[plug-in package](https://flutter.dev/developing-packages/),
|
||||
a specialized package that includes platform-specific implementation code for
|
||||
Android and/or iOS.
|
||||
|
||||
For help getting started with Flutter, view our
|
||||
[online documentation](https://flutter.io/docs), which offers tutorials,
|
||||
[online documentation](https://flutter.dev/docs), which offers tutorials,
|
||||
samples, guidance on mobile development, and a full API reference.
|
||||
|
305
analysis_options.yaml
Normal file → Executable file
305
analysis_options.yaml
Normal file → Executable file
@ -1,13 +1,27 @@
|
||||
# Defines a default set of lint rules enforced for
|
||||
# projects at Google. For details and rationale,
|
||||
# see https://github.com/dart-lang/pedantic#enabled-lints.
|
||||
include: package:pedantic/analysis_options.yaml
|
||||
# Specify analysis options.
|
||||
#
|
||||
# Until there are meta linter rules, each desired lint must be explicitly enabled.
|
||||
# See: https://github.com/dart-lang/linter/issues/288
|
||||
#
|
||||
# For a list of lints, see: http://dart-lang.github.io/linter/lints/
|
||||
# See the configuration guide for more
|
||||
# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
|
||||
#
|
||||
# There are other similar analysis options files in the flutter repos,
|
||||
# which should be kept in sync with this file:
|
||||
#
|
||||
# - analysis_options.yaml (this file)
|
||||
# - packages/flutter/lib/analysis_options_user.yaml
|
||||
# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
|
||||
# - https://github.com/flutter/engine/blob/master/analysis_options.yaml
|
||||
#
|
||||
# This file contains the analysis options used by Flutter tools, such as IntelliJ,
|
||||
# Android Studio, and the `flutter analyze` command.
|
||||
|
||||
analyzer:
|
||||
strong-mode:
|
||||
implicit-casts: false
|
||||
# implicit-dynamic: false
|
||||
|
||||
implicit-dynamic: false
|
||||
errors:
|
||||
# treat missing required parameters as a warning (not a hint)
|
||||
missing_required_param: warning
|
||||
@ -15,118 +29,175 @@ analyzer:
|
||||
missing_return: warning
|
||||
# allow having TODOs in the code
|
||||
todo: ignore
|
||||
# Ignore errors like
|
||||
# 'super_goes_last' is a deprecated lint rule and should not be used • included_file_warning
|
||||
included_file_warning: ignore
|
||||
|
||||
# 过滤 jaguar_serializer
|
||||
# Ignore analyzer hints for updating pubspecs when using Future or
|
||||
# Stream and not importing dart:async
|
||||
# Please see https://github.com/flutter/flutter/pull/24528 for details.
|
||||
sdk_version_async_exported_from_core: ignore
|
||||
exclude:
|
||||
- "**/*.jser.dart"
|
||||
- "**/*.g.dart"
|
||||
|
||||
linter:
|
||||
rules:
|
||||
# these rules are documented on and in the same order as
|
||||
# the Dart Lint rules page to make maintenance easier
|
||||
# http://dart-lang.github.io/linter/lints/
|
||||
|
||||
# === error rules ===
|
||||
- avoid_empty_else
|
||||
- avoid_slow_async_io
|
||||
- cancel_subscriptions
|
||||
# - close_sinks # https://github.com/flutter/flutter/issues/5789
|
||||
# - comment_references # blocked on https://github.com/dart-lang/dartdoc/issues/1153
|
||||
- control_flow_in_finally
|
||||
- empty_statements
|
||||
- hash_and_equals
|
||||
# - invariant_booleans # https://github.com/flutter/flutter/issues/5790
|
||||
- iterable_contains_unrelated_type
|
||||
- list_remove_unrelated_type
|
||||
# - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791
|
||||
- no_adjacent_strings_in_list
|
||||
- no_duplicate_case_values
|
||||
- test_types_in_equals
|
||||
- throw_in_finally
|
||||
- unrelated_type_equality_checks
|
||||
- valid_regexps
|
||||
|
||||
# === style rules ===
|
||||
- always_declare_return_types
|
||||
# - always_put_control_body_on_new_line
|
||||
- always_require_non_null_named_parameters
|
||||
- always_specify_types
|
||||
- annotate_overrides
|
||||
# - avoid_annotating_with_dynamic # not yet tested
|
||||
# - avoid_as # 2019-01-30 removed for no-implicit-casts
|
||||
# - avoid_catches_without_on_clauses # not yet tested
|
||||
# - avoid_catching_errors # not yet tested
|
||||
# - avoid_classes_with_only_static_members # not yet tested
|
||||
# - avoid_function_literals_in_foreach_calls # not yet tested
|
||||
- avoid_init_to_null
|
||||
- avoid_null_checks_in_equality_operators
|
||||
# - avoid_positional_boolean_parameters # not yet tested
|
||||
- avoid_return_types_on_setters
|
||||
# - avoid_returning_null # not yet tested
|
||||
# - avoid_returning_this # not yet tested
|
||||
# - avoid_setters_without_getters # not yet tested
|
||||
# - avoid_types_on_closure_parameters # not yet tested
|
||||
- await_only_futures
|
||||
- camel_case_types
|
||||
# - cascade_invocations # not yet tested
|
||||
# - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
|
||||
- directives_ordering
|
||||
- empty_catches
|
||||
- empty_constructor_bodies
|
||||
- implementation_imports
|
||||
# - join_return_with_assignment # not yet tested
|
||||
- library_names
|
||||
- library_prefixes
|
||||
- non_constant_identifier_names
|
||||
# - omit_local_variable_types # opposite of always_specify_types
|
||||
# - one_member_abstracts # too many false positives
|
||||
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
|
||||
- overridden_fields
|
||||
- package_api_docs
|
||||
- package_prefixed_library_names
|
||||
# - parameter_assignments # we do this commonly
|
||||
- prefer_adjacent_string_concatenation
|
||||
- prefer_collection_literals
|
||||
# - prefer_conditional_assignment # not yet tested
|
||||
- prefer_const_constructors
|
||||
# - prefer_constructors_over_static_methods # not yet tested
|
||||
- prefer_contains
|
||||
- prefer_equal_for_default_values
|
||||
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
|
||||
# - prefer_final_fields # https://github.com/dart-lang/linter/issues/506
|
||||
# - prefer_final_locals
|
||||
# - prefer_foreach # not yet tested
|
||||
# - prefer_function_declarations_over_variables # not yet tested
|
||||
- prefer_initializing_formals
|
||||
# - prefer_interpolation_to_compose_strings # not yet tested
|
||||
- prefer_is_empty
|
||||
- prefer_is_not_empty
|
||||
- prefer_void_to_null
|
||||
# - recursive_getters # https://github.com/dart-lang/linter/issues/452
|
||||
- slash_for_doc_comments
|
||||
- sort_constructors_first
|
||||
- sort_unnamed_constructors_first
|
||||
# - super_goes_last
|
||||
# - type_annotate_public_apis # subset of always_specify_types
|
||||
- type_init_formals
|
||||
# - unawaited_futures # https://github.com/flutter/flutter/issues/5793
|
||||
- unnecessary_brace_in_string_interps
|
||||
- unnecessary_const
|
||||
- unnecessary_getters_setters
|
||||
# - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
|
||||
- unnecessary_new
|
||||
- unnecessary_null_aware_assignments
|
||||
- unnecessary_null_in_if_null_operators
|
||||
# - unnecessary_overrides # https://github.com/dart-lang/linter/issues/626 and https://github.com/dart-lang/linter/issues/627
|
||||
- unnecessary_statements
|
||||
- unnecessary_this
|
||||
- use_rethrow_when_possible
|
||||
# - use_setters_to_change_properties # not yet tested
|
||||
# - use_string_buffers # https://github.com/dart-lang/linter/pull/664
|
||||
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
|
||||
|
||||
# === pub rules ===
|
||||
- package_names
|
||||
# these rules are documented on and in the same order as
|
||||
# the Dart Lint rules page to make maintenance easier
|
||||
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
|
||||
- always_declare_return_types
|
||||
- always_put_control_body_on_new_line
|
||||
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
|
||||
- always_require_non_null_named_parameters
|
||||
- always_specify_types
|
||||
- annotate_overrides
|
||||
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
|
||||
# - avoid_as # required for implicit-casts: true
|
||||
- avoid_bool_literals_in_conditional_expressions
|
||||
# - avoid_catches_without_on_clauses # we do this commonly
|
||||
# - avoid_catching_errors # we do this commonly
|
||||
- avoid_classes_with_only_static_members
|
||||
# - avoid_double_and_int_checks # only useful when targeting JS runtime
|
||||
- avoid_empty_else
|
||||
# - avoid_equals_and_hash_code_on_mutable_classes # not yet tested
|
||||
- avoid_field_initializers_in_const_classes
|
||||
- avoid_function_literals_in_foreach_calls
|
||||
# - avoid_implementing_value_types # not yet tested
|
||||
- avoid_init_to_null
|
||||
# - avoid_js_rounded_ints # only useful when targeting JS runtime
|
||||
- avoid_null_checks_in_equality_operators
|
||||
# - avoid_positional_boolean_parameters # not yet tested
|
||||
# - avoid_print # not yet tested
|
||||
# - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
|
||||
# - avoid_redundant_argument_values # not yet tested
|
||||
- avoid_relative_lib_imports
|
||||
- avoid_renaming_method_parameters
|
||||
- avoid_return_types_on_setters
|
||||
# - avoid_returning_null # there are plenty of valid reasons to return null
|
||||
# - avoid_returning_null_for_future # not yet tested
|
||||
- avoid_returning_null_for_void
|
||||
# - avoid_returning_this # there are plenty of valid reasons to return this
|
||||
# - avoid_setters_without_getters # not yet tested
|
||||
# - avoid_shadowing_type_parameters # not yet tested
|
||||
- avoid_single_cascade_in_expression_statements
|
||||
- avoid_slow_async_io
|
||||
- avoid_types_as_parameter_names
|
||||
# - avoid_types_on_closure_parameters # conflicts with always_specify_types
|
||||
# - avoid_unnecessary_containers # not yet tested
|
||||
- avoid_unused_constructor_parameters
|
||||
- avoid_void_async
|
||||
# - avoid_web_libraries_in_flutter # not yet tested
|
||||
- await_only_futures
|
||||
- camel_case_extensions
|
||||
- camel_case_types
|
||||
- cancel_subscriptions
|
||||
# - cascade_invocations # not yet tested
|
||||
# - close_sinks # not reliable enough
|
||||
# - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
|
||||
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
|
||||
- control_flow_in_finally
|
||||
# - curly_braces_in_flow_control_structures # not yet tested
|
||||
# - diagnostic_describe_all_properties # not yet tested
|
||||
- directives_ordering
|
||||
- empty_catches
|
||||
- empty_constructor_bodies
|
||||
- empty_statements
|
||||
# - file_names # not yet tested
|
||||
- flutter_style_todos
|
||||
- hash_and_equals
|
||||
- implementation_imports
|
||||
# - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
|
||||
- iterable_contains_unrelated_type
|
||||
# - join_return_with_assignment # not yet tested
|
||||
- library_names
|
||||
- library_prefixes
|
||||
# - lines_longer_than_80_chars # not yet tested
|
||||
- list_remove_unrelated_type
|
||||
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
|
||||
# - missing_whitespace_between_adjacent_strings # not yet tested
|
||||
- no_adjacent_strings_in_list
|
||||
- no_duplicate_case_values
|
||||
# - no_logic_in_create_state # not yet tested
|
||||
# - no_runtimeType_toString # not yet tested
|
||||
- non_constant_identifier_names
|
||||
# - null_closures # not yet tested
|
||||
# - omit_local_variable_types # opposite of always_specify_types
|
||||
# - one_member_abstracts # too many false positives
|
||||
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
|
||||
- overridden_fields
|
||||
- package_api_docs
|
||||
- package_names
|
||||
- package_prefixed_library_names
|
||||
# - parameter_assignments # we do this commonly
|
||||
- prefer_adjacent_string_concatenation
|
||||
- prefer_asserts_in_initializer_lists
|
||||
# - prefer_asserts_with_message # not yet tested
|
||||
- prefer_collection_literals
|
||||
- prefer_conditional_assignment
|
||||
- prefer_const_constructors
|
||||
- prefer_const_constructors_in_immutables
|
||||
- prefer_const_declarations
|
||||
- prefer_const_literals_to_create_immutables
|
||||
# - prefer_constructors_over_static_methods # not yet tested
|
||||
- prefer_contains
|
||||
# - prefer_double_quotes # opposite of prefer_single_quotes
|
||||
- prefer_equal_for_default_values
|
||||
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
|
||||
# - prefer_final_fields
|
||||
# - prefer_final_in_for_each
|
||||
# - prefer_final_locals
|
||||
- prefer_for_elements_to_map_fromIterable
|
||||
- prefer_foreach
|
||||
# - prefer_function_declarations_over_variables # not yet tested
|
||||
- prefer_generic_function_type_aliases
|
||||
- prefer_if_elements_to_conditional_expressions
|
||||
- prefer_if_null_operators
|
||||
- prefer_initializing_formals
|
||||
- prefer_inlined_adds
|
||||
# - prefer_int_literals # not yet tested
|
||||
# - prefer_interpolation_to_compose_strings # not yet tested
|
||||
- prefer_is_empty
|
||||
- prefer_is_not_empty
|
||||
- prefer_is_not_operator
|
||||
- prefer_iterable_whereType
|
||||
# - prefer_mixin # https://github.com/dart-lang/language/issues/32
|
||||
# - prefer_null_aware_operators # disable until NNBD, see https://github.com/flutter/flutter/pull/32711#issuecomment-492930932
|
||||
# - prefer_relative_imports # not yet tested
|
||||
- prefer_single_quotes
|
||||
- prefer_spread_collections
|
||||
- prefer_typing_uninitialized_variables
|
||||
- prefer_void_to_null
|
||||
# - provide_deprecation_message # not yet tested
|
||||
# - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
|
||||
- recursive_getters
|
||||
- slash_for_doc_comments
|
||||
# - sort_child_properties_last # not yet tested
|
||||
- sort_constructors_first
|
||||
- sort_pub_dependencies
|
||||
- sort_unnamed_constructors_first
|
||||
- test_types_in_equals
|
||||
- throw_in_finally
|
||||
# - type_annotate_public_apis # subset of always_specify_types
|
||||
- type_init_formals
|
||||
# - unawaited_futures # too many false positives
|
||||
# - unnecessary_await_in_return # not yet tested
|
||||
- unnecessary_brace_in_string_interps
|
||||
- unnecessary_const
|
||||
# - unnecessary_final # conflicts with prefer_final_locals
|
||||
- unnecessary_getters_setters
|
||||
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
|
||||
- unnecessary_new
|
||||
- unnecessary_null_aware_assignments
|
||||
- unnecessary_null_in_if_null_operators
|
||||
- unnecessary_overrides
|
||||
- unnecessary_parenthesis
|
||||
- unnecessary_statements
|
||||
- unnecessary_string_interpolations
|
||||
- unnecessary_this
|
||||
- unrelated_type_equality_checks
|
||||
# - unsafe_html # not yet tested
|
||||
- use_full_hex_values_for_flutter_colors
|
||||
# - use_function_type_syntax_for_parameters # not yet tested
|
||||
# - use_key_in_widget_constructors # not yet tested
|
||||
- use_rethrow_when_possible
|
||||
# - use_setters_to_change_properties # not yet tested
|
||||
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
|
||||
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
|
||||
- valid_regexps
|
||||
- void_checks
|
@ -1,5 +1,5 @@
|
||||
group 'io.github.v7lin.fakeweibo'
|
||||
version '1.0-SNAPSHOT'
|
||||
group 'io.github.v7lin.weibo_kit'
|
||||
version '1.0.0'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
@ -8,7 +8,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,12 +19,13 @@ rootProject.allprojects {
|
||||
|
||||
// weibo
|
||||
maven {
|
||||
url "https://dl.bintray.com/thelasterstar/maven/"
|
||||
url 'https://dl.bintray.com/thelasterstar/maven/'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply from: './quality.gradle'
|
||||
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
@ -33,9 +34,7 @@ android {
|
||||
minSdkVersion 16
|
||||
|
||||
// library 混淆 -> 随 library 引用,自动添加到 apk 打包混淆
|
||||
consumerProguardFiles 'consumer-proguard-rules.txt'
|
||||
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
@ -44,5 +43,7 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.sina.weibo.sdk:core:4.3.4:openDefaultRelease@aar'
|
||||
implementation 'androidx.annotation:annotation:1.0.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.0.0'
|
||||
implementation 'com.sina.weibo.sdk:core:9.12.0:openDefaultRelease@aar'
|
||||
}
|
||||
|
135
android/checkstyle.xml
Normal file
135
android/checkstyle.xml
Normal file
@ -0,0 +1,135 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||
"http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
|
||||
|
||||
<module name="Checker">
|
||||
<!--module name="NewlineAtEndOfFile"/-->
|
||||
<module name="FileLength"/>
|
||||
<module name="FileTabCharacter"/>
|
||||
|
||||
<!-- Trailing spaces -->
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="\s+$"/>
|
||||
<property name="message" value="Line has trailing spaces."/>
|
||||
</module>
|
||||
|
||||
<!-- Space after 'for' and 'if' -->
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="^\s*(for|if)[^ ]\("/>
|
||||
<property name="message" value="Space needed before opening parenthesis."/>
|
||||
</module>
|
||||
|
||||
<!-- For each spacing -->
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="^\s*for \(.*?([^ ]:|:[^ ])"/>
|
||||
<property name="message" value="Space needed around ':' character."/>
|
||||
</module>
|
||||
|
||||
<module name="TreeWalker">
|
||||
<!--<property name="cacheFile" value="${checkstyle.cache.file}"/>-->
|
||||
|
||||
<!-- Checks for Javadoc comments. -->
|
||||
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
|
||||
<!--module name="JavadocMethod"/-->
|
||||
<!--module name="JavadocType"/-->
|
||||
<!--module name="JavadocVariable"/-->
|
||||
<!--module name="JavadocStyle"/-->
|
||||
|
||||
|
||||
<!-- Checks for Naming Conventions. -->
|
||||
<!-- See http://checkstyle.sf.net/config_naming.html -->
|
||||
<!--<module name="ConstantName"/>-->
|
||||
<module name="LocalFinalVariableName"/>
|
||||
<module name="LocalVariableName"/>
|
||||
<module name="MemberName"/>
|
||||
<module name="MethodName">
|
||||
<property name="format" value="^[a-z][a-zA-Z0-9_]*$"/>
|
||||
</module>
|
||||
<module name="PackageName"/>
|
||||
<module name="ParameterName"/>
|
||||
<module name="StaticVariableName"/>
|
||||
<module name="TypeName"/>
|
||||
|
||||
|
||||
<!-- Checks for imports -->
|
||||
<!-- See http://checkstyle.sf.net/config_import.html -->
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="IllegalImport"/>
|
||||
<module name="RedundantImport"/>
|
||||
<module name="UnusedImports">
|
||||
<property name="processJavadoc" value="true"/>
|
||||
</module>
|
||||
|
||||
|
||||
<!-- Checks for Size Violations. -->
|
||||
<!-- See http://checkstyle.sf.net/config_sizes.html -->
|
||||
<module name="LineLength">
|
||||
<property name="max" value="200"/>
|
||||
</module>
|
||||
<module name="MethodLength"/>
|
||||
<!--module name="ParameterNumber"/-->
|
||||
|
||||
|
||||
<!-- Checks for whitespace -->
|
||||
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
|
||||
<module name="GenericWhitespace"/>
|
||||
<module name="EmptyForIteratorPad"/>
|
||||
<module name="MethodParamPad"/>
|
||||
<!--<module name="NoWhitespaceAfter"/>-->
|
||||
<module name="NoWhitespaceBefore"/>
|
||||
<module name="OperatorWrap"/>
|
||||
<module name="ParenPad"/>
|
||||
<module name="TypecastParenPad"/>
|
||||
<module name="WhitespaceAfter"/>
|
||||
<module name="WhitespaceAround"/>
|
||||
|
||||
|
||||
<!-- Modifier Checks -->
|
||||
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
|
||||
<module name="ModifierOrder"/>
|
||||
<module name="RedundantModifier"/>
|
||||
|
||||
|
||||
<!-- Checks for blocks. You know, those {}'s -->
|
||||
<!-- See http://checkstyle.sf.net/config_blocks.html -->
|
||||
<!--module name="AvoidNestedBlocks"/-->
|
||||
<!--module name="EmptyBlock"/-->
|
||||
<module name="LeftCurly"/>
|
||||
<!--module name="NeedBraces"/-->
|
||||
<module name="RightCurly"/>
|
||||
|
||||
|
||||
<!-- Checks for common coding problems -->
|
||||
<!-- See http://checkstyle.sf.net/config_coding.html -->
|
||||
<!--module name="AvoidInlineConditionals"/-->
|
||||
<module name="CovariantEquals"/>
|
||||
<module name="EmptyStatement"/>
|
||||
<!--<module name="EqualsAvoidNull"/>-->
|
||||
<module name="EqualsHashCode"/>
|
||||
<!--module name="HiddenField"/-->
|
||||
<module name="IllegalInstantiation"/>
|
||||
<!--<module name="InnerAssignment"/>-->
|
||||
<!--module name="MagicNumber"/-->
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<!--<module name="RedundantThrows"/>-->
|
||||
<module name="SimplifyBooleanExpression"/>
|
||||
<module name="SimplifyBooleanReturn"/>
|
||||
|
||||
<!-- Checks for class design -->
|
||||
<!-- See http://checkstyle.sf.net/config_design.html -->
|
||||
<!--module name="DesignForExtension"/-->
|
||||
<!--module name="FinalClass"/-->
|
||||
<!--module name="HideUtilityClassConstructor"/-->
|
||||
<!--module name="InterfaceIsType"/-->
|
||||
<!--module name="VisibilityModifier"/-->
|
||||
|
||||
|
||||
<!-- Miscellaneous other checks. -->
|
||||
<!-- See http://checkstyle.sf.net/config_misc.html -->
|
||||
<!--module name="ArrayTypeStyle"/-->
|
||||
<!--module name="FinalParameters"/-->
|
||||
<!--module name="TodoComment"/-->
|
||||
<module name="UpperEll"/>
|
||||
</module>
|
||||
</module>
|
@ -1 +0,0 @@
|
||||
# 微博
|
4
android/consumer-rules.pro
Normal file
4
android/consumer-rules.pro
Normal file
@ -0,0 +1,4 @@
|
||||
# 微博
|
||||
|
||||
-keep public class com.sina.weibo.sdk.**{*;}
|
||||
-keep public class com.weibo.ssosdk.**{*;}
|
@ -1 +1,4 @@
|
||||
org.gradle.jvmargs=-Xmx1536M
|
||||
android.enableR8=true
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
|
5
android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
|
17
android/quality.gradle
Normal file
17
android/quality.gradle
Normal file
@ -0,0 +1,17 @@
|
||||
apply plugin: 'checkstyle'
|
||||
|
||||
check.dependsOn 'checkstyle'
|
||||
|
||||
checkstyle {
|
||||
// toolVersion = "6.15"
|
||||
}
|
||||
|
||||
task checkstyle(type: Checkstyle) {
|
||||
configFile project.file('checkstyle.xml')
|
||||
source 'src/main/java'
|
||||
ignoreFailures false
|
||||
showViolations true
|
||||
include '**/*.java'
|
||||
|
||||
classpath = files()
|
||||
}
|
@ -1 +1 @@
|
||||
rootProject.name = 'fake_weibo'
|
||||
rootProject.name = 'weibo_kit'
|
||||
|
@ -1,11 +1,6 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="io.github.v7lin.fakeweibo">
|
||||
package="io.github.v7lin.weibo_kit">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<!-- 用于调用 JNI -->
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
</manifest>
|
||||
|
@ -1,259 +0,0 @@
|
||||
package io.github.v7lin.fakeweibo;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.sina.weibo.sdk.WbSdk;
|
||||
import com.sina.weibo.sdk.api.ImageObject;
|
||||
import com.sina.weibo.sdk.api.TextObject;
|
||||
import com.sina.weibo.sdk.api.WebpageObject;
|
||||
import com.sina.weibo.sdk.api.WeiboMultiMessage;
|
||||
import com.sina.weibo.sdk.auth.AuthInfo;
|
||||
import com.sina.weibo.sdk.auth.Oauth2AccessToken;
|
||||
import com.sina.weibo.sdk.auth.WbAuthListener;
|
||||
import com.sina.weibo.sdk.auth.WbConnectErrorMessage;
|
||||
import com.sina.weibo.sdk.auth.sso.SsoHandler;
|
||||
import com.sina.weibo.sdk.share.WbShareCallback;
|
||||
import com.sina.weibo.sdk.share.WbShareHandler;
|
||||
import com.sina.weibo.sdk.utils.Utility;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.flutter.plugin.common.MethodCall;
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
|
||||
import io.flutter.plugin.common.MethodChannel.Result;
|
||||
import io.flutter.plugin.common.PluginRegistry;
|
||||
import io.flutter.plugin.common.PluginRegistry.Registrar;
|
||||
|
||||
/**
|
||||
* FakeWeiboPlugin
|
||||
*/
|
||||
public class FakeWeiboPlugin implements MethodCallHandler, PluginRegistry.ActivityResultListener {
|
||||
/**
|
||||
* Plugin registration.
|
||||
*/
|
||||
public static void registerWith(Registrar registrar) {
|
||||
final MethodChannel channel = new MethodChannel(registrar.messenger(), "v7lin.github.io/fake_weibo");
|
||||
FakeWeiboPlugin plugin = new FakeWeiboPlugin(registrar, channel);
|
||||
registrar.addActivityResultListener(plugin);
|
||||
channel.setMethodCallHandler(plugin);
|
||||
}
|
||||
|
||||
private static class WeiboErrorCode {
|
||||
public static final int SUCCESS = 0;//成功
|
||||
public static final int USERCANCEL = -1;//用户取消发送
|
||||
public static final int SENT_FAIL = -2;//发送失败
|
||||
public static final int AUTH_DENY = -3;//授权失败
|
||||
public static final int USERCANCEL_INSTALL = -4;//用户取消安装微博客户端
|
||||
public static final int PAY_FAIL = -5;//支付失败
|
||||
public static final int SHARE_IN_SDK_FAILED = -8;//分享失败 详情见response UserInfo
|
||||
public static final int UNSUPPORT = -99;//不支持的请求
|
||||
public static final int UNKNOWN = -100;
|
||||
public static final int SSO_PKG_SIGN_ERROR = 21338;//sso package or sign error
|
||||
}
|
||||
|
||||
private static final String METHOD_REGISTERAPP = "registerApp";
|
||||
private static final String METHOD_ISWEIBOINSTALLED = "isWeiboInstalled";
|
||||
private static final String METHOD_AUTH = "auth";
|
||||
private static final String METHOD_SHARETEXT = "shareText";
|
||||
private static final String METHOD_SHAREIMAGE = "shareImage";
|
||||
private static final String METHOD_SHAREWEBPAGE = "shareWebpage";
|
||||
|
||||
private static final String METHOD_ONAUTHRESP = "onAuthResp";
|
||||
private static final String METHOD_ONSHAREMSGRESP = "onShareMsgResp";
|
||||
|
||||
private static final String ARGUMENT_KEY_APPKEY = "appKey";
|
||||
private static final String ARGUMENT_KEY_SCOPE = "scope";
|
||||
private static final String ARGUMENT_KEY_REDIRECTURL = "redirectUrl";
|
||||
private static final String ARGUMENT_KEY_TEXT = "text";
|
||||
private static final String ARGUMENT_KEY_TITLE = "title";
|
||||
private static final String ARGUMENT_KEY_DESCRIPTION = "description";
|
||||
private static final String ARGUMENT_KEY_THUMBDATA = "thumbData";
|
||||
private static final String ARGUMENT_KEY_IMAGEDATA = "imageData";
|
||||
private static final String ARGUMENT_KEY_IMAGEURI = "imageUri";
|
||||
private static final String ARGUMENT_KEY_WEBPAGEURL = "webpageUrl";
|
||||
|
||||
private static final String ARGUMENT_KEY_RESULT_ERRORCODE = "errorCode";
|
||||
private static final String ARGUMENT_KEY_RESULT_ERRORMESSAGE = "errorMessage";
|
||||
private static final String ARGUMENT_KEY_RESULT_USERID = "userId";
|
||||
private static final String ARGUMENT_KEY_RESULT_ACCESSTOKEN = "accessToken";
|
||||
private static final String ARGUMENT_KEY_RESULT_REFRESHTOKEN = "refreshToken";
|
||||
private static final String ARGUMENT_KEY_RESULT_EXPIRESIN = "expiresIn";
|
||||
|
||||
private final Registrar registrar;
|
||||
private final MethodChannel channel;
|
||||
|
||||
private SsoHandler ssoHandler;
|
||||
private WbShareHandler shareHandler;
|
||||
|
||||
private FakeWeiboPlugin(Registrar registrar, MethodChannel channel) {
|
||||
this.registrar = registrar;
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMethodCall(MethodCall call, Result result) {
|
||||
if (METHOD_REGISTERAPP.equals(call.method)) {
|
||||
String appKey = call.argument(ARGUMENT_KEY_APPKEY);
|
||||
String scope = call.argument(ARGUMENT_KEY_SCOPE);
|
||||
String redirectUrl = call.argument(ARGUMENT_KEY_REDIRECTURL);
|
||||
|
||||
WbSdk.install(registrar.context(), new AuthInfo(registrar.context(), appKey, redirectUrl, scope));
|
||||
ssoHandler = new SsoHandler(registrar.activity());
|
||||
shareHandler = new WbShareHandler(registrar.activity());
|
||||
shareHandler.registerApp();
|
||||
result.success(null);
|
||||
} else if (METHOD_ISWEIBOINSTALLED.equals(call.method)) {
|
||||
result.success(WbSdk.isWbInstall(registrar.context()));
|
||||
} else if (METHOD_AUTH.equals(call.method)) {
|
||||
handleAuthCall(call, result);
|
||||
} else if (METHOD_SHARETEXT.equals(call.method)) {
|
||||
handleShareTextCall(call, result);
|
||||
} else if (METHOD_SHAREIMAGE.equals(call.method) ||
|
||||
METHOD_SHAREWEBPAGE.equals(call.method)) {
|
||||
handleShareMediaCall(call, result);
|
||||
} else {
|
||||
result.notImplemented();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleAuthCall(MethodCall call, Result result) {
|
||||
if (ssoHandler != null) {
|
||||
ssoHandler.authorize(new WbAuthListener() {
|
||||
@Override
|
||||
public void onSuccess(Oauth2AccessToken oauth2AccessToken) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if (oauth2AccessToken.isSessionValid()) {
|
||||
map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.SUCCESS);
|
||||
map.put(ARGUMENT_KEY_RESULT_USERID, oauth2AccessToken.getUid());
|
||||
map.put(ARGUMENT_KEY_RESULT_ACCESSTOKEN, oauth2AccessToken.getToken());
|
||||
map.put(ARGUMENT_KEY_RESULT_REFRESHTOKEN, oauth2AccessToken.getRefreshToken());
|
||||
long expiresIn = (long) Math.ceil((oauth2AccessToken.getExpiresTime() - System.currentTimeMillis()) / 1000.0);
|
||||
map.put(ARGUMENT_KEY_RESULT_EXPIRESIN, expiresIn);// 向上取整
|
||||
} else {
|
||||
map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.UNKNOWN);
|
||||
}
|
||||
channel.invokeMethod(METHOD_ONAUTHRESP, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.USERCANCEL);
|
||||
channel.invokeMethod(METHOD_ONAUTHRESP, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(WbConnectErrorMessage wbConnectErrorMessage) {
|
||||
// 微博有毒,WbConnectErrorMessage对象两个属性设置错误
|
||||
if (TextUtils.equals(wbConnectErrorMessage.getErrorMessage(), "21338")) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.SSO_PKG_SIGN_ERROR);
|
||||
map.put(ARGUMENT_KEY_RESULT_ERRORMESSAGE, wbConnectErrorMessage.getErrorCode());
|
||||
channel.invokeMethod(METHOD_ONAUTHRESP, map);
|
||||
} else {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.UNKNOWN);
|
||||
channel.invokeMethod(METHOD_ONAUTHRESP, map);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
result.success(null);
|
||||
}
|
||||
|
||||
private void handleShareTextCall(MethodCall call, Result result) {
|
||||
if (shareHandler != null) {
|
||||
WeiboMultiMessage message = new WeiboMultiMessage();
|
||||
|
||||
TextObject object = new TextObject();
|
||||
object.text = call.argument(ARGUMENT_KEY_TEXT);// 1024
|
||||
|
||||
message.textObject = object;
|
||||
|
||||
shareHandler.shareMessage(message, false);
|
||||
}
|
||||
result.success(null);
|
||||
}
|
||||
|
||||
private void handleShareMediaCall(MethodCall call, Result result) {
|
||||
if (shareHandler != null) {
|
||||
WeiboMultiMessage message = new WeiboMultiMessage();
|
||||
|
||||
if (METHOD_SHAREIMAGE.equals(call.method)) {
|
||||
if (call.hasArgument(ARGUMENT_KEY_TEXT)) {
|
||||
TextObject object = new TextObject();
|
||||
object.text = call.argument(ARGUMENT_KEY_TEXT);// 1024
|
||||
|
||||
message.textObject = object;
|
||||
}
|
||||
|
||||
ImageObject object = new ImageObject();
|
||||
if (call.hasArgument(ARGUMENT_KEY_IMAGEDATA)) {
|
||||
object.imageData = call.argument(ARGUMENT_KEY_IMAGEDATA);// 2 * 1024 * 1024
|
||||
} else if (call.hasArgument(ARGUMENT_KEY_IMAGEURI)) {
|
||||
String imageUri = call.argument(ARGUMENT_KEY_IMAGEURI);
|
||||
object.imagePath = Uri.parse(imageUri).getPath();// 512 - 10 * 1024 * 1024
|
||||
}
|
||||
|
||||
message.mediaObject = object;
|
||||
} else if (METHOD_SHAREWEBPAGE.equals(call.method)) {
|
||||
WebpageObject object = new WebpageObject();
|
||||
object.identify = Utility.generateGUID();
|
||||
object.title = call.argument(ARGUMENT_KEY_TITLE);// 512
|
||||
object.description = call.argument(ARGUMENT_KEY_DESCRIPTION);// 1024
|
||||
object.thumbData = call.argument(ARGUMENT_KEY_THUMBDATA);// 32 * 1024
|
||||
object.defaultText = call.argument(ARGUMENT_KEY_DESCRIPTION);
|
||||
object.actionUrl = call.argument(ARGUMENT_KEY_WEBPAGEURL);// 512
|
||||
|
||||
message.mediaObject = object;
|
||||
}
|
||||
|
||||
shareHandler.shareMessage(message, false);
|
||||
}
|
||||
result.success(null);
|
||||
}
|
||||
|
||||
// --- ActivityResultListener
|
||||
|
||||
@Override
|
||||
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == 32973) {
|
||||
if (ssoHandler != null) {
|
||||
ssoHandler.authorizeCallBack(requestCode, resultCode, data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (requestCode == WbShareHandler.WB_SHARE_REQUEST) {
|
||||
if (shareHandler != null) {
|
||||
shareHandler.doResultIntent(data, new WbShareCallback() {
|
||||
@Override
|
||||
public void onWbShareSuccess() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.SUCCESS);
|
||||
channel.invokeMethod(METHOD_ONSHAREMSGRESP, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWbShareCancel() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.USERCANCEL);
|
||||
channel.invokeMethod(METHOD_ONSHAREMSGRESP, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWbShareFail() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.SHARE_IN_SDK_FAILED);
|
||||
channel.invokeMethod(METHOD_ONSHAREMSGRESP, map);
|
||||
}
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
274
android/src/main/java/io/github/v7lin/weibo_kit/WeiboKit.java
Normal file
274
android/src/main/java/io/github/v7lin/weibo_kit/WeiboKit.java
Normal file
@ -0,0 +1,274 @@
|
||||
package io.github.v7lin.weibo_kit;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.sina.weibo.sdk.api.ImageObject;
|
||||
import com.sina.weibo.sdk.api.TextObject;
|
||||
import com.sina.weibo.sdk.api.WebpageObject;
|
||||
import com.sina.weibo.sdk.api.WeiboMultiMessage;
|
||||
import com.sina.weibo.sdk.auth.AuthInfo;
|
||||
import com.sina.weibo.sdk.auth.Oauth2AccessToken;
|
||||
import com.sina.weibo.sdk.auth.WbAuthListener;
|
||||
import com.sina.weibo.sdk.common.UiError;
|
||||
import com.sina.weibo.sdk.openapi.IWBAPI;
|
||||
import com.sina.weibo.sdk.openapi.WBAPIFactory;
|
||||
import com.sina.weibo.sdk.share.WbShareCallback;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import io.flutter.plugin.common.BinaryMessenger;
|
||||
import io.flutter.plugin.common.MethodCall;
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
import io.flutter.plugin.common.PluginRegistry;
|
||||
|
||||
public class WeiboKit implements MethodChannel.MethodCallHandler, PluginRegistry.ActivityResultListener {
|
||||
|
||||
private static class WeiboErrorCode {
|
||||
public static final int SUCCESS = 0;//成功
|
||||
public static final int USERCANCEL = -1;//用户取消发送
|
||||
public static final int SENT_FAIL = -2;//发送失败
|
||||
public static final int AUTH_DENY = -3;//授权失败
|
||||
public static final int USERCANCEL_INSTALL = -4;//用户取消安装微博客户端
|
||||
public static final int PAY_FAIL = -5;//支付失败
|
||||
public static final int SHARE_IN_SDK_FAILED = -8;//分享失败 详情见response UserInfo
|
||||
public static final int UNSUPPORT = -99;//不支持的请求
|
||||
public static final int UNKNOWN = -100;
|
||||
}
|
||||
|
||||
private static final String METHOD_REGISTERAPP = "registerApp";
|
||||
private static final String METHOD_ISINSTALLED = "isInstalled";
|
||||
private static final String METHOD_AUTH = "auth";
|
||||
private static final String METHOD_SHARETEXT = "shareText";
|
||||
private static final String METHOD_SHAREIMAGE = "shareImage";
|
||||
private static final String METHOD_SHAREWEBPAGE = "shareWebpage";
|
||||
|
||||
private static final String METHOD_ONAUTHRESP = "onAuthResp";
|
||||
private static final String METHOD_ONSHAREMSGRESP = "onShareMsgResp";
|
||||
|
||||
private static final String ARGUMENT_KEY_APPKEY = "appKey";
|
||||
private static final String ARGUMENT_KEY_SCOPE = "scope";
|
||||
private static final String ARGUMENT_KEY_REDIRECTURL = "redirectUrl";
|
||||
private static final String ARGUMENT_KEY_TEXT = "text";
|
||||
private static final String ARGUMENT_KEY_TITLE = "title";
|
||||
private static final String ARGUMENT_KEY_DESCRIPTION = "description";
|
||||
private static final String ARGUMENT_KEY_THUMBDATA = "thumbData";
|
||||
private static final String ARGUMENT_KEY_IMAGEDATA = "imageData";
|
||||
private static final String ARGUMENT_KEY_IMAGEURI = "imageUri";
|
||||
private static final String ARGUMENT_KEY_WEBPAGEURL = "webpageUrl";
|
||||
|
||||
private static final String ARGUMENT_KEY_RESULT_ERRORCODE = "errorCode";
|
||||
private static final String ARGUMENT_KEY_RESULT_ERRORMESSAGE = "errorMessage";
|
||||
private static final String ARGUMENT_KEY_RESULT_USERID = "userId";
|
||||
private static final String ARGUMENT_KEY_RESULT_ACCESSTOKEN = "accessToken";
|
||||
private static final String ARGUMENT_KEY_RESULT_REFRESHTOKEN = "refreshToken";
|
||||
private static final String ARGUMENT_KEY_RESULT_EXPIRESIN = "expiresIn";
|
||||
|
||||
//
|
||||
|
||||
private Context applicationContext;
|
||||
private Activity activity;
|
||||
|
||||
private MethodChannel channel;
|
||||
|
||||
private IWBAPI iwbapi;
|
||||
|
||||
public WeiboKit() {
|
||||
super();
|
||||
}
|
||||
|
||||
public WeiboKit(Context applicationContext, Activity activity) {
|
||||
this.applicationContext = applicationContext;
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
public void setApplicationContext(@Nullable Context applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
public void setActivity(@Nullable Activity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
public void startListening(@NonNull BinaryMessenger messenger) {
|
||||
channel = new MethodChannel(messenger, "v7lin.github.io/weibo_kit");
|
||||
channel.setMethodCallHandler(this);
|
||||
}
|
||||
|
||||
public void stopListening() {
|
||||
channel.setMethodCallHandler(null);
|
||||
channel = null;
|
||||
}
|
||||
|
||||
// --- MethodCallHandler
|
||||
|
||||
@Override
|
||||
public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
|
||||
if (METHOD_REGISTERAPP.equals(call.method)) {
|
||||
String appKey = call.argument(ARGUMENT_KEY_APPKEY);
|
||||
String scope = call.argument(ARGUMENT_KEY_SCOPE);
|
||||
String redirectUrl = call.argument(ARGUMENT_KEY_REDIRECTURL);
|
||||
|
||||
iwbapi = WBAPIFactory.createWBAPI(activity);
|
||||
iwbapi.registerApp(applicationContext, new AuthInfo(applicationContext, appKey, redirectUrl, scope));
|
||||
result.success(null);
|
||||
} else if (METHOD_ISINSTALLED.equals(call.method)) {
|
||||
result.success(iwbapi.isWBAppInstalled());
|
||||
} else if (METHOD_AUTH.equals(call.method)) {
|
||||
handleAuthCall(call, result);
|
||||
} else if (METHOD_SHARETEXT.equals(call.method)) {
|
||||
handleShareTextCall(call, result);
|
||||
} else if (METHOD_SHAREIMAGE.equals(call.method) ||
|
||||
METHOD_SHAREWEBPAGE.equals(call.method)) {
|
||||
handleShareMediaCall(call, result);
|
||||
} else {
|
||||
result.notImplemented();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleAuthCall(MethodCall call, MethodChannel.Result result) {
|
||||
if (iwbapi != null) {
|
||||
iwbapi.authorize(new WbAuthListener() {
|
||||
@Override
|
||||
public void onComplete(Oauth2AccessToken token) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if (token.isSessionValid()) {
|
||||
map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.SUCCESS);
|
||||
map.put(ARGUMENT_KEY_RESULT_USERID, token.getUid());
|
||||
map.put(ARGUMENT_KEY_RESULT_ACCESSTOKEN, token.getAccessToken());
|
||||
map.put(ARGUMENT_KEY_RESULT_REFRESHTOKEN, token.getRefreshToken());
|
||||
long expiresIn = (long) Math.ceil((token.getExpiresTime() - System.currentTimeMillis()) / 1000.0);
|
||||
map.put(ARGUMENT_KEY_RESULT_EXPIRESIN, expiresIn);// 向上取整
|
||||
} else {
|
||||
map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.UNKNOWN);
|
||||
}
|
||||
if (channel != null) {
|
||||
channel.invokeMethod(METHOD_ONAUTHRESP, map);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(UiError uiError) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.UNKNOWN);
|
||||
channel.invokeMethod(METHOD_ONAUTHRESP, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.USERCANCEL);
|
||||
if (channel != null) {
|
||||
channel.invokeMethod(METHOD_ONAUTHRESP, map);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
result.success(null);
|
||||
}
|
||||
|
||||
private void handleShareTextCall(MethodCall call, MethodChannel.Result result) {
|
||||
WeiboMultiMessage message = new WeiboMultiMessage();
|
||||
|
||||
TextObject object = new TextObject();
|
||||
object.text = call.argument(ARGUMENT_KEY_TEXT);// 1024
|
||||
|
||||
message.textObject = object;
|
||||
|
||||
if (iwbapi != null) {
|
||||
iwbapi.shareMessage(message, false);
|
||||
}
|
||||
result.success(null);
|
||||
}
|
||||
|
||||
private void handleShareMediaCall(MethodCall call, MethodChannel.Result result) {
|
||||
WeiboMultiMessage message = new WeiboMultiMessage();
|
||||
|
||||
if (METHOD_SHAREIMAGE.equals(call.method)) {
|
||||
if (call.hasArgument(ARGUMENT_KEY_TEXT)) {
|
||||
TextObject object = new TextObject();
|
||||
object.text = call.argument(ARGUMENT_KEY_TEXT);// 1024
|
||||
|
||||
message.textObject = object;
|
||||
}
|
||||
|
||||
ImageObject object = new ImageObject();
|
||||
if (call.hasArgument(ARGUMENT_KEY_IMAGEDATA)) {
|
||||
object.imageData = call.argument(ARGUMENT_KEY_IMAGEDATA);// 2 * 1024 * 1024
|
||||
} else if (call.hasArgument(ARGUMENT_KEY_IMAGEURI)) {
|
||||
String imageUri = call.argument(ARGUMENT_KEY_IMAGEURI);
|
||||
object.imagePath = Uri.parse(imageUri).getPath();// 512 - 10 * 1024 * 1024
|
||||
}
|
||||
|
||||
message.mediaObject = object;
|
||||
} else if (METHOD_SHAREWEBPAGE.equals(call.method)) {
|
||||
WebpageObject object = new WebpageObject();
|
||||
object.identify = UUID.randomUUID().toString();
|
||||
object.title = call.argument(ARGUMENT_KEY_TITLE);// 512
|
||||
object.description = call.argument(ARGUMENT_KEY_DESCRIPTION);// 1024
|
||||
object.thumbData = call.argument(ARGUMENT_KEY_THUMBDATA);// 32 * 1024
|
||||
object.defaultText = call.argument(ARGUMENT_KEY_DESCRIPTION);
|
||||
object.actionUrl = call.argument(ARGUMENT_KEY_WEBPAGEURL);// 512
|
||||
|
||||
message.mediaObject = object;
|
||||
}
|
||||
|
||||
if (iwbapi != null) {
|
||||
iwbapi.shareMessage(message, false);
|
||||
}
|
||||
result.success(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode) {
|
||||
case 32973:
|
||||
if (iwbapi != null) {
|
||||
iwbapi.authorizeCallback(requestCode, resultCode, data);
|
||||
}
|
||||
return true;
|
||||
case 10001:
|
||||
if (iwbapi != null) {
|
||||
iwbapi.doResultIntent(data, new WbShareCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.SUCCESS);
|
||||
if (channel != null) {
|
||||
channel.invokeMethod(METHOD_ONSHAREMSGRESP, map);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(UiError uiError) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.SHARE_IN_SDK_FAILED);
|
||||
if (channel != null) {
|
||||
channel.invokeMethod(METHOD_ONSHAREMSGRESP, map);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.USERCANCEL);
|
||||
if (channel != null) {
|
||||
channel.invokeMethod(METHOD_ONSHAREMSGRESP, map);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package io.github.v7lin.weibo_kit;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import io.flutter.embedding.engine.plugins.FlutterPlugin;
|
||||
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
|
||||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
|
||||
import io.flutter.plugin.common.PluginRegistry.Registrar;
|
||||
|
||||
/** WeiboKitPlugin */
|
||||
public class WeiboKitPlugin implements FlutterPlugin, ActivityAware {
|
||||
// This static function is optional and equivalent to onAttachedToEngine. It supports the old
|
||||
// pre-Flutter-1.12 Android projects. You are encouraged to continue supporting
|
||||
// plugin registration via this function while apps migrate to use the new Android APIs
|
||||
// post-flutter-1.12 via https://flutter.dev/go/android-project-migration.
|
||||
//
|
||||
// It is encouraged to share logic between onAttachedToEngine and registerWith to keep
|
||||
// them functionally equivalent. Only one of onAttachedToEngine or registerWith will be called
|
||||
// depending on the user's project. onAttachedToEngine or registerWith must both be defined
|
||||
// in the same class.
|
||||
public static void registerWith(Registrar registrar) {
|
||||
WeiboKit weiboKit = new WeiboKit(registrar.context(), registrar.activity());
|
||||
registrar.addActivityResultListener(weiboKit);
|
||||
weiboKit.startListening(registrar.messenger());
|
||||
}
|
||||
|
||||
// --- FlutterPlugin
|
||||
|
||||
private final WeiboKit weiboKit;
|
||||
|
||||
private ActivityPluginBinding pluginBinding;
|
||||
|
||||
public WeiboKitPlugin() {
|
||||
weiboKit = new WeiboKit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
|
||||
weiboKit.setApplicationContext(binding.getApplicationContext());
|
||||
weiboKit.setActivity(null);
|
||||
weiboKit.startListening(binding.getBinaryMessenger());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
|
||||
weiboKit.setApplicationContext(null);
|
||||
weiboKit.setActivity(null);
|
||||
weiboKit.stopListening();
|
||||
}
|
||||
|
||||
// --- ActivityAware
|
||||
|
||||
@Override
|
||||
public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) {
|
||||
weiboKit.setActivity(binding.getActivity());
|
||||
pluginBinding = binding;
|
||||
pluginBinding.addActivityResultListener(weiboKit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromActivityForConfigChanges() {
|
||||
onDetachedFromActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) {
|
||||
onAttachedToActivity(binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromActivity() {
|
||||
weiboKit.setActivity(null);
|
||||
pluginBinding.removeActivityResultListener(weiboKit);
|
||||
pluginBinding = null;
|
||||
}
|
||||
}
|
54
example/.gitignore
vendored
54
example/.gitignore
vendored
@ -1,6 +1,5 @@
|
||||
# Miscellaneous
|
||||
*.class
|
||||
*.lock
|
||||
*.log
|
||||
*.pyc
|
||||
*.swp
|
||||
@ -16,56 +15,29 @@
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Visual Studio Code related
|
||||
.vscode/
|
||||
# The .vscode folder contains launch configuration and tasks you configure in
|
||||
# VS Code which you may wish to be included in version control, so this line
|
||||
# is commented out by default.
|
||||
#.vscode/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
**/doc/api/
|
||||
.dart_tool/
|
||||
.flutter-plugins
|
||||
.flutter-plugins-dependencies
|
||||
.packages
|
||||
.pub-cache/
|
||||
.pub/
|
||||
build/
|
||||
/build/
|
||||
|
||||
# Android related
|
||||
**/android/**/gradle-wrapper.jar
|
||||
**/android/.gradle
|
||||
**/android/captures/
|
||||
**/android/gradlew
|
||||
**/android/gradlew.bat
|
||||
**/android/local.properties
|
||||
**/android/**/GeneratedPluginRegistrant.java
|
||||
# Web related
|
||||
lib/generated_plugin_registrant.dart
|
||||
|
||||
# iOS/XCode related
|
||||
**/ios/**/*.mode1v3
|
||||
**/ios/**/*.mode2v3
|
||||
**/ios/**/*.moved-aside
|
||||
**/ios/**/*.pbxuser
|
||||
**/ios/**/*.perspectivev3
|
||||
**/ios/**/*sync/
|
||||
**/ios/**/.sconsign.dblite
|
||||
**/ios/**/.tags*
|
||||
**/ios/**/.vagrant/
|
||||
**/ios/**/DerivedData/
|
||||
**/ios/**/Icon?
|
||||
**/ios/**/Pods/
|
||||
**/ios/**/.symlinks/
|
||||
**/ios/**/profile
|
||||
**/ios/**/xcuserdata
|
||||
**/ios/.generated/
|
||||
**/ios/Flutter/App.framework
|
||||
**/ios/Flutter/Flutter.framework
|
||||
**/ios/Flutter/Generated.xcconfig
|
||||
**/ios/Flutter/app.flx
|
||||
**/ios/Flutter/app.zip
|
||||
**/ios/Flutter/flutter_assets/
|
||||
**/ios/ServiceDefinitions.json
|
||||
**/ios/Runner/GeneratedPluginRegistrant.*
|
||||
# Symbolication related
|
||||
app.*.symbols
|
||||
|
||||
# Obfuscation related
|
||||
app.*.map.json
|
||||
|
||||
# Exceptions to above rules.
|
||||
!**/ios/**/default.mode1v3
|
||||
!**/ios/**/default.mode2v3
|
||||
!**/ios/**/default.pbxuser
|
||||
!**/ios/**/default.perspectivev3
|
||||
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
|
||||
|
@ -4,7 +4,7 @@
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: 5391447fae6209bb21a89e6a5a6583cac1af9b4b
|
||||
revision: b041144f833e05cf463b8887fa12efdec9493488
|
||||
channel: stable
|
||||
|
||||
project_type: app
|
||||
|
@ -1,6 +1,6 @@
|
||||
# fake_weibo_example
|
||||
# weibo_kit_example
|
||||
|
||||
Demonstrates how to use the fake_weibo plugin.
|
||||
Demonstrates how to use the weibo_kit plugin.
|
||||
|
||||
## Getting Started
|
||||
|
||||
@ -8,9 +8,9 @@ This project is a starting point for a Flutter application.
|
||||
|
||||
A few resources to get you started if this is your first Flutter project:
|
||||
|
||||
- [Lab: Write your first Flutter app](https://flutter.io/docs/get-started/codelab)
|
||||
- [Cookbook: Useful Flutter samples](https://flutter.io/docs/cookbook)
|
||||
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
|
||||
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
|
||||
|
||||
For help getting started with Flutter, view our
|
||||
[online documentation](https://flutter.io/docs), which offers tutorials,
|
||||
For help getting started with Flutter, view our
|
||||
[online documentation](https://flutter.dev/docs), which offers tutorials,
|
||||
samples, guidance on mobile development, and a full API reference.
|
||||
|
34
example/analysis_options.yaml
Normal file → Executable file
34
example/analysis_options.yaml
Normal file → Executable file
@ -1,32 +1,4 @@
|
||||
# Defines a default set of lint rules enforced for
|
||||
# projects at Google. For details and rationale,
|
||||
# see https://github.com/dart-lang/pedantic#enabled-lints.
|
||||
include: package:pedantic/analysis_options.yaml
|
||||
# Take our settings from the repo's main analysis_options.yaml file, but include
|
||||
# an additional rule to validate that public members are documented.
|
||||
|
||||
analyzer:
|
||||
strong-mode:
|
||||
implicit-casts: false
|
||||
# implicit-dynamic: false
|
||||
|
||||
linter:
|
||||
rules:
|
||||
- iterable_contains_unrelated_type
|
||||
- list_remove_unrelated_type
|
||||
- test_types_in_equals
|
||||
- unrelated_type_equality_checks
|
||||
- valid_regexps
|
||||
- annotate_overrides
|
||||
- hash_and_equals
|
||||
- prefer_is_not_empty
|
||||
- avoid_empty_else
|
||||
- cancel_subscriptions
|
||||
- close_sinks
|
||||
- always_declare_return_types
|
||||
- camel_case_types
|
||||
- empty_constructor_bodies
|
||||
- avoid_init_to_null
|
||||
# - constant_identifier_names
|
||||
- one_member_abstracts
|
||||
- slash_for_doc_comments
|
||||
- sort_constructors_first
|
||||
- unnecessary_new
|
||||
include: ../analysis_options.yaml
|
||||
|
7
example/android/.gitignore
vendored
Normal file
7
example/android/.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
gradle-wrapper.jar
|
||||
/.gradle
|
||||
/captures/
|
||||
/gradlew
|
||||
/gradlew.bat
|
||||
/local.properties
|
||||
GeneratedPluginRegistrant.java
|
@ -33,12 +33,11 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||
applicationId "io.github.v7lin.fakeweiboexample"
|
||||
applicationId "io.github.v7lin.weibo_kit_example"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 28
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
@ -46,11 +45,6 @@ android {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
signingConfig signingConfigs.debug
|
||||
|
||||
minifyEnabled true
|
||||
useProguard true
|
||||
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -58,9 +52,3 @@ android {
|
||||
flutter {
|
||||
source '../..'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||
}
|
||||
|
8
example/android/app/proguard-rules.pro
vendored
8
example/android/app/proguard-rules.pro
vendored
@ -1,8 +0,0 @@
|
||||
#Flutter Wrapper
|
||||
-keep class io.flutter.app.** { *; }
|
||||
-keep class io.flutter.plugin.** { *; }
|
||||
-keep class io.flutter.util.** { *; }
|
||||
-keep class io.flutter.view.** { *; }
|
||||
-keep class io.flutter.** { *; }
|
||||
-keep class io.flutter.plugins.** { *; }
|
||||
-dontwarn io.flutter.**
|
7
example/android/app/src/debug/AndroidManifest.xml
Normal file
7
example/android/app/src/debug/AndroidManifest.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="io.github.v7lin.weibo_kit_example">
|
||||
<!-- Flutter needs it to communicate with the running application
|
||||
to allow setting breakpoints, to provide hot reload, etc.
|
||||
-->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
</manifest>
|
@ -1,12 +1,5 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="io.github.v7lin.fakeweiboexample">
|
||||
|
||||
<!-- The INTERNET permission is required for development. Specifically,
|
||||
flutter needs it to communicate with the running application
|
||||
to allow setting breakpoints, to provide hot reload, etc.
|
||||
-->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
package="io.github.v7lin.weibo_kit_example">
|
||||
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
|
||||
calls FlutterMain.startInitialization(this); in its onCreate method.
|
||||
In most cases you can leave this as-is, but you if you want to provide
|
||||
@ -14,26 +7,41 @@
|
||||
FlutterApplication and put your custom class here. -->
|
||||
<application
|
||||
android:name="io.flutter.app.FlutterApplication"
|
||||
android:label="fake_weibo_example"
|
||||
android:label="weibo_kit_example"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:launchMode="singleTop"
|
||||
android:theme="@style/LaunchTheme"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
android:hardwareAccelerated="true"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<!-- This keeps the window background of the activity showing
|
||||
until Flutter renders its first frame. It can be removed if
|
||||
there is no splash screen (such as the default splash screen
|
||||
defined in @style/LaunchTheme). -->
|
||||
<!-- Specifies an Android theme to apply to this Activity as soon as
|
||||
the Android process has started. This theme is visible to the user
|
||||
while the Flutter UI initializes. After that, this theme continues
|
||||
to determine the Window background behind the Flutter UI. -->
|
||||
<meta-data
|
||||
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
|
||||
android:value="true" />
|
||||
android:name="io.flutter.embedding.android.NormalTheme"
|
||||
android:resource="@style/NormalTheme"
|
||||
/>
|
||||
<!-- Displays an Android View that continues showing the launch screen
|
||||
Drawable until Flutter paints its first frame, then this splash
|
||||
screen fades out. A splash screen is useful to avoid any visual
|
||||
gap between the end of Android's launch screen and the painting of
|
||||
Flutter's first frame. -->
|
||||
<meta-data
|
||||
android:name="io.flutter.embedding.android.SplashScreenDrawable"
|
||||
android:resource="@drawable/launch_background"
|
||||
/>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- Don't delete the meta-data below.
|
||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
</application>
|
||||
</manifest>
|
||||
|
@ -1,13 +0,0 @@
|
||||
package io.github.v7lin.fakeweiboexample;
|
||||
|
||||
import android.os.Bundle;
|
||||
import io.flutter.app.FlutterActivity;
|
||||
import io.flutter.plugins.GeneratedPluginRegistrant;
|
||||
|
||||
public class MainActivity extends FlutterActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
GeneratedPluginRegistrant.registerWith(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package io.github.v7lin.weibo_kit_example;
|
||||
|
||||
import io.flutter.embedding.android.FlutterActivity;
|
||||
|
||||
public class MainActivity extends FlutterActivity {
|
||||
}
|
@ -1,8 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- Theme applied to the Android Window while the process is starting -->
|
||||
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||
<!-- Show a splash screen on the activity. Automatically removed when
|
||||
Flutter draws its first frame -->
|
||||
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||
</style>
|
||||
<!-- Theme applied to the Android Window as soon as the process has started.
|
||||
This theme determines the color of the Android Window while your
|
||||
Flutter UI initializes, as well as behind your Flutter UI while its
|
||||
running.
|
||||
|
||||
This Theme is only used starting with V2 of Flutter's Android embedding. -->
|
||||
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||
<item name="android:windowBackground">@android:color/white</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
7
example/android/app/src/profile/AndroidManifest.xml
Normal file
7
example/android/app/src/profile/AndroidManifest.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="io.github.v7lin.weibo_kit_example">
|
||||
<!-- Flutter needs it to communicate with the running application
|
||||
to allow setting breakpoints, to provide hot reload, etc.
|
||||
-->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
</manifest>
|
@ -5,7 +5,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1 +1,4 @@
|
||||
org.gradle.jvmargs=-Xmx1536M
|
||||
android.enableR8=true
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
|
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
|
||||
|
@ -1,15 +1,15 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
include ':app'
|
||||
|
||||
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
|
||||
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
|
||||
def properties = new Properties()
|
||||
|
||||
def plugins = new Properties()
|
||||
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
|
||||
if (pluginsFile.exists()) {
|
||||
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
|
||||
}
|
||||
assert localPropertiesFile.exists()
|
||||
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
|
||||
|
||||
plugins.each { name, path ->
|
||||
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
|
||||
include ":$name"
|
||||
project(":$name").projectDir = pluginDirectory
|
||||
}
|
||||
def flutterSdkPath = properties.getProperty("flutter.sdk")
|
||||
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
|
||||
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 721 B |
Binary file not shown.
Before Width: | Height: | Size: 103 KiB |
32
example/ios/.gitignore
vendored
Normal file
32
example/ios/.gitignore
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
*.mode1v3
|
||||
*.mode2v3
|
||||
*.moved-aside
|
||||
*.pbxuser
|
||||
*.perspectivev3
|
||||
**/*sync/
|
||||
.sconsign.dblite
|
||||
.tags*
|
||||
**/.vagrant/
|
||||
**/DerivedData/
|
||||
Icon?
|
||||
**/Pods/
|
||||
**/.symlinks/
|
||||
profile
|
||||
xcuserdata
|
||||
**/.generated/
|
||||
Flutter/App.framework
|
||||
Flutter/Flutter.framework
|
||||
Flutter/Flutter.podspec
|
||||
Flutter/Generated.xcconfig
|
||||
Flutter/app.flx
|
||||
Flutter/app.zip
|
||||
Flutter/flutter_assets/
|
||||
Flutter/flutter_export_environment.sh
|
||||
ServiceDefinitions.json
|
||||
Runner/GeneratedPluginRegistrant.*
|
||||
|
||||
# Exceptions to above rules.
|
||||
!default.mode1v3
|
||||
!default.mode2v3
|
||||
!default.pbxuser
|
||||
!default.perspectivev3
|
@ -3,7 +3,7 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>App</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
|
@ -15,49 +15,64 @@ def parse_KV_file(file, separator='=')
|
||||
if !File.exists? file_abs_path
|
||||
return [];
|
||||
end
|
||||
pods_ary = []
|
||||
generated_key_values = {}
|
||||
skip_line_start_symbols = ["#", "/"]
|
||||
File.foreach(file_abs_path) { |line|
|
||||
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
|
||||
plugin = line.split(pattern=separator)
|
||||
if plugin.length == 2
|
||||
podname = plugin[0].strip()
|
||||
path = plugin[1].strip()
|
||||
podpath = File.expand_path("#{path}", file_abs_path)
|
||||
pods_ary.push({:name => podname, :path => podpath});
|
||||
else
|
||||
puts "Invalid plugin specification: #{line}"
|
||||
end
|
||||
}
|
||||
return pods_ary
|
||||
File.foreach(file_abs_path) do |line|
|
||||
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
|
||||
plugin = line.split(pattern=separator)
|
||||
if plugin.length == 2
|
||||
podname = plugin[0].strip()
|
||||
path = plugin[1].strip()
|
||||
podpath = File.expand_path("#{path}", file_abs_path)
|
||||
generated_key_values[podname] = podpath
|
||||
else
|
||||
puts "Invalid plugin specification: #{line}"
|
||||
end
|
||||
end
|
||||
generated_key_values
|
||||
end
|
||||
|
||||
target 'Runner' do
|
||||
# Flutter Pod
|
||||
|
||||
copied_flutter_dir = File.join(__dir__, 'Flutter')
|
||||
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
|
||||
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
|
||||
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
|
||||
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
|
||||
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
|
||||
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
|
||||
|
||||
generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
|
||||
unless File.exist?(generated_xcode_build_settings_path)
|
||||
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
|
||||
end
|
||||
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
|
||||
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
|
||||
|
||||
unless File.exist?(copied_framework_path)
|
||||
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
|
||||
end
|
||||
unless File.exist?(copied_podspec_path)
|
||||
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
|
||||
end
|
||||
end
|
||||
|
||||
# Keep pod path relative so it can be checked into Podfile.lock.
|
||||
pod 'Flutter', :path => 'Flutter'
|
||||
|
||||
# Plugin Pods
|
||||
|
||||
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
|
||||
# referring to absolute paths on developers' machines.
|
||||
system('rm -rf .symlinks')
|
||||
system('mkdir -p .symlinks/plugins')
|
||||
|
||||
# Flutter Pods
|
||||
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
|
||||
if generated_xcode_build_settings.empty?
|
||||
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
|
||||
end
|
||||
generated_xcode_build_settings.map { |p|
|
||||
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
|
||||
symlink = File.join('.symlinks', 'flutter')
|
||||
File.symlink(File.dirname(p[:path]), symlink)
|
||||
pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
|
||||
end
|
||||
}
|
||||
|
||||
# Plugin Pods
|
||||
plugin_pods = parse_KV_file('../.flutter-plugins')
|
||||
plugin_pods.map { |p|
|
||||
symlink = File.join('.symlinks', 'plugins', p[:name])
|
||||
File.symlink(p[:path], symlink)
|
||||
pod p[:name], :path => File.join(symlink, 'ios')
|
||||
}
|
||||
plugin_pods.each do |name, path|
|
||||
symlink = File.join('.symlinks', 'plugins', name)
|
||||
File.symlink(path, symlink)
|
||||
pod name, :path => File.join(symlink, 'ios')
|
||||
end
|
||||
end
|
||||
|
||||
post_install do |installer|
|
||||
|
50
example/ios/Podfile.lock
Normal file
50
example/ios/Podfile.lock
Normal file
@ -0,0 +1,50 @@
|
||||
PODS:
|
||||
- Flutter (1.0.0)
|
||||
- path_provider (0.0.1):
|
||||
- Flutter
|
||||
- path_provider_linux (0.0.1):
|
||||
- Flutter
|
||||
- path_provider_macos (0.0.1):
|
||||
- Flutter
|
||||
- weibo_kit (1.0.0):
|
||||
- Flutter
|
||||
- weibo_kit/vendor (= 1.0.0)
|
||||
- weibo_kit/vendor (1.0.0):
|
||||
- Flutter
|
||||
- Weibo_SDK (~> 3.2.7)
|
||||
- Weibo_SDK (3.2.7)
|
||||
|
||||
DEPENDENCIES:
|
||||
- Flutter (from `Flutter`)
|
||||
- path_provider (from `.symlinks/plugins/path_provider/ios`)
|
||||
- path_provider_linux (from `.symlinks/plugins/path_provider_linux/ios`)
|
||||
- path_provider_macos (from `.symlinks/plugins/path_provider_macos/ios`)
|
||||
- weibo_kit (from `.symlinks/plugins/weibo_kit/ios`)
|
||||
|
||||
SPEC REPOS:
|
||||
trunk:
|
||||
- Weibo_SDK
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
Flutter:
|
||||
:path: Flutter
|
||||
path_provider:
|
||||
:path: ".symlinks/plugins/path_provider/ios"
|
||||
path_provider_linux:
|
||||
:path: ".symlinks/plugins/path_provider_linux/ios"
|
||||
path_provider_macos:
|
||||
:path: ".symlinks/plugins/path_provider_macos/ios"
|
||||
weibo_kit:
|
||||
:path: ".symlinks/plugins/weibo_kit/ios"
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
|
||||
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
|
||||
path_provider_linux: 4d630dc393e1f20364f3e3b4a2ff41d9674a84e4
|
||||
path_provider_macos: f760a3c5b04357c380e2fddb6f9db6f3015897e0
|
||||
weibo_kit: b3178a26e9ea391bf9fec5c6ef1ee3f5d38735ad
|
||||
Weibo_SDK: 5a4d08f7e1fedbb635435e4585c8c0439c7da089
|
||||
|
||||
PODFILE CHECKSUM: f32fb4e7c14f8b3ca19a369d7be425dd9241af27
|
||||
|
||||
COCOAPODS: 1.8.4
|
@ -3,23 +3,18 @@
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objectVersion = 51;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
|
||||
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
|
||||
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; };
|
||||
3CDD46DAA37A5371B2A70EC2 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FF490F57C9D1EABC131B9426 /* libPods-Runner.a */; };
|
||||
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
|
||||
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
|
||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
||||
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
|
||||
F607D74C02A3D09C94D22138 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CC78EBE1496BEBD8B37D6CBF /* libPods-Runner.a */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
@ -29,8 +24,6 @@
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
|
||||
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
|
||||
);
|
||||
name = "Embed Frameworks";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@ -40,24 +33,22 @@
|
||||
/* Begin PBXFileReference section */
|
||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
||||
3329B2A78B4C4B969972BA19 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
|
||||
40991B03E162E46C56B9D900 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
||||
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||
8C3451CC4D3C94BCDF014D4C /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; };
|
||||
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
983F5802E11ABE4DB378B222 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
|
||||
CC78EBE1496BEBD8B37D6CBF /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
C5C37EFD234544E62872E54A /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
|
||||
E0BD40F9BEC5B3B35E91E09D /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
FF490F57C9D1EABC131B9426 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -65,31 +56,27 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
|
||||
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
|
||||
F607D74C02A3D09C94D22138 /* libPods-Runner.a in Frameworks */,
|
||||
3CDD46DAA37A5371B2A70EC2 /* libPods-Runner.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
118CEF9B5D8D03B56D5D7C1F /* Pods */ = {
|
||||
6C41AA3581FC291CB33F9055 /* Pods */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3329B2A78B4C4B969972BA19 /* Pods-Runner.debug.xcconfig */,
|
||||
983F5802E11ABE4DB378B222 /* Pods-Runner.release.xcconfig */,
|
||||
40991B03E162E46C56B9D900 /* Pods-Runner.profile.xcconfig */,
|
||||
E0BD40F9BEC5B3B35E91E09D /* Pods-Runner.debug.xcconfig */,
|
||||
C5C37EFD234544E62872E54A /* Pods-Runner.release.xcconfig */,
|
||||
8C3451CC4D3C94BCDF014D4C /* Pods-Runner.profile.xcconfig */,
|
||||
);
|
||||
name = Pods;
|
||||
path = Pods;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9740EEB11CF90186004384FC /* Flutter */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3B80C3931E831B6300D905FE /* App.framework */,
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
|
||||
9740EEBA1CF902C7004384FC /* Flutter.framework */,
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */,
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
|
||||
9740EEB31CF90195004384FC /* Generated.xcconfig */,
|
||||
@ -103,8 +90,8 @@
|
||||
9740EEB11CF90186004384FC /* Flutter */,
|
||||
97C146F01CF9000F007C117D /* Runner */,
|
||||
97C146EF1CF9000F007C117D /* Products */,
|
||||
118CEF9B5D8D03B56D5D7C1F /* Pods */,
|
||||
BC7D72E583FD7697E09D7784 /* Frameworks */,
|
||||
6C41AA3581FC291CB33F9055 /* Pods */,
|
||||
97EA60ED8F200E6F573A9890 /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
@ -140,10 +127,10 @@
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
BC7D72E583FD7697E09D7784 /* Frameworks */ = {
|
||||
97EA60ED8F200E6F573A9890 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CC78EBE1496BEBD8B37D6CBF /* libPods-Runner.a */,
|
||||
FF490F57C9D1EABC131B9426 /* libPods-Runner.a */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
@ -155,15 +142,15 @@
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
|
||||
buildPhases = (
|
||||
5E40D85FABB1650818BB4959 /* [CP] Check Pods Manifest.lock */,
|
||||
631D2F29201BBC63DC66AD43 /* [CP] Check Pods Manifest.lock */,
|
||||
9740EEB61CF901F6004384FC /* Run Script */,
|
||||
97C146EA1CF9000F007C117D /* Sources */,
|
||||
97C146EB1CF9000F007C117D /* Frameworks */,
|
||||
97C146EC1CF9000F007C117D /* Resources */,
|
||||
9705A1C41CF9048500538489 /* Embed Frameworks */,
|
||||
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
|
||||
BA5C6C2059F783B8F3A1D718 /* [CP] Embed Pods Frameworks */,
|
||||
2E75A410B195E117A49D1E82 /* [CP] Copy Pods Resources */,
|
||||
1F77EE1FF4C528197971DB94 /* [CP] Embed Pods Frameworks */,
|
||||
BEFF80007E7E4E2B2694658C /* [CP] Copy Pods Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@ -180,21 +167,19 @@
|
||||
97C146E61CF9000F007C117D /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0910;
|
||||
ORGANIZATIONNAME = "The Chromium Authors";
|
||||
LastUpgradeCheck = 1020;
|
||||
ORGANIZATIONNAME = "";
|
||||
TargetAttributes = {
|
||||
97C146ED1CF9000F007C117D = {
|
||||
CreatedOnToolsVersion = 7.3.1;
|
||||
DevelopmentTeam = 78W43A3TE2;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
compatibilityVersion = "Xcode 9.3";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
English,
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
@ -215,7 +200,6 @@
|
||||
files = (
|
||||
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
|
||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
|
||||
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
|
||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
|
||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
|
||||
);
|
||||
@ -224,22 +208,21 @@
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
2E75A410B195E117A49D1E82 /* [CP] Copy Pods Resources */ = {
|
||||
1F77EE1FF4C528197971DB94 /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh",
|
||||
"${PODS_ROOT}/Weibo_SDK/libWeiboSDK/WeiboSDK.bundle",
|
||||
inputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
|
||||
);
|
||||
name = "[CP] Copy Pods Resources";
|
||||
outputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/WeiboSDK.bundle",
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
|
||||
@ -254,18 +237,22 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
|
||||
};
|
||||
5E40D85FABB1650818BB4959 /* [CP] Check Pods Manifest.lock */ = {
|
||||
631D2F29201BBC63DC66AD43 /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
|
||||
"${PODS_ROOT}/Manifest.lock",
|
||||
);
|
||||
name = "[CP] Check Pods Manifest.lock";
|
||||
outputFileListPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
|
||||
);
|
||||
@ -288,22 +275,21 @@
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
|
||||
};
|
||||
BA5C6C2059F783B8F3A1D718 /* [CP] Embed Pods Frameworks */ = {
|
||||
BEFF80007E7E4E2B2694658C /* [CP] Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
|
||||
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
|
||||
inputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
|
||||
name = "[CP] Copy Pods Resources";
|
||||
outputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
@ -355,12 +341,14 @@
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
@ -384,6 +372,7 @@
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
@ -395,7 +384,6 @@
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
DEVELOPMENT_TEAM = 78W43A3TE2;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@ -403,12 +391,15 @@
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.github.v7lin.fakeWeiboExample;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.github.v7lin.weiboKitExample;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
};
|
||||
@ -428,12 +419,14 @@
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
@ -482,12 +475,14 @@
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
@ -511,6 +506,7 @@
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
@ -522,7 +518,6 @@
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
DEVELOPMENT_TEAM = 78W43A3TE2;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@ -530,12 +525,15 @@
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.github.v7lin.fakeWeiboExample;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.github.v7lin.weiboKitExample;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
};
|
||||
@ -547,7 +545,6 @@
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
DEVELOPMENT_TEAM = 78W43A3TE2;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@ -555,12 +552,15 @@
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.github.v7lin.fakeWeiboExample;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.github.v7lin.weiboKitExample;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0910"
|
||||
LastUpgradeVersion = "1020"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@ -26,7 +26,6 @@
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
@ -46,7 +45,6 @@
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "AppDelegate.h"
|
||||
#include "GeneratedPluginRegistrant.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "GeneratedPluginRegistrant.h"
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
@ -3,7 +3,7 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
@ -11,7 +11,7 @@
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>fake_weibo_example</string>
|
||||
<string>weibo_kit_example</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
@ -24,10 +24,13 @@
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>com.weibo</string>
|
||||
<string>weibo</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>wb3393861383</string>
|
||||
<string>your</string>
|
||||
<string>weibo</string>
|
||||
<string>app</string>
|
||||
<string>key</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
@ -48,6 +51,17 @@
|
||||
<true/>
|
||||
<key>NSExceptionDomains</key>
|
||||
<dict>
|
||||
<key>sina.cn</key>
|
||||
<dict>
|
||||
<key>NSExceptionMinimumTLSVersion</key>
|
||||
<string>TLSv1.0</string>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>sina.com.cn</key>
|
||||
<dict>
|
||||
<key>NSExceptionMinimumTLSVersion</key>
|
||||
@ -59,6 +73,50 @@
|
||||
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>sinaimg.cn</key>
|
||||
<dict>
|
||||
<key>NSExceptionMinimumTLSVersion</key>
|
||||
<string>TLSv1.0</string>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>sinajs.cn</key>
|
||||
<dict>
|
||||
<key>NSExceptionMinimumTLSVersion</key>
|
||||
<string>TLSv1.0</string>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>weibo.cn</key>
|
||||
<dict>
|
||||
<key>NSExceptionMinimumTLSVersion</key>
|
||||
<string>TLSv1.0</string>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>weibo.com</key>
|
||||
<dict>
|
||||
<key>NSExceptionMinimumTLSVersion</key>
|
||||
<string>TLSv1.0</string>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
|
@ -1,9 +1,14 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:fake_weibo/fake_weibo.dart';
|
||||
import 'package:image/image.dart' as image;
|
||||
import 'package:okhttp_kit/okhttp_kit.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:path_provider/path_provider.dart' as path_provider;
|
||||
import 'package:weibo_kit/weibo_kit.dart';
|
||||
|
||||
void main() {
|
||||
runZoned(() {
|
||||
@ -37,7 +42,7 @@ class Home extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _HomeState extends State<Home> {
|
||||
static const String _WEIBO_APP_KEY = '3393861383';
|
||||
static const String _WEIBO_APP_KEY = 'your weibo app key';
|
||||
static const List<String> _WEIBO_SCOPE = <String>[
|
||||
WeiboScope.ALL,
|
||||
];
|
||||
@ -86,14 +91,14 @@ class _HomeState extends State<Home> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Fake Weibo Demo'),
|
||||
title: const Text('Weibo Kit Demo'),
|
||||
),
|
||||
body: ListView(
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
title: const Text('环境检查'),
|
||||
onTap: () async {
|
||||
String content = 'weibo: ${await _weibo.isWeiboInstalled()}';
|
||||
String content = 'weibo: ${await _weibo.isInstalled()}';
|
||||
_showTips('环境检查', content);
|
||||
},
|
||||
),
|
||||
@ -138,30 +143,70 @@ class _HomeState extends State<Home> {
|
||||
ListTile(
|
||||
title: const Text('图片分享'),
|
||||
onTap: () async {
|
||||
AssetImage image = const AssetImage('images/icon/timg.jpeg');
|
||||
AssetBundleImageKey key =
|
||||
await image.obtainKey(createLocalImageConfiguration(context));
|
||||
ByteData imageData = await key.bundle.load(key.name);
|
||||
await _weibo.shareImage(
|
||||
text: 'Share Text',
|
||||
imageData: imageData.buffer.asUint8List(),
|
||||
);
|
||||
OkHttpClient client = OkHttpClientBuilder().build();
|
||||
Response resp = await client
|
||||
.newCall(RequestBuilder()
|
||||
.get()
|
||||
.url(HttpUrl.parse(
|
||||
'https://www.baidu.com/img/bd_logo1.png?where=super'))
|
||||
.build())
|
||||
.enqueue();
|
||||
if (resp.isSuccessful()) {
|
||||
Directory saveDir = Platform.isAndroid
|
||||
? await path_provider.getExternalStorageDirectory()
|
||||
: await path_provider.getApplicationDocumentsDirectory();
|
||||
File saveFile = File(path.join(saveDir.path, 'timg.png'));
|
||||
if (!saveFile.existsSync()) {
|
||||
saveFile.createSync(recursive: true);
|
||||
saveFile.writeAsBytesSync(
|
||||
await resp.body().bytes(),
|
||||
flush: true,
|
||||
);
|
||||
}
|
||||
await _weibo.shareImage(
|
||||
text: 'Share Text',
|
||||
imageUri: Uri.file(saveFile.path),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('网页分享'),
|
||||
onTap: () async {
|
||||
AssetImage image =
|
||||
const AssetImage('images/icon/ic_launcher.png');
|
||||
AssetBundleImageKey key =
|
||||
await image.obtainKey(createLocalImageConfiguration(context));
|
||||
ByteData thumbData = await key.bundle.load(key.name);
|
||||
await _weibo.shareWebpage(
|
||||
title: 'title',
|
||||
description: 'share webpage',
|
||||
thumbData: thumbData.buffer.asUint8List(),
|
||||
webpageUrl: 'https://www.baidu.com',
|
||||
);
|
||||
OkHttpClient client = OkHttpClientBuilder().build();
|
||||
Response resp = await client
|
||||
.newCall(RequestBuilder()
|
||||
.get()
|
||||
.url(HttpUrl.parse(
|
||||
'https://www.baidu.com/img/bd_logo1.png?where=super'))
|
||||
.build())
|
||||
.enqueue();
|
||||
if (resp.isSuccessful()) {
|
||||
Directory saveDir = Platform.isAndroid
|
||||
? await path_provider.getExternalStorageDirectory()
|
||||
: await path_provider.getApplicationDocumentsDirectory();
|
||||
File saveFile = File(path.join(saveDir.path, 'timg.png'));
|
||||
if (!saveFile.existsSync()) {
|
||||
saveFile.createSync(recursive: true);
|
||||
saveFile.writeAsBytesSync(
|
||||
await resp.body().bytes(),
|
||||
flush: true,
|
||||
);
|
||||
}
|
||||
image.Image thumbnail =
|
||||
image.decodePng(saveFile.readAsBytesSync());
|
||||
Uint8List thumbData = thumbnail.getBytes();
|
||||
if (thumbData.length > 32 * 1024) {
|
||||
thumbData = Uint8List.fromList(image.encodeJpg(thumbnail,
|
||||
quality: 100 * 32 * 1024 ~/ thumbData.length));
|
||||
}
|
||||
await _weibo.shareWebpage(
|
||||
title: 'title',
|
||||
description: 'share webpage',
|
||||
thumbData: thumbData.buffer.asUint8List(),
|
||||
webpageUrl: 'https://www.baidu.com',
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
@ -170,7 +215,7 @@ class _HomeState extends State<Home> {
|
||||
}
|
||||
|
||||
void _showTips(String title, String content) {
|
||||
showDialog(
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
|
287
example/pubspec.lock
Normal file
287
example/pubspec.lock
Normal file
@ -0,0 +1,287 @@
|
||||
# Generated by pub
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
archive:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: archive
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.0.13"
|
||||
args:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: args
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.6.0"
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: async
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.4.1"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: boolean_selector
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: charcode
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.3"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.14.12"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: convert
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: cupertino_icons
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.1.3"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "5.2.0"
|
||||
fixnum:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fixnum
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.10.11"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
image:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.1.12"
|
||||
intl:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: intl
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.16.1"
|
||||
json_annotation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: json_annotation
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.12.6"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.8"
|
||||
okhttp_kit:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: okhttp_kit
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
path:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: path
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.6.4"
|
||||
path_provider:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: path_provider
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.6.11"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_linux
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.0.1+1"
|
||||
path_provider_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_macos
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.0.4+3"
|
||||
path_provider_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_platform_interface
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: petitparser
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.4.0"
|
||||
platform:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: platform
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.2.1"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: plugin_platform_interface
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
process:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: process
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.0.13"
|
||||
quiver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: quiver
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.1.3"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.99"
|
||||
source_span:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_span
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stack_trace
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.9.3"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_channel
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
string_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: string_scanner
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.2.15"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.6"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_math
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.0.8"
|
||||
weibo_kit:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "1.0.0"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xdg_directories
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.1.0"
|
||||
xml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xml
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.6.1"
|
||||
sdks:
|
||||
dart: ">=2.7.0 <3.0.0"
|
||||
flutter: ">=1.12.13+hotfix.5 <2.0.0"
|
@ -1,29 +1,40 @@
|
||||
name: fake_weibo_example
|
||||
description: Demonstrates how to use the fake_weibo plugin.
|
||||
publish_to: 'none'
|
||||
name: weibo_kit_example
|
||||
description: Demonstrates how to use the weibo_kit plugin.
|
||||
version: 1.0.0+1000
|
||||
# The following line prevents the package from being accidentally published to
|
||||
# pub.dev using `pub publish`. This is preferred for private packages.
|
||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
|
||||
environment:
|
||||
sdk: ">=2.1.0 <3.0.0"
|
||||
sdk: ">=2.7.0 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
weibo_kit:
|
||||
# When depending on this package from a real application you should use:
|
||||
# weibo_kit: ^x.y.z
|
||||
# See https://dart.dev/tools/pub/dependencies#version-constraints
|
||||
# The example app is bundled with the plugin so we use a path dependency on
|
||||
# the parent directory to use the current plugin's version.
|
||||
path: ../
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^0.1.2
|
||||
cupertino_icons: ^0.1.3
|
||||
|
||||
fake_weibo:
|
||||
path: ../
|
||||
path: ^1.6.4
|
||||
path_provider: ^1.4.0
|
||||
|
||||
okhttp_kit: ^1.0.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
pedantic: '>=1.4.0 <3.0.0'
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://www.dartlang.org/tools/pub/pubspec
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
||||
# The following section is specific to Flutter.
|
||||
flutter:
|
||||
@ -34,15 +45,15 @@ flutter:
|
||||
uses-material-design: true
|
||||
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
assets:
|
||||
- images/icon/timg.jpeg
|
||||
- images/icon/ic_launcher.png
|
||||
# assets:
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.io/assets-and-images/#resolution-aware.
|
||||
# https://flutter.dev/assets-and-images/#resolution-aware.
|
||||
|
||||
# For details regarding adding assets from package dependencies, see
|
||||
# https://flutter.io/assets-and-images/#from-packages
|
||||
# https://flutter.dev/assets-and-images/#from-packages
|
||||
|
||||
# To add custom fonts to your application, add a fonts section here,
|
||||
# in this "flutter" section. Each entry in this list should have a
|
||||
@ -62,4 +73,4 @@ flutter:
|
||||
# weight: 700
|
||||
#
|
||||
# For details regarding fonts from package dependencies,
|
||||
# see https://flutter.io/custom-fonts/#from-packages
|
||||
# see https://flutter.dev/custom-fonts/#from-packages
|
||||
|
1
ios/.gitignore
vendored
1
ios/.gitignore
vendored
@ -34,3 +34,4 @@ Icon?
|
||||
.tags*
|
||||
|
||||
/Flutter/Generated.xcconfig
|
||||
/Flutter/flutter_export_environment.sh
|
@ -1,4 +0,0 @@
|
||||
#import <Flutter/Flutter.h>
|
||||
|
||||
@interface FakeWeiboPlugin : NSObject<FlutterPlugin>
|
||||
@end
|
4
ios/Classes/WeiboKitPlugin.h
Normal file
4
ios/Classes/WeiboKitPlugin.h
Normal file
@ -0,0 +1,4 @@
|
||||
#import <Flutter/Flutter.h>
|
||||
|
||||
@interface WeiboKitPlugin : NSObject <FlutterPlugin>
|
||||
@end
|
@ -1,25 +1,25 @@
|
||||
#import "FakeWeiboPlugin.h"
|
||||
#import "WeiboKitPlugin.h"
|
||||
#import <Weibo_SDK/WeiboSDK.h>
|
||||
|
||||
@interface FakeWeiboPlugin () <WeiboSDKDelegate>
|
||||
@interface WeiboKitPlugin () <WeiboSDKDelegate>
|
||||
|
||||
@end
|
||||
|
||||
@implementation FakeWeiboPlugin {
|
||||
@implementation WeiboKitPlugin {
|
||||
FlutterMethodChannel * _channel;
|
||||
}
|
||||
|
||||
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
|
||||
FlutterMethodChannel* channel = [FlutterMethodChannel
|
||||
methodChannelWithName:@"v7lin.github.io/fake_weibo"
|
||||
binaryMessenger:[registrar messenger]];
|
||||
FakeWeiboPlugin* instance = [[FakeWeiboPlugin alloc] initWithChannel:channel];
|
||||
[registrar addApplicationDelegate:instance];
|
||||
[registrar addMethodCallDelegate:instance channel:channel];
|
||||
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
|
||||
FlutterMethodChannel *channel =
|
||||
[FlutterMethodChannel methodChannelWithName:@"v7lin.github.io/weibo_kit"
|
||||
binaryMessenger:[registrar messenger]];
|
||||
WeiboKitPlugin *instance = [[WeiboKitPlugin alloc] initWithChannel:channel];
|
||||
[registrar addApplicationDelegate:instance];
|
||||
[registrar addMethodCallDelegate:instance channel:channel];
|
||||
}
|
||||
|
||||
static NSString * const METHOD_REGISTERAPP = @"registerApp";
|
||||
static NSString * const METHOD_ISWEIBOINSTALLED = @"isWeiboInstalled";
|
||||
static NSString * const METHOD_ISINSTALLED = @"isInstalled";
|
||||
static NSString * const METHOD_AUTH = @"auth";
|
||||
static NSString * const METHOD_SHARETEXT = @"shareText";
|
||||
static NSString * const METHOD_SHAREIMAGE = @"shareImage";
|
||||
@ -54,23 +54,24 @@ static NSString * const ARGUMENT_KEY_RESULT_EXPIRESIN = @"expiresIn";
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
|
||||
if ([METHOD_REGISTERAPP isEqualToString:call.method]) {
|
||||
NSString * appKey = call.arguments[ARGUMENT_KEY_APPKEY];
|
||||
[WeiboSDK registerApp:appKey];
|
||||
result(nil);
|
||||
} else if ([METHOD_ISWEIBOINSTALLED isEqualToString:call.method]) {
|
||||
result([NSNumber numberWithBool:[WeiboSDK isWeiboAppInstalled]]);
|
||||
} else if ([METHOD_AUTH isEqualToString:call.method]) {
|
||||
[self handleAuthCall:call result:result];
|
||||
} else if ([METHOD_SHARETEXT isEqualToString:call.method]) {
|
||||
[self handleShareTextCall:call result:result];
|
||||
} else if ([METHOD_SHAREIMAGE isEqualToString:call.method] ||
|
||||
[METHOD_SHAREWEBPAGE isEqualToString:call.method]) {
|
||||
[self handleShareMediaCall:call result:result];
|
||||
} else {
|
||||
result(FlutterMethodNotImplemented);
|
||||
}
|
||||
- (void)handleMethodCall:(FlutterMethodCall *)call
|
||||
result:(FlutterResult)result {
|
||||
if ([METHOD_REGISTERAPP isEqualToString:call.method]) {
|
||||
NSString * appKey = call.arguments[ARGUMENT_KEY_APPKEY];
|
||||
[WeiboSDK registerApp:appKey];
|
||||
result(nil);
|
||||
} else if ([METHOD_ISINSTALLED isEqualToString:call.method]) {
|
||||
result([NSNumber numberWithBool:[WeiboSDK isWeiboAppInstalled]]);
|
||||
} else if ([METHOD_AUTH isEqualToString:call.method]) {
|
||||
[self handleAuthCall:call result:result];
|
||||
} else if ([METHOD_SHARETEXT isEqualToString:call.method]) {
|
||||
[self handleShareTextCall:call result:result];
|
||||
} else if ([METHOD_SHAREIMAGE isEqualToString:call.method] ||
|
||||
[METHOD_SHAREWEBPAGE isEqualToString:call.method]) {
|
||||
[self handleShareMediaCall:call result:result];
|
||||
} else {
|
||||
result(FlutterMethodNotImplemented);
|
||||
}
|
||||
}
|
||||
|
||||
-(void)handleAuthCall:(FlutterMethodCall*)call result:(FlutterResult)result {
|
@ -1,24 +0,0 @@
|
||||
#
|
||||
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
|
||||
#
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'fake_weibo'
|
||||
s.version = '0.0.1'
|
||||
s.summary = 'A new Flutter plugin.'
|
||||
s.description = <<-DESC
|
||||
A new Flutter plugin.
|
||||
DESC
|
||||
s.homepage = 'http://example.com'
|
||||
s.license = { :file => '../LICENSE' }
|
||||
s.author = { 'Your Company' => 'email@example.com' }
|
||||
s.source = { :path => '.' }
|
||||
s.source_files = 'Classes/**/*'
|
||||
s.public_header_files = 'Classes/**/*.h'
|
||||
s.dependency 'Flutter'
|
||||
# 微博
|
||||
s.static_framework = true
|
||||
s.dependency 'Weibo_SDK', '~> 3.2.5.1'
|
||||
|
||||
s.ios.deployment_target = '9.0'
|
||||
end
|
||||
|
28
ios/weibo_kit.podspec
Normal file
28
ios/weibo_kit.podspec
Normal file
@ -0,0 +1,28 @@
|
||||
#
|
||||
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
|
||||
# Run `pod lib lint weibo_kit.podspec' to validate before publishing.
|
||||
#
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'weibo_kit'
|
||||
s.version = '1.0.0'
|
||||
s.summary = 'A powerful weibo plugin for Flutter.'
|
||||
s.description = <<-DESC
|
||||
A powerful weibo plugin for Flutter.
|
||||
DESC
|
||||
s.homepage = 'http://example.com'
|
||||
s.license = { :file => '../LICENSE' }
|
||||
s.author = { 'Your Company' => 'email@example.com' }
|
||||
s.source = { :path => '.' }
|
||||
s.source_files = 'Classes/**/*'
|
||||
s.public_header_files = 'Classes/**/*.h'
|
||||
s.dependency 'Flutter'
|
||||
s.platform = :ios, '9.0'
|
||||
|
||||
s.static_framework = true
|
||||
s.subspec 'vendor' do |sp|
|
||||
sp.dependency 'Weibo_SDK', '~> 3.2.7'
|
||||
end
|
||||
|
||||
# Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported.
|
||||
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
|
||||
end
|
@ -1,9 +0,0 @@
|
||||
library fake_weibo;
|
||||
|
||||
export 'src/domain/api/weibo_api_resp.dart';
|
||||
export 'src/domain/api/weibo_user_info_resp.dart'
|
||||
hide WeiboUserInfoRespSerializer;
|
||||
export 'src/domain/sdk/weibo_auth_resp.dart' hide WeiboAuthRespSerializer;
|
||||
export 'src/domain/sdk/weibo_sdk_resp.dart' hide WeiboSdkRespSerializer;
|
||||
export 'src/weibo.dart';
|
||||
export 'src/weibo_scope.dart';
|
@ -1,54 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'weibo_user_info_resp.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarSerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$WeiboUserInfoRespSerializer
|
||||
implements Serializer<WeiboUserInfoResp> {
|
||||
@override
|
||||
Map<String, dynamic> toMap(WeiboUserInfoResp model) {
|
||||
if (model == null) return null;
|
||||
Map<String, dynamic> ret = <String, dynamic>{};
|
||||
setMapValue(ret, 'id', model.id);
|
||||
setMapValue(ret, 'idstr', model.idstr);
|
||||
setMapValue(ret, 'screen_name', model.screenName);
|
||||
setMapValue(ret, 'name', model.name);
|
||||
setMapValue(ret, 'location', model.location);
|
||||
setMapValue(ret, 'description', model.description);
|
||||
setMapValue(ret, 'profile_image_url', model.profileImageUrl);
|
||||
setMapValue(ret, 'gender', model.gender);
|
||||
setMapValue(ret, 'avatar_large', model.avatarLarge);
|
||||
setMapValue(ret, 'avatar_hd', model.avatarHd);
|
||||
setMapValue(ret, 'error_code', model.errorCode);
|
||||
setMapValue(ret, 'error', model.error);
|
||||
setMapValue(ret, 'request', model.request);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@override
|
||||
WeiboUserInfoResp fromMap(Map map) {
|
||||
if (map == null) return null;
|
||||
final obj = new WeiboUserInfoResp(
|
||||
errorCode: map['error_code'] as int ?? getJserDefault('errorCode'),
|
||||
error: map['error'] as String ?? getJserDefault('error'),
|
||||
request: map['request'] as String ?? getJserDefault('request'),
|
||||
id: map['id'] as int ?? getJserDefault('id'),
|
||||
idstr: map['idstr'] as String ?? getJserDefault('idstr'),
|
||||
screenName:
|
||||
map['screen_name'] as String ?? getJserDefault('screenName'),
|
||||
name: map['name'] as String ?? getJserDefault('name'),
|
||||
location: map['location'] as String ?? getJserDefault('location'),
|
||||
description:
|
||||
map['description'] as String ?? getJserDefault('description'),
|
||||
profileImageUrl: map['profile_image_url'] as String ??
|
||||
getJserDefault('profileImageUrl'),
|
||||
gender: map['gender'] as String ?? getJserDefault('gender'),
|
||||
avatarLarge:
|
||||
map['avatar_large'] as String ?? getJserDefault('avatarLarge'),
|
||||
avatarHd: map['avatar_hd'] as String ?? getJserDefault('avatarHd'));
|
||||
return obj;
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
import 'package:fake_weibo/src/domain/sdk/weibo_sdk_resp.dart';
|
||||
|
||||
part 'weibo_auth_resp.jser.dart';
|
||||
|
||||
@GenSerializer()
|
||||
class WeiboAuthRespSerializer extends Serializer<WeiboAuthResp>
|
||||
with _$WeiboAuthRespSerializer {}
|
||||
|
||||
class WeiboAuthResp extends WeiboSdkResp {
|
||||
WeiboAuthResp({
|
||||
int errorCode,
|
||||
String errorMessage,
|
||||
this.userId,
|
||||
this.accessToken,
|
||||
this.refreshToken,
|
||||
this.expiresIn,
|
||||
}) : super(errorCode: errorCode, errorMessage: errorMessage);
|
||||
|
||||
final String userId;
|
||||
final String accessToken;
|
||||
final String refreshToken;
|
||||
final int expiresIn;
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'weibo_auth_resp.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarSerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$WeiboAuthRespSerializer implements Serializer<WeiboAuthResp> {
|
||||
@override
|
||||
Map<String, dynamic> toMap(WeiboAuthResp model) {
|
||||
if (model == null) return null;
|
||||
Map<String, dynamic> ret = <String, dynamic>{};
|
||||
setMapValue(ret, 'userId', model.userId);
|
||||
setMapValue(ret, 'accessToken', model.accessToken);
|
||||
setMapValue(ret, 'refreshToken', model.refreshToken);
|
||||
setMapValue(ret, 'expiresIn', model.expiresIn);
|
||||
setMapValue(ret, 'errorCode', model.errorCode);
|
||||
setMapValue(ret, 'errorMessage', model.errorMessage);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@override
|
||||
WeiboAuthResp fromMap(Map map) {
|
||||
if (map == null) return null;
|
||||
final obj = new WeiboAuthResp(
|
||||
errorCode: map['errorCode'] as int ?? getJserDefault('errorCode'),
|
||||
errorMessage:
|
||||
map['errorMessage'] as String ?? getJserDefault('errorMessage'),
|
||||
userId: map['userId'] as String ?? getJserDefault('userId'),
|
||||
accessToken:
|
||||
map['accessToken'] as String ?? getJserDefault('accessToken'),
|
||||
refreshToken:
|
||||
map['refreshToken'] as String ?? getJserDefault('refreshToken'),
|
||||
expiresIn: map['expiresIn'] as int ?? getJserDefault('expiresIn'));
|
||||
return obj;
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'weibo_sdk_resp.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarSerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$WeiboSdkRespSerializer implements Serializer<WeiboSdkResp> {
|
||||
@override
|
||||
Map<String, dynamic> toMap(WeiboSdkResp model) {
|
||||
if (model == null) return null;
|
||||
Map<String, dynamic> ret = <String, dynamic>{};
|
||||
setMapValue(ret, 'errorCode', model.errorCode);
|
||||
setMapValue(ret, 'errorMessage', model.errorMessage);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@override
|
||||
WeiboSdkResp fromMap(Map map) {
|
||||
if (map == null) return null;
|
||||
final obj = new WeiboSdkResp(
|
||||
errorCode: map['errorCode'] as int ?? getJserDefault('errorCode'),
|
||||
errorMessage:
|
||||
map['errorMessage'] as String ?? getJserDefault('errorMessage'));
|
||||
return obj;
|
||||
}
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
import 'package:fake_weibo/src/domain/api/weibo_api_resp.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:weibo_kit/src/model/api/weibo_api_resp.dart';
|
||||
|
||||
part 'weibo_user_info_resp.jser.dart';
|
||||
|
||||
@GenSerializer(nameFormatter: toSnakeCase)
|
||||
class WeiboUserInfoRespSerializer extends Serializer<WeiboUserInfoResp>
|
||||
with _$WeiboUserInfoRespSerializer {}
|
||||
part 'weibo_user_info_resp.g.dart';
|
||||
|
||||
@JsonSerializable(
|
||||
anyMap: true,
|
||||
explicitToJson: true,
|
||||
fieldRename: FieldRename.snake,
|
||||
)
|
||||
class WeiboUserInfoResp extends WeiboApiResp {
|
||||
WeiboUserInfoResp({
|
||||
int errorCode,
|
||||
@ -24,6 +25,9 @@ class WeiboUserInfoResp extends WeiboApiResp {
|
||||
this.avatarHd,
|
||||
}) : super(errorCode: errorCode, error: error, request: request);
|
||||
|
||||
factory WeiboUserInfoResp.fromJson(Map<dynamic, dynamic> json) =>
|
||||
_$WeiboUserInfoRespFromJson(json);
|
||||
|
||||
/// 用户UID(int64)
|
||||
final int id;
|
||||
|
||||
@ -61,4 +65,6 @@ class WeiboUserInfoResp extends WeiboApiResp {
|
||||
bool isFemale() {
|
||||
return gender == 'f';
|
||||
}
|
||||
|
||||
Map<dynamic, dynamic> toJson() => _$WeiboUserInfoRespToJson(this);
|
||||
}
|
42
lib/src/model/api/weibo_user_info_resp.g.dart
Normal file
42
lib/src/model/api/weibo_user_info_resp.g.dart
Normal file
@ -0,0 +1,42 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'weibo_user_info_resp.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
WeiboUserInfoResp _$WeiboUserInfoRespFromJson(Map json) {
|
||||
return WeiboUserInfoResp(
|
||||
errorCode: json['error_code'] as int,
|
||||
error: json['error'] as String,
|
||||
request: json['request'] as String,
|
||||
id: json['id'] as int,
|
||||
idstr: json['idstr'] as String,
|
||||
screenName: json['screen_name'] as String,
|
||||
name: json['name'] as String,
|
||||
location: json['location'] as String,
|
||||
description: json['description'] as String,
|
||||
profileImageUrl: json['profile_image_url'] as String,
|
||||
gender: json['gender'] as String,
|
||||
avatarLarge: json['avatar_large'] as String,
|
||||
avatarHd: json['avatar_hd'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$WeiboUserInfoRespToJson(WeiboUserInfoResp instance) =>
|
||||
<String, dynamic>{
|
||||
'error_code': instance.errorCode,
|
||||
'error': instance.error,
|
||||
'request': instance.request,
|
||||
'id': instance.id,
|
||||
'idstr': instance.idstr,
|
||||
'screen_name': instance.screenName,
|
||||
'name': instance.name,
|
||||
'location': instance.location,
|
||||
'description': instance.description,
|
||||
'profile_image_url': instance.profileImageUrl,
|
||||
'gender': instance.gender,
|
||||
'avatar_large': instance.avatarLarge,
|
||||
'avatar_hd': instance.avatarHd,
|
||||
};
|
30
lib/src/model/sdk/weibo_auth_resp.dart
Normal file
30
lib/src/model/sdk/weibo_auth_resp.dart
Normal file
@ -0,0 +1,30 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:weibo_kit/src/model/sdk/weibo_sdk_resp.dart';
|
||||
|
||||
part 'weibo_auth_resp.g.dart';
|
||||
|
||||
@JsonSerializable(
|
||||
anyMap: true,
|
||||
explicitToJson: true,
|
||||
)
|
||||
class WeiboAuthResp extends WeiboSdkResp {
|
||||
WeiboAuthResp({
|
||||
int errorCode,
|
||||
String errorMessage,
|
||||
this.userId,
|
||||
this.accessToken,
|
||||
this.refreshToken,
|
||||
this.expiresIn,
|
||||
}) : super(errorCode: errorCode, errorMessage: errorMessage);
|
||||
|
||||
factory WeiboAuthResp.fromJson(Map<dynamic, dynamic> json) =>
|
||||
_$WeiboAuthRespFromJson(json);
|
||||
|
||||
final String userId;
|
||||
final String accessToken;
|
||||
final String refreshToken;
|
||||
final int expiresIn;
|
||||
|
||||
@override
|
||||
Map<dynamic, dynamic> toJson() => _$WeiboAuthRespToJson(this);
|
||||
}
|
28
lib/src/model/sdk/weibo_auth_resp.g.dart
Normal file
28
lib/src/model/sdk/weibo_auth_resp.g.dart
Normal file
@ -0,0 +1,28 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'weibo_auth_resp.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
WeiboAuthResp _$WeiboAuthRespFromJson(Map json) {
|
||||
return WeiboAuthResp(
|
||||
errorCode: json['errorCode'] as int,
|
||||
errorMessage: json['errorMessage'] as String,
|
||||
userId: json['userId'] as String,
|
||||
accessToken: json['accessToken'] as String,
|
||||
refreshToken: json['refreshToken'] as String,
|
||||
expiresIn: json['expiresIn'] as int,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$WeiboAuthRespToJson(WeiboAuthResp instance) =>
|
||||
<String, dynamic>{
|
||||
'errorCode': instance.errorCode,
|
||||
'errorMessage': instance.errorMessage,
|
||||
'userId': instance.userId,
|
||||
'accessToken': instance.accessToken,
|
||||
'refreshToken': instance.refreshToken,
|
||||
'expiresIn': instance.expiresIn,
|
||||
};
|
@ -1,17 +1,20 @@
|
||||
import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'weibo_sdk_resp.jser.dart';
|
||||
|
||||
@GenSerializer()
|
||||
class WeiboSdkRespSerializer extends Serializer<WeiboSdkResp>
|
||||
with _$WeiboSdkRespSerializer {}
|
||||
part 'weibo_sdk_resp.g.dart';
|
||||
|
||||
@JsonSerializable(
|
||||
anyMap: true,
|
||||
explicitToJson: true,
|
||||
)
|
||||
class WeiboSdkResp {
|
||||
WeiboSdkResp({
|
||||
int errorCode,
|
||||
this.errorMessage,
|
||||
}) : errorCode = errorCode ?? SUCCESS;
|
||||
|
||||
factory WeiboSdkResp.fromJson(Map<dynamic, dynamic> json) =>
|
||||
_$WeiboSdkRespFromJson(json);
|
||||
|
||||
/// 成功
|
||||
static const int SUCCESS = 0;
|
||||
|
||||
@ -39,9 +42,8 @@ class WeiboSdkResp {
|
||||
/// 未知
|
||||
static const int UNKNOWN = -100;
|
||||
|
||||
/// sso package or sign error
|
||||
static const int SSO_PKG_SIGN_ERROR = 21338;
|
||||
|
||||
final int errorCode;
|
||||
final String errorMessage;
|
||||
|
||||
Map<dynamic, dynamic> toJson() => _$WeiboSdkRespToJson(this);
|
||||
}
|
20
lib/src/model/sdk/weibo_sdk_resp.g.dart
Normal file
20
lib/src/model/sdk/weibo_sdk_resp.g.dart
Normal file
@ -0,0 +1,20 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'weibo_sdk_resp.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
WeiboSdkResp _$WeiboSdkRespFromJson(Map json) {
|
||||
return WeiboSdkResp(
|
||||
errorCode: json['errorCode'] as int,
|
||||
errorMessage: json['errorMessage'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$WeiboSdkRespToJson(WeiboSdkResp instance) =>
|
||||
<String, dynamic>{
|
||||
'errorCode': instance.errorCode,
|
||||
'errorMessage': instance.errorMessage,
|
||||
};
|
@ -3,11 +3,11 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:fake_weibo/src/domain/api/weibo_user_info_resp.dart';
|
||||
import 'package:fake_weibo/src/domain/sdk/weibo_auth_resp.dart';
|
||||
import 'package:fake_weibo/src/domain/sdk/weibo_sdk_resp.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:weibo_kit/src/model/api/weibo_user_info_resp.dart';
|
||||
import 'package:weibo_kit/src/model/sdk/weibo_auth_resp.dart';
|
||||
import 'package:weibo_kit/src/model/sdk/weibo_sdk_resp.dart';
|
||||
|
||||
class Weibo {
|
||||
Weibo() {
|
||||
@ -15,7 +15,7 @@ class Weibo {
|
||||
}
|
||||
|
||||
static const String _METHOD_REGISTERAPP = 'registerApp';
|
||||
static const String _METHOD_ISWEIBOINSTALLED = 'isWeiboInstalled';
|
||||
static const String _METHOD_ISINSTALLED = 'isInstalled';
|
||||
static const String _METHOD_AUTH = 'auth';
|
||||
static const String _METHOD_SHARETEXT = 'shareText';
|
||||
static const String _METHOD_SHAREIMAGE = 'shareImage';
|
||||
@ -41,7 +41,7 @@ class Weibo {
|
||||
'https://api.weibo.com/oauth2/default.html';
|
||||
|
||||
final MethodChannel _channel =
|
||||
const MethodChannel('v7lin.github.io/fake_weibo');
|
||||
const MethodChannel('v7lin.github.io/weibo_kit');
|
||||
|
||||
final StreamController<WeiboAuthResp> _authRespStreamController =
|
||||
StreamController<WeiboAuthResp>.broadcast();
|
||||
@ -57,7 +57,7 @@ class Weibo {
|
||||
}) {
|
||||
assert(appKey != null && appKey.isNotEmpty);
|
||||
assert(scope != null && scope.isNotEmpty);
|
||||
return _channel.invokeMethod(
|
||||
return _channel.invokeMethod<void>(
|
||||
_METHOD_REGISTERAPP,
|
||||
<String, dynamic>{
|
||||
_ARGUMENT_KEY_APPKEY: appKey,
|
||||
@ -70,12 +70,12 @@ class Weibo {
|
||||
Future<dynamic> _handleMethod(MethodCall call) async {
|
||||
switch (call.method) {
|
||||
case _METHOD_ONAUTHRESP:
|
||||
_authRespStreamController.add(WeiboAuthRespSerializer()
|
||||
.fromMap(call.arguments as Map<dynamic, dynamic>));
|
||||
_authRespStreamController.add(
|
||||
WeiboAuthResp.fromJson(call.arguments as Map<dynamic, dynamic>));
|
||||
break;
|
||||
case _METHOD_ONSHAREMSGRESP:
|
||||
_shareMsgRespStreamController.add(WeiboSdkRespSerializer()
|
||||
.fromMap(call.arguments as Map<dynamic, dynamic>));
|
||||
_shareMsgRespStreamController.add(
|
||||
WeiboSdkResp.fromJson(call.arguments as Map<dynamic, dynamic>));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -90,8 +90,8 @@ class Weibo {
|
||||
return _shareMsgRespStreamController.stream;
|
||||
}
|
||||
|
||||
Future<bool> isWeiboInstalled() async {
|
||||
return (await _channel.invokeMethod(_METHOD_ISWEIBOINSTALLED)) as bool;
|
||||
Future<bool> isInstalled() {
|
||||
return _channel.invokeMethod<bool>(_METHOD_ISINSTALLED);
|
||||
}
|
||||
|
||||
/// 登录
|
||||
@ -102,7 +102,7 @@ class Weibo {
|
||||
}) {
|
||||
assert(appKey != null && appKey.isNotEmpty);
|
||||
assert(scope != null && scope.isNotEmpty);
|
||||
return _channel.invokeMethod(
|
||||
return _channel.invokeMethod<void>(
|
||||
_METHOD_AUTH,
|
||||
<String, dynamic>{
|
||||
_ARGUMENT_KEY_APPKEY: appKey,
|
||||
@ -131,8 +131,8 @@ class Weibo {
|
||||
}).then((HttpClientResponse response) async {
|
||||
if (response.statusCode == HttpStatus.ok) {
|
||||
String content = await utf8.decodeStream(response);
|
||||
return WeiboUserInfoRespSerializer()
|
||||
.fromMap(json.decode(content) as Map<dynamic, dynamic>);
|
||||
return WeiboUserInfoResp.fromJson(
|
||||
json.decode(content) as Map<dynamic, dynamic>);
|
||||
}
|
||||
throw HttpException(
|
||||
'HttpResponse statusCode: ${response.statusCode}, reasonPhrase: ${response.reasonPhrase}.');
|
||||
@ -145,15 +145,15 @@ class Weibo {
|
||||
String accessToken,
|
||||
Map<String, String> params,
|
||||
) {
|
||||
params.putIfAbsent('source', () => appkey);
|
||||
params.putIfAbsent('access_token', () => accessToken);
|
||||
params['source'] = appkey;
|
||||
params['access_token'] = accessToken;
|
||||
Uri baseUri = Uri.parse(baseUrl);
|
||||
Map<String, List<String>> queryParametersAll =
|
||||
Map<String, List<String>>.of(baseUri.queryParametersAll);
|
||||
params.forEach((String key, String value) {
|
||||
queryParametersAll.remove(key);
|
||||
queryParametersAll.putIfAbsent(key, () => <String>[value]);
|
||||
});
|
||||
for (MapEntry<String, String> entry in params.entries) {
|
||||
queryParametersAll.remove(entry.key);
|
||||
queryParametersAll.putIfAbsent(entry.key, () => <String>[entry.value]);
|
||||
}
|
||||
return baseUri.replace(queryParameters: queryParametersAll);
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ class Weibo {
|
||||
@required String text,
|
||||
}) {
|
||||
assert(text != null && text.length <= 1024);
|
||||
return _channel.invokeMethod(
|
||||
return _channel.invokeMethod<void>(
|
||||
_METHOD_SHARETEXT,
|
||||
<String, dynamic>{
|
||||
_ARGUMENT_KEY_TEXT: text,
|
||||
@ -182,17 +182,14 @@ class Weibo {
|
||||
imageUri.isScheme(_SCHEME_FILE) &&
|
||||
imageUri.toFilePath().length <= 512 &&
|
||||
File.fromUri(imageUri).lengthSync() <= 10 * 1024 * 1024));
|
||||
Map<String, dynamic> map = <String, dynamic>{};
|
||||
if (text != null && text.isNotEmpty) {
|
||||
map.putIfAbsent(_ARGUMENT_KEY_TEXT, () => text);
|
||||
}
|
||||
if (imageData != null) {
|
||||
map.putIfAbsent(_ARGUMENT_KEY_IMAGEDATA, () => imageData);
|
||||
}
|
||||
if (imageUri != null) {
|
||||
map.putIfAbsent(_ARGUMENT_KEY_IMAGEURI, () => imageUri.toString());
|
||||
}
|
||||
return _channel.invokeMethod(_METHOD_SHAREIMAGE, map);
|
||||
return _channel.invokeMethod<void>(
|
||||
_METHOD_SHAREIMAGE,
|
||||
<String, dynamic>{
|
||||
if (text != null && text.isNotEmpty) _ARGUMENT_KEY_TEXT: text,
|
||||
if (imageData != null) _ARGUMENT_KEY_IMAGEDATA: imageData,
|
||||
if (imageUri != null) _ARGUMENT_KEY_IMAGEURI: imageUri.toString(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 分享 - 网页
|
||||
@ -210,7 +207,7 @@ class Weibo {
|
||||
assert(webpageUrl != null &&
|
||||
webpageUrl.isNotEmpty &&
|
||||
webpageUrl.length <= 255);
|
||||
return _channel.invokeMethod(
|
||||
return _channel.invokeMethod<void>(
|
||||
_METHOD_SHAREWEBPAGE,
|
||||
<String, dynamic>{
|
||||
_ARGUMENT_KEY_TITLE: title,
|
||||
|
8
lib/weibo_kit.dart
Normal file
8
lib/weibo_kit.dart
Normal file
@ -0,0 +1,8 @@
|
||||
library weibo_kit;
|
||||
|
||||
export 'src/model/api/weibo_api_resp.dart';
|
||||
export 'src/model/api/weibo_user_info_resp.dart';
|
||||
export 'src/model/sdk/weibo_auth_resp.dart';
|
||||
export 'src/model/sdk/weibo_sdk_resp.dart';
|
||||
export 'src/weibo.dart';
|
||||
export 'src/weibo_constant.dart';
|
546
pubspec.lock
Normal file
546
pubspec.lock
Normal file
@ -0,0 +1,546 @@
|
||||
# Generated by pub
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
_fe_analyzer_shared:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: _fe_analyzer_shared
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "4.0.0"
|
||||
analyzer:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: analyzer
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.39.10"
|
||||
archive:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: archive
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.0.13"
|
||||
args:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: args
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.6.0"
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: async
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.4.1"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: boolean_selector
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
build:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: build
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
build_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: build_config
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.4.2"
|
||||
build_daemon:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: build_daemon
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
build_resolvers:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: build_resolvers
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.3.9"
|
||||
build_runner:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: build_runner
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.10.0"
|
||||
build_runner_core:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: build_runner_core
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "5.2.0"
|
||||
built_collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: built_collection
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "4.3.2"
|
||||
built_value:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: built_value
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "7.1.0"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: charcode
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.3"
|
||||
checked_yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: checked_yaml
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
code_builder:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: code_builder
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.3.0"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.14.12"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: convert
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
csslib:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: csslib
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.16.1"
|
||||
dart_style:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: dart_style
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.3.6"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "5.2.0"
|
||||
fixnum:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fixnum
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.10.11"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
glob:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: glob
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
graphs:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: graphs
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
html:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: html
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.14.0+3"
|
||||
http_multi_server:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_multi_server
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
http_parser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_parser
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.1.4"
|
||||
image:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.1.12"
|
||||
intl:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: intl
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.16.1"
|
||||
io:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: io
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.3.4"
|
||||
js:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: js
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.6.2"
|
||||
json_annotation:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: json_annotation
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
json_serializable:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: json_serializable
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.3.0"
|
||||
logging:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: logging
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.11.4"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.12.6"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.8"
|
||||
mime:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: mime
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.9.6+3"
|
||||
node_interop:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: node_interop
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
node_io:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: node_io
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
okhttp_kit:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: okhttp_kit
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
package_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_config
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.9.3"
|
||||
path:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: path
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.6.4"
|
||||
path_provider:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: path_provider
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.6.11"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_linux
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.0.1+1"
|
||||
path_provider_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_macos
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.0.4+3"
|
||||
path_provider_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_platform_interface
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
pedantic:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: pedantic
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.9.0"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: petitparser
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.4.0"
|
||||
platform:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: platform
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.2.1"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: plugin_platform_interface
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
pool:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pool
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.4.0"
|
||||
process:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: process
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.0.13"
|
||||
pub_semver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pub_semver
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.4.4"
|
||||
pubspec_parse:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pubspec_parse
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.1.5"
|
||||
quiver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: quiver
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.1.3"
|
||||
shelf:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.7.5"
|
||||
shelf_web_socket:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf_web_socket
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.2.3"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.99"
|
||||
source_gen:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_gen
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.9.5"
|
||||
source_span:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_span
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stack_trace
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.9.3"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_channel
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
stream_transform:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_transform
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
string_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: string_scanner
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.2.15"
|
||||
timing:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: timing
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.1.1+2"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.6"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_math
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.0.8"
|
||||
watcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: watcher
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.9.7+15"
|
||||
web_socket_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: web_socket_channel
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xdg_directories
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.1.0"
|
||||
xml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xml
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.6.1"
|
||||
yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: yaml
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.2.1"
|
||||
sdks:
|
||||
dart: ">=2.7.0 <3.0.0"
|
||||
flutter: ">=1.12.13+hotfix.5 <2.0.0"
|
44
pubspec.yaml
44
pubspec.yaml
@ -1,52 +1,60 @@
|
||||
name: fake_weibo
|
||||
name: weibo_kit
|
||||
description: A powerful weibo plugin for Flutter.
|
||||
version: 0.2.4
|
||||
author: v7lin <v7lin@qq.com>
|
||||
version: 1.0.0
|
||||
# author: v7lin <v7lin@qq.com>
|
||||
homepage: https://github.com/v7lin/fake_weibo
|
||||
|
||||
environment:
|
||||
sdk: ">=2.1.0 <3.0.0"
|
||||
sdk: ">=2.7.0 <3.0.0"
|
||||
flutter: ">=1.10.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
meta: ^1.1.6
|
||||
|
||||
jaguar_serializer: ^2.2.12
|
||||
json_annotation: '>=2.0.0 <4.0.0'
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
pedantic: '>=1.4.0 <3.0.0'
|
||||
path: ^1.6.4
|
||||
path_provider: ^1.4.0
|
||||
|
||||
okhttp_kit: ^1.0.0
|
||||
|
||||
pedantic:
|
||||
|
||||
build_runner:
|
||||
jaguar_serializer_cli:
|
||||
json_serializable:
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://www.dartlang.org/tools/pub/pubspec
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
||||
# The following section is specific to Flutter.
|
||||
flutter:
|
||||
# This section identifies this Flutter project as a plugin project.
|
||||
# The androidPackage and pluginClass identifiers should not ordinarily
|
||||
# The 'pluginClass' and Android 'package' identifiers should not ordinarily
|
||||
# be modified. They are used by the tooling to maintain consistency when
|
||||
# adding or updating assets for this project.
|
||||
plugin:
|
||||
androidPackage: io.github.v7lin.fakeweibo
|
||||
pluginClass: FakeWeiboPlugin
|
||||
platforms:
|
||||
android:
|
||||
package: io.github.v7lin.weibo_kit
|
||||
pluginClass: WeiboKitPlugin
|
||||
ios:
|
||||
pluginClass: WeiboKitPlugin
|
||||
|
||||
# To add assets to your plugin package, add an assets section, like this:
|
||||
# assets:
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
#
|
||||
# For details regarding assets in packages, see
|
||||
# https://flutter.io/assets-and-images/#from-packages
|
||||
# https://flutter.dev/assets-and-images/#from-packages
|
||||
#
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.io/assets-and-images/#resolution-aware.
|
||||
# https://flutter.dev/assets-and-images/#resolution-aware.
|
||||
|
||||
# To add custom fonts to your plugin package, add a fonts section here,
|
||||
# in this "flutter" section. Each entry in this list should have a
|
||||
@ -66,4 +74,4 @@ flutter:
|
||||
# weight: 700
|
||||
#
|
||||
# For details regarding fonts in packages, see
|
||||
# https://flutter.io/custom-fonts/#from-packages
|
||||
# https://flutter.dev/custom-fonts/#from-packages
|
||||
|
@ -1 +0,0 @@
|
||||
void main() {}
|
@ -1,47 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:fake_weibo/src/domain/api/weibo_user_info_resp.dart';
|
||||
import 'package:fake_weibo/src/domain/sdk/weibo_auth_resp.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
|
||||
void main() {
|
||||
test('smoke test - snake case', () {
|
||||
print('${toSnakeCase('oneField')}');
|
||||
print('${toSnakeCase('oneField_street')}');
|
||||
print('${toSnakeCase('one_field')}');
|
||||
});
|
||||
|
||||
test('smoke test - kebab case', () {
|
||||
print('${toKebabCase('oneField')}');
|
||||
print('${toKebabCase('oneField_street')}');
|
||||
print('${toKebabCase('one_field')}');
|
||||
});
|
||||
|
||||
test('smoke test - camel case', () {
|
||||
print('${toCamelCase('oneField')}');
|
||||
print('${toCamelCase('oneField_street')}');
|
||||
print('${toCamelCase('one_field')}');
|
||||
});
|
||||
|
||||
test('smoke test - jaguar_serializer', () {
|
||||
WeiboAuthResp authResp = WeiboAuthRespSerializer().fromMap(json.decode(
|
||||
'{"expiresIn":157679999,"errorCode":0,"accessToken":"2.00s67kHGj4SghD8e46233eea9O1IDB","userId":"5611295980","refreshToken":"2.00s67kHGj4SghD6ee52b48200iqHz3"}')
|
||||
as Map<dynamic, dynamic>);
|
||||
expect(authResp.errorCode, equals(0));
|
||||
expect(authResp.expiresIn, equals(157679999));
|
||||
expect(authResp.accessToken, equals('2.00s67kHGj4SghD8e46233eea9O1IDB'));
|
||||
|
||||
WeiboUserInfoResp userInfoResp = WeiboUserInfoRespSerializer().fromMap(
|
||||
json.decode(
|
||||
'{"id":5611295980,"idstr":"5611295980","class":1,"screen_name":"v7lin","name":"v7lin","province":"35","city":"1","location":"福建 福州","description":"","url":"","profile_image_url":"http://tvax4.sinaimg.cn/crop.0.0.640.640.50/0067KqpSly8fujqh4oj39j30hs0hsjs6.jpg","cover_image_phone":"http://ww1.sinaimg.cn/crop.0.0.640.640.640/549d0121tw1egm1kjly3jj20hs0hsq4f.jpg","profile_url":"u/5611295980","domain":"","weihao":"","gender":"m","followers_count":1,"friends_count":1,"pagefriends_count":0,"statuses_count":0,"video_status_count":0,"favourites_count":0,"created_at":"Mon May 18 19:32:52 +0800 2015","following":false,"allow_all_act_msg":false,"geo_enabled":true,"verified":false,"verified_type":-1,"remark":"","insecurity":{"sexual_content":false},"ptype":0,"allow_all_comment":true,"avatar_large":"http://tvax4.sinaimg.cn/crop.0.0.640.640.180/0067KqpSly8fujqh4oj39j30hs0hsjs6.jpg","avatar_hd":"http://tvax4.sinaimg.cn/crop.0.0.640.640.1024/0067KqpSly8fujqh4oj39j30hs0hsjs6.jpg","verified_reason":"","verified_trade":"","verified_reason_url":"","verified_source":"","verified_source_url":"","follow_me":false,"like":false,"like_me":false,"online_status":0,"bi_followers_count":0,"lang":"zh-cn","star":0,"mbtype":0,"mbrank":0,"block_word":0,"block_app":0,"credit_score":80,"user_ability":0,"urank":4,"story_read_state":-1,"vclub_member":0,"is_teenager":0,"is_guardian":0,"is_teenager_list":0}')
|
||||
as Map<dynamic, dynamic>);
|
||||
expect(userInfoResp.errorCode, equals(0));
|
||||
expect(userInfoResp.id, equals(5611295980));
|
||||
expect(userInfoResp.screenName, equals('v7lin'));
|
||||
expect(
|
||||
userInfoResp.avatarHd,
|
||||
equals(
|
||||
'http://tvax4.sinaimg.cn/crop.0.0.640.640.1024/0067KqpSly8fujqh4oj39j30hs0hsjs6.jpg'));
|
||||
});
|
||||
}
|
79
test/weibo_kit_test.dart
Normal file
79
test/weibo_kit_test.dart
Normal file
@ -0,0 +1,79 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pedantic/pedantic.dart';
|
||||
import 'package:weibo_kit/weibo_kit.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
const MethodChannel channel = MethodChannel('v7lin.github.io/weibo_kit');
|
||||
final Weibo weibo = Weibo();
|
||||
|
||||
setUp(() {
|
||||
channel.setMockMethodCallHandler((MethodCall call) async {
|
||||
switch (call.method) {
|
||||
case 'registerApp':
|
||||
return null;
|
||||
case 'isInstalled':
|
||||
return true;
|
||||
case 'auth':
|
||||
unawaited(channel.binaryMessenger.handlePlatformMessage(
|
||||
channel.name,
|
||||
channel.codec.encodeMethodCall(
|
||||
MethodCall('onAuthResp', json.decode('{"errorCode":-1}'))),
|
||||
(ByteData data) {
|
||||
// mock success
|
||||
},
|
||||
));
|
||||
return null;
|
||||
case 'shareText':
|
||||
case 'shareImage':
|
||||
case 'shareWebpage':
|
||||
unawaited(channel.binaryMessenger.handlePlatformMessage(
|
||||
channel.name,
|
||||
channel.codec.encodeMethodCall(
|
||||
MethodCall('onShareMsgResp', json.decode('{"errorCode":-1}'))),
|
||||
(ByteData data) {
|
||||
// mock success
|
||||
},
|
||||
));
|
||||
return null;
|
||||
}
|
||||
throw PlatformException(code: '0', message: '想啥呢,升级插件不想升级Mock?');
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
channel.setMockMethodCallHandler(null);
|
||||
});
|
||||
|
||||
test('isInstalled', () async {
|
||||
expect(await weibo.isInstalled(), true);
|
||||
});
|
||||
|
||||
test('auth', () async {
|
||||
StreamSubscription<WeiboAuthResp> sub =
|
||||
weibo.authResp().listen((WeiboAuthResp resp) {
|
||||
expect(resp.errorCode, WeiboSdkResp.USERCANCEL);
|
||||
});
|
||||
await weibo.auth(
|
||||
appKey: 'your weibo app key',
|
||||
scope: <String>[WeiboScope.ALL],
|
||||
);
|
||||
await sub.cancel();
|
||||
});
|
||||
|
||||
test('share', () async {
|
||||
StreamSubscription<WeiboSdkResp> sub =
|
||||
weibo.shareMsgResp().listen((WeiboSdkResp resp) {
|
||||
expect(resp.errorCode, WeiboSdkResp.USERCANCEL);
|
||||
});
|
||||
await weibo.shareText(
|
||||
text: 'share text',
|
||||
);
|
||||
await sub.cancel();
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user