Skip to content

Commit ce3915a

Browse files
committed
Merged v1.0.22
2 parents 130121e + 7c97afb commit ce3915a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+552
-261
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ script:
1515

1616
cache:
1717
directories:
18-
- "$HOME/.pub-cache"
18+
- "$HOME/.pub-cache"

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,31 @@ or clone this repository and add to your project. As this is an early developmen
2323
Once you have the library added to your project, upon first call to your app (Similar to what your application class would be) add the following...
2424
2525
```dart
26-
Parse().initialize(
26+
await Parse().initialize(
2727
ApplicationConstants.keyApplicationId,
2828
ApplicationConstants.keyParseServerUrl);
2929
```
3030
if you want to use secure storage also that's allow using sdk on desktop application
3131
```dart
3232
33-
Parse().initialize(keyParseApplicationId, keyParseServerUrl,
33+
await Parse().initialize(keyParseApplicationId, keyParseServerUrl,
3434
masterKey: keyParseMasterKey,
3535
debug: true,
36-
coreStore: CoreStoreImp.getInstance());
36+
coreStore: await CoreStoreSembastImp.getInstance());
3737
```
3838
It's possible to add other params, such as ...
3939

4040
```dart
41-
Parse().initialize(
41+
await Parse().initialize(
4242
ApplicationConstants.keyApplicationId,
4343
ApplicationConstants.keyParseServerUrl,
4444
masterKey: ApplicationConstants.keyParseMasterKey,
4545
clientKey: ApplicationConstants.keyParseClientKey,
4646
debug: true,
4747
liveQueryUrl: ApplicationConstants.keyLiveQueryUrl,
4848
autoSendSessionId: true,
49-
securityContext: securityContext);
49+
securityContext: securityContext,
50+
coreStore: await CoreStoreSharedPrefsImp.getInstance());
5051
```
5152

5253
## Objects
@@ -133,6 +134,14 @@ and to retrieve it
133134
var dietPlan = DietPlan().fromPin('OBJECT ID OF OBJECT');
134135
```
135136

137+
## Storage
138+
We now have 2 types of storage, secure and unsecure. We currently rely on 2 third party options:
139+
140+
* SharedPreferences
141+
* Sembast
142+
143+
Sembast offers secured storage, whilst SharePreferences wraps NSUserDefaults (on iOS) and SharedPreferences (on Android).
144+
136145
## Increment Counter values in objects
137146
Retrieve it, call
138147

@@ -577,4 +586,4 @@ Objects:
577586
This project was authored by Phill Wiggins. You can contact me at [email protected]
578587
<!--stackedit_data:
579588
eyJoaXN0b3J5IjpbLTU4MDA4MDUwNCw3MTg2NTA0MjBdfQ==
580-
-->
589+
-->

example/.vscode/launch.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{
2-
3-
"version": "0.2.0",
4-
"configurations": [
5-
{
6-
"name": "Flutter Desktop Attach",
7-
"request": "attach",
8-
"observatoryUri": "http://127.0.0.1:52878/UWW_6_X9Y74=/",
9-
"type": "dart"
10-
}
11-
]
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Flutter Desktop Attach",
6+
"request": "attach",
7+
"observatoryUri": "http://127.0.0.1:52878/UWW_6_X9Y74=/",
8+
"type": "dart"
9+
}
10+
]
1211
}

example/lib/data/base/api_response.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'api_error.dart';
55
class ApiResponse {
66
ApiResponse(this.success, this.statusCode, this.results, this.error)
77
: count = results?.length ?? 0,
8-
result = results?.first;
8+
result = results?.isNotEmpty ?? false ? results.first : null;
99

1010
final bool success;
1111
final int statusCode;

example/lib/data/model/diet_plan.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ class DietPlan extends ParseObject implements ParseCloneable {
3333
set fat(num fat) => set<num>(keyFat, fat);
3434

3535
bool get status => get<bool>(keyStatus);
36+
3637
set status(bool status) => set<bool>(keyStatus, status);
3738
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const String keyApplicationName = '';
2-
const String keyParseApplicationId = '';
3-
const String keyParseMasterKey = '';
4-
const String keyParseServerUrl = '';
1+
const String keyApplicationName = 'BodyCal';
2+
const String keyParseApplicationId = 'bodycaldb';
3+
const String keyParseMasterKey = '343gf35g4t6hev445f4t5f45g45d';
4+
const String keyParseServerUrl = 'http://45.76.129.16:1338/parse/';

example/lib/main.dart

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ import 'package:flutter_plugin_example/data/repositories/diet_plan/repository_di
1010
import 'package:flutter_plugin_example/data/repositories/user/repository_user.dart';
1111
import 'package:flutter_plugin_example/domain/constants/application_constants.dart';
1212
import 'package:flutter_plugin_example/domain/utils/db_utils.dart';
13-
import 'package:flutter_stetho/flutter_stetho.dart';
1413
import 'package:parse_server_sdk/parse_server_sdk.dart';
1514

1615
void main() {
17-
Stetho.initialize();
1816
_setTargetPlatformForDesktop();
1917

2018
runApp(MyApp());
@@ -66,17 +64,20 @@ class _MyAppState extends State<MyApp> {
6664
Future<void> initData() async {
6765
// Initialize repository
6866
await initRepository();
67+
final CoreStore coreStore = await initCoreStore();
6968

7069
// Initialize parse
71-
Parse().initialize(keyParseApplicationId, keyParseServerUrl,
72-
masterKey: keyParseMasterKey, debug: true);
70+
await Parse().initialize(keyParseApplicationId, keyParseServerUrl,
71+
masterKey: keyParseMasterKey,
72+
debug: true,
73+
coreStore: await CoreStoreSharedPrefsImp.getInstance());
7374

7475
//parse serve with secure store and desktop support
7576

7677
// Parse().initialize(keyParseApplicationId, keyParseServerUrl,
7778
// masterKey: keyParseMasterKey,
7879
// debug: true,
79-
// coreStore: CoreStoreImp.getInstance());
80+
// coreStore: CoreStoreSharedPrefsImp.getInstance());
8081

8182
// Check server is healthy and live - Debug is on in this instance so check logs for result
8283
final ParseResponse response = await Parse().healthCheck();
@@ -303,7 +304,7 @@ class _MyAppState extends State<MyApp> {
303304
if (result.success) {
304305
if (result.result is ParseObject) {
305306
final ParseObject parseObject = result.result;
306-
print(parseObject.className);
307+
print(parseObject.parseClassName);
307308
}
308309
}
309310
}
@@ -371,6 +372,15 @@ class _MyAppState extends State<MyApp> {
371372
dietPlanRepo ??= DietPlanRepository.init(await getDB());
372373
userRepo ??= UserRepository.init(await getDB());
373374
}
375+
376+
377+
/// Available options:
378+
/// SharedPreferences - Not secure but will work with older versions of SDK - CoreStoreSharedPrefsImpl
379+
/// Sembast - NoSQL DB - Has security - CoreStoreSembastImpl
380+
Future<CoreStore> initCoreStore() async {
381+
//return CoreStoreSembastImp.getInstance();
382+
return CoreStoreSharedPrefsImp.getInstance();
383+
}
374384
}
375385

376386
const String dietPlansToAdd =

example/lib/pages/decision_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class _DecisionPageState extends State<DecisionPage> {
6161

6262
Future<void> _initParse() async {
6363
try {
64-
Parse().initialize(keyParseApplicationId, keyParseServerUrl,
64+
await Parse().initialize(keyParseApplicationId, keyParseServerUrl,
6565
masterKey: keyParseMasterKey, debug: true);
6666
final ParseResponse response = await Parse().healthCheck();
6767
if (response.success) {

example/lib/pages/login_page.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ class _LoginPageState extends State<LoginPage> {
185185
Icons.mail,
186186
color: Colors.grey,
187187
)),
188-
validator: (String value) => value.isEmpty ? 'Email can\'t be empty' : null,
188+
validator: (String value) =>
189+
value.isEmpty ? 'Email can\'t be empty' : null,
189190
onSaved: (String value) => _email = value,
190191
),
191192
);
@@ -204,7 +205,8 @@ class _LoginPageState extends State<LoginPage> {
204205
Icons.lock,
205206
color: Colors.grey,
206207
)),
207-
validator: (String value) => value.isEmpty ? 'Password can\'t be empty' : null,
208+
validator: (String value) =>
209+
value.isEmpty ? 'Password can\'t be empty' : null,
208210
onSaved: (String value) => _password = value,
209211
),
210212
);
Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
11
{
2-
"images" : [
2+
"images": [
33
{
4-
"idiom" : "mac",
5-
"size" : "16x16",
6-
"scale" : "1x"
4+
"idiom": "mac",
5+
"size": "16x16",
6+
"scale": "1x"
77
},
88
{
9-
"idiom" : "mac",
10-
"size" : "16x16",
11-
"scale" : "2x"
9+
"idiom": "mac",
10+
"size": "16x16",
11+
"scale": "2x"
1212
},
1313
{
14-
"idiom" : "mac",
15-
"size" : "32x32",
16-
"scale" : "1x"
14+
"idiom": "mac",
15+
"size": "32x32",
16+
"scale": "1x"
1717
},
1818
{
19-
"idiom" : "mac",
20-
"size" : "32x32",
21-
"scale" : "2x"
19+
"idiom": "mac",
20+
"size": "32x32",
21+
"scale": "2x"
2222
},
2323
{
24-
"idiom" : "mac",
25-
"size" : "128x128",
26-
"scale" : "1x"
24+
"idiom": "mac",
25+
"size": "128x128",
26+
"scale": "1x"
2727
},
2828
{
29-
"idiom" : "mac",
30-
"size" : "128x128",
31-
"scale" : "2x"
29+
"idiom": "mac",
30+
"size": "128x128",
31+
"scale": "2x"
3232
},
3333
{
34-
"idiom" : "mac",
35-
"size" : "256x256",
36-
"scale" : "1x"
34+
"idiom": "mac",
35+
"size": "256x256",
36+
"scale": "1x"
3737
},
3838
{
39-
"idiom" : "mac",
40-
"size" : "256x256",
41-
"scale" : "2x"
39+
"idiom": "mac",
40+
"size": "256x256",
41+
"scale": "2x"
4242
},
4343
{
44-
"idiom" : "mac",
45-
"size" : "512x512",
46-
"scale" : "1x"
44+
"idiom": "mac",
45+
"size": "512x512",
46+
"scale": "1x"
4747
},
4848
{
49-
"idiom" : "mac",
50-
"size" : "512x512",
51-
"scale" : "2x"
49+
"idiom": "mac",
50+
"size": "512x512",
51+
"scale": "2x"
5252
}
5353
],
54-
"info" : {
55-
"version" : 1,
56-
"author" : "xcode"
54+
"info": {
55+
"version": 1,
56+
"author": "xcode"
5757
}
5858
}

example/pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ dependencies:
88
# The following adds the Cupertino Icons font to your application.
99
# Use with the CupertinoIcons class for iOS style icons.
1010
cupertino_icons: ^0.1.2
11-
flutter_stetho: ^0.2.2
1211
sembast: ^1.13.3+1
1312
shared_preferences: ^0.5.0
1413

example/test/data/repository/diet_plan/repository_diet_plan_api_test.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void main() {
3434
test('add DietPlan from API', () async {
3535
// Given
3636
final DietPlan expected = getDummyDietPlan();
37-
expected.getObjectData()['objectId'] = null;
37+
expected['objectId'] = null;
3838

3939
// When
4040
final ApiResponse response = await repository.add(expected);
@@ -51,11 +51,11 @@ void main() {
5151
// Given
5252
final List<DietPlan> actual = List<DietPlan>();
5353
final DietPlan item1 = getDummyDietPlan();
54-
item1.getObjectData()['objectId'] = null;
54+
item1['objectId'] = null;
5555
item1.protein = 5;
5656
actual.add(item1);
5757
final DietPlan item2 = getDummyDietPlan();
58-
item2.getObjectData()['objectId'] = null;
58+
item2['objectId'] = null;
5959
item2.protein = 6;
6060
actual.add(item2);
6161

@@ -74,7 +74,7 @@ void main() {
7474
test('getById DietPlan from API', () async {
7575
// Given
7676
final DietPlan dummy = getDummyDietPlan();
77-
dummy.getObjectData()['objectId'] = null;
77+
dummy['objectId'] = null;
7878

7979
// When
8080
final ApiResponse response = await repository.add(dummy);
@@ -95,7 +95,7 @@ void main() {
9595
test('getNewerThan DietPlan from API', () async {
9696
// Given
9797
final DietPlan dummy = getDummyDietPlan();
98-
dummy.getObjectData()['objectId'] = null;
98+
dummy['objectId'] = null;
9999

100100
// When
101101
final ApiResponse baseResponse = await repository.add(dummy);
@@ -120,11 +120,11 @@ void main() {
120120
final List<DietPlan> actual = List<DietPlan>();
121121

122122
final DietPlan item1 = getDummyDietPlan();
123-
item1.getObjectData()['objectId'] = null;
123+
item1['objectId'] = null;
124124
item1.protein = 5;
125125
actual.add(item1);
126126
final DietPlan item2 = getDummyDietPlan();
127-
item2.getObjectData()['objectId'] = null;
127+
item2['objectId'] = null;
128128
item2.protein = 6;
129129
actual.add(item2);
130130

@@ -142,7 +142,7 @@ void main() {
142142
test('update DietPlan from API', () async {
143143
// Given
144144
final DietPlan expected = getDummyDietPlan();
145-
expected.getObjectData()['objectId'] = null;
145+
expected['objectId'] = null;
146146
final ApiResponse response = await repository.add(expected);
147147
final DietPlan initialResponse = response.result;
148148

@@ -165,11 +165,11 @@ void main() {
165165
final List<DietPlan> actual = List<DietPlan>();
166166

167167
final DietPlan item1 = getDummyDietPlan();
168-
item1.getObjectData()['objectId'] = null;
168+
item1['objectId'] = null;
169169
item1.protein = 7;
170170
actual.add(item1);
171171
final DietPlan item2 = getDummyDietPlan();
172-
item2.getObjectData()['objectId'] = null;
172+
item2['objectId'] = null;
173173
item2.protein = 8;
174174
actual.add(item2);
175175
await repository.addAll(actual);

example/test/data/repository/diet_plan/repository_diet_plan_db_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void main() {
126126
// Given
127127
final DietPlan expected = getDummyDietPlan();
128128
// ignore: invalid_use_of_protected_member
129-
expected.getObjectData()[keyVarUpdatedAt] = DateTime.now();
129+
expected[keyVarUpdatedAt] = DateTime.now();
130130
final ApiResponse response = await repository.add(expected);
131131

132132
// When

0 commit comments

Comments
 (0)