mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-08-11 15:40:29 -04:00
accessibility work
This commit is contained in:
parent
be8014c97a
commit
de691cd778
48 changed files with 862 additions and 551 deletions
58
lib/theme/views/styled_widgets/styled_dropdown.dart
Normal file
58
lib/theme/views/styled_widgets/styled_dropdown.dart
Normal file
|
@ -0,0 +1,58 @@
|
|||
import 'package:async_tools/async_tools.dart';
|
||||
import 'package:awesome_extensions/awesome_extensions_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../models/models.dart';
|
||||
import '../views.dart';
|
||||
|
||||
const _kStyledDropdownChanged = 'kStyledDropdownChanged';
|
||||
|
||||
class StyledDropdown<T> extends StatelessWidget {
|
||||
const StyledDropdown(
|
||||
{required List<DropdownMenuItem<T>> items,
|
||||
required T value,
|
||||
String? decoratorLabel,
|
||||
Future<void> Function(T)? onChanged,
|
||||
super.key})
|
||||
: _items = items,
|
||||
_onChanged = onChanged,
|
||||
_decoratorLabel = decoratorLabel,
|
||||
_value = value;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final scheme = theme.extension<ScaleScheme>()!;
|
||||
|
||||
Widget ctrl = DropdownButton<T>(
|
||||
isExpanded: true,
|
||||
padding: const EdgeInsets.fromLTRB(4, 0, 4, 0).scaled(context),
|
||||
focusColor: theme.focusColor,
|
||||
dropdownColor: scheme.primaryScale.elementBackground,
|
||||
iconEnabledColor: scheme.primaryScale.appText,
|
||||
iconDisabledColor: scheme.primaryScale.appText.withAlpha(127),
|
||||
items: _items,
|
||||
value: _value,
|
||||
onChanged: _onChanged == null
|
||||
? null
|
||||
: (value) {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
singleFuture((this, _kStyledDropdownChanged), () async {
|
||||
await _onChanged(value);
|
||||
});
|
||||
});
|
||||
if (_decoratorLabel != null) {
|
||||
ctrl = ctrl
|
||||
.paddingLTRB(0, 4.scaled(context), 0, 4.scaled(context))
|
||||
.decoratorLabel(context, _decoratorLabel);
|
||||
}
|
||||
return ctrl;
|
||||
}
|
||||
|
||||
final List<DropdownMenuItem<T>> _items;
|
||||
final String? _decoratorLabel;
|
||||
final Future<void> Function(T)? _onChanged;
|
||||
final T _value;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue