ae208699d8
Keep the Material-only session UI and narrow its tests to the supported host. Preserve public Cupertino parameters for callers while removing unreachable Cupertino widgets and variants.
46 lines
1.4 KiB
Dart
46 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../../core/servers/server_catalog.dart';
|
|
import '../../../../core/servers/server_context.dart';
|
|
|
|
/// Select the machine before reading its harnesses or directory listing.
|
|
Future<SavedServer?> chooseChatMachine(BuildContext context) async {
|
|
final scope = ServerContext.maybeOf(context);
|
|
final servers = scope?.notifier?.catalog.servers ?? const <SavedServer>[];
|
|
if (servers.isEmpty) return null;
|
|
if (servers.length == 1) return servers.single;
|
|
return showDialog<SavedServer>(
|
|
context: context,
|
|
builder: (context) => SimpleDialog(
|
|
title: const Text('New chat on…'),
|
|
children: [
|
|
for (final server in servers)
|
|
SimpleDialogOption(
|
|
onPressed: () => Navigator.pop(context, server),
|
|
child: ListTile(
|
|
leading: const Icon(Icons.computer),
|
|
title: Text(server.name),
|
|
subtitle: Text(Uri.parse(server.endpoints.first).host),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Future<void> showChatMachineError(BuildContext context, String message) {
|
|
return showDialog<void>(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
title: const Text('Machine unavailable'),
|
|
content: Text(message),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context),
|
|
child: const Text('OK'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|