mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-07-22 14:10:37 -04:00
Accessibility update
This commit is contained in:
parent
be8014c97a
commit
3b1cb53b8a
55 changed files with 1089 additions and 807 deletions
63
lib/theme/views/styled_widgets/styled_checkbox.dart
Normal file
63
lib/theme/views/styled_widgets/styled_checkbox.dart
Normal file
|
@ -0,0 +1,63 @@
|
|||
import 'package:async_tools/async_tools.dart';
|
||||
import 'package:awesome_extensions/awesome_extensions_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../views.dart';
|
||||
|
||||
const _kStyledCheckboxChanged = 'kStyledCheckboxChanged';
|
||||
|
||||
class StyledCheckbox extends StatelessWidget {
|
||||
const StyledCheckbox(
|
||||
{required bool value,
|
||||
required String label,
|
||||
String? decoratorLabel,
|
||||
Future<void> Function(bool)? onChanged,
|
||||
super.key})
|
||||
: _value = value,
|
||||
_onChanged = onChanged,
|
||||
_label = label,
|
||||
_decoratorLabel = decoratorLabel;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final textTheme = theme.textTheme;
|
||||
|
||||
var textStyle = textTheme.labelLarge!;
|
||||
if (_onChanged == null) {
|
||||
textStyle = textStyle.copyWith(color: textStyle.color!.withAlpha(127));
|
||||
}
|
||||
|
||||
Widget ctrl = Row(children: [
|
||||
Transform.scale(
|
||||
scale: 1.scaled(context),
|
||||
child: Checkbox(
|
||||
value: _value,
|
||||
onChanged: _onChanged == null
|
||||
? null
|
||||
: (value) {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
singleFuture((this, _kStyledCheckboxChanged), () async {
|
||||
await _onChanged(value);
|
||||
});
|
||||
})),
|
||||
Text(_label, style: textStyle).paddingAll(4.scaled(context)),
|
||||
]);
|
||||
|
||||
if (_decoratorLabel != null) {
|
||||
ctrl = ctrl
|
||||
.paddingLTRB(4.scaled(context), 4.scaled(context), 4.scaled(context),
|
||||
4.scaled(context))
|
||||
.decoratorLabel(context, _decoratorLabel);
|
||||
}
|
||||
|
||||
return ctrl;
|
||||
}
|
||||
|
||||
final String _label;
|
||||
final String? _decoratorLabel;
|
||||
final Future<void> Function(bool)? _onChanged;
|
||||
final bool _value;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue