From d44b5a8080ce7e6876c98a097e4832fbcbf77311 Mon Sep 17 00:00:00 2001 From: v7lin Date: Fri, 17 May 2019 11:49:54 +0800 Subject: [PATCH] xxx --- README.md | 1 + example/android/app/build.gradle | 5 +++ example/lib/main.dart | 70 ++++++++++++++------------------ 3 files changed, 37 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 2df4917..49a0175 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # fake_weibo [![Build Status](https://cloud.drone.io/api/badges/v7lin/fake_weibo/status.svg)](https://cloud.drone.io/v7lin/fake_weibo) +[![Codecov](https://codecov.io/gh/v7lin/fake_weibo/branch/master/graph/badge.svg)](https://codecov.io/gh/v7lin/fake_weibo) [![GitHub Tag](https://img.shields.io/github/tag/v7lin/fake_weibo.svg)](https://github.com/v7lin/fake_weibo/releases) [![Pub Package](https://img.shields.io/pub/v/fake_weibo.svg)](https://pub.dartlang.org/packages/fake_weibo) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/v7lin/fake_weibo/blob/master/LICENSE) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index d5d7601..840b71c 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -46,6 +46,11 @@ 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' } } } diff --git a/example/lib/main.dart b/example/lib/main.dart index 1e44a6f..82e98f6 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -5,11 +5,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:fake_weibo/fake_weibo.dart'; -const String _WEIBO_APP_KEY = '3393861383'; -const List _WEIBO_SCOPE = [ - WeiboScope.ALL, -]; - void main() { runZoned(() { runApp(MyApp()); @@ -28,27 +23,13 @@ void main() { class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - Weibo weibo = Weibo() - ..registerApp( - appKey: _WEIBO_APP_KEY, - scope: _WEIBO_SCOPE, - ); - return WeiboProvider( - weibo: weibo, - child: MaterialApp( - home: Home( - weibo: weibo, - ), - ), + return MaterialApp( + home: Home(), ); } } class Home extends StatefulWidget { - Home({Key key, @required this.weibo}) : super(key: key); - - final Weibo weibo; - @override State createState() { return _HomeState(); @@ -56,6 +37,13 @@ class Home extends StatefulWidget { } class _HomeState extends State { + static const String _WEIBO_APP_KEY = '3393861383'; + static const List _WEIBO_SCOPE = [ + WeiboScope.ALL, + ]; + + Weibo _weibo = Weibo(); + StreamSubscription _auth; StreamSubscription _share; @@ -64,8 +52,12 @@ class _HomeState extends State { @override void initState() { super.initState(); - _auth = widget.weibo.authResp().listen(_listenAuth); - _share = widget.weibo.shareMsgResp().listen(_listenShareMsg); + _weibo.registerApp( + appKey: _WEIBO_APP_KEY, + scope: _WEIBO_SCOPE, + ); + _auth = _weibo.authResp().listen(_listenAuth); + _share = _weibo.shareMsgResp().listen(_listenShareMsg); } void _listenAuth(WeiboAuthResp resp) { @@ -94,33 +86,32 @@ class _HomeState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Fake Weibo Demo'), + title: const Text('Fake Weibo Demo'), ), body: ListView( children: [ ListTile( - title: Text('环境检查'), + title: const Text('环境检查'), onTap: () async { - String content = - 'weibo: ${await widget.weibo.isWeiboInstalled()}'; + String content = 'weibo: ${await _weibo.isWeiboInstalled()}'; _showTips('环境检查', content); }, ), ListTile( - title: Text('登录'), + title: const Text('登录'), onTap: () { - widget.weibo.auth( + _weibo.auth( appKey: _WEIBO_APP_KEY, scope: _WEIBO_SCOPE, ); }, ), ListTile( - title: Text('用户信息'), + title: const Text('用户信息'), onTap: () async { if (_authResp != null && _authResp.errorCode == WeiboSdkResp.SUCCESS) { - WeiboUserInfoResp userInfoResp = await widget.weibo.getUserInfo( + WeiboUserInfoResp userInfoResp = await _weibo.getUserInfo( appkey: _WEIBO_APP_KEY, userId: _authResp.userId, accessToken: _authResp.accessToken, @@ -137,33 +128,34 @@ class _HomeState extends State { }, ), ListTile( - title: Text('文字分享'), + title: const Text('文字分享'), onTap: () { - widget.weibo.shareText( + _weibo.shareText( text: 'Share Text', ); }, ), ListTile( - title: Text('图片分享'), + title: const Text('图片分享'), onTap: () async { - AssetImage image = AssetImage('images/icon/timg.jpeg'); + AssetImage image = const AssetImage('images/icon/timg.jpeg'); AssetBundleImageKey key = await image.obtainKey(createLocalImageConfiguration(context)); ByteData imageData = await key.bundle.load(key.name); - await widget.weibo.shareImage( + await _weibo.shareImage( imageData: imageData.buffer.asUint8List(), ); }, ), ListTile( - title: Text('网页分享'), + title: const Text('网页分享'), onTap: () async { - AssetImage image = AssetImage('images/icon/ic_launcher.png'); + 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 widget.weibo.shareWebpage( + await _weibo.shareWebpage( title: 'title', description: 'share webpage', thumbData: thumbData.buffer.asUint8List(),