fix(flutter): 增加首页服务器设置并更新真机默认地址

This commit is contained in:
Zhou Weidong committed 2026-10-17 23:12:47 +08:00
1 parent 9fe62d13cb
commit c4694c6f18
13 files changed
+264 -143

No files matched your search

+51 -22
View File
@@ -15,6 +15,7 @@ import '../../core/theme/app_colors.dart';
import '../../core/theme/app_theme.dart';
import '../../core/widgets/auth_gate.dart';
import '../../core/widgets/empty_state.dart';
import '../../core/widgets/server_endpoint_dialog.dart';
import '../../l10n/app_localizations.dart';
import '../discover/discover_view.dart';
import '../mine/mine_view.dart';
@@ -50,28 +51,9 @@ class HomePage extends StatelessWidget {
if (catalog.error != null) {
return Scaffold(
backgroundColor: Colors.black,
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.error_outline_rounded,
color: Colors.white70,
size: 40,
),
const SizedBox(height: 12),
Text(l10n.catalogError),
const SizedBox(height: 12),
FilledButton(onPressed: catalog.load, child: Text(l10n.retry)),
if (kDebugMode) ...[
const SizedBox(height: 16),
Text(
AppConfig.apiBaseUrl,
style: const TextStyle(fontSize: 12, color: Colors.white54),
),
],
],
),
body: HomeFailureView(
onRetry: catalog.load,
showDebugTools: kDebugMode,
),
);
}
@@ -96,6 +78,53 @@ class HomePage extends StatelessWidget {
}
}
/// Home catalog failure with optional debug-only endpoint controls.
class HomeFailureView extends StatelessWidget {
const HomeFailureView({
super.key,
required this.onRetry,
this.showDebugTools = kDebugMode,
});
final VoidCallback onRetry;
final bool showDebugTools;
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.error_outline_rounded,
color: Colors.white70,
size: 40,
),
const SizedBox(height: 12),
Text(l10n.catalogError),
const SizedBox(height: 12),
FilledButton(onPressed: onRetry, child: Text(l10n.retry)),
if (showDebugTools) ...[
const SizedBox(height: 16),
Text(
AppConfig.apiBaseUrl,
style: const TextStyle(fontSize: 12, color: Colors.white54),
),
const SizedBox(height: 8),
OutlinedButton.icon(
key: const Key('home-server-settings'),
onPressed: () => showServerEndpointDialog(context, l10n),
icon: const Icon(Icons.dns_outlined),
label: Text(l10n.serverSettings),
),
],
],
),
);
}
}
/// The three primary destinations share a single route and keep their state.
class _HomeTabs extends StatefulWidget {
const _HomeTabs({super.key, required this.dramas});