Skip to content
New issue

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

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

Already on GitHub? # to your account

Revert "Support Relation." #180

Merged
merged 1 commit into from
May 31, 2019
Merged
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
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ build/
.idea
example/ios/Frameworks/
example/lib/ui/

.vscode/
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
## 1.0.22

## 1.0.21
LiveQuery fix
Logout fix
Expand Down
17 changes: 1 addition & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Want to get involved? Join our Slack channel and help out! (http://flutter-parse
To install, either add to your pubspec.yaml
```yml
dependencies:
parse_server_sdk: ^1.0.22
parse_server_sdk: ^1.0.21
```
or clone this repository and add to your project. As this is an early development with multiple contributors, it is probably best to download/clone and keep updating as an when a new feature is added.

Expand Down Expand Up @@ -537,21 +537,6 @@ final Map<String, String> params = <String, String>{'plan': 'paid'};
function.execute(parameters: params);
```

## Relation
The SDK supports Relation.

To Retrive a relation instance for user, call:
```dart
final relation = user.getRelation('dietPlans');
```

and then you can add a relation to the passed in object.

```dart
relation.add(dietPlan);
final result = await user.save();
```

## Other Features of this library
Main:
* Installation (View the example application)
Expand Down
2 changes: 0 additions & 2 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@
24DF2572E6AEEB9F7CE180C9 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
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>"; };
5804EFBD11740E02FC51BC3E /* 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>"; };
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>"; };
96499D95196B10F296043703 /* 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>"; };
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>"; };
Expand Down
4 changes: 2 additions & 2 deletions example/lib/data/repositories/user/provider_db_user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class UserProviderDB implements UserProviderContract {

Map<String, dynamic> convertItemToStorageMap(User item) {
final Map<String, dynamic> values = Map<String, dynamic>();
// ignore: invalid_use_of_protected_member
values['value'] = json.jsonEncode(item.toJson(full: true));
values[keyVarObjectId] = item.objectId;
item.updatedAt != null
Expand All @@ -91,7 +90,8 @@ class UserProviderDB implements UserProviderContract {
User convertRecordToItem({Record record, Map<String, dynamic> values}) {
try {
values ??= record.value;
final User item = User.clone().fromJson(json.jsonDecode(values['value']));
final User item =
User.clone().fromJson(json.jsonDecode(values['value']));
return item;
} catch (e) {
return null;
Expand Down
86 changes: 41 additions & 45 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:flutter_plugin_example/data/repositories/diet_plan/repository_di
import 'package:flutter_plugin_example/data/repositories/user/repository_user.dart';
import 'package:flutter_plugin_example/domain/constants/application_constants.dart';
import 'package:flutter_plugin_example/domain/utils/db_utils.dart';
import 'package:flutter_plugin_example/pages/decision_page.dart';
import 'package:flutter_stetho/flutter_stetho.dart';
import 'package:parse_server_sdk/parse_server_sdk.dart';

Expand Down Expand Up @@ -40,74 +41,69 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> {
DietPlanRepository dietPlanRepo;
UserRepository userRepo;

String text = '';

@override
void initState() {
super.initState();
initData();
// initData();
}

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text(text),
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
),
);
title: 'Parse Server Example',
home: DecisionPage());
}

Future<void> initData() async {
// Initialize repository
await initRepository();
// await initRepository();

// Initialize parse
Parse().initialize(keyParseApplicationId, keyParseServerUrl,
masterKey: keyParseMasterKey, debug: true);

//parse serve with secure store and desktop support

// Parse().initialize(keyParseApplicationId, keyParseServerUrl,
// masterKey: keyParseMasterKey,
// debug: true,
// coreStore: CoreStoreImp.getInstance());

// Check server is healthy and live - Debug is on in this instance so check logs for result
final ParseResponse response = await Parse().healthCheck();

if (response.success) {
await runTestQueries();
text += 'runTestQueries\n';
print('runTestQueries');
} else {
text += 'Server health check failed';
print('Server health check failed');
}
}

Future<void> runTestQueries() async {
// Basic repository example
await repositoryAddUser();
await repositoryAddItems();
await repositoryGetAllItems();
//await repositoryAddUser();
//await repositoryAddItems();
//await repositoryGetAllItems();

//Basic usage
await createItem();
await getAllItems();
await getAllItemsByName();
await getSingleItem();
await getConfigs();
await query();
await initUser();
await initInstallation();
await function();
await functionWithParameters();
await test();
}

Future<void> initInstallation() async {
final ParseInstallation installation =
await ParseInstallation.currentInstallation();
final ParseResponse response = await installation.create();
print(response);
// createItem();
// getAllItems();
// getAllItemsByName();
// getSingleItem();
// getConfigs();
// query();
// initUser();
// var instalattion = await ParseInstallation.currentInstallation();
// var rees = instalattion.create();
// print(rees);
//function();
//functionWithParameters();
// test();
}

Future<void> test() async {
Expand Down Expand Up @@ -363,13 +359,13 @@ class _MyAppState extends State<MyApp> {
dietPlanRepo ??= DietPlanRepository.init(await getDB());
userRepo ??= UserRepository.init(await getDB());
}
}

const String dietPlansToAdd =
'[{"className":"Diet_Plans","Name":"Textbook","Description":"For an active lifestyle and a straight forward macro plan, we suggest this plan.","Fat":25,"Carbs":50,"Protein":25,"Status":0},'
'{"className":"Diet_Plans","Name":"Body Builder","Description":"Default Body Builders Diet","Fat":20,"Carbs":40,"Protein":40,"Status":0},'
'{"className":"Diet_Plans","Name":"Zone Diet","Description":"Popular with CrossFit users. Zone Diet targets similar macros.","Fat":30,"Carbs":40,"Protein":30,"Status":0},'
'{"className":"Diet_Plans","Name":"Low Fat","Description":"Low fat diet.","Fat":15,"Carbs":60,"Protein":25,"Status":0},'
'{"className":"Diet_Plans","Name":"Low Carb","Description":"Low Carb diet, main focus on quality fats and protein.","Fat":35,"Carbs":25,"Protein":40,"Status":0},'
'{"className":"Diet_Plans","Name":"Paleo","Description":"Paleo diet.","Fat":60,"Carbs":25,"Protein":10,"Status":0},'
'{"className":"Diet_Plans","Name":"Ketogenic","Description":"High quality fats, low carbs.","Fat":65,"Carbs":5,"Protein":30,"Status":0}]';
String dietPlansToAdd =
'[{"className":"Diet_Plans","Name":"Textbook","Description":"For an active lifestyle and a straight forward macro plan, we suggest this plan.","Fat":25,"Carbs":50,"Protein":25,"Status":0},'
'{"className":"Diet_Plans","Name":"Body Builder","Description":"Default Body Builders Diet","Fat":20,"Carbs":40,"Protein":40,"Status":0},'
'{"className":"Diet_Plans","Name":"Zone Diet","Description":"Popular with CrossFit users. Zone Diet targets similar macros.","Fat":30,"Carbs":40,"Protein":30,"Status":0},'
'{"className":"Diet_Plans","Name":"Low Fat","Description":"Low fat diet.","Fat":15,"Carbs":60,"Protein":25,"Status":0},'
'{"className":"Diet_Plans","Name":"Low Carb","Description":"Low Carb diet, main focus on quality fats and protein.","Fat":35,"Carbs":25,"Protein":40,"Status":0},'
'{"className":"Diet_Plans","Name":"Paleo","Description":"Paleo diet.","Fat":60,"Carbs":25,"Protein":10,"Status":0},'
'{"className":"Diet_Plans","Name":"Ketogenic","Description":"High quality fats, low carbs.","Fat":65,"Carbs":5,"Protein":30,"Status":0}]';
}
17 changes: 8 additions & 9 deletions example/windows/find_vcvars.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
import 'dart:io';

int main() {
final String programDir = Platform.environment['PROGRAMFILES(X86)'];
final String pathPrefix = '$programDir\\Microsoft Visual Studio';
const String pathSuffix = 'VC\\Auxiliary\\Build\\vcvars64.bat';
final List<String> years = <String>['2017', '2019'];
final List<String> flavors = <String>[
'Community', 'Professional', 'Enterprise', 'Preview'];
for (final String year in years) {
for (final String flavor in flavors) {
final String testPath = '$pathPrefix\\$year\\$flavor\\$pathSuffix';
final programDir = Platform.environment['PROGRAMFILES(X86)'];
final pathPrefix = '$programDir\\Microsoft Visual Studio';
const pathSuffix = 'VC\\Auxiliary\\Build\\vcvars64.bat';
final years = ['2017', '2019'];
final flavors = ['Community', 'Professional', 'Enterprise', 'Preview'];
for (final year in years) {
for (final flavor in flavors) {
final testPath = '$pathPrefix\\$year\\$flavor\\$pathSuffix';
if (File(testPath).existsSync()) {
print(testPath);
return 0;
Expand Down
12 changes: 6 additions & 6 deletions example/windows/generate_props.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import 'dart:io';

void main(List<String> arguments) {
final String outputPath = arguments[0];
final Map<String, String> settings = <String, String>{
final outputPath = arguments[0];
final settings = {
'FLUTTER_ROOT': arguments[1],
'EXTRA_BUNDLE_FLAGS': arguments[2],
};
Expand All @@ -39,16 +39,16 @@ ${getItemGroupContent(settings)}
}

String getUserMacrosContent(Map<String, String> settings) {
final StringBuffer macroList = StringBuffer();
for (final MapEntry<dynamic, dynamic> setting in settings.entries) {
final macroList = StringBuffer();
for (final setting in settings.entries) {
macroList.writeln(' <${setting.key}>${setting.value}</${setting.key}>');
}
return macroList.toString();
}

String getItemGroupContent(Map<String, String> settings) {
final StringBuffer macroList = StringBuffer();
for (final String name in settings.keys) {
final macroList = StringBuffer();
for (final name in settings.keys) {
macroList.writeln(''' <BuildMacro Include="$name">
<Value>\$($name)</Value>
<EnvironmentVariable>true</EnvironmentVariable>
Expand Down
19 changes: 12 additions & 7 deletions lib/generated/i18n.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import 'dart:async';

import 'package:flutter/foundation.dart';
Expand All @@ -12,32 +13,35 @@ class S implements WidgetsLocalizations {
const S();

static const GeneratedLocalizationsDelegate delegate =
GeneratedLocalizationsDelegate();
const GeneratedLocalizationsDelegate();

static S of(BuildContext context) =>
Localizations.of<S>(context, WidgetsLocalizations);

@override
TextDirection get textDirection => TextDirection.ltr;

}

class en extends S {
const en();
}

class GeneratedLocalizationsDelegate
extends LocalizationsDelegate<WidgetsLocalizations> {

class GeneratedLocalizationsDelegate extends LocalizationsDelegate<WidgetsLocalizations> {
const GeneratedLocalizationsDelegate();

List<Locale> get supportedLocales {
return const <Locale>[
Locale("en", ""),

const Locale("en", ""),

];
}

LocaleResolutionCallback resolution({Locale fallback}) {
return (Locale locale, Iterable<Locale> supported) {
final Locale languageLocale = Locale(locale.languageCode, "");
final Locale languageLocale = new Locale(locale.languageCode, "");
if (supported.contains(locale))
return locale;
else if (supported.contains(languageLocale))
Expand All @@ -53,11 +57,12 @@ class GeneratedLocalizationsDelegate
Future<WidgetsLocalizations> load(Locale locale) {
final String lang = getLang(locale);
switch (lang) {

case "en":
return SynchronousFuture<WidgetsLocalizations>(const en());
return new SynchronousFuture<WidgetsLocalizations>(const en());

default:
return SynchronousFuture<WidgetsLocalizations>(const S());
return new SynchronousFuture<WidgetsLocalizations>(const S());
}
}

Expand Down
Loading