Skip to content

Commit 60f3774

Browse files
authored
Merge pull request #16 from Jeremiahandsome/main
release room v4.0.1 and atomic-x v4.0.0
2 parents bb562a4 + d921ffd commit 60f3774

59 files changed

Lines changed: 3360 additions & 748 deletions

File tree

Some content is hidden

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

application/pubspec.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ dependencies:
5050
tencent_chat_uikit:
5151
path: ../chat/uikit
5252

53+
# Temporary solution, to be removed after the release of chat/live
54+
dependency_overrides:
55+
atomic_x_core: 4.0.0
56+
rtc_room_engine: 4.0.0
57+
5358
dev_dependencies:
5459
flutter_test:
5560
sdk: flutter

atomic-x/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 4.0.0
2+
* Adapted for atomic_x_core 4.0.0.
3+
14
## 3.6.6
25
* Fixed the conflict issue on the iOS platform after using the third-party library file_picker.
36
* Removed dependencies on certain third-party libraries.

atomic-x/call_assets/loading.gif

12.5 KB
Loading

atomic-x/lib/base_component/utils/app_builder.dart

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class AppBuilder {
6565

6666
static Future<void> init({required String path}) async {
6767
final instance = getInstance();
68+
await StorageUtil.init();
6869
await instance._loadConfig(path: path);
6970
}
7071

@@ -136,23 +137,31 @@ class MessageListConfig {
136137
final String alignment;
137138
final List<String> messageActionList;
138139
final bool _jsonEnableReadReceipt;
140+
bool? _cachedEnableReadReceipt;
139141

140142
MessageListConfig({
141143
required this.alignment,
142144
required this.messageActionList,
143145
required bool jsonEnableReadReceipt,
144-
}) : _jsonEnableReadReceipt = jsonEnableReadReceipt;
146+
}) : _jsonEnableReadReceipt = jsonEnableReadReceipt {
147+
// Load cached value asynchronously
148+
_loadEnableReadReceipt();
149+
}
145150

146-
bool get enableReadReceipt {
147-
final value = StorageUtil.get(_enableReadReceiptKey);
148-
if (value is bool) {
149-
return value;
150-
}
151+
void _loadEnableReadReceipt() {
152+
StorageUtil.get(_enableReadReceiptKey).then((value) {
153+
if (value is bool) {
154+
_cachedEnableReadReceipt = value;
155+
}
156+
});
157+
}
151158

152-
return _jsonEnableReadReceipt;
159+
bool get enableReadReceipt {
160+
return _cachedEnableReadReceipt ?? _jsonEnableReadReceipt;
153161
}
154162

155-
Future<bool> setEnableReadReceipt(bool value) {
163+
Future<bool> setEnableReadReceipt(bool value) async {
164+
_cachedEnableReadReceipt = value;
156165
return StorageUtil.set(_enableReadReceiptKey, value);
157166
}
158167

@@ -285,20 +294,34 @@ class AvatarConfig {
285294

286295
class TranslateConfig {
287296
static const String _translateTargetLanguageKey = 'atomic_translate_target_language';
297+
String? _cachedTargetLanguage;
298+
299+
TranslateConfig() {
300+
// Load cached value asynchronously
301+
_loadTargetLanguage();
302+
}
303+
304+
void _loadTargetLanguage() {
305+
StorageUtil.get(_translateTargetLanguageKey).then((value) {
306+
if (value is String && value.isNotEmpty) {
307+
_cachedTargetLanguage = value;
308+
}
309+
});
310+
}
288311

289312
/// Get translate target language
290313
/// Returns saved language or device language as default
291314
String get targetLanguage {
292-
final saved = StorageUtil.get(_translateTargetLanguageKey);
293-
if (saved is String && saved.isNotEmpty) {
294-
return saved;
315+
if (_cachedTargetLanguage != null && _cachedTargetLanguage!.isNotEmpty) {
316+
return _cachedTargetLanguage!;
295317
}
296318
// Return device language as default
297319
return PlatformDispatcher.instance.locale.languageCode;
298320
}
299321

300322
/// Set translate target language
301-
Future<bool> setTargetLanguage(String languageCode) {
323+
Future<bool> setTargetLanguage(String languageCode) async {
324+
_cachedTargetLanguage = languageCode;
302325
return StorageUtil.set(_translateTargetLanguageKey, languageCode);
303326
}
304327
}

atomic-x/lib/base_component/utils/locale_provider.dart

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,26 @@ import 'package:tuikit_atomic_x/base_component/base_component.dart';
44
class LocaleProvider extends ChangeNotifier {
55
String? _locale;
66

7+
LocaleProvider() {
8+
// Load cached locale value asynchronously
9+
_loadLocale();
10+
}
11+
12+
void _loadLocale() {
13+
StorageUtil.get('locale').then((value) {
14+
if (value is String) {
15+
_locale = value;
16+
} else {
17+
_locale = "system";
18+
}
19+
20+
notifyListeners();
21+
});
22+
}
23+
724
Locale? get locale {
8-
_locale = (StorageUtil.get('locale') as String?) ?? "system";
9-
switch (_locale) {
25+
final localeValue = _locale ?? "system";
26+
switch (localeValue) {
1027
case 'ar':
1128
return const Locale('ar');
1229
case 'en':

atomic-x/lib/base_component/utils/storage_util.dart

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@ class StorageUtil {
1010
_preferences = await SharedPreferences.getInstance();
1111
}
1212

13-
static Future<bool> set<T>(String key, T value) {
14-
if (_preferences == null) {
15-
debugPrint('StorageUtil, need call await init() first');
16-
return Future.value(false);
17-
}
13+
static Future<bool> set<T>(String key, T value) async {
14+
_preferences ??= await SharedPreferences.getInstance();
1815

1916
String type = value.runtimeType.toString();
2017
switch (type) {
@@ -31,25 +28,19 @@ class StorageUtil {
3128
case "_InternalLinkedHashMap<String, String>":
3229
return _preferences!.setString(key, json.encode(value));
3330
default:
34-
return Future.value(false);
31+
return false;
3532
}
3633
}
3734

38-
static Object? get(String key) {
39-
if (_preferences == null) {
40-
debugPrint('StorageUtil, need call await init() first');
41-
return null;
42-
}
35+
static Future<Object?> get(String key) async {
36+
_preferences ??= await SharedPreferences.getInstance();
4337

4438
Object? value = _preferences!.get(key);
4539
return value;
4640
}
4741

48-
static Future<bool> remove(String key) {
49-
if (_preferences == null) {
50-
debugPrint('StorageUtil, need call await init() first');
51-
return Future.value(false);
52-
}
42+
static Future<bool> remove(String key) async {
43+
_preferences ??= await SharedPreferences.getInstance();
5344

5445
return _preferences!.remove(key);
5546
}

atomic-x/lib/contact_list/pages/add_friend.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class _AddFriendState extends State<AddFriend> {
117117
Widget build(BuildContext context) {
118118
return Scaffold(
119119
appBar: AppBar(
120-
title: Text(_showAddFriendDetail ? atomicLocale.addFriend : atomicLocale.addFriend),
120+
title: Text(atomicLocale.addFriend, style: TextStyle(color: colorsTheme.textColorPrimary)),
121121
backgroundColor: colorsTheme.bgColorOperate,
122122
scrolledUnderElevation: 0,
123123
leading: IconButton.buttonContent(

atomic-x/lib/contact_list/pages/add_group.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class _AddGroupState extends State<AddGroup> {
118118
Widget build(BuildContext context) {
119119
return Scaffold(
120120
appBar: AppBar(
121-
title: Text(_showJoinGroupDetail ? atomicLocale.addGroup : atomicLocale.addGroup),
121+
title: Text(atomicLocale.addGroup, style: TextStyle(color: colorsTheme.textColorPrimary)),
122122
backgroundColor: colorsTheme.bgColorOperate,
123123
elevation: 0,
124124
leading: IconButton.buttonContent(

atomic-x/lib/contact_list/pages/blacklist.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class _BlacklistState extends State<Blacklist> {
4444
final colorsTheme = BaseThemeProvider.colorsOf(context);
4545

4646
return Scaffold(
47+
backgroundColor: colorsTheme.bgColorOperate,
4748
appBar: AppBar(
4849
backgroundColor: colorsTheme.bgColorOperate,
4950
scrolledUnderElevation: 0,

atomic-x/lib/contact_list/pages/group_list.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class _GroupListState extends State<GroupList> {
4242
final colorsTheme = BaseThemeProvider.colorsOf(context);
4343

4444
return Scaffold(
45+
backgroundColor: colorsTheme.bgColorOperate,
4546
appBar: AppBar(
4647
backgroundColor: colorsTheme.bgColorOperate,
4748
scrolledUnderElevation: 0,

0 commit comments

Comments
 (0)