Showing
16 changed files
with
332 additions
and
89 deletions
... | @@ -24,7 +24,7 @@ Map<String, LibraryLoader> _deferredLibraries = { | ... | @@ -24,7 +24,7 @@ Map<String, LibraryLoader> _deferredLibraries = { |
24 | 'zh': () => new Future.value(null), | 24 | 'zh': () => new Future.value(null), |
25 | }; | 25 | }; |
26 | 26 | ||
27 | -MessageLookupByLibrary _findExact(String localeName) { | 27 | +MessageLookupByLibrary? _findExact(String localeName) { |
28 | switch (localeName) { | 28 | switch (localeName) { |
29 | case 'en': | 29 | case 'en': |
30 | return messages_en.messages; | 30 | return messages_en.messages; |
... | @@ -58,9 +58,9 @@ bool _messagesExistFor(String locale) { | ... | @@ -58,9 +58,9 @@ bool _messagesExistFor(String locale) { |
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 | ||
61 | -MessageLookupByLibrary _findGeneratedMessagesFor(String locale) { | 61 | +MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { |
62 | - var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor, | 62 | + var actualLocale = |
63 | - onFailure: (_) => null); | 63 | + Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); |
64 | if (actualLocale == null) return null; | 64 | if (actualLocale == null) return null; |
65 | return _findExact(actualLocale); | 65 | return _findExact(actualLocale); |
66 | } | 66 | } | ... | ... |
... | @@ -7,7 +7,8 @@ | ... | @@ -7,7 +7,8 @@ |
7 | // ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new | 7 | // ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new |
8 | // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering | 8 | // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering |
9 | // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases | 9 | // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases |
10 | -// ignore_for_file:unused_import, file_names | 10 | +// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes |
11 | +// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes | ||
11 | 12 | ||
12 | import 'package:intl/intl.dart'; | 13 | import 'package:intl/intl.dart'; |
13 | import 'package:intl/message_lookup_by_library.dart'; | 14 | import 'package:intl/message_lookup_by_library.dart'; |
... | @@ -21,7 +22,7 @@ class MessageLookup extends MessageLookupByLibrary { | ... | @@ -21,7 +22,7 @@ class MessageLookup extends MessageLookupByLibrary { |
21 | 22 | ||
22 | final messages = _notInlinedMessages(_notInlinedMessages); | 23 | final messages = _notInlinedMessages(_notInlinedMessages); |
23 | 24 | ||
24 | - static _notInlinedMessages(_) => <String, Function>{ | 25 | + static Map<String, Function> _notInlinedMessages(_) => <String, Function>{ |
25 | "accountEditPageUserBirthday": | 26 | "accountEditPageUserBirthday": |
26 | MessageLookupByLibrary.simpleMessage("Birthday"), | 27 | MessageLookupByLibrary.simpleMessage("Birthday"), |
27 | "accountEditPageUserBirthdayPlaceholder": | 28 | "accountEditPageUserBirthdayPlaceholder": | ... | ... |
... | @@ -7,7 +7,8 @@ | ... | @@ -7,7 +7,8 @@ |
7 | // ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new | 7 | // ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new |
8 | // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering | 8 | // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering |
9 | // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases | 9 | // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases |
10 | -// ignore_for_file:unused_import, file_names | 10 | +// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes |
11 | +// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes | ||
11 | 12 | ||
12 | import 'package:intl/intl.dart'; | 13 | import 'package:intl/intl.dart'; |
13 | import 'package:intl/message_lookup_by_library.dart'; | 14 | import 'package:intl/message_lookup_by_library.dart'; |
... | @@ -21,7 +22,7 @@ class MessageLookup extends MessageLookupByLibrary { | ... | @@ -21,7 +22,7 @@ class MessageLookup extends MessageLookupByLibrary { |
21 | 22 | ||
22 | final messages = _notInlinedMessages(_notInlinedMessages); | 23 | final messages = _notInlinedMessages(_notInlinedMessages); |
23 | 24 | ||
24 | - static _notInlinedMessages(_) => <String, Function>{ | 25 | + static Map<String, Function> _notInlinedMessages(_) => <String, Function>{ |
25 | "accountEditPageUserBirthday": | 26 | "accountEditPageUserBirthday": |
26 | MessageLookupByLibrary.simpleMessage("出生日期"), | 27 | MessageLookupByLibrary.simpleMessage("出生日期"), |
27 | "accountEditPageUserBirthdayPlaceholder": | 28 | "accountEditPageUserBirthdayPlaceholder": | ... | ... |
... | @@ -7,6 +7,8 @@ import 'package:Parlando/account/models/user_entity.dart'; | ... | @@ -7,6 +7,8 @@ import 'package:Parlando/account/models/user_entity.dart'; |
7 | import 'package:Parlando/generated/json/user_entity.g.dart'; | 7 | import 'package:Parlando/generated/json/user_entity.g.dart'; |
8 | import 'package:Parlando/category/models/category_item_entity.dart'; | 8 | import 'package:Parlando/category/models/category_item_entity.dart'; |
9 | import 'package:Parlando/generated/json/category_item_entity.g.dart'; | 9 | import 'package:Parlando/generated/json/category_item_entity.g.dart'; |
10 | +import 'package:Parlando/home/models/setting_entity.dart'; | ||
11 | +import 'package:Parlando/generated/json/setting_entity.g.dart'; | ||
10 | import 'package:Parlando/poem/models/lang_sort_entity.dart'; | 12 | import 'package:Parlando/poem/models/lang_sort_entity.dart'; |
11 | import 'package:Parlando/generated/json/lang_sort_entity.g.dart'; | 13 | import 'package:Parlando/generated/json/lang_sort_entity.g.dart'; |
12 | import 'package:Parlando/poem/models/search_entity.dart'; | 14 | import 'package:Parlando/poem/models/search_entity.dart'; |
... | @@ -81,24 +83,36 @@ class JsonConvert { | ... | @@ -81,24 +83,36 @@ class JsonConvert { |
81 | } | 83 | } |
82 | //Go back to a single instance by type | 84 | //Go back to a single instance by type |
83 | static M? _fromJsonSingle<M>(Map<String, dynamic> json) { | 85 | static M? _fromJsonSingle<M>(Map<String, dynamic> json) { |
84 | - final String type = M.toString(); | 86 | + final String type = M.toString(); |
85 | - if(type == (UserEntity).toString()){ | 87 | + if (type == (UserEntity).toString()) { |
86 | - return UserEntity.fromJson(json) as M; | 88 | + return UserEntity.fromJson(json) as M; |
87 | - } | 89 | + } |
88 | - if(type == (CategoryItemEntity).toString()){ | 90 | + if (type == (CategoryItemEntity).toString()) { |
89 | - return CategoryItemEntity.fromJson(json) as M; | 91 | + return CategoryItemEntity.fromJson(json) as M; |
90 | - } | 92 | + } |
91 | - if(type == (LangSortEntity).toString()){ | 93 | + if (type == (SettingEntity).toString()) { |
92 | - return LangSortEntity.fromJson(json) as M; | 94 | + return SettingEntity.fromJson(json) as M; |
93 | - } | 95 | + } |
94 | - if(type == (SearchEntity).toString()){ | 96 | + if (type == (SettingData).toString()) { |
95 | - return SearchEntity.fromJson(json) as M; | 97 | + return SettingData.fromJson(json) as M; |
96 | - } | 98 | + } |
97 | - if(type == (SearchItems).toString()){ | 99 | + if (type == (SettingDataLoginSetting).toString()) { |
98 | - return SearchItems.fromJson(json) as M; | 100 | + return SettingDataLoginSetting.fromJson(json) as M; |
99 | - } | 101 | + } |
100 | - if(type == (SearchItemsOwner).toString()){ | 102 | + if (type == (SettingError).toString()) { |
101 | - return SearchItemsOwner.fromJson(json) as M; | 103 | + return SettingError.fromJson(json) as M; |
104 | + } | ||
105 | + if (type == (LangSortEntity).toString()) { | ||
106 | + return LangSortEntity.fromJson(json) as M; | ||
107 | + } | ||
108 | + if (type == (SearchEntity).toString()) { | ||
109 | + return SearchEntity.fromJson(json) as M; | ||
110 | + } | ||
111 | + if (type == (SearchItems).toString()) { | ||
112 | + return SearchItems.fromJson(json) as M; | ||
113 | + } | ||
114 | + if (type == (SearchItemsOwner).toString()) { | ||
115 | + return SearchItemsOwner.fromJson(json) as M; | ||
102 | } | 116 | } |
103 | if(type == (SearchItemsLicense).toString()){ | 117 | if(type == (SearchItemsLicense).toString()){ |
104 | return SearchItemsLicense.fromJson(json) as M; | 118 | return SearchItemsLicense.fromJson(json) as M; |
... | @@ -117,23 +131,59 @@ class JsonConvert { | ... | @@ -117,23 +131,59 @@ class JsonConvert { |
117 | 131 | ||
118 | //list is returned by type | 132 | //list is returned by type |
119 | static M? _getListChildType<M>(List<Map<String, dynamic>> data) { | 133 | static M? _getListChildType<M>(List<Map<String, dynamic>> data) { |
120 | - if(<UserEntity>[] is M){ | 134 | + if (<UserEntity>[] is M) { |
121 | - return data.map<UserEntity>((Map<String, dynamic> e) => UserEntity.fromJson(e)).toList() as M; | 135 | + return data |
122 | - } | 136 | + .map<UserEntity>((Map<String, dynamic> e) => UserEntity.fromJson(e)) |
123 | - if(<CategoryItemEntity>[] is M){ | 137 | + .toList() as M; |
124 | - return data.map<CategoryItemEntity>((Map<String, dynamic> e) => CategoryItemEntity.fromJson(e)).toList() as M; | 138 | + } |
125 | - } | 139 | + if (<CategoryItemEntity>[] is M) { |
126 | - if(<LangSortEntity>[] is M){ | 140 | + return data |
127 | - return data.map<LangSortEntity>((Map<String, dynamic> e) => LangSortEntity.fromJson(e)).toList() as M; | 141 | + .map<CategoryItemEntity>( |
128 | - } | 142 | + (Map<String, dynamic> e) => CategoryItemEntity.fromJson(e)) |
129 | - if(<SearchEntity>[] is M){ | 143 | + .toList() as M; |
130 | - return data.map<SearchEntity>((Map<String, dynamic> e) => SearchEntity.fromJson(e)).toList() as M; | 144 | + } |
131 | - } | 145 | + if (<SettingEntity>[] is M) { |
132 | - if(<SearchItems>[] is M){ | 146 | + return data |
133 | - return data.map<SearchItems>((Map<String, dynamic> e) => SearchItems.fromJson(e)).toList() as M; | 147 | + .map<SettingEntity>( |
134 | - } | 148 | + (Map<String, dynamic> e) => SettingEntity.fromJson(e)) |
135 | - if(<SearchItemsOwner>[] is M){ | 149 | + .toList() as M; |
136 | - return data.map<SearchItemsOwner>((Map<String, dynamic> e) => SearchItemsOwner.fromJson(e)).toList() as M; | 150 | + } |
151 | + if (<SettingData>[] is M) { | ||
152 | + return data | ||
153 | + .map<SettingData>((Map<String, dynamic> e) => SettingData.fromJson(e)) | ||
154 | + .toList() as M; | ||
155 | + } | ||
156 | + if (<SettingDataLoginSetting>[] is M) { | ||
157 | + return data | ||
158 | + .map<SettingDataLoginSetting>( | ||
159 | + (Map<String, dynamic> e) => SettingDataLoginSetting.fromJson(e)) | ||
160 | + .toList() as M; | ||
161 | + } | ||
162 | + if (<SettingError>[] is M) { | ||
163 | + return data | ||
164 | + .map<SettingError>( | ||
165 | + (Map<String, dynamic> e) => SettingError.fromJson(e)) | ||
166 | + .toList() as M; | ||
167 | + } | ||
168 | + if (<LangSortEntity>[] is M) { | ||
169 | + return data | ||
170 | + .map<LangSortEntity>( | ||
171 | + (Map<String, dynamic> e) => LangSortEntity.fromJson(e)) | ||
172 | + .toList() as M; | ||
173 | + } | ||
174 | + if (<SearchEntity>[] is M) { | ||
175 | + return data | ||
176 | + .map<SearchEntity>( | ||
177 | + (Map<String, dynamic> e) => SearchEntity.fromJson(e)) | ||
178 | + .toList() as M; | ||
179 | + } | ||
180 | + if (<SearchItems>[] is M) { | ||
181 | + return data | ||
182 | + .map<SearchItems>((Map<String, dynamic> e) => SearchItems.fromJson(e)) | ||
183 | + .toList() as M; | ||
184 | + } | ||
185 | + if (<SearchItemsOwner>[] is M) { | ||
186 | + return data.map<SearchItemsOwner>((Map<String, dynamic> e) => SearchItemsOwner.fromJson(e)).toList() as M; | ||
137 | } | 187 | } |
138 | if(<SearchItemsLicense>[] is M){ | 188 | if(<SearchItemsLicense>[] is M){ |
139 | return data.map<SearchItemsLicense>((Map<String, dynamic> e) => SearchItemsLicense.fromJson(e)).toList() as M; | 189 | return data.map<SearchItemsLicense>((Map<String, dynamic> e) => SearchItemsLicense.fromJson(e)).toList() as M; | ... | ... |
... | @@ -11,17 +11,17 @@ CategoryItemEntity $CategoryItemEntityFromJson(Map<String, dynamic> json) { | ... | @@ -11,17 +11,17 @@ CategoryItemEntity $CategoryItemEntityFromJson(Map<String, dynamic> json) { |
11 | if (timeLunar != null) { | 11 | if (timeLunar != null) { |
12 | categoryItemEntity.timeLunar = timeLunar; | 12 | categoryItemEntity.timeLunar = timeLunar; |
13 | } | 13 | } |
14 | - final String? timeSolar = jsonConvert.convert<String>(json['time_solar']); | 14 | + final String? timeSolar = jsonConvert.convert<String>(json['time_solar']); |
15 | - if (timeSolar != null) { | 15 | + if (timeSolar != null) { |
16 | - categoryItemEntity.timeSolar = timeSolar; | 16 | + categoryItemEntity.timeSolar = timeSolar; |
17 | - } | 17 | + } |
18 | - final String? period = jsonConvert.convert<String>(json['period']); | 18 | + final String? period = jsonConvert.convert<String>(json['period']); |
19 | - if (period != null) { | 19 | + if (period != null) { |
20 | - categoryItemEntity.period = period; | 20 | + categoryItemEntity.period = period; |
21 | - } | 21 | + } |
22 | - final String? poem = jsonConvert.convert<String>(json['poem']); | 22 | + final String? poem = jsonConvert.convert<String>(json['poem']); |
23 | - if (poem != null) { | 23 | + if (poem != null) { |
24 | - categoryItemEntity.poem = poem; | 24 | + categoryItemEntity.poem = poem; |
25 | } | 25 | } |
26 | final String? author = jsonConvert.convert<String>(json['author']); | 26 | final String? author = jsonConvert.convert<String>(json['author']); |
27 | if (author != null) { | 27 | if (author != null) { | ... | ... |
... | @@ -11,7 +11,7 @@ LangSortEntity $LangSortEntityFromJson(Map<String, dynamic> json) { | ... | @@ -11,7 +11,7 @@ LangSortEntity $LangSortEntityFromJson(Map<String, dynamic> json) { |
11 | if (name != null) { | 11 | if (name != null) { |
12 | langSortEntity.name = name; | 12 | langSortEntity.name = name; |
13 | } | 13 | } |
14 | - return langSortEntity; | 14 | + return langSortEntity; |
15 | } | 15 | } |
16 | 16 | ||
17 | Map<String, dynamic> $LangSortEntityToJson(LangSortEntity entity) { | 17 | Map<String, dynamic> $LangSortEntityToJson(LangSortEntity entity) { | ... | ... |
... | @@ -12,11 +12,12 @@ SearchEntity $SearchEntityFromJson(Map<String, dynamic> json) { | ... | @@ -12,11 +12,12 @@ SearchEntity $SearchEntityFromJson(Map<String, dynamic> json) { |
12 | if (incompleteResults != null) { | 12 | if (incompleteResults != null) { |
13 | searchEntity.incompleteResults = incompleteResults; | 13 | searchEntity.incompleteResults = incompleteResults; |
14 | } | 14 | } |
15 | - final List<SearchItems>? items = jsonConvert.convertListNotNull<SearchItems>(json['items']); | 15 | + final List<SearchItems>? items = |
16 | - if (items != null) { | 16 | + jsonConvert.convertListNotNull<SearchItems>(json['items']); |
17 | - searchEntity.items = items; | 17 | + if (items != null) { |
18 | - } | 18 | + searchEntity.items = items; |
19 | - return searchEntity; | 19 | + } |
20 | + return searchEntity; | ||
20 | } | 21 | } |
21 | 22 | ||
22 | Map<String, dynamic> $SearchEntityToJson(SearchEntity entity) { | 23 | Map<String, dynamic> $SearchEntityToJson(SearchEntity entity) { | ... | ... |
lib/generated/json/setting_entity.g.dart
0 → 100644
1 | +import 'package:Parlando/generated/json/base/json_convert_content.dart'; | ||
2 | +import 'package:Parlando/home/models/setting_entity.dart'; | ||
3 | + | ||
4 | +SettingEntity $SettingEntityFromJson(Map<String, dynamic> json) { | ||
5 | + final SettingEntity settingEntity = SettingEntity(); | ||
6 | + final String? status = jsonConvert.convert<String>(json['status']); | ||
7 | + if (status != null) { | ||
8 | + settingEntity.status = status; | ||
9 | + } | ||
10 | + final int? code = jsonConvert.convert<int>(json['code']); | ||
11 | + if (code != null) { | ||
12 | + settingEntity.code = code; | ||
13 | + } | ||
14 | + final String? message = jsonConvert.convert<String>(json['message']); | ||
15 | + if (message != null) { | ||
16 | + settingEntity.message = message; | ||
17 | + } | ||
18 | + final SettingData? data = jsonConvert.convert<SettingData>(json['data']); | ||
19 | + if (data != null) { | ||
20 | + settingEntity.data = data; | ||
21 | + } | ||
22 | + final SettingError? error = jsonConvert.convert<SettingError>(json['error']); | ||
23 | + if (error != null) { | ||
24 | + settingEntity.error = error; | ||
25 | + } | ||
26 | + return settingEntity; | ||
27 | +} | ||
28 | + | ||
29 | +Map<String, dynamic> $SettingEntityToJson(SettingEntity entity) { | ||
30 | + final Map<String, dynamic> data = <String, dynamic>{}; | ||
31 | + data['status'] = entity.status; | ||
32 | + data['code'] = entity.code; | ||
33 | + data['message'] = entity.message; | ||
34 | + data['data'] = entity.data?.toJson(); | ||
35 | + data['error'] = entity.error?.toJson(); | ||
36 | + return data; | ||
37 | +} | ||
38 | + | ||
39 | +SettingData $SettingDataFromJson(Map<String, dynamic> json) { | ||
40 | + final SettingData settingData = SettingData(); | ||
41 | + final List<SettingDataLoginSetting>? loginSetting = jsonConvert | ||
42 | + .convertListNotNull<SettingDataLoginSetting>(json['login_setting']); | ||
43 | + if (loginSetting != null) { | ||
44 | + settingData.loginSetting = loginSetting; | ||
45 | + } | ||
46 | + return settingData; | ||
47 | +} | ||
48 | + | ||
49 | +Map<String, dynamic> $SettingDataToJson(SettingData entity) { | ||
50 | + final Map<String, dynamic> data = <String, dynamic>{}; | ||
51 | + data['login_setting'] = entity.loginSetting?.map((v) => v.toJson()).toList(); | ||
52 | + return data; | ||
53 | +} | ||
54 | + | ||
55 | +SettingDataLoginSetting $SettingDataLoginSettingFromJson( | ||
56 | + Map<String, dynamic> json) { | ||
57 | + final SettingDataLoginSetting settingDataLoginSetting = | ||
58 | + SettingDataLoginSetting(); | ||
59 | + final String? icon = jsonConvert.convert<String>(json['icon']); | ||
60 | + if (icon != null) { | ||
61 | + settingDataLoginSetting.icon = icon; | ||
62 | + } | ||
63 | + final String? name = jsonConvert.convert<String>(json['name']); | ||
64 | + if (name != null) { | ||
65 | + settingDataLoginSetting.name = name; | ||
66 | + } | ||
67 | + final int? state = jsonConvert.convert<int>(json['state']); | ||
68 | + if (state != null) { | ||
69 | + settingDataLoginSetting.state = state; | ||
70 | + } | ||
71 | + return settingDataLoginSetting; | ||
72 | +} | ||
73 | + | ||
74 | +Map<String, dynamic> $SettingDataLoginSettingToJson( | ||
75 | + SettingDataLoginSetting entity) { | ||
76 | + final Map<String, dynamic> data = <String, dynamic>{}; | ||
77 | + data['icon'] = entity.icon; | ||
78 | + data['name'] = entity.name; | ||
79 | + data['state'] = entity.state; | ||
80 | + return data; | ||
81 | +} | ||
82 | + | ||
83 | +SettingError $SettingErrorFromJson(Map<String, dynamic> json) { | ||
84 | + final SettingError settingError = SettingError(); | ||
85 | + return settingError; | ||
86 | +} | ||
87 | + | ||
88 | +Map<String, dynamic> $SettingErrorToJson(SettingError entity) { | ||
89 | + final Map<String, dynamic> data = <String, dynamic>{}; | ||
90 | + return data; | ||
91 | +} |
... | @@ -11,11 +11,11 @@ UserEntity $UserEntityFromJson(Map<String, dynamic> json) { | ... | @@ -11,11 +11,11 @@ UserEntity $UserEntityFromJson(Map<String, dynamic> json) { |
11 | if (name != null) { | 11 | if (name != null) { |
12 | userEntity.name = name; | 12 | userEntity.name = name; |
13 | } | 13 | } |
14 | - final String? avatar = jsonConvert.convert<String>(json['avatar']); | 14 | + final String? avatar = jsonConvert.convert<String>(json['avatar']); |
15 | - if (avatar != null) { | 15 | + if (avatar != null) { |
16 | - userEntity.avatar = avatar; | 16 | + userEntity.avatar = avatar; |
17 | - } | 17 | + } |
18 | - return userEntity; | 18 | + return userEntity; |
19 | } | 19 | } |
20 | 20 | ||
21 | Map<String, dynamic> $UserEntityToJson(UserEntity entity) { | 21 | Map<String, dynamic> $UserEntityToJson(UserEntity entity) { | ... | ... |
... | @@ -10,12 +10,18 @@ import 'intl/messages_all.dart'; | ... | @@ -10,12 +10,18 @@ import 'intl/messages_all.dart'; |
10 | 10 | ||
11 | // ignore_for_file: non_constant_identifier_names, lines_longer_than_80_chars | 11 | // ignore_for_file: non_constant_identifier_names, lines_longer_than_80_chars |
12 | // ignore_for_file: join_return_with_assignment, prefer_final_in_for_each | 12 | // ignore_for_file: join_return_with_assignment, prefer_final_in_for_each |
13 | -// ignore_for_file: avoid_redundant_argument_values | 13 | +// ignore_for_file: avoid_redundant_argument_values, avoid_escaping_inner_quotes |
14 | 14 | ||
15 | class S { | 15 | class S { |
16 | S(); | 16 | S(); |
17 | 17 | ||
18 | - static S current; | 18 | + static S? _current; |
19 | + | ||
20 | + static S get current { | ||
21 | + assert(_current != null, | ||
22 | + 'No instance of S was loaded. Try to initialize the S delegate before accessing S.current.'); | ||
23 | + return _current!; | ||
24 | + } | ||
19 | 25 | ||
20 | static const AppLocalizationDelegate delegate = AppLocalizationDelegate(); | 26 | static const AppLocalizationDelegate delegate = AppLocalizationDelegate(); |
21 | 27 | ||
... | @@ -26,13 +32,21 @@ class S { | ... | @@ -26,13 +32,21 @@ class S { |
26 | final localeName = Intl.canonicalizedLocale(name); | 32 | final localeName = Intl.canonicalizedLocale(name); |
27 | return initializeMessages(localeName).then((_) { | 33 | return initializeMessages(localeName).then((_) { |
28 | Intl.defaultLocale = localeName; | 34 | Intl.defaultLocale = localeName; |
29 | - S.current = S(); | 35 | + final instance = S(); |
36 | + S._current = instance; | ||
30 | 37 | ||
31 | - return S.current; | 38 | + return instance; |
32 | }); | 39 | }); |
33 | } | 40 | } |
34 | 41 | ||
35 | static S of(BuildContext context) { | 42 | static S of(BuildContext context) { |
43 | + final instance = S.maybeOf(context); | ||
44 | + assert(instance != null, | ||
45 | + 'No instance of S present in the widget tree. Did you add S.delegate in localizationsDelegates?'); | ||
46 | + return instance!; | ||
47 | + } | ||
48 | + | ||
49 | + static S? maybeOf(BuildContext context) { | ||
36 | return Localizations.of<S>(context, S); | 50 | return Localizations.of<S>(context, S); |
37 | } | 51 | } |
38 | 52 | ||
... | @@ -385,13 +399,11 @@ class AppLocalizationDelegate extends LocalizationsDelegate<S> { | ... | @@ -385,13 +399,11 @@ class AppLocalizationDelegate extends LocalizationsDelegate<S> { |
385 | bool shouldReload(AppLocalizationDelegate old) => false; | 399 | bool shouldReload(AppLocalizationDelegate old) => false; |
386 | 400 | ||
387 | bool _isSupported(Locale locale) { | 401 | bool _isSupported(Locale locale) { |
388 | - if (locale != null) { | 402 | + for (var supportedLocale in supportedLocales) { |
389 | - for (var supportedLocale in supportedLocales) { | 403 | + if (supportedLocale.languageCode == locale.languageCode) { |
390 | - if (supportedLocale.languageCode == locale.languageCode) { | 404 | + return true; |
391 | - return true; | ||
392 | - } | ||
393 | } | 405 | } |
394 | } | 406 | } |
395 | return false; | 407 | return false; |
396 | } | 408 | } |
397 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
409 | +} | ... | ... |
lib/home/models/setting_entity.dart
0 → 100644
1 | +import 'dart:convert'; | ||
2 | +import 'package:Parlando/generated/json/base/json_field.dart'; | ||
3 | +import 'package:Parlando/generated/json/setting_entity.g.dart'; | ||
4 | + | ||
5 | +@JsonSerializable() | ||
6 | +class SettingEntity { | ||
7 | + String? status; | ||
8 | + int? code; | ||
9 | + String? message; | ||
10 | + SettingData? data; | ||
11 | + SettingError? error; | ||
12 | + | ||
13 | + SettingEntity(); | ||
14 | + | ||
15 | + factory SettingEntity.fromJson(Map<String, dynamic> json) => | ||
16 | + $SettingEntityFromJson(json); | ||
17 | + | ||
18 | + Map<String, dynamic> toJson() => $SettingEntityToJson(this); | ||
19 | + | ||
20 | + @override | ||
21 | + String toString() { | ||
22 | + return jsonEncode(this); | ||
23 | + } | ||
24 | +} | ||
25 | + | ||
26 | +@JsonSerializable() | ||
27 | +class SettingData { | ||
28 | + @JSONField(name: "login_setting") | ||
29 | + List<SettingDataLoginSetting>? loginSetting; | ||
30 | + | ||
31 | + SettingData(); | ||
32 | + | ||
33 | + factory SettingData.fromJson(Map<String, dynamic> json) => | ||
34 | + $SettingDataFromJson(json); | ||
35 | + | ||
36 | + Map<String, dynamic> toJson() => $SettingDataToJson(this); | ||
37 | + | ||
38 | + @override | ||
39 | + String toString() { | ||
40 | + return jsonEncode(this); | ||
41 | + } | ||
42 | +} | ||
43 | + | ||
44 | +@JsonSerializable() | ||
45 | +class SettingDataLoginSetting { | ||
46 | + String? icon; | ||
47 | + String? name; | ||
48 | + int? state; | ||
49 | + | ||
50 | + SettingDataLoginSetting(); | ||
51 | + | ||
52 | + factory SettingDataLoginSetting.fromJson(Map<String, dynamic> json) => | ||
53 | + $SettingDataLoginSettingFromJson(json); | ||
54 | + | ||
55 | + Map<String, dynamic> toJson() => $SettingDataLoginSettingToJson(this); | ||
56 | + | ||
57 | + @override | ||
58 | + String toString() { | ||
59 | + return jsonEncode(this); | ||
60 | + } | ||
61 | +} | ||
62 | + | ||
63 | +@JsonSerializable() | ||
64 | +class SettingError { | ||
65 | + SettingError(); | ||
66 | + | ||
67 | + factory SettingError.fromJson(Map<String, dynamic> json) => | ||
68 | + $SettingErrorFromJson(json); | ||
69 | + | ||
70 | + Map<String, dynamic> toJson() => $SettingErrorToJson(this); | ||
71 | + | ||
72 | + @override | ||
73 | + String toString() { | ||
74 | + return jsonEncode(this); | ||
75 | + } | ||
76 | +} |
1 | import 'dart:async'; | 1 | import 'dart:async'; |
2 | 2 | ||
3 | +import 'package:Parlando/home/models/setting_entity.dart'; | ||
4 | +import 'package:Parlando/net/dio_utils.dart'; | ||
5 | +import 'package:Parlando/net/http_api.dart'; | ||
3 | import 'package:flutter/material.dart'; | 6 | import 'package:flutter/material.dart'; |
4 | import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart'; | 7 | import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart'; |
5 | import 'package:Parlando/extension/shared/size_fit.dart'; | 8 | import 'package:Parlando/extension/shared/size_fit.dart'; |
... | @@ -72,6 +75,15 @@ class _SplashPageState extends State<SplashPage> { | ... | @@ -72,6 +75,15 @@ class _SplashPageState extends State<SplashPage> { |
72 | } | 75 | } |
73 | 76 | ||
74 | void _initSplash() { | 77 | void _initSplash() { |
78 | + // 加载配置数据 | ||
79 | + DioUtils.instance.asyncRequestNetwork<SettingEntity>( | ||
80 | + Method.get, | ||
81 | + HttpApi.setting, | ||
82 | + params: [], | ||
83 | + onSuccess: (data) {}, | ||
84 | + onError: (code, msg) {}, | ||
85 | + ); | ||
86 | + | ||
75 | _subscription = | 87 | _subscription = |
76 | Stream.value(1).delay(const Duration(milliseconds: 1500)).listen((_) { | 88 | Stream.value(1).delay(const Duration(milliseconds: 1500)).listen((_) { |
77 | if (SpUtil.getBool(Constant.keyGuide, defValue: true)! || | 89 | if (SpUtil.getBool(Constant.keyGuide, defValue: true)! || | ... | ... |
... | @@ -99,7 +99,7 @@ class MyApp extends StatelessWidget { | ... | @@ -99,7 +99,7 @@ class MyApp extends StatelessWidget { |
99 | /// 适配数据(根据自己的数据结构,可自行选择添加) | 99 | /// 适配数据(根据自己的数据结构,可自行选择添加) |
100 | interceptors.add(AdapterInterceptor()); | 100 | interceptors.add(AdapterInterceptor()); |
101 | configDio( | 101 | configDio( |
102 | - baseUrl: 'https://api.github.com/', | 102 | + baseUrl: 'http://www.yiyan.pub/api/v1/', |
103 | interceptors: interceptors, | 103 | interceptors: interceptors, |
104 | ); | 104 | ); |
105 | } | 105 | } | ... | ... |
1 | - | 1 | +class HttpApi { |
2 | -class HttpApi{ | 2 | + static const String setting = 'setting'; |
3 | - static const String users = 'users/simplezhli'; | ||
4 | static const String search = 'search/repositories'; | 3 | static const String search = 'search/repositories'; |
5 | static const String subscriptions = 'users/simplezhli/subscriptions'; | 4 | static const String subscriptions = 'users/simplezhli/subscriptions'; |
6 | static const String upload = 'uuc/upload-inco'; | 5 | static const String upload = 'uuc/upload-inco'; | ... | ... |
... | @@ -126,7 +126,7 @@ packages: | ... | @@ -126,7 +126,7 @@ packages: |
126 | name: camera | 126 | name: camera |
127 | url: "https://pub.flutter-io.cn" | 127 | url: "https://pub.flutter-io.cn" |
128 | source: hosted | 128 | source: hosted |
129 | - version: "0.9.4+16" | 129 | + version: "0.9.4+18" |
130 | camera_platform_interface: | 130 | camera_platform_interface: |
131 | dependency: transitive | 131 | dependency: transitive |
132 | description: | 132 | description: |
... | @@ -301,7 +301,7 @@ packages: | ... | @@ -301,7 +301,7 @@ packages: |
301 | name: dio | 301 | name: dio |
302 | url: "https://pub.flutter-io.cn" | 302 | url: "https://pub.flutter-io.cn" |
303 | source: hosted | 303 | source: hosted |
304 | - version: "4.0.4" | 304 | + version: "4.0.5" |
305 | fake_async: | 305 | fake_async: |
306 | dependency: transitive | 306 | dependency: transitive |
307 | description: | 307 | description: |
... | @@ -362,7 +362,7 @@ packages: | ... | @@ -362,7 +362,7 @@ packages: |
362 | path: "." | 362 | path: "." |
363 | ref: "597a0538" | 363 | ref: "597a0538" |
364 | resolved-ref: "597a05386700e1cf854ad9b56fe21b103c669f62" | 364 | resolved-ref: "597a05386700e1cf854ad9b56fe21b103c669f62" |
365 | - url: "https://github.com/simplezhli/flutter_2d_amap.git" | 365 | + url: "https://gitee.com/reasonpun/flutter_2d_amap.git" |
366 | source: git | 366 | source: git |
367 | version: "0.2.0+2" | 367 | version: "0.2.0+2" |
368 | flutter_blurhash: | 368 | flutter_blurhash: |
... | @@ -409,7 +409,7 @@ packages: | ... | @@ -409,7 +409,7 @@ packages: |
409 | name: flutter_native_splash | 409 | name: flutter_native_splash |
410 | url: "https://pub.flutter-io.cn" | 410 | url: "https://pub.flutter-io.cn" |
411 | source: hosted | 411 | source: hosted |
412 | - version: "2.1.1" | 412 | + version: "2.1.2+1" |
413 | flutter_plugin_android_lifecycle: | 413 | flutter_plugin_android_lifecycle: |
414 | dependency: transitive | 414 | dependency: transitive |
415 | description: | 415 | description: |
... | @@ -975,7 +975,7 @@ packages: | ... | @@ -975,7 +975,7 @@ packages: |
975 | name: shelf | 975 | name: shelf |
976 | url: "https://pub.flutter-io.cn" | 976 | url: "https://pub.flutter-io.cn" |
977 | source: hosted | 977 | source: hosted |
978 | - version: "1.2.0" | 978 | + version: "1.3.0" |
979 | shelf_packages_handler: | 979 | shelf_packages_handler: |
980 | dependency: transitive | 980 | dependency: transitive |
981 | description: | 981 | description: |
... | @@ -1113,7 +1113,7 @@ packages: | ... | @@ -1113,7 +1113,7 @@ packages: |
1113 | name: synchronized | 1113 | name: synchronized |
1114 | url: "https://pub.flutter-io.cn" | 1114 | url: "https://pub.flutter-io.cn" |
1115 | source: hosted | 1115 | source: hosted |
1116 | - version: "3.0.0" | 1116 | + version: "3.0.0+2" |
1117 | tapped: | 1117 | tapped: |
1118 | dependency: "direct main" | 1118 | dependency: "direct main" |
1119 | description: | 1119 | description: |
... | @@ -1274,7 +1274,7 @@ packages: | ... | @@ -1274,7 +1274,7 @@ packages: |
1274 | name: video_player_android | 1274 | name: video_player_android |
1275 | url: "https://pub.flutter-io.cn" | 1275 | url: "https://pub.flutter-io.cn" |
1276 | source: hosted | 1276 | source: hosted |
1277 | - version: "2.3.1" | 1277 | + version: "2.3.2" |
1278 | video_player_avfoundation: | 1278 | video_player_avfoundation: |
1279 | dependency: transitive | 1279 | dependency: transitive |
1280 | description: | 1280 | description: |
... | @@ -1288,7 +1288,7 @@ packages: | ... | @@ -1288,7 +1288,7 @@ packages: |
1288 | name: video_player_platform_interface | 1288 | name: video_player_platform_interface |
1289 | url: "https://pub.flutter-io.cn" | 1289 | url: "https://pub.flutter-io.cn" |
1290 | source: hosted | 1290 | source: hosted |
1291 | - version: "5.1.0" | 1291 | + version: "5.1.1" |
1292 | video_player_web: | 1292 | video_player_web: |
1293 | dependency: transitive | 1293 | dependency: transitive |
1294 | description: | 1294 | description: |
... | @@ -1365,7 +1365,7 @@ packages: | ... | @@ -1365,7 +1365,7 @@ packages: |
1365 | name: win32 | 1365 | name: win32 |
1366 | url: "https://pub.flutter-io.cn" | 1366 | url: "https://pub.flutter-io.cn" |
1367 | source: hosted | 1367 | source: hosted |
1368 | - version: "2.4.1" | 1368 | + version: "2.5.0" |
1369 | xdg_directories: | 1369 | xdg_directories: |
1370 | dependency: transitive | 1370 | dependency: transitive |
1371 | description: | 1371 | description: | ... | ... |
... | @@ -84,7 +84,7 @@ dependencies: | ... | @@ -84,7 +84,7 @@ dependencies: |
84 | flutter_2d_amap: | 84 | flutter_2d_amap: |
85 | git: | 85 | git: |
86 | ref: '597a0538' | 86 | ref: '597a0538' |
87 | - url: 'https://github.com/simplezhli/flutter_2d_amap.git' | 87 | + url: 'https://gitee.com/reasonpun/flutter_2d_amap.git' |
88 | 88 | ||
89 | # tiktok | 89 | # tiktok |
90 | video_player: ^2.2.10 | 90 | video_player: ^2.2.10 | ... | ... |
-
Please register or login to post a comment