Skip to content

Commit

Permalink
pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecoomber committed May 8, 2024
1 parent beee8ac commit 3219128
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion example/lib/pages/components/stepper_input_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class _StepperInputExampleState extends State<StepperInputExample> {
),
ZetaStepperInput(rounded: false),
ZetaStepperInput(
size: ZetaWidgetSize.large,
size: ZetaStepperInputSize.large,
onChange: (_) {},
),
].divide(const SizedBox(height: 16)).toList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import '../../utils/utils.dart';
Widget stepperInputUseCase(BuildContext context) {
return WidgetbookTestWidget(
widget: ZetaStepperInput(
initialValue: context.knobs.intOrNull.input(label: 'Initial value'),
min: context.knobs.intOrNull.input(label: 'Minimum value'),
max: context.knobs.intOrNull.input(label: 'Maximum value'),
initialValue: context.knobs.int.input(label: 'Initial value'),
min: context.knobs.int.input(label: 'Minimum value'),
max: context.knobs.int.input(label: 'Maximum value'),
size: context.knobs.list(
label: 'Size',
options: ZetaWidgetSize.values,
options: ZetaStepperInputSize.values,
labelBuilder: enumLabelBuilder,
),
rounded: context.knobs.boolean(label: 'Rounded', initialValue: true),
Expand Down
19 changes: 14 additions & 5 deletions lib/src/components/stepper_input/stepper_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@ import 'package:flutter/services.dart';

import '../../../zeta_flutter.dart';

/// Sizes for [ZetaStepperInput]
enum ZetaStepperInputSize {
/// Medium
medium,

/// Large
large,
}

/// A stepper input, also called numeric stepper, is a common UI element that allows uers to input a number or value simply by clicking the plus and minus buttons.
class ZetaStepperInput extends StatefulWidget {
/// Creates a new [ZetaStepperInput]
const ZetaStepperInput({
this.rounded = true,
this.size = ZetaWidgetSize.medium,
this.size = ZetaStepperInputSize.medium,
this.initialValue,
this.min,
this.max,
Expand All @@ -24,7 +33,7 @@ class ZetaStepperInput extends StatefulWidget {
final bool rounded;

/// The size of the stepper input.
final ZetaWidgetSize size;
final ZetaStepperInputSize size;

/// The initial value of the stepper input.
///
Expand All @@ -47,7 +56,7 @@ class ZetaStepperInput extends StatefulWidget {
super.debugFillProperties(properties);
properties
..add(DiagnosticsProperty<bool>('rounded', rounded))
..add(EnumProperty<ZetaWidgetSize>('size', size))
..add(EnumProperty<ZetaStepperInputSize>('size', size))
..add(IntProperty('initialValue', initialValue))
..add(IntProperty('min', min))
..add(IntProperty('max', max))
Expand Down Expand Up @@ -88,7 +97,7 @@ class _ZetaStepperInputState extends State<ZetaStepperInput> {
}

double get _height {
if (widget.size != ZetaWidgetSize.large) {
if (widget.size != ZetaStepperInputSize.large) {
return ZetaSpacing.x10;
} else {
return ZetaSpacing.x12;
Expand Down Expand Up @@ -128,7 +137,7 @@ class _ZetaStepperInputState extends State<ZetaStepperInput> {
? ZetaIcons.remove_round
: ZetaIcons.remove_sharp,
type: ZetaButtonType.outlineSubtle,
size: widget.size == ZetaWidgetSize.small ? ZetaWidgetSize.medium : widget.size,
size: widget.size == ZetaStepperInputSize.medium ? ZetaWidgetSize.medium : ZetaWidgetSize.large,
borderType: widget.rounded ? ZetaWidgetBorder.rounded : ZetaWidgetBorder.sharp,
onPressed: !_disabled
? () => _onChange(
Expand Down

0 comments on commit 3219128

Please sign in to comment.