3ec580c2d9
Servers become rows with a selection mark, addresses as subtitles and a Use/Edit/Remove menu plus an Add server row; the connection is a status row with address and Reconnect/Disconnect rows; Templates and Schedules are chevron rows in a Library group. Material groups are flat surfaceContainer surfaces with primary titleSmall headers (no Cards); Cupertino uses inset-grouped sections on the grouped background, switches for the ntfy choices. The trust warning is a footer, helper copy is shortened, Save workspace is a legible tonal/plain button, and the column starts at the bar's inset (max 720) instead of being centred. The page pads by the top media padding instead of a top SafeArea.
87 lines
2.4 KiB
Dart
87 lines
2.4 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'settings_theme.dart';
|
|
|
|
/// One row of a [SettingsGroup]: Material [ListTile], Cupertino
|
|
/// [CupertinoListTile]. The subtitle wraps (the Cupertino tile otherwise caps
|
|
/// it at one line), so addresses and status details stay readable at large
|
|
/// text.
|
|
class SettingsRow extends StatelessWidget {
|
|
const SettingsRow({
|
|
super.key,
|
|
required this.title,
|
|
this.subtitle,
|
|
this.leading,
|
|
this.trailing,
|
|
this.onTap,
|
|
this.chevron = false,
|
|
this.action = false,
|
|
this.enabled = true,
|
|
});
|
|
|
|
final Widget title;
|
|
final Widget? subtitle;
|
|
final Widget? leading;
|
|
final Widget? trailing;
|
|
final VoidCallback? onTap;
|
|
|
|
/// A navigation row: shows the platform's disclosure chevron.
|
|
final bool chevron;
|
|
|
|
/// A command row (Reconnect, Add server): the title takes the accent
|
|
/// colour, as a button would.
|
|
final bool action;
|
|
final bool enabled;
|
|
|
|
Widget _wrapping(Widget child) => Builder(
|
|
builder: (context) => DefaultTextStyle(
|
|
style: DefaultTextStyle.of(context).style,
|
|
child: child,
|
|
),
|
|
);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final tap = enabled ? onTap : null;
|
|
final subtitle = this.subtitle;
|
|
if (usesCupertinoControls(context)) {
|
|
final accent = CupertinoTheme.of(context).primaryColor;
|
|
final disabled = CupertinoColors.tertiaryLabel.resolveFrom(context);
|
|
return CupertinoListTile(
|
|
leading: leading == null
|
|
? null
|
|
: IconTheme.merge(
|
|
data: IconThemeData(color: enabled ? accent : disabled),
|
|
child: leading!,
|
|
),
|
|
title: DefaultTextStyle.merge(
|
|
style: TextStyle(
|
|
color: !enabled
|
|
? disabled
|
|
: action
|
|
? accent
|
|
: null,
|
|
),
|
|
child: title,
|
|
),
|
|
subtitle: subtitle == null ? null : _wrapping(subtitle),
|
|
trailing:
|
|
trailing ?? (chevron ? const CupertinoListTileChevron() : null),
|
|
onTap: tap,
|
|
);
|
|
}
|
|
final scheme = Theme.of(context).colorScheme;
|
|
return ListTile(
|
|
enabled: enabled,
|
|
leading: leading,
|
|
iconColor: action ? scheme.primary : null,
|
|
textColor: action ? scheme.primary : null,
|
|
title: title,
|
|
subtitle: subtitle,
|
|
trailing: trailing ?? (chevron ? const Icon(Icons.chevron_right) : null),
|
|
onTap: tap,
|
|
);
|
|
}
|
|
}
|