@@ -23,6 +23,7 @@ class _ServerSettingsPageState extends State<ServerSettingsPage> {
2323 final _basicUsernameController = TextEditingController ();
2424 final _basicPasswordController = TextEditingController ();
2525 bool _basicEnabled = false ;
26+ bool _hasCheckedConnection = false ; // Only show status after explicit check/test
2627
2728 @override
2829 void initState () {
@@ -69,17 +70,18 @@ class _ServerSettingsPageState extends State<ServerSettingsPage> {
6970 appBar: AppBar (
7071 title: const Text ('Server Settings' ),
7172 actions: [
72- Consumer <AppProvider >(
73- builder: (context, appProvider, child) {
74- return IconButton (
75- icon: Icon (
76- appProvider.isConnected ? Icons .cloud_done : Icons .cloud_off,
77- color: appProvider.isConnected ? Colors .green : Colors .red,
78- ),
79- onPressed: () => _checkConnection (),
80- );
81- },
82- ),
73+ if (_hasCheckedConnection)
74+ Consumer <AppProvider >(
75+ builder: (context, appProvider, child) {
76+ return IconButton (
77+ icon: Icon (
78+ appProvider.isConnected ? Icons .cloud_done : Icons .cloud_off,
79+ color: appProvider.isConnected ? Colors .green : Colors .red,
80+ ),
81+ onPressed: () => _checkConnection (),
82+ );
83+ },
84+ ),
8385 ],
8486 ),
8587 resizeToAvoidBottomInset: true ,
@@ -95,65 +97,66 @@ class _ServerSettingsPageState extends State<ServerSettingsPage> {
9597 child: Column (
9698 crossAxisAlignment: CrossAxisAlignment .stretch,
9799 children: [
98- // Connection status card
99- Consumer <AppProvider >(
100- builder: (context, appProvider, child) {
101- return Card (
102- child: Padding (
103- padding: const EdgeInsets .all (
104- AppConstants .defaultPadding,
105- ),
106- child: Column (
107- crossAxisAlignment: CrossAxisAlignment .start,
108- children: [
109- Row (
110- children: [
111- Icon (
112- appProvider.isConnected
113- ? Icons .check_circle
114- : Icons .error,
115- color: appProvider.isConnected
116- ? Colors .green
117- : Colors .red,
118- ),
119- const SizedBox (width: AppConstants .smallPadding),
100+ // Connection status card (only visible after explicit test/check)
101+ if (_hasCheckedConnection)
102+ Consumer <AppProvider >(
103+ builder: (context, appProvider, child) {
104+ return Card (
105+ child: Padding (
106+ padding: const EdgeInsets .all (
107+ AppConstants .defaultPadding,
108+ ),
109+ child: Column (
110+ crossAxisAlignment: CrossAxisAlignment .start,
111+ children: [
112+ Row (
113+ children: [
114+ Icon (
115+ appProvider.isConnected
116+ ? Icons .check_circle
117+ : Icons .error,
118+ color: appProvider.isConnected
119+ ? Colors .green
120+ : Colors .red,
121+ ),
122+ const SizedBox (width: AppConstants .smallPadding),
123+ Text (
124+ appProvider.isConnected
125+ ? 'Connected'
126+ : 'Disconnected' ,
127+ style: Theme .of (context).textTheme.titleMedium,
128+ ),
129+ ],
130+ ),
131+ if (! appProvider.isConnected &&
132+ appProvider.errorMessage.isNotEmpty) ...[
133+ const SizedBox (height: AppConstants .smallPadding),
120134 Text (
121- appProvider.isConnected
122- ? 'Connected'
123- : 'Disconnected' ,
124- style: Theme .of (context).textTheme.titleMedium,
135+ appProvider.errorMessage,
136+ style: TextStyle (
137+ color: Theme .of (context).colorScheme.error,
138+ fontSize: 12 ,
139+ ),
125140 ),
126141 ],
127- ),
128- if (! appProvider.isConnected &&
129- appProvider.errorMessage.isNotEmpty) ...[
130- const SizedBox (height: AppConstants .smallPadding),
131- Text (
132- appProvider.errorMessage,
133- style: TextStyle (
134- color: Theme .of (context).colorScheme.error,
135- fontSize: 12 ,
142+ if (appProvider.isConnected &&
143+ appProvider.appInfo != null ) ...[
144+ const SizedBox (height: AppConstants .smallPadding),
145+ Text (
146+ 'Host: ${appProvider .appInfo !.hostname }' ,
147+ style: Theme .of (context).textTheme.bodySmall,
136148 ),
137- ),
138- ],
139- if (appProvider.isConnected &&
140- appProvider.appInfo != null ) ...[
141- const SizedBox (height: AppConstants .smallPadding),
142- Text (
143- 'Host: ${appProvider .appInfo !.hostname }' ,
144- style: Theme .of (context).textTheme.bodySmall,
145- ),
146- Text (
147- 'Working Directory: ${appProvider .appInfo !.path .cwd }' ,
148- style: Theme .of (context).textTheme.bodySmall,
149- ),
149+ Text (
150+ 'Working Directory: ${appProvider .appInfo !.path .cwd }' ,
151+ style: Theme .of (context).textTheme.bodySmall,
152+ ),
153+ ],
150154 ],
151- ] ,
155+ ) ,
152156 ),
153- ),
154- );
155- },
156- ),
157+ );
158+ },
159+ ),
157160
158161 const SizedBox (height: AppConstants .defaultPadding),
159162
@@ -376,6 +379,9 @@ class _ServerSettingsPageState extends State<ServerSettingsPage> {
376379 // Then test connection
377380 final appProvider = context.read <AppProvider >();
378381 await appProvider.getAppInfo ();
382+ setState (() {
383+ _hasCheckedConnection = true ;
384+ });
379385
380386 if (mounted) {
381387 if (appProvider.isConnected) {
@@ -400,6 +406,9 @@ class _ServerSettingsPageState extends State<ServerSettingsPage> {
400406 void _checkConnection () async {
401407 final appProvider = context.read <AppProvider >();
402408 await appProvider.checkConnection ();
409+ setState (() {
410+ _hasCheckedConnection = true ;
411+ });
403412
404413 if (mounted) {
405414 final message = appProvider.isConnected
0 commit comments