Skip to content

Commit 6923792

Browse files
committed
Add feature: customizable halo for prebuilt indicators
1 parent d046d84 commit 6923792

File tree

4 files changed

+128
-100
lines changed

4 files changed

+128
-100
lines changed

lib/src/indicators/circular_slide_indicator.dart

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ import 'package:flutter/material.dart';
33
import 'slide_indicator.dart';
44

55
class CircularSlideIndicator implements SlideIndicator {
6-
const CircularSlideIndicator({
7-
this.itemSpacing = 20,
8-
this.indicatorRadius = 6,
9-
this.indicatorBorderWidth = 1,
10-
this.indicatorBorderColor,
11-
this.padding,
12-
this.alignment = Alignment.bottomCenter,
13-
this.currentIndicatorColor,
14-
this.indicatorBackgroundColor,
15-
});
6+
const CircularSlideIndicator(
7+
{this.itemSpacing = 20,
8+
this.indicatorRadius = 6,
9+
this.indicatorBorderWidth = 1,
10+
this.indicatorBorderColor,
11+
this.padding,
12+
this.alignment = Alignment.bottomCenter,
13+
this.currentIndicatorColor,
14+
this.indicatorBackgroundColor,
15+
this.haloDecoration,
16+
this.haloPadding});
1617

1718
final AlignmentGeometry alignment;
1819
final Color? currentIndicatorColor;
@@ -22,6 +23,8 @@ class CircularSlideIndicator implements SlideIndicator {
2223
final double indicatorRadius;
2324
final double itemSpacing;
2425
final EdgeInsets? padding;
26+
final BoxDecoration? haloDecoration;
27+
final EdgeInsets? haloPadding;
2528

2629
@override
2730
Widget build(int currentPage, double pageDelta, int itemCount) {
@@ -37,20 +40,24 @@ class CircularSlideIndicator implements SlideIndicator {
3740
return Container(
3841
alignment: alignment,
3942
padding: padding,
40-
child: SizedBox(
41-
width: itemCount * itemSpacing,
42-
height: indicatorRadius * 2,
43-
child: CustomPaint(
44-
painter: CircularIndicatorPainter(
45-
currentIndicatorColor: currentIndicatorColor ?? activeColor,
46-
indicatorBackgroundColor:
47-
indicatorBackgroundColor ?? backgroundColor,
48-
currentPage: currentPage,
49-
pageDelta: pageDelta,
50-
itemCount: itemCount,
51-
radius: indicatorRadius,
52-
indicatorBorderColor: indicatorBorderColor,
53-
borderWidth: indicatorBorderWidth,
43+
child: Container(
44+
decoration: haloDecoration,
45+
padding: haloPadding,
46+
child: SizedBox(
47+
width: itemCount * itemSpacing,
48+
height: indicatorRadius * 2,
49+
child: CustomPaint(
50+
painter: CircularIndicatorPainter(
51+
currentIndicatorColor: currentIndicatorColor ?? activeColor,
52+
indicatorBackgroundColor:
53+
indicatorBackgroundColor ?? backgroundColor,
54+
currentPage: currentPage,
55+
pageDelta: pageDelta,
56+
itemCount: itemCount,
57+
radius: indicatorRadius,
58+
indicatorBorderColor: indicatorBorderColor,
59+
borderWidth: indicatorBorderWidth,
60+
),
5461
),
5562
),
5663
),

lib/src/indicators/circular_static_indicator.dart

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@ import 'package:flutter/material.dart';
33
import 'slide_indicator.dart';
44

55
class CircularStaticIndicator extends SlideIndicator {
6-
CircularStaticIndicator({
7-
this.itemSpacing = 20,
8-
this.indicatorRadius = 6,
9-
this.padding,
10-
this.alignment = Alignment.bottomCenter,
11-
this.currentIndicatorColor,
12-
this.indicatorBackgroundColor,
13-
this.enableAnimation = false,
14-
this.indicatorBorderWidth = 1,
15-
this.indicatorBorderColor,
16-
});
6+
CircularStaticIndicator(
7+
{this.itemSpacing = 20,
8+
this.indicatorRadius = 6,
9+
this.padding,
10+
this.alignment = Alignment.bottomCenter,
11+
this.currentIndicatorColor,
12+
this.indicatorBackgroundColor,
13+
this.enableAnimation = false,
14+
this.indicatorBorderWidth = 1,
15+
this.indicatorBorderColor,
16+
this.haloDecoration,
17+
this.haloPadding});
1718

1819
final AlignmentGeometry alignment;
1920
final Color? currentIndicatorColor;
@@ -24,6 +25,8 @@ class CircularStaticIndicator extends SlideIndicator {
2425
final double indicatorRadius;
2526
final double itemSpacing;
2627
final EdgeInsets? padding;
28+
final BoxDecoration? haloDecoration;
29+
final EdgeInsets? haloPadding;
2730

2831
@override
2932
Widget build(int currentPage, double pageDelta, int itemCount) {
@@ -39,21 +42,25 @@ class CircularStaticIndicator extends SlideIndicator {
3942
return Container(
4043
alignment: alignment,
4144
padding: padding,
42-
child: SizedBox(
43-
width: itemCount * itemSpacing,
44-
height: indicatorRadius * 2,
45-
child: CustomPaint(
46-
painter: CircularStaticIndicatorPainter(
47-
currentIndicatorColor: currentIndicatorColor ?? activeColor,
48-
indicatorBackgroundColor:
49-
indicatorBackgroundColor ?? backgroundColor,
50-
currentPage: currentPage,
51-
pageDelta: pageDelta,
52-
itemCount: itemCount,
53-
radius: indicatorRadius,
54-
enableAnimation: enableAnimation,
55-
indicatorBorderColor: indicatorBorderColor,
56-
borderWidth: indicatorBorderWidth,
45+
child: Container(
46+
decoration: haloDecoration,
47+
padding: haloPadding,
48+
child: SizedBox(
49+
width: itemCount * itemSpacing,
50+
height: indicatorRadius * 2,
51+
child: CustomPaint(
52+
painter: CircularStaticIndicatorPainter(
53+
currentIndicatorColor: currentIndicatorColor ?? activeColor,
54+
indicatorBackgroundColor:
55+
indicatorBackgroundColor ?? backgroundColor,
56+
currentPage: currentPage,
57+
pageDelta: pageDelta,
58+
itemCount: itemCount,
59+
radius: indicatorRadius,
60+
enableAnimation: enableAnimation,
61+
indicatorBorderColor: indicatorBorderColor,
62+
borderWidth: indicatorBorderWidth,
63+
),
5764
),
5865
),
5966
),

lib/src/indicators/circular_wave_slide_indicator.dart

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ import 'package:flutter/material.dart';
33
import 'slide_indicator.dart';
44

55
class CircularWaveSlideIndicator implements SlideIndicator {
6-
CircularWaveSlideIndicator({
7-
this.itemSpacing = 20,
8-
this.indicatorRadius = 6,
9-
this.padding,
10-
this.alignment = Alignment.bottomCenter,
11-
this.currentIndicatorColor,
12-
this.indicatorBackgroundColor,
13-
this.indicatorBorderWidth = 1,
14-
this.indicatorBorderColor,
15-
});
6+
CircularWaveSlideIndicator(
7+
{this.itemSpacing = 20,
8+
this.indicatorRadius = 6,
9+
this.padding,
10+
this.alignment = Alignment.bottomCenter,
11+
this.currentIndicatorColor,
12+
this.indicatorBackgroundColor,
13+
this.indicatorBorderWidth = 1,
14+
this.indicatorBorderColor,
15+
this.haloDecoration,
16+
this.haloPadding});
1617

1718
final AlignmentGeometry alignment;
1819
final Color? currentIndicatorColor;
@@ -22,6 +23,8 @@ class CircularWaveSlideIndicator implements SlideIndicator {
2223
final double indicatorRadius;
2324
final double itemSpacing;
2425
final EdgeInsets? padding;
26+
final BoxDecoration? haloDecoration;
27+
final EdgeInsets? haloPadding;
2528

2629
@override
2730
Widget build(int currentPage, double pageDelta, int itemCount) {
@@ -37,20 +40,24 @@ class CircularWaveSlideIndicator implements SlideIndicator {
3740
return Container(
3841
alignment: alignment,
3942
padding: padding,
40-
child: SizedBox(
41-
width: itemCount * itemSpacing,
42-
height: indicatorRadius * 2,
43-
child: CustomPaint(
44-
painter: CircularWaveIndicatorPainter(
45-
currentIndicatorColor: currentIndicatorColor ?? activeColor,
46-
indicatorBackgroundColor:
47-
indicatorBackgroundColor ?? backgroundColor,
48-
currentPage: currentPage,
49-
pageDelta: pageDelta,
50-
itemCount: itemCount,
51-
radius: indicatorRadius,
52-
indicatorBorderColor: indicatorBorderColor,
53-
borderWidth: indicatorBorderWidth,
43+
child: Container(
44+
decoration: haloDecoration,
45+
padding: haloPadding,
46+
child: SizedBox(
47+
width: itemCount * itemSpacing,
48+
height: indicatorRadius * 2,
49+
child: CustomPaint(
50+
painter: CircularWaveIndicatorPainter(
51+
currentIndicatorColor: currentIndicatorColor ?? activeColor,
52+
indicatorBackgroundColor:
53+
indicatorBackgroundColor ?? backgroundColor,
54+
currentPage: currentPage,
55+
pageDelta: pageDelta,
56+
itemCount: itemCount,
57+
radius: indicatorRadius,
58+
indicatorBorderColor: indicatorBorderColor,
59+
borderWidth: indicatorBorderWidth,
60+
),
5461
),
5562
),
5663
),

lib/src/indicators/sequential_fill_indicator.dart

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@ import 'package:flutter/material.dart';
33
import 'slide_indicator.dart';
44

55
class SequentialFillIndicator extends SlideIndicator {
6-
SequentialFillIndicator({
7-
this.itemSpacing = 20,
8-
this.indicatorRadius = 6,
9-
this.padding,
10-
this.alignment = Alignment.bottomCenter,
11-
this.currentIndicatorColor,
12-
this.indicatorBackgroundColor,
13-
this.enableAnimation = false,
14-
this.indicatorBorderWidth = 1,
15-
this.indicatorBorderColor,
16-
});
6+
SequentialFillIndicator(
7+
{this.itemSpacing = 20,
8+
this.indicatorRadius = 6,
9+
this.padding,
10+
this.alignment = Alignment.bottomCenter,
11+
this.currentIndicatorColor,
12+
this.indicatorBackgroundColor,
13+
this.enableAnimation = false,
14+
this.indicatorBorderWidth = 1,
15+
this.indicatorBorderColor,
16+
this.haloDecoration,
17+
this.haloPadding});
1718

1819
final AlignmentGeometry alignment;
1920
final Color? currentIndicatorColor;
@@ -24,6 +25,8 @@ class SequentialFillIndicator extends SlideIndicator {
2425
final double indicatorRadius;
2526
final double itemSpacing;
2627
final EdgeInsets? padding;
28+
final BoxDecoration? haloDecoration;
29+
final EdgeInsets? haloPadding;
2730

2831
@override
2932
Widget build(int currentPage, double pageDelta, int itemCount) {
@@ -39,21 +42,25 @@ class SequentialFillIndicator extends SlideIndicator {
3942
return Container(
4043
alignment: alignment,
4144
padding: padding,
42-
child: SizedBox(
43-
width: itemCount * itemSpacing,
44-
height: indicatorRadius * 2,
45-
child: CustomPaint(
46-
painter: SequentialFillIndicatorPainter(
47-
currentIndicatorColor: currentIndicatorColor ?? activeColor,
48-
indicatorBackgroundColor:
49-
indicatorBackgroundColor ?? backgroundColor,
50-
currentPage: currentPage,
51-
pageDelta: pageDelta,
52-
itemCount: itemCount,
53-
radius: indicatorRadius,
54-
enableAnimation: enableAnimation,
55-
indicatorBorderColor: indicatorBorderColor,
56-
borderWidth: indicatorBorderWidth,
45+
child: Container(
46+
decoration: haloDecoration,
47+
padding: haloPadding,
48+
child: SizedBox(
49+
width: itemCount * itemSpacing,
50+
height: indicatorRadius * 2,
51+
child: CustomPaint(
52+
painter: SequentialFillIndicatorPainter(
53+
currentIndicatorColor: currentIndicatorColor ?? activeColor,
54+
indicatorBackgroundColor:
55+
indicatorBackgroundColor ?? backgroundColor,
56+
currentPage: currentPage,
57+
pageDelta: pageDelta,
58+
itemCount: itemCount,
59+
radius: indicatorRadius,
60+
enableAnimation: enableAnimation,
61+
indicatorBorderColor: indicatorBorderColor,
62+
borderWidth: indicatorBorderWidth,
63+
),
5764
),
5865
),
5966
),

0 commit comments

Comments
 (0)