Line data Source code
1 : import 'package:flutter/cupertino.dart';
2 : import 'package:flutter/material.dart';
3 :
4 : import '../../convex_bottom_bar.dart';
5 : import 'blend_image_icon.dart';
6 : import 'inner_builder.dart';
7 : import 'transition_container.dart';
8 :
9 : /// Tab item are flipped when click.
10 : class FlipTabStyle extends InnerBuilder {
11 : /// Curve for flip transition.
12 : final Curve curve;
13 :
14 : /// Create style builder.
15 1 : FlipTabStyle({
16 : List<TabItem> items,
17 : Color activeColor,
18 : Color color,
19 : this.curve,
20 1 : }) : super(items: items, activeColor: activeColor, color: color);
21 :
22 1 : @override
23 : Widget build(BuildContext context, int index, bool active) {
24 2 : var item = items[index];
25 : if (active) {
26 1 : return TransitionContainer.flip(
27 1 : duration: Duration(milliseconds: 500),
28 : height: ACTION_LAYOUT_SIZE,
29 1 : bottomChild: Container(
30 1 : padding: EdgeInsets.only(bottom: 2),
31 1 : child: Column(
32 : mainAxisAlignment: MainAxisAlignment.end,
33 1 : children: <Widget>[
34 1 : BlendImageIcon(
35 2 : item.activeIcon ?? item.icon,
36 2 : color: item.blend ? activeColor : null,
37 : size: ACTION_INNER_BUTTON_SIZE,
38 : ),
39 4 : Text(item.title, style: TextStyle(color: activeColor))
40 : ],
41 : ),
42 : ),
43 1 : topChild: Container(
44 : height: BAR_HEIGHT,
45 1 : child: Center(
46 4 : child: BlendImageIcon(item.icon, color: item.blend ? color : null),
47 : ),
48 : ),
49 1 : curve: curve,
50 : );
51 : }
52 1 : return Center(
53 4 : child: BlendImageIcon(item.icon, color: item.blend ? color : null),
54 : );
55 : }
56 : }
|