Skip to content

Commit a5fad90

Browse files
authored
Merge pull request #11 from StringCare/develop
Develop
2 parents 1166dc7 + c399e7c commit a5fad90

21 files changed

+434
-251
lines changed

.pubignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
stringcare.iml
2+
3+
*.lock
4+
.dart_tool
5+
.DS_Store
6+
.idea/

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 0.1.0
2+
3+
* Added `string()` method for getting resources.
4+
* Added `withLang` for overriding current language (string format).
5+
* Added `withLocale` for overriding current language (locale format).
6+
* Added `RemoteLanguages` for overriding translations at runtime.
7+
18
## 0.0.1
29

3-
* TODO: Describe initial release.
10+
* Initial version.

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ Flutter plugin for encrypt/decrypt `String` and `Uint8List` objects easily with
1313

1414
-----
1515

16-
Simplify the way you work with secured resources, Strings and Uint8List objects:
17-
18-
```dart
19-
"my_secret".obfuscate();
20-
```
16+
Retrieve any string resource quickly and easily, anywhere:
2117

2218
`en.json`
2319

@@ -28,7 +24,13 @@ Simplify the way you work with secured resources, Strings and Uint8List objects:
2824
```
2925

3026
```dart
31-
R.strings.hello_there.on(context);
27+
R.strings.hello_there.string();
28+
```
29+
30+
Simplify the way you work with secured resources, Strings and Uint8List objects:
31+
32+
```dart
33+
"my_secret".obfuscate();
3234
```
3335

3436
-----

bin/obfuscate.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:stringcare/src/compile/utils.dart';
22

33
void main(List<String> arguments) async {
4-
print(introMessage('0.0.2'));
4+
print(introMessage('0.1.0'));
55

66
var config = loadConfigFile();
77

@@ -12,4 +12,4 @@ void main(List<String> arguments) async {
1212
var stringKeys = await processLangObfuscation(config);
1313

1414
buildRFile(config, assetsPaths, stringKeys);
15-
}
15+
}

bin/reveal.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:stringcare/src/compile/utils.dart';
22

33
void main(List<String> arguments) async {
4-
print(introMessage('0.0.2'));
4+
print(introMessage('0.1.0'));
55

66
var config = loadConfigFile();
77

example/lib/main.dart

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'presenter.dart';
88
import 'r.dart';
99

1010
void main() {
11-
Stringcare.locales = [
11+
Stringcare().locales = [
1212
Locale('en', ''),
1313
Locale('es', ''),
1414
Locale('es', 'AR'),
@@ -29,17 +29,22 @@ class _MyAppState extends State<MyApp> {
2929
@override
3030
Widget build(BuildContext context) {
3131
return new MaterialApp(
32-
supportedLocales: Stringcare.locales,
33-
localizationsDelegates: Stringcare.delegates,
34-
localeResolutionCallback: Stringcare.localeResolutionCallback,
35-
home: MyAppPage(presenter: widget.presenter));
32+
navigatorKey: Stringcare().navigatorKey,
33+
supportedLocales: Stringcare().locales,
34+
localizationsDelegates: Stringcare().delegates,
35+
localeResolutionCallback: Stringcare().localeResolutionCallback,
36+
home: MyAppPage(presenter: widget.presenter),
37+
);
3638
}
3739
}
3840

3941
class MyAppPage extends StatefulWidget {
4042
final Presenter presenter;
4143

42-
MyAppPage({Key key, this.presenter}) : super(key: key);
44+
MyAppPage({
45+
Key? key,
46+
required this.presenter,
47+
}) : super(key: key);
4348

4449
@override
4550
MyAppPageState createState() => MyAppPageState();
@@ -62,10 +67,10 @@ class MyAppPageState extends State<MyAppPage> {
6267

6368
// Platform messages are asynchronous, so we initialize in an async method.
6469
Future<void> initPlatformState() async {
65-
String platformVersion;
70+
String? platformVersion;
6671
// Platform messages may fail, so we use a try/catch PlatformException.
6772
try {
68-
platformVersion = await Stringcare.platformVersion;
73+
platformVersion = await Stringcare().platformVersion;
6974
} on PlatformException {
7075
platformVersion = 'Failed to get platform version.';
7176
}
@@ -76,7 +81,7 @@ class MyAppPageState extends State<MyAppPage> {
7681
if (!mounted) return;
7782

7883
setState(() {
79-
_platformVersion = platformVersion;
84+
_platformVersion = platformVersion ?? '';
8085
});
8186
}
8287

@@ -106,20 +111,23 @@ class MyAppPageState extends State<MyAppPage> {
106111
ListTile(
107112
title: Text("Test hash"),
108113
),
109-
Text(Stringcare.testHash([])),
114+
Text(Stringcare().testHash([])),
110115
ListTile(
111116
title: Text("Test sign"),
112117
),
113-
Text(Stringcare.testSign([])),
118+
Text(Stringcare().testSign([])),
114119
ListTile(
115120
title: Text("Lang resource"),
116121
),
117-
Text(R.strings.hello_there.on(context)),
122+
Text(R.strings.hello_there.string()),
118123
ListTile(
119124
title: Text("Lang pattern resource"),
120125
),
121-
Text(R.strings.hello_format
122-
.on(context, values: ["Tom"])),
126+
Text(
127+
R.strings.hello_format.string(
128+
values: ["Tom"],
129+
),
130+
),
123131
ListTile(
124132
title: Text("Retrieving specific lang"),
125133
),
@@ -271,14 +279,18 @@ class MyAppPageState extends State<MyAppPage> {
271279
width: 400,
272280
),
273281
Container(
274-
decoration: BoxDecoration(
275-
image: DecorationImage(
282+
height: 400,
283+
width: 400,
284+
decoration: BoxDecoration(
285+
image: DecorationImage(
276286
fit: BoxFit.none,
277287
image: ScAssetImageProvider(
278288
R.assets.images_voyager_jpeg),
279289
repeat: ImageRepeat.repeat,
280-
)),
281-
child: Text("Voyager")),
290+
),
291+
),
292+
child: Text("Voyager"),
293+
),
282294
],
283295
),
284296
),

example/lib/presenter.dart

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ class Presenter {
66
String p2 = "sfvsfdgvsdfvsfdvsfvsrf";
77
String p3 = "dtlbkjdnsfvsftrglbjknd";
88

9-
String obfuscatedBlank;
10-
String revealedBlank;
11-
String obfuscatedHello;
12-
String revealedHello;
13-
String obfuscatedEmoji;
14-
String revealedEmoji;
15-
String signatureEmoji;
16-
String readableEmoji;
17-
bool sameSignatureTestEmoji;
18-
bool otherSignatureTestEmoji;
9+
String obfuscatedBlank = '';
10+
String revealedBlank = '';
11+
String obfuscatedHello = '';
12+
String revealedHello = '';
13+
String obfuscatedEmoji = '';
14+
String revealedEmoji = '';
15+
String signatureEmoji = '';
16+
String readableEmoji = '';
17+
bool sameSignatureTestEmoji = false;
18+
bool otherSignatureTestEmoji = false;
1919

20-
String obfuscatedLorem;
21-
String revealedLorem;
22-
String signatureLorem;
23-
String readableLorem;
24-
bool sameSignatureTestLorem;
25-
bool otherSignatureTestLorem;
20+
String obfuscatedLorem = '';
21+
String revealedLorem = '';
22+
String signatureLorem = '';
23+
String readableLorem = '';
24+
bool sameSignatureTestLorem = false;
25+
bool otherSignatureTestLorem = false;
2626

2727
Presenter() {
2828
obfuscatedBlank = Vars.blank.obfuscate();
@@ -32,20 +32,20 @@ class Presenter {
3232

3333
obfuscatedEmoji = Vars.emojis.obfuscateWith([p2, p1, p3]);
3434
revealedEmoji = obfuscatedEmoji.revealWith([p1, p3, p2]);
35-
signatureEmoji = Stringcare.getSignature([p1, p2, p3]);
35+
signatureEmoji = Stringcare().getSignature([p1, p2, p3]);
3636
readableEmoji = obfuscatedEmoji.readableObfuscate();
3737
sameSignatureTestEmoji =
38-
Stringcare.validSignature(signatureEmoji, [p3, p1, p2]);
38+
Stringcare().validSignature(signatureEmoji, [p3, p1, p2]);
3939
otherSignatureTestEmoji =
40-
Stringcare.validSignature(signatureEmoji, [p2, p3]);
40+
Stringcare().validSignature(signatureEmoji, [p2, p3]);
4141

4242
obfuscatedLorem = Vars.loremipsu.obfuscateWith([p2, p1, p3]);
4343
revealedLorem = obfuscatedLorem.revealWith([p2, p1, p3]);
44-
signatureLorem = Stringcare.getSignature([p1, p2, p3]);
44+
signatureLorem = Stringcare().getSignature([p1, p2, p3]);
4545
readableLorem = obfuscatedLorem.readableObfuscate();
4646
sameSignatureTestLorem =
47-
Stringcare.validSignature(signatureLorem, [p3, p1, p2]);
47+
Stringcare().validSignature(signatureLorem, [p3, p1, p2]);
4848
otherSignatureTestLorem =
49-
Stringcare.validSignature(signatureLorem, [p2, p3]);
49+
Stringcare().validSignature(signatureLorem, [p2, p3]);
5050
}
5151
}

example/lib/r.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
///
55
66
// ignore_for_file: non_constant_identifier_names
7-
class _Assets {
8-
_Assets();
7+
class Assets {
8+
Assets();
99

10-
final String images_coding_svg = "assets/images/coding.svg";
11-
final String images_voyager_jpeg = "assets/images/voyager.jpeg";
10+
final String images_coding_svg = 'assets/images/coding.svg';
11+
final String images_voyager_jpeg = 'assets/images/voyager.jpeg';
1212

1313
}
1414

15-
class _Strings {
16-
_Strings();
15+
class Strings {
16+
Strings();
1717

18-
final String hello_there = "hello_there";
19-
final String hello_format = "hello_format";
18+
final String hello_there = 'hello_there';
19+
final String hello_format = 'hello_format';
2020

2121
}
2222

2323
class R {
24-
static _Assets assets = _Assets();
25-
static _Strings strings = _Strings();
24+
static Assets assets = Assets();
25+
static Strings strings = Strings();
2626
}
2727

example/pubspec.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Demonstrates how to use the stringcare plugin.
44
publish_to: 'none'
55

66
environment:
7-
sdk: ">=2.7.0 <3.0.0"
7+
sdk: '>=2.19.6 <3.0.0'
88

99
dependencies:
1010
flutter:
@@ -14,7 +14,7 @@ dependencies:
1414
stringcare:
1515
path: ../
1616

17-
cupertino_icons: ^1.0.5
17+
cupertino_icons: ^1.0.6
1818

1919
stringcare:
2020
assets:
@@ -34,9 +34,7 @@ dev_dependencies:
3434
sdk: flutter
3535

3636
flutter:
37-
3837
uses-material-design: true
39-
4038
assets:
4139
- lang/en.json
4240
- lang/es.json

example/test/widget_test.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import 'package:flutter/material.dart';
99
import 'package:flutter_test/flutter_test.dart';
10-
1110
import 'package:stringcare_example/main.dart';
1211

1312
void main() {
@@ -18,8 +17,8 @@ void main() {
1817
// Verify that platform version is retrieved.
1918
expect(
2019
find.byWidgetPredicate(
21-
(Widget widget) => widget is Text &&
22-
widget.data.startsWith('Running on:'),
20+
(Widget widget) =>
21+
widget is Text && widget.data?.startsWith('Running on:') == true,
2322
),
2423
findsOneWidget,
2524
);

0 commit comments

Comments
 (0)