|
1 | 1 | import 'package:flutter/material.dart'; |
2 | | - |
3 | | -import 'slide_indicator.dart'; |
| 2 | +import 'package:flutter_carousel_widget/flutter_carousel_widget.dart'; |
4 | 3 |
|
5 | 4 | class CircularStaticIndicator extends SlideIndicator { |
6 | 5 | 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, |
| 6 | + this.slideIndicatorOptions = const SlideIndicatorOptions(), |
16 | 7 | }); |
17 | 8 |
|
18 | | - final AlignmentGeometry alignment; |
19 | | - final Color? currentIndicatorColor; |
20 | | - final bool enableAnimation; |
21 | | - final Color? indicatorBackgroundColor; |
22 | | - final Color? indicatorBorderColor; |
23 | | - final double indicatorBorderWidth; |
24 | | - final double indicatorRadius; |
25 | | - final double itemSpacing; |
26 | | - final EdgeInsets? padding; |
| 9 | + final SlideIndicatorOptions slideIndicatorOptions; |
27 | 10 |
|
28 | 11 | @override |
29 | 12 | Widget build(int currentPage, double pageDelta, int itemCount) { |
30 | | - var activeColor = const Color(0xFFFFFFFF); |
31 | | - var backgroundColor = const Color(0x66FFFFFF); |
32 | | - |
33 | | - // if (SchedulerBinding.instance.window.platformBrightness == |
34 | | - // Brightness.light) { |
35 | | - // activeColor = const Color(0xFF000000); |
36 | | - // backgroundColor = const Color(0xFF878484); |
37 | | - // } |
38 | | - |
39 | 13 | return Container( |
40 | | - alignment: alignment, |
41 | | - 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, |
| 14 | + alignment: slideIndicatorOptions.alignment, |
| 15 | + padding: slideIndicatorOptions.padding, |
| 16 | + child: Container( |
| 17 | + decoration: slideIndicatorOptions.enableHalo |
| 18 | + ? slideIndicatorOptions.haloDecoration |
| 19 | + : null, |
| 20 | + padding: slideIndicatorOptions.enableHalo |
| 21 | + ? slideIndicatorOptions.haloPadding |
| 22 | + : null, |
| 23 | + child: SizedBox( |
| 24 | + width: itemCount * slideIndicatorOptions.itemSpacing, |
| 25 | + height: slideIndicatorOptions.indicatorRadius * 2, |
| 26 | + child: CustomPaint( |
| 27 | + painter: CircularStaticIndicatorPainter( |
| 28 | + currentIndicatorColor: |
| 29 | + slideIndicatorOptions.currentIndicatorColor, |
| 30 | + indicatorBackgroundColor: |
| 31 | + slideIndicatorOptions.indicatorBackgroundColor, |
| 32 | + currentPage: currentPage, |
| 33 | + pageDelta: pageDelta, |
| 34 | + itemCount: itemCount, |
| 35 | + radius: slideIndicatorOptions.indicatorRadius, |
| 36 | + enableAnimation: slideIndicatorOptions.enableAnimation, |
| 37 | + indicatorBorderColor: slideIndicatorOptions.indicatorBorderColor, |
| 38 | + borderWidth: slideIndicatorOptions.indicatorBorderWidth, |
| 39 | + ), |
57 | 40 | ), |
58 | 41 | ), |
59 | 42 | ), |
|
0 commit comments