Skip to content

Commit 6c6adaf

Browse files
authored
feat : Progress Circle (ZebraDevs#31)
Authored-by: Osman <[email protected]>
1 parent 12cd2e5 commit 6c6adaf

File tree

9 files changed

+500
-36
lines changed

9 files changed

+500
-36
lines changed

example/lib/home.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import 'package:zeta_example/pages/components/navigation_bar_example.dart';
1313
import 'package:zeta_example/pages/theme/color_example.dart';
1414
import 'package:zeta_example/pages/components/password_input_example.dart';
1515
import 'package:zeta_example/pages/components/progress_example.dart';
16-
1716
import 'package:zeta_example/pages/assets/icons_example.dart';
1817
import 'package:zeta_example/widgets.dart';
1918
import 'package:zeta_flutter/zeta_flutter.dart';

example/lib/pages/components/progress_example.dart

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ class ProgressExampleState extends State<ProgressExample> {
2828
SizedBox(
2929
height: 20,
3030
),
31-
Wrapper(stepsCompleted: 0, type: ZetaProgressBarType.standard, isThin: false, stateChangeable: true),
31+
Wrapper(
32+
stepsCompleted: 0,
33+
type: ZetaProgressBarType.standard,
34+
isThin: false,
35+
stateChangeable: true),
3236
SizedBox(
3337
height: 20,
3438
),
@@ -38,6 +42,12 @@ class ProgressExampleState extends State<ProgressExample> {
3842
isThin: false,
3943
label: "UPLOADING ...",
4044
),
45+
Wrapper(
46+
stepsCompleted: 0,
47+
circleSize: ZetaCircleSizes.xl,
48+
rounded: false,
49+
isCircle: true,
50+
),
4151
]),
4252
),
4353
),
@@ -47,21 +57,26 @@ class ProgressExampleState extends State<ProgressExample> {
4757
}
4858

4959
class Wrapper extends StatefulWidget {
50-
const Wrapper(
51-
{super.key,
52-
required this.stepsCompleted,
53-
this.type = ZetaProgressBarType.standard,
54-
this.isThin = false,
55-
this.rounded = true,
56-
this.stateChangeable = false,
57-
this.label});
60+
const Wrapper({
61+
super.key,
62+
required this.stepsCompleted,
63+
this.type = ZetaProgressBarType.standard,
64+
this.isThin = false,
65+
this.rounded = true,
66+
this.stateChangeable = false,
67+
this.label,
68+
this.isCircle = false,
69+
this.circleSize,
70+
});
5871

5972
final int stepsCompleted;
60-
final bool rounded;
61-
final ZetaProgressBarType type;
62-
final bool isThin;
73+
final bool? rounded;
74+
final ZetaProgressBarType? type;
75+
final bool? isThin;
6376
final String? label;
64-
final bool stateChangeable;
77+
final bool? stateChangeable;
78+
final bool isCircle;
79+
final ZetaCircleSizes? circleSize;
6580

6681
@override
6782
State<Wrapper> createState() => _WrapperState();
@@ -75,7 +90,7 @@ class _WrapperState extends State<Wrapper> {
7590
@override
7691
void initState() {
7792
super.initState();
78-
type = widget.type;
93+
type = widget.type!;
7994
stepsCompleted = widget.stepsCompleted;
8095
progress = stepsCompleted / 10;
8196
}
@@ -90,7 +105,9 @@ class _WrapperState extends State<Wrapper> {
90105

91106
void setLoading() {
92107
setState(() {
93-
type = type == ZetaProgressBarType.buffering ? ZetaProgressBarType.standard : ZetaProgressBarType.buffering;
108+
type = type == ZetaProgressBarType.buffering
109+
? ZetaProgressBarType.standard
110+
: ZetaProgressBarType.buffering;
94111
});
95112
}
96113

@@ -99,20 +116,35 @@ class _WrapperState extends State<Wrapper> {
99116
return Column(
100117
// Replace with a Column for vertical
101118
children: [
102-
SizedBox(
103-
width: 400,
104-
child: ZetaProgressBar(
105-
progress: progress, rounded: widget.rounded, type: type, isThin: widget.isThin, label: widget.label),
106-
),
119+
widget.isCircle
120+
? Center(
121+
child: ZetaProgressCircle(
122+
progress: progress,
123+
size: widget.circleSize!,
124+
),
125+
)
126+
: SizedBox(
127+
width: 400,
128+
child: ZetaProgressBar(
129+
progress: progress,
130+
rounded: widget.rounded!,
131+
type: type,
132+
isThin: widget.isThin!,
133+
label: widget.label),
134+
),
107135
const SizedBox(width: 40),
108136
Row(
109137
mainAxisAlignment: MainAxisAlignment.center,
110138
children: [
111139
widget.type != ZetaProgressBarType.indeterminate
112-
? FilledButton(onPressed: increasePercentage, child: Text("Increase"))
140+
? FilledButton(
141+
onPressed: increasePercentage, child: Text("Increase"))
113142
: Container(),
114143
const SizedBox(width: 40),
115-
widget.stateChangeable ? FilledButton(onPressed: setLoading, child: Text("Start Buffering")) : Container()
144+
widget.stateChangeable!
145+
? FilledButton(
146+
onPressed: setLoading, child: Text("Start Buffering"))
147+
: SizedBox.shrink()
116148
],
117149
)
118150
],

example/widgetbook/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class HotReload extends StatelessWidget {
8484
name: 'Progress',
8585
useCases: [
8686
WidgetbookUseCase(name: 'Bar', builder: (context) => progressBarUseCase(context)),
87+
WidgetbookUseCase(name : 'Circle', builder : (context) => progressCircleUseCase(context))
8788
],
8889
),
8990
]..sort((a, b) => a.name.compareTo(b.name)),

example/widgetbook/pages/components/progress_widgetbook.dart

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,32 @@ Widget progressBarUseCase(BuildContext context) => WidgetbookTestWidget(
99
return SizedBox(
1010
width: constraints.maxWidth - ZetaSpacing.xl,
1111
child: ZetaProgressBar(
12-
progress: context.knobs.double.slider(label: 'Progress', min: 0, max: 1, initialValue: 0.5).toDouble(),
13-
type: context.knobs
14-
.list(label: 'Type', options: ZetaProgressBarType.values, labelBuilder: (value) => value.name),
12+
progress: context.knobs.double
13+
.slider(label: 'Progress', min: 0, max: 1, initialValue: 0.5)
14+
.toDouble(),
15+
type: context.knobs.list(
16+
label: 'Type',
17+
options: ZetaProgressBarType.values,
18+
labelBuilder: (value) => value.name),
1519
isThin: context.knobs.boolean(label: 'Thin'),
1620
rounded: context.knobs.boolean(label: 'Rounded'),
1721
label: context.knobs.stringOrNull(label: 'Label'),
1822
),
1923
);
2024
}),
2125
);
26+
27+
Widget progressCircleUseCase(BuildContext context) =>
28+
WidgetbookTestWidget(widget:
29+
ZetaProgressCircle(
30+
progress: context.knobs.double
31+
.slider(label: 'Progress', min: 0, max: 1, initialValue: 0.5)
32+
.toDouble(),
33+
rounded: context.knobs.boolean(label: 'Rounded'),
34+
size: context.knobs.list(
35+
initialOption: ZetaCircleSizes.xl,
36+
label: 'Size',
37+
options: ZetaCircleSizes.values,
38+
labelBuilder: (value) => value.name),
39+
),
40+
);

0 commit comments

Comments
 (0)