aves_mio/lib/widgets/settings/settings_definition.dart
Fabio Micheluz 2c988f959b
Some checks are pending
Quality check / Flutter analysis (push) Waiting to run
Quality check / CodeQL analysis (java-kotlin) (push) Waiting to run
first commit
2026-02-19 13:25:23 +01:00

44 lines
1.3 KiB
Dart

import 'dart:async';
import 'package:aves/widgets/common/identity/aves_expansion_tile.dart';
import 'package:flutter/widgets.dart';
abstract class SettingsSection {
String get key;
Widget icon(BuildContext context);
String title(BuildContext context);
Future<List<SettingsTile>> tiles(BuildContext context);
Widget build(BuildContext sectionContext, ValueNotifier<String?> expandedNotifier) {
return FutureBuilder<List<SettingsTile>>(
future: tiles(sectionContext),
builder: (tileContext, snapshot) {
final tiles = snapshot.data;
if (tiles == null) return const SizedBox();
return AvesExpansionTile(
// key is expected by test driver
key: Key('section-$key'),
// use a fixed value instead of the title to identify this expansion tile
// so that the tile state is kept when the language is modified
value: key,
leading: icon(tileContext),
title: title(tileContext),
expandedNotifier: expandedNotifier,
showHighlight: false,
// reuse section context so that dialogs opened from tiles have the right text theme
children: tiles.map((v) => v.build(sectionContext)).toList(),
);
},
);
}
}
abstract class SettingsTile {
String title(BuildContext context);
Widget build(BuildContext context);
}