|
| 1 | +import 'package:flutter/cupertino.dart'; |
| 2 | +import 'package:flutter/material.dart'; |
| 3 | + |
| 4 | +class GFIntroBottomNavigation extends StatelessWidget { |
| 5 | + const GFIntroBottomNavigation({ |
| 6 | + Key key, |
| 7 | + this.rightText = 'NEXT', |
| 8 | + this.pageNumber = 0, |
| 9 | + this.onNext, |
| 10 | + this.showDivider = true, |
| 11 | + this.dividerColor = Colors.grey, |
| 12 | + this.dividerHeight = 1, |
| 13 | + this.dividerThickness = 0.0, |
| 14 | + this.child, |
| 15 | + this.padding = const EdgeInsets.all(8), |
| 16 | + this.margin = const EdgeInsets.all(8), |
| 17 | + this.pagesCount = 0, |
| 18 | + this.skipText = 'SKIP', |
| 19 | + this.onSkipTap, |
| 20 | + this.skipWidget, |
| 21 | + this.rightWidget, |
| 22 | + this.dotShape = BoxShape.circle, |
| 23 | + this.defaultColor, |
| 24 | + this.activeColor, |
| 25 | + this.dotHeight, |
| 26 | + this.dotWidth, |
| 27 | + this.dotMargin, |
| 28 | + this.skipStyle, |
| 29 | + this.rightStyle, |
| 30 | + this.onDoneTap, |
| 31 | + this.doneText = 'GO', |
| 32 | + }) : super(key: key); |
| 33 | + |
| 34 | + final String rightText; |
| 35 | + final int pageNumber; |
| 36 | + final VoidCallback onNext; |
| 37 | + final bool showDivider; |
| 38 | + final double dividerHeight; |
| 39 | + final double dividerThickness; |
| 40 | + final Color dividerColor; |
| 41 | + final Widget child; |
| 42 | + final int pagesCount; |
| 43 | + final String skipText; |
| 44 | + final VoidCallback onSkipTap; |
| 45 | + final VoidCallback onDoneTap; |
| 46 | + final EdgeInsets padding; |
| 47 | + final EdgeInsets margin; |
| 48 | + final Widget skipWidget; |
| 49 | + final Widget rightWidget; |
| 50 | + final TextStyle skipStyle; |
| 51 | + final TextStyle rightStyle; |
| 52 | + final String doneText; |
| 53 | + |
| 54 | + ///dot |
| 55 | + final BoxShape dotShape; |
| 56 | + final Color defaultColor; |
| 57 | + final Color activeColor; |
| 58 | + final double dotHeight; |
| 59 | + final double dotWidth; |
| 60 | + final EdgeInsets dotMargin; |
| 61 | + |
| 62 | + @override |
| 63 | + Widget build(BuildContext context) => Container( |
| 64 | + child: DefaultTextStyle( |
| 65 | + style: const TextStyle( |
| 66 | + color: Colors.black, |
| 67 | + fontSize: 16, |
| 68 | + ), |
| 69 | + child: Column( |
| 70 | + mainAxisAlignment: MainAxisAlignment.end, |
| 71 | + children: <Widget>[ |
| 72 | + showDivider |
| 73 | + ? Divider( |
| 74 | + height: dividerHeight, |
| 75 | + thickness: dividerThickness, |
| 76 | + color: dividerColor, |
| 77 | + ) |
| 78 | + : Container(), |
| 79 | + Container( |
| 80 | + padding: padding, |
| 81 | + margin: margin, |
| 82 | + child: Row( |
| 83 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, |
| 84 | + children: <Widget>[ |
| 85 | + GestureDetector( |
| 86 | + behavior: HitTestBehavior.translucent, |
| 87 | + child: Padding( |
| 88 | + padding: const EdgeInsets.only( |
| 89 | + top: 8, |
| 90 | + bottom: 8, |
| 91 | + left: 24, |
| 92 | + right: 32, |
| 93 | + ), |
| 94 | + child: skipWidget ?? |
| 95 | + Text( |
| 96 | + skipText, |
| 97 | + style: skipStyle ?? |
| 98 | + const TextStyle( |
| 99 | + color: Colors.black, |
| 100 | + fontSize: 16, |
| 101 | + ), |
| 102 | + )), |
| 103 | + onTap: onSkipTap, |
| 104 | + ), |
| 105 | + Expanded( |
| 106 | + child: Container( |
| 107 | + child: Stack( |
| 108 | + children: [ |
| 109 | + Row( |
| 110 | + mainAxisAlignment: MainAxisAlignment.center, |
| 111 | + children: getDotsList(), |
| 112 | + ) |
| 113 | + ], |
| 114 | + ), |
| 115 | + ), |
| 116 | + ), |
| 117 | + GestureDetector( |
| 118 | + behavior: HitTestBehavior.translucent, |
| 119 | + child: Padding( |
| 120 | + padding: const EdgeInsets.only( |
| 121 | + top: 8, bottom: 8, left: 32, right: 24), |
| 122 | + child: rightWidget ?? |
| 123 | + Text( |
| 124 | + pageNumber == pagesCount - 1 |
| 125 | + ? doneText |
| 126 | + : rightText, |
| 127 | + style: rightStyle ?? |
| 128 | + const TextStyle( |
| 129 | + color: Colors.black, |
| 130 | + fontSize: 16, |
| 131 | + )), |
| 132 | + ), |
| 133 | + onTap: pageNumber == pagesCount - 1 ? onDoneTap : onNext, |
| 134 | + ), |
| 135 | + ], |
| 136 | + ), |
| 137 | + ) |
| 138 | + ], |
| 139 | + ), |
| 140 | + ), |
| 141 | + ); |
| 142 | + |
| 143 | + List<Widget> getDotsList() { |
| 144 | + final List<Widget> list = []; |
| 145 | + for (int i = 0; i < pagesCount; i++) { |
| 146 | + list.add(Container( |
| 147 | + width: dotWidth ?? 12, |
| 148 | + height: dotHeight ?? 12, |
| 149 | + margin: dotMargin ?? const EdgeInsets.symmetric(horizontal: 4), |
| 150 | + decoration: BoxDecoration( |
| 151 | + shape: dotShape, |
| 152 | + color: pageNumber == i |
| 153 | + ? activeColor ?? Colors.blue |
| 154 | + : defaultColor ?? Colors.grey.withOpacity(0.5), |
| 155 | + ), |
| 156 | + )); |
| 157 | + } |
| 158 | + return list; |
| 159 | + } |
| 160 | +} |
0 commit comments