Skip to content

Commit

Permalink
fix(UX-1241): Fixed inkwell on ZetaStepper (#190)
Browse files Browse the repository at this point in the history
refactor: Optimized ZetaStepper to be made up of sub-components.
test: Wrote tests for ZetaStepper
  • Loading branch information
mikecoomber authored Oct 18, 2024
1 parent 58fc7f5 commit 60a137f
Show file tree
Hide file tree
Showing 12 changed files with 929 additions and 314 deletions.
47 changes: 4 additions & 43 deletions example/lib/pages/components/stepper_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,9 @@ class StepperExample extends StatefulWidget {
}

class _StepperExampleState extends State<StepperExample> {
int _sharpHorizontalStep = 0;
int _horistonalStep = 0;
int _verticalStep = 0;

ZetaStepType _getForStepIndex({
required int currentStep,
required int stepIndex,
}) {
if (currentStep == stepIndex) return ZetaStepType.enabled;
if (currentStep > stepIndex) return ZetaStepType.complete;

return ZetaStepType.disabled;
}

@override
Widget build(BuildContext context) {
return ExampleScaffold(
Expand All @@ -35,32 +25,17 @@ class _StepperExampleState extends State<StepperExample> {
SizedBox(
height: 150,
child: ZetaStepper(
currentStep: _sharpHorizontalStep,
onStepTapped: (index) => setState(() => _sharpHorizontalStep = index),
currentStep: _horistonalStep,
onStepTapped: (index) => setState(() => _horistonalStep = index),
steps: [
ZetaStep(
type: _getForStepIndex(
currentStep: _sharpHorizontalStep,
stepIndex: 0,
),
title: Text("Title"),
content: Text("Content"),
),
ZetaStep(
type: _getForStepIndex(
currentStep: _sharpHorizontalStep,
stepIndex: 1,
),
title: Text("Title 2"),
content: Text("Content 2"),
),
ZetaStep(
type: _getForStepIndex(
currentStep: _sharpHorizontalStep,
stepIndex: 2,
),
title: Text("Title 3"),
content: Text("Content 3"),
),
],
),
Expand All @@ -73,31 +48,17 @@ class _StepperExampleState extends State<StepperExample> {
onStepTapped: (index) => setState(() => _verticalStep = index),
steps: [
ZetaStep(
type: _getForStepIndex(
currentStep: _verticalStep,
stepIndex: 0,
),
title: Text("Title"),
subtitle: Text("Step Number"),
content: Text("Content"),
),
ZetaStep(
type: _getForStepIndex(
currentStep: _verticalStep,
stepIndex: 1,
),
title: Text("Title 2"),
subtitle: Text("Step Number"),
content: Text("Content 2"),
disabled: true,
),
ZetaStep(
type: _getForStepIndex(
currentStep: _verticalStep,
stepIndex: 2,
),
title: Text("Title 3"),
subtitle: Text("Step Number"),
content: Text("Content 3"),
),
],
),
Expand Down
15 changes: 0 additions & 15 deletions example/widgetbook/pages/components/stepper_widgetbook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ import '../../utils/scaffold.dart';
Widget stepperUseCase(BuildContext context) {
int currentStep = 0;

ZetaStepType getForStepIndex(int stepIndex) {
if (currentStep == stepIndex) return ZetaStepType.enabled;
if (currentStep > stepIndex) return ZetaStepType.complete;

return ZetaStepType.disabled;
}

final type = context.knobs.list(
label: "Type",
options: [
Expand All @@ -24,8 +17,6 @@ Widget stepperUseCase(BuildContext context) {
labelBuilder: (type) => type.name,
);

final enabledContent = context.knobs.boolean(label: 'Enabled Content', initialValue: true);

return WidgetbookScaffold(
builder: (context, _) => StatefulBuilder(
builder: (context, setState) {
Expand All @@ -40,19 +31,13 @@ Widget stepperUseCase(BuildContext context) {
type: type,
steps: [
ZetaStep(
type: getForStepIndex(0),
title: Text("Title"),
content: enabledContent ? Text("Content") : null,
),
ZetaStep(
type: getForStepIndex(1),
title: Text("Title 2"),
content: enabledContent ? Text("Content 2") : null,
),
ZetaStep(
type: getForStepIndex(2),
title: Text("Title 3"),
content: enabledContent ? Text("Content 3") : null,
),
],
),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/components/components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export 'segmented_control/segmented_control.dart';
export 'select_input/select_input.dart';
export 'slider/slider.dart';
export 'snack_bar/snack_bar.dart';
export 'stepper/stepper.dart';
export 'stepper/stepper.dart' hide HorizontalStep, StepDivider, StepIcon, VerticalStep;
export 'stepper_input/stepper_input.dart' hide ZetaStepperInputState;
export 'switch/zeta_switch.dart';
export 'tabs/tab.dart';
Expand Down
Loading

0 comments on commit 60a137f

Please sign in to comment.