545291e04a
- Run rows show a failed run's reason (else its diagnostic's first line, full text in a tooltip) or a short result preview; the Summary leads with "Why it failed". - Run again for succeeded/canceled/interrupted runs opens the New run form pre-filled (prompt, workspace, report format) at the latest version with the original offered. - Run detail and stage tabs show their names; touch shows captions on the Runs header and artifact viewer actions (desktop keeps tooltips). - ErrorNotice maps not connected / server too old / permission / timeout to what to do, raw detail behind Details (Schedules, create chat, Runs, Pipelines banners). - Settings has no Back arrow; Schedules keeps the rail on wide windows; phone Settings leads with Connection and Notifications and has a Jump to topic menu. - Walkthrough: Open Connection (skipped when connected), labelled Copy. - Pluralised counts; no duplicate status/rail names for screen readers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
240 lines
7.6 KiB
Dart
240 lines
7.6 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'settings_layout.dart';
|
|
import 'settings_page_chrome.dart';
|
|
import 'settings_section.dart';
|
|
import 'settings_skeleton.dart';
|
|
import 'settings_phone_order.dart';
|
|
|
|
/// The one Settings page: a pinned search field over a scrolling column of
|
|
/// grouped sections, with a jump index beside it on wide layouts.
|
|
///
|
|
/// Local sections render at once. A [SettingsSection.lazy] section shows a
|
|
/// skeleton until the list scrolls within a viewport of it or a search matches
|
|
/// it; once reached it stays mounted, so its loaded value survives scrolling.
|
|
class SettingsSearchPage extends StatefulWidget {
|
|
const SettingsSearchPage({super.key, required this.sections});
|
|
|
|
final List<SettingsSection> sections;
|
|
|
|
@override
|
|
State<SettingsSearchPage> createState() => _SettingsSearchPageState();
|
|
}
|
|
|
|
class _SettingsSearchPageState extends State<SettingsSearchPage> {
|
|
final TextEditingController _search = TextEditingController();
|
|
final ScrollController _scroll = ScrollController();
|
|
final GlobalKey _viewport = GlobalKey();
|
|
final Map<String, GlobalKey> _keys = {};
|
|
final Set<String> _activated = {};
|
|
String _query = '';
|
|
bool _activationScheduled = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_scheduleActivation();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_search.dispose();
|
|
_scroll.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
bool get _searching => _query.trim().isNotEmpty;
|
|
|
|
List<SettingsSection> get _visible => [
|
|
for (final section in widget.sections)
|
|
if (section.matches(_query)) section,
|
|
];
|
|
|
|
GlobalKey _keyFor(String id) => _keys.putIfAbsent(id, GlobalKey.new);
|
|
|
|
bool _isActive(SettingsSection section) =>
|
|
!section.lazy || _activated.contains(section.id) || _searching;
|
|
|
|
void _onQueryChanged(String value) {
|
|
setState(() {
|
|
_query = value;
|
|
if (_searching) {
|
|
_activated.addAll([
|
|
for (final section in _visible)
|
|
if (section.lazy) section.id,
|
|
]);
|
|
}
|
|
});
|
|
_scheduleActivation(jumpToFirstMatch: true);
|
|
}
|
|
|
|
/// Activation and jumps run after the frame: they read layout, and a scroll
|
|
/// notification may arrive during layout.
|
|
void _scheduleActivation({bool jumpToFirstMatch = false}) {
|
|
if (_activationScheduled) return;
|
|
_activationScheduled = true;
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
_activationScheduled = false;
|
|
if (!mounted) return;
|
|
if (jumpToFirstMatch) _jumpForQuery();
|
|
_activateNear();
|
|
});
|
|
}
|
|
|
|
void _jumpForQuery() {
|
|
if (_searching) {
|
|
final first = _visible.firstOrNull;
|
|
if (first != null) _jumpTo(first.id);
|
|
} else if (_scroll.hasClients) {
|
|
unawaited(
|
|
_scroll.animateTo(
|
|
0,
|
|
duration: const Duration(milliseconds: 200),
|
|
curve: Curves.easeOut,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
void _jumpTo(String id) {
|
|
final context = _keys[id]?.currentContext;
|
|
if (context == null) return;
|
|
unawaited(
|
|
Scrollable.ensureVisible(
|
|
context,
|
|
duration: const Duration(milliseconds: 250),
|
|
curve: Curves.easeOut,
|
|
),
|
|
);
|
|
}
|
|
|
|
void _activateNear() {
|
|
final viewport = _viewport.currentContext?.findRenderObject();
|
|
if (viewport is! RenderBox || !viewport.hasSize) return;
|
|
final top = viewport.localToGlobal(Offset.zero).dy;
|
|
final limit = top + viewport.size.height * (1 + settingsPreloadViewports);
|
|
var changed = false;
|
|
for (final section in widget.sections) {
|
|
if (!section.lazy || _activated.contains(section.id)) continue;
|
|
final box = _keys[section.id]?.currentContext?.findRenderObject();
|
|
if (box is! RenderBox || !box.hasSize || !box.attached) continue;
|
|
if (box.localToGlobal(Offset.zero).dy <= limit) {
|
|
_activated.add(section.id);
|
|
changed = true;
|
|
}
|
|
}
|
|
if (changed) setState(() {});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final insets = MediaQuery.paddingOf(context);
|
|
return LayoutBuilder(
|
|
builder: (context, constraints) {
|
|
final wide = constraints.maxWidth >= settingsIndexMinWidth;
|
|
// A phone leads with Connection and Notifications and jumps by menu.
|
|
final visible = wide ? _visible : settingsPhoneOrder(_visible);
|
|
return Row(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: <Widget>[
|
|
Expanded(
|
|
child: Padding(
|
|
padding: EdgeInsetsDirectional.fromSTEB(
|
|
insets.left + settingsPageSidePadding,
|
|
insets.top + settingsPageTopPadding,
|
|
insets.right + settingsPageSidePadding,
|
|
0,
|
|
),
|
|
child: Align(
|
|
alignment: Alignment.topCenter,
|
|
child: ConstrainedBox(
|
|
constraints: const BoxConstraints(
|
|
maxWidth: settingsContentMaxWidth,
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: <Widget>[
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: SettingsSearchField(
|
|
controller: _search,
|
|
onChanged: _onQueryChanged,
|
|
),
|
|
),
|
|
if (!wide && visible.length > 1)
|
|
SettingsTopicMenu(
|
|
sections: visible,
|
|
onJump: _jumpTo,
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: settingsSectionGap),
|
|
Expanded(child: _list(visible, insets)),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
if (wide && visible.isNotEmpty)
|
|
SizedBox(
|
|
width: settingsIndexWidth,
|
|
child: Padding(
|
|
padding: EdgeInsetsDirectional.only(
|
|
top: insets.top + settingsPageTopPadding,
|
|
),
|
|
child: SettingsSectionIndex(
|
|
sections: visible,
|
|
onJump: _jumpTo,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget _list(List<SettingsSection> visible, EdgeInsets insets) {
|
|
if (visible.isEmpty) {
|
|
return Padding(
|
|
padding: const EdgeInsets.all(settingsRowInset),
|
|
child: Text('No settings match "${_search.text.trim()}".'),
|
|
);
|
|
}
|
|
return NotificationListener<ScrollNotification>(
|
|
onNotification: (_) {
|
|
_scheduleActivation();
|
|
return false;
|
|
},
|
|
child: KeyedSubtree(
|
|
key: _viewport,
|
|
child: SingleChildScrollView(
|
|
key: const ValueKey<String>('settings.scroll'),
|
|
controller: _scroll,
|
|
padding: EdgeInsets.only(
|
|
bottom: insets.bottom + settingsPageBottomPadding,
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: <Widget>[
|
|
for (final (index, section) in visible.indexed) ...<Widget>[
|
|
if (index > 0) const SizedBox(height: settingsSectionGap),
|
|
KeyedSubtree(
|
|
key: _keyFor(section.id),
|
|
child: _isActive(section)
|
|
? Builder(builder: section.builder)
|
|
: SettingsSkeleton(title: section.title),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|