Line data Source code
1 : import 'package:flutter/cupertino.dart';
2 :
3 : import '../bar.dart';
4 : import '../item.dart';
5 : import 'fixed_circle_tab_style.dart';
6 : import 'fixed_tab_style.dart';
7 : import 'flip_tab_style.dart';
8 : import 'react_circle_tab_style.dart';
9 : import 'react_tab_style.dart';
10 : import 'textin_tab_style.dart';
11 : import 'titled_tab_style.dart';
12 :
13 1 : DelegateBuilder supportedStyle(
14 : TabStyle style, {
15 : @required List<TabItem> items,
16 : Color color,
17 : Color activeColor,
18 : Color backgroundColor,
19 : Curve curve,
20 : }) {
21 1 : assert(items != null && items.isNotEmpty, 'items should not be empty');
22 : assert(
23 2 : ((style == TabStyle.fixed || style == TabStyle.fixedCircle) &&
24 2 : items.length.isOdd) ||
25 2 : (style != TabStyle.fixed && style != TabStyle.fixedCircle),
26 : 'item count should be an odd number when using fixed/fixedCircle');
27 : DelegateBuilder builder;
28 : switch (style) {
29 1 : case TabStyle.fixed:
30 1 : builder = FixedTabStyle(
31 : items: items,
32 : color: color,
33 : activeColor: activeColor,
34 2 : convexIndex: items.length ~/ 2,
35 : );
36 : break;
37 1 : case TabStyle.fixedCircle:
38 1 : builder = FixedCircleTabStyle(
39 : items: items,
40 : color: color,
41 : activeColor: activeColor,
42 : backgroundColor: backgroundColor,
43 2 : convexIndex: items.length ~/ 2,
44 : );
45 : break;
46 1 : case TabStyle.react:
47 1 : builder = ReactTabStyle(
48 : items: items,
49 : color: color,
50 : activeColor: activeColor,
51 : curve: curve,
52 : );
53 : break;
54 1 : case TabStyle.reactCircle:
55 1 : builder = ReactCircleTabStyle(
56 : items: items,
57 : color: color,
58 : activeColor: activeColor,
59 : backgroundColor: backgroundColor,
60 : curve: curve,
61 : );
62 : break;
63 1 : case TabStyle.textIn:
64 1 : builder = TextInTabStyle(
65 : items: items,
66 : color: color,
67 : activeColor: activeColor,
68 : curve: curve,
69 : );
70 : break;
71 1 : case TabStyle.titled:
72 1 : builder = TitledTabStyle(
73 : items: items,
74 : color: color,
75 : activeColor: activeColor,
76 : curve: curve,
77 : backgroundColor: backgroundColor,
78 : );
79 : break;
80 1 : case TabStyle.flip:
81 1 : builder = FlipTabStyle(
82 : items: items,
83 : color: color,
84 : activeColor: activeColor,
85 : curve: curve,
86 : );
87 : break;
88 : default:
89 0 : builder = ReactCircleTabStyle(
90 : items: items,
91 : color: color,
92 : activeColor: activeColor,
93 : backgroundColor: backgroundColor,
94 : curve: curve,
95 : );
96 : break;
97 : }
98 : return builder;
99 : }
|