Skip to content

Commit 0e02fbd

Browse files
authored
Development/dependencies and comments (crowdin#29)
1 parent 323df08 commit 0e02fbd

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

lib/src/crowdin.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class Crowdin {
4545

4646
static final _api = CrowdinApi();
4747

48+
/// if _withRealTimeUpdates = true, real-time preview is enabled and authentication is required
4849
static bool _withRealTimeUpdates = false;
4950

5051
static bool get withRealTimeUpdates => _withRealTimeUpdates;
@@ -54,8 +55,10 @@ class Crowdin {
5455
_withRealTimeUpdates = value;
5556
}
5657

58+
/// contains configuration for real-time preview functionality
5759
static late CrowdinPreviewManager crowdinPreviewManager;
5860

61+
/// contains all parameters needed for OAuth authentication
5962
static late CrowdinAuthConfig? _authConfig;
6063

6164
/// Crowdin SDK initialization

lib/src/gen/crowdin_generator.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import 'package:path/path.dart' as path;
77
import '../common/gen_l10n_types.dart';
88
import 'l10n_config.dart';
99

10-
///todo refactor to reuse getKeys in real-time preview
11-
1210
class CrowdinGenerator {
1311
static Future<void> generate() async {
1412
final String projectDirectory = Directory.current.path;

lib/src/real_time_preview/crowdin_preview_manager.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class CrowdinPreviewManager {
3939

4040
late AppResourceBundle previewArb;
4141

42+
// set preview arb when locale changes
4243
void setPreviewArb(AppResourceBundle distributionArb) {
4344
previewArb = distributionArb;
4445

@@ -63,6 +64,7 @@ class CrowdinPreviewManager {
6364
}
6465
}
6566

67+
// sort only needed key-value pairs
6668
Map<String, String> getFinalMappingData(
6769
Map<String, dynamic> mappingData, Map<String, String> currentMap) {
6870
var data = mappingData;
@@ -136,6 +138,7 @@ class CrowdinPreviewManager {
136138
}
137139
}
138140

141+
// update preview arb when translation change received
139142
@visibleForTesting
140143
void updatePreviewArb({
141144
required String id,

lib/src/real_time_preview/crowdin_real_time_preview_widget.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
22

33
import '../../crowdin_sdk.dart';
44

5+
/// Wrap your app root widget with the CrowdinRealTimePreviewWidget to provide UI updates after
6+
/// translation updates receiving
57
class CrowdinRealTimePreviewWidget extends StatefulWidget {
68
final Widget child;
79

@@ -30,6 +32,7 @@ class _CrowdinRealTimePreviewWidgetState
3032
}
3133
}
3234

35+
// rebuild every widget in the tree without calling setState()
3336
void _rebuildTree(String textKey) {
3437
(context as Element).visitChildElements(
3538
(element) => _elementRebuildVisitor(element, textKey));

pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ environment:
1111
dependencies:
1212
flutter:
1313
sdk: flutter
14-
http: ^0.13.3
14+
http: '>=0.13.3 <2.0.0'
1515
intl: '>=0.17.0 <0.19.0'
1616
shared_preferences: ^2.0.4
17-
connectivity_plus: '>=2.1.0 <3.9.0'
17+
connectivity_plus: '>=2.1.0 <5.0.0'
1818
yaml: ^3.1.1
1919
meta: ^1.7.0
2020
path: ^1.8.1
2121
oauth2: ^2.0.1
22-
url_launcher: ^6.1.10
22+
url_launcher: ^6.1.0
2323
uni_links: ^0.5.1
24-
web_socket_channel: ^2.4.0
24+
web_socket_channel: ^2.2.0
2525

2626
flutter_localizations:
2727
sdk: flutter

0 commit comments

Comments
 (0)