@@ -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 );
0 commit comments