Line data Source code
1 : import 'dart:ui'; 2 : 3 : import 'package:flutter/cupertino.dart'; 4 : import 'package:flutter/material.dart'; 5 : 6 : import '../../convex_bottom_bar.dart'; 7 : import 'blend_image_icon.dart'; 8 : import 'inner_builder.dart'; 9 : 10 : /// Convex shape is fixed center with circle. 11 : class FixedCircleTabStyle extends InnerBuilder { 12 : /// Color used as background of appbar and circle icon. 13 : final Color backgroundColor; 14 : 15 : /// Index of the centered convex shape. 16 : final int convexIndex; 17 : 18 : /// Margin of tab. 19 : final margin = (ACTION_LAYOUT_SIZE - ACTION_INNER_BUTTON_SIZE) / 4; 20 : 21 1 : FixedCircleTabStyle( 22 : {List<TabItem> items, 23 : Color activeColor, 24 : Color color, 25 : this.backgroundColor, 26 : this.convexIndex}) 27 1 : : super(items: items, activeColor: activeColor, color: color); 28 : 29 1 : @override 30 : Widget build(BuildContext context, int index, bool active) { 31 2 : if (index == convexIndex) { 32 2 : final item = items[index]; 33 1 : return Container( 34 1 : decoration: BoxDecoration( 35 : shape: BoxShape.circle, 36 1 : color: active ? activeColor : color, 37 : ), 38 : width: ACTION_LAYOUT_SIZE, 39 : height: ACTION_LAYOUT_SIZE, 40 2 : margin: EdgeInsets.all(margin), 41 1 : child: BlendImageIcon( 42 2 : active ? item.activeIcon ?? item.icon : item.icon, 43 : size: ACTION_INNER_BUTTON_SIZE, 44 2 : color: item.blend ? backgroundColor : null, 45 : ), 46 : ); 47 : } 48 2 : var item = items[index]; 49 1 : return Container( 50 1 : padding: EdgeInsets.only(bottom: 2), 51 1 : child: Column( 52 : mainAxisAlignment: MainAxisAlignment.end, 53 1 : children: <Widget>[ 54 1 : BlendImageIcon( 55 1 : active ? item.activeIcon ?? item.icon : item.icon, 56 2 : color: item.blend ? (active ? activeColor : color) : null, 57 : ), 58 1 : Text( 59 1 : item.title, 60 2 : style: TextStyle(color: active ? activeColor : color), 61 : ) 62 : ], 63 : ), 64 : ); 65 : } 66 : 67 1 : @override 68 : bool fixed() { 69 : return true; 70 : } 71 : }