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
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":flutter" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/../../.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":flutter" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/build/generated/res/resValues/debug" />
<option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
<option name="PROJECT_TYPE" value="1" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes" />
<output-test url="file://$MODULE_DIR$/build/intermediates/javac/debugUnitTest/compileDebugUnitTestJavaWithJavac/classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debug/compileDebugAidl/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debug/compileDebugRenderscript/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debugAndroidTest/compileDebugAndroidTestAidl/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debugAndroidTest/compileDebugAndroidTestRenderscript/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/generated/not_namespaced_r_class_sources" />
<excludeFolder url="file://$MODULE_DIR$/build/generated/source/r" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/aapt_friendly_merged_manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotation_processor_list" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations_typedef_file" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations_zip" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check_manifest_result" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/compile_library_classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/compile_only_not_namespaced_r_class_jar" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/consumer_proguard_file" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/flutter" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/full_jar" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/intermediate-jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javac" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/library_and_local_jars_jni" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/library_assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/library_java_res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/library_manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint_jar" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_jni_libs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/packaged-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/packaged_res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/public_res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/runtime_library_classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shader_assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 28 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Gradle: com.android.support:support-fragment:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:localbroadcastmanager:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:documentfile:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: __local_aars__:/Users/apple/Downloads/flutter/bin/cache/artifacts/engine/android-arm64/flutter.jar:unspecified@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:slidingpanelayout:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:viewmodel:1.1.1@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:loader:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.core:runtime:1.1.1@aar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:livedata-core:1.1.1@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:collections:28.0.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:cursoradapter:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:runtime:1.1.1@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-compat:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-ui:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:asynclayoutinflater:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:print:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.core:common:1.1.1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:versionedparcelable:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: __local_aars__:/Users/apple/lsy/gengmei_alpha/gmalpha_flutter/.android/Flutter/build/intermediates/flutter/debug/libs.jar:unspecified@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: junit:junit:4.12@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-core:1.3@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:viewpager:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-utils:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-annotations:28.0.0@jar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:common:1.1.1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-v13:27.1.1@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:interpolator:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:livedata:1.1.1@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:drawerlayout:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:coordinatorlayout:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:customview:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:swiperefreshlayout:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-v4:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-media-compat:28.0.0@aar" level="project" />
<orderEntry type="module" module-name="flutter_boost" />
<orderEntry type="module" module-name="shared_preferences" />
<orderEntry type="module" module-name="sqflite" />
<orderEntry type="module" module-name="xservice_kit" />
<orderEntry type="module" module-name="path_provider" />
</component>
</module>
\ No newline at end of file
......@@ -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);
......@@ -18,9 +24,12 @@ class AppConfig {
static Widget getPlaceHoder([width, height]) {
return new Container(
width: width,
height: height,
child: new Image.asset('images/placehoder_img.png',fit: BoxFit.cover,));
width: width,
height: height,
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(
width: 35.0,
height: 35.0,
child: const CircularProgressIndicator(strokeWidth: 2.0)
),
child: showEmpty
? _initEmpty(emptyText)
: SizedBox(
width: 35.0,
height: 35.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();
......@@ -47,4 +60,4 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
void dispose() {
super.dispose();
}
}
\ No newline at end of file
}
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();
}
}
......@@ -4,43 +4,40 @@ import 'package:flutter/src/widgets/framework.dart';
import 'package:gmalpha_flutter/base/base.dart';
import 'package:gmalpha_flutter/macros/ALColors.dart';
import 'package:gmalpha_flutter/model/setting_model.dart';
import 'package:provide/provide.dart';
import 'package:flutter_boost/flutter_boost.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:provider/provider.dart';
class SettingPage extends PageProvideNode {
final provide = new SettingProvide();
class SettingPage extends StatefulWidget {
Map args;
SettingPage(Map args) {
mProviders.provide(Provider<SettingProvide>.value(provide));
provide.init(args);
SettingPage(this.args) {
print(args);
}
@override
Widget buildContent(BuildContext context) => _HomeContentPage(provide);
}
class _HomeContentPage extends StatefulWidget {
SettingProvide provide;
// @override
// Widget buildContent(BuildContext context) => _HomeContentPage();
//
// @override
// ChangeNotifier getProvider() {
// var settingProvide = SettingProvide();
// settingProvide.init(args);
// return settingProvide;
// }
_HomeContentPage(this.provide);
// @override
// Widget build(BuildContext context)=>_HomeContentPage();
@override
State<StatefulWidget> createState() {
return _HomeContentState();
}
State<StatefulWidget> createState() => _HomeContentState();
}
class _HomeContentState extends State<_HomeContentPage> {
SettingProvide _provide;
var screenUtil;
class _HomeContentState extends State<SettingPage> {
TextEditingController textEditingController = TextEditingController();
@override
void initState() {
super.initState();
_provide ??= widget.provide;
}
@override
......@@ -49,46 +46,70 @@ class _HomeContentState extends State<_HomeContentPage> {
textEditingController.dispose();
}
var settingProvide = SettingProvide();
@override
Widget build(BuildContext context) {
// if (screenUtil == null) {
// screenUtil = new ScreenUtil(width: 375, height: 667)..init(context);
// }
// return ChangeNotifierProvider.value(value: settingProvide
// ,child: getMainView(),);
return getMainView();
}
getMainView() {
return Scaffold(
appBar: new AppBar(
backgroundColor: Color(0xFFffffff),
elevation: 0,
brightness: Brightness.light,
leading: new GestureDetector(
child: new ImageIcon(
AssetImage('images/nav_back.png'),
color: ALColors.Color323232,
),
onTap: () {
FlutterBoost.singleton.closePageForContext(context);
}),
leading: GestureDetector(
onTap: () => clickAction(),
child: Padding(
padding: EdgeInsets.fromLTRB(10, 0, 0, 0),
child: ImageIcon(AssetImage("images/nav_back.png")),
),
),
// leading: new GestureDetector(
// child: new ImageIcon(
// AssetImage('images/nav_back.png'),
// color: ALColors.Color323232,
// ),
// onTap: () {
// FlutterBoost.singleton.closePageForContext(context);
// }),[]
actions: <Widget>[
Container(
height: double.infinity,
padding: EdgeInsets.fromLTRB(0, 0, 30, 0),
child: Center(child: Provide(
builder: (BuildContext c, Widget w, SettingProvide pro) {
return pro.isModifyAll
? Text(
"保存",
style:
TextStyle(fontSize: 14, color: Color(0xffC4C4C4)),
)
: Text(
"保存",
style: TextStyle(fontSize: 14, color: Colors.black),
);
}))),
padding: EdgeInsets.fromLTRB(0, 0, 30, 0),
child: Text(
"保存",
style: TextStyle(
fontSize: 14,
color: Color(Provider.of<SettingProvide>(context).color)),
),
)
// Container(
// height: double.infinity,
// padding: EdgeInsets.fromLTRB(0, 0, 30, 0),
// child: Center(
// child: Provider
// .of<SettingProvide>(context)
// .isModifyAll
// ? Text(
// "保存",
// style:
// TextStyle(fontSize: 14, color: Color(0xffC4C4C4)),
// )
// : Text(
// "保存",
// style: TextStyle(fontSize: 14, color: Colors.black),
// )),
// )
],
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(29, 10, 0, 0),
child: Text(
......@@ -104,59 +125,55 @@ class _HomeContentState extends State<_HomeContentPage> {
child: Stack(
alignment: AlignmentDirectional.bottomEnd,
children: <Widget>[
Provide(builder:
(BuildContext context, Widget child, SettingProvide pro) {
return pro.headUrl == null
? Image.asset("images/icon_default_head.png")
: ClipOval(
child: CachedNetworkImage(
imageUrl: pro.headUrl,
placeholder: (context, url) {
return Image.asset(
"images/icon_default_head.png");
},
),
);
}),
ClipOval(
child: Provider.of<SettingProvide>(context).headUrl != null
? CachedNetworkImage(
width: double.maxFinite,
height: double.maxFinite,
imageUrl:
Provider.of<SettingProvide>(context).headUrl,
placeholder: (context, url) {
return Image.asset(
"images/icon_default_head.png");
},
fit: BoxFit.cover,
)
: Image.asset("images/icon_default_head.png"),
),
Image.asset("images/camera.png"),
],
),
),
),
Container(
height: 240,
child: Provide(
builder: (BuildContext c, Widget w, SettingProvide pro) {
return ListView.separated(
padding: EdgeInsets.fromLTRB(30, 0, 30, 0),
itemCount: pro.listSize,
itemBuilder: (BuildContext context, int index) {
return Provide(builder: (BuildContext context, Widget child,
SettingProvide pro) {
if (index == 0) {
return specialOneItem("昵称", index);
} else if (index == 1) {
return ListItemView(context, "国家", pro.city, index);
} else if (index == 2) {
if (pro.bindIns) {
return ListItemView(
context, "我的Instagram账号", pro.email, index);
} else {
return ListItemView(context, "意见与建议", "", index);
}
} else if (index == 3) {
return ListItemView(context, "意见与建议", "", index);
}
});
},
separatorBuilder: (BuildContext context, int index) {
return new Divider(
height: 1.0,
color: Color(0xffE4E4E4),
);
},
);
})),
height: 240,
child: ListView.separated(
padding: EdgeInsets.fromLTRB(30, 0, 30, 0),
itemCount: Provider.of<SettingProvide>(context).listSize,
itemBuilder: (BuildContext context, int index) {
if (index == 0) {
return specialOneItem(context, "昵称", index);
} else if (index == 1) {
return ListItemView(context, "国家",
Provider.of<SettingProvide>(context).city, index);
} else if (index == 2) {
if (Provider.of<SettingProvide>(context).bindIns) {
return ListItemView(context, "我的Instagram账号",
Provider.of<SettingProvide>(context).email, index);
} else {
return ListItemView(context, "意见与建议", "", index);
}
} else if (index == 3) {
return ListItemView(context, "意见与建议", "", index);
}
},
separatorBuilder: (BuildContext context, int index) {
return new Divider(
height: 1.0,
color: Color(0xffE4E4E4),
);
}),
),
Container(
padding: EdgeInsets.fromLTRB(30, 0, 30, 0),
child: Divider(
......@@ -177,7 +194,7 @@ class _HomeContentState extends State<_HomeContentPage> {
"退出登入",
style: TextStyle(color: Color(0xff323232), fontSize: 14),
),
onPressed: () => _provide.quitLogin(),
onPressed: () => Provider.of<SettingProvide>(context).quitLogin(),
),
),
Expanded(
......@@ -193,7 +210,7 @@ class _HomeContentState extends State<_HomeContentPage> {
return Container(
height: 60,
child: GestureDetector(
onTap: onListItemTap(index),
onTap: onListItemTap(context, index),
child: Row(
children: <Widget>[
Center(
......@@ -220,57 +237,109 @@ class _HomeContentState extends State<_HomeContentPage> {
));
}
specialOneItem(String left, int index) {
specialOneItem(BuildContext context, String left, int index) {
return Container(
height: 60,
child: GestureDetector(
onTap: onListItemTap(index),
onTap: onListItemTap(context, index),
child: Row(
children: <Widget>[
Center(
child: Text(
left,
style: TextStyle(fontSize: 13, color: Color(0xff323232)),
),
child: Text(left,
style: TextStyle(fontSize: 13, color: Color(0xff323232))),
),
Expanded(
child: Container(
width: double.maxFinite,
child: Provide(builder:
(BuildContext context, Widget w, SettingProvide pro) {
return TextField(
controller: textEditingController,
textAlign: TextAlign.end,
style:
TextStyle(fontSize: 13, color: Color(0xff323232)),
maxLines: 1,
showCursor: false,
onEditingComplete: () {
pro.tempName = textEditingController.text;
pro.setSaveBtnStatus();
},
decoration: InputDecoration(
border: InputBorder.none,
hintText: pro.tempName,
hintStyle: TextStyle(
fontSize: 13, color: Color(0xff323232))));
}))),
child: Container(
width: double.maxFinite,
child: TextField(
controller: textEditingController,
textAlign: TextAlign.end,
style: TextStyle(fontSize: 13, color: Color(0xff323232)),
maxLines: 1,
showCursor: false,
onEditingComplete: () {
Provider.of<SettingProvide>(context).tempName =
textEditingController.text;
Provider.of<SettingProvide>(context).setSaveBtnStatus();
},
decoration: InputDecoration(
border: InputBorder.none,
hintText: Provider.of<SettingProvide>(context).tempName,
hintStyle:
TextStyle(fontSize: 13, color: Color(0xff323232)))),
),
)
],
),
),
);
}
onListItemTap(int index) {
onListItemTap(BuildContext context, int index) {
if (index == 1) {
//点击国家
_provide.clickCity();
Provider.of<SettingProvide>(context).clickCity();
} else if (index == 2) {
//ins
_provide.clickIns();
Provider.of<SettingProvide>(context).clickIns();
} else if (index == 3) {
//意见
_provide.clickArguement();
Provider.of<SettingProvide>(context).clickArguement();
}
}
clickAction() {
Provider.of<SettingProvide>(context).clickLeft();
}
}
class my extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
// TODO: implement paint
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
// TODO: implement shouldRepaint
return null;
}
}
class CircleView extends SingleChildRenderObjectWidget {
@override
RenderObject createRenderObject(BuildContext context) {
return null;
}
}
//class A extends StatefulWidget{
//
//
// A(
// ......
//
// ){
// .........
// }
//
//
//
// @override
// State<StatefulWidget> createState() {
// // TODO: implement createState
// return null;
// }
//
//}
//
//class st extends State{
// @override
// Widget build(BuildContext context) {
//
// return Container(
//
//
// )
// }
//}
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