Skip to content

Commit

Permalink
v2.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
maelchiotti committed Dec 15, 2024
1 parent 7378393 commit 8a1426b
Show file tree
Hide file tree
Showing 17 changed files with 86 additions and 37 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 2.0.4

Update example

## 2.0.3

### Changed
Expand Down
3 changes: 2 additions & 1 deletion lib/src/section/setting_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class SettingSection extends StatelessWidget {
children: [
if (title != null)
Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
padding:
const EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
child: Text(
title!,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tiles/setting_action/setting_action_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SettingActionTile extends SettingTile {
});

/// Called when the tile is tapped.
final Function() onTap;
final VoidCallback onTap;

@override
Widget build(BuildContext context) {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tiles/setting_checkbox/setting_checkbox_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SettingCheckboxTile extends SettingTile {
/// Called when the status of the checkbox is changed.
///
/// If `null`, the tile will be disabled.
final Function(bool?)? onChanged;
final void Function(bool?)? onChanged;

@override
Widget build(BuildContext context) {
Expand Down
7 changes: 4 additions & 3 deletions lib/src/tiles/setting_color/setting_color_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ class SettingColorTile extends SettingTile {
final Color initialColor;

/// Called when the color is picked.
final Function(Color) onSubmitted;
final void Function(Color) onSubmitted;

/// Called when the dialog is canceled.
final Function()? onCanceled;
final VoidCallback? onCanceled;

Future<void> _openDialog(BuildContext context) async {
final colorPickersMap = {
for (final colorPickerType in ColorPickerType.values) colorPickerType: colorPickers.contains(colorPickerType),
for (final colorPickerType in ColorPickerType.values)
colorPickerType: colorPickers.contains(colorPickerType),
};

await ColorPicker(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ class SettingMultipleOptionsDialog<T> extends StatefulWidget {
final List<T>? defaultOptions;

@override
State<SettingMultipleOptionsDialog<T>> createState() => _SettingMultipleOptionsDialogState<T>();
State<SettingMultipleOptionsDialog<T>> createState() =>
_SettingMultipleOptionsDialogState<T>();
}

class _SettingMultipleOptionsDialogState<T> extends State<SettingMultipleOptionsDialog<T>> {
class _SettingMultipleOptionsDialogState<T>
extends State<SettingMultipleOptionsDialog<T>> {
late List<T> _selectedOptions;

@override
Expand Down Expand Up @@ -68,13 +70,19 @@ class _SettingMultipleOptionsDialogState<T> extends State<SettingMultipleOptions
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(
Localizations.of<MaterialLocalizations>(context, MaterialLocalizations)?.cancelButtonLabel ?? 'Cancel',
Localizations.of<MaterialLocalizations>(
context, MaterialLocalizations)
?.cancelButtonLabel ??
'Cancel',
),
),
TextButton(
onPressed: () => Navigator.pop(context, _selectedOptions),
child: Text(
Localizations.of<MaterialLocalizations>(context, MaterialLocalizations)?.okButtonLabel ?? 'OK',
Localizations.of<MaterialLocalizations>(
context, MaterialLocalizations)
?.okButtonLabel ??
'OK',
),
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class SettingMultipleOptionsTile<T> extends SettingTile {
this.initialOptions,
required this.onSubmitted,
this.onCanceled,
}) : options = options.map((e) => (value: e, title: e.toString(), subtitle: null)).toList();
}) : options = options
.map((e) => (value: e, title: e.toString(), subtitle: null))
.toList();

/// A setting tile with multiple options that can be checked.
Expand Down Expand Up @@ -55,10 +57,10 @@ class SettingMultipleOptionsTile<T> extends SettingTile {
final List<T>? initialOptions;

/// Called when the options are chosen.
final Function(List<T>) onSubmitted;
final void Function(List<T>) onSubmitted;

/// Called when the dialog is canceled.
final Function()? onCanceled;
final VoidCallback? onCanceled;

Future<void> _openDialog(BuildContext context) async {
final result = await showAdaptiveDialog<List<T>>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ class SettingSingleOptionDialog<T> extends StatefulWidget {
final T? defaultOption;

@override
State<SettingSingleOptionDialog<T>> createState() => _SettingSingleOptionDialogState<T>();
State<SettingSingleOptionDialog<T>> createState() =>
_SettingSingleOptionDialogState<T>();
}

class _SettingSingleOptionDialogState<T> extends State<SettingSingleOptionDialog<T>> {
class _SettingSingleOptionDialogState<T>
extends State<SettingSingleOptionDialog<T>> {
late T? _selectedOption;

@override
Expand Down Expand Up @@ -68,13 +70,19 @@ class _SettingSingleOptionDialogState<T> extends State<SettingSingleOptionDialog
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(
Localizations.of<MaterialLocalizations>(context, MaterialLocalizations)?.cancelButtonLabel ?? 'Cancel',
Localizations.of<MaterialLocalizations>(
context, MaterialLocalizations)
?.cancelButtonLabel ??
'Cancel',
),
),
TextButton(
onPressed: () => Navigator.pop(context, _selectedOption),
child: Text(
Localizations.of<MaterialLocalizations>(context, MaterialLocalizations)?.okButtonLabel ?? 'OK',
Localizations.of<MaterialLocalizations>(
context, MaterialLocalizations)
?.okButtonLabel ??
'OK',
),
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class SettingSingleOptionTile<T> extends SettingTile {
this.initialOption,
required this.onSubmitted,
this.onCanceled,
}) : options = options.map((option) => (value: option, title: option.toString(), subtitle: null)).toList();
}) : options = options
.map((option) =>
(value: option, title: option.toString(), subtitle: null))
.toList();

/// A setting tile with a single option that can be selected.
///
Expand Down Expand Up @@ -55,10 +58,10 @@ class SettingSingleOptionTile<T> extends SettingTile {
final T? initialOption;

/// Called when the option is chosen.
final Function(T) onSubmitted;
final void Function(T) onSubmitted;

/// Called when the dialog is canceled.
final Function()? onCanceled;
final VoidCallback? onCanceled;

Future<void> _openDialog(BuildContext context) async {
final result = await showAdaptiveDialog<T>(
Expand Down
18 changes: 13 additions & 5 deletions lib/src/tiles/setting_slider/setting_slider_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class SettingSliderDialog extends StatefulWidget {
final int? divisions;
final double initialValue;

final Function(double)? onChanged;
final void Function(double)? onChanged;

@override
State<SettingSliderDialog> createState() => _SettingSliderDialogState();
}

class _SettingSliderDialogState<T> extends State<SettingSliderDialog> {
class _SettingSliderDialogState extends State<SettingSliderDialog> {
late double _value;

@override
Expand All @@ -55,7 +55,9 @@ class _SettingSliderDialogState<T> extends State<SettingSliderDialog> {
content: SingleChildScrollView(
child: Slider(
value: _value,
label: widget.label != null ? widget.label!(_value) : _value.toStringAsFixed(2),
label: widget.label != null
? widget.label!(_value)
: _value.toStringAsFixed(2),
min: widget.min,
max: widget.max,
divisions: widget.divisions,
Expand All @@ -66,13 +68,19 @@ class _SettingSliderDialogState<T> extends State<SettingSliderDialog> {
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(
Localizations.of<MaterialLocalizations>(context, MaterialLocalizations)?.cancelButtonLabel ?? 'Cancel',
Localizations.of<MaterialLocalizations>(
context, MaterialLocalizations)
?.cancelButtonLabel ??
'Cancel',
),
),
TextButton(
onPressed: () => Navigator.pop(context, _value),
child: Text(
Localizations.of<MaterialLocalizations>(context, MaterialLocalizations)?.okButtonLabel ?? 'OK',
Localizations.of<MaterialLocalizations>(
context, MaterialLocalizations)
?.okButtonLabel ??
'OK',
),
),
],
Expand Down
6 changes: 3 additions & 3 deletions lib/src/tiles/setting_slider/setting_slider_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ class SettingSliderTile extends SettingTile {
final double initialValue;

/// Called when the slider value is changed.
final Function(double)? onChanged;
final void Function(double)? onChanged;

/// Called when the slider value is chosen.
final Function(double) onSubmitted;
final void Function(double) onSubmitted;

/// Called when the dialog is canceled.
final Function()? onCanceled;
final VoidCallback? onCanceled;

Future<void> _openDialog(BuildContext context) async {
final result = await showAdaptiveDialog<double>(
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tiles/setting_switch/setting_switch_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SettingSwitchTile extends SettingTile {
/// Called when the status of the switch is changed.
///
/// If `null`, the tile will be disabled.
final Function(bool)? onChanged;
final void Function(bool)? onChanged;

@override
Widget build(BuildContext context) {
Expand Down
12 changes: 9 additions & 3 deletions lib/src/tiles/setting_text_field/setting_text_field_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SettingTextFieldDialog extends StatefulWidget {
State<SettingTextFieldDialog> createState() => _SettingTextFieldDialogState();
}

class _SettingTextFieldDialogState<T> extends State<SettingTextFieldDialog> {
class _SettingTextFieldDialogState extends State<SettingTextFieldDialog> {
late TextEditingController _textEditingController;

@override
Expand All @@ -44,13 +44,19 @@ class _SettingTextFieldDialogState<T> extends State<SettingTextFieldDialog> {
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(
Localizations.of<MaterialLocalizations>(context, MaterialLocalizations)?.cancelButtonLabel ?? 'Cancel',
Localizations.of<MaterialLocalizations>(
context, MaterialLocalizations)
?.cancelButtonLabel ??
'Cancel',
),
),
TextButton(
onPressed: () => Navigator.pop(context, _textEditingController.text),
child: Text(
Localizations.of<MaterialLocalizations>(context, MaterialLocalizations)?.okButtonLabel ?? 'OK',
Localizations.of<MaterialLocalizations>(
context, MaterialLocalizations)
?.okButtonLabel ??
'OK',
),
),
],
Expand Down
4 changes: 2 additions & 2 deletions lib/src/tiles/setting_text_field/setting_text_field_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class SettingTextFieldTile extends SettingTile {
final String? initialText;

/// Called when the text is submitted.
final Function(String) onSubmitted;
final void Function(String) onSubmitted;

/// Called when the dialog is canceled.
final Function()? onCanceled;
final void Function()? onCanceled;

Future<void> _openDialog(BuildContext context) async {
final result = await showAdaptiveDialog<String>(
Expand Down
3 changes: 2 additions & 1 deletion lib/src/tiles/setting_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ abstract class SettingTile extends StatelessWidget {
final theme = Theme.of(context);

final titleMedium = theme.textTheme.titleMedium;
final titleSmall = theme.textTheme.titleSmall?.copyWith(color: theme.colorScheme.secondary);
final titleSmall = theme.textTheme.titleSmall
?.copyWith(color: theme.colorScheme.secondary);
final bodyMedium = theme.textTheme.bodyMedium;

return Expanded(
Expand Down
9 changes: 8 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# Dart
.PHONY: format

format:
dart format .

# Publishing
.PHONY: dry_run publish

dry_run:
dart pub publish --dry-run

publish:
dart pub publish
dart pub publish
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: "A collection of settings tiles to easily create a settings screen"
repository: https://github.com/maelchiotti/settings_tiles
issue_tracker: https://github.com/maelchiotti/settings_tiles/issues

version: 2.0.3
version: 2.0.4

environment:
sdk: ">=3.0.0 <4.0.0"
Expand Down

0 comments on commit 8a1426b

Please sign in to comment.