Skip to content

fixed something #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Flutter",
"type": "dart",
"request": "launch",
"program": "example/lib/main.dart"
}
]
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Parse Server Dart

A rewrite of a library hosted on GitHub. This is not my own content but based on a library already created and looks to be abandoned.

https://github.com/lotux/parse_server_dart

## Join in!
Want to get involved? Join our Slack channel and help out! FlutterParseSDK.Slack.com
## example 目录有完整测试

## Getting Started

Expand Down
11 changes: 6 additions & 5 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# flutter_plugin_example
# flutter_parse_client_example

Demonstrates how to use the flutter_plugin plugin.
Demonstrates how to use the flutter parse client.

## Getting Started
## html ok

For help getting started with Flutter, view our online
[documentation](https://flutter.io/).
## websoket ok

## bloc
17 changes: 17 additions & 0 deletions example/android/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>android</name>
<comment>Project android created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
2 changes: 2 additions & 0 deletions example/android/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
connection.project.dir=
eclipse.preferences.version=1
6 changes: 6 additions & 0 deletions example/android/app/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
23 changes: 23 additions & 0 deletions example/android/app/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>app</name>
<comment>Project app created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
connection.project.dir=..
eclipse.preferences.version=1
22 changes: 17 additions & 5 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

Expand All @@ -24,10 +34,10 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.flutterpluginexample"
minSdkVersion 16
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand All @@ -46,6 +56,8 @@ flutter {

dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// implementation "com.android.support:appcompat-v7:27.1.0"
}
// apply plugin: 'com.google.gms.google-services'
2 changes: 1 addition & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="flutter_plugin_example"
android:label="parse_example"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
Expand Down
15 changes: 14 additions & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.0.1'
}
}

allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}

Expand All @@ -27,3 +29,14 @@ subprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}

subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.1.0"
}
}
}
}
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Empty file modified example/android/gradlew
100644 → 100755
Empty file.
38 changes: 38 additions & 0 deletions example/lib/ApplicationBloc.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'dart:async';

import 'package:Parse_example/blocProvider.dart';
import 'package:parse_server_sdk/network/parse_livequery.dart';

class ApplicationBloc implements BlocBase {
///
/// Synchronous Stream to handle the provision of the movie genres
///
StreamController<List> _syncController = StreamController<List>.broadcast();
Stream<List> get outParseStream => _syncController.stream;

///
StreamController<List> _cmdController = StreamController<List>.broadcast();
StreamSink get getMovieGenres => _cmdController.sink;

List _genresList;

ApplicationBloc(LiveQuery liveQuery) {
// _genresList = liveQuery.channel as List;
// Read all genres from Internet
// api.movieGenres().then((list) {
// _genresList = list;
// });
_syncController.stream.listen((_) {
_syncController.sink.addStream(liveQuery.channel.stream);
});
// _cmdController.stream.listen((_) {
// _syncController.sink
// .add(UnmodifiableListView<MovieGenre>(_genresList.genres));
// });
}

void dispose() {
_syncController.close();
_cmdController.close();
}
}
32 changes: 32 additions & 0 deletions example/lib/IncrementBloc.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'dart:async';

import 'package:Parse_example/blocProvider.dart';

class IncrementBloc implements BlocBase {
int _counter;

// 处理counter的stream
StreamController<int> _counterController = StreamController<int>();
StreamSink<int> get _inAdd => _counterController.sink;
Stream<int> get outCounter => _counterController.stream;

// 处理业务逻辑的stream
StreamController _actionController = StreamController();
StreamSink get incrementCounter => _actionController.sink;

// 构造器
IncrementBloc() {
_counter = 0;
_actionController.stream.listen(_handleLogic);
}

void dispose() {
_actionController.close();
_counterController.close();
}

void _handleLogic(data) {
_counter = _counter + 1;
_inAdd.add(_counter);
}
}
11 changes: 6 additions & 5 deletions example/lib/application_constants.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
abstract class ApplicationConstants {
static const String APP_NAME = "";
static const String PARSE_APPLICATION_ID = "";
static const String PARSE_MASTER_KEY = "";
static const String PARSE_SERVER_URL = "";
}
static const String APP_NAME = "MyApp";
static const String PARSE_APPLICATION_ID = "myAppId";
static const String PARSE_MASTER_KEY = "123456";
static const String PARSE_SERVER_URL = "http://118.24.162.252:2018/parse";
static const String PARSE_LIVE_SERVER_URL = "ws://118.24.162.252:2018/parse";
}
40 changes: 40 additions & 0 deletions example/lib/blocProvider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:flutter/material.dart';

abstract class BlocBase {
void dispose();
}

class BlocProvider<T extends BlocBase> extends StatefulWidget {
BlocProvider({
Key key,
@required this.child,
@required this.bloc,
}) : super(key: key);

final T bloc;
final Widget child;

@override
_BlocProviderState<T> createState() => _BlocProviderState<T>();

static T of<T extends BlocBase>(BuildContext context) {
final type = _typeOf<BlocProvider<T>>();
BlocProvider<T> provider = context.ancestorWidgetOfExactType(type);
return provider.bloc;
}

static Type _typeOf<T>() => T;
}

class _BlocProviderState<T> extends State<BlocProvider<BlocBase>> {
@override
void dispose() {
widget.bloc.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return widget.child;
}
}
19 changes: 19 additions & 0 deletions example/lib/count_bloc.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'dart:async';
import 'package:Parse_example/blocProvider.dart';
import 'package:rxdart/rxdart.dart';

class CountBLoC implements BlocBase {
int _count = 0;
var _countController = StreamController<int>.broadcast();
var _subject = BehaviorSubject<int>();
Stream<int> get stream => _subject.stream;
int get value => _count;

increment() {
_countController.sink.add(++_count);
}

dispose() {
_countController.close();
}
}
34 changes: 17 additions & 17 deletions example/lib/diet_plan.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@ class DietPlan extends ParseObject {
num fat;
num status;

static const String DIET_PLAN = 'Diet_Plans';
static const String NAME = 'Name';
static const String DESCRIPTION = 'Description';
static const String PROTEIN = 'Protein';
static const String CARBS = 'Carbs';
static const String FAT = 'Fat';
static const String STATUS = 'Status';
static const String DIET_PLAN = 'post';
static const String NAME = 'title';
// static const String DESCRIPTION = 'text';
// static const String PROTEIN = 'Protein';
// static const String CARBS = 'Carbs';
// static const String FAT = 'Fat';
// static const String STATUS = 'Status';

@override
dynamic fromJson(Map<String, dynamic> objectData) {
this.name = objectData[NAME];
this.description = objectData[DESCRIPTION];
this.protein = objectData[PROTEIN];
this.carbs = objectData[CARBS];
this.fat = objectData[FAT];
this.status = objectData[STATUS];
// this.description = objectData[DESCRIPTION];
// this.protein = objectData[PROTEIN];
// this.carbs = objectData[CARBS];
// this.fat = objectData[FAT];
// this.status = objectData[STATUS];
return this;
}

Map<String, dynamic> toJson() => {
NAME: name,
DESCRIPTION: description,
PROTEIN: protein,
CARBS: carbs,
FAT: fat,
STATUS: status,
// DESCRIPTION: description,
// PROTEIN: protein,
// CARBS: carbs,
// FAT: fat,
// STATUS: status,
};

@override
Expand Down
Loading