Skip to content

Commit

Permalink
ui: improve error readablity
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-ding committed Nov 5, 2024
1 parent 949b6e5 commit f1c4e30
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 26 deletions.
2 changes: 1 addition & 1 deletion ui/lib/activity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class _ActivityPageState extends ConsumerState<ActivityPage>
},
));
},
error: (err, trace) => Text("$err"),
error: (err, trace) => PoError(msg: "网络错误", err: err),
loading: () => const MyProgressIndicator());
})
],
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/settings/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class _AuthState extends ConsumerState<AuthSettings> {
],
));
},
error: (err, trace) => Text("$err"),
error: (err, trace) => PoError(msg: "网络错误", err: err),
loading: () => const MyProgressIndicator());
}
}
2 changes: 1 addition & 1 deletion ui/lib/settings/downloader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class _DownloaderState extends ConsumerState<DownloaderSettings> {
onTap: () => showDownloadClientDetails(DownloadClient()),
child: const Icon(Icons.add));
})),
error: (err, trace) => Text("$err"),
error: (err, trace) => PoError(msg: "网络错误", err: err),
loading: () => const MyProgressIndicator());
}

Expand Down
2 changes: 1 addition & 1 deletion ui/lib/settings/general.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class _GeneralState extends ConsumerState<GeneralSettings> {
),
);
},
error: (err, trace) => Text("$err"),
error: (err, trace) => PoError(msg: "网络错误", err: err),
loading: () => const MyProgressIndicator());
}
}
2 changes: 1 addition & 1 deletion ui/lib/settings/importlist.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class _ImportlistState extends ConsumerState<Importlist> {
child: const Icon(Icons.add));
}),
),
error: (err, trace) => Text("$err"),
error: (err, trace) => PoError(msg: "网络错误", err: err),
loading: () => const MyProgressIndicator());
}

Expand Down
2 changes: 1 addition & 1 deletion ui/lib/settings/indexer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class _IndexerState extends ConsumerState<IndexerSettings> {
child: const Icon(Icons.add));
}),
),
error: (err, trace) => Text("$err"),
error: (err, trace) => PoError(msg: "网络错误", err: err),
loading: () => const MyProgressIndicator());
}

Expand Down
2 changes: 1 addition & 1 deletion ui/lib/settings/notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class _NotifierState extends ConsumerState<NotifierSettings> {
child: const Icon(Icons.add));
}),
),
error: (err, trace) => Text("$err"),
error: (err, trace) => PoError(msg: "网络错误", err: err),
loading: () => const MyProgressIndicator());
}

Expand Down
2 changes: 1 addition & 1 deletion ui/lib/settings/prowlarr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ProwlarrSettingState extends ConsumerState<ProwlarrSettingPage> {
],
),
),
error: (err, trace) => Text("$err"),
error: (err, trace) => PoError(msg: "网络错误", err: err),
loading: () => const MyProgressIndicator());
}
}
2 changes: 1 addition & 1 deletion ui/lib/settings/storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class _StorageState extends ConsumerState<StorageSettings> {
child: const Icon(Icons.add));
}),
),
error: (err, trace) => Text("$err"),
error: (err, trace) => PoError(msg: "网络错误", err: err),
loading: () => const MyProgressIndicator());
}

Expand Down
6 changes: 3 additions & 3 deletions ui/lib/system_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class _SystemPageState extends ConsumerState<SystemPage> {
]);
}));
},
error: (err, trace) => Text("$err"),
error: (err, trace) => PoError(msg: "网络错误", err: err),
loading: () => const MyProgressIndicator())
],
),
Expand Down Expand Up @@ -111,7 +111,7 @@ class _SystemPageState extends ConsumerState<SystemPage> {
]),
]);
},
error: (err, trace) => Text("$err"),
error: (err, trace) => PoError(msg: "网络错误", err: err),
loading: () => const MyProgressIndicator())
],
),
Expand Down Expand Up @@ -185,7 +185,7 @@ class _SystemPageState extends ConsumerState<SystemPage> {
],
);
},
error: (err, trace) => Text("$err"),
error: (err, trace) => PoError(msg: "网络错误", err: err),
loading: () => const MyProgressIndicator())
],
)
Expand Down
4 changes: 1 addition & 3 deletions ui/lib/tv_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ class _TvDetailsPageState extends ConsumerState<TvDetailsPage> {
],
);
},
error: (err, trace) {
return Text("$err");
},
error: (err, trace) => PoError(msg: "网络错误", err: err),
loading: () => const MyProgressIndicator()));
}

Expand Down
22 changes: 11 additions & 11 deletions ui/lib/welcome_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ class WelcomePageState extends ConsumerState<WelcomePage> {
//alignment: Alignment.bottomRight,
children: [
() {
return switch (data) {
AsyncData(:final value) => SingleChildScrollView(
child: Wrap(
alignment: WrapAlignment.start,
spacing: isSmallScreen(context) ? 0 : 10,
runSpacing: isSmallScreen(context) ? 10 : 20,
children: getMediaAll(value),
),
),
_ => const MyProgressIndicator(),
};
return data.when(
data: (value) => SingleChildScrollView(
child: Wrap(
alignment: WrapAlignment.start,
spacing: isSmallScreen(context) ? 0 : 10,
runSpacing: isSmallScreen(context) ? 10 : 20,
children: getMediaAll(value),
),
),
error: (err, trace) => PoError(msg: "网络错误", err: err),
loading: () => const MyProgressIndicator());
}(),
getMoreButtonAndActions(uri)
],
Expand Down
20 changes: 20 additions & 0 deletions ui/lib/widgets/widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,23 @@ class _LoadingTextButtonState extends State<LoadingTextButton> {
);
}
}

class PoError extends StatelessWidget {
const PoError({super.key, required this.msg, required this.err});
final String msg;
final dynamic err;

@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("$msg ", style: TextStyle(color:Theme.of(context).colorScheme.error),),
Tooltip(
message: "$err",
child: Icon(Icons.info,color: Theme.of(context).colorScheme.error,),
)
],
);
}
}

0 comments on commit f1c4e30

Please sign in to comment.