3933ff980c
Keep the Material settings implementation while preserving public Cupertino parameters for later cleanup. Narrow settings tests to the Material-only behavior.
58 lines
1.9 KiB
Dart
58 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../core/transport/pipelines_client.dart' as transport;
|
|
import 'settings_controller.dart';
|
|
import 'settings_row.dart';
|
|
import 'settings_theme.dart';
|
|
|
|
/// The connection's state as one row: a status icon, the state as the title
|
|
/// and the build/time/reason/backoff facts as its subtitle lines. Missing ping
|
|
/// values stay explicit.
|
|
class SettingsStatusRow extends StatelessWidget {
|
|
const SettingsStatusRow({super.key, required this.controller});
|
|
|
|
final SettingsController controller;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final state = controller.connection;
|
|
final lines = controller.connectionLines;
|
|
final title = lines.isEmpty ? '' : lines.first;
|
|
final details = lines.length > 1 ? lines.sublist(1) : const <String>[];
|
|
final connectedColor = Theme.of(context).colorScheme.primary;
|
|
final Color? color = switch (state.kind) {
|
|
transport.ConnectionKind.connected => connectedColor,
|
|
transport.ConnectionKind.disconnected => settingsErrorColor(context),
|
|
_ => null,
|
|
};
|
|
final Widget leading = switch (state.kind) {
|
|
transport.ConnectionKind.connecting => const SizedBox.square(
|
|
dimension: 20,
|
|
child: CircularProgressIndicator(strokeWidth: 2),
|
|
),
|
|
transport.ConnectionKind.connected => Icon(
|
|
Icons.check_circle,
|
|
color: color,
|
|
),
|
|
transport.ConnectionKind.disconnected => Icon(
|
|
Icons.error_outline,
|
|
color: color,
|
|
),
|
|
transport.ConnectionKind.idle => Icon(Icons.radio_button_unchecked),
|
|
};
|
|
return SettingsRow(
|
|
leading: leading,
|
|
title: Text(
|
|
title,
|
|
style: TextStyle(color: color, fontWeight: FontWeight.w600),
|
|
),
|
|
subtitle: details.isEmpty
|
|
? null
|
|
: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[for (final line in details) Text(line)],
|
|
),
|
|
);
|
|
}
|
|
}
|