Skip to content

Commit 160a879

Browse files
FlutterOdandrii-bodnar
authored andcommitted
pr comments fixes
1 parent b15a5d5 commit 160a879

File tree

9 files changed

+67
-156
lines changed

9 files changed

+67
-156
lines changed

.flutter-plugins-dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.1.0/","native_build":true,"dependencies":[]},{"name":"shared_preferences","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-2.0.2/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.1.0/","native_build":true,"dependencies":[]},{"name":"shared_preferences","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-2.0.2/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.6/","native_build":true,"dependencies":[]},{"name":"shared_preferences_macos","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-2.0.2/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus_linux","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.1.0/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.6/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_linux-2.0.4/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"connectivity_plus_windows","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.0.6/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_windows-2.0.4/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"connectivity_plus_web","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.1.0+1/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-2.0.4/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":["connectivity_plus_linux","connectivity_plus_macos","connectivity_plus_web","connectivity_plus_windows"]},{"name":"connectivity_plus_linux","dependencies":[]},{"name":"connectivity_plus_macos","dependencies":[]},{"name":"connectivity_plus_web","dependencies":[]},{"name":"connectivity_plus_windows","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2023-02-19 23:03:53.495512","version":"3.3.10"}
1+
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.1.0/","native_build":true,"dependencies":[]},{"name":"shared_preferences","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-2.0.2/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.1.0/","native_build":true,"dependencies":[]},{"name":"shared_preferences","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-2.0.2/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.6/","native_build":true,"dependencies":[]},{"name":"shared_preferences_macos","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-2.0.2/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus_linux","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.1.0/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.6/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_linux-2.0.4/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"connectivity_plus_windows","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.0.6/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_windows-2.0.4/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"connectivity_plus_web","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.1.0+1/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/yurii/src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-2.0.4/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":["connectivity_plus_linux","connectivity_plus_macos","connectivity_plus_web","connectivity_plus_windows"]},{"name":"connectivity_plus_linux","dependencies":[]},{"name":"connectivity_plus_macos","dependencies":[]},{"name":"connectivity_plus_web","dependencies":[]},{"name":"connectivity_plus_windows","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2023-02-22 15:48:18.008821","version":"3.3.10"}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
.history
1010
.svn/
1111
migrate_working_dir/
12+
.flutter-plugins
13+
.flutter-plugins-dependencies
1214

1315
# IntelliJ related
1416
*.iml
@@ -29,4 +31,8 @@ migrate_working_dir/
2931
.packages
3032
build/
3133

34+
.pub-cache/
35+
.pub/
36+
/build/
37+
3238
*.env

example/README.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
# example
22

3-
example project
3+
Simple project to demonstrate how to use Crowdin SDK
44

55
## Getting Started
66

7-
This project is a starting point for a Flutter application.
7+
To run example project follow next steps:
88

9-
A few resources to get you started if this is your first Flutter project:
10-
11-
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12-
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
13-
14-
For help getting started with Flutter development, view the
15-
[online documentation](https://docs.flutter.dev/), which offers tutorials,
16-
samples, guidance on mobile development, and a full API reference.
9+
1. Clone repository from GitHub
10+
2. Create project on [Crowdin](https://crowdin.com/). Use texts_en.arb file from this project (flutter-sdk/example/lib/l10n/texts_en.arb) as source file.
11+
3. Run 'pup get' command to get project dependencies
12+
4. Run 'flutter gen-l10n'
13+
5. Run 'flutter pub run crowdin_sdk:gen' to generate Crowdin localization
14+
6. Provide your distribution hash to Crowdin initialization in 'main' function
15+
```
16+
void main() async {
17+
WidgetsFlutterBinding.ensureInitialized();
18+
Crowdin.init(
19+
distributionHash: 'your distribution hash',
20+
...
21+
);
22+
...
23+
}
24+
```
25+
8. Run the application

example/lib/main.dart

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
11
import 'package:crowdin_sdk/crowdin_sdk.dart';
22
import 'package:flutter/material.dart';
33
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
4-
54
import 'package:flutter_gen/gen_l10n/crowdin_localizations.dart';
6-
import 'dart:io';
7-
8-
import 'package:flutter_dotenv/flutter_dotenv.dart';
95

10-
final GlobalKey<ScaffoldState> _key = GlobalKey();
11-
12-
List<Locale> locales = const [
13-
Locale('en'),
14-
Locale('uk'),
15-
Locale('it'),
16-
Locale('he'),
17-
];
6+
import 'package:intl/intl.dart';
187

198
void main() async {
209
WidgetsFlutterBinding.ensureInitialized();
21-
await dotenv.load(fileName: ".env");
2210
Crowdin.init(
23-
distributionHash: dotenv.env['DISTRIBUTION_HASH'] ?? '', //your distribution hash
11+
distributionHash: 'your distribution hash', //your distribution hash
2412
connectionType: InternetConnectionType.mobileData,
2513
distributionTtl: const Duration(minutes: 25),
2614
);
@@ -40,18 +28,18 @@ class _MyHomePageState extends State<MyHomePage> {
4028
super.initState();
4129
}
4230

43-
Locale currentLocale = Locale(Locale(Platform.localeName).toLanguageTag());
31+
Locale currentLocale = Locale(Intl.shortLocale(Intl.systemLocale));
4432

4533
@override
4634
Widget build(BuildContext context) {
4735
return MaterialApp(
4836
locale: currentLocale,
4937
localizationsDelegates: CrowdinLocalization.localizationsDelegates,
50-
supportedLocales: locales,
38+
supportedLocales: AppLocalizations.supportedLocales,
5139
theme: ThemeData(
5240
primarySwatch: Colors.blue,
5341
),
54-
home: Home(
42+
home: MainScreen(
5543
changeLocale: (locale) => {
5644
setState(() {
5745
currentLocale = locale;
@@ -62,20 +50,18 @@ class _MyHomePageState extends State<MyHomePage> {
6250
}
6351
}
6452

65-
class Home extends StatefulWidget {
53+
class MainScreen extends StatefulWidget {
6654
final void Function(Locale locale) changeLocale;
6755

68-
const Home({Key? key, required this.changeLocale}) : super(key: key);
56+
const MainScreen({Key? key, required this.changeLocale}) : super(key: key);
6957

7058
@override
71-
State<Home> createState() => _HomeState();
59+
State<MainScreen> createState() => _MainScreenState();
7260
}
7361

74-
class _HomeState extends State<Home> {
75-
String dropdownValue = locales.first.languageCode;
62+
class _MainScreenState extends State<MainScreen> {
7663

7764
int _counter = 0;
78-
7965
void _incrementCounter() {
8066
setState(() {
8167
_counter++;
@@ -86,7 +72,6 @@ class _HomeState extends State<Home> {
8672
Widget build(BuildContext context) {
8773
return Scaffold(
8874
drawer: Drawer(
89-
key: _key,
9075
child: ListView(
9176
padding: EdgeInsets.zero,
9277
children: [
@@ -142,11 +127,6 @@ class _HomeState extends State<Home> {
142127
AppLocalizations.of(context)!.counter(_counter),
143128
style: const TextStyle(fontSize: 30),
144129
),
145-
const SizedBox(height: 16),
146-
Text(
147-
AppLocalizations.of(context)!.nThings(0, 'thing'),
148-
style: const TextStyle(fontSize: 30),
149-
),
150130
],
151131
),
152132
),
@@ -188,15 +168,12 @@ class _SettingsScreenState extends State<SettingsScreen> {
188168
iconSize: 40,
189169
value: AppLocalizations.of(context)!.localeName,
190170
items: [
191-
...locales
171+
...AppLocalizations.supportedLocales
192172
.map((locale) => DropdownMenuItem<String>(
193173
value: locale.languageCode,
194174
onTap: () async {
195175
await Crowdin.getDistribution(locale);
196176
widget.onLanguageChanged(locale);
197-
setState(() {
198-
// dropdownValue = locale.languageCode;
199-
});
200177
},
201178
child: Text(locale.languageCode),
202179
))

example/pubspec.lock

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,6 @@ packages:
132132
description: flutter
133133
source: sdk
134134
version: "0.0.0"
135-
flutter_dotenv:
136-
dependency: "direct main"
137-
description:
138-
name: flutter_dotenv
139-
url: "https://pub.dartlang.org"
140-
source: hosted
141-
version: "5.0.2"
142135
flutter_lints:
143136
dependency: "direct dev"
144137
description:

example/pubspec.yaml

Lines changed: 6 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,38 @@
11
name: example
2-
description: example project
2+
description: Simple project to demonstrate how to use Crowdin SDK
3+
34

4-
# The following line prevents the package from being accidentally published to
5-
# pub.dev using `flutter pub publish`. This is preferred for private packages.
65
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
76

8-
# The following defines the version and build number for your application.
9-
# A version number is three numbers separated by dots, like 1.2.43
10-
# followed by an optional build number separated by a +.
11-
# Both the version and the builder number may be overridden in flutter
12-
# build by specifying --build-name and --build-number, respectively.
13-
# In Android, build-name is used as versionName while build-number used as versionCode.
14-
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
15-
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
16-
# Read more about iOS versioning at
17-
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
18-
# In Windows, build-name is used as the major, minor, and patch parts
19-
# of the product and file versions while build-number is used as the build suffix.
207
version: 1.0.0+1
218

229
environment:
2310
sdk: '>=2.18.6 <3.0.0'
2411

25-
# Dependencies specify other packages that your package needs in order to work.
26-
# To automatically upgrade your package dependencies to the latest versions
27-
# consider running `flutter pub upgrade --major-versions`. Alternatively,
28-
# dependencies can be manually updated by changing the version numbers below to
29-
# the latest version available on pub.dev. To see which dependencies have newer
30-
# versions available, run `flutter pub outdated`.
3112
dependencies:
3213
flutter:
3314
sdk: flutter
3415
flutter_localizations:
3516
sdk: flutter
3617
intl: 0.17.0
37-
flutter_dotenv: 5.0.2
3818

19+
# In your real app use:
20+
# crowdin_sdk: x.x.x
3921
crowdin_sdk:
4022
path: ../
4123

42-
# The following adds the Cupertino Icons font to your application.
43-
# Use with the CupertinoIcons class for iOS style icons.
24+
4425
cupertino_icons: ^1.0.2
4526

4627
dev_dependencies:
4728
flutter_test:
4829
sdk: flutter
4930

50-
# The "flutter_lints" package below contains a set of recommended lints to
51-
# encourage good coding practices. The lint set provided by the package is
52-
# activated in the `analysis_options.yaml` file located at the root of your
53-
# package. See that file for information about deactivating specific lint
54-
# rules and activating additional ones.
5531
flutter_lints: ^2.0.0
5632

57-
# For information on the generic Dart part of this file, see the
58-
# following page: https://dart.dev/tools/pub/pubspec
59-
6033
# The following section is specific to Flutter packages.
6134
flutter:
6235
generate: true
63-
# The following line ensures that the Material Icons font is
64-
# included with your application, so that you can use the icons in
65-
# the material Icons class.
66-
uses-material-design: true
6736

68-
# To add assets to your application, add an assets section, like this:
69-
assets:
70-
- .env
71-
72-
# An image asset can refer to one or more resolution-specific "variants", see
73-
# https://flutter.dev/assets-and-images/#resolution-aware
74-
75-
# For details regarding adding assets from package dependencies, see
76-
# https://flutter.dev/assets-and-images/#from-packages
37+
uses-material-design: true
7738

78-
# To add custom fonts to your application, add a fonts section here,
79-
# in this "flutter" section. Each entry in this list should have a
80-
# "family" key with the font family name, and a "fonts" key with a
81-
# list giving the asset and other descriptors for the font. For
82-
# example:
83-
# fonts:
84-
# - family: Schyler
85-
# fonts:
86-
# - asset: fonts/Schyler-Regular.ttf
87-
# - asset: fonts/Schyler-Italic.ttf
88-
# style: italic
89-
# - family: Trajan Pro
90-
# fonts:
91-
# - asset: fonts/TrajanPro.ttf
92-
# - asset: fonts/TrajanPro_Bold.ttf
93-
# weight: 700
94-
#
95-
# For details regarding fonts from package dependencies,
96-
# see https://flutter.dev/custom-fonts/#from-packages

example/test/widget_test.dart

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
1-
// // This is a basic Flutter widget test.
2-
// //
3-
// // To perform an interaction with a widget in your test, use the WidgetTester
4-
// // utility in the flutter_test package. For example, you can send tap and scroll
5-
// // gestures. You can also use WidgetTester to find child widgets in the widget
6-
// // tree, read text, and verify that the values of widget properties are correct.
1+
// This is a basic Flutter widget test.
72
//
8-
// import 'package:flutter/material.dart';
9-
// import 'package:flutter_test/flutter_test.dart';
10-
//
11-
// import 'package:example/main.dart';
12-
//
13-
// void main() {
14-
// testWidgets('Counter increments smoke test', (WidgetTester tester) async {
15-
// // Build our app and trigger a frame.
16-
// await tester.pumpWidget(const MyApp());
17-
//
18-
// // Verify that our counter starts at 0.
19-
// expect(find.text('0'), findsOneWidget);
20-
// expect(find.text('1'), findsNothing);
21-
//
22-
// // Tap the '+' icon and trigger a frame.
23-
// await tester.tap(find.byIcon(Icons.add));
24-
// await tester.pump();
25-
//
26-
// // Verify that our counter has incremented.
27-
// expect(find.text('0'), findsNothing);
28-
// expect(find.text('1'), findsOneWidget);
29-
// });
30-
// }
3+
// To perform an interaction with a widget in your test, use the WidgetTester
4+
// utility in the flutter_test package. For example, you can send tap and scroll
5+
// gestures. You can also use WidgetTester to find child widgets in the widget
6+
// tree, read text, and verify that the values of widget properties are correct.
7+
8+
import 'package:flutter/material.dart';
9+
import 'package:flutter_test/flutter_test.dart';
10+
11+
import 'package:example/main.dart';
12+
13+
void main() {
14+
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
15+
// Build our app and trigger a frame.
16+
await tester.pumpWidget(const MyHomePage());
17+
18+
expect(find.text('1'), findsNothing);
19+
20+
// Tap the '+' icon and trigger a frame.
21+
await tester.tap(find.byIcon(Icons.add));
22+
await tester.pump();
23+
24+
expect(find.text('0'), findsNothing);
25+
});
26+
}

lib/src/crowdin.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ class Crowdin {
7979
}
8080
} catch (ex) {
8181
throw CrowdinException('No translations on Crowdin');
82-
// throw CrowdinException('$ex');
8382
}
8483
}
8584

lib/src/crowdin_extractor.dart

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,6 @@ class Extractor {
153153
other: extractedPlurals[5],
154154
);
155155
}
156-
157-
// String? _findPlural(String formattedMessage, String pluralKey) {
158-
// final exp = RegExp('($pluralKey)\\s*{([^}]+)}');
159-
// final RegExpMatch? match = exp.firstMatch(formattedMessage);
160-
// if (match != null && match.groupCount == 2) {
161-
// return match.group(2)!;
162-
// } else {
163-
// return null;
164-
// }
165-
// }
166-
167156
}
168157

169158
@visibleForTesting

0 commit comments

Comments
 (0)