Skip to content

Commit 196a50a

Browse files
committed
Fix android tile service issues
1 parent 8cdaf30 commit 196a50a

File tree

18 files changed

+268
-173
lines changed

18 files changed

+268
-173
lines changed

lib/application.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ class ApplicationState extends State<Application> {
142142
locale: config.locale,
143143
themeMode: config.themeMode,
144144
primaryColor: config.primaryColor,
145+
prueBlack: config.prueBlack,
145146
),
146147
builder: (_, state, child) {
147148
return DynamicColorBuilder(
@@ -180,7 +181,7 @@ class ApplicationState extends State<Application> {
180181
brightness: Brightness.dark,
181182
systemColorSchemes: systemColorSchemes,
182183
primaryColor: state.primaryColor,
183-
),
184+
).toPrueBlack(state.prueBlack),
184185
),
185186
home: child,
186187
);

lib/common/color.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,13 @@ extension ColorExtension on Color {
1616
toLittle() {
1717
return withOpacity(0.03);
1818
}
19-
}
19+
}
20+
21+
extension ColorSchemeExtension on ColorScheme {
22+
ColorScheme toPrueBlack(bool isPrueBlack) => isPrueBlack
23+
? copyWith(
24+
surface: Colors.black,
25+
background: Colors.black,
26+
)
27+
: this;
28+
}

lib/fragments/profiles/edit_profile.dart

Lines changed: 47 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,11 @@ class _EditProfileState extends State<EditProfile> {
8989
});
9090
}
9191

92-
Future<FileInfo> _getFileInfo(path) async {
92+
Future<FileInfo?> _getFileInfo(path) async {
9393
final file = File(path);
94+
if (!await file.exists()) {
95+
return null;
96+
}
9497
final lastModified = await file.lastModified();
9598
final size = await file.length();
9699
return FileInfo(
@@ -127,59 +130,6 @@ class _EditProfileState extends State<EditProfile> {
127130
);
128131
}
129132

130-
Widget _buildSubtitle() {
131-
return Column(
132-
crossAxisAlignment: CrossAxisAlignment.start,
133-
children: [
134-
const SizedBox(
135-
height: 4,
136-
),
137-
ValueListenableBuilder<FileInfo?>(
138-
valueListenable: fileInfoNotifier,
139-
builder: (_, fileInfo, __) {
140-
final height =
141-
globalState.appController.measure.bodyMediumHeight + 4;
142-
return SizedBox(
143-
height: height,
144-
child: FadeBox(
145-
child: fileInfo == null
146-
? SizedBox(
147-
width: height,
148-
height: height,
149-
child: const CircularProgressIndicator(
150-
strokeWidth: 2,
151-
),
152-
)
153-
: Text(
154-
fileInfo.desc,
155-
),
156-
),
157-
);
158-
},
159-
),
160-
const SizedBox(
161-
height: 8,
162-
),
163-
Wrap(
164-
runSpacing: 6,
165-
spacing: 12,
166-
children: [
167-
CommonChip(
168-
avatar: const Icon(Icons.edit),
169-
label: appLocalizations.edit,
170-
onPressed: _editProfileFile,
171-
),
172-
CommonChip(
173-
avatar: const Icon(Icons.upload),
174-
label: appLocalizations.upload,
175-
onPressed: _uploadProfileFile,
176-
),
177-
],
178-
),
179-
],
180-
);
181-
}
182-
183133
@override
184134
Widget build(BuildContext context) {
185135
final items = [
@@ -250,9 +200,49 @@ class _EditProfileState extends State<EditProfile> {
250200
),
251201
),
252202
],
253-
ListItem(
254-
title: Text(appLocalizations.profile),
255-
subtitle: _buildSubtitle(),
203+
ValueListenableBuilder<FileInfo?>(
204+
valueListenable: fileInfoNotifier,
205+
builder: (_, fileInfo, __) {
206+
return FadeBox(
207+
child: fileInfo == null
208+
? Container()
209+
: ListItem(
210+
title: Text(
211+
appLocalizations.profile,
212+
),
213+
subtitle: Column(
214+
crossAxisAlignment: CrossAxisAlignment.start,
215+
children: [
216+
const SizedBox(
217+
height: 4,
218+
),
219+
Text(
220+
fileInfo.desc,
221+
),
222+
const SizedBox(
223+
height: 8,
224+
),
225+
Wrap(
226+
runSpacing: 6,
227+
spacing: 12,
228+
children: [
229+
CommonChip(
230+
avatar: const Icon(Icons.edit),
231+
label: appLocalizations.edit,
232+
onPressed: _editProfileFile,
233+
),
234+
CommonChip(
235+
avatar: const Icon(Icons.upload),
236+
label: appLocalizations.upload,
237+
onPressed: _uploadProfileFile,
238+
),
239+
],
240+
),
241+
],
242+
),
243+
),
244+
);
245+
},
256246
),
257247
];
258248
return FloatLayout(

lib/fragments/profiles/profiles.dart

Lines changed: 75 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class _ProfileItemState extends State<ProfileItem> {
189189
),
190190
onTab: () async {
191191
await globalState.appController.deleteProfile(widget.profile.id);
192-
if(mounted){
192+
if (mounted) {
193193
Navigator.of(context).pop();
194194
}
195195
},
@@ -231,75 +231,90 @@ class _ProfileItemState extends State<ProfileItem> {
231231
);
232232
}
233233

234+
List<Widget> _buildUserInfo(UserInfo userInfo) {
235+
final use = userInfo.upload + userInfo.download;
236+
final total = userInfo.total;
237+
if(total == 0){
238+
return [];
239+
}
240+
final useShow = TrafficValue(value: use).show;
241+
final totalShow = TrafficValue(value: total).show;
242+
final progress = total == 0 ? 0.0 : use / total;
243+
final expireShow = userInfo.expire == 0
244+
? appLocalizations.infiniteTime
245+
: DateTime.fromMillisecondsSinceEpoch(userInfo.expire * 1000).show;
246+
return [
247+
LinearProgressIndicator(
248+
minHeight: 6,
249+
value: progress,
250+
),
251+
const SizedBox(
252+
height: 8,
253+
),
254+
Text(
255+
"$useShow / $totalShow · $expireShow",
256+
style: context.textTheme.labelMedium?.toLight,
257+
),
258+
const SizedBox(
259+
height: 4,
260+
),
261+
];
262+
}
263+
264+
List<Widget> _buildUrlProfileInfo(Profile profile) {
265+
final userInfo = profile.userInfo;
266+
return [
267+
const SizedBox(
268+
height: 8,
269+
),
270+
if (userInfo != null) ..._buildUserInfo(userInfo),
271+
Text(
272+
profile.lastUpdateDate?.lastUpdateTimeDesc ?? "",
273+
style: context.textTheme.labelMedium?.toLight,
274+
),
275+
];
276+
}
277+
278+
List<Widget> _buildFileProfileInfo(Profile profile) {
279+
return [
280+
const SizedBox(
281+
height: 8,
282+
),
283+
Text(
284+
profile.lastUpdateDate?.lastUpdateTimeDesc ?? "",
285+
style: context.textTheme.labelMedium?.toLight,
286+
),
287+
];
288+
}
289+
234290
_buildTitle(Profile profile) {
235-
final textTheme = context.textTheme;
236291
return Container(
237292
padding: const EdgeInsets.symmetric(vertical: 4),
238293
child: Column(
239294
crossAxisAlignment: CrossAxisAlignment.start,
240295
mainAxisAlignment: MainAxisAlignment.center,
241296
children: [
242-
Row(
243-
mainAxisSize: MainAxisSize.max,
244-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
245-
children: [
246-
Flexible(
247-
child: Text(
248-
profile.label ?? profile.id,
249-
style: textTheme.titleMedium,
250-
maxLines: 1,
251-
overflow: TextOverflow.ellipsis,
252-
),
253-
),
254-
Text(
255-
profile.lastUpdateDate?.lastUpdateTimeDesc ?? '',
256-
style: textTheme.labelMedium?.toLight,
257-
),
258-
],
297+
Text(
298+
profile.label ?? profile.id,
299+
style: context.textTheme.titleMedium,
300+
maxLines: 1,
301+
overflow: TextOverflow.ellipsis,
259302
),
260-
Builder(builder: (context) {
261-
final userInfo = profile.userInfo ?? const UserInfo();
262-
final use = userInfo.upload + userInfo.download;
263-
final total = userInfo.total;
264-
final useShow = TrafficValue(value: use).show;
265-
final totalShow = TrafficValue(value: total).show;
266-
final progress = total == 0 ? 0.0 : use / total;
267-
final expireShow = userInfo.expire == 0
268-
? appLocalizations.infiniteTime
269-
: DateTime.fromMillisecondsSinceEpoch(userInfo.expire * 1000)
270-
.show;
271-
return Column(
272-
mainAxisSize: MainAxisSize.min,
273-
crossAxisAlignment: CrossAxisAlignment.start,
274-
mainAxisAlignment: MainAxisAlignment.center,
275-
children: [
276-
Container(
277-
margin: const EdgeInsets.symmetric(
278-
vertical: 8,
303+
Column(
304+
mainAxisSize: MainAxisSize.min,
305+
crossAxisAlignment: CrossAxisAlignment.start,
306+
mainAxisAlignment: MainAxisAlignment.center,
307+
children: [
308+
...switch (profile.type) {
309+
ProfileType.file => _buildFileProfileInfo(
310+
profile,
279311
),
280-
child: LinearProgressIndicator(
281-
minHeight: 6,
282-
value: progress,
312+
ProfileType.url => _buildUrlProfileInfo(
313+
profile,
283314
),
284-
),
285-
Text(
286-
"$useShow / $totalShow",
287-
style: textTheme.labelMedium?.toLight,
288-
),
289-
const SizedBox(
290-
height: 2,
291-
),
292-
Row(
293-
children: [
294-
Text(
295-
expireShow,
296-
style: textTheme.labelMedium?.toLight,
297-
),
298-
],
299-
)
300-
],
301-
);
302-
}),
315+
},
316+
],
317+
),
303318
],
304319
),
305320
);

lib/fragments/theme.dart

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ class ThemeFragment extends StatelessWidget {
2626
final previewCard = Padding(
2727
padding: const EdgeInsets.symmetric(horizontal: 16),
2828
child: CommonCard(
29-
onPressed: (){
30-
31-
},
29+
onPressed: () {},
3230
info: Info(
3331
label: appLocalizations.preview,
3432
iconData: Icons.looks,
@@ -87,7 +85,6 @@ class ThemeColorsBox extends StatefulWidget {
8785
}
8886

8987
class _ThemeColorsBoxState extends State<ThemeColorsBox> {
90-
9188
Widget _themeModeCheckBox({
9289
bool? isSelected,
9390
required ThemeModeItem themeModeItem,
@@ -229,6 +226,27 @@ class _ThemeColorsBoxState extends State<ThemeColorsBox> {
229226
),
230227
),
231228
),
229+
Padding(
230+
padding: const EdgeInsets.symmetric(vertical: 16),
231+
child: Selector<Config, bool>(
232+
selector: (_, config) => config.prueBlack,
233+
builder: (_, value, ___) {
234+
return ListItem.switchItem(
235+
leading: Icon(
236+
Icons.contrast,
237+
color: context.colorScheme.primary,
238+
),
239+
title: Text(appLocalizations.prueBlackMode),
240+
delegate: SwitchDelegate(
241+
value: value,
242+
onChanged: (value){
243+
globalState.appController.config.prueBlack = value;
244+
}
245+
),
246+
);
247+
},
248+
),
249+
)
232250
],
233251
);
234252
}

lib/l10n/arb/intl_en.arb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,5 +219,6 @@
219219
"autoCloseConnectionsDesc": "Auto close connections after change node",
220220
"onlyStatisticsProxy": "Only statistics proxy",
221221
"onlyStatisticsProxyDesc": "When turned on, only statistics proxy traffic",
222-
"deleteProfileTip": "Sure you want to delete the current profile?"
222+
"deleteProfileTip": "Sure you want to delete the current profile?",
223+
"prueBlackMode": "Prue black mode"
223224
}

lib/l10n/arb/intl_zh_CN.arb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,5 +219,6 @@
219219
"autoCloseConnectionsDesc": "切换节点后自动关闭连接",
220220
"onlyStatisticsProxy": "仅统计代理",
221221
"onlyStatisticsProxyDesc": "开启后,将只统计代理流量",
222-
"deleteProfileTip": "确定要删除当前配置吗?"
222+
"deleteProfileTip": "确定要删除当前配置吗?",
223+
"prueBlackMode": "纯黑模式"
223224
}

lib/l10n/intl/messages_en.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ class MessageLookup extends MessageLookupByLibrary {
257257
"proxyPort": MessageLookupByLibrary.simpleMessage("ProxyPort"),
258258
"proxyPortDesc": MessageLookupByLibrary.simpleMessage(
259259
"Set the Clash listening port"),
260+
"prueBlackMode":
261+
MessageLookupByLibrary.simpleMessage("Prue black mode"),
260262
"qrcode": MessageLookupByLibrary.simpleMessage("QR code"),
261263
"qrcodeDesc": MessageLookupByLibrary.simpleMessage(
262264
"Scan QR code to obtain profile"),

lib/l10n/intl/messages_zh_CN.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ class MessageLookup extends MessageLookupByLibrary {
208208
"proxyGroup": MessageLookupByLibrary.simpleMessage("代理组"),
209209
"proxyPort": MessageLookupByLibrary.simpleMessage("代理端口"),
210210
"proxyPortDesc": MessageLookupByLibrary.simpleMessage("设置Clash监听端口"),
211+
"prueBlackMode": MessageLookupByLibrary.simpleMessage("纯黑模式"),
211212
"qrcode": MessageLookupByLibrary.simpleMessage("二维码"),
212213
"qrcodeDesc": MessageLookupByLibrary.simpleMessage("扫描二维码获取配置文件"),
213214
"recovery": MessageLookupByLibrary.simpleMessage("恢复"),

0 commit comments

Comments
 (0)