Commit b6798a3e authored by 林生雨's avatar 林生雨

Commit

parent 39d8bf42
#Thu Aug 08 10:34:21 CST 2019
#Fri Aug 09 14:55:50 CST 2019
gradle.version=4.10.2
This diff is collapsed.
......@@ -35,9 +35,9 @@ buildDir = new File(rootProject.projectDir, "../build/host")
dependencies {
implementation project(':flutter')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:design:27.1.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
testImplementation 'junit:junit:4.12'
......
Flutter crash report; please file at https://github.com/flutter/flutter/issues.
## command
flutter --no-color run --machine --track-widget-creation --device-id=emulator-5554 lib/main.dart
## exception
SocketException: SocketException: Write failed (OS Error: Broken pipe, errno = 32), port = 0
```
null```
## flutter doctor
```
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.5 18F132, locale zh-Hans-CN)
• Flutter version 1.7.8+hotfix.4 at /Users/apple/Downloads/flutter
• Framework revision 20e59316b8 (3 weeks ago), 2019-07-18 20:04:33 -0700
• Engine revision fee001c93f
• Dart version 2.4.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
• Android SDK at /Users/apple/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.1
• ANDROID_HOME = /Users/apple/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2.1, Build version 10E1001
• CocoaPods version 1.7.4
[✓] iOS tools - develop for iOS devices
• ios-deploy 1.9.4
[✓] Android Studio (version 3.4)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 37.0.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[!] IntelliJ IDEA Ultimate Edition (version 2019.1.3)
• IntelliJ at /Applications/IntelliJ IDEA.app
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.dev/intellij-setup/#installing-the-plugins
[✓] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
! Doctor found issues in 1 category.
```
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:gmalpha_flutter/base/user_tool.dart';
import 'package:gmalpha_flutter/model/setting_model.dart';
import 'package:provider/provider.dart';
import 'package:rxdart/rxdart.dart';
import 'package:shared_preferences/shared_preferences.dart';
class AppConfig {
class AppConfig<T extends ChangeNotifier> {
static const primaryColor = Color(0xFF5DBE82); //主题色
static const disabledMainColor = Color.fromRGBO(97, 190, 130, 0.5);
......@@ -20,7 +26,10 @@ class AppConfig {
return new Container(
width: width,
height: height,
child: new Image.asset('images/placehoder_img.png',fit: BoxFit.cover,));
child: new Image.asset(
'images/placehoder_img.png',
fit: BoxFit.cover,
));
}
static Widget getUserPlaceHoder(width, height) {
......@@ -34,20 +43,21 @@ class AppConfig {
return new SizedBox(
width: width,
height: height,
child: const CircularProgressIndicator(strokeWidth: 2.0)
);
child: const CircularProgressIndicator(strokeWidth: 2.0));
}
//debug:false release: true
static const bool inProduction = const bool.fromEnvironment("dart.vm.product");
static const bool inProduction =
const bool.fromEnvironment("dart.vm.product");
static Widget initLoading(bool showEmpty, [String emptyText = '暂无数据']) {
return new Center(
child: showEmpty ? _initEmpty(emptyText) : SizedBox(
child: showEmpty
? _initEmpty(emptyText)
: SizedBox(
width: 35.0,
height: 35.0,
child: const CircularProgressIndicator(strokeWidth: 2.0)
),
child: const CircularProgressIndicator(strokeWidth: 2.0)),
);
}
......@@ -56,17 +66,107 @@ class AppConfig {
padding: EdgeInsets.fromLTRB(0, 80, 0, 0),
child: new Column(
children: <Widget>[
new Icon(Icons.hourglass_empty, color: Colors.grey,size: 60,),
new Container(height: 10,),
new Icon(
Icons.hourglass_empty,
color: Colors.grey,
size: 60,
),
new Container(
height: 10,
),
new Text(emptyText)
],
),
);
}
static UserTools userTools;
static SharedPreferences _spf;
static List<SingleChildCloneableWidget> list = [
ChangeNotifierProvider<SettingProvide>.value(value: SettingProvide()),
];
static init() async {
// userTools = await UserTools.getInstance();
}
}
const bool inProduction = const bool.fromEnvironment("dart.vm.product");
const BASEURL_RELEASE = 'https://api.github.com/';
const BASEURL_DEBUG = 'https://api.github.com/';
class ApiDio {
static ApiDio instance;
static ApiService apiService;
ApiDio() {
var options = new BaseOptions(
connectTimeout: 5000,
receiveTimeout: 3000,
baseUrl: inProduction ? BASEURL_RELEASE : BASEURL_DEBUG,
contentType: new ContentType('application', 'x-www-form-urlencoded',
charset: 'utf-8'));
Dio dio = new Dio(options);
dio.interceptors.add(AuthInterceptor()); // 添加 token
dio
..interceptors
.add(LogInterceptor(responseBody: true, requestBody: true)); //添加日志
apiService = new ApiService(dio);
}
static ApiService getInstance() {
if (instance == null) {
instance = new ApiDio();
}
return _getApiService();
}
static ApiService _getApiService() {
return apiService;
}
}
class AuthInterceptor extends Interceptor {
String PLATFORM = "android";
String CLIENT = "store";
@override
onRequest(RequestOptions options) async {
Map<String, String> headers = new Map();
headers["Accept-Charset"] = "utf-8";
headers["Connection"] = "keep-alive";
headers["Accept"] = "*/*";
headers["x-version"] = "XXX";
headers["x-platform"] = PLATFORM;
headers["x-client"] = CLIENT;
headers["x-equCode"] = "XXX";
headers["Authorization"] = "XXX";
headers["token"] = "Xxx";
options.headers = headers;
return super.onRequest(options);
}
}
class ApiService {
ApiService(this.dio);
Dio dio;
Future _get(String url, {Map<String, dynamic> params}) async {
var response = await dio.get(url, queryParameters: params);
return response.data;
}
Future _post(String url, Map<String, dynamic> params) async {
var response = await dio.post(url, data: params);
return response.data;
}
Observable post(String url, Map<String, dynamic> params) =>
Observable.fromFuture(_post(url, params)).asBroadcastStream();
Observable get(String url, {Map<String, dynamic> params}) =>
Observable.fromFuture(_get(url, params: params)).asBroadcastStream();
}
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:provide/provide.dart';
import 'package:gmalpha_flutter/model/setting_model.dart';
import 'package:provider/provider.dart';
import 'package:rxdart/rxdart.dart';
/// BaseProvide
class BaseProvide with ChangeNotifier {
CompositeSubscription compositeSubscription = CompositeSubscription();
addSubscription(StreamSubscription subscription){
addSubscription(StreamSubscription subscription) {
compositeSubscription.add(subscription);
}
......@@ -21,23 +20,37 @@ class BaseProvide with ChangeNotifier {
}
}
abstract class PageProvideNode extends StatelessWidget {
final Providers mProviders = Providers();
abstract class PageProvideNode<T extends ChangeNotifier>
extends StatelessWidget {
Widget buildContent(BuildContext context);
T getProvider();
@override
Widget build(BuildContext context) {
return ProviderNode(
providers: mProviders,
return ChangeNotifierProvider(
builder: (_) => getProvider(),
child: buildContent(context),
);
}
}
abstract class PageMultiProvideNode<T extends ChangeNotifier>
extends StatelessWidget {
Widget buildContent(BuildContext context);
abstract class BaseState<T extends StatefulWidget> extends State<T> {
List<SingleChildCloneableWidget> getProviders();
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: getProviders(),
child: buildContent(context),
);
}
}
abstract class BaseState<T extends StatefulWidget> extends State<T> {
@override
void initState() {
super.initState();
......
class ThemeColorEvent{
int color;
ThemeColorEvent(this.color);
}
\ No newline at end of file
import 'dart:async';
import 'package:event_bus/event_bus.dart';
import 'package:flutter/material.dart';
import 'package:flutter_boost/flutter_boost.dart';
import 'package:gmalpha_flutter/macros/ALColors.dart';
import 'package:gmalpha_flutter/page/SettingPage.dart';
import 'package:provider/provider.dart';
import 'base/app_config.dart';
import 'base/base.dart';
import 'event/ThemeColorEvent.dart';
import 'model/setting_model.dart';
import 'simple_page_widgets.dart';
import 'comment_suggest.dart';
void main() async {
await AppConfig.init();
runApp(MyApp());
runApp(MyApplication());
}
class MyApplication extends PageMultiProvideNode {
class MyApp extends StatefulWidget {
@override
Widget buildContent(BuildContext context) => MyApp();
@override
List<SingleChildCloneableWidget> getProviders() {
return AppConfig.list;
}
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
EventBus eventBus = EventBus();
StreamSubscription _colorSubscription;
@override
void initState() {
super.initState();
//event bus example
_colorSubscription = eventBus.on<ThemeColorEvent>().listen((event) {
print("==========${event.color}");
});
eventBus.fire(ThemeColorEvent(0xffffffff));
FlutterBoost.singleton.registerPageBuilders({
'first': (pageName, params, _) => FirstRouteWidget(),
'second': (pageName, params, _) => SecondRouteWidget(),
'setting_page': (pageName, params, _) => SettingPage(params),
"page_a": (pageName, params, _) => SettingPage(params),
// 'tab': (pageName, params, _) => TabRouteWidget(),
// 'flutterFragment': (pageName, params, _) => FragmentRouteWidget(params),
// 'comment_suggest': (pageName, params, _) {
......@@ -44,6 +68,13 @@ class _MyAppState extends State<MyApp> {
FlutterBoost.handleOnStartPage();
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
_colorSubscription.cancel();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
......@@ -54,9 +85,14 @@ class _MyAppState extends State<MyApp> {
// '/': (context) => SettingPage({"Cookie":" _gm_token=7e48641558699683; sessionid=nb3ze4ur7ucosln8sd8pzwojddenv9ym; _gtid=a1bc0a387e1911e996b9525400fa516d4094"}),
// },//调试的时候可以打开
// builder: FlutterBoost.init(postPush: _onRoutePushed),
home: SettingPage({"Cookie":" _gm_token=7e48641558699683; sessionid=nb3ze4ur7ucosln8sd8pzwojddenv9ym; _gtid=a1bc0a387e1911e996b9525400fa516d4094"}),
home: SettingPage({
"Cookie":
" _gm_token=7e48641558699683; sessionid=nb3ze4ur7ucosln8sd8pzwojddenv9ym; _gtid=a1bc0a387e1911e996b9525400fa516d4094"
}),
theme: new ThemeData(
primaryColor: Colors.white,
appBarTheme: AppBarTheme(
color: Color(Provider.of<SettingProvide>(context).color)),
backgroundColor: Color(0xFFFFFFFF),
accentColor: Color(0xFFFFFFFF),
textTheme: TextTheme(
......
......@@ -6,14 +6,18 @@ class SettingProvide extends BaseProvide {
final repo = new SettingRepo();
bool isModifyAll = false;
int listSize;
int listSize = 4;
int color = 0xffFFFFFF;
bool canClick = true;
String name;
String city;
String email;
String headUrl;
String userId;
bool bindIns = false;
bool bindIns = true;
String tempName;
String tempCity;
......@@ -48,7 +52,10 @@ class SettingProvide extends BaseProvide {
}
void quitLogin() {
repo.quitLogin();
headUrl = "http://pic26.nipic.com/20121221/9252150_142515375000_2.jpg";
color = 0xff000000;
notifyListeners();
// repo.quitLogin();
}
void clickCity() {
......@@ -56,14 +63,22 @@ class SettingProvide extends BaseProvide {
}
void clickIns() {
if(bindIns) {
if (bindIns) {
repo.clickIns();
}else{
} else {
clickArguement();
}
}
void loadData() =>
repo.loadData("1", "1").listen((data) {}).onError((error) {});
void clickArguement() {
repo.clickArguement();
}
void clickLeft() {
color = 0xff000000;
notifyListeners();
}
}
This diff is collapsed.
import 'package:flutter/services.dart';
import 'package:gmalpha_flutter/base/app_config.dart';
import 'package:rxdart/rxdart.dart';
const settingChannel = const MethodChannel('flutter.io/setting_channel_method');
class SettingRepo {
getInstance(){
return 0;
}
Future<bool> quitLogin() async {
await settingChannel.invokeMethod("quit_login", null);
await settingChannel.invokeMethod("quit_login", {"a":"a","a":"a"});
}
Future<String> clickCity() async {
......@@ -18,4 +25,13 @@ class SettingRepo {
Future<String> clickArguement() async {
await settingChannel.invokeMethod("click_arguement", null);
}
Observable loadData(String pageNum, String pageSize) {
Map<String, String> map = new Map();
map["pageNum"] = pageNum;
map["pageSize"] = pageSize;
return ApiDio.getInstance().get("good/list", params: map);
}
}
......@@ -71,20 +71,25 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.13"
event_bus:
dependency: "direct main"
description:
name: event_bus
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_boost:
dependency: "direct dev"
dependency: "direct main"
description:
path: "."
ref: "0.0.411"
resolved-ref: "3978c43c31c1c29b569724fd330b367caa459acc"
url: "https://github.com/alibaba/flutter_boost.git"
source: git
version: "0.0.411"
name: flutter_boost
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.0.420"
flutter_cache_manager:
dependency: transitive
description:
......
......@@ -12,72 +12,41 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
# 网络库
dio: ^2.1.0
# 状态管理库
provider: ^3.0.0+1
provide: ^1.0.2
rxdart: ^0.21.0
flutter_screenutil: ^0.3.0
shared_preferences: ^0.5.1+2
cached_network_image: 1.1.0
flutter_boost: ^0.0.415
# event bus
event_bus: ^1.1.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter_boost:
git:
url: 'https://github.com/alibaba/flutter_boost.git'
ref: '0.0.411'
# native_flutter_transfer_plugin:
# git:
# url: 'git@git.wanmeizhensuo.com:mobile/native_flutter_transfer_plugin.git'
# ref: '0.0.1'
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add Flutter specific assets to your application, add an assets section,
# like this:
assets:
- images/nav_back.png
- images/camera.png
- images/right_arrow.png
- images/icon_default_head.png
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.io/assets-and-images/#from-packages
# To add Flutter specific custom fonts to your application, add a fonts
# section here, in this "flutter" section. Each entry in this list should
# have a "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.io/custom-fonts/#from-packages
module:
androidPackage: com.example.gmalpha_flutter
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment