feat(flutter): 增加 debug 服务地址编辑器
This commit is contained in:
1 parent
eab5d3e230
commit
c259b0b543
9 files changed
+298
-5
No files matched your search
@@ -18,6 +18,7 @@ import '../../core/theme/app_theme.dart';
|
||||
import '../../core/widgets/app_bottom_nav.dart';
|
||||
import '../../core/widgets/app_pull_to_refresh.dart';
|
||||
import '../../core/widgets/catalog_debug_info.dart';
|
||||
import '../../core/widgets/catalog_endpoint_editor.dart';
|
||||
import '../../core/widgets/empty_state.dart';
|
||||
import '../../l10n/app_localizations.dart';
|
||||
import '../filter/filter_page.dart';
|
||||
@@ -258,7 +259,11 @@ class _DiscoverPageState extends State<DiscoverPage> {
|
||||
actionLabel: l10n.retry,
|
||||
onAction: () => unawaited(_retryCategories(categories)),
|
||||
footer: kDebugMode
|
||||
? CatalogDebugInfo(error: categories.debugError ?? error)
|
||||
? CatalogDebugInfo(
|
||||
error: categories.debugError ?? error,
|
||||
onEditEndpoint: () =>
|
||||
unawaited(_editCategoriesEndpoint(categories)),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
@@ -518,6 +523,10 @@ class _DiscoverPageState extends State<DiscoverPage> {
|
||||
return retryCatalogLoad(reload: categories.load);
|
||||
}
|
||||
|
||||
Future<void> _editCategoriesEndpoint(CategoryController categories) {
|
||||
return showCatalogEndpointEditor(context, reload: categories.load);
|
||||
}
|
||||
|
||||
void _act(DiscoverPageAction action) {
|
||||
logic.act(
|
||||
context,
|
||||
|
||||
@@ -16,6 +16,7 @@ import '../../core/platform/haptics.dart';
|
||||
import '../../core/theme/app_theme.dart';
|
||||
import '../../core/widgets/app_bottom_nav.dart';
|
||||
import '../../core/widgets/catalog_debug_info.dart';
|
||||
import '../../core/widgets/catalog_endpoint_editor.dart';
|
||||
import '../../core/widgets/empty_state.dart';
|
||||
import '../../l10n/app_localizations.dart';
|
||||
import '../discover/discover_types.dart';
|
||||
@@ -79,6 +80,10 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
||||
return retryCatalogLoad(reload: catalog.load);
|
||||
}
|
||||
|
||||
Future<void> _editHomeEndpoint(CatalogController catalog) {
|
||||
return showCatalogEndpointEditor(context, reload: catalog.load);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final catalog = context.watch<CatalogController>();
|
||||
@@ -107,6 +112,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
||||
body: HomeFailureView(
|
||||
error: catalog.debugError ?? catalog.error,
|
||||
onRetry: () => unawaited(_retryHome(catalog)),
|
||||
onEditEndpoint: () => unawaited(_editHomeEndpoint(catalog)),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -134,10 +140,16 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
||||
|
||||
/// 首页目录加载失败与重试入口。
|
||||
class HomeFailureView extends StatelessWidget {
|
||||
const HomeFailureView({super.key, this.error, required this.onRetry});
|
||||
const HomeFailureView({
|
||||
super.key,
|
||||
this.error,
|
||||
required this.onRetry,
|
||||
this.onEditEndpoint,
|
||||
});
|
||||
|
||||
final String? error;
|
||||
final VoidCallback onRetry;
|
||||
final VoidCallback? onEditEndpoint;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -147,7 +159,9 @@ class HomeFailureView extends StatelessWidget {
|
||||
title: l10n.catalogError,
|
||||
actionLabel: l10n.retry,
|
||||
onAction: onRetry,
|
||||
footer: kDebugMode ? CatalogDebugInfo(error: error) : null,
|
||||
footer: kDebugMode
|
||||
? CatalogDebugInfo(error: error, onEditEndpoint: onEditEndpoint)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user