Drop the per-machine connection bar from the chat
Saved machines' state and sign-in live in Settings; the chat no longer shows "<machine> · Connected" above both panes, which also pushed the thread pane below a bar that belongs to neither pane.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import '../core/servers/chat/chat_server_pool.dart';
|
||||
import '../core/servers/chat/chat_server_status.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../features/chat/screen.dart';
|
||||
@@ -42,11 +41,10 @@ class ChatDestination extends StatelessWidget {
|
||||
animation: Listenable.merge([session, ?pool]),
|
||||
builder: (context, _) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
// Saved machines connect independently; their state and sign-in live
|
||||
// in Settings, so the chat itself carries no connection chrome.
|
||||
if (pool != null && pool!.servers.catalog.servers.isNotEmpty) {
|
||||
return TopBarNotices(
|
||||
notices: [ChatServerStatusBar(pool: pool!)],
|
||||
child: _chatScreen(),
|
||||
);
|
||||
return _chatScreen();
|
||||
}
|
||||
if ((server.requiresConfiguration || server.error != null) &&
|
||||
session.endpoint == null) {
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import 'chat_server_pool.dart';
|
||||
import 'machine_sign_in_dialog.dart';
|
||||
|
||||
/// Connection problems on one machine never hide healthy machines' chats.
|
||||
class ChatServerStatusBar extends StatelessWidget {
|
||||
const ChatServerStatusBar({super.key, required this.pool});
|
||||
final ChatServerPool pool;
|
||||
Widget _connectButton(BuildContext context, ChatMachineStatus machine) {
|
||||
final label =
|
||||
'${machine.server.name} · ${machine.connecting ? 'Connecting' : 'Sign in'}';
|
||||
final action = machine.connecting
|
||||
? null
|
||||
: () => showMachineSignIn(
|
||||
context,
|
||||
name: machine.server.name,
|
||||
signIn: (password) => pool.signIn(machine.server.id, password),
|
||||
);
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoButton(
|
||||
onPressed: action,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
machine.connecting
|
||||
? CupertinoIcons.arrow_2_circlepath
|
||||
: CupertinoIcons.lock,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(label),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return TextButton.icon(
|
||||
onPressed: action,
|
||||
icon: Icon(machine.connecting ? Icons.sync : Icons.lock_outline),
|
||||
label: Text(label),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 4,
|
||||
children: [
|
||||
for (final machine in pool.machines)
|
||||
Tooltip(
|
||||
message:
|
||||
machine.error ?? (machine.connected ? 'Connected' : 'Connecting'),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (machine.connected)
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Text('${machine.server.name} · Connected'),
|
||||
)
|
||||
else
|
||||
_connectButton(context, machine),
|
||||
if (!machine.connected && !machine.connecting)
|
||||
usesCupertinoHost(context)
|
||||
? CupertinoButton(
|
||||
onPressed: () => pool.retry(machine.server.id),
|
||||
child: const Icon(CupertinoIcons.refresh),
|
||||
)
|
||||
: IconButton(
|
||||
tooltip: 'Retry ${machine.server.name}',
|
||||
onPressed: () => pool.retry(machine.server.id),
|
||||
icon: const Icon(Icons.refresh),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user